PageSourceSearch

https://seascape.network/203.64ca4606.async.js

js seascape.network collected 2026-10-06 07:39:36 UTC 512,424 bytes, 877 lines download raw bytes

vendor: 4,333 bytes, line 1
1(self.webpackChunkseascape_web=self.webpackChunkseascape_web||[]).push([[203],{24806:function(e){e.exports=function(){"use strict";var e=1e3,t=6e4,r=36e5,s="millisecond",i="second",n="minute",o="hour",a="day",c="week",l="month",h="quarter",u="year",d="date",p="Invalid Date",g=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,f=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,m={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],r=e%100;return"["+e+(t[(r-20)%10]||t[r]||t[0])+"]"}},w=function(e,t,r){var s=String(e);return!s||s.length>=t?e:""+Array(t+1-s.length).join(r)+e},y={s:w,z:function(e){var t=-e.utcOffset(),r=Math.abs(t),s=Math.floor(r/60),i=r%60;return(t<=0?"+":"-")+w(s,2,"0")+":"+w(i,2,"0")},m:function e(t,r){if(t.date()<r.date())return-e(r,t);var s=12*(r.year()-t.year())+(r.month()-t.month()),i=t.clone().add(s,l),n=r-i<0,o=t.clone().add(s+(n?-1:1),l);return+(-(s+(r-i)/(n?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:u,w:c,d:a,D:d,h:o,m:n,s:i,ms:s,Q:h}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},b="en",v={};v[b]=m;var C="$isDayjsObject",E=function(e){return e instanceof S||!(!e||!e[C])},N=function e(t,r,s){var i;if(!t)return b;if("string"==typeof t){var n=t.toLowerCase();v[n]&&(i=n),r&&(v[n]=r,i=n);var o=t.split("-");if(!i&&o.length>1)return e(o[0])}else{var a=t.name;v[a]=t,i=a}return!s&&i&&(b=i),i||!s&&b},I=function(e,t){if(E(e))return e.clone();var r="object"==typeof t?t:{};return r.date=e,r.args=arguments,new S(r)},A=y;A.l=N,A.i=E,A.w=function(e,t){return I(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var S=function(){function m(e){this.$L=N(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[C]=!0}var w=m.prototype;return w.parse=function(e){this.$d=function(e){var t=e.date,r=e.utc;if(null===t)return new Date(NaN);if(A.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var s=t.match(g);if(s){var i=s[2]-1||0,n=(s[7]||"0").substring(0,3);return r?new Date(Date.UTC(s[1],i,s[3]||1,s[4]||0,s[5]||0,s[6]||0,n)):new Date(s[1],i,s[3]||1,s[4]||0,s[5]||0,s[6]||0,n)}}return new Date(t)}(e),this.init()},w.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},w.$utils=function(){return A},w.isValid=function(){return!(this.$d.toString()===p)},w.isSame=function(e,t){var r=I(e);return this.startOf(t)<=r&&r<=this.endOf(t)},w.isAfter=function(e,t){return I(e)<this.startOf(t)},w.isBefore=function(e,t){return this.endOf(t)<I(e)},w.$g=function(e,t,r){return A.u(e)?this[t]:this.set(r,e)},w.unix=function(){return Math.floor(this.valueOf()/1e3)},w.valueOf=function(){return this.$d.getTime()},w.startOf=function(e,t){var r=this,s=!!A.u(t)||t,h=A.p(e),p=function(e,t){var i=A.w(r.$u?Date.UTC(r.$y,t,e):new Date(r.$y,t,e),r);return s?i:i.endOf(a)},g=function(e,t){return A.w(r.toDate()[e].apply(r.toDate("s"),(s?[0,0,0,0]:[23,59,59,999]).slice(t)),r)},f=this.$W,m=this.$M,w=this.$D,y="set"+(this.$u?"UTC":"");switch(h){case u:return s?p(1,0):p(31,11);case l:return s?p(1,m):p(0,m+1);case c:var b=this.$locale().weekStart||0,v=(f<b?f+7:f)-b;return p(s?w-v:w+(6-v),m);case a:case d:return g(y+"Hours",0);case o:return g(y+"Minutes",1);case n:return g(y+"Seconds",2);case i:return g(y+"Milliseconds",3);default:return this.clone()}},w.endOf=function(e){return this.startOf(e,!1)},w.$set=function(e,t){var r,c=A.p(e),h="set"+(this.$u?"UTC":""),p=(r={},r[a]=h+"Date",r[d]=h+"Date",r[l]=h+"Month",r[u]=h+"FullYear",r[o]=h+"Hours",r[n]=h+"Minutes",r[i]=h+"Seconds",r[s]=h+"Milliseconds",r)[c],g=c===a?this.$D+(t-this.$W):t;if(c===l||c===u){var f=this.clone().set(d,1);f.$d[p](g),f.init(),this.$d=f.set(d,Math.min(this.$D,f.daysInMonth())).$d}else p&&this.$d[p](g);return this.init(),this},w.set=function(e,t){return this.clone().$set(e,t)},w.get=function(e){return this[A.p(e)]()},w.add=function(s,h){var d,p=this;s=Number(s);
vendor: 4,430 bytes, line 1
1var g=A.p(h),f=function(e){var t=I(p);return A.w(t.date(t.date()+Math.round(e*s)),p)};if(g===l)return this.set(l,this.$M+s);if(g===u)return this.set(u,this.$y+s);if(g===a)return f(1);if(g===c)return f(7);var m=(d={},d[n]=t,d[o]=r,d[i]=e,d)[g]||1,w=this.$d.getTime()+s*m;return A.w(w,this)},w.subtract=function(e,t){return this.add(-1*e,t)},w.format=function(e){var t=this,r=this.$locale();if(!this.isValid())return r.invalidDate||p;var s=e||"YYYY-MM-DDTHH:mm:ssZ",i=A.z(this),n=this.$H,o=this.$m,a=this.$M,c=r.weekdays,l=r.months,h=r.meridiem,u=function(e,r,i,n){return e&&(e[r]||e(t,s))||i[r].slice(0,n)},d=function(e){return A.s(n%12||12,e,"0")},g=h||function(e,t,r){var s=e<12?"AM":"PM";return r?s.toLowerCase():s};return s.replace(f,(function(e,s){return s||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return A.s(t.$y,4,"0");case"M":return a+1;case"MM":return A.s(a+1,2,"0");case"MMM":return u(r.monthsShort,a,l,3);case"MMMM":return u(l,a);case"D":return t.$D;case"DD":return A.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return u(r.weekdaysMin,t.$W,c,2);case"ddd":return u(r.weekdaysShort,t.$W,c,3);case"dddd":return c[t.$W];case"H":return String(n);case"HH":return A.s(n,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return g(n,o,!0);case"A":return g(n,o,!1);case"m":return String(o);case"mm":return A.s(o,2,"0");case"s":return String(t.$s);case"ss":return A.s(t.$s,2,"0");case"SSS":return A.s(t.$ms,3,"0");case"Z":return i}return null}(e)||i.replace(":","")}))},w.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},w.diff=function(s,d,p){var g,f=this,m=A.p(d),w=I(s),y=(w.utcOffset()-this.utcOffset())*t,b=this-w,v=function(){return A.m(f,w)};switch(m){case u:g=v()/12;break;case l:g=v();break;case h:g=v()/3;break;case c:g=(b-y)/6048e5;break;case a:g=(b-y)/864e5;break;case o:g=b/r;break;case n:g=b/t;break;case i:g=b/e;break;default:g=b}return p?g:A.a(g)},w.daysInMonth=function(){return this.endOf(l).$D},w.$locale=function(){return v[this.$L]},w.locale=function(e,t){if(!e)return this.$L;var r=this.clone(),s=N(e,t,!0);return s&&(r.$L=s),r},w.clone=function(){return A.w(this.$d,this)},w.toDate=function(){return new Date(this.valueOf())},w.toJSON=function(){return this.isValid()?this.toISOString():null},w.toISOString=function(){return this.$d.toISOString()},w.toString=function(){return this.$d.toUTCString()},m}(),_=S.prototype;return I.prototype=_,[["$ms",s],["$s",i],["$m",n],["$H",o],["$W",a],["$M",l],["$y",u],["$D",d]].forEach((function(e){_[e[1]]=function(t){return this.$g(t,e[0],e[1])}})),I.extend=function(e,t){return e.$i||(e(t,S,I),e.$i=!0),I},I.locale=N,I.isDayjs=E,I.unix=function(e){return I(1e3*e)},I.en=v[b],I.Ls=v,I.p={},I}()},1788:function(e){e.exports=function(){"use strict";return{name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],r=e%100;return"["+e+(t[(r-20)%10]||t[r]||t[0])+"]"}}}()},69219:function(e){e.exports=function(){"use strict";return function(e,t,r){e=e||{};var s=t.prototype,i={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function n(e,t,r,i){return s.fromToBase(e,t,r,i)}r.en.relativeTime=i,s.fromToBase=function(t,s,n,o,a){for(var c,l,h,u=n.$locale().relativeTime||i,d=e.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],p=d.length,g=0;g<p;g+=1){var f=d[g];f.d&&(c=o?r(t).diff(n,f.d,!0):n.diff(t,f.d,!0));var m=(e.rounding||Math.round)(Math.abs(c));if(h=c>0,m<=f.r||!f.r){m<=1&&g>0&&(f=d[g-1]);var w=u[f.l];a&&(m=a(""+m)),l="string"==typeof w?w.replace("%d",m):w(m,s,f.l,h);break}}if(s)return l;var y=h?u.future:u.past;return"function"==typeof y?y(l):y.replace("%s",l)},s.to=function(e,t){return n(e,t,this,!0)},s.from=function(e,t){return n(e,t,this)};var o=function(e){return e.$u?r.utc():r()};s.toNow=function(e){return this.to(o(this),e)},s.fromNow=function(e){return this.from(o(this),e)}}}()},89790:function(e){e.exports=function(){"use strict";return function(e,t,r){r.updateLocale=function(e,t){var s=r.Ls[e];
1if(s)return(t?Object.keys(t):[]).forEach((function(e){s[e]=t[e]})),s}}}()},14967:function(e,t,r){"use strict";r.d(t,{Z:function(){return lg}});var s=r(17187),i=r.n(s),n=r(16411),o=r(22229),a=r(91011),c=r(38200),l=Object.defineProperty,h=(e,t,r)=>((e,t,r)=>t in e?l(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class u extends c.q{constructor(e){super(),this.opts=e,h(this,"protocol","wc"),h(this,"version",2)}}var d=Object.defineProperty,p=(e,t,r)=>((e,t,r)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class g extends c.q{constructor(e,t){super(),this.core=e,this.logger=t,p(this,"records",new Map)}}class f{constructor(e,t){this.logger=e,this.core=t}}class m extends c.q{constructor(e,t){super(),this.relayer=e,this.logger=t}}class w extends c.q{constructor(e){super()}}class y{constructor(e,t,r,s){this.core=e,this.logger=t,this.name=r}}Object.defineProperty;class b extends c.q{constructor(e,t){super(),this.relayer=e,this.logger=t}}class v extends c.q{constructor(e,t){super(),this.core=e,this.logger=t}}class C{constructor(e,t,r){this.core=e,this.logger=t,this.store=r}}class E{constructor(e,t){this.projectId=e,this.logger=t}}class N{constructor(e,t,r){this.core=e,this.logger=t,this.telemetryEnabled=r}}var I=Object.defineProperty,A=(e,t,r)=>((e,t,r)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class S{constructor(e){this.opts=e,A(this,"protocol","wc"),A(this,"version",2)}}class _{constructor(e){this.client=e}}var O=r(66736),P=r(85094),T=r(49392),k=r(43631),R=r(62873),x=r(65755);const U="2.23.2";let D={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${U}`};class $ extends Error{constructor(e,t={}){const r=t.cause instanceof $?t.cause.details:t.cause?.message?t.cause.message:t.details,s=t.cause instanceof $&&t.cause.docsPath||t.docsPath,i=D.getDocsUrl?.({...t,docsPath:s});super([e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...i?[`Docs: ${i}`]:[],...r?[`Details: ${r}`]:[],...D.version?[`Version: ${D.version}`]:[]].join("\n"),t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{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,"metaMessages",{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,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=r,this.docsPath=s,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=U}walk(e){return M(this,e)}}function M(e,t){return t?.(e)?e:e&&"object"==typeof e&&"cause"in e&&void 0!==e.cause?M(e.cause,t):t?null:e}function L(e,{strict:t=!0}={}){return!!e&&("string"==typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}class j extends ${constructor({size:e,targetSize:t,type:r}){super(`${r.charAt(0).toUpperCase()}${r.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}function B(e,{dir:t,size:r=32}={}){return"string"==typeof e?function(e,{dir:t,size:r=32}={}){if(null===r)return e;const s=e.replace("0x","");if(s.length>2*r)throw new j({size:Math.ceil(s.length/2),targetSize:r,type:"hex"});return`0x${s["right"===t?"padEnd":"padStart"](2*r,"0")}`}(e,{dir:t,size:r}):function(e,{dir:t,size:r=32}={}){if(null===r)return e;if(e.length>r)throw new j({size:e.length,targetSize:r,type:"bytes"});const s=new Uint8Array(r);for(let i=0;i<r;i++){const n="right"===t;s[n?i:r-i-1]=e[n?i:e.length-i-1]}return s}(e,{dir:t,size:r})}class q extends ${constructor({max:e,min:t,signed:r,size:s,value:i}){super(`Number "${i}" is not in safe ${s?`${8*s}-bit ${r?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class W extends ${constructor({givenSize:e,maxSize:t}
1){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function F(e){return L(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function H(e,{size:t}){if(F(e)>t)throw new W({givenSize:F(e),maxSize:t})}function z(e,t={}){const{signed:r}=t;t.size&&H(e,{size:t.size});const s=BigInt(e);if(!r)return s;const i=(e.length-2)/2;return s<=(1n<<8n*BigInt(i)-1n)-1n?s:s-BigInt(`0x${"f".padStart(2*i,"f")}`)-1n}function V(e,t={}){return Number(z(e,t))}const K=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function J(e,t={}){return"number"==typeof e||"bigint"==typeof e?Y(e,t):"string"==typeof e?function(e,t={}){const r=X.encode(e);return G(r,t)}(e,t):"boolean"==typeof e?function(e,t={}){const r=`0x${Number(e)}`;if("number"==typeof t.size)return H(r,{size:t.size}),B(r,{size:t.size});return r}(e,t):G(e,t)}function G(e,t={}){let r="";for(let t=0;t<e.length;t++)r+=K[e[t]];const s=`0x${r}`;return"number"==typeof t.size?(H(s,{size:t.size}),B(s,{dir:"right",size:t.size})):s}function Y(e,t={}){const{signed:r,size:s}=t,i=BigInt(e);let n;s?n=r?(1n<<8n*BigInt(s)-1n)-1n:2n**(8n*BigInt(s))-1n:"number"==typeof e&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o="bigint"==typeof n&&r?-n-1n:0;if(n&&i>n||i<o){const t="bigint"==typeof e?"n":"";throw new q({max:n?`${n}${t}`:void 0,min:`${o}${t}`,signed:r,size:s,value:`${e}${t}`})}const a=`0x${(r&&i<0?(1n<<BigInt(8*s))+BigInt(i):i).toString(16)}`;return s?B(a,{size:s}):a}const X=new TextEncoder;const Z=new TextEncoder;function Q(e,t={}){return"number"==typeof e||"bigint"==typeof e?function(e,t){const r=Y(e,t);return ae(r)}(e,t):"boolean"==typeof e?function(e,t={}){const r=new Uint8Array(1);if(r[0]=Number(e),"number"==typeof t.size)return H(r,{size:t.size}),B(r,{size:t.size});return r}(e,t):L(e)?ae(e,t):ce(e,t)}const ee=48,te=57,re=65,se=70,ie=97,ne=102;function oe(e){return e>=ee&&e<=te?e-ee:e>=re&&e<=se?e-(re-10):e>=ie&&e<=ne?e-(ie-10):void 0}function ae(e,t={}){let r=e;t.size&&(H(r,{size:t.size}),r=B(r,{dir:"right",size:t.size}));let s=r.slice(2);s.length%2&&(s=`0${s}`);const i=s.length/2,n=new Uint8Array(i);for(let e=0,t=0;e<i;e++){const r=oe(s.charCodeAt(t++)),i=oe(s.charCodeAt(t++));if(void 0===r||void 0===i)throw new $(`Invalid byte sequence ("${s[t-2]}${s[t-1]}" in "${s}").`);n[e]=16*r+i}return n}function ce(e,t={}){const r=Z.encode(e);return"number"==typeof t.size?(H(r,{size:t.size}),B(r,{dir:"right",size:t.size})):r}var le=r(47305);const he=BigInt(2**32-1),ue=BigInt(32);function de(e,t=!1){return t?{h:Number(e&he),l:Number(e>>ue&he)}:{h:0|Number(e>>ue&he),l:0|Number(e&he)}}function pe(e,t=!1){let r=new Uint32Array(e.length),s=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:n,l:o}=de(e[i],t);[r[i],s[i]]=[n,o]}return[r,s]}const ge=(e,t,r)=>e<<r|t>>>32-r,fe=(e,t,r)=>t<<r|e>>>32-r,me=(e,t,r)=>t<<r-32|e>>>64-r,we=(e,t,r)=>e<<r-32|t>>>64-r;var ye=r(62216);const be=[],ve=[],Ce=[],Ee=BigInt(0),Ne=BigInt(1),Ie=BigInt(2),Ae=BigInt(7),Se=BigInt(256),_e=BigInt(113);for(let e=0,t=Ne,r=1,s=0;e<24;e++){[r,s]=[s,(2*r+3*s)%5],be.push(2*(5*s+r)),ve.push((e+1)*(e+2)/2%64);let i=Ee;for(let e=0;e<7;e++)t=(t<<Ne^(t>>Ae)*_e)%Se,t&Ie&&(i^=Ne<<(Ne<<BigInt(e))-Ne);Ce.push(i)}const[Oe,Pe]=pe(Ce,!0),Te=(e,t,r)=>r>32?me(e,t,r):ge(e,t,r),ke=(e,t,r)=>r>32?we(e,t,r):fe(e,t,r);class Re extends ye.kb{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,(0,le.k8)(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=(0,ye.Jq)(this.state)}keccak(){ye.iA||(0,ye.l1)(this.state32),function(e,t=24){const r=new Uint32Array(10);for(let s=24-t;s<24;s++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const s=(t+8)%10,i=(t+2)%10,n=r[i],o=r[i+1],a=Te(n,o,1)^r[s],c=ke(n,o,1)^r[s+1];for(let r=0;r<50;r+=10)e[t+r]^=a,e[t+r+1]^=c}let t=e[2],i=e[3];for(let r=0;r<24;r++){const s=ve[r],n=Te(t,i,s),o=ke(t,i,s),a=be[r];t=e[a],i=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let s=0;s<10;s++)r[s]=e[t+s];for(let s=0;s<10;s++)e[t+s]^=~r[(s+2)%10]&r[(s+4)%10]}e[0]^=Oe[s],e[1]^=Pe[s]}r.fill(0)}(this.state32,this.rounds),ye.iA||(0,ye.l1)(this.state32),this.posOut=0,this.pos=0}update(e){(0,le.$h)(this);const{blockLen:t,state:r}=this,s=(e=(0,ye.O0)(e)).length;for(let i=0;i<s;){const n=Math.min(t-this.pos,s-i);for(let t=0;t<n;t++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,0!=(128&t)&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){(0,le.$h)(this,!1),(0,le.gk)(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const n=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+n),s),this.posOut+=n,s+=n}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return(0,le.k8)(e),this.xofInto(new Uint8Array(e))}digestInto(e){if((0,le.eB)(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,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:n}=this;return e||(e=new Re(t,r,s,n,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=n,e.destroyed=this.destroyed,e}}const xe=(e,t,r)=>(0,ye.hE)((()=>new Re(t,e,r))),Ue=xe(1,136,32);function De(e,t){const r=t||"hex",s=Ue(L(e,{strict:!1})?Q(e):e);return"bytes"===r?s:J(s)}class $e extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const Me=new $e(8192);function Le(e,t){if(Me.has(`${e}.${t}`))return Me.get(`${e}.${t}`);const r=t?`${t}${e.toLowerCase()}`:e.substring(2).toLowerCase(),s=De(ce(r),"bytes"),i=(t?r.substring(`${t}0x`.length):r).split("");for(let e=0;e<40;e+=2)s[e>>1]>>4>=8&&i[e]&&(i[e]=i[e].toUpperCase()),(15&s[e>>1])>
1=8&&i[e+1]&&(i[e+1]=i[e+1].toUpperCase());const n=`0x${i.join("")}`;return Me.set(`${e}.${t}`,n),n}function je(e){if(0===e||1===e)return e;if(27===e)return 0;if(28===e)return 1;throw new Error("Invalid yParityOrV value")}async function Be({hash:e,signature:t}){return s=await async function({hash:e,signature:t}){const s=L(e)?e:J(e),{secp256k1:i}=await r.e(1610).then(r.bind(r,1610)),n=(()=>{if("object"==typeof t&&"r"in t&&"s"in t){const{r:e,s:r,v:s,yParity:n}=t,o=je(Number(n??s));return new i.Signature(z(e),z(r)).addRecoveryBit(o)}const e=L(t)?t:J(t),r=je(V(`0x${e.slice(130)}`));return i.Signature.fromCompact(e.substring(2,130)).addRecoveryBit(r)})();return`0x${n.recoverPublicKey(s.substring(2)).toHex(!1)}`}({hash:e,signature:t}),Le(`0x${De(`0x${s.substring(4)}`).substring(26)}`);var s}var qe=r(39578),We=r(69391),Fe=r(37968),He=r(34155),ze=r(48764).Buffer;const Ve=":";function Ke(e){const[t,r]=e.split(Ve);return{namespace:t,reference:r}}function Je(e,t){return e.includes(":")?[e]:t.chains||[]}var Ge=Object.defineProperty,Ye=Object.defineProperties,Xe=Object.getOwnPropertyDescriptors,Ze=Object.getOwnPropertySymbols,Qe=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable,tt=(e,t,r)=>t in e?Ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,rt=(e,t)=>{for(var r in t||(t={}))Qe.call(t,r)&&tt(e,r,t[r]);if(Ze)for(var r of Ze(t))et.call(t,r)&&tt(e,r,t[r]);return e};const st="react-native",it="node",nt="browser",ot="unknown",at="js";function ct(){return typeof He<"u"&&typeof He.versions<"u"&&typeof He.versions.node<"u"}function lt(){return!(0,R.getDocument)()&&!!(0,R.getNavigator)()&&"ReactNative"===navigator.product}function ht(){return!ct()&&!!(0,R.getNavigator)()&&!!(0,R.getDocument)()}function ut(){return lt()?st:ct()?it:ht()?nt:ot}function dt(){var e;try{return lt()&&typeof r.g<"u"&&typeof(null==r.g?void 0:r.g.Application)<"u"?null==(e=r.g.Application)?void 0:e.applicationId:void 0}catch{return}}function pt(e){var t,r;const s=gt();try{return null!=e&&e.url&&s.url&&new URL(e.url).host!==new URL(s.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${e.url} differs from the actual page url:${s.url}. This is probably unintended and can lead to issues.`),e.url=s.url),null!=(t=e?.icons)&&t.length&&e.icons.length>0&&(e.icons=e.icons.filter((e=>""!==e))),((e,t)=>Ye(e,Xe(t)))(rt(rt({},s),e),{url:e?.url||s.url,name:e?.name||s.name,description:e?.description||s.description,icons:null!=(r=e?.icons)&&r.length&&e.icons.length>0?e.icons:s.icons})}catch(t){return console.warn("Error populating app metadata",t),e||s}}function gt(){return(0,x.D)()||{name:"",description:"",url:"",icons:[""]}}function ft(e,t,s){const i=function(){if(ut()===st&&typeof r.g<"u"&&typeof(null==r.g?void 0:r.g.Platform)<"u"){const{OS:e,Version:t}=r.g.Platform;return[e,t].join("-")}const e=(0,k.qY)();if(null===e)return"unknown";const t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return"browser"===e.type?[t,e.name,e.version].join("-"):[t,e.version].join("-")}(),n=function(){var e;const t=ut();
1return t===nt?[t,(null==(e=(0,R.getLocation)())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),[at,s].join("-"),i,n].join("/")}function mt({protocol:e,version:t,relayUrl:r,sdkVersion:s,auth:i,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=r.split("?"),h={auth:i,ua:ft(e,t,s),projectId:n,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},u=function(e,t){const r=new URLSearchParams(e);for(const e of Object.keys(t).sort())if(t.hasOwnProperty(e)){const s=t[e];void 0!==s&&r.set(e,s)}return r.toString()}(l[1]||"",h);return l[0]+"?"+u}function wt(e,t){return e.filter((e=>t.includes(e))).length===e.length}function yt(e){return Object.fromEntries(e.entries())}function bt(e){return new Map(Object.entries(e))}function vt(e=O.FIVE_MINUTES,t){const r=(0,O.toMiliseconds)(e||O.FIVE_MINUTES);let s,i,n,o;return{resolve:e=>{n&&s&&(clearTimeout(n),s(e),o=Promise.resolve(e))},reject:e=>{n&&i&&(clearTimeout(n),i(e))},done:()=>new Promise(((e,a)=>{if(o)return e(o);n=setTimeout((()=>{const e=new Error(t);o=Promise.reject(e),a(e)}),r),s=e,i=a}))}}function Ct(e,t,r){return new Promise((async(s,i)=>{const n=setTimeout((()=>i(new Error(r))),t);try{s(await e)}catch(e){i(e)}clearTimeout(n)}))}function Et(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${e}`)}function Nt(e){const[t,r]=e.split(":"),s={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof r)s.topic=r;else{if("id"!==t||!Number.isInteger(Number(r)))throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${r}`);s.id=Number(r)}return s}function It(e,t){return(0,O.fromMiliseconds)((t||Date.now())+(0,O.toMiliseconds)(e))}function At(e){return Date.now()>=(0,O.toMiliseconds)(e)}function St(e,t){return`${e}${t?`:${t}`:""}`}function _t(e=[],t=[]){return[...new Set([...e,...t])]}async function Ot({id:e,topic:t,wcDeepLink:s}){var i;try{if(!s)return;const n=("string"==typeof s?JSON.parse(s):s)?.href;if("string"!=typeof n)return;const o=function(e,t,r){const s=`requestId=${t}&sessionTopic=${r}`;e.endsWith("/")&&(e=e.slice(0,-1));let i=`${e}`;if(e.startsWith("https://t.me")){i=`${i}${e.includes("?")?"&startapp=":"?startapp="}${function(e,t=!1){const r=ze.from(e).toString("base64");return t?r.replace(/[=]/g,""):r}(s,!0)}`}else i=`${i}/wc?${s}`;return i}(n,e,t),a=ut();if(a===nt){if(null==(i=(0,R.getDocument)())||!i.hasFocus())return void console.warn("Document does not have focus, skipping deeplink.");!function(e){let t="_self";!function(){try{return window.self!==window.top}catch{return!1}}()?(typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)||e.startsWith("https://")||e.startsWith("http://"))&&(t="_blank"):t="_top",window.open(e,t,"noreferrer noopener")}(o)}else a===st&&typeof(null==r.g?void 0:r.g.Linking)<"u"&&await r.g.Linking.openURL(o)}catch(e){console.error(e)}}function Pt(e,t){if(!e.includes(t))return null;const r=e.split(/([&,?,=])/),s=r.indexOf(t);return r[s+2]}function Tt(){return typeof crypto<"u"&&null!=crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))}function kt(){return typeof He<"u"&&"true"==={NODE_ENV:"production",PUBLIC_PATH:"/"}.IS_VITEST}function Rt(e){return ze.from(e,"base64").toString("utf-8")}function xt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ut(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Dt(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");xt(e.outputLen),xt(e.blockLen)}function $t(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Mt(e,t){Ut(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}const Lt=BigInt(2**32-1),jt=BigInt(32);function Bt(e,t=!1){return t?{h:Number(e&Lt),l:Number(e>>jt&Lt)}:{h:0|Number(e>>jt&Lt),l:0|Number(e&Lt)}}const qt="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function Wt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Ft(e,t){return e<<32-t|e>>>t}const Ht=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function zt(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Vt(e){for(let t=0;t<e.length;t++)e[t]=zt(e[t])}function Kt(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),Ut(e),e}class Jt{clone(){return this._cloneInto()}}function Gt(e){const t=t=>e().update(Kt(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function Yt(e=32){if(qt&&"function"==typeof qt.getRandomValues)return qt.getRandomValues(new Uint8Array(e));if(qt&&"function"==typeof qt.randomBytes)return qt.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}const Xt=[],Zt=[],Qt=[],er=BigInt(0),tr=BigInt(1),rr=BigInt(2),sr=BigInt(7),ir=BigInt(256),nr=BigInt(113);for(let e=0,t=tr,r=1,s=0;e<24;e++){[r,s]=[s,(2*r+3*s)%5],Xt.push(2*(5*s+r)),Zt.push((e+1)*(e+2)/2%64);let i=er;for(let e=0;e<7;e++)t=(t<<tr^(t>>sr)*nr)%ir,t&rr&&(i^=tr<<(tr<<BigInt(e))-tr);Qt.push(i)}const[or,ar]=function(e,t=!1){let r=new Uint32Array(e.length),s=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:n,l:o}=Bt(e[i],t);[r[i],s[i]]=[n,o]}return[r,s]}(Qt,!0),cr=(e,t,r)=>r>32?((e,t,r)=>t<<r-32|e>>>64-r)(e,t,r):((e,t,r)=>e<<r|t>>>32-r)(e,t,r),lr=(e,t,r)=>r>32?((e,t,r)=>e<<r-32|t>>>64-r)(e,t,r):((e,t,r)=>t<<r|e>>>32-r)(e,t,r);class hr extends Jt{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,xt(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var n;this.state=new Uint8Array(200),this.state32=(n=this.state,new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)))}
1keccak(){Ht||Vt(this.state32),function(e,t=24){const r=new Uint32Array(10);for(let s=24-t;s<24;s++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const s=(t+8)%10,i=(t+2)%10,n=r[i],o=r[i+1],a=cr(n,o,1)^r[s],c=lr(n,o,1)^r[s+1];for(let r=0;r<50;r+=10)e[t+r]^=a,e[t+r+1]^=c}let t=e[2],i=e[3];for(let r=0;r<24;r++){const s=Zt[r],n=cr(t,i,s),o=lr(t,i,s),a=Xt[r];t=e[a],i=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let s=0;s<10;s++)r[s]=e[t+s];for(let s=0;s<10;s++)e[t+s]^=~r[(s+2)%10]&r[(s+4)%10]}e[0]^=or[s],e[1]^=ar[s]}r.fill(0)}(this.state32,this.rounds),Ht||Vt(this.state32),this.posOut=0,this.pos=0}update(e){$t(this);const{blockLen:t,state:r}=this,s=(e=Kt(e)).length;for(let i=0;i<s;){const n=Math.min(t-this.pos,s-i);for(let t=0;t<n;t++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,0!=(128&t)&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){$t(this,!1),Ut(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const n=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+n),s),this.posOut+=n,s+=n}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return xt(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Mt(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,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:n}=this;return e||(e=new hr(t,r,s,n,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=s,e.enableXOF=n,e.destroyed=this.destroyed,e}}const ur=((e,t,r)=>Gt((()=>new hr(t,e,r))))(1,136,32),dr="https://rpc.walletconnect.org/v1";function pr(e){const t=`�Ethereum Signed Message:\n${e.length}`,r=(new TextEncoder).encode(t+e);return"0x"+ze.from(ur(r)).toString("hex")}async function gr(e,t,r,s,i,n){switch(r.t){case"eip191":return await async function(e,t,r){return(await Be({hash:pr(t),signature:r})).toLowerCase()===e.toLowerCase()}(e,t,r.s);case"eip1271":return await async function(e,t,r,s,i,n){const o=Ke(s);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${s}`);try{const o="0x1626ba7e",a="0000000000000000000000000000000000000000000000000000000000000040",c="0000000000000000000000000000000000000000000000000000000000000041",l=r.substring(2),h=o+pr(t).substring(2)+a+c+l,u=await fetch(`${n||dr}/?chainId=${s}&projectId=${i}`,{method:"POST",body:JSON.stringify({id:fr(),jsonrpc:"2.0",method:"eth_call",params:[{to:e,data:h},"latest"]})}),{result:d}=await u.json();return!!d&&d.slice(0,o.length).toLowerCase()===o.toLowerCase()}catch(e){return console.error("isValidEip1271Signature: ",e),!1}}(e,t,r.s,s,i,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${r.t}`)}}function fr(){return Date.now()+Math.floor(1e3*Math.random())}var mr=Object.defineProperty,wr=Object.defineProperties,yr=Object.getOwnPropertyDescriptors,br=Object.getOwnPropertySymbols,vr=Object.prototype.hasOwnProperty,Cr=Object.prototype.propertyIsEnumerable,Er=(e,t,r)=>t in e?mr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Nr=(e,t)=>{for(var r in t||(t={}))vr.call(t,r)&&Er(e,r,t[r]);if(br)for(var r of br(t))Cr.call(t,r)&&Er(e,r,t[r]);return e},Ir=(e,t)=>wr(e,yr(t));const Ar=e=>e?.split(":"),Sr=e=>{const t=e&&Ar(e);if(t)return t[2]+":"+t[3]},_r=e=>{const t=e&&Ar(e);if(t)return t.pop()};async function Or(e){const{cacao:t,projectId:r}=e,{s:s,p:i}=t,n=Pr(i,i.iss),o=_r(i.iss);return await gr(o,n,s,Sr(i.iss),r)}const Pr=(e,t)=>{const r=`${e.domain} wants you to sign in with your Ethereum account:`,s=_r(t);if(!e.aud&&!e.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let i=e.statement||void 0;const n=`URI: ${e.aud||e.uri}
1`,o=`Version: ${e.version}`,a=`Chain ID: ${(e=>{const t=e&&Ar(e);if(t)return e.includes("did:pkh:")?t[3]:t[1]})(t)}`,c=`Nonce: ${e.nonce}`,l=`Issued At: ${e.iat}`,h=e.exp?`Expiration Time: ${e.exp}`:void 0,u=e.nbf?`Not Before: ${e.nbf}`:void 0,d=e.requestId?`Request ID: ${e.requestId}`:void 0,p=e.resources?`Resources:${e.resources.map((e=>`\n- ${e}`)).join("")}`:void 0,g=Br(e.resources);if(g){i=Mr(i,xr(g))}return[r,s,"",i,"",n,o,a,c,l,h,u,d,p].filter((e=>null!=e)).join("\n")};function Tr(e){if(!e)throw new Error("No recap provided, value is undefined");if(!e.att)throw new Error("No `att` property found");const t=Object.keys(e.att);if(null==t||!t.length)throw new Error("No resources found in `att` property");t.forEach((t=>{const r=e.att[t];if(Array.isArray(r))throw new Error(`Resource must be an object: ${t}`);if("object"!=typeof r)throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(r).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(r).forEach((e=>{const t=r[e];if(!Array.isArray(t))throw new Error(`Ability limits ${e} must be an array of objects, found: ${t}`);if(!t.length)throw new Error(`Value of ${e} is empty array, must be an array with objects`);t.forEach((t=>{if("object"!=typeof t)throw new Error(`Ability limits (${e}) must be an array of objects, found: ${t}`)}))}))}))}function kr(e,t,r={}){t=t?.sort(((e,t)=>e.localeCompare(t)));const s=t.map((t=>({[`${e}/${t}`]:[r]})));return Object.assign({},...s)}function Rr(e){return Tr(e),`urn:recap:${function(e){return ze.from(JSON.stringify(e)).toString("base64")}(e).replace(/=/g,"")}`}function xr(e){const t=function(e){return JSON.parse(ze.from(e,"base64").toString("utf-8"))}(e.replace("urn:recap:",""));return Tr(t),t}function Ur(e,t,r){const s=function(e,t,r,s={}){return r?.sort(((e,t)=>e.localeCompare(t))),{att:{[e]:kr(t,r,s)}}}(e,t,r);return Rr(s)}function Dr(e){return e&&e.includes("urn:recap:")}function $r(e,t){const r=function(e,t){Tr(e),Tr(t);const r=Object.keys(e.att).concat(Object.keys(t.att)).sort(((e,t)=>e.localeCompare(t))),s={att:{}};return r.forEach((r=>{var i,n;Object.keys((null==(i=e.att)?void 0:i[r])||{}).concat(Object.keys((null==(n=t.att)?void 0:n[r])||{})).sort(((e,t)=>e.localeCompare(t))).forEach((i=>{var n,o;s.att[r]=Ir(Nr({},s.att[r]),{[i]:(null==(n=e.att[r])?void 0:n[i])||(null==(o=t.att[r])?void 0:o[i])})}))})),s}(xr(e),xr(t));return Rr(r)}function Mr(e="",t){Tr(t);const r="I further authorize the stated URI to perform the following actions on my behalf: ";if(e.includes(r))return e;const s=[];let i=0;Object.keys(t.att).forEach((e=>{const r=Object.keys(t.att[e]).map((e=>({ability:e.split("/")[0],action:e.split("/")[1]})));r.sort(((e,t)=>e.action.localeCompare(t.action)));const n={};r.forEach((e=>{n[e.ability]||(n[e.ability]=[]),n[e.ability].push(e.action)}));const o=Object.keys(n).map((t=>(i++,`(${i}) '${t}': '${n[t].join("', '")}' for '${e}'.`)));s.push(o.join(", ").replace(".,","."))}));return`${e?e+" ":""}${`${r}${s.join(" ")}`}`}function Lr(e){var t;const r=xr(e);Tr(r);const s=null==(t=r.att)?void 0:t.eip155;return s?Object.keys(s).map((e=>e.split("/")[1])):[]}function jr(e){const t=xr(e);Tr(t);const r=[];return Object.values(t.att).forEach((e=>{Object.values(e).forEach((e=>{var t;null!=(t=e?.[0])&&t.chains&&r.push(e[0].chains)}))})),[...new Set(r.flat())]}function Br(e){if(!e)return;const t=e?.[e.length-1];return Dr(t)?t:void 0}function qr(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Wr(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Fr(e,...t){if(!Wr(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Hr(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function zr(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}const Vr=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(!(68===new Uint8Array(new Uint32Array([287454020]).buffer)[0]))throw new Error("Non little-endian hardware is not supported");function Kr(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!Wr(e))throw new Error("Uint8Array expected, got "+typeof e);e=Yr(e)}return e}function Jr(e,t,r=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(r&&!function(e){return e.byteOffset%4==0}(t))throw new Error("invalid output, must be aligned");return t}function Gr(e,t,r,s){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,s);const i=BigInt(32),n=BigInt(4294967295),o=Number(r>>i&n),a=Number(r&n),c=s?4:0,l=s?0:4;e.setUint32(t+c,o,s),e.setUint32(t+l,a,s)}function Yr(e){return Uint8Array.from(e)}function Xr(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const Zr=e=>Uint8Array.from(e.split("").map((e=>
1e.charCodeAt(0)))),Qr=Zr("expand 16-byte k"),es=Zr("expand 32-byte k"),ts=Vr(Qr),rs=Vr(es);function ss(e,t){return e<<t|e>>>32-t}function is(e){return e.byteOffset%4==0}const ns=2**32-1,os=new Uint32Array;const as=(e,t)=>255&e[t++]|(255&e[t++])<<8;class cs{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,Fr(e=Kr(e),32);const t=as(e,0),r=as(e,2),s=as(e,4),i=as(e,6),n=as(e,8),o=as(e,10),a=as(e,12),c=as(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|r<<3),this.r[2]=7939&(r>>>10|s<<6),this.r[3]=8191&(s>>>7|i<<9),this.r[4]=255&(i>>>4|n<<12),this.r[5]=n>>>1&8190,this.r[6]=8191&(n>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=as(e,16+2*t)}process(e,t,r=!1){const s=r?0:2048,{h:i,r:n}=this,o=n[0],a=n[1],c=n[2],l=n[3],h=n[4],u=n[5],d=n[6],p=n[7],g=n[8],f=n[9],m=as(e,t+0),w=as(e,t+2),y=as(e,t+4),b=as(e,t+6),v=as(e,t+8),C=as(e,t+10),E=as(e,t+12),N=as(e,t+14);let I=i[0]+(8191&m),A=i[1]+(8191&(m>>>13|w<<3)),S=i[2]+(8191&(w>>>10|y<<6)),_=i[3]+(8191&(y>>>7|b<<9)),O=i[4]+(8191&(b>>>4|v<<12)),P=i[5]+(v>>>1&8191),T=i[6]+(8191&(v>>>14|C<<2)),k=i[7]+(8191&(C>>>11|E<<5)),R=i[8]+(8191&(E>>>8|N<<8)),x=i[9]+(N>>>5|s),U=0,D=U+I*o+A*(5*f)+S*(5*g)+_*(5*p)+O*(5*d);U=D>>>13,D&=8191,D+=P*(5*u)+T*(5*h)+k*(5*l)+R*(5*c)+x*(5*a),U+=D>>>13,D&=8191;let $=U+I*a+A*o+S*(5*f)+_*(5*g)+O*(5*p);U=$>>>13,$&=8191,$+=P*(5*d)+T*(5*u)+k*(5*h)+R*(5*l)+x*(5*c),U+=$>>>13,$&=8191;let M=U+I*c+A*a+S*o+_*(5*f)+O*(5*g);U=M>>>13,M&=8191,M+=P*(5*p)+T*(5*d)+k*(5*u)+R*(5*h)+x*(5*l),U+=M>>>13,M&=8191;let L=U+I*l+A*c+S*a+_*o+O*(5*f);U=L>>>13,L&=8191,L+=P*(5*g)+T*(5*p)+k*(5*d)+R*(5*u)+x*(5*h),U+=L>>>13,L&=8191;let j=U+I*h+A*l+S*c+_*a+O*o;U=j>>>13,j&=8191,j+=P*(5*f)+T*(5*g)+k*(5*p)+R*(5*d)+x*(5*u),U+=j>>>13,j&=8191;let B=U+I*u+A*h+S*l+_*c+O*a;U=B>>>13,B&=8191,B+=P*o+T*(5*f)+k*(5*g)+R*(5*p)+x*(5*d),U+=B>>>13,B&=8191;let q=U+I*d+A*u+S*h+_*l+O*c;U=q>>>13,q&=8191,q+=P*a+T*o+k*(5*f)+R*(5*g)+x*(5*p),U+=q>>>13,q&=8191;let W=U+I*p+A*d+S*u+_*h+O*l;U=W>>>13,W&=8191,W+=P*c+T*a+k*o+R*(5*f)+x*(5*g),U+=W>>>13,W&=8191;let F=U+I*g+A*p+S*d+_*u+O*h;U=F>>>13,F&=8191,F+=P*l+T*c+k*a+R*o+x*(5*f),U+=F>>>13,F&=8191;let H=U+I*f+A*g+S*p+_*d+O*u;U=H>>>13,H&=8191,H+=P*h+T*l+k*c+R*a+x*o,U+=H>>>13,H&=8191,U=(U<<2)+U|0,U=U+D|0,D=8191&U,U>>>=13,$+=U,i[0]=D,i[1]=$,i[2]=M,i[3]=L,i[4]=j,i[5]=B,i[6]=q,i[7]=W,i[8]=F,i[9]=H}finalize(){const{h:e,pad:t}=this,r=new Uint16Array(10);let s=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=s,s=e[t]>>>13,e[t]&=8191;e[0]+=5*s,s=e[0]>>>13,e[0]&=8191,e[1]+=s,s=e[1]>>>13,e[1]&=8191,e[2]+=s,r[0]=e[0]+5,s=r[0]>>>13,r[0]&=8191;for(let t=1;t<10;t++)r[t]=e[t]+s,s=r[t]>>>13,r[t]&=8191;r[9]-=8192;let i=(1^s)-1;for(let e=0;e<10;e++)r[e]&=i;i=~i;for(let t=0;t<10;t++)e[t]=e[t]&i|r[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let n=e[0]+t[0];e[0]=65535&n;for(let r=1;r<8;r++)n=(e[r]+t[r]|0)+(n>>>16)|0,e[r]=65535&n;Xr(r)}update(e){Hr(this);const{buffer:t,blockLen:r}=this,s=(e=Kr(e)).length;for(let i=0;i<s;){const n=Math.min(r-this.pos,s-i);if(n!==r)t.set(e.subarray(i,i+n),this.pos),this.pos+=n,i+=n,this.pos===r&&(this.process(t,0,!1),this.pos=0);else for(;r<=s-i;i+=r)this.process(e,i)}return this}destroy(){Xr(this.h,this.r,this.buffer,this.pad)}digestInto(e){Hr(this),function(e,t){Fr(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}(e,this),this.finished=!0;const{buffer:t,h:r}=this;let{pos:s}=this;if(s){for(t[s++]=1;s<16;s++)t[s]=0;this.process(t,0,!0)}this.finalize();let i=0;for(let t=0;t<8;t++)e[i++]=r[t]>>>0,e[i++]=r[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}}const ls=function(e){const t=(t,r)=>e(r).update(Kr(t)).digest(),r=e(new Uint8Array(32));return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=t=>e(t),t}((e=>
1new cs(e)));const hs=function(e,t){const{allowShortKeys:r,extendNonceFn:s,counterLength:i,counterRight:n,rounds:o}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return qr(i),qr(o),zr(n),zr(r),(t,a,c,l,h=0)=>{Fr(t),Fr(a),Fr(c);const u=c.length;if(void 0===l&&(l=new Uint8Array(u)),Fr(l),qr(h),h<0||h>=ns)throw new Error("arx: counter overflow");if(l.length<u)throw new Error(`arx: output (${l.length}) is shorter than data (${u})`);const d=[];let p,g,f=t.length;if(32===f)d.push(p=Yr(t)),g=rs;else{if(16!==f||!r)throw new Error(`arx: invalid 32-byte key, got length=${f}`);p=new Uint8Array(32),p.set(t),p.set(t,16),g=ts,d.push(p)}is(a)||d.push(a=Yr(a));const m=Vr(p);if(s){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");s(g,m,Vr(a.subarray(0,16)),m),a=a.subarray(16)}const w=16-i;if(w!==a.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(12!==w){const e=new Uint8Array(12);e.set(a,n?0:12-a.length),a=e,d.push(a)}const y=Vr(a);return function(e,t,r,s,i,n,o,a){const c=i.length,l=new Uint8Array(64),h=Vr(l),u=is(i)&&is(n),d=u?Vr(i):os,p=u?Vr(n):os;for(let g=0;g<c;o++){if(e(t,r,s,h,o,a),o>=ns)throw new Error("arx: counter overflow");const f=Math.min(64,c-g);if(u&&64===f){const e=g/4;if(g%4!=0)throw new Error("arx: invalid block position");for(let t,r=0;r<16;r++)t=e+r,p[t]=d[t]^h[r];g+=64}else{for(let e,t=0;t<f;t++)e=g+t,n[e]=i[e]^l[t];g+=f}}}(e,g,m,y,c,l,h,o),Xr(...d),l}}((function(e,t,r,s,i,n=20){let o=e[0],a=e[1],c=e[2],l=e[3],h=t[0],u=t[1],d=t[2],p=t[3],g=t[4],f=t[5],m=t[6],w=t[7],y=i,b=r[0],v=r[1],C=r[2],E=o,N=a,I=c,A=l,S=h,_=u,O=d,P=p,T=g,k=f,R=m,x=w,U=y,D=b,$=v,M=C;for(let e=0;e<n;e+=2)E=E+S|0,U=ss(U^E,16),T=T+U|0,S=ss(S^T,12),E=E+S|0,U=ss(U^E,8),T=T+U|0,S=ss(S^T,7),N=N+_|0,D=ss(D^N,16),k=k+D|0,_=ss(_^k,12),N=N+_|0,D=ss(D^N,8),k=k+D|0,_=ss(_^k,7),I=I+O|0,$=ss($^I,16),R=R+$|0,O=ss(O^R,12),I=I+O|0,$=ss($^I,8),R=R+$|0,O=ss(O^R,7),A=A+P|0,M=ss(M^A,16),x=x+M|0,P=ss(P^x,12),A=A+P|0,M=ss(M^A,8),x=x+M|0,P=ss(P^x,7),E=E+_|0,M=ss(M^E,16),R=R+M|0,_=ss(_^R,12),E=E+_|0,M=ss(M^E,8),R=R+M|0,_=ss(_^R,7),N=N+O|0,U=ss(U^N,16),x=x+U|0,O=ss(O^x,12),N=N+O|0,U=ss(U^N,8),x=x+U|0,O=ss(O^x,7),I=I+P|0,D=ss(D^I,16),T=T+D|0,P=ss(P^T,12),I=I+P|0,D=ss(D^I,8),T=T+D|0,P=ss(P^T,7),A=A+S|0,$=ss($^A,16),k=k+$|0,S=ss(S^k,12),A=A+S|0,$=ss($^A,8),k=k+$|0,S=ss(S^k,7);let L=0;s[L++]=o+E|0,s[L++]=a+N|0,s[L++]=c+I|0,s[L++]=l+A|0,s[L++]=h+S|0,s[L++]=u+_|0,s[L++]=d+O|0,s[L++]=p+P|0,s[L++]=g+T|0,s[L++]=f+k|0,s[L++]=m+R|0,s[L++]=w+x|0,s[L++]=y+U|0,s[L++]=b+D|0,s[L++]=v+$|0,s[L++]=C+M|0}),{counterRight:!1,counterLength:4,allowShortKeys:!1}),us=new Uint8Array(16),ds=(e,t)=>{e.update(t);const r=t.length%16;r&&e.update(us.subarray(r))},ps=new Uint8Array(32);function gs(e,t,r,s,i){const n=e(t,r,ps),o=ls.create(n);i&&ds(o,i),ds(o,s);const a=new Uint8Array(16),c=(e=>
1new DataView(e.buffer,e.byteOffset,e.byteLength))(a);Gr(c,0,BigInt(i?i.length:0),!0),Gr(c,8,BigInt(s.length),!0),o.update(a);const l=o.digest();return Xr(n,a),l}const fs=((e,t)=>{function r(r,...s){if(Fr(r),void 0!==e.nonceLength){const t=s[0];if(!t)throw new Error("nonce / iv required");e.varSizeNonce?Fr(t):Fr(t,e.nonceLength)}const i=e.tagLength;i&&void 0!==s[1]&&Fr(s[1]);const n=t(r,...s),o=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");Fr(t)}};let a=!1;return{encrypt(e,t){if(a)throw new Error("cannot encrypt() twice with same key + nonce");return a=!0,Fr(e),o(n.encrypt.length,t),n.encrypt(e,t)},decrypt(e,t){if(Fr(e),i&&e.length<i)throw new Error("invalid ciphertext length: smaller than tagLength="+i);return o(n.decrypt.length,t),n.decrypt(e,t)}}}return Object.assign(r,e),r})({blockSize:64,nonceLength:12,tagLength:16},(ms=hs,(e,t,r)=>({encrypt(s,i){const n=s.length;(i=Jr(n+16,i,!1)).set(s);const o=i.subarray(0,-16);ms(e,t,o,o,1);const a=gs(ms,e,t,o,r);return i.set(a,n),Xr(a),i},decrypt(s,i){i=Jr(s.length-16,i,!1);const n=s.subarray(0,-16),o=s.subarray(-16),a=gs(ms,e,t,n,r);if(!function(e,t){if(e.length!==t.length)return!1;let r=0;for(let s=0;s<e.length;s++)r|=e[s]^t[s];return 0===r}(o,a))throw new Error("invalid tag");return i.set(s.subarray(0,-16)),ms(e,t,i,i,1),Xr(a),i}})));var ms;class ws extends Jt{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Dt(e);const r=Kt(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let e=0;e<i.length;e++)i[e]^=54;this.iHash.update(i),this.oHash=e.create();for(let e=0;e<i.length;e++)i[e]^=106;this.oHash.update(i),i.fill(0)}update(e){return $t(this),this.iHash.update(e),this}digestInto(e){$t(this),Ut(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:s,destroyed:i,blockLen:n,outputLen:o}=this;return e.finished=s,e.destroyed=i,e.blockLen=n,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const ys=(e,t,r)=>new ws(e,t).update(r).digest();ys.create=(e,t)=>new ws(e,t);const bs=new Uint8Array([0]),vs=new Uint8Array;const Cs=(e,t,r,s,i)=>function(e,t,r,s=32){if(Dt(e),xt(s),s>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(s/e.outputLen);void 0===r&&(r=vs);const n=new Uint8Array(i*e.outputLen),o=ys.create(e,t),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let t=0;t<i;t++)bs[0]=t+1,a.update(0===t?vs:c).update(r).update(bs).digestInto(c),n.set(c,e.outputLen*t),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),bs.fill(0),n.slice(0,s)}(e,function(e,t,r){return Dt(e),void 0===r&&(r=new Uint8Array(e.outputLen)),ys(e,Kt(r),Kt(t))}(e,t,r),s,i);function Es(e,t,r){return e&t^~e&r}function Ns(e,t,r){return e&t^e&r^t&r}class Is extends Jt{constructor(e,t,r,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Wt(this.buffer)}update(e){$t(this);const{view:t,buffer:r,blockLen:s}=this,i=(e=Kt(e)).length;for(let n=0;n<i;){const o=Math.min(s-this.pos,i-n);if(o!==s)r.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===s&&(this.process(t,0),this.pos=0);else{const t=Wt(e);for(;s<=i-n;n+=s)this.process(t,n)}}return this.length+=e.length,this.roundClean(),this}digestInto(e){$t(this),Mt(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:s,isLE:i}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>s-n&&(this.process(r,0),n=0);for(let e=n;e<s;e++)t[e]=0;(function(e,t,r,s){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,r,s);const i=BigInt(32),n=BigInt(4294967295),o=Number(r>>i&n),a=Number(r&n),c=s?4:0,l=s?0:4;e.setUint32(t+c,o,s),e.setUint32(t+l,a,s)})(r,s-8,BigInt(8*this.length),i),this.process(r,0);const o=Wt(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,l[e],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:s,finished:i,destroyed:n,pos:o}=this;return e.length=s,e.pos=o,e.finished=i,e.destroyed=n,s%t&&e.buffer.set(r),e}}const As=new Uint32Array([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,2756
vendor: 4,591 bytes, line 1
1734187,3204031479,3329325298]),Ss=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),_s=new Uint32Array(64);class Os extends Is{constructor(){super(64,32,8,!1),this.A=0|Ss[0],this.B=0|Ss[1],this.C=0|Ss[2],this.D=0|Ss[3],this.E=0|Ss[4],this.F=0|Ss[5],this.G=0|Ss[6],this.H=0|Ss[7]}get(){const{A:e,B:t,C:r,D:s,E:i,F:n,G:o,H:a}=this;return[e,t,r,s,i,n,o,a]}set(e,t,r,s,i,n,o,a){this.A=0|e,this.B=0|t,this.C=0|r,this.D=0|s,this.E=0|i,this.F=0|n,this.G=0|o,this.H=0|a}process(e,t){for(let r=0;r<16;r++,t+=4)_s[r]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=_s[e-15],r=_s[e-2],s=Ft(t,7)^Ft(t,18)^t>>>3,i=Ft(r,17)^Ft(r,19)^r>>>10;_s[e]=i+_s[e-7]+s+_s[e-16]|0}let{A:r,B:s,C:i,D:n,E:o,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){const t=l+(Ft(o,6)^Ft(o,11)^Ft(o,25))+Es(o,a,c)+As[e]+_s[e]|0,h=(Ft(r,2)^Ft(r,13)^Ft(r,22))+Ns(r,s,i)|0;l=c,c=a,a=o,o=n+t|0,n=i,i=s,s=r,r=t+h|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,n=n+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(r,s,i,n,o,a,c,l)}roundClean(){_s.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Ps=Gt((()=>new Os)),Ts=BigInt(0),ks=BigInt(1),Rs=BigInt(2);function xs(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Us(e){if(!xs(e))throw new Error("Uint8Array expected")}function Ds(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)}const $s=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function Ms(e){Us(e);let t="";for(let r=0;r<e.length;r++)t+=$s[e[r]];return t}function Ls(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function js(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?Ts:BigInt("0x"+e)}const Bs=48,qs=57,Ws=65,Fs=70,Hs=97,zs=102;function Vs(e){return e>=Bs&&e<=qs?e-Bs:e>=Ws&&e<=Fs?e-(Ws-10):e>=Hs&&e<=zs?e-(Hs-10):void 0}function Ks(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,r=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const s=new Uint8Array(r);for(let t=0,i=0;t<r;t++,i+=2){const r=Vs(e.charCodeAt(i)),n=Vs(e.charCodeAt(i+1));if(void 0===r||void 0===n){const t=e[i]+e[i+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+i)}s[t]=16*r+n}return s}function Js(e){return js(Ms(e))}function Gs(e){return Us(e),js(Ms(Uint8Array.from(e).reverse()))}function Ys(e,t){return Ks(e.toString(16).padStart(2*t,"0"))}function Xs(e,t){return Ys(e,t).reverse()}function Zs(e,t,r){let s;if("string"==typeof t)try{s=Ks(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!xs(t))throw new Error(e+" must be hex string or Uint8Array");s=Uint8Array.from(t)}const i=s.length;if("number"==typeof r&&i!==r)throw new Error(e+" of length "+r+" expected, got "+i);return s}function Qs(...e){let t=0;for(let r=0;r<e.length;r++){const s=e[r];Us(s),t+=s.length}const r=new Uint8Array(t);for(let t=0,s=0;t<e.length;t++){const i=e[t];r.set(i,s),s+=i.length}return r}const ei=e=>"bigint"==typeof e&&Ts<=e;function ti(e,t,r){return ei(e)&&ei(t)&&ei(r)&&t<=e&&e<r}function ri(e,t,r,s){if(!ti(t,r,s))throw new Error("expected valid "+e+": "+r+" <= n < "+s+", got "+t)}function si(e){let t;for(t=0;e>Ts;e>>=ks,t+=1);return t}const ii=e=>(Rs<<BigInt(e-1))-ks,ni=e=>new Uint8Array(e),oi=e=>Uint8Array.from(e);function ai(e,t,r){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let s=ni(e),i=ni(e),n=0;const o=()=>{s.fill(1),i.fill(0),n=0},a=(...e)=>r(i,s,...e),c=(e=ni())=>{i=a(oi([0]),e),s=a(),0!==e.length&&(i=a(oi([1]),e),s=a())},l=()=>{if(n++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const r=[];for(;e<t;){s=a();const t=s.slice();r.push(t),e+=s.length}return Qs(...r)};return(e,t)=>{let r;for(o(),c(e);!(r=t(l()));)c();return o(),r}}const ci={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||xs(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)};function li(e,t,r={}){const s=(t,r,s)=>{const i=ci[r];if("function"!=typeof i)throw new Error("invalid validator function");const n=e[t];if(!(s&&void 0===n||i(n,e)))throw new Error("param "+String(t)+" is invali
1d. Expected "+r+", got "+n)};for(const[e,r]of Object.entries(t))s(e,r,!1);for(const[e,t]of Object.entries(r))s(e,t,!0);return e}function hi(e){const t=new WeakMap;return(r,...s)=>{const i=t.get(r);if(void 0!==i)return i;const n=e(r,...s);return t.set(r,n),n}}var ui=Object.freeze({__proto__:null,isBytes:xs,abytes:Us,abool:Ds,bytesToHex:Ms,numberToHexUnpadded:Ls,hexToNumber:js,hexToBytes:Ks,bytesToNumberBE:Js,bytesToNumberLE:Gs,numberToBytesBE:Ys,numberToBytesLE:Xs,numberToVarBytesBE:function(e){return Ks(Ls(e))},ensureBytes:Zs,concatBytes:Qs,equalBytes:function(e,t){if(e.length!==t.length)return!1;let r=0;for(let s=0;s<e.length;s++)r|=e[s]^t[s];return 0===r},utf8ToBytes:function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))},inRange:ti,aInRange:ri,bitLen:si,bitGet:function(e,t){return e>>BigInt(t)&ks},bitSet:function(e,t,r){return e|(r?ks:Ts)<<BigInt(t)},bitMask:ii,createHmacDrbg:ai,validateObject:li,notImplemented:()=>{throw new Error("not implemented")},memoized:hi});const di=BigInt(0),pi=BigInt(1),gi=BigInt(2),fi=BigInt(3),mi=BigInt(4),wi=BigInt(5),yi=BigInt(8);function bi(e,t){const r=e%t;return r>=di?r:t+r}function vi(e,t,r){if(t<di)throw new Error("invalid exponent, negatives unsupported");if(r<=di)throw new Error("invalid modulus");if(r===pi)return di;let s=pi;for(;t>di;)t&pi&&(s=s*e%r),e=e*e%r,t>>=pi;return s}function Ci(e,t,r){let s=e;for(;t-- >di;)s*=s,s%=r;return s}function Ei(e,t){if(e===di)throw new Error("invert: expected non-zero number");if(t<=di)throw new Error("invert: expected positive modulus, got "+t);let r=bi(e,t),s=t,i=di,n=pi;for(;r!==di;){const e=s%r,t=i-n*(s/r);s=r,r=e,i=n,n=t}if(s!==pi)throw new Error("invert: does not exist");return bi(i,t)}function Ni(e){if(e%mi===fi){const t=(e+pi)/mi;return function(e,r){const s=e.pow(r,t);if(!e.eql(e.sqr(s),r))throw new Error("Cannot find square root");return s}}if(e%yi===wi){const t=(e-wi)/yi;return function(e,r){const s=e.mul(r,gi),i=e.pow(s,t),n=e.mul(r,i),o=e.mul(e.mul(n,gi),i),a=e.mul(n,e.sub(o,e.ONE));if(!e.eql(e.sqr(a),r))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-pi)/gi;let r,s,i;for(r=e-pi,s=0;r%gi===di;r/=gi,s++);for(i=gi;i<e&&vi(i,t,e)!==e-pi;i++)if(i>1e3)throw new Error("Cannot find square root: likely non-prime P");if(1===s){const t=(e+pi)/mi;return function(e,r){const s=e.pow(r,t);if(!e.eql(e.sqr(s),r))throw new Error("Cannot find square root");return s}}const n=(r+pi)/gi;return function(e,o){if(e.pow(o,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=s,c=e.pow(e.mul(e.ONE,i),r),l=e.pow(o,n),h=e.pow(o,r);for(;!e.eql(h,e.ONE);){if(e.eql(h,e.ZERO))return e.ZERO;let t=1;for(let r=e.sqr(h);t<a&&!e.eql(r,e.ONE);t++)r=e.sqr(r);const r=e.pow(c,pi<<BigInt(a-t-1));c=e.sqr(r),l=e.mul(l,r),h=e.mul(h,c),a=t}return l}}(e)}const Ii=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Ai(e,t){const r=void 0!==t?t:e.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function Si(e,t,r=!1,s={}){if(e<=di)throw new Error("invalid field: expected ORDER > 0, got "+e);const{nBitLength:i,nByteLength:n}=Ai(e,t);if(n>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:e,isLE:r,BITS:i,BYTES:n,MASK:ii(i),ZERO:di,ONE:pi,create:t=>bi(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return di<=t&&t<e},is0:e=>e===di,isOdd:e=>(e&pi)===pi,neg:t=>bi(-t,e),eql:(e,t)=>e===t,sqr:t=>bi(t*t,e),add:(t,r)=>bi(t+r,e),sub:(t,r)=>bi(t-r,e),mul:(t,r)=>bi(t*r,e),pow:(e,t)=>function(e,t,r){if(r<di)throw new Error("invalid exponent, negatives unsupported");if(r===di)return e.ONE;if(r===pi)return t;let s=e.ONE,i=t;for(;r>di;)r&pi&&(s=e.mul(s,i)),i=e.sqr(i),r>>=pi;return s}(a,e,t),div:(t,r)=>bi(t*Ei(r,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>Ei(t,e),sqrt:s.sqrt||(t=>(o||(o=Ni(e)),o(a,t))),invertBatch:e=>function(e,t){const r=new Array(t.length),s=t.reduce(((t,s,i)=>e.is0(s)?t:(r[i]=t,e.mul(t,s))),e.ONE),i=e.inv(s);return t.reduceRight(((t,s,i)=>e.is0(s)?t:(r[i]=e.mul(t,r[i]),e.mul(t,s))),i),r}(a,e),cmov:(e,t,r)=>r?t:e,toBytes:e=>r?Xs(e,n):Ys(e,n),fromBytes:e=>{if(e.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);return r?Gs(e):Js(e)}});return Object.freeze(a)}function _i(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function Oi(e){const t=_i(e);return t+Math.ceil(t/2)}const Pi=BigInt(0),Ti=BigInt(1);function ki(e,t){const r=t.negate();return e?r:t}function Ri(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function xi(e,t){Ri(e,t);return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1)}}const Ui=new WeakMap,Di=new WeakMap;function $i(e){return Di.get(e)||1}function Mi(e,t,r,s){if(function(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach(((e,r)=>{if(!(e instanceof t))throw new Error("invalid point at index "+r)}))}(r,e),function(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach(((e,r)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+r)}))}(s,t),r.length!==s.length)throw new Error("arrays of points and scalars must have equal length");const i=e.ZERO,n=si(BigInt(r.length)),o=n>12?n-3:n>4?n-2:n?2:1,a=(1<<o)-1,c=new Array(a+1).fill(i);let l=i;for(let e=Math.floor((t.BITS-1)/o)*o;e>=0;e-=o){c.fill(i);for(let t=0;t<s.length;t++){const i=s[t],n=Number(i>>BigInt(e)&BigInt(a));c[n]=c[n].add(r[t])}let t=i;for(let e=c.length-1,r=i;e>0;e--)r=r.add(c[e]),t=t.add(r);if(l=l.add(t),0!==e)for(let e=0;e<o;e++)l=l.double()}return l}function Li(e){return function(e){li(e,Ii.reduce(((e,t)=>(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"}))}
1(e.Fp),li(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...Ai(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}BigInt(0),BigInt(1),BigInt(2),BigInt(8);const ji=BigInt(0),Bi=BigInt(1);const qi=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const Wi=BigInt(1),Fi=BigInt(2),Hi=BigInt(3),zi=BigInt(5);BigInt(8);const Vi=function(e){const t=function(e){return li(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:r}=t,s=e=>bi(e,r),i=t.montgomeryBits,n=Math.ceil(i/8),o=t.nByteLength,a=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>vi(e,r-BigInt(2),r));function l(e,t,r){const i=s(e*(t-r));return[t=s(t-i),r=s(r+i)]}const h=(t.a-BigInt(2))/BigInt(4);function u(e){return Xs(s(e),n)}function d(e,t){const d=function(e){const t=Zs("u coordinate",e,n);return 32===o&&(t[31]&=127),Gs(t)}(t),p=function(e){const t=Zs("scalar",e),r=t.length;if(r!==n&&r!==o)throw new Error("invalid scalar, expected "+n+" or "+o+" bytes, got "+r);return Gs(a(t))}(e),g=function(e,t){ri("u",e,ji,r),ri("scalar",t,ji,r);const n=t,o=e;let a,u=Bi,d=ji,p=e,g=Bi,f=ji;for(let e=BigInt(i-1);e>=ji;e--){const t=n>>e&Bi;f^=t,a=l(f,u,p),u=a[0],p=a[1],a=l(f,d,g),d=a[0],g=a[1],f=t;const r=u+d,i=s(r*r),c=u-d,m=s(c*c),w=i-m,y=p+g,b=s((p-g)*r),v=s(y*c),C=b+v,E=b-v;p=s(C*C),g=s(o*s(E*E)),u=s(i*m),d=s(w*(i+s(h*w)))}a=l(f,u,p),u=a[0],p=a[1],a=l(f,d,g),d=a[0],g=a[1];const m=c(d);return s(u*m)}(d,p);if(g===ji)throw new Error("invalid private or public key received");return u(g)}const p=u(t.Gu);function g(e){return d(e,p)}return{scalarMult:d,scalarMultBase:g,getSharedSecret:(e,t)=>d(e,t),getPublicKey:e=>g(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:p}}({P:qi,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=qi,{pow_p_5_8:r,b2:s}=function(e){const t=BigInt(10),r=BigInt(20),s=BigInt(40),i=BigInt(80),n=qi,o=e*e%n*e%n,a=Ci(o,Fi,n)*o%n,c=Ci(a,Wi,n)*e%n,l=Ci(c,zi,n)*c%n,h=Ci(l,t,n)*l%n,u=Ci(h,r,n)*h%n,d=Ci(u,s,n)*u%n,p=Ci(d,i,n)*d%n,g=Ci(p,i,n)*d%n,f=Ci(g,t,n)*l%n;return{pow_p_5_8:Ci(f,Fi,n)*e%n,b2:o}}(e);return bi(Ci(r,Hi,t)*s,t)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},randomBytes:Yt});function Ki(e){void 0!==e.lowS&&Ds("lowS",e.lowS),void 0!==e.prehash&&Ds("prehash",e.prehash)}const{bytesToNumberBE:Ji,hexToBytes:Gi}=ui;class Yi extends Error{constructor(e=""){super(e)}}const Xi={Err:Yi,_tlv:{encode:(e,t)=>{const{Err:r}=Xi;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(1&t.length)throw new r("tlv.encode: unpadded data");const s=t.length/2,i=Ls(s);if(i.length/2&128)throw new r("tlv.encode: long form length too big");const n=s>127?Ls(i.length/2|128):"";return Ls(e)+n+i+t},decode(e,t){const{Err:r}=Xi;let s=0;if(e<0||e>256)throw new r("tlv.encode: wrong tag");if(t.length<2||t[s++]!==e)throw new r("tlv.decode: wrong tlv");const i=t[s++];let n=0;if(!!(128&i)){const e=127&i;if(!e)throw new r("tlv.decode(long): indefinite length not supported");if(e>4)throw new r("tlv.decode(long): byte length is too big");const o=t.subarray(s,s+e);if(o.length!==e)throw new r("tlv.decode: length bytes not complete");if(0===o[0])throw new r("tlv.decode(long): zero leftmost byte");for(const e of o)n=n<<8|e;if(s+=e,n<128)throw new r("tlv.decode(long): not minimal encoding")}else n=i;const o=t.subarray(s,s+n);if(o.length!==n)throw new r("tlv.decode: wrong value length");return{v:o,l:t.subarray(s+n)}}},_int:{encode(e){const{Err:t}=Xi;if(e<Zi)throw new t("integer: negative integers are not allowed");let r=Ls(e);if(8&Number.parseInt(r[0],16)&&(r="00"+r),1&r.length)throw new t("unexpected DER parsing assertion: unpadded hex");return r},decode(e){const{Err:t}=Xi;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return Ji(e)}},toSig(e){const{Err:t,_int:r,_tlv:s}=Xi,i="string"==typeof e?Gi(e):e;Us(i);const{v:n,l:o}=s.decode(48,i);if(o.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=s.decode(2,n),{v:l,l:h}=s.decode(2,c);if(h.length)throw new t("invalid signature: left bytes after parsing");return{r:r.decode(a),s:r.decode(l)}},hexFromSig(e){const{_tlv:t,_int:r}=Xi,s=t.encode(2,r.encode(e.r))+t.encode(2,r.encode(e.s));return t.encode(48,s)}},Zi=BigInt(0),Qi=BigInt(1);BigInt(2);const en=BigInt(3);function tn(e){const t=function(e){const t=Li(e);li(t,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});
vendor: 12,779 bytes, line 1
1const{endo:r,Fp:s,a:i}=t;if(r){if(!s.eql(i,s.ZERO))throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function")}return Object.freeze({...t})}(e),{Fp:r}=t,s=Si(t.n,t.nBitLength),i=t.toBytes||((e,t,s)=>{const i=t.toAffine();return Qs(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),n=t.fromBytes||(e=>{const t=e.subarray(1);return{x:r.fromBytes(t.subarray(0,r.BYTES)),y:r.fromBytes(t.subarray(r.BYTES,2*r.BYTES))}});function o(e){const{a:s,b:i}=t,n=r.sqr(e),o=r.mul(n,e);return r.add(r.add(o,r.mul(e,s)),i)}if(!r.eql(r.sqr(t.Gy),o(t.Gx)))throw new Error("bad generator point: equation left != right");function a(e){const{allowedPrivateKeyLengths:r,nByteLength:s,wrapPrivateKey:i,n:n}=t;if(r&&"bigint"!=typeof e){if(xs(e)&&(e=Ms(e)),"string"!=typeof e||!r.includes(e.length))throw new Error("invalid private key");e=e.padStart(2*s,"0")}let o;try{o="bigint"==typeof e?e:Js(Zs("private key",e,s))}catch{throw new Error("invalid private key, expected hex or "+s+" bytes, got "+typeof e)}return i&&(o=bi(o,n)),ri("private key",o,Qi,n),o}function c(e){if(!(e instanceof u))throw new Error("ProjectivePoint expected")}const l=hi(((e,t)=>{const{px:s,py:i,pz:n}=e;if(r.eql(n,r.ONE))return{x:s,y:i};const o=e.is0();null==t&&(t=o?r.ONE:r.inv(n));const a=r.mul(s,t),c=r.mul(i,t),l=r.mul(n,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(l,r.ONE))throw new Error("invZ was invalid");return{x:a,y:c}})),h=hi((e=>{if(e.is0()){if(t.allowInfinityPoint&&!r.is0(e.py))return;throw new Error("bad point: ZERO")}const{x:s,y:i}=e.toAffine();if(!r.isValid(s)||!r.isValid(i))throw new Error("bad point: x or y not FE");const n=r.sqr(i),a=o(s);if(!r.eql(n,a))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0}));class u{constructor(e,t,s){if(this.px=e,this.py=t,this.pz=s,null==e||!r.isValid(e))throw new Error("x required");if(null==t||!r.isValid(t))throw new Error("y required");if(null==s||!r.isValid(s))throw new Error("z required");Object.freeze(this)}static fromAffine(e){const{x:t,y:s}=e||{};if(!e||!r.isValid(t)||!r.isValid(s))throw new Error("invalid affine point");if(e instanceof u)throw new Error("projective point not allowed");const i=e=>r.eql(e,r.ZERO);return i(t)&&i(s)?u.ZERO:new u(t,s,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(e){const t=r.invertBatch(e.map((e=>e.pz)));return e.map(((e,r)=>e.toAffine(t[r]))).map(u.fromAffine)}static fromHex(e){const t=u.fromAffine(n(Zs("pointHex",e)));return t.assertValidity(),t}static fromPrivateKey(e){return u.BASE.multiply(a(e))}static msm(e,t){return Mi(u,s,e,t)}_setWindowSize(e){p.setWindowSize(this,e)}assertValidity(){h(this)}hasEvenY(){const{y:e}=this.toAffine();if(r.isOdd)return!r.isOdd(e);throw new Error("Field doesn't support isOdd")}equals(e){c(e);const{px:t,py:s,pz:i}=this,{px:n,py:o,pz:a}=e,l=r.eql(r.mul(t,a),r.mul(n,i)),h=r.eql(r.mul(s,a),r.mul(o,i));return l&&h}negate(){return new u(this.px,r.neg(this.py),this.pz)}double(){const{a:e,b:s}=t,i=r.mul(s,en),{px:n,py:o,pz:a}=this;let c=r.ZERO,l=r.ZERO,h=r.ZERO,d=r.mul(n,n),p=r.mul(o,o),g=r.mul(a,a),f=r.mul(n,o);return f=r.add(f,f),h=r.mul(n,a),h=r.add(h,h),c=r.mul(e,h),l=r.mul(i,g),l=r.add(c,l),c=r.sub(p,l),l=r.add(p,l),l=r.mul(c,l),c=r.mul(f,c),h=r.mul(i,h),g=r.mul(e,g),f=r.sub(d,g),f=r.mul(e,f),f=r.add(f,h),h=r.add(d,d),d=r.add(h,d),d=r.add(d,g),d=r.mul(d,f),l=r.add(l,d),g=r.mul(o,a),g=r.add(g,g),d=r.mul(g,f),c=r.sub(c,d),h=r.mul(g,p),h=r.add(h,h),h=r.add(h,h),new u(c,l,h)}add(e){c(e);const{px:s,py:i,pz:n}=this,{px:o,py:a,pz:l}=e;let h=r.ZERO,d=r.ZERO,p=r.ZERO;const g=t.a,f=r.mul(t.b,en);let m=r.mul(s,o),w=r.mul(i,a),y=r.mul(n,l),b=r.add(s,i),v=r.add(o,a);b=r.mul(b,v),v=r.add(m,w),b=r.sub(b,v),v=r.add(s,n);let C=r.add(o,l);return v=r.mul(v,C),C=r.add(m,y),v=r.sub(v,C),C=r.add(i,n),h=r.add(a,l),C=r.mul(C,h),h=r.add(w,y),C=r.sub(C,h),p=r.mul(g,v),h=r.mul(f,y),p=r.add(h,p),h=r.sub(w,p),p=r.add(w,p),d=r.mul(h,p),w=r.add(m,m),w=r.add(w,m),y=r.mul(g,y),v=r.mul(f,v),w=r.add(w,y),y=r.sub(m,y),y=r.mul(g,y),v=r.add(v,y),m=r.mul(w,v),d=r.add(d,m),m=r.mul(C,v),h=r.mul(b,h),h=r.sub(h,m),m=r.mul(b,w),p=r.mul(C,p),p=r.add(p,m),new u(h,d,p)}subtract(e){return this.add(e.negate())}is0(){return this.equals(u.ZERO)}wNAF(e){return p.wNAFCached(this,e,u.normalizeZ)}multiplyUnsafe(e){const{endo:s,n:i}=t;ri("scalar",e,Zi,i);const n=u.ZERO;if(e===Zi)return n;if(this.is0()||e===Qi)return this;if(!s||p.hasPrecomputes(this))return p.wNAFCachedUnsafe(this,e,u.normalizeZ);let{k1neg:o,k1:a,k2neg:c,k2:l}=s.splitScalar(e),h=n,d=n,g=this;for(;a>Zi||l>Zi;)a&Qi&&(h=h.add(g)),l&Qi&&(d=d.add(g)),g=g.double(),a>>=Qi,l>>=Qi;return o&&(h=h.negate()),c&&(d=d.negate()),d=new u(r.mul(d.px,s.beta),d.py,d.pz),h.add(d)}multiply(e){const{endo:s,n:i}=t;let n,o;if(ri("scalar",e,Qi,i),s){const{k1neg:t,k1:i,k2neg:a,k2:c}=s.splitScalar(e);let{p:l,f:h}=this.wNAF(i),{p:d,f:g}=this.wNAF(c);l=p.constTimeNegate(t,l),d=p.constTimeNegate(a,d),d=new u(r.mul(d.px,s.beta),d.py,d.pz),n=l.add(d),o=h.add(g)}else{const{p:t,f:r}=this.wNAF(e);n=t,o=r}return u.normalizeZ([n,o])[0]}multiplyAndAddUnsafe(e,t,r){const s=u.BASE,i=(e,t)=>t!==Zi&&t!==Qi&&e.equals(s)?e.multiply(t):e.multiplyUnsafe(t),n=i(this,t).add(i(e,r));return n.is0()?void 0:n}toAffine(e){return l(this,e)}isTorsionFree(){const{h:e,isTorsionFree:r}=t;if(e===Qi)return!0;if(r)return r(u,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:e,clearCofactor:r}=t;return e===Qi?this:r?r(u,this):this.multiplyUnsafe(t.h)}toRawBytes(e=!0){return Ds("isCompressed",e),this.assertValidity(),i(u,this,e)}toHex(e=!0){return Ds("isCompressed",e),Ms(this.toRawBytes(e))}}u.BASE=new u(t.Gx,t.Gy,r.ONE),u.ZERO=new u(r.ZERO,r.ONE,r.ZERO);const d=t.nBitLength,p=function(e,t){return{constTimeNegate:ki,hasPrecomputes(e){return 1!==$i(e)},unsafeLadder(t,r,s=e.ZERO){let i=t;for(;r>Pi;)r&Ti&&(s=s.add(i)),i=i.double(),r>>=Ti;return s},precomputeWindow(e,r){const{windows:s,windowSize:i}=xi(r,t),n=[];let o=e,a=o;for(let e=0;e<s;e++){a=o,n.push(a);for(let e=1;e<i;e++)a=a.add(o),n.push(a);o=a.double()}return n},wNAF(r,s,i){const{windows:n,windowSize:o}=xi(r,t);let a=e.ZERO,c=e.BASE;const l=BigInt(2**r-1),h=2**r,u=BigInt(r);for(let e=0;e<n;e++){const t=e*o;let r=Number(i&l);i>>=u,r>o&&(r-=h,i+=Ti);const n=t,d=t+Math.abs(r)-1,p=e%2!=0,g=r<0;0===r?c=c.add(ki(p,s[n])):a=a.add(ki(g,s[d]))}return{p:a,f:c}},wNAFUnsafe(r,s,i,n=e.ZERO){const{windows:o,windowSize:a}=xi(r,t),c=BigInt(2**r-1),l=2**r,h=BigInt(r);for(let e=0;e<o;e++){const t=e*a;if(i===Pi)break;let r=Number(i&c);if(i>>=h,r>a&&(r-=l,i+=Ti),0===r)continue;let o=s[t+Math.abs(r)-1];r<0&&(o=o.negate()),n=n.add(o)}return n},getPrecomputes(e,t,r){let s=Ui.get(t);return s||(s=this.precomputeWindow(t,e),1!==e&&Ui.set(t,r(s))),s},wNAFCached(e,t,r){const s=$i(e);return this.wNAF(s,this.getPrecomputes(s,e,r),t)},wNAFCachedUnsafe(e,t,r,s){const i=$i(e);return 1===i?this.unsafeLadder(e,t,s):this.wNAFUnsafe(i,this.getPrecomputes(i,e,r),t,s)},setWindowSize(e,r){Ri(r,t),Di.set(e,r),Ui.delete(e)}}}(u,t.endo?Math.ceil(d/2):d);return{CURVE:t,ProjectivePoint:u,normPrivateKeyToScalar:a,weierstrassEquation:o,isWithinCurveOrder:function(e){return ti(e,Qi,t.n)}}}function rn(e){const t=function(e){const t=Li(e);return li(t,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...t})}(e),{Fp:r,n:s}=t,i=r.BYTES+1,n=2*r.BYTES+1;function o(e){return bi(e,s)}function a(e){return Ei(e,s)}const{ProjectivePoint:c,normPrivateKeyToScalar:l,weierstrassEquation:h,isWithinCurveOrder:u}=tn({...t,toBytes(e,t,s){const i=t.toAffine(),n=r.toBytes(i.x),o=Qs;return Ds("isCompressed",s),s?o(Uint8Array.from([t.hasEvenY()?2:3]),n):o(Uint8Array.from([4]),n,r.toBytes(i.y))},fromBytes(e){const t=e.length,s=e[0],o=e.subarray(1);if(t!==i||2!==s&&3!==s){if(t===n&&4===s){return{x:r.fromBytes(o.subarray(0,r.BYTES)),y:r.fromBytes(o.subarray(r.BYTES,2*r.BYTES))}}throw new Error("invalid Point, expected length of "+i+", or uncompressed "+n+", got "+t)}{const e=Js(o);if(!ti(e,Qi,r.ORDER))throw new Error("Point is not on curve");const t=h(e);let i;try{i=r.sqrt(t)}catch(e){const t=e instanceof Error?": "+e.message:"";throw new Error("Point is not on curve"+t)}return 1==(1&s)!==((i&Qi)===Qi)&&(i=r.neg(i)),{x:e,y:i}}}}),d=e=>Ms(Ys(e,t.nByteLength));function p(e){return e>s>>Qi}const g=(e,t,r)=>Js(e.slice(t,r));class f{constructor(e,t,r){this.r=e,this.s=t,this.recovery=r,this.assertValidity()}static fromCompact(e){const r=t.nByteLength;return e=Zs("compactSignature",e,2*r),new f(g(e,0,r),g(e,r,2*r))}static fromDER(e){const{r:t,s:r}=Xi.toSig(Zs("DER",e));return new f(t,r)}assertValidity(){ri("r",this.r,Qi,s),ri("s",this.s,Qi,s)}addRecoveryBit(e){return new f(this.r,this.s,e)}recoverPublicKey(e){const{r:s,s:i,recovery:n}=this,l=b(Zs("msgHash",e));if(null==n||![0,1,2,3].includes(n))throw new Error("recovery id invalid");const h=2===n||3===n?s+t.n:s;if(h>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const u=0==(1&n)?"02":"03",p=c.fromHex(u+d(h)),g=a(h),f=o(-l*g),m=o(i*g),w=c.BASE.multiplyAndAddUnsafe(p,f,m);if(!w)throw new Error("point at infinify");return w.assertValidity(),w}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new f(this.r,o(-this.s),this.recovery):this}toDERRawBytes(){return Ks(this.toDERHex())}toDERHex(){return Xi.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return Ks(this.toCompactHex())}toCompactHex(){return d(this.r)+d(this.s)}}const m={isValidPrivateKey(e){try{return l(e),!0}catch{return!1}},normPrivateKeyToScalar:l,randomPrivateKey:()=>{const e=Oi(t.n);return function(e,t,r=!1){const s=e.length,i=_i(t),n=Oi(t);if(s<16||s<n||s>1024)throw new Error("expected "+n+"-1024 bytes of input, got "+s);const o=bi(r?Gs(e):Js(e),t-pi)+pi;return r?Xs(o,i):Ys(o,i)}(t.randomBytes(e),t.n)},precompute(e=8,t=c.BASE){return t._setWindowSize(e),t.multiply(BigInt(3)),t}};function w(e){const t=xs(e),r="string"==typeof e,s=(t||r)&&e.length;return t?s===i||s===n:r?s===2*i||s===2*n:e instanceof c}const y=t.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const r=Js(e),s=8*e.length-t.nBitLength;return s>0?r>>BigInt(s):r},b=t.bits2int_modN||function(e){return o(y(e))},v=ii(t.nBitLength);function C(e){return ri("num < 2^"+t.nBitLength,e,Zi,v),Ys(e,t.nByteLength)}function E(e,s,i=N){if(["recovered","canonical"].some((e=>e in i)))throw new Error("sign() legacy options not supported");const{hash:n,randomBytes:h}=t;let{lowS:d,prehash:g,extraEntropy:m}=i;null==d&&(d=!0),e=Zs("msgHash",e),Ki(i),g&&(e=Zs("prehashed msgHash",n(e)));const w=b(e),v=l(s),E=[C(v),C(w)];if(null!=m&&!1!==m){const e=!0===m?h(r.BYTES):m;E.push(Zs("extraEntropy",e))}const I=Qs(...E),A=w;return{seed:I,k2sig:function(e){const t=y(e);if(!u(t))return;const r=a(t),s=c.BASE.multiply(t).toAffine(),i=o(s.x);if(i===Zi)return;const n=o(r*o(A+i*v));if(n===Zi)return;let l=(s.x===i?0:2)|Number(s.y&Qi),h=n;return d&&p(n)&&(h=function(e){return p(e)?o(-e):e}(n),l^=1),new f(i,h,l)}}}const N={lowS:t.lowS,prehash:!1},I={lowS:t.lowS,prehash:!1};return c.BASE._setWindowSize(8),{CURVE:t,getPublicKey:function(e,t=!0){return c.fromPrivateKey(e).toRawBytes(t)},getSharedSecret:function(e,t,r=!0){if(w(e))throw new Error("first arg must be private key");if(!w(t))throw new Error("second arg must be public key");return c.fromHex(t).multiply(l(e)).toRawBytes(r)},sign:function(e,r,s=N){const{seed:i,k2sig:n}=E(e,r,s),o=t;return ai(o.hash.outputLen,o.nByteLength,o.hmac)(i,n)},verify:function(e,r,s,i=I){const n=e;r=Zs("msgHash",r),s=Zs("publicKey",s);const{lowS:l,prehash:h,format:u}=i;if(Ki(i),"strict"in i)throw new Error("options.strict was renamed to lowS");if(void 0!==u&&"compact"!==u&&"der"!==u)throw new Error("format must be compact or der");const d="string"==typeof n||xs(n),p=!d&&!u&&"object"==typeof n&&null!==n&&"bigint"==typeof n.r&&"bigint"==typeof n.s;if(!d&&!p)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");let g,m;try{if(p&&(g=new f(n.r,n.s)),d){try{"compact"!==u&&(g=f.fromDER(n))}catch(e){if(!(e instanceof Xi.Err))throw e}!g&&"der"!==u&&(g=f.fromCompact(n))}m=c.fromHex(s)}catch{return!1}if(!g||l&&g.hasHighS())return!1;h&&(r=t.hash(r));const{r:w,s:y}=g,v=b(r),C=a(y),E=o(v*C),N=o(w*C),A=c.BASE.multiplyAndAddUnsafe(m,E,N)?.toAffine();return!!A&&o(A.x)===w},ProjectivePoint:c,Signature:f,utils:m}}function sn(e){return{hash:e,hmac:(t,...r)=>ys(e,t,function(...e){let t=0;for(let r=0;r<e.length;r++){const s=e[r];Ut(s),t+=s.length}
1const r=new Uint8Array(t);for(let t=0,s=0;t<e.length;t++){const i=e[t];r.set(i,s),s+=i.length}return r}(...r)),randomBytes:Yt}}BigInt(4);const nn=Si(BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff")),on=function(e,t){const r=t=>rn({...e,...sn(t)});return{...r(t),create:r}}({a:nn.create(BigInt("-3")),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Fp:nn,n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5"),h:BigInt(1),lowS:!1},Ps),an="base10",cn="base16",ln="base64pad",hn="base64url",un="utf8";function dn(){const e=Yt(32);return(0,We.BB)(e,cn)}function pn(e){const t=Ps((0,We.mL)(e,cn));return(0,We.BB)(t,cn)}function gn(e){const t=Ps((0,We.mL)(e,un));return(0,We.BB)(t,cn)}function fn(e){return(0,We.mL)(`${e}`,an)}function mn(e){return Number((0,We.BB)(e,an))}function wn(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function yn(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),r=(4-t.length%4)%4;return t+"=".repeat(r)}function bn(e){if(2===mn(e.type))return(0,We.BB)((0,We.zo)([e.type,e.sealed]),ln);if(1===mn(e.type)){if(typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return(0,We.BB)((0,We.zo)([e.type,e.senderPublicKey,e.iv,e.sealed]),ln)}return(0,We.BB)((0,We.zo)([e.type,e.iv,e.sealed]),ln)}function vn(e){const t=(e.encoding||ln)===hn?yn(e.encoded):e.encoded,r=(0,We.mL)(t,ln),s=r.slice(0,1);if(1===mn(s)){const e=33,t=e+12,i=r.slice(1,e),n=r.slice(e,t);return{type:s,sealed:r.slice(t),iv:n,senderPublicKey:i}}if(2===mn(s)){return{type:s,sealed:r.slice(1),iv:Yt(12)}}const i=r.slice(1,13);return{type:s,sealed:r.slice(13),iv:i}}function Cn(e){const t=e?.type||0;if(1===t){if(typeof e?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function En(e){return 1===e.type&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}function Nn(e){return 2===e.type}function In(e,t){const[r,s,i]=e.split("."),n=ze.from(yn(i),"base64");if(64!==n.length)throw new Error("Invalid signature length");const o=n.slice(0,32),a=n.slice(32,64),c=Ps(`${r}.${s}`),l=function(e){const t=ze.from(e.x,"base64"),r=ze.from(e.y,"base64");return(0,We.zo)([new Uint8Array([4]),t,r])}(t);if(!on.verify((0,We.zo)([o,a]),c,l))throw new Error("Invalid signature");return(0,T.xp)(e).payload}function An(e){return e?.relay||{protocol:"irn"}}function Sn(e){const t=Fe.iO[e];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${e}`);return t}function _n(e,t="-"){const r={},s="relay"+t;return Object.keys(e).forEach((t=>{if(t.startsWith(s)){const i=t.replace(s,""),n=e[t];r[i]=n}})),r}function On(e){if(!e.includes("wc:")){const t=Rt(e);null!=t&&t.includes("wc:")&&(e=t)}const t=(e=(e=e.includes("wc://")?e.replace("wc://",""):e).includes("wc:")?e.replace("wc:",""):e).indexOf(":"),r=-1!==e.indexOf("?")?e.indexOf("?"):void 0,s=e.substring(0,t),i=e.substring(t+1,r).split("@"),n=typeof r<"u"?e.substring(r):"",o=new URLSearchParams(n),a={};o.forEach(((e,t)=>{a[t]=e}));const c="string"==typeof a.methods?a.methods.split(","):void 0;return{protocol:s,topic:Pn(i[0]),version:parseInt(i[1],10),symKey:a.symKey,relay:_n(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function Pn(e){return e.startsWith("//")?e.substring(2):e}function Tn(e){const t=new URLSearchParams,r=function(e,t="-"){const r={};return Object.keys(e).forEach((s=>{const i=s,n="relay"+t+i;e[i]&&(r[n]=e[i])})),r}(e.relay);Object.keys(r).sort().forEach((e=>{t.set(e,r[e])})),t.set("symKey",e.symKey),e.expiryTimestamp&&t.set("expiryTimestamp",e.expiryTimestamp.toString()),e.methods&&t.set("methods",e.methods.join(","));const s=t.toString();return`${e.protocol}:${e.topic}@${e.version}?${s}`}function kn(e,t,r){return`${e}?wc_ev=${r}&topic=${t}`}var Rn=Object.defineProperty,xn=Object.defineProperties,Un=Object.getOwnPropertyDescriptors,Dn=Object.getOwnPropertySymbols,$n=Object.prototype.hasOwnProperty,Mn=Object.prototype.propertyIsEnumerable,Ln=(e,t,r)=>t in e?Rn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,jn=(e,t)=>{for(var r in t||(t={}))$n.call(t,r)&&Ln(e,r,t[r]);if(Dn)for(var r of Dn(t))Mn.call(t,r)&&Ln(e,r,t[r]);return e},Bn=(e,t)=>xn(e,Un(t));function qn(e){const t=[];return e.forEach((e=>{const[r,s]=e.split(":");t.push(`${r}:${s}`)})),t}function Wn(e){return e.includes(":")}function Fn(e){return Wn(e)?e.split(":")[0]:e}function Hn(e){var t,r,s;const i={};if(!Xn(e))return i;for(const[n,o]of Object.entries(e)){const e=Wn(n)?[n]:o.chains,a=o.methods||[],c=o.events||[],l=Fn(n);i[l]=Bn(jn({},i[l]),{chains:_t(e,null==(t=i[l])?void 0:t.chains),methods:_t(a,null==(r=i[l])?void 0:r.methods),events:_t(c,null==(s=i[l])?void 0:s.events)})}return i}function zn(e,t){const r=function(e){const t={};return e?.forEach((e=>{var r;const[s,i]=e.split(":");t[s]||(t[s]={accounts:[],chains:[],events:[],methods:[]}),t[s].accounts.push(e),null==(r=t[s].chains)||r.push(`${s}:${i}`)})),t}(t=t.map((e=>e.replace("did:pkh:",""))));for(const[t,s]of Object.entries(r))s.methods?s.methods=_t(s.methods,e):s.methods=e,s.events=["chainChanged","accountsChanged"];return r}const Vn={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},Kn={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function Jn(e,t){const{message:r,code:s}=Kn[e];return{message:t?`${r} ${t}`:r,code:s}}function Gn(e,t){const{message:r,code:s}=Vn[e];return{message:t?`${r} ${t}`:r,code:s}}function Yn(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function Xn(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function Zn(e){return typeof e>"u"}function Qn(e,t){return!(!t||!Zn(e))||"string"==typeof e&&!!e.trim().length}function eo(e,t){return!(!t||!Zn(e))||"number"==typeof e&&!isNaN(e)}
1function to(e){return!(!Qn(e,!1)||!e.includes(":"))&&2===e.split(":").length}function ro(e){let t=!0;return Yn(e)?e.length&&(t=e.every((e=>Qn(e,!1)))):t=!1,t}function so(e,t,r){let s=null;return Object.entries(e).forEach((([e,i])=>{if(s)return;const n=function(e,t,r){let s=null;return Yn(t)&&t.length?t.forEach((e=>{s||to(e)||(s=Gn("UNSUPPORTED_CHAINS",`${r}, chain ${e} should be a string and conform to "namespace:chainId" format`))})):to(e)||(s=Gn("UNSUPPORTED_CHAINS",`${r}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),s}(e,Je(e,i),`${t} ${r}`);n&&(s=n)})),s}function io(e,t){let r=null;return Yn(e)?e.forEach((e=>{r||function(e){if(Qn(e,!1)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&to(e)}}return!1}(e)||(r=Gn("UNSUPPORTED_ACCOUNTS",`${t}, account ${e} should be a string and conform to "namespace:chainId:address" format`))})):r=Gn("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function no(e,t){let r=null;return Object.values(e).forEach((e=>{if(r)return;const s=function(e,t){let r=null;return ro(e?.methods)?ro(e?.events)||(r=Gn("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):r=Gn("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),r}(e,`${t}, namespace`);s&&(r=s)})),r}function oo(e,t){let r=null;if(e&&Xn(e)){const s=no(e,t);s&&(r=s);const i=function(e,t){let r=null;return Object.values(e).forEach((e=>{if(r)return;const s=io(e?.accounts,`${t} namespace`);s&&(r=s)})),r}(e,t);i&&(r=i)}else r=Jn("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return r}function ao(e){return Qn(e.protocol,!0)}function co(e){return typeof e<"u"&&null!==typeof e}function lo(e,t){return!(!to(t)||!function(e){const t=[];return Object.values(e).forEach((e=>{t.push(...qn(e.accounts))})),t}(e).includes(t))}function ho(e,t,r){return!!Qn(r,!1)&&function(e,t){const r=[];return Object.values(e).forEach((e=>{qn(e.accounts).includes(t)&&r.push(...e.methods)})),r}(e,t).includes(r)}function uo(e,t,r){return!!Qn(r,!1)&&function(e,t){const r=[];return Object.values(e).forEach((e=>{qn(e.accounts).includes(t)&&r.push(...e.events)})),r}(e,t).includes(r)}function po(e,t,r){let s=null;const i=function(e){const t={};return Object.keys(e).forEach((r=>{var s;r.includes(":")?t[r]=e[r]:null==(s=e[r].chains)||s.forEach((s=>{t[s]={methods:e[r].methods,events:e[r].events}}))})),t}(e),n=function(e){const t={};return Object.keys(e).forEach((r=>{if(r.includes(":"))t[r]=e[r];else{qn(e[r].accounts)?.forEach((s=>{t[s]={accounts:e[r].accounts.filter((e=>e.includes(`${s}:`))),methods:e[r].methods,events:e[r].events}}))}})),t}(t),o=Object.keys(i),a=Object.keys(n),c=go(Object.keys(e)),l=go(Object.keys(t)),h=c.filter((e=>!l.includes(e)));return h.length&&(s=Jn("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.\n      Required: ${h.toString()}\n      Received: ${Object.keys(t).toString()}`)),wt(o,a)||(s=Jn("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.\n      Required: ${o.toString()}\n      Approved: ${a.toString()}`)),Object.keys(t).forEach((e=>{if(!e.includes(":")||s)return;const i=qn(t[e].accounts);i.includes(e)||(s=Jn("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${e}\n        Required: ${e}\n        Approved: ${i.toString()}`))})),o.forEach((e=>{s||(wt(i[e].methods,n[e].methods)?wt(i[e].events,n[e].events)||(s=Jn("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${e}`)):s=Jn("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${e}`))})),s}function go(e){return[...new Set(e.map((e=>e.includes(":")?e.split(":")[0]:e)))]}function fo(){const e=ut();return new Promise((t=>{switch(e){case nt:t(ht()&&navigator?.onLine);break;case st:t(async function(){if(lt()&&typeof r.g<"u"&&null!=r.g&&r.g.NetInfo){return(await(null==r.g?void 0:r.g.NetInfo.fetch()))?.isConnected}return!0}());break;default:t(!0)}}))}function mo(e){switch(ut()){case nt:!function(e){!lt()&&ht()&&(window.addEventListener("online",(()=>e(!0))),window.addEventListener("offline",(()=>e(!1))))}(e);break;case st:!function(e){lt()&&typeof r.g<"u"&&null!=r.g&&r.g.NetInfo&&r.g?.NetInfo.addEventListener((t=>e(t?.isConnected)))}(e)}}const wo={};class yo{static get(e){return wo[e]}static set(e,t){wo[e]=t}static delete(e){delete wo[e]}}var bo=r(64534),vo=r(56186),Co=r(28939),Eo=r(48764).Buffer,No=r(34155);const Io="core",Ao=`wc@2:${Io}:`,So="error",_o={database:":memory:"},Oo="client_ed25519_seed",Po=O.ONE_DAY,To=O.SIX_HOURS,ko="wss://relay.walletconnect.org",Ro="relayer_message",xo="relayer_message_ack",Uo="relayer_connect",Do="relayer_disconnect",$o="relayer_error",Mo="relayer_connection_stalled",Lo="relayer_publish",jo="payload",Bo="connect",qo="disconnect",Wo="error",Fo="2.21.0",Ho={link_mode:"link_mode",relay:"relay"},zo="inbound",Vo="outbound",Ko="WALLETCONNECT_LINK_MODE_APPS",Jo="subscription_created",Go="subscription_deleted",Yo="subscription_sync",Xo="subscription_resubscribed",Zo=(O.FIVE_SECONDS,{wc_pairingDelete:{req:{ttl:O.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:O.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:O.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:O.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:O.ONE_DAY,prompt:!1,tag:0},res:{ttl:O.ONE_DAY,prompt:!1,tag:0}}}),Qo="pairing_create",ea="pairing_expire",ta="pairing_delete",ra="pairing_ping",sa="history_created",ia="history_updated",na="history_deleted",oa="history_sync",aa="expirer_created",ca="expirer_deleted",la="expirer_expired",ha="expirer_sync",ua="https://verify.walletconnect.org",da=ua,pa=`${da}/v3`,ga=["https://verify.walletconnect.com",ua],fa="pairing_started",ma="pairing_uri_validation_success",wa="pairing_uri_not_expired",ya="store_new_pairing",ba="subscribing_pairing_topic",va="subscribe_pairing_topic_success",Ca="existing_pairing",Ea="pairing_not_expired",Na="emit_inactive_pairing",Ia="emit_session_proposal",Aa="no_internet_connection",Sa="malformed_pairing_uri",_a="active_pairing_already_exists",Oa="subscribe_pairing_topic_failure",Pa="pairing_expired",Ta="proposal_listener_not_found",ka="session_approve_started",Ra="session_namespaces_validation_success",xa="subscribing_session_topic",Ua="subscribe_session_topic_success",Da="publishing_session_approve",$a="session_approve_publish_success",Ma="store_session",La="publishing_session_settle",ja="session_settle_publish_success",Ba="no_internet_connection",qa="proposal_expired",Wa="subscribe_session_topic_failure",Fa="session_approve_publish_failure",Ha="session_settle_publish_failure",za="session_approve_namespace_validation_failure",Va="proposal_not_found",Ka="authenticated_session_approve_started",Ja="create_authenticated_session_topic",Ga="cacaos_verified",Ya="store_authenticated_session",Xa="subscribing_authenticated_session_topic",Za="subscribe_authenticated_session_topic_success",Qa="publishing_authenticated_session_approve",ec="no_internet_connection",tc="invalid_cacao",rc="subscribe_authenticated_session_topic_failure",sc="authenticated_session_approve_publish_failure",ic="authenticated_session_pending_request_not_found";var nc=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");
1for(var r=new Uint8Array(256),s=0;s<r.length;s++)r[s]=255;for(var i=0;i<e.length;i++){var n=e.charAt(i),o=n.charCodeAt(0);if(255!==r[o])throw new TypeError(n+" is ambiguous");r[o]=i}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function u(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var s=0,i=0;e[t]===c;)s++,t++;for(var n=(e.length-t)*l+1>>>0,o=new Uint8Array(n);e[t];){var h=r[e.charCodeAt(t)];if(255===h)return;for(var u=0,d=n-1;(0!==h||u<i)&&-1!==d;d--,u++)h+=a*o[d]>>>0,o[d]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");i=u,t++}if(" "!==e[t]){for(var p=n-i;p!==n&&0===o[p];)p++;for(var g=new Uint8Array(s+(n-p)),f=s;p!==n;)g[f++]=o[p++];return g}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var r=0,s=0,i=0,n=t.length;i!==n&&0===t[i];)i++,r++;for(var o=(n-i)*h+1>>>0,l=new Uint8Array(o);i!==n;){for(var u=t[i],d=0,p=o-1;(0!==u||d<s)&&-1!==p;p--,d++)u+=256*l[p]>>>0,l[p]=u%a>>>0,u=u/a>>>0;if(0!==u)throw new Error("Non-zero carry");s=d,i++}for(var g=o-s;g!==o&&0===l[g];)g++;for(var f=c.repeat(r);g<o;++g)f+=e.charAt(l[g]);return f},decodeUnsafe:u,decode:function(e){var r=u(e);if(r)return r;throw new Error(`Non-${t} character`)}}},oc=nc;const ac=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class cc{constructor(e,t,r){this.name=e,this.prefix=t,this.baseEncode=r}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class lc{constructor(e,t,r){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=r}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return uc(this,e)}}class hc{constructor(e){this.decoders=e}or(e){return uc(this,e)}decode(e){const t=e[0],r=this.decoders[t];if(r)return r.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const uc=(e,t)=>new hc({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class dc{constructor(e,t,r,s){this.name=e,this.prefix=t,this.baseEncode=r,this.baseDecode=s,this.encoder=new cc(e,t,r),this.decoder=new lc(e,t,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const pc=({name:e,prefix:t,encode:r,decode:s})=>new dc(e,t,r,s),gc=({prefix:e,name:t,alphabet:r})=>{const{encode:s,decode:i}=oc(r,t);return pc({prefix:e,name:t,encode:s,decode:e=>ac(i(e))})},fc=({name:e,prefix:t,bitsPerChar:r,alphabet:s})=>pc({prefix:t,name:e,encode(e){return((e,t,r)=>{const s="="===t[t.length-1],i=(1<<r)-1;let n="",o=0,a=0;for(let s=0;s<e.length;++s)for(a=a<<8|e[s],o+=8;o>r;)o-=r,n+=t[i&a>>o];if(o&&(n+=t[i&a<<r-o]),s)for(;n.length*r&7;)n+="=";return n})(e,s,r)},decode(t){return((e,t,r,s)=>{const i={};for(let e=0;e<t.length;++e)i[t[e]]=e;let n=e.length;for(;"="===e[n-1];)--n;const o=new Uint8Array(n*r/8|0);let a=0,c=0,l=0;for(let t=0;t<n;++t){const n=i[e[t]];if(void 0===n)throw new SyntaxError(`Non-${s} character`);c=c<<r|n,a+=r,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,s,r,e)}}),mc=pc({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var wc=Object.freeze({__proto__:null,identity:mc});const yc=fc({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var bc=Object.freeze({__proto__:null,base2:yc});const vc=fc({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Cc=Object.freeze({__proto__:null,base8:vc});const Ec=gc({prefix:"9",name:"base10",alphabet:"0123456789"});var Nc=Object.freeze({__proto__:null,base10:Ec});const Ic=fc({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ac=fc({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Sc=Object.freeze({__proto__:null,base16:Ic,base16upper:Ac});const _c=fc({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Oc=fc({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Pc=fc({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Tc=fc({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),kc=fc({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Rc=fc({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),xc=fc({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Uc=fc({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Dc=fc({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var $c=Object.freeze({__proto__:null,base32:_c,base32upper:Oc,base32pad:Pc,base32padupper:Tc,base32hex:kc,base32hexupper:Rc,base32hexpad:xc,base32hexpadupper:Uc,base32z:Dc});const Mc=gc({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Lc=gc({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var jc=Object.freeze({__proto__:null,base36:Mc,base36upper:Lc});const Bc=gc({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),qc=gc({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Wc=Object.freeze({__proto__:null,base58btc:Bc,base58flickr:qc});const Fc=fc({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
1+/",bitsPerChar:6}),Hc=fc({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),zc=fc({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Vc=fc({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Kc=Object.freeze({__proto__:null,base64:Fc,base64pad:Hc,base64url:zc,base64urlpad:Vc});const Jc=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),Gc=Jc.reduce(((e,t,r)=>(e[r]=t,e)),[]),Yc=Jc.reduce(((e,t,r)=>(e[t.codePointAt(0)]=r,e)),[]);const Xc=pc({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=Gc[t]),"")},decode:function(e){const t=[];for(const r of e){const e=Yc[r.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${r}`);t.push(e)}return new Uint8Array(t)}});var Zc=Object.freeze({__proto__:null,base256emoji:Xc}),Qc=function e(t,r,s){r=r||[];for(var i=s=s||0;t>=el;)r[s++]=255&t|128,t/=128;for(;-128&t;)r[s++]=255&t|128,t>>>=7;return r[s]=0|t,e.bytes=s-i+1,r},el=Math.pow(2,31);var tl=function e(t,r){var s,i=0,n=(r=r||0,0),o=r,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");s=t[o++],i+=n<28?(127&s)<<n:(127&s)*Math.pow(2,n),n+=7}while(s>=128);return e.bytes=o-r,i};var rl=Math.pow(2,7),sl=Math.pow(2,14),il=Math.pow(2,21),nl=Math.pow(2,28),ol=Math.pow(2,35),al=Math.pow(2,42),cl=Math.pow(2,49),ll=Math.pow(2,56),hl=Math.pow(2,63),ul={encode:Qc,decode:tl,encodingLength:function(e){return e<rl?1:e<sl?2:e<il?3:e<nl?4:e<ol?5:e<al?6:e<cl?7:e<ll?8:e<hl?9:10}};const dl=(e,t,r=0)=>(ul.encode(e,t,r),t),pl=e=>ul.encodingLength(e),gl=(e,t)=>{const r=t.byteLength,s=pl(e),i=s+pl(r),n=new Uint8Array(i+r);return dl(e,n,0),dl(r,n,s),n.set(t,i),new fl(e,r,t,n)};class fl{constructor(e,t,r,s){this.code=e,this.size=t,this.digest=r,this.bytes=s}}const ml=({name:e,code:t,encode:r})=>new wl(e,t,r);class wl{constructor(e,t,r){this.name=e,this.code=t,this.encode=r}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?gl(this.code,t):t.then((e=>gl(this.code,e)))}throw Error("Unknown type, must be binary type")}}const yl=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),bl=ml({name:"sha2-256",code:18,encode:yl("SHA-256")}),vl=ml({name:"sha2-512",code:19,encode:yl("SHA-512")});Object.freeze({__proto__:null,sha256:bl,sha512:vl});const Cl=ac,El={code:0,name:"identity",encode:Cl,digest:e=>gl(0,Cl(e))};Object.freeze({__proto__:null,identity:El});new TextEncoder,new TextDecoder;const Nl={...wc,...bc,...Cc,...Nc,...Sc,...$c,...jc,...Wc,...Kc,...Zc};function Il(e,t,r,s){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:s}}}const Al=Il("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Sl=Il("ascii","a",(e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t}),(e=>{const t=function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}((e=e.substring(1)).length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t})),_l={utf8:Al,"utf-8":Al,hex:Nl.base16,latin1:Sl,ascii:Sl,binary:Sl,...Nl};var Ol=Object.defineProperty,Pl=(e,t,r)=>((e,t,r)=>t in e?Ol(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Tl{constructor(e,t){this.core=e,this.logger=t,Pl(this,"keychain",new Map),Pl(this,"name","keychain"),Pl(this,"version","0.3"),Pl(this,"initialized",!1),Pl(this,"storagePrefix",Ao),Pl(this,"init",(async()=>
1{if(!this.initialized){const e=await this.getKeyChain();typeof e<"u"&&(this.keychain=e),this.initialized=!0}})),Pl(this,"has",(e=>(this.isInitialized(),this.keychain.has(e)))),Pl(this,"set",(async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()})),Pl(this,"get",(e=>{this.isInitialized();const t=this.keychain.get(e);if(typeof t>"u"){const{message:t}=Jn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t})),Pl(this,"del",(async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()})),this.core=e,this.logger=(0,a.Ep)(t,this.name)}get context(){return(0,a.Fd)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,yt(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?bt(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=Jn("NOT_INITIALIZED",this.name);throw new Error(e)}}}var kl=Object.defineProperty,Rl=(e,t,r)=>((e,t,r)=>t in e?kl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class xl{constructor(e,t,r){this.core=e,this.logger=t,Rl(this,"name","crypto"),Rl(this,"keychain"),Rl(this,"randomSessionIdentifier",dn()),Rl(this,"initialized",!1),Rl(this,"init",(async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)})),Rl(this,"hasKeys",(e=>(this.isInitialized(),this.keychain.has(e)))),Rl(this,"getClientId",(async()=>{this.isInitialized();const e=await this.getClientSeed(),t=T.Au(e);return T.bG(t.publicKey)})),Rl(this,"generateKeyPair",(()=>{this.isInitialized();const e=function(){const e=Vi.utils.randomPrivateKey(),t=Vi.getPublicKey(e);return{privateKey:(0,We.BB)(e,cn),publicKey:(0,We.BB)(t,cn)}}();return this.setPrivateKey(e.publicKey,e.privateKey)})),Rl(this,"signJWT",(async e=>{this.isInitialized();const t=await this.getClientSeed(),r=T.Au(t),s=this.randomSessionIdentifier,i=Po;return await T.vf(s,e,i,r)})),Rl(this,"generateSharedKey",((e,t,r)=>{this.isInitialized();const s=function(e,t){const r=Vi.getSharedSecret((0,We.mL)(e,cn),(0,We.mL)(t,cn)),s=Cs(Ps,r,void 0,void 0,32);return(0,We.BB)(s,cn)}(this.getPrivateKey(e),t);return this.setSymKey(s,r)})),Rl(this,"setSymKey",(async(e,t)=>{this.isInitialized();const r=t||pn(e);return await this.keychain.set(r,e),r})),Rl(this,"deleteKeyPair",(async e=>{this.isInitialized(),await this.keychain.del(e)})),Rl(this,"deleteSymKey",(async e=>{this.isInitialized(),await this.keychain.del(e)})),Rl(this,"encode",(async(e,t,r)=>{this.isInitialized();const s=Cn(r),i=(0,P.u)(t);if(Nn(s))return function(e,t){const r=fn(2),s=Yt(12),i=bn({type:r,sealed:(0,We.mL)(e,un),iv:s});return t===hn?wn(i):i}(i,r?.encoding);if(En(s)){const t=s.senderPublicKey,r=s.receiverPublicKey;e=await this.generateSharedKey(t,r)}const n=this.getSymKey(e),{type:o,senderPublicKey:a}=s;return function(e){const t=fn(typeof e.type<"u"?e.type:0);if(1===mn(t)&&typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof e.senderPublicKey<"u"?(0,We.mL)(e.senderPublicKey,cn):void 0,s=typeof e.iv<"u"?(0,We.mL)(e.iv,cn):Yt(12),i=(0,We.mL)(e.symKey,cn),n=bn({type:t,sealed:fs(i,s).encrypt((0,We.mL)(e.message,un)),iv:s,senderPublicKey:r});return e.encoding===hn?wn(n):n}({type:o,symKey:n,message:i,senderPublicKey:a,encoding:r?.encoding})})),Rl(this,"decode",(async(e,t,r)=>{this.isInitialized();const s=function(e,t){const r=vn({encoded:e,encoding:t?.encoding});return Cn({type:mn(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?(0,We.BB)(r.senderPublicKey,cn):void 0,receiverPublicKey:t?.receiverPublicKey})}(t,r);if(Nn(s)){const e=function(e,t){const{sealed:r}=vn({encoded:e,encoding:t});return(0,We.BB)(r,un)}(t,r?.encoding);return(0,P.D)(e)}if(En(s)){const t=s.receiverPublicKey,r=s.senderPublicKey;e=await this.generateSharedKey(t,r)}try{const s=function(e){const t=(0,We.mL)(e.symKey,cn),{sealed:r,iv:s}=vn({encoded:e.encoded,encoding:e.encoding}),i=fs(t,s).decrypt(r);if(null===i)throw new Error("Failed to decrypt");return(0,We.BB)(i,un)}({symKey:this.getSymKey(e),encoded:t,encoding:r?.encoding});return(0,P.D)(s)}catch(t){this.logger.error(`Failed to decode message from topic: '${e}', clientId: '${await this.getClientId()}'`),this.logger.error(t)}})),Rl(this,"getPayloadType",((e,t=ln)=>mn(vn({encoded:e,encoding:t}).type))),Rl(this,"getPayloadSenderPublicKey",((e,t=ln)=>{const r=vn({encoded:e,encoding:t});return r.senderPublicKey?(0,We.BB)(r.senderPublicKey,cn):void 0})),this.core=e,this.logger=(0,a.Ep)(t,this.name),this.keychain=r||new Tl(this.core,this.logger)}get context(){return(0,a.Fd)(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(Oo)}catch{e=dn(),await this.keychain.set(Oo,e)}return function(e,t="utf8"){const r=_l[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?r.decoder.decode(`${r.prefix}${e}`):globalThis.Buffer.from(e,"utf8")}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=Jn("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Ul=Object.defineProperty,Dl=Object.defineProperties,$l=Object.getOwnPropertyDescriptors,Ml=Object.getOwnPropertySymbols,Ll=Object.prototype.hasOwnProperty,jl=Object.prototype.propertyIsEnumerable,Bl=(e,t,r)=>t in e?Ul(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ql=(e,t,r)=>Bl(e,"symbol"!=typeof t?t+"":t,r);class Wl extends f{constructor(e,t){super(e,t),this.logger=e,this.core=t,ql(this,"messages",new Map),ql(this,"messagesWithoutClientAck",new Map),ql(this,"name","messages"),ql(this,"version","0.3"),ql(this,"initialized",!1),ql(this,"storagePrefix",Ao),ql(this,"init",(async()=>
1{if(!this.initialized){this.logger.trace("Initialized");try{const e=await this.getRelayerMessages();typeof e<"u"&&(this.messages=e);const t=await this.getRelayerMessagesWithoutClientAck();typeof t<"u"&&(this.messagesWithoutClientAck=t),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}})),ql(this,"set",(async(e,t,r)=>{this.isInitialized();const s=gn(t);let i=this.messages.get(e);if(typeof i>"u"&&(i={}),typeof i[s]<"u")return s;if(i[s]=t,this.messages.set(e,i),r===zo){const r=this.messagesWithoutClientAck.get(e)||{};this.messagesWithoutClientAck.set(e,((e,t)=>Dl(e,$l(t)))(((e,t)=>{for(var r in t||(t={}))Ll.call(t,r)&&Bl(e,r,t[r]);if(Ml)for(var r of Ml(t))jl.call(t,r)&&Bl(e,r,t[r]);return e})({},r),{[s]:t}))}return await this.persist(),s})),ql(this,"get",(e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t})),ql(this,"getWithoutAck",(e=>{this.isInitialized();const t={};for(const r of e){const e=this.messagesWithoutClientAck.get(r)||{};t[r]=Object.values(e)}return t})),ql(this,"has",((e,t)=>{this.isInitialized();return typeof this.get(e)[gn(t)]<"u"})),ql(this,"ack",(async(e,t)=>{this.isInitialized();const r=this.messagesWithoutClientAck.get(e);if(typeof r>"u")return;delete r[gn(t)],0===Object.keys(r).length?this.messagesWithoutClientAck.delete(e):this.messagesWithoutClientAck.set(e,r),await this.persist()})),ql(this,"del",(async e=>{this.isInitialized(),this.messages.delete(e),this.messagesWithoutClientAck.delete(e),await this.persist()})),this.logger=(0,a.Ep)(e,this.name),this.core=t}get context(){return(0,a.Fd)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,yt(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,yt(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?bt(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?bt(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=Jn("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Fl=Object.defineProperty,Hl=Object.defineProperties,zl=Object.getOwnPropertyDescriptors,Vl=Object.getOwnPropertySymbols,Kl=Object.prototype.hasOwnProperty,Jl=Object.prototype.propertyIsEnumerable,Gl=(e,t,r)=>t in e?Fl(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Yl=(e,t)=>{for(var r in t||(t={}))Kl.call(t,r)&&Gl(e,r,t[r]);if(Vl)for(var r of Vl(t))Jl.call(t,r)&&Gl(e,r,t[r]);return e},Xl=(e,t)=>Hl(e,zl(t)),Zl=(e,t,r)=>Gl(e,"symbol"!=typeof t?t+"":t,r);class Ql extends m{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,Zl(this,"events",new s.EventEmitter),Zl(this,"name","publisher"),Zl(this,"queue",new Map),Zl(this,"publishTimeout",(0,O.toMiliseconds)(O.ONE_MINUTE)),Zl(this,"initialPublishTimeout",(0,O.toMiliseconds)(15*O.ONE_SECOND)),Zl(this,"needsTransportRestart",!1),Zl(this,"publish",(async(e,t,r)=>{var s;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:r}});const i=r?.ttl||To,n=An(r),o=r?.prompt||!1,a=r?.tag||0,c=r?.id||(0,vo.getBigIntRpcId)().toString(),l={topic:e,message:t,opts:{ttl:i,relay:n,prompt:o,tag:a,id:c,attestation:r?.attestation,tvf:r?.tvf}},h=`Failed to publish payload, please try again. id:${c} tag:${a}`;try{const s=new Promise((async s=>{const n=({id:e})=>{l.opts.id===e&&(this.removeRequestFromQueue(e),this.relayer.events.removeListener(Lo,n),s(l))};this.relayer.events.on(Lo,n);const h=Ct(new Promise(((s,n)=>{this.rpcPublish({topic:e,message:t,ttl:i,prompt:o,tag:a,id:c,attestation:r?.attestation,tvf:r?.tvf}).then(s).catch((e=>{this.logger.warn(e,e?.message),n(e)}))})),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${c} tag:${a}`);try{await h,this.events.removeListener(Lo,n)}catch(e){this.queue.set(c,Xl(Yl({},l),{attempt:1})),this.logger.warn(e,e?.message)}}));this.logger.trace({type:"method",method:"publish",params:{id:c,topic:e,message:t,opts:r}}),await Ct(s,this.publishTimeout,h)}catch(e){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(e),null!=(s=r?.internal)&&s.throwOnFailedPublish)throw e}finally{this.queue.delete(c)}})),Zl(this,"on",((e,t)=>
1{this.events.on(e,t)})),Zl(this,"once",((e,t)=>{this.events.once(e,t)})),Zl(this,"off",((e,t)=>{this.events.off(e,t)})),Zl(this,"removeListener",((e,t)=>{this.events.removeListener(e,t)})),this.relayer=e,this.logger=(0,a.Ep)(t,this.name),this.registerEventListeners()}get context(){return(0,a.Fd)(this.logger)}async rpcPublish(e){var t,r,s,i;const{topic:n,message:o,ttl:a=To,prompt:c,tag:l,id:h,attestation:u,tvf:d}=e,p={method:Sn(An().protocol).publish,params:Yl({topic:n,message:o,ttl:a,prompt:c,tag:l,attestation:u},d),id:h};Zn(null==(t=p.params)?void 0:t.prompt)&&(null==(r=p.params)||delete r.prompt),Zn(null==(s=p.params)?void 0:s.tag)&&(null==(i=p.params)||delete i.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:p});const g=await this.relayer.request(p);return this.relayer.events.emit(Lo,e),this.logger.debug("Successfully Published Payload"),g}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach((async(e,t)=>{const r=e.attempt+1;this.queue.set(t,Xl(Yl({},e),{attempt:r}));const{topic:s,message:i,opts:n,attestation:o}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${r}`),await this.rpcPublish(Xl(Yl({},e),{topic:s,message:i,ttl:n.ttl,prompt:n.prompt,tag:n.tag,id:n.id,attestation:o,tvf:n.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)}))}registerEventListeners(){this.relayer.core.heartbeat.on(n.Lx.pulse,(()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(Mo);this.checkQueue()})),this.relayer.on(xo,(e=>{this.removeRequestFromQueue(e.id.toString())}))}}var eh=Object.defineProperty,th=(e,t,r)=>((e,t,r)=>t in e?eh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class rh{constructor(){th(this,"map",new Map),th(this,"set",((e,t)=>{const r=this.get(e);this.exists(e,t)||this.map.set(e,[...r,t])})),th(this,"get",(e=>this.map.get(e)||[])),th(this,"exists",((e,t)=>this.get(e).includes(t))),th(this,"delete",((e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const r=this.get(e);if(!this.exists(e,t))return;const s=r.filter((e=>e!==t));s.length?this.map.set(e,s):this.map.delete(e)})),th(this,"clear",(()=>{this.map.clear()}))}get topics(){return Array.from(this.map.keys())}}var sh=Object.defineProperty,ih=Object.defineProperties,nh=Object.getOwnPropertyDescriptors,oh=Object.getOwnPropertySymbols,ah=Object.prototype.hasOwnProperty,ch=Object.prototype.propertyIsEnumerable,lh=(e,t,r)=>t in e?sh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,hh=(e,t)=>{for(var r in t||(t={}))ah.call(t,r)&&lh(e,r,t[r]);if(oh)for(var r of oh(t))ch.call(t,r)&&lh(e,r,t[r]);return e},uh=(e,t)=>ih(e,nh(t)),dh=(e,t,r)=>lh(e,"symbol"!=typeof t?t+"":t,r);class ph extends b{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,dh(this,"subscriptions",new Map),dh(this,"topicMap",new rh),dh(this,"events",new s.EventEmitter),dh(this,"name","subscription"),dh(this,"version","0.3"),dh(this,"pending",new Map),dh(this,"cached",[]),dh(this,"initialized",!1),dh(this,"storagePrefix",Ao),dh(this,"subscribeTimeout",(0,O.toMiliseconds)(O.ONE_MINUTE)),dh(this,"initialSubscribeTimeout",(0,O.toMiliseconds)(15*O.ONE_SECOND)),dh(this,"clientId"),dh(this,"batchSubscribeTopicsLimit",500),dh(this,"init",(async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0})),dh(this,"subscribe",(async(e,t)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const r=An(t),s={topic:e,relay:r,transportType:t?.transportType};this.pending.set(e,s);const i=await this.rpcSubscribe(e,r,t);return"string"==typeof i&&(this.onSubscribe(i,s),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}})),i}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}})),dh(this,"unsubscribe",(async(e,t)=>{this.isInitialized(),typeof t?.id<"u"?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)})),dh(this,"isSubscribed",(e=>new Promise((t=>{t(this.topicMap.topics.includes(e))})))),dh(this,"isKnownTopic",(e=>new Promise((t=>{t(this.topicMap.topics.includes(e)||this.pending.has(e)||this.cached.some((t=>t.topic===e)))})))),dh(this,"on",((e,t)=>
1{this.events.on(e,t)})),dh(this,"once",((e,t)=>{this.events.once(e,t)})),dh(this,"off",((e,t)=>{this.events.off(e,t)})),dh(this,"removeListener",((e,t)=>{this.events.removeListener(e,t)})),dh(this,"start",(async()=>{await this.onConnect()})),dh(this,"stop",(async()=>{await this.onDisconnect()})),dh(this,"restart",(async()=>{await this.restore(),await this.onRestart()})),dh(this,"checkPending",(async()=>{if(!(0!==this.pending.size||this.initialized&&this.relayer.connected))return;const e=[];this.pending.forEach((t=>{e.push(t)})),await this.batchSubscribe(e)})),dh(this,"registerEventListeners",(()=>{this.relayer.core.heartbeat.on(n.Lx.pulse,(async()=>{await this.checkPending()})),this.events.on(Jo,(async e=>{const t=Jo;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})),this.events.on(Go,(async e=>{const t=Go;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}))})),this.relayer=e,this.logger=(0,a.Ep)(t,this.name),this.clientId=""}get context(){return(0,a.Fd)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,t){let r=!1;try{r=this.getSubscription(e).topic===t}catch{}return r}reset(){this.cached=[],this.initialized=!0}onDisable(){this.values.length>0&&(this.cached=this.values),this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const r=this.topicMap.get(e);await Promise.all(r.map((async r=>await this.unsubscribeById(e,r,t))))}async unsubscribeById(e,t,r){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:r}});try{const s=An(r);await this.restartToComplete({topic:e,id:t,relay:s}),await this.rpcUnsubscribe(e,t,s);const i=Gn("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,i),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:r}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t,r){var s;(!r||r?.transportType===Ho.relay)&&await this.restartToComplete({topic:e,id:e,relay:t});const i={method:Sn(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});const n=null==(s=r?.internal)?void 0:s.throwOnFailedPublish;
1try{const t=await this.getSubscriptionId(e);if(r?.transportType===Ho.link_mode)return setTimeout((()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(i).catch((e=>this.logger.warn(e)))}),(0,O.toMiliseconds)(O.ONE_SECOND)),t;const s=new Promise((async t=>{const r=s=>{s.topic===e&&(this.events.removeListener(Jo,r),t(s.id))};this.events.on(Jo,r);try{const s=await Ct(new Promise(((e,t)=>{this.relayer.request(i).catch((e=>{this.logger.warn(e,e?.message),t(e)})).then(e)})),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(Jo,r),t(s)}catch{}})),o=await Ct(s,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!o&&n)throw new Error(`Subscribing to ${e} failed, please try again`);return o?t:null}catch(e){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Mo),n)throw e}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t={method:Sn(e[0].relay.protocol).batchSubscribe,params:{topics:e.map((e=>e.topic))}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});try{await await Ct(new Promise((e=>{this.relayer.request(t).catch((e=>this.logger.warn(e))).then(e)})),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(Mo)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t={method:Sn(e[0].relay.protocol).batchFetchMessages,params:{topics:e.map((e=>e.topic))}};let r;this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});try{r=await await Ct(new Promise(((e,r)=>{this.relayer.request(t).catch((e=>{this.logger.warn(e),r(e)})).then(e)})),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(Mo)}return r}rpcUnsubscribe(e,t,r){const s={method:Sn(r.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(e,t){this.setSubscription(e,uh(hh({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach((e=>{this.setSubscription(e.id,hh({},e)),this.pending.delete(e.topic)}))}async onUnsubscribe(e,t,r){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,r),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,hh({},t)),this.topicMap.set(t.topic,e),this.events.emit(Jo,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:t}=Jn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const r=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(r.topic,e),this.events.emit(Go,uh(hh({},r),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Yo)}async onRestart(){if(this.cached.length){const e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<t;r++){const t=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(t)}}this.events.emit(Xo)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:e}=Jn("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map((async e=>uh(hh({}
1,e),{id:await this.getSubscriptionId(e.topic)}))))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await function(e){return new Promise((t=>setTimeout(t,e)))}((0,O.toMiliseconds)(O.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(t.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=Jn("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return gn(e+await this.getClientId())}}var gh=Object.defineProperty,fh=Object.getOwnPropertySymbols,mh=Object.prototype.hasOwnProperty,wh=Object.prototype.propertyIsEnumerable,yh=(e,t,r)=>t in e?gh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,bh=(e,t)=>{for(var r in t||(t={}))mh.call(t,r)&&yh(e,r,t[r]);if(fh)for(var r of fh(t))wh.call(t,r)&&yh(e,r,t[r]);return e},vh=(e,t,r)=>yh(e,"symbol"!=typeof t?t+"":t,r);class Ch extends w{constructor(e){super(e),vh(this,"protocol","wc"),vh(this,"version",2),vh(this,"core"),vh(this,"logger"),vh(this,"events",new s.EventEmitter),vh(this,"provider"),vh(this,"messages"),vh(this,"subscriber"),vh(this,"publisher"),vh(this,"name","relayer"),vh(this,"transportExplicitlyClosed",!1),vh(this,"initialized",!1),vh(this,"connectionAttemptInProgress",!1),vh(this,"relayUrl"),vh(this,"projectId"),vh(this,"packageName"),vh(this,"bundleId"),vh(this,"hasExperiencedNetworkDisruption",!1),vh(this,"pingTimeout"),vh(this,"heartBeatTimeout",(0,O.toMiliseconds)(O.THIRTY_SECONDS+O.FIVE_SECONDS)),vh(this,"reconnectTimeout"),vh(this,"connectPromise"),vh(this,"reconnectInProgress",!1),vh(this,"requestsInFlight",[]),vh(this,"connectTimeout",(0,O.toMiliseconds)(15*O.ONE_SECOND)),vh(this,"request",(async e=>{var t,r;this.logger.debug("Publishing Request Payload");const s=e.id||(0,vo.getBigIntRpcId)().toString();await this.toEstablishConnection();try{this.logger.trace({id:s,method:e.method,topic:null==(t=e.params)?void 0:t.topic},"relayer.request - publishing...");const i=`${s}:${(null==(r=e.params)?void 0:r.tag)||""}`;this.requestsInFlight.push(i);const n=await this.provider.request(e);return this.requestsInFlight=this.requestsInFlight.filter((e=>e!==i)),n}catch(e){throw this.logger.debug(`Failed to Publish Request: ${s}`),e}})),vh(this,"resetPingTimeout",(()=>{ct()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout((()=>{var e,t,r,s;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),null==(s=null==(r=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:r.terminate)||s.call(r)}catch(e){this.logger.warn(e,e?.message)}}),this.heartBeatTimeout))})),vh(this,"onPayloadHandler",(e=>{this.onProviderPayload(e),this.resetPingTimeout()})),vh(this,"onConnectHandler",(()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(Uo)})),vh(this,"onDisconnectHandler",(()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()})),vh(this,"onProviderErrorHandler",(e=>{this.logger.fatal(`Fatal socket error: ${e.message}`),this.events.emit($o,e),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()})),vh(this,"registerProviderListeners",(()=>{this.provider.on(jo,this.onPayloadHandler),this.provider.on(Bo,this.onConnectHandler),this.provider.on(qo,this.onDisconnectHandler),this.provider.on(Wo,this.onProviderErrorHandler)})),this.core=e.core,this.logger=typeof e.logger<"u"&&"string"!=typeof e.logger?(0,a.Ep)(e.logger,this.name):(0,a.gw)((0,a.jI)({level:e.logger||"error"})),this.messages=new Wl(this.logger,e.core),this.subscriber=new ph(this,this.logger),this.publisher=new Ql(this,this.logger),this.relayUrl=e?.relayUrl||ko,this.projectId=e.projectId,lt()&&typeof r.g<"u"&&typeof(null==r.g?void 0:r.g.Platform)<"u"&&"android"===(null==r.g?void 0:r.g.Platform.OS)?this.packageName=dt():lt()&&typeof r.g<"u"&&typeof(null==r.g?void 0:r.g.Platform)<"u"&&"ios"===(null==r.g?void 0:r.g.Platform.OS)&&(this.bundleId=dt()),this.provider={}}
1async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return(0,a.Fd)(this.logger)}get connected(){var e,t,r;return 1===(null==(r=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:r.readyState)||!1}get connecting(){var e,t,r;return 0===(null==(r=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:r.readyState)||void 0!==this.connectPromise||!1}async publish(e,t,r){this.isInitialized(),await this.publisher.publish(e,t,r),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:Ho.relay},Vo)}async subscribe(e,t){var r,s,i;this.isInitialized(),(null==t||!t.transportType||"relay"===t?.transportType)&&await this.toEstablishConnection();const n=typeof(null==(r=t?.internal)?void 0:r.throwOnFailedPublish)>"u"||(null==(s=t?.internal)?void 0:s.throwOnFailedPublish);let o,a=(null==(i=this.subscriber.topicMap.get(e))?void 0:i[0])||"";const c=t=>{t.topic===e&&(this.subscriber.off(Jo,c),o())};return await Promise.all([new Promise((e=>{o=e,this.subscriber.on(Jo,c)})),new Promise((async(r,s)=>{a=await this.subscriber.subscribe(e,bh({internal:{throwOnFailedPublish:n}},t)).catch((e=>{n&&s(e)}))||a,r()}))]),a}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await Ct(this.provider.disconnect(),2e3,"provider.disconnect()").catch((()=>this.onProviderDisconnect())):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(this.subscriber.hasAnyTopics){if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise((async(t,r)=>{await this.connect(e).then(t).catch(r).finally((()=>{this.connectPromise=void 0}))})),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}else this.logger.warn("Starting WS connection skipped because the client has no topics to work with.")}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await fo())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(0===e?.length)return void this.logger.trace("Batch message events is empty. Ignoring...");const t=e.sort(((e,t)=>e.publishedAt-t.publishedAt));this.logger.debug(`Batch of ${t.length} message events sorted`);for(const e of t)try{await this.onMessageEvent(e)}catch(e){this.logger.warn(e,"Error while processing batch message event: "+e?.message)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:r}=e;if(!t.sessionExists){const e={topic:r,expiry:It(O.FIVE_MINUTES),relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(r,e)}this.events.emit(Ro,e),await this.recordMessageEvent(e,zo)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let t=1;for(;t<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise((async(e,t)=>{const r=()=>
1{t(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(qo,r),await Ct(new Promise(((e,t)=>{this.provider.connect().then(e).catch(t)})),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch((e=>{t(e)})).finally((()=>{this.provider.off(qo,r),clearTimeout(this.reconnectTimeout)})),await new Promise((async(e,t)=>{const r=()=>{t(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(qo,r),await this.subscriber.start().then(e).catch(t).finally((()=>{this.provider.off(qo,r)}))})),this.hasExperiencedNetworkDisruption=!1,e()}))}catch(e){await this.subscriber.stop();const t=e;this.logger.warn({},t.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise((e=>setTimeout(e,(0,O.toMiliseconds)(1*t)))),t++}}startPingTimeout(){var e,t,r,s,i;if(ct())try{null!=(t=null==(e=this.provider)?void 0:e.connection)&&t.socket&&(null==(i=null==(s=null==(r=this.provider)?void 0:r.connection)?void 0:s.socket)||i.on("ping",(()=>{this.resetPingTimeout()}))),this.resetPingTimeout()}catch(e){this.logger.warn(e,e?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new bo.r(new Co.Z(mt({sdkVersion:Fo,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e,t){const{topic:r,message:s}=e;await this.messages.set(r,s,t)}async shouldIgnoreMessageEvent(e){const{topic:t,message:r}=e;if(!r||0===r.length)return this.logger.warn(`Ignoring invalid/empty message: ${r}`),!0;if(!await this.subscriber.isKnownTopic(t))return this.logger.warn(`Ignoring message for unknown topic ${t}`),!0;const s=this.messages.has(t,r);return s&&this.logger.warn(`Ignoring duplicate message: ${r}`),s}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),(0,vo.isJsonRpcRequest)(e)){if(!e.method.endsWith("_subscription"))return;const t=e.params,{topic:r,message:s,publishedAt:i,attestation:n}=t.data,o={topic:r,message:s,publishedAt:i,transportType:Ho.relay,attestation:n};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(bh({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o)}else(0,vo.isJsonRpcResponse)(e)&&this.events.emit(xo,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,zo),this.events.emit(Ro,e))}async acknowledgePayload(e){const t=(0,vo.formatJsonRpcResult)(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(jo,this.onPayloadHandler),this.provider.off(Bo,this.onConnectHandler),this.provider.off(qo,this.onDisconnectHandler),this.provider.off(Wo,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await fo();mo((async t=>{e!==t&&(e=t,t?await this.transportOpen().catch((e=>this.logger.error(e,e?.message))):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})),this.core.heartbeat.on(n.Lx.pulse,(async()=>{if(!this.transportExplicitlyClosed&&!this.connected&&function(){var e;return!ht()||!(0,R.getDocument)()||"visible"===(null==(e=(0,R.getDocument)())?void 0:e.visibilityState)}())try{await this.confirmOnlineStateOrThrow(),await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}))}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(Do),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout((async()=>{await this.transportOpen().catch((e=>this.logger.error(e,e?.message))),this.reconnectTimeout=void 0,this.reconnectInProgress=!1}),(0,O.toMiliseconds)(.1)))))}isInitialized(){if(!this.initialized){const{message:e}=Jn("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectPromise)return void await this.connectPromise;await this.connect()}}}function Eh(){}function Nh(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&"[object Object]"===Object.prototype.toString.call(e)}function Ih(e){return Object.getOwnPropertySymbols(e).filter((t=>Object.prototype.propertyIsEnumerable.call(e,t)))}
1function Ah(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Sh="[object Arguments]",_h="[object Object]";function Oh(e,t,r,s,i,n,o){const a=o(e,t,r,s,i,n);if(void 0!==a)return a;if(typeof e==typeof t)switch(typeof e){case"bigint":case"string":case"boolean":case"symbol":case"undefined":case"function":return e===t;case"number":return e===t||Object.is(e,t);case"object":return Ph(e,t,n,o)}return Ph(e,t,n,o)}function Ph(e,t,r,s){if(Object.is(e,t))return!0;let i=Ah(e),n=Ah(t);if(i===Sh&&(i=_h),n===Sh&&(n=_h),i!==n)return!1;switch(i){case"[object String]":return e.toString()===t.toString();case"[object Number]":return function(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}(e.valueOf(),t.valueOf());case"[object Boolean]":case"[object Date]":case"[object Symbol]":return Object.is(e.valueOf(),t.valueOf());case"[object RegExp]":return e.source===t.source&&e.flags===t.flags;case"[object Function]":return e===t}const o=(r=r??new Map).get(e),a=r.get(t);if(null!=o&&null!=a)return o===t;r.set(e,t),r.set(t,e);try{switch(i){case"[object Map]":if(e.size!==t.size)return!1;for(const[i,n]of e.entries())if(!t.has(i)||!Oh(n,t.get(i),i,e,t,r,s))return!1;return!0;case"[object Set]":{if(e.size!==t.size)return!1;const i=Array.from(e.values()),n=Array.from(t.values());for(let o=0;o<i.length;o++){const a=i[o],c=n.findIndex((i=>Oh(a,i,void 0,e,t,r,s)));if(-1===c)return!1;n.splice(c,1)}return!0}case"[object Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":case"[object BigUint64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object BigInt64Array]":case"[object Float32Array]":case"[object Float64Array]":if(typeof Eo<"u"&&Eo.isBuffer(e)!==Eo.isBuffer(t)||e.length!==t.length)return!1;for(let i=0;i<e.length;i++)if(!Oh(e[i],t[i],i,e,t,r,s))return!1;return!0;case"[object ArrayBuffer]":return e.byteLength===t.byteLength&&Ph(new Uint8Array(e),new Uint8Array(t),r,s);case"[object DataView]":return e.byteLength===t.byteLength&&e.byteOffset===t.byteOffset&&Ph(new Uint8Array(e),new Uint8Array(t),r,s);case"[object Error]":return e.name===t.name&&e.message===t.message;case _h:{if(!(Ph(e.constructor,t.constructor,r,s)||Nh(e)&&Nh(t)))return!1;const i=[...Object.keys(e),...Ih(e)],n=[...Object.keys(t),...Ih(t)];if(i.length!==n.length)return!1;for(let n=0;n<i.length;n++){const o=i[n],a=e[o];if(!Object.hasOwn(t,o))return!1;if(!Oh(a,t[o],o,e,t,r,s))return!1}return!0}default:return!1}}finally{r.delete(e),r.delete(t)}}function Th(e,t){return function(e,t,r){return Oh(e,t,void 0,void 0,void 0,void 0,r)}(e,t,Eh)}var kh=Object.defineProperty,Rh=Object.getOwnPropertySymbols,xh=Object.prototype.hasOwnProperty,Uh=Object.prototype.propertyIsEnumerable,Dh=(e,t,r)=>t in e?kh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,$h=(e,t)=>{for(var r in t||(t={}))xh.call(t,r)&&Dh(e,r,t[r]);if(Rh)for(var r of Rh(t))Uh.call(t,r)&&Dh(e,r,t[r]);return e},Mh=(e,t,r)=>Dh(e,"symbol"!=typeof t?t+"":t,r);class Lh extends y{constructor(e,t,r,s=Ao,i){super(e,t,r,s),this.core=e,this.logger=t,this.name=r,Mh(this,"map",new Map),Mh(this,"version","0.3"),Mh(this,"cached",[]),Mh(this,"initialized",!1),Mh(this,"getKey"),Mh(this,"storagePrefix",Ao),Mh(this,"recentlyDeleted",[]),Mh(this,"recentlyDeletedLimit",200),Mh(this,"init",(async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>{this.getKey&&null!==e&&!Zn(e)?this.map.set(this.getKey(e),e):function(e){var t;return null==(t=e?.proposer)?void 0:t.publicKey}(e)?this.map.set(e.id,e):function(e){return e?.topic}(e)&&this.map.set(e.topic,e)})),this.cached=[],this.initialized=!0)})),Mh(this,"set",(async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())})),Mh(this,"get",(e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e)))),Mh(this,"getAll",(e=>(this.isInitialized(),e?this.values.filter((t=>Object.keys(e).every((r=>Th(t[r],e[r]))))):this.values))),Mh(this,"update",(async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});const r=$h($h({},this.getData(e)),t);this.map.set(e,r),await this.persist()})),Mh(this,"delete",(async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",ke
1y:e,reason:t}),this.map.delete(e),this.addToRecentlyDeleted(e),await this.persist())})),this.logger=(0,a.Ep)(t,this.name),this.storagePrefix=s,this.getKey=i}get context(){return(0,a.Fd)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:t}=Jn("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}const{message:t}=Jn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:e}=Jn("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=Jn("NOT_INITIALIZED",this.name);throw new Error(e)}}}var jh=Object.defineProperty,Bh=(e,t,r)=>((e,t,r)=>t in e?jh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class qh{constructor(e,t){this.core=e,this.logger=t,Bh(this,"name","pairing"),Bh(this,"version","0.3"),Bh(this,"events",new(i())),Bh(this,"pairings"),Bh(this,"initialized",!1),Bh(this,"storagePrefix",Ao),Bh(this,"ignoredPayloadTypes",[1]),Bh(this,"registeredMethods",[]),Bh(this,"init",(async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))})),Bh(this,"register",(({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]})),Bh(this,"create",(async e=>{this.isInitialized();const t=dn(),r=await this.core.crypto.setSymKey(t),s=It(O.FIVE_MINUTES),i={protocol:"irn"},n={topic:r,expiry:s,relay:i,active:!1,methods:e?.methods},o=Tn({protocol:this.core.protocol,version:this.core.version,topic:r,symKey:t,relay:i,expiryTimestamp:s,methods:e?.methods});return this.events.emit(Qo,n),this.core.expirer.set(r,s),await this.pairings.set(r,n),await this.core.relayer.subscribe(r,{transportType:e?.transportType}),{topic:r,uri:o}})),Bh(this,"pair",(async e=>{this.isInitialized();const t=this.core.eventClient.createEvent({properties:{topic:e?.uri,trace:[fa]}});this.isValidPair(e,t);const{topic:r,symKey:s,relay:i,expiryTimestamp:n,methods:o}=On(e.uri);let a;if(t.props.properties.topic=r,t.addTrace(ma),t.addTrace(wa),this.pairings.keys.includes(r)){if(a=this.pairings.get(r),t.addTrace(Ca),a.active)throw t.setError(_a),new Error(`Pairing already exists: ${r}. Please try again with a new connection URI.`);t.addTrace(Ea)}const c=n||It(O.FIVE_MINUTES),l={topic:r,relay:i,expiry:c,active:!1,methods:o};this.core.expirer.set(r,c),await this.pairings.set(r,l),t.addTrace(ya),e.activatePairing&&await this.activate({topic:r}),this.events.emit(Qo,l),t.addTrace(Na),this.core.crypto.keychain.has(r)||await this.core.crypto.setSymKey(s,r),t.addTrace(ba);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{t.setError(Aa)}try{await this.core.relayer.subscribe(r,{relay:i})}catch(e){throw t.setError(Oa),e}return t.addTrace(va),l})),Bh(this,"activate",(async({topic:e})=>{this.isInitialized();const t=It(O.FIVE_MINUTES);this.core.expirer.set(e,t),await this.pairings.update(e,{active:!0,expiry:t})})),Bh(this,"ping",(async e=>{this.isInitialized(),await this.isValidPing(e),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:t}=e;if(this.pairings.keys.includes(t)){const e=await this.sendRequest(t,"wc_pairingPing",{}),{done:r,resolve:s,reject:i}=vt();this.events.once(St("pairing_ping",e),(({error:e})=>{e?i(e):s()})),await r()}})),Bh(this,"updateExpiry",(async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})})),Bh(this,"updateMetadata",(async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})})),Bh(this,"getPairings",(()=>(this.isInitialized(),this.pairings.values))),Bh(this,"disconnect",(async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",Gn("USER_DISCONNECTED")),await this.deletePairing(t))})),Bh(this,"formatUriFromPairing",(e=>{this.isInitialized();const{topic:t,relay:r,expiry:s,methods:i}=e,n=this.core.crypto.keychain.get(t);return Tn({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:n,relay:r,expiryTimestamp:s,methods:i})})),Bh(this,"sendRequest",(async(e,t,r)=>{const s=(0,vo.formatJsonRpcRequest)(t,r),i=await this.core.crypto.encode(e,s),n=Zo[t].req;return this.core.history.set(e,s),this.core.relayer.publish(e,i,n),s.id})),Bh(this,"sendResult",(async(e,t,r)=>{const s=(0,vo.formatJsonRpcResult)(e,r),i=await this.core.crypto.encode(t,s),n=(await this.core.history.get(t,e)).request.method,o=Zo[n].res;await this.core.relayer.publish(t,i,o),await this.core.history.resolve(s)})),Bh(this,"sendError",(async(e,t,r)=>{const s=(0,vo.formatJsonRpcError)(e,r),i=await this.core.crypto.encode(t,s),n=(await this.core.history.get(t,e)).request.method,o=Zo[n]?Zo[n].res:Zo.unregistered_method.res;await this.core.relayer.publish(t,i,o),await this.core.history.resolve(s)})),Bh(this,"deletePairing",(async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,Gn("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])})),Bh(this,"cleanup",(async()=>{const e=this.pairings.getAll().filter((e=>At(e.expiry)));await Promise.all(e.map((e=>this.deletePairing(e.topic))))})),Bh(this,"onRelayEventRequest",(async e=>{const{topic:t,payload:r}=e;switch(r.method){case"wc_pairingPing":return await this.onPairingPingRequest(t,r);case"wc_pairingDelete":return await this.onPairingDeleteRequest(t,r);default:return await this.onUnknownRpcMethodRequest(t,r)}})),Bh(this,"onRelayEventResponse",(async e=>{const{topic:t,payload:r}=e,s=(await this.core.history.get(t,r.id)).request.method;return"wc_pairingPing"===s?this.onPairingPingResponse(t,r):this.onUnknownRpcMethodResponse(s)})),Bh(this,"onPairingPingRequest",(async(e,t)=>{const{id:r}=t;try{this.isValidPing({topic:e}),await this.sendResult(r,e,!0),this.events.emit(ra,{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.logger.error(t)}})),Bh(this,"onPairingPingResponse",((e,t)=>
1{const{id:r}=t;setTimeout((()=>{(0,vo.isJsonRpcResult)(t)?this.events.emit(St("pairing_ping",r),{}):(0,vo.isJsonRpcError)(t)&&this.events.emit(St("pairing_ping",r),{error:t.error})}),500)})),Bh(this,"onPairingDeleteRequest",(async(e,t)=>{const{id:r}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit(ta,{id:r,topic:e})}catch(t){await this.sendError(r,e,t),this.logger.error(t)}})),Bh(this,"onUnknownRpcMethodRequest",(async(e,t)=>{const{id:r,method:s}=t;try{if(this.registeredMethods.includes(s))return;const t=Gn("WC_METHOD_UNSUPPORTED",s);await this.sendError(r,e,t),this.logger.error(t)}catch(t){await this.sendError(r,e,t),this.logger.error(t)}})),Bh(this,"onUnknownRpcMethodResponse",(e=>{this.registeredMethods.includes(e)||this.logger.error(Gn("WC_METHOD_UNSUPPORTED",e))})),Bh(this,"isValidPair",((e,t)=>{var r;if(!co(e)){const{message:r}=Jn("MISSING_OR_INVALID",`pair() params: ${e}`);throw t.setError(Sa),new Error(r)}if(!function(e){function t(e){try{return typeof new URL(e)<"u"}catch{return!1}}try{if(Qn(e,!1))return!!t(e)||t(Rt(e))}catch{}return!1}(e.uri)){const{message:r}=Jn("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw t.setError(Sa),new Error(r)}const s=On(e?.uri);if(null==(r=s?.relay)||!r.protocol){const{message:e}=Jn("MISSING_OR_INVALID","pair() uri#relay-protocol");throw t.setError(Sa),new Error(e)}if(null==s||!s.symKey){const{message:e}=Jn("MISSING_OR_INVALID","pair() uri#symKey");throw t.setError(Sa),new Error(e)}if(null!=s&&s.expiryTimestamp&&(0,O.toMiliseconds)(s?.expiryTimestamp)<Date.now()){t.setError(Pa);const{message:e}=Jn("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(e)}})),Bh(this,"isValidPing",(async e=>{if(!co(e)){const{message:t}=Jn("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)})),Bh(this,"isValidDisconnect",(async e=>{if(!co(e)){const{message:t}=Jn("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)})),Bh(this,"isValidPairingTopic",(async e=>{if(!Qn(e,!1)){const{message:t}=Jn("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.pairings.keys.includes(e)){const{message:t}=Jn("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(At(this.pairings.get(e).expiry)){await this.deletePairing(e);const{message:t}=Jn("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}})),this.core=e,this.logger=(0,a.Ep)(t,this.name),this.pairings=new Lh(this.core,this.logger,this.name,this.storagePrefix)}get context(){return(0,a.Fd)(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=Jn("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Ro,(async e=>{const{topic:t,message:r,transportType:s}=e;if(this.pairings.keys.includes(t)&&s!==Ho.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(r)))try{const e=await this.core.crypto.decode(t,r);(0,vo.isJsonRpcRequest)(e)?(this.core.history.set(t,e),await this.onRelayEventRequest({topic:t,payload:e})):(0,vo.isJsonRpcResponse)(e)&&(await this.core.history.resolve(e),await this.onRelayEventResponse({topic:t,payload:e}),this.core.history.delete(t,e.id)),await this.core.relayer.messages.ack(t,r)}catch(e){this.logger.error(e)}}))}registerExpirerEvents(){this.core.expirer.on(la,(async e=>{const{topic:t}=Nt(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(ea,{topic:t}))}))}}var Wh=Object.defineProperty,Fh=(e,t,r)=>((e,t,r)=>t in e?Wh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Hh extends g{constructor(e,t){super(e,t),this.core=e,this.logger=t,Fh(this,"records",new Map),Fh(this,"events",new s.EventEmitter),Fh(this,"name","history"),Fh(this,"version","0.3"),Fh(this,"cached",[]),Fh(this,"initialized",!1),Fh(this,"storagePrefix",Ao),Fh(this,"init",(async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>this.records.set(e.id,e))),this.cached=[],this.registerEventListeners(),this.initialized=!0)})),Fh(this,"set",((e,t,r)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:r}),this.records.has(t.id))return;const s={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:r,expiry:It(O.THIRTY_DAYS)};this.records.set(s.id,s),this.persist(),this.events.emit(sa,s)})),Fh(this,"resolve",(async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;const t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=(0,vo.isJsonRpcError)(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.persist(),this.events.emit(ia,t))})),Fh(this,"get",(async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t)))),Fh(this,"delete",((e,t)=>
1{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach((r=>{if(r.topic===e){if(typeof t<"u"&&r.id!==t)return;this.records.delete(r.id),this.events.emit(na,r)}})),this.persist()})),Fh(this,"exists",(async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e))),Fh(this,"on",((e,t)=>{this.events.on(e,t)})),Fh(this,"once",((e,t)=>{this.events.once(e,t)})),Fh(this,"off",((e,t)=>{this.events.off(e,t)})),Fh(this,"removeListener",((e,t)=>{this.events.removeListener(e,t)})),this.logger=(0,a.Ep)(t,this.name)}get context(){return(0,a.Fd)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach((t=>{if(typeof t.response<"u")return;const r={topic:t.topic,request:(0,vo.formatJsonRpcRequest)(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(r)})),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:t}=Jn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(oa)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:e}=Jn("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(sa,(e=>{const t=sa;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})})),this.events.on(ia,(e=>{const t=ia;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})})),this.events.on(na,(e=>{const t=na;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})})),this.core.heartbeat.on(n.Lx.pulse,(()=>{this.cleanup()}))}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach((t=>{(0,O.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(na,t,!1),e=!0)})),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=Jn("NOT_INITIALIZED",this.name);throw new Error(e)}}}var zh=Object.defineProperty,Vh=(e,t,r)=>((e,t,r)=>t in e?zh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Kh extends v{constructor(e,t){super(e,t),this.core=e,this.logger=t,Vh(this,"expirations",new Map),Vh(this,"events",new s.EventEmitter),Vh(this,"name","expirer"),Vh(this,"version","0.3"),Vh(this,"cached",[]),Vh(this,"initialized",!1),Vh(this,"storagePrefix",Ao),Vh(this,"init",(async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>this.expirations.set(e.target,e))),this.cached=[],this.registerEventListeners(),this.initialized=!0)})),Vh(this,"has",(e=>{try{const t=this.formatTarget(e);return typeof this.getExpiration(t)<"u"}catch{return!1}})),Vh(this,"set",((e,t)=>{this.isInitialized();const r=this.formatTarget(e),s={target:r,expiry:t};this.expirations.set(r,s),this.checkExpiry(r,s),this.events.emit(aa,{target:r,expiration:s})})),Vh(this,"get",(e=>{this.isInitialized();const t=this.formatTarget(e);return this.getExpiration(t)})),Vh(this,"del",(e=>{if(this.isInitialized(),this.has(e)){const t=this.formatTarget(e),r=this.getExpiration(t);this.expirations.delete(t),this.events.emit(ca,{target:t,expiration:r})}})),Vh(this,"on",((e,t)=>{this.events.on(e,t)})),Vh(this,"once",((e,t)=>
1{this.events.once(e,t)})),Vh(this,"off",((e,t)=>{this.events.off(e,t)})),Vh(this,"removeListener",((e,t)=>{this.events.removeListener(e,t)})),this.logger=(0,a.Ep)(t,this.name)}get context(){return(0,a.Fd)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if("string"==typeof e)return function(e){return Et("topic",e)}(e);if("number"==typeof e)return function(e){return Et("id",e)}(e);const{message:t}=Jn("UNKNOWN_TYPE","Target type: "+typeof e);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(ha)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:e}=Jn("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:t}=Jn("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(t),new Error(t)}return t}checkExpiry(e,t){const{expiry:r}=t;(0,O.toMiliseconds)(r)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(la,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach(((e,t)=>this.checkExpiry(t,e)))}registerEventListeners(){this.core.heartbeat.on(n.Lx.pulse,(()=>this.checkExpirations())),this.events.on(aa,(e=>{const t=aa;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(la,(e=>{const t=la;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(ca,(e=>{const t=ca;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=Jn("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Jh=Object.defineProperty,Gh=(e,t,r)=>((e,t,r)=>t in e?Jh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Yh extends C{constructor(e,t,r){super(e,t,r),this.core=e,this.logger=t,this.store=r,Gh(this,"name","verify-api"),Gh(this,"abortController"),Gh(this,"isDevEnv"),Gh(this,"verifyUrlV3",pa),Gh(this,"storagePrefix",Ao),Gh(this,"version",2),Gh(this,"publicKey"),Gh(this,"fetchPromise"),Gh(this,"init",(async()=>{var e;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,O.toMiliseconds)(null==(e=this.publicKey)?void 0:e.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))})),Gh(this,"register",(async e=>{if(!ht()||this.isDevEnv)return;const t=window.location.origin,{id:r,decryptedId:s}=e,i=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${t}&id=${r}&decryptedId=${s}`;try{const e=(0,R.getDocument)(),t=this.startAbortTimer(5*O.ONE_SECOND),s=await new Promise(((s,n)=>{const o=()=>{window.removeEventListener("message",c),e.body.removeChild(a),n("attestation aborted")};this.abortController.signal.addEventListener("abort",o);const a=e.createElement("iframe");a.src=i,a.style.display="none",a.addEventListener("error",o,{signal:this.abortController.signal});const c=i=>{if(i.data&&"string"==typeof i.data)try{const n=JSON.parse(i.data);if("verify_attestation"===n.type){if((0,T.xp)(n.attestation).payload.id!==r)return;clearInterval(t),e.body.removeChild(a),this.abortController.signal.removeEventListener("abort",o),window.removeEventListener("message",c),s(null===n.attestation?"":n.attestation)}}catch(e){this.logger.warn(e)}};e.body.appendChild(a),window.addEventListener("message",c,{signal:this.abortController.signal})}));return this.logger.debug("jwt attestation",s),s}catch(e){this.logger.warn(e)}return""})),Gh(this,"resolve",(async e=>{if(this.isDevEnv)return"";const{attestationId:t,hash:r,encryptedId:s}=e;if(""===t)return void this.logger.debug("resolve: attestationId is empty, skipping");if(t){if((0,T.xp)(t).payload.id!==s)return;const e=await this.isValidJwtAttestation(t);
1if(e)return e.isVerified?e:void this.logger.warn("resolve: jwt attestation: origin url not verified")}if(!r)return;const i=this.getVerifyUrl(e?.verifyUrl);return this.fetchAttestation(r,i)})),Gh(this,"fetchAttestation",(async(e,t)=>{this.logger.debug(`resolving attestation: ${e} from url: ${t}`);const r=this.startAbortTimer(5*O.ONE_SECOND),s=await fetch(`${t}/attestation/${e}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(r),200===s.status?await s.json():void 0})),Gh(this,"getVerifyUrl",(e=>{let t=e||da;return ga.includes(t)||(this.logger.info(`verify url: ${t}, not included in trusted list, assigning default: ${da}`),t=da),t})),Gh(this,"fetchPublicKey",(async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const e=this.startAbortTimer(O.FIVE_SECONDS),t=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(e),await t.json()}catch(e){this.logger.warn(e)}})),Gh(this,"persistPublicKey",(async e=>{this.logger.debug("persisting public key to local storage",e),await this.store.setItem(this.storeKey,e),this.publicKey=e})),Gh(this,"removePublicKey",(async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0})),Gh(this,"isValidJwtAttestation",(async e=>{const t=await this.getPublicKey();try{if(t)return this.validateAttestation(e,t)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}const r=await this.fetchAndPersistPublicKey();try{if(r)return this.validateAttestation(e,r)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}})),Gh(this,"getPublicKey",(async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey())),Gh(this,"fetchAndPersistPublicKey",(async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise((async e=>{const t=await this.fetchPublicKey();t&&(await this.persistPublicKey(t),e(t))}));const e=await this.fetchPromise;return this.fetchPromise=void 0,e})),Gh(this,"validateAttestation",((e,t)=>{const r=In(e,t.publicKey),s={hasExpired:(0,O.toMiliseconds)(r.exp)<Date.now(),payload:r};if(s.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:s.payload.origin,isScam:s.payload.isScam,isVerified:s.payload.isVerified}})),this.logger=(0,a.Ep)(t,this.name),this.abortController=new AbortController,this.isDevEnv=kt(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return(0,a.Fd)(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout((()=>this.abortController.abort()),(0,O.toMiliseconds)(e))}}var Xh=Object.defineProperty,Zh=(e,t,r)=>((e,t,r)=>t in e?Xh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Qh extends E{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,Zh(this,"context","echo"),Zh(this,"registerDeviceToken",(async e=>{const{clientId:t,token:r,notificationType:s,enableEncrypted:i=!1}=e,n=`https://echo.walletconnect.com/${this.projectId}/clients`;await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:t,type:s,token:r,always_raw:i})})})),this.logger=(0,a.Ep)(t,this.context)}}var eu=Object.defineProperty,tu=Object.getOwnPropertySymbols,ru=Object.prototype.hasOwnProperty,su=Object.prototype.propertyIsEnumerable,iu=(e,t,r)=>t in e?eu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,nu=(e,t)=>{for(var r in t||(t={}))ru.call(t,r)&&iu(e,r,t[r]);if(tu)for(var r of tu(t))su.call(t,r)&&iu(e,r,t[r]);return e},ou=(e,t,r)=>iu(e,"symbol"!=typeof t?t+"":t,r);class au extends N{constructor(e,t,r=!0){super(e,t,r),this.core=e,this.logger=t,ou(this,"context","event-client"),ou(this,"storagePrefix",Ao),ou(this,"storageVersion",.1),ou(this,"events",new Map),ou(this,"shouldPersist",!1),ou(this,"init",(async()=>{if(!kt())try{const e={eventId:Tt(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:ft(this.core.relayer.protocol,this.core.relayer.version,Fo)}}};await this.sendEvent([e])}catch(e){this.logger.warn(e)}})),ou(this,"createEvent",(e=>{const{event:t="ERROR",type:r="",properties:{topic:s,trace:i}}=e,n=Tt(),o=this.core.projectId||"",a=Date.now(),c=nu({eventId:n,timestamp:a,props:{event:t,type:r,properties:{topic:s,trace:i}},bundleId:o,domain:this.getAppDomain()},this.setMethods(n));return this.telemetryEnabled&&(this.events.set(n,c),this.shouldPersist=!0),c})),ou(this,"getEvent",(e=>{const{eventId:t,topic:r}=e;if(t)return this.events.get(t);const s=Array.from(this.events.values()).find((e=>e.props.properties.topic===r));return s?nu(nu({},s),this.setMethods(s.eventId)):void 0})),ou(this,"deleteEvent",(e=>{const{eventId:t}=e;this.events.delete(t),this.shouldPersist=!0})),ou(this,"setEventListeners",(()=>{this.core.heartbeat.on(n.Lx.pulse,(async()=>
1{this.shouldPersist&&await this.persist(),this.events.forEach((e=>{(0,O.fromMiliseconds)(Date.now())-(0,O.fromMiliseconds)(e.timestamp)>86400&&(this.events.delete(e.eventId),this.shouldPersist=!0)}))}))})),ou(this,"setMethods",(e=>({addTrace:t=>this.addTrace(e,t),setError:t=>this.setError(e,t)}))),ou(this,"addTrace",((e,t)=>{const r=this.events.get(e);r&&(r.props.properties.trace.push(t),this.events.set(e,r),this.shouldPersist=!0)})),ou(this,"setError",((e,t)=>{const r=this.events.get(e);r&&(r.props.type=t,r.timestamp=Date.now(),this.events.set(e,r),this.shouldPersist=!0)})),ou(this,"persist",(async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1})),ou(this,"restore",(async()=>{try{const e=await this.core.storage.getItem(this.storageKey)||[];if(!e.length)return;e.forEach((e=>{this.events.set(e.eventId,nu(nu({},e),this.setMethods(e.eventId)))}))}catch(e){this.logger.warn(e)}})),ou(this,"submit",(async()=>{if(!this.telemetryEnabled||0===this.events.size)return;const e=[];for(const[t,r]of this.events)r.props.type&&e.push(r);if(0!==e.length)try{if((await this.sendEvent(e)).ok)for(const t of e)this.events.delete(t.eventId),this.shouldPersist=!0}catch(e){this.logger.warn(e)}})),ou(this,"sendEvent",(async e=>{const t=this.getAppDomain()?"":"&sp=desktop";return await fetch(`https://pulse.walletconnect.org/batch?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Fo}${t}`,{method:"POST",body:JSON.stringify(e)})})),ou(this,"getAppDomain",(()=>gt().url)),this.logger=(0,a.Ep)(t,this.context),this.telemetryEnabled=r,r?this.restore().then((async()=>{await this.submit(),this.setEventListeners()})):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var cu=Object.defineProperty,lu=Object.getOwnPropertySymbols,hu=Object.prototype.hasOwnProperty,uu=Object.prototype.propertyIsEnumerable,du=(e,t,r)=>t in e?cu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,pu=(e,t)=>{for(var r in t||(t={}))hu.call(t,r)&&du(e,r,t[r]);if(lu)for(var r of lu(t))uu.call(t,r)&&du(e,r,t[r]);return e},gu=(e,t,r)=>du(e,"symbol"!=typeof t?t+"":t,r);class fu extends u{constructor(e){var t;super(e),gu(this,"protocol","wc"),gu(this,"version",2),gu(this,"name",Io),gu(this,"relayUrl"),gu(this,"projectId"),gu(this,"customStoragePrefix"),gu(this,"events",new s.EventEmitter),gu(this,"logger"),gu(this,"heartbeat"),gu(this,"relayer"),gu(this,"crypto"),gu(this,"storage"),gu(this,"history"),gu(this,"expirer"),gu(this,"pairing"),gu(this,"verify"),gu(this,"echoClient"),gu(this,"linkModeSupportedApps"),gu(this,"eventClient"),gu(this,"initialized",!1),gu(this,"logChunkController"),gu(this,"on",((e,t)=>this.events.on(e,t))),gu(this,"once",((e,t)=>this.events.once(e,t))),gu(this,"off",((e,t)=>this.events.off(e,t))),gu(this,"removeListener",((e,t)=>this.events.removeListener(e,t))),gu(this,"dispatchEnvelope",(({topic:e,message:t,sessionExists:r})=>{if(!e||!t)return;const s={topic:e,message:t,publishedAt:Date.now(),transportType:Ho.link_mode};this.relayer.onLinkMessageEvent(s,{sessionExists:r})}));const r=this.getGlobalCore(e?.customStoragePrefix);if(r)try{return this.customStoragePrefix=r.customStoragePrefix,this.logger=r.logger,this.heartbeat=r.heartbeat,this.crypto=r.crypto,this.history=r.history,this.expirer=r.expirer,this.storage=r.storage,this.relayer=r.relayer,this.pairing=r.pairing,this.verify=r.verify,this.echoClient=r.echoClient,this.linkModeSupportedApps=r.linkModeSupportedApps,this.eventClient=r.eventClient,this.initialized=r.initialized,this.logChunkController=r.logChunkController,r}catch(e){console.warn("Failed to copy global core",e)}this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||ko,this.customStoragePrefix=null!=e&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=(0,a.jI)({level:"string"==typeof e?.logger&&e.logger?e.logger:So,name:Io}),{logger:c,chunkLoggerController:l}=(0,a.Rt)({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=l,null!=(t=this.logChunkController)&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var e,t;null!=(e=this.logChunkController)&&e.downloadLogsBlobInBrowser&&(null==(t=this.logChunkController)||t.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=(0,a.Ep)(c,this.name),this.heartbeat=new n.C$,this.crypto=new xl(this,this.logger,e?.keychain),this.history=new Hh(this,this.logger),this.expirer=new Kh(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new o.Z(pu(pu({},_o),e?.storageOptions)),this.relayer=new Ch({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new qh(this,this.logger),this.verify=new Yh(this,this.logger,this.storage),this.echoClient=new Qh(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new au(this,this.logger,e?.telemetryEnabled),this.setGlobalCore(this)}static async init(e){const t=new fu(e);await t.initialize();const r=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",r),t}get context(){return(0,a.Fd)(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return null==(e=this.logChunkController)?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(Ko,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(
1),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(Ko)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;const t=`_walletConnectCore_${e}`,r=`${t}_count`;return globalThis[r]=(globalThis[r]||0)+1,globalThis[r]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[r]} times.`),globalThis[t]}catch(e){return void console.warn("Failed to get global WalletConnect core",e)}}setGlobalCore(e){var t;try{if(this.isGlobalCoreDisabled())return;const r=`_walletConnectCore_${(null==(t=e.opts)?void 0:t.customStoragePrefix)||""}`;globalThis[r]=e}catch(e){console.warn("Failed to set global WalletConnect core",e)}}isGlobalCoreDisabled(){try{return typeof No<"u"&&"true"==={NODE_ENV:"production",PUBLIC_PATH:"/"}.DISABLE_GLOBAL_CORE}catch{return!0}}}const mu=fu,wu="client",yu=`wc@2:${wu}:`,bu=wu,vu="error",Cu="WALLETCONNECT_DEEPLINK_CHOICE",Eu="Proposal expired",Nu=O.SEVEN_DAYS,Iu={wc_sessionPropose:{req:{ttl:O.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:O.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:O.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:O.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:O.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:O.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:O.ONE_DAY,prompt:!1,tag:1104},res:{ttl:O.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:O.ONE_DAY,prompt:!1,tag:1106},res:{ttl:O.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:O.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:O.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:O.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:O.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:O.ONE_DAY,prompt:!1,tag:1112},res:{ttl:O.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:O.ONE_DAY,prompt:!1,tag:1114},res:{ttl:O.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:O.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:O.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:O.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:O.FIVE_MINUTES,prompt:!1,tag:1119}}},Au={min:O.FIVE_MINUTES,max:O.SEVEN_DAYS},Su="IDLE",_u="ACTIVE",Ou={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},Pu=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],Tu="[email protected]:auth:",ku=`${Tu}:PUB_KEY`;var Ru=Object.defineProperty,xu=Object.defineProperties,Uu=Object.getOwnPropertyDescriptors,Du=Object.getOwnPropertySymbols,$u=Object.prototype.hasOwnProperty,Mu=Object.prototype.propertyIsEnumerable,Lu=(e,t,r)=>t in e?Ru(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ju=(e,t)=>{for(var r in t||(t={}))$u.call(t,r)&&Lu(e,r,t[r]);if(Du)for(var r of Du(t))Mu.call(t,r)&&Lu(e,r,t[r]);return e},Bu=(e,t)=>xu(e,Uu(t)),qu=(e,t,r)=>Lu(e,"symbol"!=typeof t?t+"":t,r);class Wu extends _{constructor(e){super(e),qu(this,"name","engine"),qu(this,"events",new(i())),qu(this,"initialized",!1),qu(this,"requestQueue",{state:Su,queue:[]}),qu(this,"sessionRequestQueue",{state:Su,queue:[]}),qu(this,"requestQueueDelay",O.ONE_SECOND),qu(this,"expectedPairingMethodMap",new Map),qu(this,"recentlyDeletedMap",new Map),qu(this,"recentlyDeletedLimit",200),qu(this,"relayMessageCache",[]),qu(this,"pendingSessions",new Map),qu(this,"init",(async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(Iu)}),this.initialized=!0,setTimeout((async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()}),(0,O.toMiliseconds)(this.requestQueueDelay)))})),qu(this,"connect",(async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const t=Bu(ju({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t),t.optionalNamespaces=function(e,t){var r,s,i,n,o,a;const c=Hn(e),l=Hn(t),h={},u=Object.keys(c).concat(Object.keys(l));for(const e of u)h[e]={chains:_t(null==(r=c[e])?void 0:r.chains,null==(s=l[e])?void 0:s.chains),methods:_t(null==(i=c[e])?void 0:i.methods,null==(n=l[e])?void 0:n.methods),events:_t(null==(o=c[e])?void 0:o.events,null==(a=l[e])?void 0:a.events)};return h}(t.requiredNamespaces,t.optionalNamespaces),t.requiredNamespaces={};const{pairingTopic:r,requiredNamespaces:s,optionalNamespaces:i,sessionProperties:n,scopedProperties:o,relays:a}=t;let c,l=r,h=!1;try{if(l){const e=this.client.core.pairing.pairings.get(l);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),h=e.active}}catch(e){throw this.client.logger.error(`connect() -> pairing.get(${l}) failed`),e}if(!l||!h){const{topic:e,uri:t}=await this.client.core.pairing.create();l=e,c=t}if(!l){const{message:e}=Jn("NO_MATCHING_KEY",`connect() pairing topic: ${l}`);throw new Error(e)}const u=await this.client.core.crypto.generateKeyPair(),d=Iu.wc_sessionPropose.req.ttl||O.FIVE_MINUTES,p=It(d),g=Bu(ju(ju({requiredNamespaces:s,optionalNamespaces:i,relays:a??[{protocol:"irn"}],proposer:{publicKey:u,metadata:this.client.metadata},expiryTimestamp:p,pairingTopic:l},n&&{sessionProperties:n}),o&&{scopedProperties:o}),{id:(0,vo.payloadId)()}),f=St("session_connect",g.id),{reject:m,resolve:w,done:y}=vt(d,Eu),b=({id:e})=>{e===g.id&&(this.client.events.off("proposal_expire",b),this.pendingSessions.delete(g.id),this.events.emit(f,{error:{message:Eu,code:0}}))};return this.client.events.on("proposal_expire",b),this.events.once(f,(({error:e,session:t})=>{this.client.events.off("proposal_expire",b),e?m(e):t&&w(t)})),await this.sendRequest({topic:l,method:"wc_sessionPropose",params:g,throwOnFailedPublish:!0,clientRpcId:g.id}),await this.setProposal(g.id,g),{uri:c,approval:y}})),qu(this,"pair",(async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(e)}catch(e){throw this.client.logger.error("pair() failed"),e}})),qu(this,"approve",(async e=>{var t,r,s;const i=this.client.core.eventClient.createEvent({properties:{topic:null==(t=e?.id)?void 0:t.toString(),trace:[ka]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(e){throw i.setError(Ba),e}try{await this.isValidProposalId(e?.id)}catch(t){throw this.client.logger.error(`approve() -> proposal.get(${e?.id}) failed`),i.setError(Va),t}try{await this.isValidApprove(e)}catch(e){throw this.client.logger.error("approve() -> isValidApprove() failed"),i.setError(za),e}const{id:n,relayProtocol:o,namespaces:a,sessionProperties:c,scopedProperties:l,sessionConfig:h}=e,u=this.client.proposal.get(n);this.client.core.eventClient.deleteEvent({eventId:i.eventId});const{pairingTopic:d,proposer:p,requiredNamespaces:g,optionalNamespaces:f}=u;let m=null==(r=this.client.core.eventClient)?void 0:r.getEvent({topic:d});m||(m=null==(s=this.client.core.eventClient)?void 0:s.createEvent({type:ka,properties:{topic:d,trace:[ka,Ra]}}));const w=await this.client.core.crypto.generateKeyPair(),y=p.publicKey,b=await this.client.core.crypto.generateSharedKey(w,y),v=ju(ju(ju({relay:{protocol:o??"irn"},namespaces:a,controller:{publicKey:w,metadata:this.client.metadata},expiry:It(Nu)},c&&{sessionProperties:c}),l&&{scopedProperties:l}),h&&{sessionConfig:h}),C=Ho.relay;m.addTrace(xa);try{await this.client.core.relayer.subscribe(b,{transportType:C})}catch(e){throw m.setError(Wa),e}m.addTrace(Ua);const E=Bu(ju({},v),{topic:b,requiredNamespaces:g,optionalNamespaces:f,pairingTopic:d,acknowledged:!1,self:v.controller,peer:{publicKey:p.publicKey,metadata:p.metadata},controller:w,transportType:Ho.relay});await this.client.session.set(b,E),m.addTrace(Ma);try{m.addTrace(La),await this.sendRequest({topic:b,method:"wc_sessionSettle",params:v,throwOnFailedPublish:!0}).catch((e=>{throw m?.setError(Ha),e})),m.addTrace(ja),m.addTrace(Da),await this.sendResult({id:n,topic:d,result:{relay:{protocol:o??"irn"},responderPublicKey:w},throwOnFailedPublish:!0}).catch((e=>{throw m?.setError(Fa),e})),m.addTrace($a)}catch(e){throw this.client.logger.error(e),this.client.session.delete(b,Gn("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(b),e}return this.client.core.eventClient.deleteEvent({eventId:m.eventId}),await this.client.core.pairing.updateMetadata({topic:d,metadata:p.metadata}),await this.client.proposal.delete(n,Gn("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:d}),await this.setExpiry(b,It(Nu)),{topic:b,acknowledged:()=>Promise.resolve(this.client.session.get(b))}})),qu(this,"reject",(async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(e)}catch(e){throw this.client.logger.error("reject() -> isValidReject() failed"),e}const{id:t,reason:r}=e;let s;try{s=this.client.proposal.get(t).pairingTopic}catch(e){throw this.client.logger.error(`reject() -> proposal.get(${t}) failed`),e}
1s&&(await this.sendError({id:t,topic:s,error:r,rpcOpts:Iu.wc_sessionPropose.reject}),await this.client.proposal.delete(t,Gn("USER_DISCONNECTED")))})),qu(this,"update",(async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(e)}catch(e){throw this.client.logger.error("update() -> isValidUpdate() failed"),e}const{topic:t,namespaces:r}=e,{done:s,resolve:i,reject:n}=vt(),o=(0,vo.payloadId)(),a=(0,vo.getBigIntRpcId)().toString(),c=this.client.session.get(t).namespaces;return this.events.once(St("session_update",o),(({error:e})=>{e?n(e):i()})),await this.client.session.update(t,{namespaces:r}),await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:r},throwOnFailedPublish:!0,clientRpcId:o,relayRpcId:a}).catch((e=>{this.client.logger.error(e),this.client.session.update(t,{namespaces:c}),n(e)})),{acknowledged:s}})),qu(this,"extend",(async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(e)}catch(e){throw this.client.logger.error("extend() -> isValidExtend() failed"),e}const{topic:t}=e,r=(0,vo.payloadId)(),{done:s,resolve:i,reject:n}=vt();return this.events.once(St("session_extend",r),(({error:e})=>{e?n(e):i()})),await this.setExpiry(t,It(Nu)),this.sendRequest({topic:t,method:"wc_sessionExtend",params:{},clientRpcId:r,throwOnFailedPublish:!0}).catch((e=>{n(e)})),{acknowledged:s}})),qu(this,"request",(async e=>{this.isInitialized();try{await this.isValidRequest(e)}catch(e){throw this.client.logger.error("request() -> isValidRequest() failed"),e}const{chainId:t,request:r,topic:s,expiry:i=Iu.wc_sessionRequest.req.ttl}=e,n=this.client.session.get(s);n?.transportType===Ho.relay&&await this.confirmOnlineStateOrThrow();const o=(0,vo.payloadId)(),a=(0,vo.getBigIntRpcId)().toString(),{done:c,resolve:l,reject:h}=vt(i,"Request expired. Please try again.");this.events.once(St("session_request",o),(({error:e,result:t})=>{e?h(e):l(t)}));const u="wc_sessionRequest",d=this.getAppLinkIfEnabled(n.peer.metadata,n.transportType);if(d)return await this.sendRequest({clientRpcId:o,relayRpcId:a,topic:s,method:u,params:{request:Bu(ju({},r),{expiryTimestamp:It(i)}),chainId:t},expiry:i,throwOnFailedPublish:!0,appLink:d}).catch((e=>h(e))),this.client.events.emit("session_request_sent",{topic:s,request:r,chainId:t,id:o}),await c();const p={request:Bu(ju({},r),{expiryTimestamp:It(i)}),chainId:t},g=this.shouldSetTVF(u,p);return await Promise.all([new Promise((async e=>{await this.sendRequest(ju({clientRpcId:o,relayRpcId:a,topic:s,method:u,params:p,expiry:i,throwOnFailedPublish:!0},g&&{tvf:this.getTVFParams(o,p)})).catch((e=>h(e))),this.client.events.emit("session_request_sent",{topic:s,request:r,chainId:t,id:o}),e()})),new Promise((async e=>{var t;if(null==(t=n.sessionConfig)||!t.disableDeepLink){const e=await async function(e,t){let r="";try{if(ht()&&(r=localStorage.getItem(t),r))return r;r=await e.getItem(t)}catch(e){console.error(e)}return r}(this.client.core.storage,Cu);await Ot({id:o,topic:s,wcDeepLink:e})}e()})),c()]).then((e=>e[2]))})),qu(this,"respond",(async e=>{this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:r}=e,{id:s}=r,i=this.client.session.get(t);i.transportType===Ho.relay&&await this.confirmOnlineStateOrThrow();const n=this.getAppLinkIfEnabled(i.peer.metadata,i.transportType);(0,vo.isJsonRpcResult)(r)?await this.sendResult({id:s,topic:t,result:r.result,throwOnFailedPublish:!0,appLink:n}):(0,vo.isJsonRpcError)(r)&&await this.sendError({id:s,topic:t,error:r.error,appLink:n}),this.cleanupAfterResponse(e)})),qu(this,"ping",(async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(e)}catch(e){throw this.client.logger.error("ping() -> isValidPing() failed"),e}const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=(0,vo.payloadId)(),r=(0,vo.getBigIntRpcId)().toString(),{done:s,resolve:i,reject:n}=vt();this.events.once(St("session_ping",e),(({error:e})=>{e?n(e):i()})),await Promise.all([this.sendRequest({topic:t,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:e,relayRpcId:r}),s()])}else this.client.core.pairing.pairings.keys.includes(t)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:t}))})),qu(this,"emit",(async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(e);const{topic:t,event:r,chainId:s}=e,i=(0,vo.getBigIntRpcId)().toString(),n=(0,vo.payloadId)();await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:r,chainId:s},throwOnFailedPublish:!0,relayRpcId:i,clientRpcId:n})})),qu(this,"disconnect",(async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(e);const{topic:t}=e;if(this.client.session.keys.includes(t))await this.sendRequest({topic:t,method:"wc_sessionDelete",params:Gn("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:t,emitEvent:!1});else{if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=Jn("MISMATCHED_TOPIC",`Session or pairing topic not found: ${t}`);throw new Error(e)}
1await this.client.core.pairing.disconnect({topic:t})}})),qu(this,"find",(e=>(this.isInitialized(),this.client.session.getAll().filter((t=>function(e,t){const{requiredNamespaces:r}=t,s=Object.keys(e.namespaces),i=Object.keys(r);let n=!0;return!!wt(i,s)&&(s.forEach((t=>{const{accounts:s,methods:i,events:o}=e.namespaces[t],a=qn(s),c=r[t];wt(Je(t,c),a)&&wt(c.methods,i)&&wt(c.events,o)||(n=!1)})),n)}(t,e)))))),qu(this,"getPendingSessionRequests",(()=>this.client.pendingRequest.getAll())),qu(this,"authenticate",(async(e,t)=>{var r;this.isInitialized(),this.isValidAuthenticate(e);const s=t&&this.client.core.linkModeSupportedApps.includes(t)&&(null==(r=this.client.metadata.redirect)?void 0:r.linkMode),i=s?Ho.link_mode:Ho.relay;i===Ho.relay&&await this.confirmOnlineStateOrThrow();const{chains:n,statement:o="",uri:a,domain:c,nonce:l,type:h,exp:u,nbf:d,methods:p=[],expiry:g}=e,f=[...e.resources||[]],{topic:m,uri:w}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:i});this.client.logger.info({message:"Generated new pairing",pairing:{topic:m,uri:w}});const y=await this.client.core.crypto.generateKeyPair(),b=pn(y);if(await Promise.all([this.client.auth.authKeys.set(ku,{responseTopic:b,publicKey:y}),this.client.auth.pairingTopics.set(b,{topic:b,pairingTopic:m})]),await this.client.core.relayer.subscribe(b,{transportType:i}),this.client.logger.info(`sending request to new pairing topic: ${m}`),p.length>0){const{namespace:e}=Ke(n[0]);let t=Ur(e,"request",p);Br(f)&&(t=$r(t,f.pop())),f.push(t)}const v=g&&g>Iu.wc_sessionAuthenticate.req.ttl?g:Iu.wc_sessionAuthenticate.req.ttl,C={authPayload:{type:h??"caip122",chains:n,statement:o,aud:a,domain:c,version:"1",nonce:l,iat:(new Date).toISOString(),exp:u,nbf:d,resources:f},requester:{publicKey:y,metadata:this.client.metadata},expiryTimestamp:It(v)},E={requiredNamespaces:{},optionalNamespaces:{eip155:{chains:n,methods:[...new Set(["personal_sign",...p])],events:["chainChanged","accountsChanged"]}},relays:[{protocol:"irn"}],pairingTopic:m,proposer:{publicKey:y,metadata:this.client.metadata}
1,expiryTimestamp:It(Iu.wc_sessionPropose.req.ttl),id:(0,vo.payloadId)()},{done:N,resolve:I,reject:A}=vt(v,"Request expired"),S=(0,vo.payloadId)(),_=St("session_connect",E.id),O=St("session_request",S),P=async({error:e,session:t})=>{this.events.off(O,T),e?A(e):t&&I({session:t})},T=async e=>{var r,s,n;if(await this.deletePendingAuthRequest(S,{message:"fulfilled",code:0}),e.error){const t=Gn("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return e.error.code===t.code?void 0:(this.events.off(_,P),A(e.error.message))}await this.deleteProposal(E.id),this.events.off(_,P);const{cacaos:o,responder:a}=e.result,c=[],l=[];for(const e of o){await Or({cacao:e,projectId:this.client.core.projectId})||(this.client.logger.error(e,"Signature verification failed"),A(Gn("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:t}=e,r=Br(t.resources),s=[Sr(t.iss)],i=_r(t.iss);if(r){const e=Lr(r),t=jr(r);c.push(...e),s.push(...t)}for(const e of s)l.push(`${e}:${i}`)}const h=await this.client.core.crypto.generateSharedKey(y,a.publicKey);let u;c.length>0&&(u={topic:h,acknowledged:!0,self:{publicKey:y,metadata:this.client.metadata},peer:a,controller:a.publicKey,expiry:It(Nu),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:m,namespaces:zn([...new Set(c)],[...new Set(l)]),transportType:i},await this.client.core.relayer.subscribe(h,{transportType:i}),await this.client.session.set(h,u),m&&await this.client.core.pairing.updateMetadata({topic:m,metadata:a.metadata}),u=this.client.session.get(h)),null!=(r=this.client.metadata.redirect)&&r.linkMode&&null!=(s=a.metadata.redirect)&&s.linkMode&&null!=(n=a.metadata.redirect)&&n.universal&&t&&(this.client.core.addLinkModeSupportedApp(a.metadata.redirect.universal),this.client.session.update(h,{transportType:Ho.link_mode})),I({auths:o,session:u})};let k;this.events.once(_,P),this.events.once(O,T);try{if(s){const e=(0,vo.formatJsonRpcRequest)("wc_sessionAuthenticate",C,S);this.client.core.history.set(m,e);const r=await this.client.core.crypto.encode("",e,{type:2,encoding:hn});k=kn(t,m,r)}else await Promise.all([this.sendRequest({topic:m,method:"wc_sessionAuthenticate",params:C,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:S}),this.sendRequest({topic:m,method:"wc_sessionPropose",params:E,expiry:Iu.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:E.id})])}catch(e){throw this.events.off(_,P),this.events.off(O,T),e}return await this.setProposal(E.id,E),await this.setAuthRequest(S,{request:Bu(ju({},C),{verifyContext:{}}),pairingTopic:m,transportType:i}),{uri:k??w,response:N}})),qu(this,"approveSessionAuthenticate",(async e=>{const{id:t,auths:r}=e,s=this.client.core.eventClient.createEvent({properties:{topic:t.toString(),trace:[Ka]}});try{this.isInitialized()}catch(e){throw s.setError(ec),e}const i=this.getPendingAuthRequest(t);if(!i)throw s.setError(ic),new Error(`Could not find pending auth request with id ${t}`);const n=i.transportType||Ho.relay;n===Ho.relay&&await this.confirmOnlineStateOrThrow();const o=i.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=pn(o),l={type:1,receiverPublicKey:o,senderPublicKey:a},h=[],u=[];for(const e of r){if(!await Or({cacao:e,projectId:this.client.core.projectId})){s.setError(tc);const e=Gn("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:t,topic:c,error:e,encodeOpts:l}),new Error(e.message)}s.addTrace(Ga);const{p:r}=e,i=Br(r.resources),n=[Sr(r.iss)],o=_r(r.iss);if(i){const e=Lr(i),t=jr(i);h.push(...e),n.push(...t)}for(const e of n)u.push(`${e}:${o}`)}const d=await this.client.core.crypto.generateSharedKey(a,o);let p;if(s.addTrace(Ja),h?.length>0){p={topic:d,acknowledged:!0,self:{publicKey:a,metadata:this.client.metadata},peer:{publicKey:o,metadata:i.requester.metadata},controller:o,expiry:It(Nu),authentication:r,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:i.pairingTopic,namespaces:zn([...new Set(h)],[...new Set(u)]),transportType:n},s.addTrace(Xa);try{await this.client.core.relayer.subscribe(d,{transportType:n})}catch(e){throw s.setError(rc),e}
1s.addTrace(Za),await this.client.session.set(d,p),s.addTrace(Ya),await this.client.core.pairing.updateMetadata({topic:i.pairingTopic,metadata:i.requester.metadata})}s.addTrace(Qa);try{await this.sendResult({topic:c,id:t,result:{cacaos:r,responder:{publicKey:a,metadata:this.client.metadata}},encodeOpts:l,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(i.requester.metadata,n)})}catch(e){throw s.setError(sc),e}return await this.client.auth.requests.delete(t,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:i.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:p}})),qu(this,"rejectSessionAuthenticate",(async e=>{this.isInitialized();const{id:t,reason:r}=e,s=this.getPendingAuthRequest(t);if(!s)throw new Error(`Could not find pending auth request with id ${t}`);s.transportType===Ho.relay&&await this.confirmOnlineStateOrThrow();const i=s.requester.publicKey,n=await this.client.core.crypto.generateKeyPair(),o=pn(i),a={type:1,receiverPublicKey:i,senderPublicKey:n};await this.sendError({id:t,topic:o,error:r,encodeOpts:a,rpcOpts:Iu.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(s.requester.metadata,s.transportType)}),await this.client.auth.requests.delete(t,{message:"rejected",code:0}),await this.client.proposal.delete(t,Gn("USER_DISCONNECTED"))})),qu(this,"formatAuthMessage",(e=>{this.isInitialized();const{request:t,iss:r}=e;return Pr(t,r)})),qu(this,"processRelayMessageCache",(()=>{setTimeout((async()=>{if(0!==this.relayMessageCache.length)for(;this.relayMessageCache.length>0;)try{const e=this.relayMessageCache.shift();e&&await this.onRelayMessage(e)}catch(e){this.client.logger.error(e)}}),50)})),qu(this,"cleanupDuplicatePairings",(async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.pairingTopic),r=this.client.core.pairing.pairings.getAll().filter((r=>{var s,i;return(null==(s=r.peerMetadata)?void 0:s.url)&&(null==(i=r.peerMetadata)?void 0:i.url)===e.peer.metadata.url&&r.topic&&r.topic!==t.topic}));if(0===r.length)return;this.client.logger.info(`Cleaning up ${r.length} duplicate pairing(s)`),await Promise.all(r.map((e=>this.client.core.pairing.disconnect({topic:e.topic})))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}})),qu(this,"deleteSession",(async e=>{var t;const{topic:r,expirerHasDeleted:s=!1,emitEvent:i=!0,id:n=0}=e,{self:o}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),await this.client.session.delete(r,Gn("USER_DISCONNECTED")),this.addToRecentlyDeleted(r,"session"),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(r)&&await this.client.core.crypto.deleteSymKey(r),s||this.client.core.expirer.del(r),this.client.core.storage.removeItem(Cu).catch((e=>this.client.logger.warn(e))),this.getPendingSessionRequests().forEach((e=>{e.topic===r&&this.deletePendingSessionRequest(e.id,Gn("USER_DISCONNECTED"))})),r===(null==(t=this.sessionRequestQueue.queue[0])?void 0:t.topic)&&(this.sessionRequestQueue.state=Su),i&&this.client.events.emit("session_delete",{id:n,topic:r})})),qu(this,"deleteProposal",(async(e,t)=>{if(t)try{const t=this.client.proposal.get(e);this.client.core.eventClient.getEvent({topic:t.pairingTopic})?.setError(qa)}catch{}await Promise.all([this.client.proposal.delete(e,Gn("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")})),qu(this,"deletePendingSessionRequest",(async(e,t,r=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,t),r?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter((t=>t.id!==e)),r&&(this.sessionRequestQueue.state=Su,this.client.events.emit("session_request_expire",{id:e}))})),qu(this,"deletePendingAuthRequest",(async(e,t,r=!1)=>{await Promise.all([this.client.auth.requests.delete(e,t),r?Promise.resolve():this.client.core.expirer.del(e)])})),qu(this,"setExpiry",(async(e,t)=>{this.client.session.keys.includes(e)&&(this.client.core.expirer.set(e,t),await this.client.session.update(e,{expiry:t}))})),qu(this,"setProposal",(async(e,t)=>
1{this.client.core.expirer.set(e,It(Iu.wc_sessionPropose.req.ttl)),await this.client.proposal.set(e,t)})),qu(this,"setAuthRequest",(async(e,t)=>{const{request:r,pairingTopic:s,transportType:i=Ho.relay}=t;this.client.core.expirer.set(e,r.expiryTimestamp),await this.client.auth.requests.set(e,{authPayload:r.authPayload,requester:r.requester,expiryTimestamp:r.expiryTimestamp,id:e,pairingTopic:s,verifyContext:r.verifyContext,transportType:i})})),qu(this,"setPendingSessionRequest",(async e=>{const{id:t,topic:r,params:s,verifyContext:i}=e,n=s.request.expiryTimestamp||It(Iu.wc_sessionRequest.req.ttl);this.client.core.expirer.set(t,n),await this.client.pendingRequest.set(t,{id:t,topic:r,params:s,verifyContext:i})})),qu(this,"sendRequest",(async e=>{const{topic:t,method:s,params:i,expiry:n,relayRpcId:o,clientRpcId:a,throwOnFailedPublish:c,appLink:l,tvf:h}=e,u=(0,vo.formatJsonRpcRequest)(s,i,a);let d;const p=!!l;try{const e=p?hn:ln;d=await this.client.core.crypto.encode(t,u,{encoding:e})}catch(e){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${t} failed`),e}let g;if(Pu.includes(s)){const e=gn(JSON.stringify(u)),t=gn(d);g=await this.client.core.verify.register({id:t,decryptedId:e})}const f=Iu[s].req;if(f.attestation=g,n&&(f.ttl=n),o&&(f.id=o),this.client.core.history.set(t,u),p){const e=kn(l,t,d);await r.g.Linking.openURL(e,this.client.name)}else{const e=Iu[s].req;n&&(e.ttl=n),o&&(e.id=o),e.tvf=Bu(ju({},h),{correlationId:u.id}),c?(e.internal=Bu(ju({},e.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,d,e)):this.client.core.relayer.publish(t,d,e).catch((e=>this.client.logger.error(e)))}return u.id})),qu(this,"sendResult",(async e=>{const{id:t,topic:s,result:i,throwOnFailedPublish:n,encodeOpts:o,appLink:a}=e,c=(0,vo.formatJsonRpcResult)(t,i);let l;const h=a&&typeof(null==r.g?void 0:r.g.Linking)<"u";try{const e=h?hn:ln;l=await this.client.core.crypto.encode(s,c,Bu(ju({},o||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s} failed`),e}let u,d;try{u=await this.client.core.history.get(s,t);const e=u.request;try{this.shouldSetTVF(e.method,e.params)&&(d=this.getTVFParams(t,e.params,i))}catch(e){this.client.logger.warn("sendResult() -> getTVFParams() failed",e)}}catch(e){throw this.client.logger.error(`sendResult() -> history.get(${s}, ${t}) failed`),e}if(h){const e=kn(a,s,l);await r.g.Linking.openURL(e,this.client.name)}else{const e=u.request.method,r=Iu[e].res;r.tvf=Bu(ju({},d),{correlationId:t}),n?(r.internal=Bu(ju({},r.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,l,r)):this.client.core.relayer.publish(s,l,r).catch((e=>this.client.logger.error(e)))}await this.client.core.history.resolve(c)})),qu(this,"sendError",(async e=>{const{id:t,topic:s,error:i,encodeOpts:n,rpcOpts:o,appLink:a}=e,c=(0,vo.formatJsonRpcError)(t,i);let l;const h=a&&typeof(null==r.g?void 0:r.g.Linking)<"u";try{const e=h?hn:ln;l=await this.client.core.crypto.encode(s,c,Bu(ju({},n||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s} failed`),e}let u;try{u=await this.client.core.history.get(s,t)}catch(e){throw this.client.logger.error(`sendError() -> history.get(${s}, ${t}) failed`),e}if(h){const e=kn(a,s,l);await r.g.Linking.openURL(e,this.client.name)}else{const e=u.request.method,t=o||Iu[e].res;this.client.core.relayer.publish(s,l,t)}await this.client.core.history.resolve(c)})),qu(this,"cleanup",(async()=>{const e=[],t=[];this.client.session.getAll().forEach((t=>{let r=!1;At(t.expiry)&&(r=!0),this.client.core.crypto.keychain.has(t.topic)||(r=!0),r&&e.push(t.topic)})),this.client.proposal.getAll().forEach((e=>{At(e.expiryTimestamp)&&t.push(e.id)})),await Promise.all([...e.map((e=>this.deleteSession({topic:e}))),...t.map((e=>this.deleteProposal(e)))])})),qu(this,"onProviderMessageEvent",(async e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):await this.onRelayMessage(e)})),qu(this,"onRelayEventRequest",(async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()})),qu(this,"processRequestsQueue",(async()=>
1{if(this.requestQueue.state!==_u){for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=_u;const e=this.requestQueue.queue.shift();if(e)try{await this.processRequest(e)}catch(e){this.client.logger.warn(e)}}this.requestQueue.state=Su}else this.client.logger.info("Request queue already active, skipping...")})),qu(this,"processRequest",(async e=>{const{topic:t,payload:r,attestation:s,transportType:i,encryptedId:n}=e,o=r.method;if(!this.shouldIgnorePairingRequest({topic:t,requestMethod:o}))switch(o){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:t,payload:r,attestation:s,encryptedId:n});case"wc_sessionSettle":return await this.onSessionSettleRequest(t,r);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(t,r);case"wc_sessionExtend":return await this.onSessionExtendRequest(t,r);case"wc_sessionPing":return await this.onSessionPingRequest(t,r);case"wc_sessionDelete":return await this.onSessionDeleteRequest(t,r);case"wc_sessionRequest":return await this.onSessionRequest({topic:t,payload:r,attestation:s,encryptedId:n,transportType:i});case"wc_sessionEvent":return await this.onSessionEventRequest(t,r);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:t,payload:r,attestation:s,encryptedId:n,transportType:i});default:return this.client.logger.info(`Unsupported request method ${o}`)}})),qu(this,"onRelayEventResponse",(async e=>{const{topic:t,payload:r,transportType:s}=e,i=(await this.client.core.history.get(t,r.id)).request.method;switch(i){case"wc_sessionPropose":return this.onSessionProposeResponse(t,r,s);case"wc_sessionSettle":return this.onSessionSettleResponse(t,r);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,r);case"wc_sessionExtend":return this.onSessionExtendResponse(t,r);case"wc_sessionPing":return this.onSessionPingResponse(t,r);case"wc_sessionRequest":return this.onSessionRequestResponse(t,r);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(t,r);default:return this.client.logger.info(`Unsupported response method ${i}`)}})),qu(this,"onRelayEventUnknownPayload",(e=>{const{topic:t}=e,{message:r}=Jn("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(r)})),qu(this,"shouldIgnorePairingRequest",(e=>{const{topic:t,requestMethod:r}=e,s=this.expectedPairingMethodMap.get(t);return!(!s||s.includes(r))&&!!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)})),qu(this,"onSessionProposeRequest",(async e=>{const{topic:t,payload:r,attestation:s,encryptedId:i}=e,{params:n,id:o}=r;try{const e=this.client.core.eventClient.getEvent({topic:t});0===this.client.events.listenerCount("session_proposal")&&(console.warn("No listener for session_proposal event"),e?.setError(Ta)),this.isValidConnect(ju({},r.params));const a=n.expiryTimestamp||It(Iu.wc_sessionPropose.req.ttl),c=ju({id:o,pairingTopic:t,expiryTimestamp:a},n);await this.setProposal(o,c);const l=await this.getVerifyContext({attestationId:s,hash:gn(JSON.stringify(r)),encryptedId:i,metadata:c.proposer.metadata});e?.addTrace(Ia),this.client.events.emit("session_proposal",{id:o,params:c,verifyContext:l})}catch(e){await this.sendError({id:o,topic:t,error:e,rpcOpts:Iu.wc_sessionPropose.autoReject}),this.client.logger.error(e)}})),qu(this,"onSessionProposeResponse",(async(e,t,r)=>{const{id:s}=t;if((0,vo.isJsonRpcResult)(t)){const{result:i}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:i});const n=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const o=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const a=i.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});const c=await this.client.core.crypto.generateSharedKey(o,a);this.pendingSessions.set(s,{sessionTopic:c,pairingTopic:e,proposalId:s,publicKey:o});const l=await this.client.core.relayer.subscribe(c,{transportType:r});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:l}),await this.client.core.pairing.activate({topic:e})}else if((0,vo.isJsonRpcError)(t)){await this.client.proposal.delete(s,Gn("USER_DISCONNECTED"));const e=St("session_connect",s);if(0===this.events.listenerCount(e))throw new Error(`emitting ${e} without any listeners, 954`);this.events.emit(e,{error:t.error})}})),qu(this,"onSessionSettleRequest",(async(e,t)=>{const{id:r,params:s}=t;try{this.isValidSessionSettleRequest(s);const{relay:r,controller:i,expiry:n,namespaces:o,sessionProperties:a,scopedProperties:c,sessionConfig:l}=t.params,h=[...this.pendingSessions.values()].find((t=>t.sessionTopic===e));if(!h)return this.client.logger.error(`Pending session not found for topic ${e}`);const u=this.client.proposal.get(h.proposalId),d=Bu(ju(ju(ju({topic:e,relay:r,expiry:n,namespaces:o,acknowledged:!0,pairingTopic:h.pairingTopic,requiredNamespaces:u.requiredNamespaces,optionalNamespaces:u.optionalNamespaces,controller:i.publicKey,self:{publicKey:h.publicKey,metadata:this.client.metadata},peer:{publicKey:i.publicKey,metadata:i.metadata}},a&&{sessionProperties:a}),c&&{scopedProperties:c}),l&&{sessionConfig:l}),{transportType:Ho.relay});await this.client.session.set(d.topic,d),await this.setExpiry(d.topic,d.expiry),await this.client.core.pairing.updateMetadata({topic:h.pairingTopic,metadata:d.peer.metadata}),this.client.events.emit("session_connect",{session:d}),this.events.emit(St("session_connect",h.proposalId),{session:d}),this.pendingSessions.delete(h.proposalId),this.deleteProposal(h.proposalId,!1),this.cleanupDupl
1icatePairings(d),await this.sendResult({id:t.id,topic:e,result:!0,throwOnFailedPublish:!0})}catch(t){await this.sendError({id:r,topic:e,error:t}),this.client.logger.error(t)}})),qu(this,"onSessionSettleResponse",(async(e,t)=>{const{id:r}=t;(0,vo.isJsonRpcResult)(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(St("session_approve",r),{})):(0,vo.isJsonRpcError)(t)&&(await this.client.session.delete(e,Gn("USER_DISCONNECTED")),this.events.emit(St("session_approve",r),{error:t.error}))})),qu(this,"onSessionUpdateRequest",(async(e,t)=>{const{params:r,id:s}=t;try{const t=`${e}_session_update`,i=yo.get(t);if(i&&this.isRequestOutOfSync(i,s))return this.client.logger.warn(`Discarding out of sync request - ${s}`),void this.sendError({id:s,topic:e,error:Gn("INVALID_UPDATE_REQUEST")});this.isValidUpdate(ju({topic:e},r));try{yo.set(t,s),await this.client.session.update(e,{namespaces:r.namespaces}),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0})}catch(e){throw yo.delete(t),e}this.client.events.emit("session_update",{id:s,topic:e,params:r})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}})),qu(this,"isRequestOutOfSync",((e,t)=>t.toString().slice(0,-3)<e.toString().slice(0,-3))),qu(this,"onSessionUpdateResponse",((e,t)=>{const{id:r}=t,s=St("session_update",r);if(0===this.events.listenerCount(s))throw new Error(`emitting ${s} without any listeners`);(0,vo.isJsonRpcResult)(t)?this.events.emit(St("session_update",r),{}):(0,vo.isJsonRpcError)(t)&&this.events.emit(St("session_update",r),{error:t.error})})),qu(this,"onSessionExtendRequest",(async(e,t)=>{const{id:r}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,It(Nu)),await this.sendResult({id:r,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:r,topic:e})}catch(t){await this.sendError({id:r,topic:e,error:t}),this.client.logger.error(t)}})),qu(this,"onSessionExtendResponse",((e,t)=>{const{id:r}=t,s=St("session_extend",r);if(0===this.events.listenerCount(s))throw new Error(`emitting ${s} without any listeners`);(0,vo.isJsonRpcResult)(t)?this.events.emit(St("session_extend",r),{}):(0,vo.isJsonRpcError)(t)&&this.events.emit(St("session_extend",r),{error:t.error})})),qu(this,"onSessionPingRequest",(async(e,t)=>{const{id:r}=t;try{this.isValidPing({topic:e}),await this.sendResult({id:r,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:r,topic:e})}catch(t){await this.sendError({id:r,topic:e,error:t}),this.client.logger.error(t)}})),qu(this,"onSessionPingResponse",((e,t)=>{const{id:r}=t,s=St("session_ping",r);setTimeout((()=>{if(0===this.events.listenerCount(s))throw new Error(`emitting ${s} without any listeners 2176`);(0,vo.isJsonRpcResult)(t)?this.events.emit(St("session_ping",r),{}):(0,vo.isJsonRpcError)(t)&&this.events.emit(St("session_ping",r),{error:t.error})}),500)})),qu(this,"onSessionDeleteRequest",(async(e,t)=>{const{id:r}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),Promise.all([new Promise((t=>{this.client.core.relayer.once(Lo,(async()=>{t(await this.deleteSession({topic:e,id:r}))}))})),this.sendResult({id:r,topic:e,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:Gn("USER_DISCONNECTED")})]).catch((e=>this.client.logger.error(e)))}catch(e){this.client.logger.error(e)}})),qu(this,"onSessionRequest",(async e=>{var t,r,s;const{topic:i,payload:n,attestation:o,encryptedId:a,transportType:c}=e,{id:l,params:h}=n;try{await this.isValidRequest(ju({topic:i},h));const e=this.client.session.get(i),n={id:l,topic:i,params:h,verifyContext:await this.getVerifyContext({attestationId:o,hash:gn(JSON.stringify((0,vo.formatJsonRpcRequest)("wc_sessionRequest",h,l))),encryptedId:a,metadata:e.peer.metadata,transportType:c})};await this.setPendingSessionRequest(n),c===Ho.link_mode&&null!=(t=e.peer.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(null==(r=e.peer.metadata.redirect)?void 0:r.universal),null!=(s=this.client.signConfig)&&s.disableRequestQueue?this.emitSessionRequest(n):(this.addSessionRequestToSessionRequestQueue(n),this.processSessionRequestQueue())}
1catch(e){await this.sendError({id:l,topic:i,error:e}),this.client.logger.error(e)}})),qu(this,"onSessionRequestResponse",((e,t)=>{const{id:r}=t,s=St("session_request",r);if(0===this.events.listenerCount(s))throw new Error(`emitting ${s} without any listeners`);(0,vo.isJsonRpcResult)(t)?this.events.emit(St("session_request",r),{result:t.result}):(0,vo.isJsonRpcError)(t)&&this.events.emit(St("session_request",r),{error:t.error})})),qu(this,"onSessionEventRequest",(async(e,t)=>{const{id:r,params:s}=t;try{const t=`${e}_session_event_${s.event.name}`,i=yo.get(t);if(i&&this.isRequestOutOfSync(i,r))return void this.client.logger.info(`Discarding out of sync request - ${r}`);this.isValidEmit(ju({topic:e},s)),this.client.events.emit("session_event",{id:r,topic:e,params:s}),yo.set(t,r)}catch(t){await this.sendError({id:r,topic:e,error:t}),this.client.logger.error(t)}})),qu(this,"onSessionAuthenticateResponse",((e,t)=>{const{id:r}=t;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:t}),(0,vo.isJsonRpcResult)(t)?this.events.emit(St("session_request",r),{result:t.result}):(0,vo.isJsonRpcError)(t)&&this.events.emit(St("session_request",r),{error:t.error})})),qu(this,"onSessionAuthenticateRequest",(async e=>{var t;const{topic:r,payload:s,attestation:i,encryptedId:n,transportType:o}=e;try{const{requester:e,authPayload:a,expiryTimestamp:c}=s.params,l=await this.getVerifyContext({attestationId:i,hash:gn(JSON.stringify(s)),encryptedId:n,metadata:e.metadata,transportType:o}),h={requester:e,pairingTopic:r,id:s.id,authPayload:a,verifyContext:l,expiryTimestamp:c};await this.setAuthRequest(s.id,{request:h,pairingTopic:r,transportType:o}),o===Ho.link_mode&&null!=(t=e.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(e.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:r,params:s.params,id:s.id,verifyContext:l})}catch(e){this.client.logger.error(e);const t=s.params.requester.publicKey,i=await this.client.core.crypto.generateKeyPair(),n=this.getAppLinkIfEnabled(s.params.requester.metadata,o),a={type:1,receiverPublicKey:t,senderPublicKey:i};await this.sendError({id:s.id,topic:r,error:e,encodeOpts:a,rpcOpts:Iu.wc_sessionAuthenticate.autoReject,appLink:n})}})),qu(this,"addSessionRequestToSessionRequestQueue",(e=>{this.sessionRequestQueue.queue.push(e)})),qu(this,"cleanupAfterResponse",(e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout((()=>{this.sessionRequestQueue.state=Su,this.processSessionRequestQueue()}),(0,O.toMiliseconds)(this.requestQueueDelay))})),qu(this,"cleanupPendingSentRequestsForTopic",(({topic:e,error:t})=>{const r=this.client.core.history.pending;r.length>0&&r.filter((t=>t.topic===e&&"wc_sessionRequest"===t.request.method)).forEach((e=>{const r=St("session_request",e.request.id);if(0===this.events.listenerCount(r))throw new Error(`emitting ${r} without any listeners`);this.events.emit(St("session_request",e.request.id),{error:t})}))})),qu(this,"processSessionRequestQueue",(()=>{if(this.sessionRequestQueue.state===_u)return void this.client.logger.info("session request queue is already active.");const e=this.sessionRequestQueue.queue[0];if(e)try{this.sessionRequestQueue.state=_u,this.emitSessionRequest(e)}catch(e){this.client.logger.error(e)}else this.client.logger.info("session request queue is empty.")})),qu(this,"emitSessionRequest",(e=>{this.client.events.emit("session_request",e)})),qu(this,"onPairingCreated",(e=>{if(e.methods&&this.expectedPairingMethodMap.set(e.topic,e.methods),e.active)return;const t=this.client.proposal.getAll().find((t=>t.pairingTopic===e.topic));
1t&&this.onSessionProposeRequest({topic:e.topic,payload:(0,vo.formatJsonRpcRequest)("wc_sessionPropose",Bu(ju({},t),{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties,scopedProperties:t.scopedProperties}),t.id)})})),qu(this,"isValidConnect",(async e=>{if(!co(e)){const{message:t}=Jn("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(t)}const{pairingTopic:t,requiredNamespaces:r,optionalNamespaces:s,sessionProperties:i,scopedProperties:n,relays:o}=e;if(Zn(t)||await this.isValidPairingTopic(t),!function(e,t){let r=!1;return t&&!e?r=!0:e&&Yn(e)&&e.length&&e.forEach((e=>{r=ao(e)})),r}(o,!0)){const{message:e}=Jn("MISSING_OR_INVALID",`connect() relays: ${o}`);throw new Error(e)}if(!Zn(r)&&0!==Xn(r)){const e="requiredNamespaces are deprecated and are automatically assigned to optionalNamespaces";["fatal","error","silent"].includes(this.client.logger.level)?console.warn(e):this.client.logger.warn(e),this.validateNamespaces(r,"requiredNamespaces")}if(!Zn(s)&&0!==Xn(s)&&this.validateNamespaces(s,"optionalNamespaces"),Zn(i)||this.validateSessionProps(i,"sessionProperties"),!Zn(n)){this.validateSessionProps(n,"scopedProperties");const e=Object.keys(r||{}).concat(Object.keys(s||{}));if(!Object.keys(n).every((t=>e.includes(t))))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(n)}, required/optional namespaces: ${JSON.stringify(e)}`)}})),qu(this,"validateNamespaces",((e,t)=>{const r=function(e,t,r){let s=null;if(e&&Xn(e)){const i=no(e,t);i&&(s=i);const n=so(e,t,r);n&&(s=n)}else s=Jn("MISSING_OR_INVALID",`${t}, ${r} should be an object with data`);return s}(e,"connect()",t);if(r)throw new Error(r.message)})),qu(this,"isValidApprove",(async e=>{if(!co(e))throw new Error(Jn("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:t,namespaces:r,relayProtocol:s,sessionProperties:i,scopedProperties:n}=e;this.checkRecentlyDeleted(t),await this.isValidProposalId(t);const o=this.client.proposal.get(t),a=oo(r,"approve()");if(a)throw new Error(a.message);const c=po(o.requiredNamespaces,r,"approve()");if(c)throw new Error(c.message);if(!Qn(s,!0)){const{message:e}=Jn("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(e)}if(Zn(i)||this.validateSessionProps(i,"sessionProperties"),!Zn(n)){this.validateSessionProps(n,"scopedProperties");const e=new Set(Object.keys(r));if(!Object.keys(n).every((t=>e.has(t))))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(n)}, approved namespaces: ${Array.from(e).join(", ")}`)}})),qu(this,"isValidReject",(async e=>{if(!co(e)){const{message:t}=Jn("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(t)}const{id:t,reason:r}=e;if(this.checkRecentlyDeleted(t),await this.isValidProposalId(t),!function(e){return!!(e&&"object"==typeof e&&e.code&&eo(e.code,!1)&&e.message&&Qn(e.message,!1))}(r)){const{message:e}=Jn("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(r)}`);throw new Error(e)}})),qu(this,"isValidSessionSettleRequest",(e=>{if(!co(e)){const{message:t}=Jn("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}
1const{relay:t,controller:r,namespaces:s,expiry:i}=e;if(!ao(t)){const{message:e}=Jn("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const n=function(e,t){let r=null;return Qn(e?.publicKey,!1)||(r=Jn("MISSING_OR_INVALID",`${t} controller public key should be a string`)),r}(r,"onSessionSettleRequest()");if(n)throw new Error(n.message);const o=oo(s,"onSessionSettleRequest()");if(o)throw new Error(o.message);if(At(i)){const{message:e}=Jn("EXPIRED","onSessionSettleRequest()");throw new Error(e)}})),qu(this,"isValidUpdate",(async e=>{if(!co(e)){const{message:t}=Jn("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(t)}const{topic:t,namespaces:r}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const s=this.client.session.get(t),i=oo(r,"update()");if(i)throw new Error(i.message);const n=po(s.requiredNamespaces,r,"update()");if(n)throw new Error(n.message)})),qu(this,"isValidExtend",(async e=>{if(!co(e)){const{message:t}=Jn("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:t}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t)})),qu(this,"isValidRequest",(async e=>{if(!co(e)){const{message:t}=Jn("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(t)}const{topic:t,request:r,chainId:s,expiry:i}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const{namespaces:n}=this.client.session.get(t);if(!lo(n,s)){const{message:e}=Jn("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(e)}if(!function(e){return!(Zn(e)||!Qn(e.method,!1))}(r)){const{message:e}=Jn("MISSING_OR_INVALID",`request() ${JSON.stringify(r)}`);throw new Error(e)}if(!ho(n,s,r.method)){const{message:e}=Jn("MISSING_OR_INVALID",`request() method: ${r.method}`);throw new Error(e)}if(i&&!function(e,t){return eo(e,!1)&&e<=t.max&&e>=t.min}(i,Au)){const{message:e}=Jn("MISSING_OR_INVALID",`request() expiry: ${i}. Expiry must be a number (in seconds) between ${Au.min} and ${Au.max}`);throw new Error(e)}})),qu(this,"isValidRespond",(async e=>{var t;if(!co(e)){const{message:t}=Jn("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:r,response:s}=e;try{await this.isValidSessionTopic(r)}catch(r){throw null!=(t=e?.response)&&t.id&&this.cleanupAfterResponse(e),r}if(!function(e){return!(Zn(e)||Zn(e.result)&&Zn(e.error)||!eo(e.id,!1)||!Qn(e.jsonrpc,!1))}(s)){const{message:e}=Jn("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(e)}})),qu(this,"isValidPing",(async e=>{if(!co(e)){const{message:t}=Jn("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)})),qu(this,"isValidEmit",(async e=>{if(!co(e)){const{message:t}=Jn("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(t)}const{topic:t,event:r,chainId:s}=e;await this.isValidSessionTopic(t);const{namespaces:i}=this.client.session.get(t);if(!lo(i,s)){const{message:e}=Jn("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(e)}if(!function(e){return!(Zn(e)||!Qn(e.name,!1))}(r)){const{message:e}=Jn("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(e)}if(!uo(i,s,r.name)){const{message:e}=Jn("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(e)}})),qu(this,"isValidDisconnect",(async e=>{if(!co(e)){const{message:t}=Jn("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)})),qu(this,"isValidAuthenticate",(e=>{const{chains:t,uri:r,domain:s,nonce:i}=e;if(!Array.isArray(t)||0===t.length)throw new Error("chains is required and must be a non-empty array");if(!Qn(r,!1))throw new Error("uri is required parameter");if(!Qn(s,!1))throw new Error("domain is required parameter");if(!Qn(i,!1))throw new Error("nonce is required parameter");if([...new Set(t.map((e=>Ke(e).namespace)))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:n}=Ke(t[0]);if("eip155"!==n)throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")})),qu(this,"getVerifyContext",(async e=>{const{attestationId:t,hash:r,encryptedId:s,metadata:i,transportType:n}=e,o={verified:{verifyUrl:i.verifyUrl||da,validation:"UNKNOWN",origin:i.url||""}};try{if(n===Ho.link_mode){const e=this.getAppLinkIfEnabled(i,n);return o.verified.validation=e&&new URL(e).origin===new URL(i.url).origin?"VALID":"INVALID",o}const e=await this.client.core.verify.resolve({attestationId:t,hash:r,encryptedId:s,verifyUrl:i.verifyUrl});e&&(o.verified.origin=e.origin,o.verified.isScam=e.isScam,o.verified.validation=e.origin===new URL(i.url).origin?"VALID":"INVALID")}catch(e){this.client.logger.warn(e)}return this.client.logger.debug(`Verify context: ${JSON.stringify(o)}`),o})),qu(this,"validateSessionProps",((e,t)=>
1{Object.values(e).forEach(((r,s)=>{if(null==r){const{message:i}=Jn("MISSING_OR_INVALID",`${t} must contain an existing value for each key. Received: ${r} for key ${Object.keys(e)[s]}`);throw new Error(i)}}))})),qu(this,"getPendingAuthRequest",(e=>{const t=this.client.auth.requests.get(e);return"object"==typeof t?t:void 0})),qu(this,"addToRecentlyDeleted",((e,t)=>{if(this.recentlyDeletedMap.set(e,t),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let e=0;const t=this.recentlyDeletedLimit/2;for(const r of this.recentlyDeletedMap.keys()){if(e++>=t)break;this.recentlyDeletedMap.delete(r)}}})),qu(this,"checkRecentlyDeleted",(e=>{const t=this.recentlyDeletedMap.get(e);if(t){const{message:r}=Jn("MISSING_OR_INVALID",`Record was recently deleted - ${t}: ${e}`);throw new Error(r)}})),qu(this,"isLinkModeEnabled",((e,t)=>{var s,i,n,o,a,c,l,h,u;return!(!e||t!==Ho.link_mode)&&(!0===(null==(i=null==(s=this.client.metadata)?void 0:s.redirect)?void 0:i.linkMode)&&void 0!==(null==(o=null==(n=this.client.metadata)?void 0:n.redirect)?void 0:o.universal)&&""!==(null==(c=null==(a=this.client.metadata)?void 0:a.redirect)?void 0:c.universal)&&void 0!==(null==(l=e?.redirect)?void 0:l.universal)&&""!==(null==(h=e?.redirect)?void 0:h.universal)&&!0===(null==(u=e?.redirect)?void 0:u.linkMode)&&this.client.core.linkModeSupportedApps.includes(e.redirect.universal)&&typeof(null==r.g?void 0:r.g.Linking)<"u")})),qu(this,"getAppLinkIfEnabled",((e,t)=>{var r;return this.isLinkModeEnabled(e,t)?null==(r=e?.redirect)?void 0:r.universal:void 0})),qu(this,"handleLinkModeMessage",(({url:e})=>{if(!e||!e.includes("wc_ev")||!e.includes("topic"))return;const t=Pt(e,"topic")||"",r=decodeURIComponent(Pt(e,"wc_ev")||""),s=this.client.session.keys.includes(t);s&&this.client.session.update(t,{transportType:Ho.link_mode}),this.client.core.dispatchEnvelope({topic:t,message:r,sessionExists:s})})),qu(this,"registerLinkModeListeners",(async()=>{var e;if(kt()||lt()&&null!=(e=this.client.metadata.redirect)&&e.linkMode){const e=null==r.g?void 0:r.g.Linking;if(typeof e<"u"){e.addEventListener("url",this.handleLinkModeMessage,this.client.name);const t=await e.getInitialURL();t&&setTimeout((()=>{this.handleLinkModeMessage({url:t})}),50)}}})),qu(this,"shouldSetTVF",((e,t)=>{if(!t||"wc_sessionRequest"!==e)return!1;const{request:r}=t;return Object.keys(Ou).includes(r.method)})),qu(this,"getTVFParams",((e,t,r)=>{var s,i;try{const n=t.request.method,o=this.extractTxHashesFromResult(n,r);return Bu(ju({correlationId:e,rpcMethods:[n],chainId:t.chainId},this.isValidContractData(t.request.params)&&{contractAddresses:[null==(i=null==(s=t.request.params)?void 0:s[0])?void 0:i.to]}),{txHashes:o})}catch(e){this.client.logger.warn("Error getting TVF params",e)}return{}})),qu(this,"isValidContractData",(e=>{var t;if(!e)return!1;try{const r=e?.data||(null==(t=e?.[0])?void 0:t.data);if(!r.startsWith("0x"))return!1;const s=r.slice(2);return!!/^[0-9a-fA-F]*$/.test(s)&&s.length%2==0}catch{}return!1})),qu(this,"extractTxHashesFromResult",((e,t)=>{try{if("string"==typeof t)return[t];const r=t[Ou[e].key];if(Yn(r))return"solana_signAllTransactions"===e?r.map((e=>function(e){const t=atob(e),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);const s=r[0];if(0===s)throw new Error("No signatures found");const i=1+64*s;if(r.length<i)throw new Error("Transaction data too short for claimed signature count");if(r.length<100)throw new Error("Transaction too short");const n=ze.from(e,"base64").slice(1,65);return qe.Z.encode(n)}(e))):r;if("string"==typeof r)return[r]}catch(e){this.client.logger.warn("Error extracting tx hashes from result",e)}return[]}))}async processPendingMessageEvents(){try{const e=this.client.session.keys,t=this.client.core.relayer.messages.getWithoutAck(e);for(const[e,r]of Object.entries(t))for(const t of r)try{await this.onProviderMessageEvent({topic:e,message:t,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${e}, message: ${t}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){const{message:e}=Jn("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Ro,(e=>{this.onProviderMessageEvent(e)}))}async onRelayMessage(e){const{topic:t,message:r,attestation:s,transportType:i}=e,{publicKey:n}=this.client.auth.authKeys.keys.includes(ku)?this.client.auth.authKeys.get(ku):{responseTopic:void 0,publicKey:void 0};try{const e=await this.client.core.crypto.decode(t,r,{receiverPublicKey:n,encoding:i===Ho.link_mode?hn:ln});(0,vo.isJsonRpcRequest)(e)?(this.client.core.history.set(t,e),await this.onRelayEventRequest({topic:t,payload:e,attestation:s,transportType:i,encryptedId:gn(r)})):(0,vo.isJsonRpcResponse)(e)?(await this.client.core.history.resolve(e),await this.onRelayEventResponse({topic:t,payload:e,transportType:i}),this.client.core.history.delete(t,e.id)):await this.onRelayEventUnknownPayload({topic:t,payload:e,transportType:i}),await this.client.core.relayer.messages.ack(t,r)}catch(e){this.client.logger.error(e)}}registerExpirerEvents(){this.client.core.expirer.on(la,(async e=>
1{const{topic:t,id:r}=Nt(e.target);return r&&this.client.pendingRequest.keys.includes(r)?await this.deletePendingSessionRequest(r,Jn("EXPIRED"),!0):r&&this.client.auth.requests.keys.includes(r)?await this.deletePendingAuthRequest(r,Jn("EXPIRED"),!0):void(t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):r&&(await this.deleteProposal(r,!0),this.client.events.emit("proposal_expire",{id:r})))}))}registerPairingEvents(){this.client.core.pairing.events.on(Qo,(e=>this.onPairingCreated(e))),this.client.core.pairing.events.on(ta,(e=>{this.addToRecentlyDeleted(e.topic,"pairing")}))}isValidPairingTopic(e){if(!Qn(e,!1)){const{message:t}=Jn("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=Jn("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(At(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=Jn("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!Qn(e,!1)){const{message:t}=Jn("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=Jn("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(At(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=Jn("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=Jn("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else{if(!this.client.core.pairing.pairings.keys.includes(e)){if(Qn(e,!1)){const{message:t}=Jn("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=Jn("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if(!function(e){return"number"==typeof e}(e)){const{message:t}=Jn("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=Jn("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(At(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=Jn("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class Fu extends Lh{constructor(e,t){super(e,t,"proposal",yu),this.core=e,this.logger=t}}class Hu extends Lh{constructor(e,t){super(e,t,"session",yu),this.core=e,this.logger=t}}class zu extends Lh{constructor(e,t){super(e,t,"request",yu,(e=>e.id)),this.core=e,this.logger=t}}class Vu extends Lh{constructor(e,t){super(e,t,"authKeys",Tu,(()=>ku)),this.core=e,this.logger=t}}class Ku extends Lh{constructor(e,t){super(e,t,"pairingTopics",Tu),this.core=e,this.logger=t}}class Ju extends Lh{constructor(e,t){super(e,t,"requests",Tu,(e=>e.id)),this.core=e,this.logger=t}}var Gu=Object.defineProperty,Yu=(e,t,r)=>((e,t,r)=>t in e?Gu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Xu{constructor(e,t){this.core=e,this.logger=t,Yu(this,"authKeys"),Yu(this,"pairingTopics"),Yu(this,"requests"),this.authKeys=new Vu(this.core,this.logger),this.pairingTopics=new Ku(this.core,this.logger),this.requests=new Ju(this.core,this.logger)}
1async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var Zu=Object.defineProperty,Qu=(e,t,r)=>((e,t,r)=>t in e?Zu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class ed extends S{constructor(e){super(e),Qu(this,"protocol","wc"),Qu(this,"version",2),Qu(this,"name",bu),Qu(this,"metadata"),Qu(this,"core"),Qu(this,"logger"),Qu(this,"events",new s.EventEmitter),Qu(this,"engine"),Qu(this,"session"),Qu(this,"proposal"),Qu(this,"pendingRequest"),Qu(this,"auth"),Qu(this,"signConfig"),Qu(this,"on",((e,t)=>this.events.on(e,t))),Qu(this,"once",((e,t)=>this.events.once(e,t))),Qu(this,"off",((e,t)=>this.events.off(e,t))),Qu(this,"removeListener",((e,t)=>this.events.removeListener(e,t))),Qu(this,"removeAllListeners",(e=>this.events.removeAllListeners(e))),Qu(this,"connect",(async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}})),Qu(this,"pair",(async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}})),Qu(this,"approve",(async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}})),Qu(this,"reject",(async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}})),Qu(this,"update",(async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}})),Qu(this,"extend",(async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}})),Qu(this,"request",(async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}})),Qu(this,"respond",(async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}})),Qu(this,"ping",(async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}})),Qu(this,"emit",(async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}})),Qu(this,"disconnect",(async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}})),Qu(this,"find",(e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}})),Qu(this,"getPendingSessionRequests",(()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}})),Qu(this,"authenticate",(async(e,t)=>{try{return await this.engine.authenticate(e,t)}catch(e){throw this.logger.error(e.message),e}})),Qu(this,"formatAuthMessage",(e=>{try{return this.engine.formatAuthMessage(e)}catch(e){throw this.logger.error(e.message),e}})),Qu(this,"approveSessionAuthenticate",(async e=>{try{return await this.engine.approveSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}})),Qu(this,"rejectSessionAuthenticate",(async e=>{try{return await this.engine.rejectSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}})),this.name=e?.name||bu,this.metadata=pt(e?.metadata),this.signConfig=e?.signConfig;const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,a.gw)((0,a.jI)({level:e?.logger||vu}));this.core=e?.core||new mu(e),this.logger=(0,a.Ep)(t,this.name),this.session=new Hu(this.core,this.logger),this.proposal=new Fu(this.core,this.logger),this.pendingRequest=new zu(this.core,this.logger),this.engine=new Wu(this),this.auth=new Xu(this.core,this.logger)}static async init(e){const t=new ed(e);return await t.initialize(),t}get context(){return(0,a.Fd)(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout((()=>{this.engine.processRelayMessageCache()}),(0,O.toMiliseconds)(O.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}var td=r(88900),rd=r(48764).Buffer;const sd="error",id="wc@2:universal_provider:",nd="https://rpc.walletconnect.org/v1/",od="generic",ad=`${nd}bundler`,cd="default_chain_changed";function ld(){}function hd(e){return null==e||"object"!=typeof e&&"function"!=typeof e}function ud(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function dd(e){return"object"==typeof e&&null!==e}function pd(e){return Object.getOwnPropertySymbols(e).filter((t=>Object.prototype.propertyIsEnumerable.call(e,t)))}
1function gd(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const fd="[object RegExp]",md="[object String]",wd="[object Number]",yd="[object Boolean]",bd="[object Arguments]",vd="[object Symbol]",Cd="[object Date]",Ed="[object Map]",Nd="[object Set]",Id="[object Array]",Ad="[object ArrayBuffer]",Sd="[object Object]",_d="[object DataView]",Od="[object Uint8Array]",Pd="[object Uint8ClampedArray]",Td="[object Uint16Array]",kd="[object Uint32Array]",Rd="[object Int8Array]",xd="[object Int16Array]",Ud="[object Int32Array]",Dd="[object Float32Array]",$d="[object Float64Array]";function Md(e,t,r,s=new Map,i){const n=i?.(e,t,r,s);if(null!=n)return n;if(hd(e))return e;if(s.has(e))return s.get(e);if(Array.isArray(e)){const t=new Array(e.length);s.set(e,t);for(let n=0;n<e.length;n++)t[n]=Md(e[n],n,r,s,i);return Object.hasOwn(e,"index")&&(t.index=e.index),Object.hasOwn(e,"input")&&(t.input=e.input),t}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){const t=new RegExp(e.source,e.flags);return t.lastIndex=e.lastIndex,t}if(e instanceof Map){const t=new Map;s.set(e,t);for(const[n,o]of e)t.set(n,Md(o,n,r,s,i));return t}if(e instanceof Set){const t=new Set;s.set(e,t);for(const n of e)t.add(Md(n,void 0,r,s,i));return t}if(typeof rd<"u"&&rd.isBuffer(e))return e.subarray();if(ud(e)){const t=new(Object.getPrototypeOf(e).constructor)(e.length);s.set(e,t);for(let n=0;n<e.length;n++)t[n]=Md(e[n],n,r,s,i);return t}if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){const t=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return s.set(e,t),Ld(t,e,r,s,i),t}if(typeof File<"u"&&e instanceof File){const t=new File([e],e.name,{type:e.type});return s.set(e,t),Ld(t,e,r,s,i),t}if(e instanceof Blob){const t=new Blob([e],{type:e.type});return s.set(e,t),Ld(t,e,r,s,i),t}if(e instanceof Error){const t=new e.constructor;return s.set(e,t),t.message=e.message,t.name=e.name,t.stack=e.stack,t.cause=e.cause,Ld(t,e,r,s,i),t}if("object"==typeof e&&function(e){switch(gd(e)){case bd:case Id:case Ad:case _d:case yd:case Cd:case Dd:case $d:case Rd:case xd:case Ud:case Ed:case wd:case Sd:case fd:case Nd:case md:case vd:case Od:case Pd:case Td:case kd:return!0;default:return!1}}(e)){const t=Object.create(Object.getPrototypeOf(e));return s.set(e,t),Ld(t,e,r,s,i),t}return e}function Ld(e,t,r=e,s,i){const n=[...Object.keys(t),...pd(t)];for(let o=0;o<n.length;o++){const a=n[o],c=Object.getOwnPropertyDescriptor(e,a);(null==c||c.writable)&&(e[a]=Md(t[a],a,r,s,i))}}function jd(e,t){return function(e,t){return Md(e,void 0,e,new Map,t)}(e,((r,s,i,n)=>{const o=t?.(r,s,i,n);if(null!=o)return o;if("object"==typeof e)switch(Object.prototype.toString.call(e)){case wd:case md:case yd:{const t=new e.constructor(e?.valueOf());return Ld(t,e),t}case bd:{const t={};return Ld(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}}))}function Bd(e){return jd(e)}function qd(e){return null!==e&&"object"==typeof e&&"[object Arguments]"===gd(e)}function Wd(e){return ud(e)}function Fd(e){if("object"!=typeof e||null==e)return!1;if(null===Object.getPrototypeOf(e))return!0;if("[object Object]"!==Object.prototype.toString.call(e)){const t=e[Symbol.toStringTag];return!(null==t||!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable)&&e.toString()===`[object ${t}]`}let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function Hd(e,t,r,s){if(hd(e)&&(e=Object(e)),null==t||"object"!=typeof t)return e;if(s.has(t))return function(e){if(hd(e))return e;if(Array.isArray(e)||ud(e)||e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);const t=Object.getPrototypeOf(e),r=t.constructor;if(e instanceof Date||e instanceof Map||e instanceof Set)return new r(e);if(e instanceof RegExp){const t=new r(e);return t.lastIndex=e.lastIndex,t}if(e instanceof DataView)return new r(e.buffer.slice(0));if(e instanceof Error){const t=new r(e.message);return t.stack=e.stack,t.name=e.name,t.cause=e.cause,t}if(typeof File<"u"&&e instanceof File)return new r([e],e.name,{type:e.type,lastModified:e.lastModified});if("object"==typeof e){const r=Object.create(t);return Object.assign(r,e)}return e}(s.get(t));if(s.set(t,e),Array.isArray(t)){t=t.slice();for(let e=0;e<t.length;e++)t[e]=t[e]??void 0}const i=[...Object.keys(t),...pd(t)];for(let n=0;n<i.length;n++){const o=i[n];let a=t[o],c=e[o];if(qd(a)&&(a={...a}),qd(c)&&(c={...c}),typeof rd<"u"&&rd.isBuffer(a)&&(a=Bd(a)),Array.isArray(a))if("object"==typeof c&&null!=c){const e=[],t=Reflect.ownKeys(c);for(let r=0;r<t.length;r++){const s=t[r];e[s]=c[s]}c=e}else c=[];const l=r(c,a,o,e,t,s);null!=l?e[o]=l:Array.isArray(a)||dd(c)&&dd(a)?e[o]=Hd(c,a,r,s):null==c&&Fd(a)?e[o]=Hd({},a,r,s):null==c&&Wd(a)?e[o]=Bd(a):(void 0===c||void 0!==a)&&(e[o]=a)}return e}function zd(e,...t){return function(e,...t){const r=t.slice(0,-1),s=t[t.length-1];let i=e;for(let e=0;e<r.length;e++)i=Hd(i,r[e],s,new Map);return i}(e,...t,ld)}var Vd=Object.defineProperty,Kd=Object.defineProperties,Jd=Object.getOwnPropertyDescriptors,Gd=Object.getOwnPropertySymbols,Yd=Object.prototype.hasOwnProperty,Xd=Object.prototype.propertyIsEnumerable,Zd=(e,t,r)=>t in e?Vd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Qd=(e,t)=>{for(var r in t||(t={}))Yd.call(t,r)&&Zd(e,r,t[r]);if(Gd)for(var r of Gd(t))Xd.call(t,r)&&Zd(e,r,t[r]);return e},ep=(e,t)=>Kd(e,Jd(t));function tp(e,t,r){var s;const i=Ke(e);return(null==(s=t.rpcMap)?void 0:s[i.reference])||`${nd}?chainId=${i.namespace}:${i.reference}&projectId=${r}`}function rp(e){return e.includes(":")?e.split(":")[1]:e}function sp(e){return e.map((e=>`${e.split(":")[0]}:${e.split(":")[1]}`))}function ip(e={},t={}){return zd(np(e),np(t))}function np(e){var t,r,s,i,n;const o={};if(!Xn(e))return o;for(const[a,c]of Object.entries(e)){const e=Wn(a)?[a]:c.chains,l=c.methods||[],h=c.events||[],u=c.rpcMap||{},d=Fn(a);o[d]=ep(Qd(Qd({},o[d]),c),{chains:_t(e,null==(t=o[d])?void 0:t.chains),methods:_t(l,null==(r=o[d])?void 0:r.methods),events:_t(h,null==(s=o[d])?void 0:s.events)}),(Xn(u)||Xn((null==(i=o[d])?void 0:i.rpcMap)||{}))&&(o[d].rpcMap=Qd(Qd({},u),null==(n=o[d])?void 0:n.rpcMap))}return o}function op(e){return e.includes(":")?e.split(":")[2]:e}function ap(e){const t={};for(const[r,s]of Object.entries(e)){const e=s.methods||[],i=s.events||[],n=s.accounts||[],o=Wn(r)?[r]:s.chains?s.chains:sp(s.accounts);t[r]={chains:o,methods:e,events:i,accounts:n}}return t}function cp(e){return"number"==typeof e?e:e.includes("0x")?parseInt(e,16):(e=e.includes(":")?e.split(":")[1]:e,isNaN(Number(e))?e:Number(e))}const lp={},hp=e=>lp[e],up=(e,t)=>{lp[e]=t};var dp=Object.defineProperty,pp=(e,t,r)=>((e,t,r)=>t in e?dp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class gp{constructor(e){pp(this,"name","polkadot"),pp(this,"client"),pp(this,"httpProviders"),pp(this,"events"),pp(this,"namespace"),pp(this,"chainId"),this.namespace=e.namespace,this.events=hp("events"),this.client=hp("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(cd,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2]))||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;const s=rp(t);e[s]=this.createHttpProvider(s,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||tp(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new bo.r(new td.Z(r,hp("disableProviderPing")))}}var fp=Object.defineProperty,mp=Object.defineProperties,wp=Object.getOwnPropertyDescriptors,yp=Object.getOwnPropertySymbols,bp=Object.prototype.hasOwnProperty,vp=Object.prototype.propertyIsEnumerable,Cp=(e,t,r)=>t in e?fp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,Ep=(e,t)=>{for(var r in t||(t={}))bp.call(t,r)&&Cp(e,r,t[r]);if(yp)for(var r of yp(t))vp.call(t,r)&&Cp(e,r,t[r]);return e},Np=(e,t)=>mp(e,wp(t)),Ip=(e,t,r)=>Cp(e,"symbol"!=typeof t?t+"":t,r);
1class Ap{constructor(e){Ip(this,"name","eip155"),Ip(this,"client"),Ip(this,"chainId"),Ip(this,"namespace"),Ip(this,"httpProviders"),Ip(this,"events"),this.namespace=e.namespace,this.events=hp("events"),this.client=hp("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(cd,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const r=t||tp(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new bo.r(new td.k(r,hp("disableProviderPing")))}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;const s=parseInt(rp(t));e[s]=this.createHttpProvider(s,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,r;let s=e.request.params?null==(t=e.request.params[0])?void 0:t.chainId:"0x0";s=s.startsWith("0x")?s:`0x${s}`;const i=parseInt(s,16);if(this.isChainApproved(i))this.setDefaultChain(`${i}`);else{if(!this.namespace.methods.includes("wallet_switchEthereumChain"))throw new Error(`Failed to switch to chain 'eip155:${i}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:s}]},chainId:null==(r=this.namespace.chains)?void 0:r[0]}),this.setDefaultChain(`${i}`)}return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,r,s,i,n;const o=null==(r=null==(t=e.request)?void 0:t.params)?void 0:r[0],a=`${o}${((null==(i=null==(s=e.request)?void 0:s.params)?void 0:i[1])||[]).join(",")}`;if(!o)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const c=this.client.session.get(e.topic),l=(null==(n=c?.sessionProperties)?void 0:n.capabilities)||{};if(null!=l&&l[a])return l?.[a];const h=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Np(Ep({},c.sessionProperties||{}),{capabilities:Np(Ep({},l||{}),{[a]:h})})})}catch(e){console.warn("Failed to update session with capabilities",e)}return h}async getCallStatus(e){var t,r;const s=this.client.session.get(e.topic),i=null==(t=s.sessionProperties)?void 0:t.bundler_name;if(i){const t=this.getBundlerUrl(e.chainId,i);try{return await this.getUserOperationReceipt(t,e)}catch(e){console.warn("Failed to fetch call status from bundler",e,t)}}const n=null==(r=s.sessionProperties)?void 0:r.bundler_url;if(n)try{return await this.getUserOperationReceipt(n,e)}catch(e){console.warn("Failed to fetch call status from custom bundler",e,n)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var r;const s=new URL(e),i=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,vo.formatJsonRpcRequest)("eth_getUserOperationReceipt",[null==(r=t.request.params)?void 0:r[0]]))});if(!i.ok)throw new Error(`Failed to fetch user operation receipt - ${i.status}`);return await i.json()}
1getBundlerUrl(e,t){return`${ad}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}var Sp=Object.defineProperty,_p=(e,t,r)=>((e,t,r)=>t in e?Sp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Op{constructor(e){_p(this,"name","solana"),_p(this,"client"),_p(this,"httpProviders"),_p(this,"events"),_p(this,"namespace"),_p(this,"chainId"),this.namespace=e.namespace,this.events=hp("events"),this.client=hp("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(cd,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;const s=rp(t);e[s]=this.createHttpProvider(s,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||tp(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new bo.r(new td.Z(r,hp("disableProviderPing")))}}var Pp=Object.defineProperty,Tp=(e,t,r)=>((e,t,r)=>t in e?Pp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class kp{constructor(e){Tp(this,"name","cosmos"),Tp(this,"client"),Tp(this,"httpProviders"),Tp(this,"events"),Tp(this,"namespace"),Tp(this,"chainId"),this.namespace=e.namespace,this.events=hp("events"),this.client=hp("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(cd,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;const s=rp(t);e[s]=this.createHttpProvider(s,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||tp(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new bo.r(new td.Z(r,hp("disableProviderPing")))}}var Rp=Object.defineProperty,xp=(e,t,r)=>((e,t,r)=>t in e?Rp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Up{constructor(e){xp(this,"name","algorand"),xp(this,"client"),xp(this,"httpProviders"),xp(this,"events"),xp(this,"namespace"),xp(this,"chainId"),this.namespace=e.namespace,this.events=hp("events"),this.client=hp("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const r=t||tp(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.chainId=e,this.events.emit(cd,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;e[t]=this.createHttpProvider(t,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||tp(e,this.namespace,this.client.core.projectId);return typeof r>"u"?void 0:new bo.r(new td.Z(r,hp("disableProviderPing")))}}var Dp=Object.defineProperty,$p=(e,t,r)=>((e,t,r)=>t in e?Dp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Mp{constructor(e){$p(this,"name","cip34"),$p(this,"client"),$p(this,"httpProviders"),$p(this,"events"),$p(this,"namespace"),$p(this,"chainId"),this.namespace=e.namespace,this.events=hp("events"),this.client=hp("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(cd,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{const r=this.getCardanoRPCUrl(t),s=rp(t);e[s]=this.createHttpProvider(s,r)})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||this.getCardanoRPCUrl(e);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new bo.r(new td.Z(r,hp("disableProviderPing")))}}var Lp=Object.defineProperty,jp=(e,t,r)=>((e,t,r)=>t in e?Lp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Bp{constructor(e){jp(this,"name","elrond"),jp(this,"client"),jp(this,"httpProviders"),jp(this,"events"),jp(this,"namespace"),jp(this,"chainId"),this.namespace=e.namespace,this.events=hp("events"),this.client=hp("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(cd,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;const s=rp(t);e[s]=this.createHttpProvider(s,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||tp(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new bo.r(new td.Z(r,hp("disableProviderPing")))}}var qp=Object.defineProperty,Wp=(e,t,r)=>((e,t,r)=>t in e?qp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Fp{constructor(e){Wp(this,"name","multiversx"),Wp(this,"client"),Wp(this,"httpProviders"),Wp(this,"events"),Wp(this,"namespace"),Wp(this,"chainId"),this.namespace=e.namespace,this.events=hp("events"),this.client=hp("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(cd,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;const s=rp(t);e[s]=this.createHttpProvider(s,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||tp(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new bo.r(new td.Z(r,hp("disableProviderPing")))}}var Hp=Object.defineProperty,zp=(e,t,r)=>((e,t,r)=>t in e?Hp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Vp{constructor(e){zp(this,"name","near"),zp(this,"client"),zp(this,"httpProviders"),zp(this,"events"),zp(this,"namespace"),zp(this,"chainId"),this.namespace=e.namespace,this.events=hp("events"),this.client=hp("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const r=t||tp(`${this.name}:${e}`,this.namespace);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(cd,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2]))||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var r;e[t]=this.createHttpProvider(t,null==(r=this.namespace.rpcMap)?void 0:r[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||tp(e,this.namespace);return typeof r>"u"?void 0:new bo.r(new td.Z(r,hp("disableProviderPing")))}}var Kp=Object.defineProperty,Jp=(e,t,r)=>((e,t,r)=>t in e?Kp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Gp{constructor(e){Jp(this,"name","tezos"),Jp(this,"client"),Jp(this,"httpProviders"),Jp(this,"events"),Jp(this,"namespace"),Jp(this,"chainId"),this.namespace=e.namespace,this.events=hp("events"),this.client=hp("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const r=t||tp(`${this.name}:${e}`,this.namespace);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,r)}this.events.emit(cd,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2]))||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{e[t]=this.createHttpProvider(t)})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||tp(e,this.namespace);return typeof r>"u"?void 0:new bo.r(new td.Z(r))}}var Yp=Object.defineProperty,Xp=(e,t,r)=>((e,t,r)=>t in e?Yp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r)(e,"symbol"!=typeof t?t+"":t,r);class Zp{constructor(e){Xp(this,"name",od),Xp(this,"client"),Xp(this,"httpProviders"),Xp(this,"events"),Xp(this,"namespace"),Xp(this,"chainId"),this.namespace=e.namespace,this.events=hp("events"),this.client=hp("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(cd,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[..
1.new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){var e,t;const r={};return null==(t=null==(e=this.namespace)?void 0:e.accounts)||t.forEach((e=>{const t=Ke(e);r[`${t.namespace}:${t.reference}`]=this.createHttpProvider(e)})),r}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const r=this.createHttpProvider(e,t);r&&(this.httpProviders[e]=r)}createHttpProvider(e,t){const r=t||tp(e,this.namespace,this.client.core.projectId);if(!r)throw new Error(`No RPC url provided for chainId: ${e}`);return new bo.r(new td.Z(r,hp("disableProviderPing")))}}var Qp=Object.defineProperty,eg=Object.defineProperties,tg=Object.getOwnPropertyDescriptors,rg=Object.getOwnPropertySymbols,sg=Object.prototype.hasOwnProperty,ig=Object.prototype.propertyIsEnumerable,ng=(e,t,r)=>t in e?Qp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,og=(e,t)=>{for(var r in t||(t={}))sg.call(t,r)&&ng(e,r,t[r]);if(rg)for(var r of rg(t))ig.call(t,r)&&ng(e,r,t[r]);return e},ag=(e,t)=>eg(e,tg(t)),cg=(e,t,r)=>ng(e,"symbol"!=typeof t?t+"":t,r);class lg{constructor(e){cg(this,"client"),cg(this,"namespaces"),cg(this,"optionalNamespaces"),cg(this,"sessionProperties"),cg(this,"scopedProperties"),cg(this,"events",new(i())),cg(this,"rpcProviders",{}),cg(this,"session"),cg(this,"providerOpts"),cg(this,"logger"),cg(this,"uri"),cg(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,a.gw)((0,a.jI)({level:e?.logger||sd})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const t=new lg(e);return await t.initialize(),t}async request(e,t,r){const[s,i]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:og({},e),chainId:`${s}:${i}`,topic:this.session.topic,expiry:r})}sendAsync(e,t,r,s){const i=(new Date).getTime();this.request(e,r,s).then((e=>t(null,(0,vo.formatJsonRpcResult)(i,e)))).catch((e=>t(e,void 0)))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:null==(e=this.session)?void 0:e.topic,reason:Gn("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:r,response:s}=await this.client.authenticate(e,t);r&&(this.uri=r,this.events.emit("display_uri",r));const i=await s();if(this.session=i.session,this.session){const e=ap(this.session.namespaces);this.namespaces=ip(this.namespaces,e),await this.persist("namespaces",this.namespaces),this.onConnect()}return i}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){const{uri:t,approval:r}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});t&&(this.uri=t,this.events.emit("display_uri",t));const s=await r();this.session=s;const i=ap(s.namespaces);return this.namespaces=ip(this.namespaces,i),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[r,s]=this.validateChain(e),i=this.getProvider(r);i.name===od?i.setDefaultChain(`${r}:${s}`,t):i.setDefaultChain(s,t)}catch(e){if(!/Please call connect/.test(e.message))throw e}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if(Yn(t)){for(const r of t)e.deletePairings?this.client.core.expirer.set(r.topic,0):await this.client.core.relayer.subscriber.unsubscribe(r.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var e,t;if(this.client=this.providerOpts.client||await ed.init({core:this.providerOpts.core,logger:this.providerOpts.logger||sd,relayUrl:this.providerOpts.relayUrl||"wss://relay.walletconnect.org",projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(r){throw this.logger.error("Failed to get session",r),new Error(`The provided session: ${null==(t=null==(e=this.providerOpts)?void 0:e.session)?void 0:t.topic} doesn't exist in the Sign client`)}else{const e=this.client.session.getAll();this.session=e[0]}this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map((e=>Fn(e))))];up("client",this.client),up("events",this.events),up("disableProviderPing",this.disableProviderPing),e.forEach((e=>{if(!this.session)return;const t=function(e,t){const r=Object.keys(t.namespaces).filter((t=>t.includes(e)));if(!r.length)return[];const s=[];return r.forEach((e=>{const r=t.namespaces[e].accounts;s.push(...r)})),s}(e,this.session),r=sp(t),s=ip(this.namespaces,this.optionalNamespaces),i=ag(og({},s[e]),{accounts:t,chains:r});
1switch(e){case"eip155":this.rpcProviders[e]=new Ap({namespace:i});break;case"algorand":this.rpcProviders[e]=new Up({namespace:i});break;case"solana":this.rpcProviders[e]=new Op({namespace:i});break;case"cosmos":this.rpcProviders[e]=new kp({namespace:i});break;case"polkadot":this.rpcProviders[e]=new gp({namespace:i});break;case"cip34":this.rpcProviders[e]=new Mp({namespace:i});break;case"elrond":this.rpcProviders[e]=new Bp({namespace:i});break;case"multiversx":this.rpcProviders[e]=new Fp({namespace:i});break;case"near":this.rpcProviders[e]=new Vp({namespace:i});break;case"tezos":this.rpcProviders[e]=new Gp({namespace:i});break;default:this.rpcProviders[od]?this.rpcProviders[od].updateNamespace(i):this.rpcProviders[od]=new Zp({namespace:i})}}))}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",(e=>{var t;const{topic:r}=e;r===(null==(t=this.session)?void 0:t.topic)&&this.events.emit("session_ping",e)})),this.client.on("session_event",(e=>{var t;const{params:r,topic:s}=e;if(s!==(null==(t=this.session)?void 0:t.topic))return;const{event:i}=r;if("accountsChanged"===i.name){const e=i.data;e&&Yn(e)&&this.events.emit("accountsChanged",e.map(op))}else if("chainChanged"===i.name){const e=r.chainId,t=r.event.data,s=Fn(e),i=cp(e)!==cp(t)?`${s}:${cp(t)}`:e;this.onChainChanged(i)}else this.events.emit(i.name,i.data);this.events.emit("session_event",e)})),this.client.on("session_update",(({topic:e,params:t})=>{var r,s;if(e!==(null==(r=this.session)?void 0:r.topic))return;const{namespaces:i}=t,n=null==(s=this.client)?void 0:s.session.get(e);this.session=ag(og({},n),{namespaces:i}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})})),this.client.on("session_delete",(async e=>{var t;e.topic===(null==(t=this.session)?void 0:t.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",ag(og({},Gn("USER_DISCONNECTED")),{data:e.topic})))})),this.on(cd,(e=>{this.onChainChanged(e,!0)}))}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[od]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach((e=>{var t;this.getProvider(e).updateNamespace(null==(t=this.session)?void 0:t.namespaces[e])}))}setNamespaces(e){const{namespaces:t={},optionalNamespaces:r={},sessionProperties:s,scopedProperties:i}=e;this.optionalNamespaces=ip(t,r),this.sessionProperties=s,this.scopedProperties=i}validateChain(e){const[t,r]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,r];if(t&&!Object.keys(this.namespaces||{}).map((e=>Fn(e))).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&r)return[t,r];const s=Fn(Object.keys(this.namespaces)[0]);return[s,this.rpcProviders[s].getDefaultChain()]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged(e,t=!1){if(!this.namespaces)return;const[r,s]=this.validateChain(e);if(!s)return;this.updateNamespaceChain(r,s),this.events.emit("chainChanged",s);const i=this.getProvider(r).getDefaultChain();t||this.getProvider(r).setDefaultChain(s),this.emitAccountsChangedOnChainChange({namespace:r,previousChainId:i,newChainId:e}),await this.persist("namespaces",this.namespaces)}emitAccountsChangedOnChainChange({namespace:e,previousChainId:t,newChainId:r}){var s,i;try{if(t===r)return;const n=null==(i=null==(s=this.session)?void 0:s.namespaces[e])?void 0:i.accounts;if(!n)return;const o=n.filter((e=>e.includes(`${r}:`))).map(op);if(!Yn(o))return;this.events.emit("accountsChanged",o)}catch(e){this.logger.warn("Failed to emit accountsChanged on chain change",e)}}updateNamespaceChain(e,t){if(!this.namespaces)return;const r=this.namespaces[e]?e:`${e}:${t}`,s={chains:[],methods:[],events:[],defaultChain:t};this.namespaces[r]?this.namespaces[r]&&(this.namespaces[r].defaultChain=t):this.namespaces[r]=s}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,await this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,t){var r;const s=(null==(r=this.session)?void 0:r.topic)||"";await this.client.core.storage.setItem(`${id}/${e}${s}`,t)}async getFromStore(e){var t;const r=(null==(t=this.session)?void 0:t.topic)||"";return await this.client.core.storage.getItem(`${id}/${e}${r}`)}async deleteFromStore(e){var t;const r=(null==(t=this.session)?void 0:t.topic)||"";await this.client.core.storage.removeItem(`${id}/${e}${r}`)}async cleanupStorage(){var e;try{if((null==(e=this.client)?void 0:e.session.length)>0)return;const t=await this.client.core.storage.getKeys();for(const e of t)e.startsWith(id)&&await this.client.core.storage.removeItem(e)}catch(e){this.logger.warn("Failed to cleanup storage",e)}}}},81491:function(e){e.exports=function(e,t,r,s){var i={configurable:!0,enumerable:!0};return i[e]=s,Object.defineProperty(t,r,i)},e.exports.__esModule=!0,e.exports.default=e.exports},23588:function(e,t,r){"use strict";r.d(t,{fl:function(){return S},iv:function(){return l},Ts:function(){return N},Qu:function(){return I},$m:function(){return c}});const s=globalThis,i=s.ShadowRoot&&(void 0===s.ShadyCSS||s.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,n=Symbol(),o=new WeakMap;class a{constructor(e,t,r){if(this._$cssResult$=!0,r!==n)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(i&&void 0===e){const r=void 0!==t&&1===t.length;r&&(e=o.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),r&&o.set(t,e))}return e}toString(){return this.cssText}}const c=e=>
vendor: 7,347 bytes, line 1
1new a("string"==typeof e?e:e+"",void 0,n),l=(e,...t)=>{const r=1===e.length?e[0]:t.reduce(((t,r,s)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+e[s+1]),e[0]);return new a(r,e,n)},h=(e,t)=>{if(i)e.adoptedStyleSheets=t.map((e=>e instanceof CSSStyleSheet?e:e.styleSheet));else for(const r of t){const t=document.createElement("style"),i=s.litNonce;void 0!==i&&t.setAttribute("nonce",i),t.textContent=r.cssText,e.appendChild(t)}},u=i?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const r of e.cssRules)t+=r.cssText;return c(t)})(e):e,{is:d,defineProperty:p,getOwnPropertyDescriptor:g,getOwnPropertyNames:f,getOwnPropertySymbols:m,getPrototypeOf:w}=Object,y=globalThis,b=y.trustedTypes,v=b?b.emptyScript:"",C=y.reactiveElementPolyfillSupport,E=(e,t)=>e,N={toAttribute(e,t){switch(t){case Boolean:e=e?v:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let r=e;switch(t){case Boolean:r=null!==e;break;case Number:r=null===e?null:Number(e);break;case Object:case Array:try{r=JSON.parse(e)}catch(e){r=null}}return r}},I=(e,t)=>!d(e,t),A={attribute:!0,type:String,converter:N,reflect:!1,useDefault:!1,hasChanged:I};Symbol.metadata??=Symbol("metadata"),y.litPropertyMetadata??=new WeakMap;class S extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=A){if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const r=Symbol(),s=this.getPropertyDescriptor(e,r,t);void 0!==s&&p(this.prototype,e,s)}}static getPropertyDescriptor(e,t,r){const{get:s,set:i}=g(this.prototype,e)??{get(){return this[t]},set(e){this[t]=e}};return{get:s,set(t){const n=s?.call(this);i?.call(this,t),this.requestUpdate(e,n,r)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??A}static _$Ei(){if(this.hasOwnProperty(E("elementProperties")))return;const e=w(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(E("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(E("properties"))){const e=this.properties,t=[...f(e),...m(e)];for(const r of t)this.createProperty(r,e[r])}const e=this[Symbol.metadata];if(null!==e){const t=litPropertyMetadata.get(e);if(void 0!==t)for(const[e,r]of t)this.elementProperties.set(e,r)}this._$Eh=new Map;for(const[e,t]of this.elementProperties){const r=this._$Eu(e,t);void 0!==r&&this._$Eh.set(r,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const r=new Set(e.flat(1/0).reverse());for(const e of r)t.unshift(u(e))}else void 0!==e&&t.push(u(e));return t}static _$Eu(e,t){const r=t.attribute;return!1===r?void 0:"string"==typeof r?r:"string"==typeof e?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise((e=>this.enableUpdating=e)),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach((e=>e(this)))}addController(e){(this._$EO??=new Set).add(e),void 0!==this.renderRoot&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const r of t.keys())this.hasOwnProperty(r)&&(e.set(r,this[r]),delete this[r]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return h(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach((e=>e.hostConnected?.()))}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach((e=>e.hostDisconnected?.()))}attributeChangedCallback(e,t,r){this._$AK(e,r)}_$ET(e,t){const r=this.constructor.elementProperties.get(e),s=this.constructor._$Eu(e,r);if(void 0!==s&&!0===r.reflect){const i=(void 0!==r.converter?.toAttribute?r.converter:N).toAttribute(t,r.type);this._$Em=e,null==i?this.removeAttribute(s):this.setAttribute(s,i),this._$Em=null}}_$AK(e,t){const r=this.constructor,s=r._$Eh.get(e);if(void 0!==s&&this._$Em!==s){const e=r.getPropertyOptions(s),i="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==e.converter?.fromAttribute?e.converter:N;this._$Em=s;const n=i.fromAttribute(t,e.type);this[s]=n??this._$Ej?.get(s)??n,this._$Em=null}}requestUpdate(e,t,r){if(void 0!==e){const s=this.constructor,i=this[e];if(r??=s.getPropertyOptions(e),!((r.hasChanged??I)(i,t)||r.useDefault&&r.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(s._$Eu(e,r))))return;this.C(e,t,r)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,{useDefault:r,reflect:s,wrapped:i},n){r&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,n??t??this[e]),!0!==i||void 0!==n)||(this._$AL.has(e)||(this.hasUpdated||r||(t=void 0),this._$AL.set(e,t)),!0===s&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}const e=this.constructor.elementProperties;if(e.size>0)for(const[t,r]of e){const{wrapped:e}=r,s=this[t];!0!==e||this._$AL.has(t)||void 0===s||this.C(t,void 0,r,s)}}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach((e=>e.hostUpdate?.())),this.update(t)):this._$EM()}catch(t){throw e=!1,this._$EM(),t}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach((e=>e.hostUpdated?.())),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach((e=>this._$ET(e,this[e]))),this._$EM()}updated(e){}firstUpdated(e){}}S.elementStyles=[],S.shadowRootOptions={mode:"open"},S[E("elementProperties")]=new Map,S[E("finalized")]=new Map,C?.({ReactiveElement:S}),(y.reactiveElementVersions??=[]).push("2.1.1")},68314:function(e,t,r){"use strict";r.d(t,{b:function(){return s}});const s={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"ID_AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122"}
1,CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin",cosmos:"Cosmos"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],HTTP_STATUS_CODES:{SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network",SECURE_SITE_SDK_ORIGIN:(void 0!==r(34155)?{NODE_ENV:"production",PUBLIC_PATH:"/"}.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org"}},27777:function(e,t,r){"use strict";r.d(t,{p:function(){return i}});var s=r(68314);const i={caipNetworkIdToNumber(e){return e?Number(e.split(":")[1]):void 0},parseEvmChainId(e){return"string"==typeof e?this.caipNetworkIdToNumber(e):e},getNetworksByNamespace(e,t){return e?.filter((e=>e.chainNamespace===t))||[]},getFirstNetworkByNamespace(e,t){return this.getNetworksByNamespace(e,t)[0]},getNetworkNameByCaipNetworkId(e,t){if(!t)return;const r=e.find((e=>e.caipNetworkId===t));if(r)return r.name;const[i]=t.split(":");return s.b.CHAIN_NAME_MAP?.[i]||void 0}}},35855:function(e,t,r){"use strict";r.d(t,{$U:function(){return o},Vk:function(){return i},mr:function(){return n},uJ:function(){return s}});const s={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",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"};function i(e){if(!e)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${e}:connected_connector_id`}const n={setItem(e,t){o()&&void 0!==t&&localStorage.setItem(e,t)},getItem(e){if(o())return localStorage.getItem(e)||void 0},removeItem(e){o()&&localStorage.removeItem(e)},clear(){o()&&localStorage.clear()}};function o(){return"undefined"!=typeof window&&"undefined"!=typeof localStorage}},45374:function(e,t,r){"use strict";function s(e,t){return"light"===t?{"--w3m-accent":e?.["--w3m-accent"]||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":e?.["--w3m-accent"]||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}r.d(t,{t:function(){return s}})},83966:function(e,t,r){"use strict";r.d(t,{N:function(){return d}});var s=r(44098),i=r(47205),n=r(83241),o=r(68343),a=r(66691),c=r(59757),l=r(82879);const h=(0,s.sj)({currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[]}),u={state:h,replaceState(e){e&&Object.assign(h,(0,s.iH)(e))},subscribe(e){return c.R.subscribeChainProp("accountState",(t=>{if(t)return e(t)}))},subscribeKey(e,t,r){let s;return c.R.subscribeChainProp("accountState",(r=>{if(r){const i=r[e];s!==i&&(s=i,t(i))}}),r)},setStatus(e,t){c.R.setAccountProp("status",e,t)},getCaipAddress(e){return c.R.getAccountProp("caipAddress",e)},setCaipAddress(e,t){const r=e?n.j.getPlainAddress(e):void 0;t===c.R.state.activeChain&&(c.R.state.activeCaipAddress=e),c.R.setAccountProp("caipAddress",e,t),c.R.setAccountProp("address",r,t)},setBalance(e,t,r){c.R.setAccountProp("balance",e,r),c.R.setAccountProp("balanceSymbol",t,r)},setProfileName(e,t){c.R.setAccountProp("profileName",e,t)},setProfileImage(e,t){c.R.setAccountProp("profileImage",e,t)},setUser(e,t){c.R.setAccountProp("user",e,t)},setAddressExplorerUrl(e,t){c.R.setAccountProp("addressExplorerUrl",e,t)},setSmartAccountDeployed(e,t){c.R.setAccountProp("smartAccountDeployed",e,t)},setCurrentTab(e){c.R.setAccountProp("currentTab",e,c.R.state.activeChain)},setTokenBalance(e,t){e&&c.R.setAccountProp("tokenBalance",e,t)},setShouldUpdateToAddress(e,t){c.R.setAccountProp("shouldUpdateToAddress",e,t)},setAllAccounts(e,t){c.R.setAccountProp("allAccounts",e,t)},addAddressLabel(e,t,r){const s=c.R.getAccountProp("addressLabels",r)||new Map;s.set(e,t),c.R.setAccountProp("addressLabels",s,r)},removeAddressLabel(e,t){const r=c.R.getAccountProp("addressLabels",t)||new Map;r.delete(e),c.R.setAccountProp("addressLabels",r,t)},setConnectedWalletInfo(e,t){c.R.setAccountProp("connectedWalletInfo",e,t,!1)},setPreferredAccountType(e,t){c.R.setAccountProp("preferredAccountTypes",{...h.preferredAccountTypes,[t]:e},t)},setPreferredAccountTypes(e){h.preferredAccountTypes=e},setSocialProvider(e,t){e&&c.R.setAccountProp("socialProvider",e,t)},setSocialWindow(e,t){c.R.setAccountProp("socialWindow",e?(0,s.iH)(e):void 0,t)},setFarcasterUrl(e,t){c.R.setAccountProp("farcasterUrl",e,t)},async fetchTokenBalance(e){h.balanceLoading=!0;const t=c.R.state.activeCaipNetwork?.caipNetworkId,r=c.R.state.activeCaipNetwork?.chainNamespace,s=c.R.state.activeCaipAddress,o=s?n.j.getPlainAddress(s):void 0;
1if(h.lastRetry&&!n.j.isAllowedRetry(h.lastRetry,30*i.bq.ONE_SEC_MS))return h.balanceLoading=!1,[];try{if(o&&t&&r){const e=(await a.L.getBalance(o,t)).balances.filter((e=>"0"!==e.quantity.decimals));return d.setTokenBalance(e,r),h.lastRetry=void 0,h.balanceLoading=!1,e}}catch(t){h.lastRetry=Date.now(),e?.(t),l.SnackController.showError("Token Balance Unavailable")}finally{h.balanceLoading=!1}return[]},resetAccount(e){c.R.resetAccount(e)}},d=(0,o.P)(u)},56008:function(e,t,r){"use strict";r.d(t,{AlertController:function(){return l}});var s=r(44098),i=r(87178),n=r(68343),o=r(77500);const a=(0,s.sj)({message:"",variant:"info",open:!1}),c={state:a,subscribeKey(e,t){return(0,i.VW)(a,e,t)},open(e,t){const{debug:r}=o.OptionsController.state,{shortMessage:s,longMessage:i}=e;r&&(a.message=s,a.variant=t,a.open=!0),i&&console.error("function"==typeof i?i():i)},close(){a.open=!1,a.message="",a.variant="info"}},l=(0,n.P)(c)},48113:function(e,t,r){"use strict";r.d(t,{ApiController:function(){return y}});var s=r(44098),i=r(87178),n=r(44639),o=r(83241),a=r(28356),c=r(81106),l=r(64125),h=r(87374),u=r(59757),d=r(9793),p=r(51440),g=r(77500);const f=o.j.getApiUrl(),m=new a.V({baseUrl:f,clientId:null}),w=(0,s.sj)({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],filteredWallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1}),y={state:w,subscribeKey(e,t){return(0,i.VW)(w,e,t)},_getSdkProperties(){const{projectId:e,sdkType:t,sdkVersion:r}=g.OptionsController.state;return{projectId:e,st:t||"appkit",sv:r||"html-wagmi-4.2.2"}},_filterOutExtensions(e){return g.OptionsController.state.isUniversalProvider?e.filter((e=>Boolean(e.mobile_link||e.desktop_link||e.webapp_link))):e},async _fetchWalletImage(e){const t=`${m.baseUrl}/getWalletImage/${e}`,r=await m.getBlob({path:t,params:y._getSdkProperties()});h.W.setWalletImage(e,URL.createObjectURL(r))},async _fetchNetworkImage(e){const t=`${m.baseUrl}/public/getAssetImage/${e}`,r=await m.getBlob({path:t,params:y._getSdkProperties()});h.W.setNetworkImage(e,URL.createObjectURL(r))},async _fetchConnectorImage(e){const t=`${m.baseUrl}/public/getAssetImage/${e}`,r=await m.getBlob({path:t,params:y._getSdkProperties()});h.W.setConnectorImage(e,URL.createObjectURL(r))},async _fetchCurrencyImage(e){const t=`${m.baseUrl}/public/getCurrencyImage/${e}`,r=await m.getBlob({path:t,params:y._getSdkProperties()});h.W.setCurrencyImage(e,URL.createObjectURL(r))},async _fetchTokenImage(e){const t=`${m.baseUrl}/public/getTokenImage/${e}`,r=await m.getBlob({path:t,params:y._getSdkProperties()});h.W.setTokenImage(e,URL.createObjectURL(r))},_filterWalletsByPlatform(e){return o.j.isMobile()?e?.filter((e=>{if(e.mobile_link)return!0;if(e.id===c.m.COINBASE.id)return!0;return"solana"===u.R.state.activeChain&&(e.id===c.m.SOLFLARE.id||e.id===c.m.PHANTOM.id)})):e},async fetchProjectConfig(){return(await m.get({path:"/appkit/v1/config",params:y._getSdkProperties()})).features},async fetchAllowedOrigins(){try{const{allowedOrigins:e}=await m.get({path:"/projects/v1/origins",params:y._getSdkProperties()});return e}catch(e){return[]}},async fetchNetworkImages(){const e=u.R.getAllRequestedCaipNetworks()?.map((({assets:e})=>e?.imageId)).filter(Boolean).filter((e=>!n.f.getNetworkImageById(e)));e&&await Promise.allSettled(e.map((e=>y._fetchNetworkImage(e))))},async fetchConnectorImages(){const{connectors:e}=d.ConnectorController.state,t=e.map((({imageId:e})=>e)).filter(Boolean);await Promise.allSettled(t.map((e=>y._fetchConnectorImage(e))))},async fetchCurrencyImages(e=[]){await Promise.allSettled(e.map((e=>y._fetchCurrencyImage(e))))},async fetchTokenImages(e=[]){await Promise.allSettled(e.map((e=>y._fetchTokenImage(e))))},async fetchWallets(e){const t=e.exclude??[];y._getSdkProperties().sv.startsWith("html-core-")&&t.push(...Object.values(c.m).map((e=>e.id)));const r=await m.get({path:"/getWallets",params:{...y._getSdkProperties(),...e,page:String(e.page),entries:String(e.entries),include:e.include?.join(","),exclude:t.join(",")}});return{data:y._filterWalletsByPlatform(r?.data)||[],count:r?.count}},async fetchFeaturedWallets(){const{featuredWalletIds:e}=g.OptionsController.state;if(e?.length){const t={...y._getSdkProperties(),page:1,entries:e?.length??4,include:e},{data:r}=await y.fetchWallets(t),s=[...r].sort(((t,r)=>e.indexOf(t.id)-e.indexOf(r.id))),i=s.map((e=>
1e.image_id)).filter(Boolean);await Promise.allSettled(i.map((e=>y._fetchWalletImage(e)))),w.featured=s,w.allFeatured=s}},async fetchRecommendedWallets(){try{w.isFetchingRecommendedWallets=!0;const{includeWalletIds:e,excludeWalletIds:t,featuredWalletIds:r}=g.OptionsController.state,s=[...t??[],...r??[]].filter(Boolean),i={page:1,entries:4,include:e,exclude:s,chains:u.R.getRequestedCaipNetworkIds().join(",")},{data:n,count:o}=await y.fetchWallets(i),a=l.M.getRecentWallets(),c=n.map((e=>e.image_id)).filter(Boolean),h=a.map((e=>e.image_id)).filter(Boolean);await Promise.allSettled([...c,...h].map((e=>y._fetchWalletImage(e)))),w.recommended=n,w.allRecommended=n,w.count=o??0}catch{}finally{w.isFetchingRecommendedWallets=!1}},async fetchWalletsByPage({page:e}){const{includeWalletIds:t,excludeWalletIds:r,featuredWalletIds:s}=g.OptionsController.state,i=u.R.getRequestedCaipNetworkIds().join(","),n={page:e,entries:40,include:t,exclude:[...w.recommended.map((({id:e})=>e)),...r??[],...s??[]].filter(Boolean),chains:i},{data:a,count:c}=await y.fetchWallets(n),l=a.slice(0,20).map((e=>e.image_id)).filter(Boolean);await Promise.allSettled(l.map((e=>y._fetchWalletImage(e)))),w.wallets=o.j.uniqueBy([...w.wallets,...y._filterOutExtensions(a)],"id").filter((e=>e.chains?.some((e=>i.includes(e))))),w.count=c>w.count?c:w.count,w.page=e},async initializeExcludedWallets({ids:e}){const t={page:1,entries:e.length,include:e},{data:r}=await y.fetchWallets(t);r&&r.forEach((e=>{w.excludedWallets.push({rdns:e.rdns,name:e.name})}))},async searchWallet({search:e,badge:t}){const{includeWalletIds:r,excludeWalletIds:s}=g.OptionsController.state,i=u.R.getRequestedCaipNetworkIds().join(",");w.search=[];const n={page:1,entries:100,search:e?.trim(),badge_type:t,include:r,exclude:s,chains:i},{data:a}=await y.fetchWallets(n);p.X.sendEvent({type:"track",event:"SEARCH_WALLET",properties:{badge:t??"",search:e??""}});const c=a.map((e=>e.image_id)).filter(Boolean);await Promise.allSettled([...c.map((e=>y._fetchWalletImage(e))),o.j.wait(300)]),w.search=y._filterOutExtensions(a)},initPromise(e,t){const r=w.promises[e];return r||(w.promises[e]=t())},prefetch({fetchConnectorImages:e=!0,fetchFeaturedWallets:t=!0,fetchRecommendedWallets:r=!0,fetchNetworkImages:s=!0}={}){const i=[e&&y.initPromise("connectorImages",y.fetchConnectorImages),t&&y.initPromise("featuredWallets",y.fetchFeaturedWallets),r&&y.initPromise("recommendedWallets",y.fetchRecommendedWallets),s&&y.initPromise("networkImages",y.fetchNetworkImages)].filter(Boolean);return Promise.allSettled(i)},prefetchAnalyticsConfig(){g.OptionsController.state.features?.anal
1ytics&&y.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:e}=await m.get({path:"/getAnalyticsConfig",params:y._getSdkProperties()});g.OptionsController.setFeatures({analytics:e})}catch(e){g.OptionsController.setFeatures({analytics:!1})}},filterByNamespaces(e){if(!e?.length)return w.featured=w.allFeatured,void(w.recommended=w.allRecommended);const t=u.R.getRequestedCaipNetworkIds().join(",");w.featured=w.allFeatured.filter((e=>e.chains?.some((e=>t.includes(e))))),w.recommended=w.allRecommended.filter((e=>e.chains?.some((e=>t.includes(e))))),w.filteredWallets=w.wallets.filter((e=>e.chains?.some((e=>t.includes(e)))))},clearFilterByNamespaces(){w.filteredWallets=[]},setFilterByNamespace(e){if(!e)return w.featured=w.allFeatured,void(w.recommended=w.allRecommended);const t=u.R.getRequestedCaipNetworkIds().join(",");w.featured=w.allFeatured.filter((e=>e.chains?.some((e=>t.includes(e))))),w.recommended=w.allRecommended.filter((e=>e.chains?.some((e=>t.includes(e))))),w.filteredWallets=w.wallets.filter((e=>e.chains?.some((e=>t.includes(e)))))}}},87374:function(e,t,r){"use strict";r.d(t,{W:function(){return c}});var s=r(44098),i=r(87178),n=r(68343);const o=(0,s.sj)({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),a={state:o,subscribeNetworkImages(e){return(0,s.Ld)(o.networkImages,(()=>e(o.networkImages)))},subscribeKey(e,t){return(0,i.VW)(o,e,t)},subscribe(e){return(0,s.Ld)(o,(()=>e(o)))},setWalletImage(e,t){o.walletImages[e]=t},setNetworkImage(e,t){o.networkImages[e]=t},setChainImage(e,t){o.chainImages[e]=t},setConnectorImage(e,t){o.connectorImages={...o.connectorImages,[e]:t}},setTokenImage(e,t){o.tokenImages[e]=t},setCurrencyImage(e,t){o.currencyImages[e]=t}},c=(0,n.P)(a)},66691:function(e,t,r){"use strict";r.d(t,{L:function(){return f}});var s=r(44098),i=r(47205),n=r(83241),o=r(28356),a=r(64125),c=r(83966),l=r(59757),h=r(77500),u=r(82879);const d={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"}]}]},p=n.j.getBlockchainApiUrl(),g=(0,s.sj)({clientId:null,api:new o.V({baseUrl:p,clientId:null}),supportedChains:{http:[],ws:[]}}),f={state:g,async get(e){const{st:t,sv:r}=f.getSdkProperties(),s=h.OptionsController.state.projectId,i={...e.params||{},st:t,sv:r,projectId:s};return g.api.get({...e,params:i})},getSdkProperties(){const{sdkType:e,sdkVersion:t}=h.OptionsController.state;return{st:e||"unknown",sv:t||"unknown"}},async isNetworkSupported(e){if(!e)return!1;try{g.supportedChains.http.length||await f.getSupportedNetworks()}catch(e){return!1}return g.supportedChains.http.includes(e)},async getSupportedNetworks(){try{const e=await f.get({path:"v1/supported-chains"});return g.supportedChains=e,e}catch{return g.supportedChains}},async fetchIdentity({address:e,caipNetworkId:t}){if(!await f.isNetworkSupported(t))return{avatar:"",name:""};const r=a.M.getIdentityFromCacheForAddress(e);if(r)return r;const s=await f.get({path:`/v1/identity/${e}`,params:{sender:l.R.state.activeCaipAddress?n.j.getPlainAddress(l.R.state.activeCaipAddress):void 0}});return a.M.updateIdentityCache({address:e,identity:s,timestamp:Date.now()}),s},async fetchTransactions({account:e,cursor:t,onramp:r,signal:s,cache:i,chainId:n}){return await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId)?f.get({path:`/v1/account/${e}/history`,params:{cursor:t,onramp:r,chainId:n},signal:s,cache:i}
1):{data:[],next:void 0}},async fetchSwapQuote({amount:e,userAddress:t,from:r,to:s,gasPrice:i}){return await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId)?f.get({path:"/v1/convert/quotes",headers:{"Content-Type":"application/json"},params:{amount:e,userAddress:t,from:r,to:s,gasPrice:i}}):{quotes:[]}},async fetchSwapTokens({chainId:e}){return await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId)?f.get({path:"/v1/convert/tokens",params:{chainId:e}}):{tokens:[]}},async fetchTokenPrice({addresses:e}){return await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId)?g.api.post({path:"/v1/fungible/price",body:{currency:"usd",addresses:e,projectId:h.OptionsController.state.projectId},headers:{"Content-Type":"application/json"}}):{fungibles:[]}},async fetchSwapAllowance({tokenAddress:e,userAddress:t}){return await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId)?f.get({path:"/v1/convert/allowance",params:{tokenAddress:e,userAddress:t},headers:{"Content-Type":"application/json"}}):{allowance:"0"}},async fetchGasPrice({chainId:e}){const{st:t,sv:r}=f.getSdkProperties();if(!await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Gas Price");return f.get({path:"/v1/convert/gas-price",headers:{"Content-Type":"application/json"},params:{chainId:e,st:t,sv:r}})},async generateSwapCalldata({amount:e,from:t,to:r,userAddress:s,disableEstimate:n}){if(!await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Swaps");return g.api.post({path:"/v1/convert/build-transaction",headers:{"Content-Type":"application/json"},body:{amount:e,eip155:{slippage:i.bq.CONVERT_SLIPPAGE_TOLERANCE},projectId:h.OptionsController.state.projectId,from:t,to:r,userAddress:s,disableEstimate:n}})},async generateApproveCalldata({from:e,to:t,userAddress:r}){const{st:s,sv:i}=f.getSdkProperties();if(!await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Swaps");return f.get({path:"/v1/convert/build-approve",headers:{"Content-Type":"application/json"},params:{userAddress:r,from:e,to:t,st:s,sv:i}})},async getBalance(e,t,r){const{st:s,sv:i}=f.getSdkProperties();if(!await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId))return u.SnackController.showError("Token Balance Unavailable"),{balances:[]};const n=`${t}:${e}`,o=a.M.getBalanceCacheForCaipAddress(n);if(o)return o;const c=await f.get({path:`/v1/account/${e}/balance`,params:{currency:"usd",chainId:t,forceUpdate:r,st:s,sv:i}});return a.M.updateBalanceCache({caipAddress:n,balance:c,timestamp:Date.now()}),c},async lookupEnsName(e){return await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId)?f.get({path:`/v1/profile/account/${e}`,params:{apiVersion:"2"}}):{addresses:{},attributes:[]}},async reverseLookupEnsName({address:e}){return await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId)?f.get({path:`/v1/profile/reverse/${e}`,params:{sender:c.N.state.address,apiVersion:"2"}}):[]},async getEnsNameSuggestions(e){return await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId)?f.get({path:`/v1/profile/suggestions/${e}`,params:{zone:"reown.id"}}):{suggestions:[]}},async registerEnsName({coinType:e,address:t,message:r,signature:s}){return await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId)?g.api.post({path:"/v1/profile/account",body:{coin_type:e,address:t,message:r,signature:s},headers:{"Content-Type":"application/json"}}):{success:!1}},async generateOnRampURL({destinationWallets:e,partnerUserId:t,defaultNetwork:r,purchaseAmount:s,paymentAmount:i}){if(!await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId))return"";return(await g.api.post({path:"/v1/generators/onrampurl",params:{projectId:h.OptionsController.state.projectId},body:{destinationWallets:e,defaultNetwork:r,partnerUserId:t,defaultExperience:"buy",presetCryptoAmount:s,presetFiatAmount:i}})).url},async getOnrampOptions(){if(!await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await f.get({path:"/v1/onramp/options"})}catch(e){return d}},async getOnrampQuote({purchaseCurrency:e,paymentCurrency:t,amount:r,network:s}){try{if(!await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId))return null;return await g.api.post({path:"/v1/onramp/quote",params:{projectId:h.OptionsController.state.projectId},body:{purchaseCurrency:e,paymentCurrency:t,amount:r,network:s}})}catch(e){return{coinbaseFee:{amount:r,currency:t.id},networkFee:{amount:r,currency:t.id},paymentSubtotal:{amount:r,currency:t.id},paymentTotal:{amount:r,currency:t.id},purchaseAmount:{amount:r,currency:t.id},quoteId:"mocked-quote-id"}}},async getSmartSessions(e){return await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId)?f.get({path:`/v1/sessions/${e}`}):[]},async revokeSmartSession(e,t,r){return await f.isNetworkSupported(l.R.state.activeCaipNetwork?.caipNetworkId)?g.api.post({path:`/v1/sessions/${e}/revoke`,params:{projectId:h.OptionsController.state.projectId},body:{pci:t,signature:r}}):{success:!1}},setClientId(e){g.clientId=e,g.api=new o.V({baseUrl:p,clientId:e})}}},59757:function(e,t,r){"use strict";r.d(t,{R:function(){return I}});var s=r(44098),i=r(87178),n=r(27777),o=r(68314),a=r(47205),c=r(83241),l=r(64125),h=r(68343),u=r(83966),d=r(78859),p=r(9793),g=r(51440),f=r(48121),m=r(77500),w=r(31249),y=r(4511),b=r(57244);const v={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[],user:void 0},C={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},E=(0,s.sj)({chains:(0,i.Yr)(),activeCaipAddress:void 0,activeChain:void 0,activeCaipNetwork:void 0,noAdapters:!1,universalAdapter
1:{networkControllerClient:void 0,connectionControllerClient:void 0},isSwitchingNamespace:!1}),N={state:E,subscribe(e){return(0,s.Ld)(E,(()=>{e(E)}))},subscribeKey(e,t){return(0,i.VW)(E,e,t)},subscribeChainProp(e,t,r){let i;return(0,s.Ld)(E.chains,(()=>{const s=r||E.activeChain;if(s){const r=E.chains.get(s)?.[e];i!==r&&(i=r,t(r))}}))},initialize(e,t,r){const{chainId:i,namespace:n}=l.M.getActiveNetworkProps(),o=t?.find((e=>e.id.toString()===i?.toString())),a=e.find((e=>e?.namespace===n))||e?.[0],c=e.map((e=>e.namespace)).filter((e=>void 0!==e)),h=m.OptionsController.state.enableEmbedded?new Set([...c]):new Set([...t?.map((e=>e.chainNamespace))??[]]);0!==e?.length&&a||(E.noAdapters=!0),E.noAdapters||(E.activeChain=a?.namespace,E.activeCaipNetwork=o,I.setChainNetworkData(a?.namespace,{caipNetwork:o}),E.activeChain&&w.I.set({activeChain:a?.namespace})),h.forEach((e=>{const i=t?.filter((t=>t.chainNamespace===e));I.state.chains.set(e,{namespace:e,networkState:(0,s.sj)({...C,caipNetwork:i?.[0]}),accountState:(0,s.sj)(v),caipNetworks:i??[],...r}),I.setRequestedCaipNetworks(i??[],e)}))},removeAdapter(e){if(E.activeChain===e){const t=Array.from(E.chains.entries()).find((([t])=>t!==e));if(t){const e=t[1]?.caipNetworks?.[0];e&&I.setActiveCaipNetwork(e)}}E.chains.delete(e)},addAdapter(e,{networkControllerClient:t,connectionControllerClient:r},s){E.chains.set(e.namespace,{namespace:e.namespace,networkState:{...C,caipNetwork:s[0]},accountState:v,caipNetworks:s,connectionControllerClient:r,networkControllerClient:t}),I.setRequestedCaipNetworks(s?.filter((t=>t.chainNamespace===e.namespace))??[],e.namespace)},addNetwork(e){const t=E.chains.get(e.chainNamespace);if(t){const r=[...t.caipNetworks||[]];t.caipNetworks?.find((t=>t.id===e.id))||r.push(e),E.chains.set(e.chainNamespace,{...t,caipNetworks:r}),I.setRequestedCaipNetworks(r,e.chainNamespace),p.ConnectorController.filterByNamespace(e.chainNamespace,!0)}},removeNetwork(e,t){const r=E.chains.get(e);if(r){const s=E.activeCaipNetwork?.id===t,i=[...r.caipNetworks?.filter((e=>e.id!==t))||[]];s&&r?.caipNetworks?.[0]&&I.setActiveCaipNetwork(r.caipNetworks[0]),E.chains.set(e,{...r,caipNetworks:i}),I.setRequestedCaipNetworks(i||[],e),0===i.length&&p.ConnectorController.filterByNamespace(e,!1)}},setAdapterNetworkState(e,t){const r=E.chains.get(e);r&&(r.networkState={...r.networkState||C,...t},E.chains.set(e,r))},setChainAccountData(e,t,r=!0){if(!e)throw new Error("Chain is required to update chain account data");const s=E.chains.get(e);if(s){const r={...s.accountState||v,...t};E.chains.set(e,{...s,accountState:r}),1!==E.chains.size&&E.activeChain!==e||(t.caipAddress&&(E.activeCaipAddress=t.caipAddress),u.N.replaceState(r))}},setChainNetworkData(e,t){if(!e)return;const r=E.chains.get(e);if(r){const s={...r.networkState||C,...t};E.chains.set(e,{...r,networkState:s})}},setAccountProp(e,t,r,s=!0){I.setChainAccountData(r,{[e]:t},s),"status"===e&&"disconnected"===t&&r&&p.ConnectorController.removeConnectorId(r)},setActiveNamespace(e){E.activeChain=e;const t=e?E.chains.get(e):void 0,r=t?.networkState?.caipNetwork;r?.id&&e&&(E.activeCaipAddress=t?.accountState?.caipAddress,E.activeCaipNetwork=r,I.setChainNetworkData(e,{caipNetwork:r}),l.M.setActiveCaipNetworkId(r?.caipNetworkId),w.I.set({activeChain:e,selectedNetworkId:r?.caipNetworkId}))},setActiveCaipNetwork(e){if(!e)return;E.activeChain!==e.chainNamespace&&I.setIsSwitchingNamespace(!0);const t=E.chains.get(e.chainNamespace);E.activeChain=e.chainNamespace,E.activeCaipNetwork=e,I.setChainNetworkData(e.chainNamespace,{caipNetwork:e}),E.activeCaipAddress=t?.accountState?.address?`${e.chainNamespace}:${e.id}:${t?.accountState?.address}`:void 0,I.setAccountProp("caipAddress",E.activeCaipAddress,e.chainNamespace),t&&u.N.replaceState(t.accountState),b.S.resetSend(),w.I.set({activeChain:E.activeChain,selectedNetworkId:E.activeCaipNetwork?.caipNetworkId}),l.M.setActiveCaipNetworkId(e.caipNetworkId);I.checkIfSupportedNetwork(e.chainNamespace)||!m.OptionsController.state.enableNetworkSwitch||m.OptionsController.state.allowUnsupportedChain||d.ConnectionController.state.wcBasic||I.showUnsupportedChainUI()},addCaipNetwork(e){if(!e)return;const t=E.chains.get(e.chainNamespace);t&&t?.caipNetworks?.push(e)},async switchActiveNamespace(e){if(!e)return;const t=e!==I.state.activeChain,r=I.getNetworkData(e)?.caipNetwork,s=I.getCaipNetworkByNamespace(e,r?.id);t&&s&&await I.switchActiveNetwork(s)},async switchActiveNetwork(e){const t=!I.state.chains.get(I.state.activeChain)?.caipNetworks?.some((e=>e.id===E.activeCaipNetwork?.id)),r=I.getNetworkControllerClient(e.chainNamespace);if(r){try{await r.switchCaipNetwork(e),t&&f.I.close()}catch(e){y.RouterController.goBack()}g.X.sendEvent({type:"track",event:"SWITCH_NETWORK",properties:{network:e.caipNetworkId}})}},getNetworkControllerClient(e){const t=e||E.activeChain,r=E.chains.get(t);if(!r)throw new Error("Chain adapter not found");if(!r.networkControllerClient)throw new Error("NetworkController client not set");return r.networkControllerClient},getConnectionControllerClient(e){const t=e||E.activeChain;if(!t)throw new Error("Chain is required to get connection controller client");const r=E.chains.get(t);if(!r?.connectionControllerClient)throw new Error("ConnectionController client not set");return r.connectionControllerClient},getAccountProp(e,t){let r=E.activeChain;if(t&&(r=t),!r)return;const s=E.chains.get(r)?.accountState;return s?s[e]:void 0},getNetworkProp(e,t){const r=E.chains.get(t)?.networkState;if(r)return r[e]},getRequestedCaipNetworks(e){const t=E.chains.get(e),{approvedCaipNetworkIds:r=[],requestedCaipNetworks:s=[]}=t?.networkState||{};return c.j.sortRequestedNetworks(r,s)},getAllRequestedCaipNetworks(){const e=[];return E.chains.forEach((t=>{const r=I.getRequestedCaipNetworks(t.namespace);e.push(...r)})),e},setRequestedCaipNetworks(e,t){I.setAdapterNetworkState(t,{requestedCaipNetworks:e});const r=I.getAllRequestedCaipNetworks().map((e=>e.chainNamespace)),s=Array.from(new Set(r));p.ConnectorController.filterByNamespaces(s)},getAllApprovedCaipNetworkIds(){const e=[];return E.chains.forEach((t=>{const r=I.getApprovedCaipNetworkIds(t.namespace);e.push(...r)})),e},getActiveCaipNetwork(){return E.activeCaipNetwork},getActiveCaipAddress(){return E.activeCaipAddress},getApprovedCaipNetworkIds(e){return E.chains.get(e)?.networkState?.approvedCaipNetworkIds||[]},async setApprovedCaipNetworksData(e){const t=I.getNetworkControllerClient(),r=await(t?.getApprovedCaipNetworksData());I.setAdapterNetworkState(e,{approvedCaipNetworkIds:r?.approvedCaipNetworkIds,supportsAllNetworks:r?.supportsAllNetworks})},checkIfSupportedNetwork(e,t){const r=t||E.activeCaipNetwork,s=I.getRequestedCaipNetworks(e);return!s.length||s?.some((e=>e.id===r?.id))},checkIfSupportedChainId(e){if(!E.activeChain)return!0;return I.getRequestedCaipNetworks(E.activeChain)?.some((t=>
1t.id===e))},setSmartAccountEnabledNetworks(e,t){I.setAdapterNetworkState(t,{smartAccountEnabledNetworks:e})},checkIfSmartAccountEnabled(){const e=n.p.caipNetworkIdToNumber(E.activeCaipNetwork?.caipNetworkId),t=E.activeChain;if(!t||!e)return!1;const r=I.getNetworkProp("smartAccountEnabledNetworks",t);return Boolean(r?.includes(Number(e)))},getActiveNetworkTokenAddress(){const e=E.activeCaipNetwork?.chainNamespace||"eip155";return`${e}:${E.activeCaipNetwork?.id||1}:${a.bq.NATIVE_TOKEN_ADDRESS[e]}`},showUnsupportedChainUI(){f.I.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const e=E.activeCaipNetwork;return Boolean(e?.chainNamespace&&a.bq.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(e.chainNamespace))},resetNetwork(e){I.setAdapterNetworkState(e,{approvedCaipNetworkIds:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]})},resetAccount(e){const t=e;if(!t)throw new Error("Chain is required to set account prop");E.activeCaipAddress=void 0,I.setChainAccountData(t,{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,preferredAccountTypes:void 0,socialProvider:void 0,socialWindow:void 0,farcasterUrl:void 0,allAccounts:[],user:void 0,status:"disconnected"}),p.ConnectorController.removeConnectorId(t)},setIsSwitchingNamespace(e){E.isSwitchingNamespace=e},getFirstCaipNetworkSupportsAuthConnector(){const e=[];let t;if(E.chains.forEach((t=>{o.b.AUTH_CONNECTOR_SUPPORTED_CHAINS.find((e=>e===t.namespace))&&t.namespace&&e.push(t.namespace)})),e.length>0){const r=e[0];return t=r?E.chains.get(r)?.caipNetworks?.[0]:void 0,t}},getAccountData(e){return e?I.state.chains.get(e)?.accountState:u.N.state},getNetworkData(e){const t=e||E.activeChain;if(t)return I.state.chains.get(t)?.networkState},getCaipNetworkByNamespace(e,t){if(!e)return;const r=I.state.chains.get(e),s=r?.caipNetworks?.find((e=>e.id===t));return s||(r?.networkState?.caipNetwork||r?.caipNetworks?.[0])},getRequestedCaipNetworkIds(){const e=p.ConnectorController.state.filterByNamespace;return(e?[E.chains.get(e)]:Array.from(E.chains.values())).flatMap((e=>e?.caipNetworks||[])).map((e=>e.caipNetworkId))},getCaipNetworks(e){return e?I.getRequestedCaipNetworks(e):I.getAllRequestedCaipNetworks()}},I=(0,h.P)(N)},78859:function(e,t,r){"use strict";r.d(t,{ConnectionController:function(){return I}});var s=r(44098),i=r(87178),n=r(83241),o=r(64125),a=r(68343),c=r(83966),l=r(59757),h=r(9793),u=r(51440),d=r(48121),p=r(4511),g=r(22192),f=r(66691),m=r(77500),w=r(82879);const y=(0,s.sj)({transactions:[],coinbaseTransactions:{},transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),b={state:y,subscribe(e){return(0,s.Ld)(y,(()=>e(y)))},setLastNetworkInView(e){y.lastNetworkInView=e},async fetchTransactions(e,t){if(!e)throw new Error("Transactions can't be fetched without an accountAddress");y.loading=!0;try{const r=await f.L.fetchTransactions({account:e,cursor:y.next,onramp:t,cache:"coinbase"===t?"no-cache":void 0,chainId:l.R.state.activeCaipNetwork?.caipNetworkId}),s=v.filterSpamTransactions(r.data),i=v.filterByConnectedChain(s),n=[...y.transactions,...i];y.loading=!1,"coinbase"===t?y.coinbaseTransactions=v.groupTransactionsByYearAndMonth(y.coinbaseTransactions,r.data):(y.transactions=n,y.transactionsByYear=v.groupTransactionsByYearAndMonth(y.transactionsByYear,i)),y.empty=0===n.length,y.next=r.next?r.next:void 0}catch(t){const r=l.R.state.activeChain;u.X.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:e,projectId:m.OptionsController.state.projectId,cursor:y.next,isSmartAccount:c.N.state.preferredAccountTypes?.[r]===g.y_.ACCOUNT_TYPES.SMART_ACCOUNT}}),w.SnackController.showError("Failed to fetch transactions"),y.loading=!1,y.empty=!0,y.next=void 0}},groupTransactionsByYearAndMonth(e={},t=[]){const r=e;return t.forEach((e=>{const t=new Date(e.metadata.minedAt).getFullYear(),s=new Date(e.metadata.minedAt).getMonth(),i=r[t]??{},n=(i[s]??[]).filter((t=>t.id!==e.id));r[t]={...i,[s]:[...n,e].sort(((e,t)=>new Date(t.metadata.minedAt).getTime()-new Date(e.metadata.minedAt).getTime()))}})),r},filterSpamTransactions(e){return e.filter((e=>!e.transfers.every((e=>!0===e.nft_info?.flags.is_spam))))},filterByConnectedChain(e){const t=l.R.state.activeCaipNetwork?.caipNetworkId;return e.filter((e=>e.metadata.chain===t))}
1,clearCursor(){y.next=void 0},resetTransactions(){y.transactions=[],y.transactionsByYear={},y.lastNetworkInView=void 0,y.loading=!1,y.empty=!1,y.next=void 0}},v=(0,a.P)(b,"API_ERROR"),C=(0,s.sj)({connections:new Map,wcError:!1,buffering:!1,status:"disconnected"});let E;const N={state:C,subscribeKey(e,t){return(0,i.VW)(C,e,t)},_getClient(){return C._client},setClient(e){C._client=(0,s.iH)(e)},async connectWalletConnect(){if(n.j.isTelegram()||n.j.isSafari()&&n.j.isIos()){if(E)return await E,void(E=void 0);if(!n.j.isPairingExpired(C?.wcPairingExpiry)){const e=C.wcUri;return void(C.wcUri=e)}E=I._getClient()?.connectWalletConnect?.().catch((()=>{})),I.state.status="connecting",await E,E=void 0,C.wcPairingExpiry=void 0,I.state.status="connected"}else await(I._getClient()?.connectWalletConnect?.())},async connectExternal(e,t,r=!0){await(I._getClient()?.connectExternal?.(e)),r&&l.R.setActiveNamespace(t)},async reconnectExternal(e){await(I._getClient()?.reconnectExternal?.(e));const t=e.chain||l.R.state.activeChain;t&&h.ConnectorController.setConnectorId(e.id,t)},async setPreferredAccountType(e,t){d.I.setLoading(!0,l.R.state.activeChain);const r=h.ConnectorController.getAuthConnector();r&&(c.N.setPreferredAccountType(e,t),await r.provider.setPreferredAccount(e),o.M.setPreferredAccountTypes(c.N.state.preferredAccountTypes??{[t]:e}),await I.reconnectExternal(r),d.I.setLoading(!1,l.R.state.activeChain),u.X.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:e,network:l.R.state.activeCaipNetwork?.caipNetworkId||""}}))},async signMessage(e){return I._getClient()?.signMessage(e)},parseUnits(e,t){return I._getClient()?.parseUnits(e,t)},formatUnits(e,t){return I._getClient()?.formatUnits(e,t)},async sendTransaction(e){return I._getClient()?.sendTransaction(e)},async getCapabilities(e){return I._getClient()?.getCapabilities(e)},async grantPermissions(e){return I._getClient()?.grantPermissions(e)},async walletGetAssets(e){return I._getClient()?.walletGetAssets(e)??{}},async estimateGas(e){return I._getClient()?.estimateGas(e)},async writeContract(e){return I._getClient()?.writeContract(e)},async getEnsAddress(e){return I._getClient()?.getEnsAddress(e)},async getEnsAvatar(e){return I._getClient()?.getEnsAvatar(e)},checkInstalled(e){return I._getClient()?.checkInstalled?.(e)||!1},resetWcConnection(){C.wcUri=void 0,C.wcPairingExpiry=void 0,C.wcLinking=void 0,C.recentWallet=void 0,C.status="disconnected",v.resetTransactions(),o.M.deleteWalletConnectDeepLink()},resetUri(){C.wcUri=void 0,C.wcPairingExpiry=void 0,E=void 0},finalizeWcConnection(){const{wcLinking:e,recentWallet:t}=I.state;e&&o.M.setWalletConnectDeepLink(e),t&&o.M.setAppKitRecent(t),u.X.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:e?"mobile":"qrcode",name:p.RouterController.state.data?.wallet?.name||"Unknown"}})},setWcBasic(e){C.wcBasic=e},setUri(e){C.wcUri=e,C.wcPairingExpiry=n.j.getPairingExpiry()},setWcLinking(e){C.wcLinking=e},setWcError(e){C.wcError=e,C.buffering=!1},setRecentWallet(e){C.recentWallet=e},setBuffering(e){C.buffering=e},setStatus(e){C.status=e},async disconnect(e){try{await(I._getClient()?.disconnect(e))}catch(e){throw new a.g("Failed to disconnect","INTERNAL_SDK_ERROR",e)}},setConnections(e,t){C.connections.set(t,e)},switchAccount({connection:e,address:t,namespace:r}){if(h.ConnectorController.state.activeConnectorIds[r]===e.connectorId){const e=l.R.state.activeCaipNetwork;if(e){const s=`${r}:${e.id}:${t}`;c.N.setCaipAddress(s,r)}else console.warn(`No current network found for namespace "${r}"`)}else{const t=h.ConnectorController.getConnector(e.connectorId);t?I.connectExternal(t,r):console.warn(`No connector found for namespace "${r}"`)}}},I=(0,a.P)(N)},9793:function(e,t,r){"use strict";r.d(t,{ConnectorController:function(){return y}});var s=r(44098),i=r(87178),n=r(68314),o=r(45374),a=r(81106),c=r(64125),l=r(68343),h=r(48113),u=r(59757),d=r(77500),p=r(4511),g=r(12858);const f={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0,cosmos:void 0},m=(0,s.sj)({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:{...f},filterByNamespaceMap:{eip155:!0,solana:!0,polkadot:!0,bip122:!0,cosmos:!0}}),w={state:m,subscribe(e){return(0,s.Ld)(m,(()=>{e(m)}))},subscribeKey(e,t){return(0,i.VW)(m,e,t)},initialize(e){e.forEach((e=>{const t=c.M.getConnectedConnectorId(e);t&&y.setConnectorId(t,e)}))},setActiveConnector(e){e&&(m.activeConnector=(0,s.iH)(e))},setConnectors(e){e.filter((e=>!m.allConnectors.some((t=>
1t.id===e.id&&y.getConnectorName(t.name)===y.getConnectorName(e.name)&&t.chain===e.chain)))).forEach((e=>{"MULTI_CHAIN"!==e.type&&m.allConnectors.push((0,s.iH)(e))}));const t=y.getEnabledNamespaces(),r=y.getEnabledConnectors(t);m.connectors=y.mergeMultiChainConnectors(r)},filterByNamespaces(e){Object.keys(m.filterByNamespaceMap).forEach((e=>{m.filterByNamespaceMap[e]=!1})),e.forEach((e=>{m.filterByNamespaceMap[e]=!0})),y.updateConnectorsForEnabledNamespaces()},filterByNamespace(e,t){m.filterByNamespaceMap[e]=t,y.updateConnectorsForEnabledNamespaces()},updateConnectorsForEnabledNamespaces(){const e=y.getEnabledNamespaces(),t=y.getEnabledConnectors(e),r=y.areAllNamespacesEnabled();m.connectors=y.mergeMultiChainConnectors(t),r?h.ApiController.clearFilterByNamespaces():h.ApiController.filterByNamespaces(e)},getEnabledNamespaces(){return Object.entries(m.filterByNamespaceMap).filter((([e,t])=>t)).map((([e])=>e))},getEnabledConnectors(e){return m.allConnectors.filter((t=>e.includes(t.chain)))},areAllNamespacesEnabled(){return Object.values(m.filterByNamespaceMap).every((e=>e))},mergeMultiChainConnectors(e){const t=y.generateConnectorMapByName(e),r=[];return t.forEach((e=>{const t=e[0],s=t?.id===n.b.CONNECTOR_ID.AUTH;e.length>1&&t?r.push({name:t.name,imageUrl:t.imageUrl,imageId:t.imageId,connectors:[...e],type:s?"AUTH":"MULTI_CHAIN",chain:"eip155",id:t?.id||""}):t&&r.push(t)})),r},generateConnectorMapByName(e){const t=new Map;return e.forEach((e=>{const{name:r}=e,s=y.getConnectorName(r);if(!s)return;const i=t.get(s)||[];i.find((t=>t.chain===e.chain))||i.push(e),t.set(s,i)})),t},getConnectorName(e){if(!e)return e;return{"Trust Wallet":"Trust"}[e]||e},getUniqueConnectorsByName(e){const t=[];return e.forEach((e=>{t.find((t=>t.chain===e.chain))||t.push(e)})),t},addConnector(e){if(e.id===n.b.CONNECTOR_ID.AUTH){const t=e,r=(0,s.CO)(d.OptionsController.state),i=g.ThemeController.getSnapshot().themeMode,n=g.ThemeController.getSnapshot().themeVariables;t?.provider?.syncDappData?.({metadata:r.metadata,sdkVersion:r.sdkVersion,projectId:r.projectId,sdkType:r.sdkType}),t?.provider?.syncTheme({themeMode:i,themeVariables:n,w3mThemeVariables:(0,o.t)(n,i)}),y.setConnectors([e])}else y.setConnectors([e])},getAuthConnector(e){const t=e||u.R.state.activeChain,r=m.connectors.find((e=>e.id===n.b.CONNECTOR_ID.AUTH));if(r){if(r?.connectors?.length){return r.connectors.find((e=>e.chain===t))}return r}},getAnnouncedConnectorRdns(){return m.connectors.filter((e=>"ANNOUNCED"===e.type)).map((e=>e.info?.rdns))},getConnectorById(e){return m.allConnectors.find((t=>t.id===e))},getConnector(e,t){return m.allConnectors.filter((e=>e.chain===u.R.state.activeChain)).find((r=>r.explorerId===e||r.info?.rdns===t))},syncIfAuthConnector(e){if("ID_AUTH"!==e.id)return;const t=e,r=(0,s.CO)(d.OptionsController.state),i=g.ThemeController.getSnapshot().themeMode,n=g.ThemeController.getSnapshot().themeVariables;t?.provider?.syncDappData?.({metadata:r.metadata,sdkVersion:r.sdkVersion,sdkType:r.sdkType,projectId:r.projectId}),t.provider.syncTheme({themeMode:i,themeVariables:n,w3mThemeVariables:(0,o.t)(n,i)})},getConnectorsByNamespace(e){const t=m.allConnectors.filter((t=>t.chain===e));return y.mergeMultiChainConnectors(t)},selectWalletConnector(e){const t=y.getConnector(e.id,e.rdns),r=u.R.state.activeChain;a.R.handleMobileDeeplinkRedirect(t?.explorerId||e.id,r),t?p.RouterController.push("ConnectingExternal",{connector:t}):p.RouterController.push("ConnectingWalletConnect",{wallet:e})},getConnectors(e){return e?y.getConnectorsByNamespace(e):y.mergeMultiChainConnectors(m.allConnectors)},setFilterByNamespace(e){m.filterByNamespace=e,m.connectors=y.getConnectors(e),h.ApiController.setFilterByNamespace(e)},setConnectorId(e,t){e&&(m.activeConnectorIds={...m.activeConnectorIds,[t]:e},c.M.setConnectedConnectorId(t,e))},removeConnectorId(e){m.activeConnectorIds={...m.activeConnectorIds,[e]:void 0},c.M.deleteConnectedConnectorId(e)},getConnectorId(e){if(e)return m.activeConnectorIds[e]},isConnected(e){return e?Boolean(m.activeConnectorIds[e]):Object.values(m.activeConnectorIds).some((e=>Boolean(e)))},resetConnectorIds(){m.activeConnectorIds={...f}}},y=(0,l.P)(w)},51440:function(e,t,r){"use strict";r.d(t,{X:function(){return f}});var s=r(44098),i=r(68314),n=r(35855),o=r(83241),a=r(28356),c=r(83966),l=r(56008),h=r(77500);const u=o.j.getAnalyticsUrl(),d=new a.V({baseUrl:u,clientId:null}),p=["MODAL_CREATED"],g=(0,s.sj)({timestamp:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"}}),f={state:g,subscribe(e){return(0,s.Ld)(g,(()=>e(g)))},getSdkProperties(){const{projectId:e,sdkType:t,sdkVersion:r}=h.OptionsController.state;return{projectId:e,st:t,sv:r||"html-wagmi-4.2.2"}},async _sendAnalyticsEvent(e){try{const t=c.N.state.address;if(p.includes(e.data.event)||"undefined"==typeof window)return;await d.post({path:"/e",params:f.getSdkProperties(),body:{eventId:o.j.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:e.timestamp,props:{...e.data,address:t}}}),g.reportedErrors.FORBIDDEN=!1}
1catch(e){e instanceof Error&&e.cause instanceof Response&&e.cause.status===i.b.HTTP_STATUS_CODES.FORBIDDEN&&!g.reportedErrors.FORBIDDEN&&(l.AlertController.open({shortMessage:"Invalid App Configuration",longMessage:`Origin ${(0,n.$U)()?window.origin:"uknown"} not found on Allowlist - update configuration on cloud.reown.com`},"error"),g.reportedErrors.FORBIDDEN=!0)}},sendEvent(e){g.timestamp=Date.now(),g.data=e,h.OptionsController.state.features?.analytics&&f._sendAnalyticsEvent(g)}}},48121:function(e,t,r){"use strict";r.d(t,{I:function(){return v}});var s=r(44098),i=r(87178),n=r(83241),o=r(68314),a=r(83966),c=r(59757),l=r(9793),h=r(4511);const u={onSwitchNetwork({network:e,ignoreSwitchConfirmation:t=!1}){const r=c.R.state.activeCaipNetwork,s=h.RouterController.state.data;if(e.id===r?.id)return;const i=a.N.getCaipAddress(c.R.state.activeChain),n=e.chainNamespace!==c.R.state.activeChain,u=a.N.getCaipAddress(e.chainNamespace),d=l.ConnectorController.getConnectorId(c.R.state.activeChain)===o.b.CONNECTOR_ID.AUTH,p=o.b.AUTH_CONNECTOR_SUPPORTED_CHAINS.find((t=>t===e.chainNamespace));t||d&&p?h.RouterController.push("SwitchNetwork",{...s,network:e}):i&&n&&!u?h.RouterController.push("SwitchActiveChain",{switchToChain:e.chainNamespace,navigateTo:"Connect",navigateWithReplace:!0,network:e}):h.RouterController.push("SwitchNetwork",{...s,network:e})}};var d=r(68343),p=r(48113),g=r(78859),f=r(51440),m=r(77500),w=r(31249);const y=(0,s.sj)({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),b={state:y,subscribe(e){return(0,s.Ld)(y,(()=>e(y)))},subscribeKey(e,t){return(0,i.VW)(y,e,t)},async open(e){const t="connected"===a.N.state.status,r=e?.namespace,s=c.R.state.activeChain,i=r&&r!==s,o=c.R.getAccountData(e?.namespace)?.caipAddress;if(g.ConnectionController.state.wcBasic?p.ApiController.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1}):await p.ApiController.prefetch({fetchConnectorImages:!t,fetchFeaturedWallets:!t,fetchRecommendedWallets:!t}),l.ConnectorController.setFilterByNamespace(e?.namespace),v.setLoading(!0,r),r&&i){const e=c.R.getNetworkData(r)?.caipNetwork||c.R.getRequestedCaipNetworks(r)[0];e&&u.onSwitchNetwork({network:e,ignoreSwitchConfirmation:!0})}else{const t=c.R.state.noAdapters;m.OptionsController.state.manualWCControl||t&&!o?n.j.isMobile()?h.RouterController.reset("AllWallets"):h.RouterController.reset("ConnectingWalletConnectBasic"):e?.view?h.RouterController.reset(e.view,e.data):o?h.RouterController.reset("Account"):h.RouterController.reset("Connect")}y.open=!0,w.I.set({open:!0}),f.X.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:Boolean(o)}})},close(){const e=m.OptionsController.state.enableEmbedded,t=Boolean(c.R.state.activeCaipAddress);y.open&&f.X.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:t}}),y.open=!1,h.RouterController.reset("Connect"),v.clearLoading(),e?t?h.RouterController.replace("Account"):h.RouterController.push("Connect"):w.I.set({open:!1}),g.ConnectionController.resetUri()},setLoading(e,t){t&&y.loadingNamespaceMap.set(t,e),y.loading=e,w.I.set({loading:e})},clearLoading(){y.loadingNamespaceMap.clear(),y.loading=!1},shake(){y.shake||(y.shake=!0,setTimeout((()=>{y.shake=!1}),500))}},v=(0,d.P)(b)},77500:function(e,t,r){"use strict";r.d(t,{OptionsController:function(){return l}});var s=r(44098),i=r(87178),n=r(47205),o=r(83241);const a={getFeatureValue(e,t){const r=t?.[e];return void 0===r?n.bq.DEFAULT_FEATURES[e]:r},filterSocialsByPlatform(e){if(!e||!e.length)return e;if(o.j.isTelegram()){if(o.j.isIos())return e.filter((e=>"google"!==e));if(o.j.isMac())return e.filter((e=>"x"!==e));if(o.j.isAndroid())return e.filter((e=>!["facebook","x"].includes(e)))}return e}},c=(0,s.sj)({features:n.bq.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:n.bq.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0,experimental_preferUniversalLinks:!1,remoteFeatures:{}}),l={state:c,subscribeKey(e,t){return(0,i.VW)(c,e,t)},setOptions(e){Object.assign(c,e)},setRemoteFeatures(e){if(!e)return;const t={...c.remoteFeatures,...e};c.remoteFeatures=t,c.remoteFeatures?.socials&&(c.remoteFeatures.socials=a.filterS
1ocialsByPlatform(c.remoteFeatures.socials))},setFeatures(e){if(!e)return;c.features||(c.features=n.bq.DEFAULT_FEATURES);const t={...c.features,...e};c.features=t},setProjectId(e){c.projectId=e},setCustomRpcUrls(e){c.customRpcUrls=e},setAllWallets(e){c.allWallets=e},setIncludeWalletIds(e){c.includeWalletIds=e},setExcludeWalletIds(e){c.excludeWalletIds=e},setFeaturedWalletIds(e){c.featuredWalletIds=e},setTokens(e){c.tokens=e},setTermsConditionsUrl(e){c.termsConditionsUrl=e},setPrivacyPolicyUrl(e){c.privacyPolicyUrl=e},setCustomWallets(e){c.customWallets=e},setIsSiweEnabled(e){c.isSiweEnabled=e},setIsUniversalProvider(e){c.isUniversalProvider=e},setSdkVersion(e){c.sdkVersion=e},setMetadata(e){c.metadata=e},setDisableAppend(e){c.disableAppend=e},setEIP6963Enabled(e){c.enableEIP6963=e},setDebug(e){c.debug=e},setEnableWalletConnect(e){c.enableWalletConnect=e},setEnableWalletGuide(e){c.enableWalletGuide=e},setEnableAuthLogger(e){c.enableAuthLogger=e},setEnableWallets(e){c.enableWallets=e},setPreferUniversalLinks(e){c.experimental_preferUniversalLinks=e},setHasMultipleAddresses(e){c.hasMultipleAddresses=e},setSIWX(e){c.siwx=e},setConnectMethodsOrder(e){c.features={...c.features,connectMethodsOrder:e}},setWalletFeaturesOrder(e){c.features={...c.features,walletFeaturesOrder:e}},setSocialsOrder(e){c.remoteFeatures={...c.remoteFeatures,socials:e}},setCollapseWallets(e){c.features={...c.features,collapseWallets:e}},setEnableEmbedded(e){c.enableEmbedded=e},setAllowUnsupportedChain(e){c.allowUnsupportedChain=e},setManualWCControl(e){c.manualWCControl=e},setEnableNetworkSwitch(e){c.enableNetworkSwitch=e},setDefaultAccountTypes(e={}){Object.entries(e).forEach((([e,t])=>{t&&(c.defaultAccountTypes[e]=t)}))},setUniversalProviderConfigOverride(e){c.universalProviderConfigOverride=e},getUniversalProviderConfigOverride(){return c.universalProviderConfigOverride},getSnapshot(){return(0,s.CO)(c)}}},31249:function(e,t,r){"use strict";r.d(t,{I:function(){return o}});var s=r(44098),i=r(87178);const n=(0,s.sj)({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),o={state:n,subscribe(e){return(0,s.Ld)(n,(()=>e(n)))},subscribeOpen(e){return(0,i.VW)(n,"open",e)},set(e){Object.assign(n,{...n,...e})}}},4511:function(e,t,r){"use strict";r.d(t,{RouterController:function(){return p}});var s=r(44098),i=r(87178),n=r(68343),o=r(83966),a=r(59757),c=r(9793),l=r(48121),h=r(77500);const u=(0,s.sj)({view:"Connect",history:["Connect"],transactionStack:[]}),d={state:u,subscribeKey(e,t){return(0,i.VW)(u,e,t)},pushTransactionStack(e){u.transactionStack.push(e)},popTransactionStack(e){const t=u.transactionStack.pop();if(!t)return;const{onSuccess:r,onError:s,onCancel:i}=t;switch(e){case"success":r?.();break;case"error":s?.(),p.goBack();break;case"cancel":i?.(),p.goBack()}},push(e,t){e!==u.view&&(u.view=e,u.history.push(e),u.data=t)},reset(e,t){u.view=e,u.history=[e],u.data=t},replace(e,t){u.history.at(-1)===e||(u.view=e,u.history[u.history.length-1]=e,u.data=t)},goBack(){const e=a.R.state.activeCaipAddress,t="ConnectingFarcaster"===p.state.view,r=!e&&t;if(u.history.length>1){u.history.pop();const[t]=u.history.slice(-1);if(t){const r="Connect"===t;u.view=e&&r?"Account":t}}else l.I.close();u.data?.wallet&&(u.data.wallet=void 0),setTimeout((()=>{if(r){o.N.setFarcasterUrl(void 0,a.R.state.activeChain);const e=c.ConnectorController.getAuthConnector();e?.provider?.reload();const t=(0,s.CO)(h.OptionsController.state);e?.provider?.syncDappData?.({metadata:t.metadata,sdkVersion:t.sdkVersion,projectId:t.projectId,sdkType:t.sdkType})}}),100)},goBackToIndex(e){if(u.history.length>1){u.history=u.history.slice(0,e+1);const[t]=u.history.slice(-1);t&&(u.view=t)}},goBackOrCloseModal(){p.state.history.length>1?p.goBack():l.I.close()}},p=(0,n.P)(d)},57244:function(e,t,r){"use strict";r.d(t,{S:function(){return B}});var s=r(44098),i=r(87178),n=1e6,o=1e6,a="[big.js] ",c=a+"Invalid ",l=c+"decimal places",h=c+"rounding mode",u=a+"Division by zero",d={},p=void 0,g=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function f(e,t,r,s){var i=e.c;if(r===p&&(r=e.constructor.RM),0!==r&&1!==r&&2!==r&&3!==r)throw Error(h);if(t<1)s=3===r&&(s||!!i[0])||0===t&&(1===r&&i[0]>=5||2===r&&(i[0]>5||5===i[0]&&(s||i[1]!==p))),i.length=1,s?(e.e=e.e-t+1,i[0]=1):i[0]=e.e=0;else if(t<i.length){if(s=1===r&&i[t]>=5||2===r&&(i[t]>5||5===i[t]&&(s||i[t+1]!==p||1&i[t-1]))||3===r&&(s||!!i[0]),i.length=t,s)for(;++i[--t]>9;)if(i[t]=0,0===t){++e.e,i.unshift(1);break}for(t=i.length;!i[--t];)i.pop()}return e}function m(e,t,r){var s=e.e,i=e.c.join(""),n=i.length;if(t)i=i.charAt(0)+(n>1?"."+i.slice(1):"")+(s<0?"e":"e+")+s;else if(s<0){for(;++s;)i="0"+i;i="0."+i}else if(s>0)if(++s>n)for(s-=n;s--;)i+="0";else s<n&&(i=i.slice(0,s)+"."+i.slice(s));else n>1&&(i=i.charAt(0)+"."+i.slice(1));return e.s<0&&r?"-"+i:i}d.abs=function(){var e=new this.constructor(this);return e.s=1,e},d.cmp=function(e){var t,r=this,s=r.c,i=(e=new r.constructor(e)).c,n=r.s,o=e.s,a=r.e,c=e.e;if(!s[0]||!i[0])return s[0]?n:i[0]?-o:0;if(n!=o)return n;if(t=n<0,a!=c)return a>c^t?1:-1;for(o=(a=s.length)<(c=i.length)?a:c,n=-1;++n<o;)if(s[n]!=i[n])return s[n]>i[n]^t?1:-1;return a==c?0:a>c^t?1:-1},d.div=function(e){var t=this,r=t.constructor,s=t.c,i=(e=new r(e)).c,o=t.s==e.s?1:-1,a=r.DP;if(a!==~~a||a<0||a>n)throw Error(l);
vendor: 5,585 bytes, line 1
1if(!i[0])throw Error(u);if(!s[0])return e.s=o,e.c=[e.e=0],e;var c,h,d,g,m,w=i.slice(),y=c=i.length,b=s.length,v=s.slice(0,c),C=v.length,E=e,N=E.c=[],I=0,A=a+(E.e=t.e-e.e)+1;for(E.s=o,o=A<0?0:A,w.unshift(0);C++<c;)v.push(0);do{for(d=0;d<10;d++){if(c!=(C=v.length))g=c>C?1:-1;else for(m=-1,g=0;++m<c;)if(i[m]!=v[m]){g=i[m]>v[m]?1:-1;break}if(!(g<0))break;for(h=C==c?i:w;C;){if(v[--C]<h[C]){for(m=C;m&&!v[--m];)v[m]=9;--v[m],v[C]+=10}v[C]-=h[C]}for(;!v[0];)v.shift()}N[I++]=g?d:++d,v[0]&&g?v[C]=s[y]||0:v=[s[y]]}while((y++<b||v[0]!==p)&&o--);return N[0]||1==I||(N.shift(),E.e--,A--),I>A&&f(E,A,r.RM,v[0]!==p),E},d.eq=function(e){return 0===this.cmp(e)},d.gt=function(e){return this.cmp(e)>0},d.gte=function(e){return this.cmp(e)>-1},d.lt=function(e){return this.cmp(e)<0},d.lte=function(e){return this.cmp(e)<1},d.minus=d.sub=function(e){var t,r,s,i,n=this,o=n.constructor,a=n.s,c=(e=new o(e)).s;if(a!=c)return e.s=-c,n.plus(e);var l=n.c.slice(),h=n.e,u=e.c,d=e.e;if(!l[0]||!u[0])return u[0]?e.s=-c:l[0]?e=new o(n):e.s=1,e;if(a=h-d){for((i=a<0)?(a=-a,s=l):(d=h,s=u),s.reverse(),c=a;c--;)s.push(0);s.reverse()}else for(r=((i=l.length<u.length)?l:u).length,a=c=0;c<r;c++)if(l[c]!=u[c]){i=l[c]<u[c];break}if(i&&(s=l,l=u,u=s,e.s=-e.s),(c=(r=u.length)-(t=l.length))>0)for(;c--;)l[t++]=0;for(c=t;r>a;){if(l[--r]<u[r]){for(t=r;t&&!l[--t];)l[t]=9;--l[t],l[r]+=10}l[r]-=u[r]}for(;0===l[--c];)l.pop();for(;0===l[0];)l.shift(),--d;return l[0]||(e.s=1,l=[d=0]),e.c=l,e.e=d,e},d.mod=function(e){var t,r=this,s=r.constructor,i=r.s,n=(e=new s(e)).s;if(!e.c[0])throw Error(u);return r.s=e.s=1,t=1==e.cmp(r),r.s=i,e.s=n,t?new s(r):(i=s.DP,n=s.RM,s.DP=s.RM=0,r=r.div(e),s.DP=i,s.RM=n,this.minus(r.times(e)))},d.neg=function(){var e=new this.constructor(this);return e.s=-e.s,e},d.plus=d.add=function(e){var t,r,s,i=this,n=i.constructor;if(e=new n(e),i.s!=e.s)return e.s=-e.s,i.minus(e);var o=i.e,a=i.c,c=e.e,l=e.c;if(!a[0]||!l[0])return l[0]||(a[0]?e=new n(i):e.s=i.s),e;if(a=a.slice(),t=o-c){for(t>0?(c=o,s=l):(t=-t,s=a),s.reverse();t--;)s.push(0);s.reverse()}for(a.length-l.length<0&&(s=l,l=a,a=s),t=l.length,r=0;t;a[t]%=10)r=(a[--t]=a[t]+l[t]+r)/10|0;for(r&&(a.unshift(r),++c),t=a.length;0===a[--t];)a.pop();return e.c=a,e.e=c,e},d.pow=function(e){var t=this,r=new t.constructor("1"),s=r,i=e<0;if(e!==~~e||e<-1e6||e>o)throw Error(c+"exponent");for(i&&(e=-e);1&e&&(s=s.times(t)),e>>=1;)t=t.times(t);return i?r.div(s):s},d.prec=function(e,t){if(e!==~~e||e<1||e>n)throw Error(c+"precision");return f(new this.constructor(this),e,t)},d.round=function(e,t){if(e===p)e=0;else if(e!==~~e||e<-n||e>n)throw Error(l);return f(new this.constructor(this),e+this.e+1,t)},d.sqrt=function(){var e,t,r,s=this,i=s.constructor,n=s.s,o=s.e,c=new i("0.5");if(!s.c[0])return new i(s);if(n<0)throw Error(a+"No square root");0===(n=Math.sqrt(+m(s,!0,!0)))||n===1/0?((t=s.c.join("")).length+o&1||(t+="0"),o=((o+1)/2|0)-(o<0||1&o),e=new i(((n=Math.sqrt(t))==1/0?"5e":(n=n.toExponential()).slice(0,n.indexOf("e")+1))+o)):e=new i(n+""),o=e.e+(i.DP+=4);do{r=e,e=c.times(r.plus(s.div(r)))}while(r.c.slice(0,o).join("")!==e.c.slice(0,o).join(""));return f(e,(i.DP-=4)+e.e+1,i.RM)},d.times=d.mul=function(e){var t,r=this,s=r.constructor,i=r.c,n=(e=new s(e)).c,o=i.length,a=n.length,c=r.e,l=e.e;if(e.s=r.s==e.s?1:-1,!i[0]||!n[0])return e.c=[e.e=0],e;for(e.e=c+l,o<a&&(t=i,i=n,n=t,l=o,o=a,a=l),t=new Array(l=o+a);l--;)t[l]=0;for(c=a;c--;){for(a=0,l=o+c;l>c;)a=t[l]+n[c]*i[l-c-1]+a,t[l--]=a%10,a=a/10|0;t[l]=a}for(a?++e.e:t.shift(),c=t.length;!t[--c];)t.pop();return e.c=t,e},d.toExponential=function(e,t){var r=this,s=r.c[0];if(e!==p){if(e!==~~e||e<0||e>n)throw Error(l);for(r=f(new r.constructor(r),++e,t);r.c.length<e;)r.c.push(0)}return m(r,!0,!!s)},d.toFixed=function(e,t){var r=this,s=r.c[0];if(e!==p){if(e!==~~e||e<0||e>n)throw Error(l);for(e=e+(r=f(new r.constructor(r),e+r.e+1,t)).e+1;r.c.length<e;)r.c.push(0)}return m(r,!1,!!s)},d[Symbol.for("nodejs.util.inspect.custom")]=d.toJSON=d.toString=function(){var e=this,t=e.constructor;return m(e,e.e<=t.NE||e.e>=t.PE,!!e.c[0])},d.toNumber=function(){var e=+m(this,!0,!0);if(!0===this.constructor.strict&&!this.eq(e.toString()))throw Error(a+"Imprecise conversion");return e},d.toPrecision=function(e,t){var r=this,s=r.constructor,i=r.c[0];if(e!==p){if(e!==~~e||e<1||e>n)throw Error(c+"precision");for(r=f(new s(r),e,t);r.c.length<e;)r.c.push(0)}return m(r,e<=r.e||r.e<=s.NE||r.e>=s.PE,!!i)},d.valueOf=function(){var e=this,t=e.constructor;if(!0===t.strict)throw Error(a+"valueOf disallowed");return m(e,e.e<=t.NE||e.e>=t.PE,!0)};var w=function e(){function t(r){var s=this;if(!(s instanceof t))return r===p?e():new t(r);if(r instanceof t)s.s=r.s,s.e=r.e,s.c=r.c.slice();else{if("string"!=typeof r){if(!0===t.strict&&"bigint"!=typeof r)throw TypeError(c+"value");r=0===r&&1/r<0?"-0":String(r)}!function(e,t){var r,s,i;if(!g.test(t))throw Error(c+"number");e.s="-"==t.charAt(0)?(t=t.slice(1),-1):1,(r=t.indexOf("."))>-1&&(t=t.replace(".",""));(s=t.search(/e/i))>0?(r<0&&(r=s),r+=+t.slice(s+1),t=t.substring(0,s)):r<0&&(r=t.length);for(i=t.length,s=0;s<i&&"0"==t.charAt(s);)++s;if(s==i)e.c=[e.e=0];else{for(;i>0&&"0"==t.charAt(--i););for(e.e=r-s-1,e.c=[],r=0;s<=i;)e.c[r++]=+t.charAt(s++)}}(s,r)}s.constructor=t}return t.prototype=d,t.DP=20,t.RM=1,t.NE=-7,t.PE=21,t.strict=false,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}(),y=w;const b={bigNumber(e){return new y(e||0)},multiply(e,t){if(void 0===e||void 0===t)return new y(0);const r=new y(e),s=new y(t);return r.times(s)},formatNumberToLocalString(e,t=2){return void 0===e?"0.00":"number"==typeof e?e.toLocaleStr
1ing("en-US",{maximumFractionDigits:t,minimumFractionDigits:t}):parseFloat(e).toLocaleString("en-US",{maximumFractionDigits:t,minimumFractionDigits:t})},parseLocalStringToNumber(e){return void 0===e?0:parseFloat(e.replace(/,/gu,""))}},v=[{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"}]}],C=[{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"}]}];var E=r(68314);const N=e=>E.b.USDT_CONTRACT_ADDRESSES.includes(e)?C:v;var I=r(22192),A=r(47205),S=r(83241),_=r(83966),O=r(66691),P=r(59757),T=r(78859),k=r(15229);const R={createBalance(e,t){const r={name:e.metadata.name||"",symbol:e.metadata.symbol||"",decimals:e.metadata.decimals||0,value:e.metadata.value||0,price:e.metadata.price||0,iconUrl:e.metadata.iconUrl||""};return{name:r.name,symbol:r.symbol,chainId:t,address:"native"===e.address?void 0:this.convertAddressToCAIP10Address(e.address,t),value:r.value,price:r.price,quantity:{decimals:r.decimals.toString(),numeric:this.convertHexToBalance({hex:e.balance,decimals:r.decimals})},iconUrl:r.iconUrl}},convertHexToBalance({hex:e,decimals:t}){return(0,k.b)(BigInt(e),t)},convertAddressToCAIP10Address(e,t){return`${t}:${e}`},createCAIP2ChainId(e,t){return`${t}:${parseInt(e,16)}`},getChainIdHexFromCAIP2ChainId(e){const t=e.split(":");if(t.length<2||!t[1])return"0x0";const r=t[1],s=parseInt(r,10);return isNaN(s)?"0x0":`0x${s.toString(16)}`},isWalletGetAssetsResponse(e){return"object"==typeof e&&null!==e&&Object.values(e).every((e=>Array.isArray(e)&&e.every((e=>this.isValidAsset(e)))))},isValidAsset(e){return"object"==typeof e&&null!==e&&"string"==typeof e.address&&"string"==typeof e.balance&&("ERC20"===e.type||"NATIVE"===e.type)&&"object"==typeof e.metadata&&null!==e.metadata&&"string"==typeof e.metadata.name&&"string"==typeof e.metadata.symbol&&"number"==typeof e.metadata.decimals&&"number"==typeof e.metadata.price&&"string"==typeof e.metadata.iconUrl}},x={async getMyTokensWithBalance(e){const t=_.N.state.address,r=P.R.state.activeCaipNetwork;if(!t||!r)return[];if("eip155"===r.chainNamespace){const e=await this.getEIP155Balances(t,r);if(e)return this.filterLowQualityTokens(e)}const s=await O.L.getBalance(t,r.caipNetworkId,e);return this.filterLowQualityTokens(s.balances)},async getEIP155Balances(e,t){try{const r=R.getChainIdHexFromCAIP2ChainId(t.caipNetworkId);if(!(await T.ConnectionController.getCapabilities(e))?.[r]?.assetDiscovery?.supported)return null;const s=await T.ConnectionController.walletGetAssets({account:e,chainFilter:[r]});if(!R.isWalletGetAssetsResponse(s))return null;return(s[r]||[]).map((e=>R.createBalance(e,t.caipNetworkId)))}catch(e){return null}},filterLowQualityTokens(e){return e.filter((e=>"0"!==e.quantity.decimals))},mapBalancesToSwapTokens(e){return e?.map((e=>({...e,address:e?.address?e.address:P.R.getActiveNetworkTokenAddress(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1})))||[]}};
1var U=r(68343),D=r(51440),$=r(4511),M=r(82879);const L=(0,s.sj)({tokenBalances:[],loading:!1}),j={state:L,subscribe(e){return(0,s.Ld)(L,(()=>e(L)))},subscribeKey(e,t){return(0,i.VW)(L,e,t)},setToken(e){e&&(L.token=(0,s.iH)(e))},setTokenAmount(e){L.sendTokenAmount=e},setReceiverAddress(e){L.receiverAddress=e},setReceiverProfileImageUrl(e){L.receiverProfileImageUrl=e},setReceiverProfileName(e){L.receiverProfileName=e},setNetworkBalanceInUsd(e){L.networkBalanceInUSD=e},setLoading(e){L.loading=e},async sendToken(){try{switch(B.setLoading(!0),P.R.state.activeCaipNetwork?.chainNamespace){case"eip155":return void await B.sendEvmToken();case"solana":return void await B.sendSolanaToken();default:throw new Error("Unsupported chain")}}finally{B.setLoading(!1)}},async sendEvmToken(){const e=P.R.state.activeChain,t=_.N.state.preferredAccountTypes?.[e];if(!B.state.sendTokenAmount||!B.state.receiverAddress)throw new Error("An amount and receiver address are required");if(!B.state.token)throw new Error("A token is required");B.state.token?.address?(D.X.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:t===I.y_.ACCOUNT_TYPES.SMART_ACCOUNT,token:B.state.token.address,amount:B.state.sendTokenAmount,network:P.R.state.activeCaipNetwork?.caipNetworkId||""}}),await B.sendERC20Token({receiverAddress:B.state.receiverAddress,tokenAddress:B.state.token.address,sendTokenAmount:B.state.sendTokenAmount,decimals:B.state.token.quantity.decimals})):(D.X.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:t===I.y_.ACCOUNT_TYPES.SMART_ACCOUNT,token:B.state.token.symbol||"",amount:B.state.sendTokenAmount,network:P.R.state.activeCaipNetwork?.caipNetworkId||""}}),await B.sendNativeToken({receiverAddress:B.state.receiverAddress,sendTokenAmount:B.state.sendTokenAmount,decimals:B.state.token.quantity.decimals}))},async fetchTokenBalance(e){L.loading=!0;const t=P.R.state.activeCaipNetwork?.caipNetworkId,r=P.R.state.activeCaipNetwork?.chainNamespace,s=P.R.state.activeCaipAddress,i=s?S.j.getPlainAddress(s):void 0;if(L.lastRetry&&!S.j.isAllowedRetry(L.lastRetry,30*A.bq.ONE_SEC_MS))return L.loading=!1,[];try{if(i&&t&&r){const e=await x.getMyTokensWithBalance();return L.tokenBalances=e,L.lastRetry=void 0,e}}catch(t){L.lastRetry=Date.now(),e?.(t),M.SnackController.showError("Token Balance Unavailable")}finally{L.loading=!1}return[]},fetchNetworkBalance(){if(0===L.tokenBalances.length)return;const e=x.mapBalancesToSwapTokens(L.tokenBalances);if(!e)return;const t=e.find((e=>e.address===P.R.getActiveNetworkTokenAddress()));t&&(L.networkBalanceInUSD=t?b.multiply(t.quantity.numeric,t.price).toString():"0")},async sendNativeToken(e){$.RouterController.pushTransactionStack({});const t=e.receiverAddress,r=_.N.state.address,s=T.ConnectionController.parseUnits(e.sendTokenAmount.toString(),Number(e.decimals));await T.ConnectionController.sendTransaction({chainNamespace:"eip155",to:t,address:r,data:"0x",value:s??BigInt(0)}),D.X.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:_.N.state.preferredAccountTypes?.eip155===I.y_.ACCOUNT_TYPES.SMART_ACCOUNT,token:B.state.token?.symbol||"",amount:e.sendTokenAmount,network:P.R.state.activeCaipNetwork?.caipNetworkId||""}}),T.ConnectionController._getClient()?.updateBalance("eip155"),B.resetSend()},async sendERC20Token(e){$.RouterController.pushTransactionStack({onSuccess(){$.RouterController.replace("Account")}});const t=T.ConnectionController.parseUnits(e.sendTokenAmount.toString(),Number(e.decimals));if(_.N.state.address&&e.sendTokenAmount&&e.receiverAddress&&e.tokenAddress){const r=S.j.getPlainAddress(e.tokenAddress);await T.ConnectionController.writeContract({fromAddress:_.N.state.address,tokenAddress:r,args:[e.receiverAddress,t??BigInt(0)],method:"transfer",abi:N(r),chainNamespace:"eip155"}),B.resetSend()}},async sendSolanaToken(){if(!B.state.sendTokenAmount||!B.state.receiverAddress)throw new Error("An amount and receiver address are required");$.RouterController.pushTransactionStack({onSuccess(){$.RouterController.replace("Account")}}),await T.ConnectionController.sendTransaction({chainNamespace:"solana",to:B.state.receiverAddress,value:B.state.sendTokenAmount}),T.ConnectionController._getClient()?.updateBalance("solana"),B.resetSend()},resetSend(){L.token=void 0,L.sendTokenAmount=void 0,L.receiverAddress=void 0,L.receiverProfileImageUrl=void 0,L.receiverProfileName=void 0,L.loading=!1,L.tokenBalances=[]}},B=(0,U.P)(j)},82879:function(e,t,r){"use strict";r.d(t,{SnackController:function(){return c}});var s=r(44098),i=r(87178),n=r(83241);const o=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),a=(0,s.sj)({...o}),c={state:a,subscribeKey(e,t){return(0,i.VW)(a,e,t)},showLoading(e,t={}){this._showMessage({message:e,variant:"loading",...t})},showSuccess(e){this._showMessage({message:e,variant:"success"})},showSvg(e,t){this._showMessage({message:e,svg:t})},showError(e){const t=n.j.parseError(e);this._showMessage({message:t,variant:"error"})},hide(){a.message=o.message,a.variant=o.variant,a.svg=o.svg,a.open=o.open,a.autoClose=o.autoClose},_showMessage({message:e,svg:t,variant:r="success",autoClose:s=o.autoClose}){a.open?(a.open=!1,setTimeout((()=>{a.message=e,a.variant=r,a.svg=t,a.open=!0,a.autoClose=s}),150)):(a.message=e,a.variant=r,a.svg=t,a.open=!0,a.autoClose=s)}}},12858:function(e,t,r){"use strict";r.d(t,{ThemeController:function(){return l}});var s=r(44098),i=r(45374),n=r(68343),o=r(9793);const a=(0,s.sj)({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),c={state:a,subscribe(e){return(0,s.Ld)(a,(()=>e(a)))},setThemeMode(e){a.themeMode=e;try{const t=o.ConnectorController.getAuthConnector();
1if(t){const r=c.getSnapshot().themeVariables;t.provider.syncTheme({themeMode:e,themeVariables:r,w3mThemeVariables:(0,i.t)(r,e)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(e){a.themeVariables={...a.themeVariables,...e};try{const e=o.ConnectorController.getAuthConnector();if(e){const t=c.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:t,w3mThemeVariables:(0,i.t)(a.themeVariables,a.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot(){return(0,s.CO)(a)}},l=(0,n.P)(c)},44639:function(e,t,r){"use strict";r.d(t,{f:function(){return c}});var s=r(44098),i=r(48113),n=r(87374);const o={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00",cosmos:""},a=(0,s.sj)({networkImagePromises:{}}),c={async fetchWalletImage(e){if(e)return await i.ApiController._fetchWalletImage(e),this.getWalletImageById(e)},async fetchNetworkImage(e){if(!e)return;const t=this.getNetworkImageById(e);return t||(a.networkImagePromises[e]||(a.networkImagePromises[e]=i.ApiController._fetchNetworkImage(e)),await a.networkImagePromises[e],this.getNetworkImageById(e))},getWalletImageById(e){if(e)return n.W.state.walletImages[e]},getWalletImage(e){return e?.image_url?e?.image_url:e?.image_id?n.W.state.walletImages[e.image_id]:void 0},getNetworkImage(e){return e?.assets?.imageUrl?e?.assets?.imageUrl:e?.assets?.imageId?n.W.state.networkImages[e.assets.imageId]:void 0},getNetworkImageById(e){if(e)return n.W.state.networkImages[e]},getConnectorImage(e){return e?.imageUrl?e.imageUrl:e?.imageId?n.W.state.connectorImages[e.imageId]:void 0},getChainImage(e){return n.W.state.networkImages[o[e]]}}},47205:function(e,t,r){"use strict";r.d(t,{a$:function(){return n},bq:function(){return o},gy:function(){return i}});const s=(void 0!==r(34155)?{NODE_ENV:"production",PUBLIC_PATH:"/"}.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",i=[{label:"Coinbase",name:"coinbase",feeRange:"1-2%",url:"",supportedChains:["eip155"]},{label:"Meld.io",name:"meld",feeRange:"1-2%",url:"https://meldcrypto.com",supportedChains:["eip155","solana"]}],n="WXETMuFUQmqqybHuRkSgxv:25B8LJHSfpG6LVjR2ytU5Cwh7Z4Sch2ocoU",o={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,FIVE_SEC_MS:5e3,THREE_SEC_MS:3e3,ONE_SEC_MS:1e3,SECURE_SITE:s,SECURE_SITE_DASHBOARD:`${s}/dashboard`,SECURE_SITE_FAVICON:`${s}/images/favicon.png`,RESTRICTED_TIMEZONES:["ASIA/SHANGHAI","ASIA/URUMQI","ASIA/CHONGQING","ASIA/HARBIN","ASIA/KASHGAR","ASIA/MACAU","ASIA/HONG_KONG","ASIA/MACAO","ASIA/BEIJING","ASIA/HARBIN"],WC_COINBASE_PAY_SDK_CHAINS:["ethereum","arbitrum","polygon","berachain","avalanche-c-chain","optimism","celo","base"],WC_COINBASE_PAY_SDK_FALLBACK_CHAIN:"ethereum",WC_COINBASE_PAY_SDK_CHAIN_NAME_MAP:{Ethereum:"ethereum","Arbitrum One":"arbitrum",Polygon:"polygon",Berachain:"berachain",Avalanche:"avalanche-c-chain","OP Mainnet":"optimism",Celo:"celo",Base:"base"},WC_COINBASE_ONRAMP_APP_ID:"bf18c88d-495a-463b-b249-0b9d3656cf5e",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"],BALANCE_SUPPORTED_CHAINS:["eip155","solana"],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:["eip155"],ONRAMP_SUPPORTED_CHAIN_NAMESPACES:["eip155","solana"],ACTIVITY_ENABLED_CHAIN_NAMESPACES:["eip155"],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x",cosmos:"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:["eip155","solana"],DEFAULT_REMOTE_FEATURES:{swaps:["1inch"],onramp:["coinbase","meld"],email:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],activity:!0,reownBranding:!0},DEFAULT_REMOTE_FEATURES_DISABLED:{email:!1,socials:!1,swaps:!1,onramp:!1,activity:!1,reownBranding:!1},DEFAULT_FEATURES:{receive:!0,send:!0,emailShowWallets:!0,connectorTypeOrder:["walletConnect","recent","
1injected","featured","custom","external","recommended"],analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0,pay:!1},DEFAULT_SOCIALS:["google","x","farcaster","discord","apple","github","facebook"],DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",BITCOIN:"bitcoin"}}},83241:function(e,t,r){"use strict";r.d(t,{j:function(){return o}});var s=r(68314),i=r(47205),n=r(64125);const o={isMobile(){return!!this.isClient()&&Boolean("function"==typeof window?.matchMedia&&window?.matchMedia("(pointer:coarse)")?.matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent))},checkCaipNetwork(e,t=""){return e?.caipNetworkId.toLocaleLowerCase().includes(t.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const e=window?.navigator.userAgent.toLowerCase();return o.isMobile()&&e.includes("android")},isIos(){if(!this.isMobile())return!1;const e=window?.navigator.userAgent.toLowerCase();return e.includes("iphone")||e.includes("ipad")},isSafari(){if(!this.isClient())return!1;const e=window?.navigator.userAgent.toLowerCase();return e.includes("safari")},isClient(){return"undefined"!=typeof window},isPairingExpired(e){return!e||e-Date.now()<=i.bq.TEN_SEC_MS}
1,isAllowedRetry(e,t=i.bq.ONE_SEC_MS){return Date.now()-e>=t},copyToClopboard(e){navigator.clipboard.writeText(e)},isIframe(){try{return window?.self!==window?.top}catch(e){return!1}},isSafeApp(){if(o.isClient()&&window.self!==window.top)try{const e=window?.location?.ancestorOrigins?.[0],t="https://app.safe.global";if(e){const r=new URL(e),s=new URL(t);return r.hostname===s.hostname}}catch{return!1}return!1},getPairingExpiry(){return Date.now()+i.bq.FOUR_MINUTES_MS},getNetworkId(e){return e?.split(":")[1]},getPlainAddress(e){return e?.split(":")[2]},async wait(e){return new Promise((t=>{setTimeout(t,e)}))},debounce(e,t=500){let r;return(...s)=>{r&&clearTimeout(r),r=setTimeout((function(){e(...s)}),t)}},isHttpUrl(e){return e.startsWith("http://")||e.startsWith("https://")},formatNativeUrl(e,t,r=null){if(o.isHttpUrl(e))return this.formatUniversalUrl(e,t);let s=e,i=r;s.includes("://")||(s=e.replaceAll("/","").replaceAll(":",""),s=`${s}://`),s.endsWith("/")||(s=`${s}/`),i&&!i?.endsWith("/")&&(i=`${i}/`),this.isTelegram()&&this.isAndroid()&&(t=encodeURIComponent(t));const n=encodeURIComponent(t);return{redirect:`${s}wc?uri=${n}`,redirectUniversalLink:i?`${i}wc?uri=${n}`:void 0,href:s}},formatUniversalUrl(e,t){if(!o.isHttpUrl(e))return this.formatNativeUrl(e,t);let r=e;r.endsWith("/")||(r=`${r}/`);return{redirect:`${r}wc?uri=${encodeURIComponent(t)}`,href:r}},getOpenTargetForPlatform(e){return"popupWindow"===e?e:this.isTelegram()?n.M.getTelegramSocialProvider()?"_top":"_blank":e},openHref(e,t,r){window?.open(e,this.getOpenTargetForPlatform(t),r||"noreferrer noopener")},returnOpenHref(e,t,r){return window?.open(e,this.getOpenTargetForPlatform(t),r||"noreferrer noopener")},isTelegram(){return"undefined"!=typeof window&&(Boolean(window.TelegramWebviewProxy)||Boolean(window.Telegram)||Boolean(window.TelegramWebviewProxyProto))},isPWA(){if("undefined"==typeof window)return!1;const e=window.matchMedia?.("(display-mode: standalone)")?.matches,t=window?.navigator?.standalone;return Boolean(e||t)},async preloadImage(e){const t=new Promise(((t,r)=>{const s=new Image;s.onload=t,s.onerror=r,s.crossOrigin="anonymous",s.src=e}));return Promise.race([t,o.wait(2e3)])},formatBalance(e,t){let r="0.000";if("string"==typeof e){const t=Number(e);if(t){const e=Math.floor(1e3*t)/1e3;e&&(r=e.toString())}}return`${r}${t?` ${t}`:""}`},formatBalance2(e,t){let r;if("0"===e)r="0";else if("string"==typeof e){const t=Number(e);t&&(r=t.toString().match(/^-?\d+(?:\.\d{0,3})?/u)?.[0])}return{value:r??"0",rest:"0"===r?"000":"",symbol:t}},getApiUrl(){return s.b.W3M_API_URL},getBlockchainApiUrl(){return s.b.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return s.b.PULSE_API_URL},getUUID(){return crypto?.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,(e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},parseError(e){return"string"==typeof e?e:"string"==typeof e?.issues?.[0]?.message?e.issues[0].message:e instanceof Error?e.message:"Unknown error"},sortRequestedNetworks(e,t=[]){const r={};return t&&e&&(e.forEach(((e,t)=>{r[e]=t})),t.sort(((e,t)=>{const s=r[e.id],i=r[t.id];return void 0!==s&&void 0!==i?s-i:void 0!==s?-1:void 0!==i?1:0}))),t},calculateBalance(e){let t=0;for(const r of e)t+=r.value??0;return t},formatTokenBalance(e){const t=e.toFixed(2),[r,s]=t.split(".");return{dollars:r,pennies:s}},isAddress(e,t="eip155"){switch(t){case"eip155":return!!/^(?:0x)?[0-9a-f]{40}$/iu.test(e)&&!(!/^(?:0x)?[0-9a-f]{40}$/iu.test(e)&&!/^(?:0x)?[0-9A-F]{40}$/iu.test(e));case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(e);default:return!1}},uniqueBy(e,t){const r=new Set;return e.filter((e=>{const s=e[t];return!r.has(s)&&(r.add(s),!0)}))},generateSdkVersion(e,t,r){return`${t}-${0===e.length?i.bq.ADAPTER_TYPES.UNIVERSAL:e.map((e=>e.adapterType)).join(",")}-${r}`},createAccount(e,t,r,s,i){return{namespace:e,address:t,type:r,publicKey:s,path:i}},isCaipAddress(e){if("string"!=typeof e)return!1;const t=e.split(":"),r=t[0];return 3===t.filter(Boolean).length&&r in s.b.CHAIN_NAME_MAP},isMac(){const e=window?.navigator.userAgent.toLowerCase();return e.includes("macintosh")&&!e.includes("safari")},formatTelegramSocialLoginUrl(e){const t=`--${encodeURIComponent(window?.location.href)}`,r="state=";if("auth.magic.link"===new URL(e).host){const s="provider_authorization_url=",i=e.substring(e.indexOf(s)+s.length),n=this.injectIntoUrl(decodeURIComponent(i),r,t);return e.replace(i,encodeURIComponent(n))}return this.injectIntoUrl(e,r,t)},injectIntoUrl(e,t,r){const s=e.indexOf(t);if(-1===s)throw new Error(`${t} parameter not found in the URL: ${e}`);const i=e.indexOf("&",s),n=t.length,o=-1!==i?i:e.length;return e.substring(0,s+n)+(e.substring(s+n,o)+r)+e.substring(i)}}},28356:function(e,t,r){"use strict";async function s(...e){const t=await fetch(...e);if(!t.ok){throw new Error(`HTTP status code: ${t.status}`,{cause:t})}return t}r.d(t,{V:function(){return i}});class i{constructor({baseUrl:e,clientId:t}){this.baseUrl=e,this.clientId=t}async get({headers:e,signal:t,cache:r,...i}){const n=this.createUrl(i);return(await s(n,{method:"GET",headers:e,signal:t,cache:r})).json()}async getBlob({headers:e,signal:t,...r}){const i=this.createUrl(r);return(await s(i,{method:"GET",headers:e,signal:t})).blob()}async post({body:e,headers:t,signal:r,...i}){const n=this.createUrl(i);return(await s(n,{method:"POST",headers:t,body:e?JSON.stringify(e):void 0,signal:r})).json()}async put({body:e,headers:t,signal:r,...i}){const n=this.createUrl(i);return(await s(n,{method:"PUT",headers:t,body:e?JSON.stringify(e):void 0,signal:r})).json()}async delete({body:e,headers:t,signal:r,...i}){const n=this.createUrl(i);return(await s(n,{method:"DELETE",headers:t,body:e?JSON.stringify(e):void 0,signal:r})).json()}createUrl({path:e,params:t}
1){const r=new URL(e,this.baseUrl);return t&&Object.entries(t).forEach((([e,t])=>{t&&r.searchParams.append(e,t)})),this.clientId&&r.searchParams.append("clientId",this.clientId),r}}},81106:function(e,t,r){"use strict";r.d(t,{R:function(){return n},m:function(){return i}});var s=r(68314);const i={PHANTOM:{id:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",url:"https://phantom.app"},SOLFLARE:{id:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",url:"https://solflare.com"},COINBASE:{id:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",url:"https://go.cb-w.com"}},n={handleMobileDeeplinkRedirect(e,t){const r=window.location.href,n=encodeURIComponent(r);if(e===i.PHANTOM.id&&!("phantom"in window)){const e=r.startsWith("https")?"https":"http",t=r.split("/")[2],s=encodeURIComponent(`${e}://${t}`);window.location.href=`${i.PHANTOM.url}/ul/browse/${n}?ref=${s}`}e!==i.SOLFLARE.id||"solflare"in window||(window.location.href=`${i.SOLFLARE.url}/ul/v1/browse/${n}?ref=${n}`),t===s.b.CHAIN.SOLANA&&(e!==i.COINBASE.id||"coinbaseSolana"in window||(window.location.href=`${i.COINBASE.url}/dapp?cb_url=${n}`))}}},72579:function(e,t,r){"use strict";r.d(t,{w:function(){return f}});r(14967);var s=r(68314),i=r(22192),n=r(83966),o=r(59757),a=r(78859),c=r(9793),l=r(51440),h=r(48121),u=r(77500),d=r(4511),p=r(82879),g=r(83241);const f={getSIWX(){return u.OptionsController.state.siwx},async initializeIfEnabled(){const e=u.OptionsController.state.siwx,t=o.R.getActiveCaipAddress();if(!e||!t)return;const[r,s,i]=t.split(":");if(o.R.checkIfSupportedNetwork(r))try{if((await e.getSessions(`${r}:${s}`,i)).length)return;await h.I.open({view:"SIWXSignMessage"})}catch(e){console.error("SIWXUtil:initializeIfEnabled",e),l.X.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties()}),await(a.ConnectionController._getClient()?.disconnect().catch(console.error)),d.RouterController.reset("Connect"),p.SnackController.showError("A problem occurred while trying initialize authentication")}},async requestSignMessage(){const e=u.OptionsController.state.siwx,t=g.j.getPlainAddress(o.R.getActiveCaipAddress()),r=o.R.getActiveCaipNetwork(),i=a.ConnectionController._getClient();if(!e)throw new Error("SIWX is not enabled");if(!t)throw new Error("No ActiveCaipAddress found");if(!r)throw new Error("No ActiveCaipNetwork or client found");if(!i)throw new Error("No ConnectionController client found");try{const n=await e.createMessage({chainId:r.caipNetworkId,accountAddress:t}),o=n.toString();c.ConnectorController.getConnectorId(r.chainNamespace)===s.b.CONNECTOR_ID.AUTH&&d.RouterController.pushTransactionStack({});const a=await i.signMessage(o);await e.addSession({data:n,message:o,signature:a}),h.I.close(),l.X.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:this.getSIWXEventProperties()})}catch(e){const t=this.getSIWXEventProperties();h.I.state.open&&"ApproveTransaction"!==d.RouterController.state.view||await h.I.open({view:"SIWXSignMessage"}),t.isSmartAccount?p.SnackController.showError("This application might not support Smart Accounts"):p.SnackController.showError("Signature declined"),l.X.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:t}),console.error("SWIXUtil:requestSignMessage",e)}},async cancelSignMessage(){try{const e=this.getSIWX()?.getRequired?.();e?await a.ConnectionController.disconnect():h.I.close(),d.RouterController.reset("Connect"),l.X.sendEvent({event:"CLICK_CANCEL_SIWX",type:"track",properties:this.getSIWXEventProperties()})}catch(e){console.error("SIWXUtil:cancelSignMessage",e)}},async getSessions(){const e=u.OptionsController.state.siwx,t=g.j.getPlainAddress(o.R.getActiveCaipAddress()),r=o.R.getActiveCaipNetwork();return e&&t&&r?e.getSessions(r.caipNetworkId,t):[]},async isSIWXCloseDisabled(){const e=this.getSIWX();if(e){const t="ApproveTransaction"===d.RouterController.state.view,r="SIWXSignMessage"===d.RouterController.state.view;
1if(t||r)return e.getRequired?.()&&0===(await this.getSessions()).length}return!1},async universalProviderAuthenticate({universalProvider:e,chains:t,methods:r}){const s=f.getSIWX(),i=new Set(t.map((e=>e.split(":")[0])));if(!s||1!==i.size||!i.has("eip155"))return!1;const a=await s.createMessage({chainId:o.R.getActiveCaipNetwork()?.caipNetworkId||"",accountAddress:""}),c=await e.authenticate({nonce:a.nonce,domain:a.domain,uri:a.uri,exp:a.expirationTime,iat:a.issuedAt,nbf:a.notBefore,requestId:a.requestId,version:a.version,resources:a.resources,statement:a.statement,chainId:a.chainId,methods:r,chains:[a.chainId,...t.filter((e=>e!==a.chainId))]});if(p.SnackController.showLoading("Authenticating...",{autoClose:!1}),n.N.setConnectedWalletInfo({...c.session.peer.metadata,name:c.session.peer.metadata.name,icon:c.session.peer.metadata.icons?.[0],type:"WALLET_CONNECT"},Array.from(i)[0]),c?.auths?.length){const t=c.auths.map((t=>{const r=e.client.formatAuthMessage({request:t.p,iss:t.p.iss});return{data:{...t.p,accountAddress:t.p.iss.split(":").slice(-1).join(""),chainId:t.p.iss.split(":").slice(2,4).join(":"),uri:t.p.aud,version:t.p.version||a.version,expirationTime:t.p.exp,issuedAt:t.p.iat,notBefore:t.p.nbf},message:r,signature:t.s.s,cacao:t}}));try{await s.setSessions(t),l.X.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:f.getSIWXEventProperties()})}catch(t){throw console.error("SIWX:universalProviderAuth - failed to set sessions",t),l.X.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:f.getSIWXEventProperties()}),await e.disconnect().catch(console.error),t}finally{p.SnackController.hide()}}return!0},getSIWXEventProperties(){const e=o.R.state.activeChain;return{network:o.R.state.activeCaipNetwork?.caipNetworkId||"",isSmartAccount:n.N.state.preferredAccountTypes?.[e]===i.y_.ACCOUNT_TYPES.SMART_ACCOUNT}},async clearSessions(){const e=this.getSIWX();e&&await e.setSessions([])}}},64125:function(e,t,r){"use strict";r.d(t,{M:function(){return i}});var s=r(35855);const i={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5},isCacheExpired(e,t){return Date.now()-e>t},getActiveNetworkProps(){const e=i.getActiveNamespace(),t=i.getActiveCaipNetworkId(),r=t?t.split(":")[1]:void 0;return{namespace:e,caipNetworkId:t,chainId:r?isNaN(Number(r))?r:Number(r):void 0}},setWalletConnectDeepLink({name:e,href:t}){try{s.mr.setItem(s.uJ.DEEPLINK_CHOICE,JSON.stringify({href:t,name:e}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const e=s.mr.getItem(s.uJ.DEEPLINK_CHOICE);if(e)return JSON.parse(e)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{s.mr.removeItem(s.uJ.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(e){try{s.mr.setItem(s.uJ.ACTIVE_NAMESPACE,e)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(e){try{s.mr.setItem(s.uJ.ACTIVE_CAIP_NETWORK_ID,e),i.setActiveNamespace(e.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return s.mr.getItem(s.uJ.ACTIVE_CAIP_NETWORK_ID)}catch{return void console.info("Unable to get active caip network id")}},deleteActiveCaipNetworkId(){try{s.mr.removeItem(s.uJ.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(e){try{const t=(0,s.Vk)(e);s.mr.removeItem(t)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(e){try{const t=i.getRecentWallets();t.find((t=>t.id===e.id))||(t.unshift(e),t.length>2&&t.pop(),s.mr.setItem(s.uJ.RECENT_WALLETS,JSON.stringify(t)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const e=s.mr.getItem(s.uJ.RECENT_WALLETS);return e?JSON.parse(e):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(e,t){try{const r=(0,s.Vk)(e);s.mr.setItem(r,t)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return s.mr.getItem(s.uJ.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(e){if(e)try{const t=(0,s.Vk)(e);return s.mr.getItem(t)}catch(t){console.info("Unable to get connected connector id in namespace ",e)}},setConnectedSocialProvider(e){try{s.mr.setItem(s.uJ.CONNECTED_SOCIAL,e)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return s.mr.getItem(s.uJ.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{s.mr.removeItem(s.uJ.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return s.mr.getItem(s.uJ.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){const e=s.mr.getItem(s.uJ.ACTIVE_CAIP_NETWORK_ID)?.split(":")?.[1];return e},setConnectionStatus(e){try{s.mr.setItem(s.uJ.CONNECTION_STATUS,e)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return s.mr.getItem(s.uJ.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const e=s.mr.getItem(s.uJ.CONNECTED_NAMESPACES);return e?.length?e.split(","):[]}catch{return[]}},setConnectedNamespaces(e){try{const t=Array.from(new Set(e));s.mr.setItem(s.uJ.CONNECTED_NAMESPACES,t.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(e){try{const t=i.getConnectedNamespaces();t.includes(e)||(t.push(e),i.setConnectedNamespaces(t))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(e){try{const t=i.getConnectedNamespaces(),r=t.indexOf(e);r>-1&&(t.splice(r,1),i.setConnectedNamespaces(t))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return s.mr.getItem(s.uJ.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(e){try{s.mr.setItem(s.uJ.TELEGRAM_SOCIAL_PROVIDER,e)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{s.mr.removeItem(s.uJ.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let e={};try{const t=s.mr.getItem(s.uJ.PORTFOLIO_CACHE);e=t?JSON.parse(t):{}}catch{console.info("Unable to get balance cache")}return e},removeAddressFromBalanceCache(e){try{const t=i.getBalanceCache();s.mr.setItem(s.uJ.PORTFOLIO_CACHE,JSON.stringify({...t,[e]:void 0}))}catch{console.info("Unable to remove address from balance cache",e)}},getBalanceCacheForCaipAddress(e){try{const t=i.getBalanceCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.portfolio))return t.balance;i.removeAddressFromBalanceCache(e)}catch{console.info("Unable to get balance cache for address",e)}},updateBalanceCache(e){try{const t=i.getBalanceCache();t[e.caipAddress]=e,s.mr.setItem(s.uJ.PORTFOLIO_CACHE,JSON.stringify(t))}catch{console.info("Unable to update balance cache",e)}},getNativeBalanceCache(){let e={};try{const t=s.mr.getItem(s.uJ.NATIVE_BALANCE_CACHE);e=t?JSON.parse(t):{}}catch{console.info("Unable to get balance cache")}return e},removeAddressFromNativeBalanceCache(e){try{const t=i.getBalanceCache();s.mr.setItem(s.uJ.NATIVE_BALANCE_CACHE,JSON.stringify({...t,[e]:void 0}))}catch{console.info("Unable to remove address from balance cache",e)}},getNativeBalanceCacheForCaipAddress(e){try{const t=i.getNativeBalanceCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.nativeBalance))return t;console.info("Discarding cache for address",e),i.removeAddressFromBalanceCache(e)}catch{console.info("Unable to get balance cache for address",e)}},updateNativeBalanceCache(e){try{const t=i.getNativeBalanceCache();t[e.caipAddress]=e,s.mr.setItem(s.uJ.NATIVE_BALANCE_CACHE,JSON.stringify(t))}catch{console.info("Unable to update balance cache",e)}},getEnsCache(){let e={};try{const t=s.mr.getItem(s.uJ.ENS_CACHE);e=t?JSON.parse(t):{}}catch{console.info("Unable to get ens name cache")}return e}
1,getEnsFromCacheForAddress(e){try{const t=i.getEnsCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.ens))return t.ens;i.removeEnsFromCache(e)}catch{console.info("Unable to get ens name from cache",e)}},updateEnsCache(e){try{const t=i.getEnsCache();t[e.address]=e,s.mr.setItem(s.uJ.ENS_CACHE,JSON.stringify(t))}catch{console.info("Unable to update ens name cache",e)}},removeEnsFromCache(e){try{const t=i.getEnsCache();s.mr.setItem(s.uJ.ENS_CACHE,JSON.stringify({...t,[e]:void 0}))}catch{console.info("Unable to remove ens name from cache",e)}},getIdentityCache(){let e={};try{const t=s.mr.getItem(s.uJ.IDENTITY_CACHE);e=t?JSON.parse(t):{}}catch{console.info("Unable to get identity cache")}return e},getIdentityFromCacheForAddress(e){try{const t=i.getIdentityCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.identity))return t.identity;i.removeIdentityFromCache(e)}catch{console.info("Unable to get identity from cache",e)}},updateIdentityCache(e){try{const t=i.getIdentityCache();t[e.address]={identity:e.identity,timestamp:e.timestamp},s.mr.setItem(s.uJ.IDENTITY_CACHE,JSON.stringify(t))}catch{console.info("Unable to update identity cache",e)}},removeIdentityFromCache(e){try{const t=i.getIdentityCache();s.mr.setItem(s.uJ.IDENTITY_CACHE,JSON.stringify({...t,[e]:void 0}))}catch{console.info("Unable to remove identity from cache",e)}},clearAddressCache(){try{s.mr.removeItem(s.uJ.PORTFOLIO_CACHE),s.mr.removeItem(s.uJ.NATIVE_BALANCE_CACHE),s.mr.removeItem(s.uJ.ENS_CACHE),s.mr.removeItem(s.uJ.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}},setPreferredAccountTypes(e){try{s.mr.setItem(s.uJ.PREFERRED_ACCOUNT_TYPES,JSON.stringify(e))}catch{console.info("Unable to set preferred account types",e)}},getPreferredAccountTypes(){try{const e=s.mr.getItem(s.uJ.PREFERRED_ACCOUNT_TYPES);return e?JSON.parse(e):{}}catch{console.info("Unable to get preferred account types")}return{}},setConnections(e,t){try{const r={...i.getConnections(),[t]:e};s.mr.setItem(s.uJ.CONNECTIONS,JSON.stringify(r))}catch(e){console.error("Unable to sync connections to storage",e)}},getConnections(){try{const e=s.mr.getItem(s.uJ.CONNECTIONS);return e?JSON.parse(e):{}}catch(e){return console.error("Unable to get connections from storage",e),{}}}}},68343:function(e,t,r){"use strict";r.d(t,{g:function(){return d},P:function(){return g}});var s=r(44098),i=r(87178),n=r(83241),o=r(28356),a=r(77500);const c=Object.freeze({enabled:!0,events:[]}),l=new o.V({baseUrl:n.j.getAnalyticsUrl(),clientId:null}),h=(0,s.sj)({...c}),u={state:h,subscribeKey(e,t){return(0,i.VW)(h,e,t)},async sendError(e,t){if(!h.enabled)return;const r=Date.now();if(h.events.filter((e=>{const t=new Date(e.properties.timestamp||"").getTime();return r-t<6e4})).length>=5)return;const s={type:"error",event:t,properties:{errorType:e.name,errorMessage:e.message,stackTrace:e.stack,timestamp:(new Date).toISOString()}};h.events.push(s);try{if("undefined"==typeof window)return;const{projectId:r,sdkType:s,sdkVersion:i}=a.OptionsController.state;await l.post({path:"/e",params:{projectId:r,st:s,sv:i||"html-wagmi-4.2.2"},body:{eventId:n.j.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:(new Date).toISOString(),props:{type:"error",event:t,errorType:e.name,errorMessage:e.message,stackTrace:e.stack}}})}catch{}},enable(){h.enabled=!0},disable(){h.enabled=!1},clearEvents(){h.events=[]}};class d extends Error{constructor(e,t,r){super(e),this.name="AppKitError",this.category=t,this.originalError=r,Object.setPrototypeOf(this,d.prototype);let s=!1;if(r instanceof Error&&"string"==typeof r.stack&&r.stack){const e=r.stack,t=e.indexOf("\n");if(t>-1){const r=e.substring(t+1);this.stack=`${this.name}: ${this.message}\n${r}`,s=!0}}s||(Error.captureStackTrace?Error.captureStackTrace(this,d):this.stack||(this.stack=`${this.name}: ${this.message}`))}}function p(e,t){const r=e instanceof d?e:new d(e instanceof Error?e.message:String(e),t,e);throw u.sendError(r,r.category),r}function g(e,t="INTERNAL_SDK_ERROR"){const r={};return Object.keys(e).forEach((s=>{const i=e[s];if("function"==typeof i){let e=i;e="AsyncFunction"===i.constructor.name?async(...e)=>{try{return await i(...e)}catch(e){return p(e,t)}}:(...e)=>{try{return i(...e)}catch(e){return p(e,t)}},r[s]=e}else r[s]=i})),r}},11697:function(e,t,r){"use strict";r.d(t,{C:function(){return p}});var s=r(68314),i=r(77500),n=r(64125),o=r(48113),a=r(83241),c=r(78859),l=r(59757),h=r(9793),u=r(99436),d=r(32786);const p={getConnectorsByType(e,t,r){const{customWallets:s}=i.OptionsController.state,o=n.M.getRecentWallets(),a=d.J.filterOutDuplicateWallets(t),c=d.J.filterOutDuplicateWallets(r),l=e.filter((e=>"MULTI_CHAIN"===e.type)),h=e.filter((e=>"ANNOUNCED"===e.type)),u=e.filter((e=>"INJECTED"===e.type));return{custom:s,recent:o,external:e.filter((e=>"EXTERNAL"===e.type)),multiChain:l,announced:h,injected:u,recommended:a,featured:c}},showConnector(e){const t=e.info?.rdns,r=Boolean(t)&&o.ApiController.state.excludedWallets.some((e=>Boolean(e.rdns)&&e.rdns===t)),s=Boolean(e.name)&&o.ApiController.state.excludedWallets.some((t=>u.g.isLowerCaseMatch(t.name,e.name)));if("INJECTED"===e.type){if("Browser Wallet"===e.name){if(!a.j.isMobile())return!1;if(a.j.isMobile()&&!t&&!c.ConnectionController.checkInstalled())return!1}if(r||s)return!1}return"ANNOUNCED"!==e.type&&"EXTERNAL"!==e.type||!r&&!s},getIsConnectedWithWC(){return Array.from(l.R.state.chains.values()).some((e=>h.ConnectorController.getConnectorId(e.namespace)===s.b.CONNECTOR_ID.WALLET_CONNECT))},getConnectorTypeOrder({recommended:e,featured:t,custom:r,recent:s,announced:n,injected:o,multiChain:a,external:c,overriddenConnectors:l=i.OptionsController.state.features?.connectorTypeOrder??[]}){const h=p.getIsConnectedWithWC(),u=[{type:"walletConnect",isEnabled:i.OptionsController.state.enableWalletConnect&&!h},{type:"recent",isEnabled:s.length>0},{type:"injected",isEnabled:[...o,...n,...a].length>0},{type:"featured",isEnabled:t.length>0},{type:"custom",isEnabled:r&&r.length>0},{type:"external",isEnabled:c.length>0},{type:"recommended",isEnabled:e.length>0}].filter((e=>e.isEnabled)),d=new Set(u.map((e=>e.type))),g=l.filter((e=>d.has(e))).map((e=>({type:e,isEnabled:!0}))),f=u.filter((({type:e})=>!g.some((({type:t})=>t===e))));return Array.from(new Set([...g,...f].map((({type:e})=>e))))}}},72134:function(e,t,r){"use strict";r.d(t,{b:function(){return s}});const s={ACCOUNT_TABS:[{label:"Tokens"},{label:"NFTs"},{label:"Activity"}],SECURE_SITE_ORIGIN:(void 0!==r(34155)?{NODE_ENV:"production",PUBLIC_PATH:"/"}.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",VIEW_DIRECTION:{Next:"next",Prev:"prev"},DEFAULT_CONNECT_METHOD_ORDER:["email","social","wallet"],ANIMATION_DURATIONS:{HeaderText:120,ModalHeight:150,ViewTransition:150}}},32786:function(e,t,r){"use strict";r.d(t,{J:function(){return u}});var s=r(77500),i=r(9793),n=r(64125),o=r(83241),a=r(48113),c=r(99436),l=r(11697),h=r(72134);const u={filterOutDuplicatesByRDNS(e){const t=s.OptionsController.state.enableEIP6963?i.ConnectorController.state.connectors:[],r=n.M.getRecentWallets(),a=t.map((e=>
1e.info?.rdns)).filter(Boolean),c=r.map((e=>e.rdns)).filter(Boolean),l=a.concat(c);if(l.includes("io.metamask.mobile")&&o.j.isMobile()){const e=l.indexOf("io.metamask.mobile");l[e]="io.metamask"}return e.filter((e=>!l.includes(String(e?.rdns))))},filterOutDuplicatesByIds(e){const t=i.ConnectorController.state.connectors.filter((e=>"ANNOUNCED"===e.type||"INJECTED"===e.type)),r=n.M.getRecentWallets(),s=t.map((e=>e.explorerId)),o=r.map((e=>e.id)),a=s.concat(o);return e.filter((e=>!a.includes(e?.id)))},filterOutDuplicateWallets(e){const t=this.filterOutDuplicatesByRDNS(e);return this.filterOutDuplicatesByIds(t)},markWalletsAsInstalled(e){const{connectors:t}=i.ConnectorController.state,{featuredWalletIds:r}=s.OptionsController.state,n=t.filter((e=>"ANNOUNCED"===e.type)).reduce(((e,t)=>t.info?.rdns?(e[t.info.rdns]=!0,e):e),{});return e.map((e=>({...e,installed:Boolean(e.rdns)&&Boolean(n[e.rdns??""])}))).sort(((e,t)=>{const s=Number(t.installed)-Number(e.installed);if(0!==s)return s;if(r?.length){const s=r.indexOf(e.id),i=r.indexOf(t.id);if(-1!==s&&-1!==i)return s-i;if(-1!==s)return-1;if(-1!==i)return 1}return 0}))},getConnectOrderMethod(e,t){const r=e?.connectMethodsOrder||s.OptionsController.state.features?.connectMethodsOrder,n=t||i.ConnectorController.state.connectors;if(r)return r;const{injected:o,announced:c}=l.C.getConnectorsByType(n,a.ApiController.state.recommended,a.ApiController.state.featured),u=o.filter(l.C.showConnector),d=c.filter(l.C.showConnector);return u.length||d.length?["wallet","email","social"]:h.b.DEFAULT_CONNECT_METHOD_ORDER},isExcluded(e){const t=Boolean(e.rdns)&&a.ApiController.state.excludedWallets.some((t=>t.rdns===e.rdns)),r=Boolean(e.name)&&a.ApiController.state.excludedWallets.some((t=>c.g.isLowerCaseMatch(t.name,e.name)));return t||r}}},80446:function(e,t,r){"use strict";r.d(t,{Hg:function(){return i.H},Mo:function(){return h.M},n:function(){return s.n},Hs:function(){return s.Hs},R:function(){return s.R}});var s=r(24134),i=r(1512),n=r(24806),o=r(1788),a=r(69219),c=r(89790);n.extend(a),n.extend(c);const l={...o,name:"en-web3-modal",relativeTime:{future:"in %s",past:"%s ago",s:"%d sec",m:"1 min",mm:"%d min",h:"1 hr",hh:"%d hrs",d:"1 d",dd:"%d d",M:"1 mo",MM:"%d mo",y:"1 yr",yy:"%d yr"}};n.locale("en-web3-modal",l);var h=r(25729)},24134:function(e,t,r){"use strict";r.d(t,{Bp:function(){return g},ET:function(){return d},Hs:function(){return l},R:function(){return h},ZM:function(){return p},n:function(){return c}});var s=r(19064),i=r(45374);let n,o,a;function c(e,t){n=document.createElement("style"),o=document.createElement("style"),a=document.createElement("style"),n.textContent=u(e).core.cssText,o.textContent=u(e).dark.cssText,a.textContent=u(e).light.cssText,document.head.appendChild(n),document.head.appendChild(o),document.head.appendChild(a),l(t)}function l(e){o&&a&&("light"===e?(o.removeAttribute("media"),a.media="enabled"):(a.removeAttribute("media"),o.media="enabled"))}function h(e){n&&o&&a&&(n.textContent=u(e).core.cssText,o.textContent=u(e).dark.cssText,a.textContent=u(e).light.cssText)}function u(e){return{core:s.iv`
2      @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
3      @keyframes w3m-shake {
4        0% {
5          transform: scale(1) rotate(0deg);
6        }
7        20% {
8          transform: scale(1) rotate(-1deg);
9        }
10        40% {
11          transform: scale(1) rotate(1.5deg);
12        }
13        60% {
14          transform: scale(1) rotate(-1.5deg);
15        }
16        80% {
17          transform: scale(1) rotate(1deg);
18        }
19        100% {
20          transform: scale(1) rotate(0deg);
21        }
22      }
23      @keyframes w3m-iframe-fade-out {
24        0% {
25          opacity: 1;
26        }
27        100% {
28          opacity: 0;
29        }
30      }
31      @keyframes w3m-iframe-zoom-in {
32        0% {
33          transform: translateY(50px);
34          opacity: 0;
35        }
36        100% {
37          transform: translateY(0px);
38          opacity: 1;
39        }
40      }
41      @keyframes w3m-iframe-zoom-in-mobile {
42        0% {
43          transform: scale(0.95);
44          opacity: 0;
45        }
46        100% {
47          transform: scale(1);
48          opacity: 1;
49        }
50      }
51      :root {
52        --w3m-modal-width: 360px;
53        --w3m-color-mix-strength: ${(0,s.$m)(e?.["--w3m-color-mix-strength"]?`${e["--w3m-color-mix-strength"]}%`:"0%")};
54        --w3m-font-family: ${(0,s.$m)(e?.["--w3m-font-family"]||"Inter, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;")};
55        --w3m-font-size-master: ${(0,s.$m)(e?.["--w3m-font-size-master"]||"10px")};
56        --w3m-border-radius-master: ${(0,s.$m)(e?.["--w3m-border-radius-master"]||"4px")};
57        --w3m-z-index: ${(0,s.$m)(e?.["--w3m-z-index"]||
vendor: 15,824 bytes, lines 57-483
57999)};
58
59        --wui-font-family: var(--w3m-font-family);
60
61        --wui-font-size-mini: calc(var(--w3m-font-size-master) * 0.8);
62        --wui-font-size-micro: var(--w3m-font-size-master);
63        --wui-font-size-tiny: calc(var(--w3m-font-size-master) * 1.2);
64        --wui-font-size-small: calc(var(--w3m-font-size-master) * 1.4);
65        --wui-font-size-paragraph: calc(var(--w3m-font-size-master) * 1.6);
66        --wui-font-size-medium: calc(var(--w3m-font-size-master) * 1.8);
67        --wui-font-size-large: calc(var(--w3m-font-size-master) * 2);
68        --wui-font-size-title-6: calc(var(--w3m-font-size-master) * 2.2);
69        --wui-font-size-medium-title: calc(var(--w3m-font-size-master) * 2.4);
70        --wui-font-size-2xl: calc(var(--w3m-font-size-master) * 4);
71
72        --wui-border-radius-5xs: var(--w3m-border-radius-master);
73        --wui-border-radius-4xs: calc(var(--w3m-border-radius-master) * 1.5);
74        --wui-border-radius-3xs: calc(var(--w3m-border-radius-master) * 2);
75        --wui-border-radius-xxs: calc(var(--w3m-border-radius-master) * 3);
76        --wui-border-radius-xs: calc(var(--w3m-border-radius-master) * 4);
77        --wui-border-radius-s: calc(var(--w3m-border-radius-master) * 5);
78        --wui-border-radius-m: calc(var(--w3m-border-radius-master) * 7);
79        --wui-border-radius-l: calc(var(--w3m-border-radius-master) * 9);
80        --wui-border-radius-3xl: calc(var(--w3m-border-radius-master) * 20);
81
82        --wui-font-weight-light: 400;
83        --wui-font-weight-regular: 500;
84        --wui-font-weight-medium: 600;
85        --wui-font-weight-bold: 700;
86
87        --wui-letter-spacing-2xl: -1.6px;
88        --wui-letter-spacing-medium-title: -0.96px;
89        --wui-letter-spacing-title-6: -0.88px;
90        --wui-letter-spacing-large: -0.8px;
91        --wui-letter-spacing-medium: -0.72px;
92        --wui-letter-spacing-paragraph: -0.64px;
93        --wui-letter-spacing-small: -0.56px;
94        --wui-letter-spacing-tiny: -0.48px;
95        --wui-letter-spacing-micro: -0.2px;
96        --wui-letter-spacing-mini: -0.16px;
97
98        --wui-spacing-0: 0px;
99        --wui-spacing-4xs: 2px;
100        --wui-spacing-3xs: 4px;
101        --wui-spacing-xxs: 6px;
102        --wui-spacing-2xs: 7px;
103        --wui-spacing-xs: 8px;
104        --wui-spacing-1xs: 10px;
105        --wui-spacing-s: 12px;
106        --wui-spacing-m: 14px;
107        --wui-spacing-l: 16px;
108        --wui-spacing-2l: 18px;
109        --wui-spacing-xl: 20px;
110        --wui-spacing-xxl: 24px;
111        --wui-spacing-2xl: 32px;
112        --wui-spacing-3xl: 40px;
113        --wui-spacing-4xl: 90px;
114        --wui-spacing-5xl: 95px;
115
116        --wui-icon-box-size-xxs: 14px;
117        --wui-icon-box-size-xs: 20px;
118        --wui-icon-box-size-sm: 24px;
119        --wui-icon-box-size-md: 32px;
120        --wui-icon-box-size-mdl: 36px;
121        --wui-icon-box-size-lg: 40px;
122        --wui-icon-box-size-2lg: 48px;
123        --wui-icon-box-size-xl: 64px;
124
125        --wui-icon-size-inherit: inherit;
126        --wui-icon-size-xxs: 10px;
127        --wui-icon-size-xs: 12px;
128        --wui-icon-size-sm: 14px;
129        --wui-icon-size-md: 16px;
130        --wui-icon-size-mdl: 18px;
131        --wui-icon-size-lg: 20px;
132        --wui-icon-size-xl: 24px;
133        --wui-icon-size-xxl: 28px;
134
135        --wui-wallet-image-size-inherit: inherit;
136        --wui-wallet-image-size-sm: 40px;
137        --wui-wallet-image-size-md: 56px;
138        --wui-wallet-image-size-lg: 80px;
139
140        --wui-visual-size-size-inherit: inherit;
141        --wui-visual-size-sm: 40px;
142        --wui-visual-size-md: 55px;
143        --wui-visual-size-lg: 80px;
144
145        --wui-box-size-md: 100px;
146        --wui-box-size-lg: 120px;
147
148        --wui-ease-out-power-2: cubic-bezier(0, 0, 0.22, 1);
149        --wui-ease-out-power-1: cubic-bezier(0, 0, 0.55, 1);
150
151        --wui-ease-in-power-3: cubic-bezier(0.66, 0, 1, 1);
152        --wui-ease-in-power-2: cubic-bezier(0.45, 0, 1, 1);
153        --wui-ease-in-power-1: cubic-bezier(0.3, 0, 1, 1);
154
155        --wui-ease-inout-power-1: cubic-bezier(0.45, 0, 0.55, 1);
156
157        --wui-duration-lg: 200ms;
158        --wui-duration-md: 125ms;
159        --wui-duration-sm: 75ms;
160
161        --wui-path-network-sm: path(
162          'M15.4 2.1a5.21 5.21 0 0 1 5.2 0l11.61 6.7a5.21 5.21 0 0 1 2.61 4.52v13.4c0 1.87-1 3.59-2.6 4.52l-11.61 6.7c-1.62.93-3.6.93-5.22 0l-11.6-6.7a5.21 5.21 0 0 1-2.61-4.51v-13.4c0-1.87 1-3.6 2.6-4.52L15.4 2.1Z'
163        );
164
165        --wui-path-network-md: path(
166          'M43.4605 10.7248L28.0485 1.61089C25.5438 0.129705 22.4562 0.129705 19.9515 1.61088L4.53951 10.7248C2.03626 12.2051 0.5 14.9365 0.5 17.886V36.1139C0.5 39.0635 2.03626 41.7949 4.53951 43.2752L19.9515 52.3891C22.4562 53.8703 25.5438 53.8703 28.0485 52.3891L43.4605 43.2752C45.9637 41.7949 47.5 39.0635 47.5 36.114V17.8861C47.5 14.9365 45.9637 12.2051 43.4605 10.7248Z'
167        );
168
169        --wui-path-network-lg: path(
170          'M78.3244 18.926L50.1808 2.45078C45.7376 -0.150261 40.2624 -0.150262 35.8192 2.45078L7.6756 18.926C3.23322 21.5266 0.5 26.3301 0.5 31.5248V64.4752C0.5 69.6699 3.23322 74.4734 7.6756 77.074L35.8192 93.5492C40.2624 96.1503 45.7376 96.1503 50.1808 93.5492L78.3244 77.074C82.7668 74.4734 85.5 69.6699 85.5 64.4752V31.5248C85.5 26.3301 82.7668 21.5266 78.3244 18.926Z'
171        );
172
173        --wui-width-network-sm: 36px;
174        --wui-width-network-md: 48px;
175        --wui-width-network-lg: 86px;
176
177        --wui-height-network-sm: 40px;
178        --wui-height-network-md: 54px;
179        --wui-height-network-lg: 96px;
180
181        --wui-icon-size-network-xs: 12px;
182        --wui-icon-size-network-sm: 16px;
183        --wui-icon-size-network-md: 24px;
184        --wui-icon-size-network-lg: 42px;
185
186        --wui-color-inherit: inherit;
187
188        --wui-color-inverse-100: #fff;
189        --wui-color-inverse-000: #000;
190
191        --wui-cover: rgba(20, 20, 20, 0.8);
192
193        --wui-color-modal-bg: var(--wui-color-modal-bg-base);
194
195        --wui-color-accent-100: var(--wui-color-accent-base-100);
196        --wui-color-accent-090: var(--wui-color-accent-base-090);
197        --wui-color-accent-080: var(--wui-color-accent-base-080);
198
199        --wui-color-success-100: var(--wui-color-success-base-100);
200        --wui-color-success-125: var(--wui-color-success-base-125);
201
202        --wui-color-warning-100: var(--wui-color-warning-base-100);
203
204        --wui-color-error-100: var(--wui-color-error-base-100);
205        --wui-color-error-125: var(--wui-color-error-base-125);
206
207        --wui-color-blue-100: var(--wui-color-blue-base-100);
208        --wui-color-blue-90: var(--wui-color-blue-base-90);
209
210        --wui-icon-box-bg-error-100: var(--wui-icon-box-bg-error-base-100);
211        --wui-icon-box-bg-blue-100: var(--wui-icon-box-bg-blue-base-100);
212        --wui-icon-box-bg-success-100: var(--wui-icon-box-bg-success-base-100);
213        --wui-icon-box-bg-inverse-100: var(--wui-icon-box-bg-inverse-base-100);
214
215        --wui-all-wallets-bg-100: var(--wui-all-wallets-bg-100);
216
217        --wui-avatar-border: var(--wui-avatar-border-base);
218
219        --wui-thumbnail-border: var(--wui-thumbnail-border-base);
220
221        --wui-wallet-button-bg: var(--wui-wallet-button-bg-base);
222
223        --wui-box-shadow-blue: var(--wui-color-accent-glass-020);
224      }
225
226      @supports (background: color-mix(in srgb, white 50%, black)) {
227        :root {
228          --wui-color-modal-bg: color-mix(
229            in srgb,
230            var(--w3m-color-mix) var(--w3m-color-mix-strength),
231            var(--wui-color-modal-bg-base)
232          );
233
234          --wui-box-shadow-blue: color-mix(in srgb, var(--wui-color-accent-100) 20%, transparent);
235
236          --wui-color-accent-100: color-mix(
237            in srgb,
238            var(--wui-color-accent-base-100) 100%,
239            transparent
240          );
241          --wui-color-accent-090: color-mix(
242            in srgb,
243            var(--wui-color-accent-base-100) 90%,
244            transparent
245          );
246          --wui-color-accent-080: color-mix(
247            in srgb,
248            var(--wui-color-accent-base-100) 80%,
249            transparent
250          );
251          --wui-color-accent-glass-090: color-mix(
252            in srgb,
253            var(--wui-color-accent-base-100) 90%,
254            transparent
255          );
256          --wui-color-accent-glass-080: color-mix(
257            in srgb,
258            var(--wui-color-accent-base-100) 80%,
259            transparent
260          );
261          --wui-color-accent-glass-020: color-mix(
262            in srgb,
263            var(--wui-color-accent-base-100) 20%,
264            transparent
265          );
266          --wui-color-accent-glass-015: color-mix(
267            in srgb,
268            var(--wui-color-accent-base-100) 15%,
269            transparent
270          );
271          --wui-color-accent-glass-010: color-mix(
272            in srgb,
273            var(--wui-color-accent-base-100) 10%,
274            transparent
275          );
276          --wui-color-accent-glass-005: color-mix(
277            in srgb,
278            var(--wui-color-accent-base-100) 5%,
279            transparent
280          );
281          --wui-color-accent-002: color-mix(
282            in srgb,
283            var(--wui-color-accent-base-100) 2%,
284            transparent
285          );
286
287          --wui-color-fg-100: color-mix(
288            in srgb,
289            var(--w3m-color-mix) var(--w3m-color-mix-strength),
290            var(--wui-color-fg-100)
291          );
292          --wui-color-fg-125: color-mix(
293            in srgb,
294            var(--w3m-color-mix) var(--w3m-color-mix-strength),
295            var(--wui-color-fg-125)
296          );
297          --wui-color-fg-150: color-mix(
298            in srgb,
299            var(--w3m-color-mix) var(--w3m-color-mix-strength),
300            var(--wui-color-fg-150)
301          );
302          --wui-color-fg-175: color-mix(
303            in srgb,
304            var(--w3m-color-mix) var(--w3m-color-mix-strength),
305            var(--wui-color-fg-175)
306          );
307          --wui-color-fg-200: color-mix(
308            in srgb,
309            var(--w3m-color-mix) var(--w3m-color-mix-strength),
310            var(--wui-color-fg-200)
311          );
312          --wui-color-fg-225: color-mix(
313            in srgb,
314            var(--w3m-color-mix) var(--w3m-color-mix-strength),
315            var(--wui-color-fg-225)
316          );
317          --wui-color-fg-250: color-mix(
318            in srgb,
319            var(--w3m-color-mix) var(--w3m-color-mix-strength),
320            var(--wui-color-fg-250)
321          );
322          --wui-color-fg-275: color-mix(
323            in srgb,
324            var(--w3m-color-mix) var(--w3m-color-mix-strength),
325            var(--wui-color-fg-275)
326          );
327          --wui-color-fg-300: color-mix(
328            in srgb,
329            var(--w3m-color-mix) var(--w3m-color-mix-strength),
330            var(--wui-color-fg-300)
331          );
332          --wui-color-fg-325: color-mix(
333            in srgb,
334            var(--w3m-color-mix) var(--w3m-color-mix-strength),
335            var(--wui-color-fg-325)
336          );
337          --wui-color-fg-350: color-mix(
338            in srgb,
339            var(--w3m-color-mix) var(--w3m-color-mix-strength),
340            var(--wui-color-fg-350)
341          );
342
343          --wui-color-bg-100: color-mix(
344            in srgb,
345            var(--w3m-color-mix) var(--w3m-color-mix-strength),
346            var(--wui-color-bg-100)
347          );
348          --wui-color-bg-125: color-mix(
349            in srgb,
350            var(--w3m-color-mix) var(--w3m-color-mix-strength),
351            var(--wui-color-bg-125)
352          );
353          --wui-color-bg-150: color-mix(
354            in srgb,
355            var(--w3m-color-mix) var(--w3m-color-mix-strength),
356            var(--wui-color-bg-150)
357          );
358          --wui-color-bg-175: color-mix(
359            in srgb,
360            var(--w3m-color-mix) var(--w3m-color-mix-strength),
361            var(--wui-color-bg-175)
362          );
363          --wui-color-bg-200: color-mix(
364            in srgb,
365            var(--w3m-color-mix) var(--w3m-color-mix-strength),
366            var(--wui-color-bg-200)
367          );
368          --wui-color-bg-225: color-mix(
369            in srgb,
370            var(--w3m-color-mix) var(--w3m-color-mix-strength),
371            var(--wui-color-bg-225)
372          );
373          --wui-color-bg-250: color-mix(
374            in srgb,
375            var(--w3m-color-mix) var(--w3m-color-mix-strength),
376            var(--wui-color-bg-250)
377          );
378          --wui-color-bg-275: color-mix(
379            in srgb,
380            var(--w3m-color-mix) var(--w3m-color-mix-strength),
381            var(--wui-color-bg-275)
382          );
383          --wui-color-bg-300: color-mix(
384            in srgb,
385            var(--w3m-color-mix) var(--w3m-color-mix-strength),
386            var(--wui-color-bg-300)
387          );
388          --wui-color-bg-325: color-mix(
389            in srgb,
390            var(--w3m-color-mix) var(--w3m-color-mix-strength),
391            var(--wui-color-bg-325)
392          );
393          --wui-color-bg-350: color-mix(
394            in srgb,
395            var(--w3m-color-mix) var(--w3m-color-mix-strength),
396            var(--wui-color-bg-350)
397          );
398
399          --wui-color-success-100: color-mix(
400            in srgb,
401            var(--w3m-color-mix) var(--w3m-color-mix-strength),
402            var(--wui-color-success-base-100)
403          );
404          --wui-color-success-125: color-mix(
405            in srgb,
406            var(--w3m-color-mix) var(--w3m-color-mix-strength),
407            var(--wui-color-success-base-125)
408          );
409
410          --wui-color-warning-100: color-mix(
411            in srgb,
412            var(--w3m-color-mix) var(--w3m-color-mix-strength),
413            var(--wui-color-warning-base-100)
414          );
415
416          --wui-color-error-100: color-mix(
417            in srgb,
418            var(--w3m-color-mix) var(--w3m-color-mix-strength),
419            var(--wui-color-error-base-100)
420          );
421          --wui-color-blue-100: color-mix(
422            in srgb,
423            var(--w3m-color-mix) var(--w3m-color-mix-strength),
424            var(--wui-color-blue-base-100)
425          );
426          --wui-color-blue-90: color-mix(
427            in srgb,
428            var(--w3m-color-mix) var(--w3m-color-mix-strength),
429            var(--wui-color-blue-base-90)
430          );
431          --wui-color-error-125: color-mix(
432            in srgb,
433            var(--w3m-color-mix) var(--w3m-color-mix-strength),
434            var(--wui-color-error-base-125)
435          );
436
437          --wui-icon-box-bg-error-100: color-mix(
438            in srgb,
439            var(--w3m-color-mix) var(--w3m-color-mix-strength),
440            var(--wui-icon-box-bg-error-base-100)
441          );
442          --wui-icon-box-bg-accent-100: color-mix(
443            in srgb,
444            var(--w3m-color-mix) var(--w3m-color-mix-strength),
445            var(--wui-icon-box-bg-blue-base-100)
446          );
447          --wui-icon-box-bg-success-100: color-mix(
448            in srgb,
449            var(--w3m-color-mix) var(--w3m-color-mix-strength),
450            var(--wui-icon-box-bg-success-base-100)
451          );
452          --wui-icon-box-bg-inverse-100: color-mix(
453            in srgb,
454            var(--w3m-color-mix) var(--w3m-color-mix-strength),
455            var(--wui-icon-box-bg-inverse-base-100)
456          );
457
458          --wui-all-wallets-bg-100: color-mix(
459            in srgb,
460            var(--w3m-color-mix) var(--w3m-color-mix-strength),
461            var(--wui-all-wallets-bg-100)
462          );
463
464          --wui-avatar-border: color-mix(
465            in srgb,
466            var(--w3m-color-mix) var(--w3m-color-mix-strength),
467            var(--wui-avatar-border-base)
468          );
469
470          --wui-thumbnail-border: color-mix(
471            in srgb,
472            var(--w3m-color-mix) var(--w3m-color-mix-strength),
473            var(--wui-thumbnail-border-base)
474          );
475
476          --wui-wallet-button-bg: color-mix(
477            in srgb,
478            var(--w3m-color-mix) var(--w3m-color-mix-strength),
479            var(--wui-wallet-button-bg-base)
480          );
481        }
482      }
483    `,
483light:s.iv`
484      :root {
485        --w3m-color-mix: ${(0,s.$m)(e?.["--w3m-color-mix"]||"#fff")};
486        --w3m-accent: ${(0,s.$m)((0,i.t)(e,"dark")["--w3m-accent"])};
487        --w3m-default: #fff;
488
489        --wui-color-modal-bg-base: ${(0,s.$m)((0,i.t)(e,"dark")["--w3m-background"])};
490        --wui-color-accent-base-100: var(--w3m-accent);
491
492        --wui-color-blueberry-100: hsla(230, 100%, 67%, 1);
493        --wui-color-blueberry-090: hsla(231, 76%, 61%, 1);
494        --wui-color-blueberry-080: hsla(230, 59%, 55%, 1);
495        --wui-color-blueberry-050: hsla(231, 100%, 70%, 0.1);
496
497        --wui-color-fg-100: #e4e7e7;
498        --wui-color-fg-125: #d0d5d5;
499        --wui-color-fg-150: #a8b1b1;
500        --wui-color-fg-175: #a8b0b0;
501        --wui-color-fg-200: #949e9e;
502        --wui-color-fg-225: #868f8f;
503        --wui-color-fg-250: #788080;
504        --wui-color-fg-275: #788181;
505        --wui-color-fg-300: #6e7777;
506        --wui-color-fg-325: #9a9a9a;
507        --wui-color-fg-350: #363636;
508
509        --wui-color-bg-100: #141414;
510        --wui-color-bg-125: #191a1a;
511        --wui-color-bg-150: #1e1f1f;
512        --wui-color-bg-175: #222525;
513        --wui-color-bg-200: #272a2a;
514        --wui-color-bg-225: #2c3030;
515        --wui-color-bg-250: #313535;
516        --wui-color-bg-275: #363b3b;
517        --wui-color-bg-300: #3b4040;
518        --wui-color-bg-325: #252525;
519        --wui-color-bg-350: #ffffff;
520
521        --wui-color-success-base-100: #26d962;
522        --wui-color-success-base-125: #30a46b;
523
524        --wui-color-warning-base-100: #f3a13f;
525
526        --wui-color-error-base-100: #f25a67;
527        --wui-color-error-base-125: #df4a34;
528
529        --wui-color-blue-base-100: rgba(102, 125, 255, 1);
530        --wui-color-blue-base-90: rgba(102, 125, 255, 0.9);
531
532        --wui-color-success-glass-001: rgba(38, 217, 98, 0.01);
533        --wui-color-success-glass-002: rgba(38, 217, 98, 0.02);
534        --wui-color-success-glass-005: rgba(38, 217, 98, 0.05);
535        --wui-color-success-glass-010: rgba(38, 217, 98, 0.1);
536        --wui-color-success-glass-015: rgba(38, 217, 98, 0.15);
537        --wui-color-success-glass-020: rgba(38, 217, 98, 0.2);
538        --wui-color-success-glass-025: rgba(38, 217, 98, 0.25);
539        --wui-color-success-glass-030: rgba(38, 217, 98, 0.3);
540        --wui-color-success-glass-060: rgba(38, 217, 98, 0.6);
541        --wui-color-success-glass-080: rgba(38, 217, 98, 0.8);
542
543        --wui-color-success-glass-reown-020: rgba(48, 164, 107, 0.2);
544
545        --wui-color-warning-glass-reown-020: rgba(243, 161, 63, 0.2);
546
547        --wui-color-error-glass-001: rgba(242, 90, 103, 0.01);
548        --wui-color-error-glass-002: rgba(242, 90, 103, 0.02);
549        --wui-color-error-glass-005: rgba(242, 90, 103, 0.05);
550        --wui-color-error-glass-010: rgba(242, 90, 103, 0.1);
551        --wui-color-error-glass-015: rgba(242, 90, 103, 0.15);
552        --wui-color-error-glass-020: rgba(242, 90, 103, 0.2);
553        --wui-color-error-glass-025: rgba(242, 90, 103, 0.25);
554        --wui-color-error-glass-030: rgba(242, 90, 103, 0.3);
555        --wui-color-error-glass-060: rgba(242, 90, 103, 0.6);
556        --wui-color-error-glass-080: rgba(242, 90, 103, 0.8);
557
558        --wui-color-error-glass-reown-020: rgba(223, 74, 52, 0.2);
559
560        --wui-color-gray-glass-001: rgba(255, 255, 255, 0.01);
561        --wui-color-gray-glass-002: rgba(255, 255, 255, 0.02);
562        --wui-color-gray-glass-005: rgba(255, 255, 255, 0.05);
563        --wui-color-gray-glass-010: rgba(255, 255, 255, 0.1);
564        --wui-color-gray-glass-015: rgba(255, 255, 255, 0.15);
565        --wui-color-gray-glass-020: rgba(255, 255, 255, 0.2);
566        --wui-color-gray-glass-025: rgba(255, 255, 255, 0.25);
567        --wui-color-gray-glass-030: rgba(255, 255, 255, 0.3);
568        --wui-color-gray-glass-060: rgba(255, 255, 255, 0.6);
569        --wui-color-gray-glass-080: rgba(255, 255, 255, 0.8);
570        --wui-color-gray-glass-090: rgba(255, 255, 255, 0.9);
571
572        --wui-color-dark-glass-100: rgba(42, 42, 42, 1);
573
574        --wui-icon-box-bg-error-base-100: #3c2426;
575        --wui-icon-box-bg-blue-base-100: #20303f;
576        --wui-icon-box-bg-success-base-100: #1f3a28;
577        --wui-icon-box-bg-inverse-base-100: #243240;
578
579        --wui-all-wallets-bg-100: #222b35;
580
581        --wui-avatar-border-base: #252525;
582
583        --wui-thumbnail-border-base: #252525;
584
585        --wui-wallet-button-bg-base: var(--wui-color-bg-125);
586
587        --w3m-card-embedded-shadow-color: rgb(17 17 18 / 25%);
588      }
589    `,dark:s.iv`
590      :root {
591        --w3m-color-mix: ${(0,s.$m)(e?.["--w3m-color-mix"]||"#000")};
592        --w3m-accent: ${(0,s.$m)((0,i.t)(e,"light")["--w3m-accent"])};
593        --w3m-default: #000;
594
595        --wui-color-modal-bg-base: ${(0,s.$m)((0,i.t)(e,"light")["--w3m-background"])};
596        --wui-color-accent-base-100: var(--w3m-accent);
597
598        --wui-color-blueberry-100: hsla(231, 100%, 70%, 1);
599        --wui-color-blueberry-090: hsla(231, 97%, 72%, 1);
600        --wui-color-blueberry-080: hsla(231, 92%, 74%, 1);
601
602        --wui-color-fg-100: #141414;
603        --wui-color-fg-125: #2d3131;
604        --wui-color-fg-150: #474d4d;
605        --wui-color-fg-175: #636d6d;
606        --wui-color-fg-200: #798686;
607        --wui-color-fg-225: #828f8f;
608        --wui-color-fg-250: #8b9797;
609        --wui-color-fg-275: #95a0a0;
610        --wui-color-fg-300: #9ea9a9;
611        --wui-color-fg-325: #9a9a9a;
612        --wui-color-fg-350: #d0d0d0;
613
614        --wui-color-bg-100: #ffffff;
615        --wui-color-bg-125: #f5fafa;
616        --wui-color-bg-150: #f3f8f8;
617        --wui-color-bg-175: #eef4f4;
618        --wui-color-bg-200: #eaf1f1;
619        --wui-color-bg-225: #e5eded;
620        --wui-color-bg-250: #e1e9e9;
621        --wui-color-bg-275: #dce7e7;
622        --wui-color-bg-300: #d8e3e3;
623        --wui-color-bg-325: #f3f3f3;
624        --wui-color-bg-350: #202020;
625
626        --wui-color-success-base-100: #26b562;
627        --wui-color-success-base-125: #30a46b;
628
629        --wui-color-warning-base-100: #f3a13f;
630
631        --wui-color-error-base-100: #f05142;
632        --wui-color-error-base-125: #df4a34;
633
634        --wui-color-blue-base-100: rgba(102, 125, 255, 1);
635        --wui-color-blue-base-90: rgba(102, 125, 255, 0.9);
636
637        --wui-color-success-glass-001: rgba(38, 181, 98, 0.01);
638        --wui-color-success-glass-002: rgba(38, 181, 98, 0.02);
639        --wui-color-success-glass-005: rgba(38, 181, 98, 0.05);
640        --wui-color-success-glass-010: rgba(38, 181, 98, 0.1);
641        --wui-color-success-glass-015: rgba(38, 181, 98, 0.15);
642        --wui-color-success-glass-020: rgba(38, 181, 98, 0.2);
643        --wui-color-success-glass-025: rgba(38, 181, 98, 0.25);
644        --wui-color-success-glass-030: rgba(38, 181, 98, 0.3);
645        --wui-color-success-glass-060: rgba(38, 181, 98, 0.6);
646        --wui-color-success-glass-080: rgba(38, 181, 98, 0.8);
647
648        --wui-color-success-glass-reown-020: rgba(48, 164, 107, 0.2);
649
650        --wui-color-warning-glass-reown-020: rgba(243, 161, 63, 0.2);
651
652        --wui-color-error-glass-001: rgba(240, 81, 66, 0.01);
653        --wui-color-error-glass-002: rgba(240, 81, 66, 0.02);
654        --wui-color-error-glass-005: rgba(240, 81, 66, 0.05);
655        --wui-color-error-glass-010: rgba(240, 81, 66, 0.1);
656        --wui-color-error-glass-015: rgba(240, 81, 66, 0.15);
657        --wui-color-error-glass-020: rgba(240, 81, 66, 0.2);
658        --wui-color-error-glass-025: rgba(240, 81, 66, 0.25);
659        --wui-color-error-glass-030: rgba(240, 81, 66, 0.3);
660        --wui-color-error-glass-060: rgba(240, 81, 66, 0.6);
661        --wui-color-error-glass-080: rgba(240, 81, 66, 0.8);
662
663        --wui-color-error-glass-reown-020: rgba(223, 74, 52, 0.2);
664
665        --wui-icon-box-bg-error-base-100: #f4dfdd;
666        --wui-icon-box-bg-blue-base-100: #d9ecfb;
667        --wui-icon-box-bg-success-base-100: #daf0e4;
668        --wui-icon-box-bg-inverse-base-100: #dcecfc;
669
670        --wui-all-wallets-bg-100: #e8f1fa;
671
672        --wui-avatar-border-base: #f3f4f4;
673
674        --wui-thumbnail-border-base: #eaefef;
675
676        --wui-wallet-button-bg-base: var(--wui-color-bg-125);
677
678        --wui-color-gray-glass-001: rgba(0, 0, 0, 0.01);
679        --wui-color-gray-glass-002: rgba(0, 0, 0, 0.02);
680        --wui-color-gray-glass-005: rgba(0, 0, 0, 0.05);
681        --wui-color-gray-glass-010: rgba(0, 0, 0, 0.1);
682        --wui-color-gray-glass-015: rgba(0, 0, 0, 0.15);
683        --wui-color-gray-glass-020: rgba(0, 0, 0, 0.2);
684        --wui-color-gray-glass-025: rgba(0, 0, 0, 0.25);
685        --wui-color-gray-glass-030: rgba(0, 0, 0, 0.3);
686        --wui-color-gray-glass-060: rgba(0, 0, 0, 0.6);
687        --wui-color-gray-glass-080: rgba(0, 0, 0, 0.8);
688        --wui-color-gray-glass-090: rgba(0, 0, 0, 0.9);
689
690        --wui-color-dark-glass-100: rgba(233, 233, 233, 1);
691
692        --w3m-card-embedded-shadow-color: rgb(224 225 233 / 25%);
693      }
694    `}}const d=s.iv`
695  *,
696  *::after,
697  *::before,
698  :host {
699    margin: 0;
700    padding: 0;
701    box-sizing: border-box;
702    font-style: normal;
703    text-rendering: optimizeSpeed;
704    -webkit-font-smoothing: antialiased;
705    -moz-osx-font-smoothing: grayscale;
706    -webkit-tap-highlight-color: transparent;
707    font-family: var(--wui-font-family);
708    backface-visibility: hidden;
709  }
710`,p=s.iv`
711  button,
712  a {
713    cursor: pointer;
714    display: flex;
715    justify-content: center;
716    align-items: center;
717    position: relative;
718    transition:
719      color var(--wui-duration-lg) var(--wui-ease-out-power-1),
720      background-color var(--wui-duration-lg) var(--wui-ease-out-power-1),
721      border var(--wui-duration-lg) var(--wui-ease-out-power-1),
722      border-radius var(--wui-duration-lg) var(--wui-ease-out-power-1),
723      box-shadow var(--wui-duration-lg) var(--wui-ease-out-power-1);
724    will-change: background-color, color, border, box-shadow, border-radius;
725    outline: none;
726    border: none;
727    column-gap: var(--wui-spacing-3xs);
728    background-color: transparent;
729    text-decoration: none;
730  }
731
732  wui-flex {
733    transition: border-radius var(--wui-duration-lg) var(--wui-ease-out-power-1);
734    will-change: border-radius;
735  }
736
737  button:disabled > wui-wallet-image,
738  button:disabled > wui-all-wallets-image,
739  button:disabled > wui-network-image,
740  button:disabled > wui-image,
741  button:disabled > wui-transaction-visual,
742  button:disabled > wui-logo {
743    filter: grayscale(1);
744  }
745
746  @media (hover: hover) and (pointer: fine) {
747    button:hover:enabled {
748      background-color: var(--wui-color-gray-glass-005);
749    }
750
751    button:active:enabled {
752      background-color: var(--wui-color-gray-glass-010);
753    }
754  }
755
756  button:disabled > wui-icon-box {
757    opacity: 0.5;
758  }
759
760  input {
761    border: none;
762    outline: none;
763    appearance: none;
764  }
765`,g=s.iv`
766  .wui-color-inherit {
767    color: var(--wui-color-inherit);
768  }
769
770  .wui-color-accent-100 {
771    color: var(--wui-color-accent-100);
772  }
773
774  .wui-color-error-100 {
775    color: var(--wui-color-error-100);
776  }
777
778  .wui-color-blue-100 {
779    color: var(--wui-color-blue-100);
780  }
781
782  .wui-color-blue-90 {
783    color: var(--wui-color-blue-90);
784  }
785
786  .wui-color-error-125 {
787    color: var(--wui-color-error-125);
788  }
789
790  .wui-color-success-100 {
791    color: var(--wui-color-success-100);
792  }
793
794  .wui-color-success-125 {
795    color: var(--wui-color-success-125);
796  }
797
798  .wui-color-inverse-100 {
799    color: var(--wui-color-inverse-100);
800  }
801
802  .wui-color-inverse-000 {
803    color: var(--wui-color-inverse-000);
804  }
805
806  .wui-color-fg-100 {
807    color: var(--wui-color-fg-100);
808  }
809
810  .wui-color-fg-200 {
811    color: var(--wui-color-fg-200);
812  }
813
814  .wui-color-fg-300 {
815    color: var(--wui-color-fg-300);
816  }
817
818  .wui-color-fg-325 {
819    color: var(--wui-color-fg-325);
820  }
821
822  .wui-color-fg-350 {
823    color: var(--wui-color-fg-350);
824  }
825
826  .wui-bg-color-inherit {
827    background-color: var(--wui-color-inherit);
828  }
829
830  .wui-bg-color-blue-100 {
831    background-color: var(--wui-color-accent-100);
832  }
833
834  .wui-bg-color-error-100 {
835    background-color: var(--wui-color-error-100);
836  }
837
838  .wui-bg-color-error-125 {
839    background-color: var(--wui-color-error-125);
840  }
841
842  .wui-bg-color-success-100 {
843    background-color: var(--wui-color-success-100);
844  }
845
846  .wui-bg-color-success-125 {
847    background-color: var(--wui-color-success-100);
848  }
849
850  .wui-bg-color-inverse-100 {
851    background-color: var(--wui-color-inverse-100);
852  }
853
854  .wui-bg-color-inverse-000 {
855    background-color: var(--wui-color-inverse-000);
856  }
857
858  .wui-bg-color-fg-100 {
859    background-color: var(--wui-color-fg-100);
860  }
861
862  .wui-bg-color-fg-200 {
863    background-color: var(--wui-color-fg-200);
864  }
865
866  .wui-bg-color-fg-300 {
867    background-color: var(--wui-color-fg-300);
868  }
869
870  .wui-color-fg-325 {
871    background-color: var(--wui-color-fg-325);
872  }
873
874  .wui-color-fg-350 {
875    background-color: var(--wui-color-fg-350);
876  }
877`},1512:function(e,t,r){"use strict";r.d(t,{H:function(){return s}});const s={getSpacingStyles(e,t){return Array.isArray(e)?e[t]?`var(--wui-spacing-${e[t]})`:void 0:"string"==typeof e?`var(--wui-spacing-${e})`:void 0},getFormattedDate(e){return new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(e)},getHostName(e){try{return new URL(e).hostname}catch(e){return""}},getTruncateString({string:e,charsStart:t,charsEnd:r,truncate:s}){return e.length<=t+r?e:"end"===s?`${e.substring(0,t)}...`:"start"===s?`...${e.substring(e.length-r)}`:`${e.substring(0,Math.floor(t))}...${e.substring(e.length-Math.floor(r))}`},generateAvatarColors(e){const t=e.toLowerCase().replace(/^0x/iu,"").replace(/[^a-f0-9]/gu,"").substring(0,6).padEnd(6,"0"),r=this.hexToRgb(t),s=getComputedStyle(document.documentElement).getPropertyValue("--w3m-border-radius-master"),i=100-3*Number(s?.replace("px","")),n=`${i}% ${i}% at 65% 40%`,o=[];for(let e=0;e<5;e+=1){const t=this.tintColor(r,.15*e);o.push(`rgb(${t[0]}, ${t[1]}, ${t[2]})`)}return`\n    --local-color-1: ${o[0]};\n    --local-color-2: ${o[1]};\n    --local-color-3: ${o[2]};\n    --local-color-4: ${o[3]};\n    --local-color-5: ${o[4]};\n    --local-radial-circle: ${n}\n   `},hexToRgb(e){const t=parseInt(e,16);return[t>>16&255,t>>8&255,255&t]},tintColor(e,t){const[r,s,i]=e;return[Math.round(r+(255-r)*t),Math.round(s+(255-s)*t),Math.round(i+(255-i)*t)]},isNumber(e){return/^[0-9]+$/u.test(e)},getColorTheme(e){return e||("undefined"!=typeof window&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)")?.matches?"dar
877k":"light":"dark")},splitBalance(e){const t=e.split(".");return 2===t.length?[t[0],t[1]]:["0","00"]},roundNumber(e,t,r){return e.toString().length>=t?Number(e).toFixed(r):e},formatNumberToLocalString(e,t=2){return void 0===e?"0.00":"number"==typeof e?e.toLocaleString("en-US",{maximumFractionDigits:t,minimumFractionDigits:t}):parseFloat(e).toLocaleString("en-US",{maximumFractionDigits:t,minimumFractionDigits:t})}}},25729:function(e,t,r){"use strict";function s(e){return function(t){return"function"==typeof t?function(e,t){return customElements.get(e)||customElements.define(e,t),t}(e,t):function(e,t){const{kind:r,elements:s}=t;return{kind:r,elements:s,finisher(t){customElements.get(e)||customElements.define(e,t)}}}(e,t)}}r.d(t,{M:function(){return s}})},99013:function(e,t,r){"use strict";r.d(t,{b:function(){return s}});const s={METMASK_CONNECTOR_NAME:"MetaMask",TRUST_CONNECTOR_NAME:"Trust Wallet",SOLFLARE_CONNECTOR_NAME:"Solflare",PHANTOM_CONNECTOR_NAME:"Phantom",COIN98_CONNECTOR_NAME:"Coin98",MAGIC_EDEN_CONNECTOR_NAME:"Magic Eden",BACKPACK_CONNECTOR_NAME:"Backpack",BITGET_CONNECTOR_NAME:"Bitget Wallet",FRONTIER_CONNECTOR_NAME:"Frontier",XVERSE_CONNECTOR_NAME:"Xverse Wallet",LEATHER_CONNECTOR_NAME:"Leather",EIP155:"eip155",ADD_CHAIN_METHOD:"wallet_addEthereumChain",EIP6963_ANNOUNCE_EVENT:"eip6963:announceProvider",EIP6963_REQUEST_EVENT:"eip6963:requestProvider",CONNECTOR_RDNS_MAP:{coinbaseWallet:"com.coinbase.wallet",coinbaseWalletSDK:"com.coinbase.wallet"},CONNECTOR_TYPE_EXTERNAL:"EXTERNAL",CONNECTOR_TYPE_WALLET_CONNECT:"WALLET_CONNECT",CONNECTOR_TYPE_INJECTED:"INJECTED",CONNECTOR_TYPE_ANNOUNCED:"ANNOUNCED",CONNECTOR_TYPE_AUTH:"AUTH",CONNECTOR_TYPE_MULTI_CHAIN:"MULTI_CHAIN",CONNECTOR_TYPE_W3M_AUTH:"ID_AUTH"}},99436:function(e,t,r){"use strict";r.d(t,{g:function(){return i}});var s=r(99013);const i={getCaipTokens(e){if(!e)return;const t={};return Object.entries(e).forEach((([e,r])=>{t[`${s.b.EIP155}:${e}`]=r})),t},isLowerCaseMatch(e,t){return e?.toLowerCase()===t?.toLowerCase()}}},22192:function(e,t,r){"use strict";r.d(t,{y_:function(){return s}});r(34155);const s={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"}}},203:function(e,t,r){"use strict";r.d(t,{createAppKit:function(){return Te}});var s=r(9793),i=r(78859),n=r(83241),o=r(77500),a=r(14967),c=r(68314);const l={validateCaipAddress(e){if(3!==e.split(":")?.length)throw new Error("Invalid CAIP Address");return e},parseCaipAddress(e){const t=e.split(":");if(3!==t.length)throw new Error(`Invalid CAIP-10 address: ${e}`);const[r,s,i]=t;if(!r||!s||!i)throw new Error(`Invalid CAIP-10 address: ${e}`);return{chainNamespace:r,chainId:s,address:i}},parseCaipNetworkId(e){const t=e.split(":");if(2!==t.length)throw new Error(`Invalid CAIP-2 network id: ${e}`);const[r,s]=t;if(!r||!s)throw new Error(`Invalid CAIP-2 network id: ${e}`);return{chainNamespace:r,chainId:s}}};var h=r(27777),u=r(59757),d=r(66691),p=r(83966),g=r(64125),f=r(44098),m=r(87178);const w=2147483648,y={convertEVMChainIdToCoinType(e){if(e>=w)throw new Error("Invalid chainId");return(w|e)>>>0}};var b=r(68343),v=r(4511);const C=(0,f.sj)({suggestions:[],loading:!1}),E={state:C,subscribe(e){return(0,f.Ld)(C,(()=>e(C)))},subscribeKey(e,t){return(0,m.VW)(C,e,t)},async resolveName(e){try{return await d.L.lookupEnsName(e)}catch(e){throw new Error(e?.reasons?.[0]?.description||"Error resolving name")}},async isNameRegistered(e){try{return await d.L.lookupEnsName(e),!0}catch{return!1}},async getSuggestions(e){try{C.loading=!0,C.suggestions=[];const t=await d.L.getEnsNameSuggestions(e);return C.suggestions=t.suggestions.map((e=>({...e,name:e.name})))||[],C.suggestions}catch(e){const t=N.parseEnsApiError(e,"Error fetching name suggestions");throw new Error(t)}finally{C.loading=!1}},async getNamesForAddress(e){try{if(!u.R.state.activeCaipNetwork)return[];
877const t=g.M.getEnsFromCacheForAddress(e);if(t)return t;const r=await d.L.reverseLookupEnsName({address:e});return g.M.updateEnsCache({address:e,ens:r,timestamp:Date.now()}),r}catch(e){const t=N.parseEnsApiError(e,"Error fetching names for address");throw new Error(t)}},async registerName(e){const t=u.R.state.activeCaipNetwork;if(!t)throw new Error("Network not found");const r=p.N.state.address,n=s.ConnectorController.getAuthConnector();if(!r||!n)throw new Error("Address or auth connector not found");C.loading=!0;try{const s=JSON.stringify({name:e,attributes:{},timestamp:Math.floor(Date.now()/1e3)});v.RouterController.pushTransactionStack({onCancel(){v.RouterController.replace("RegisterAccountName")}});const n=await i.ConnectionController.signMessage(s);C.loading=!1;const o=t.id;if(!o)throw new Error("Network not found");const a=y.convertEVMChainIdToCoinType(Number(o));await d.L.registerEnsName({coinType:a,address:r,signature:n,message:s}),p.N.setProfileName(e,t.chainNamespace),v.RouterController.replace("RegisterAccountNameSuccess")}catch(t){const r=N.parseEnsApiError(t,`Error registering name ${e}`);throw v.RouterController.replace("RegisterAccountName"),new Error(r)}finally{C.loading=!1}},validateName(e){return/^[a-zA-Z0-9-]{4,}$/u.test(e)},parseEnsApiError(e,t){return e?.reasons?.[0]?.description||t}},N=(0,b.P)(E);var I=r(44639),A=r(47205),S=r(48113);const _={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"}]},O={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},P={providers:A.gy,selectedProvider:null,error:null,purchaseCurrency:_,paymentCurrency:O,purchaseCurrencies:[_],paymentCurrencies:[],quotesLoading:!1},T=(0,f.sj)(P),k={state:T,subscribe(e){return(0,f.Ld)(T,(()=>e(T)))},subscribeKey(e,t){return(0,m.VW)(T,e,t)},setSelectedProvider(e){if(e&&"meld"===e.name){const t=u.R.state.activeChain===c.b.CHAIN.SOLANA?"SOL":"USDC",r=p.N.state.address??"",s=new URL(e.url);s.searchParams.append("publicKey",A.a$),s.searchParams.append("destinationCurrencyCode",t),s.searchParams.append("walletAddress",r),s.searchParams.append("externalCustomerId",o.OptionsController.state.projectId),T.selectedProvider={...e,url:s.toString()}}else T.selectedProvider=e},setOnrampProviders(e){if(Array.isArray(e)&&e.every((e=>"string"==typeof e))){const t=e,r=A.gy.filter((e=>t.includes(e.name)));T.providers=r}else T.providers=[]},setPurchaseCurrency(e){T.purchaseCurrency=e},setPaymentCurrency(e){T.paymentCurrency=e},setPurchaseAmount(e){R.state.purchaseAmount=e},setPaymentAmount(e){R.state.paymentAmount=e},async getAvailableCurrencies(){const e=await d.L.getOnrampOptions();T.purchaseCurrencies=e.purchaseCurrencies,T.paymentCurrencies=e.paymentCurrencies,T.paymentCurrency=e.paymentCurrencies[0]||O,T.purchaseCurrency=e.purchaseCurrencies[0]||_,await S.ApiController.fetchCurrencyImages(e.paymentCurrencies.map((e=>e.id))),await S.ApiController.fetchTokenImages(e.purchaseCurrencies.map((e=>e.symbol)))},async getQuote(){T.quotesLoading=!0;try{const e=await d.L.getOnrampQuote({purchaseCurrency:T.purchaseCurrency,paymentCurrency:T.paymentCurrency,amount:T.paymentAmount?.toString()||"0",network:T.purchaseCurrency?.symbol});return T.quotesLoading=!1,T.purchaseAmount=Number(e?.purchaseAmount.amount),e}catch(e){return T.error=e.message,T.quotesLoading=!1,null}finally{T.quotesLoading=!1}},resetState(){T.selectedProvider=null,T.error=null,T.purchaseCurrency=_,T.paymentCurrency=O,T.purchaseCurrencies=[_],T.paymentCurrencies=[],T.paymentAmount=void 0,T.purchaseAmount=void 0,T.quotesLoading=!1}},R=(0,b.P)(k);var x=r(56008),U=r(51440),D=r(12858),$=r(57244),M=r(72579),L=r(48121),j=r(31249),B=r(82879);function q(e,t){return s.ConnectorController.getConnectorId(e)===t}r(11697),r(72134);var W=r(32786),F=r(80446);const H={EmbeddedWalletAbortController:new AbortController,UniversalProviderErrors:{UNAUTHORIZED_DOMAIN_NOT_ALLOWED:{message:"Unauthorized: origin not allowed",alertErrorKey:"INVALID_APP_CONFIGURATION"},JWT_VALIDATION_ERROR:{message:"JWT validation error: JWT Token is not yet valid",alertErrorKey:"JWT_TOKEN_NOT_VALID"}
877,INVALID_KEY:{message:"Unauthorized: invalid key",alertErrorKey:"INVALID_PROJECT_ID"}},ALERT_ERRORS:{SWITCH_NETWORK_NOT_FOUND:{shortMessage:"Network Not Found",longMessage:"Network not found - please make sure it is included in 'networks' array in createAppKit function"},INVALID_APP_CONFIGURATION:{shortMessage:"Invalid App Configuration",longMessage:()=>`Origin ${"undefined"!=typeof window?window.origin:"unknown"} not found on Allowlist - update configuration on cloud.reown.com`},IFRAME_LOAD_FAILED:{shortMessage:"Network Error - Could not load embedded wallet",longMessage:()=>"There was an issue loading the embedded wallet. Please try again later."},IFRAME_REQUEST_TIMEOUT:{shortMessage:"Embedded Wallet Request Timed Out",longMessage:()=>"There was an issue doing the request to the embedded wallet. Please try again later."},UNVERIFIED_DOMAIN:{shortMessage:"Invalid App Configuration",longMessage:()=>"There was an issue loading the embedded wallet. Please verify that your domain is allowed at cloud.reown.com"},JWT_TOKEN_NOT_VALID:{shortMessage:"Session Expired",longMessage:"Invalid session found on UniversalProvider - please check your time settings and connect again"},INVALID_PROJECT_ID:{shortMessage:"Invalid App Configuration",longMessage:"Invalid Project ID - update configuration"},PROJECT_ID_NOT_CONFIGURED:{shortMessage:"Project ID Not Configured",longMessage:"Project ID Not Configured - update configuration on cloud.reown.com"}}};var z=r(68597),V=r(26445),K=r(39028),J=r(62914),G=r(22319);function Y(e,t={}){const{key:r="fallback",name:s="Fallback",rank:i=!1,shouldThrow:n=X,retryCount:o,retryDelay:a}=t;return({chain:t,pollingInterval:c=4e3,timeout:l,...h})=>{let u=e,d=()=>{};const p=(0,G.q)({key:r,name:s,async request({method:e,params:r}){let s;const i=async(o=0)=>{const a=u[o]({...h,chain:t,retryCount:0,timeout:l});try{const t=await a.request({method:e,params:r});return d({method:e,params:r,response:t,transport:a,status:"success"}),t}catch(c){if(d({error:c,method:e,params:r,transport:a,status:"error"}),n(c))throw c;if(o===u.length-1)throw c;if(s??=u.slice(o+1).some((r=>{const{include:s,exclude:i}=r({chain:t}).config.methods||{};return s?s.includes(e):!i||!i.includes(e)})),!s)throw c;return i(o+1)}};return i()},retryCount:o,retryDelay:a,type:"fallback"},{onResponse:e=>d=e,transports:u.map((e=>e({chain:t,retryCount:0})))});if(i){const e="object"==typeof i?i:{};!function({chain:e,interval:t=4e3,onTransports:r,ping:s,sampleCount:i=10,timeout:n=1e3,transports:o,weights:a={}}){const{stability:c=.7,latency:l=.3}=a,h=[],u=async()=>{const a=await Promise.all(o.map((async t=>{const r=t({chain:e,retryCount:0,timeout:n}),i=Date.now();let o,a;try{await(s?s({transport:r}):r.request({method:"net_listening"})),a=1}catch{a=0}finally{o=Date.now()}return{latency:o-i,success:a}})));h.push(a),h.length>i&&h.shift();const d=Math.max(...h.map((e=>Math.max(...e.map((({latency:e})=>e)))))),p=o.map(((e,t)=>{const r=h.map((e=>e[t].latency)),s=1-r.reduce(((e,t)=>e+t),0)/r.length/d,i=h.map((e=>e[t].success)),n=i.reduce(((e,t)=>e+t),0)/i.length;return 0===n?[0,t]:[l*s+c*n,t]})).sort(((e,t)=>t[0]-e[0]));r(p.map((([,e])=>o[e]))),await(0,J.D)(t),u()};u()}({chain:t,interval:e.interval??c,onTransports:e=>u=e,ping:e.ping,sampleCount:e.sampleCount,timeout:e.timeout,transports:u,weights:e.weights})}return p}}function X(e){return!(!("code"in e)||"number"!=typeof e.code||e.code!==K.KB.code&&e.code!==K.ab.code&&!V.M_.nodeMessage.test(e.message)&&5e3!==e.code)}var Z=r(99013);const Q={ConnectorExplorerIds:{[c.b.CONNECTOR_ID.COINBASE]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[c.b.CONNECTOR_ID.COINBASE_SDK]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[c.b.CONNECTOR_ID.SAFE]:"225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",[c.b.CONNECTOR_ID.LEDGER]:"19177a98252e07ddfc9af2083ba8e07ef627cb6103467ffebb3f8f4205fd7927",[c.b.CONNECTOR_ID.OKX]:"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709",[Z.b.METMASK_CONNECTOR_NAME]:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",[Z.b.TRUST_CONNECTOR_NAME]:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",[Z.b.SOLFLARE_CONNECTOR_NAME]:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",[Z.b.PHANTOM_CONNECTOR_NAME]:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",[Z.b.COIN98_CONNECTOR_NAME]:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",[Z.b.MAGIC_EDEN_CONNECTOR_NAME]:"8b830a2b724a9c3fbab63af6f55ed29c9dfa8a55e732dc88c80a196a2ba136c6",[Z.b.BACKPACK_CONNECTOR_NAME]:"2bd8c14e035c2d48f184aaa168559e86b0e3433228d3c4075900a221785019b0",[Z.b.BITGET_CONNECTOR_NAME]:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",[Z.b.FRONTIER_CONNECTOR_NAME]:"85db431492aa2e8672e93f4ea7acf10c88b97b867b0d373107af63dc4880f041",[Z.b.XVERSE_CONNECTOR_NAME]:"2a87d74ae02e10bdd1f51f7ce6c4e1cc53cd5f2c0b6b5ad0d7b300
8777d2b13de7b",[Z.b.LEATHER_CONNECTOR_NAME]:"483afe1df1df63daf313109971ff3ef8356ddf1cc4e45877d205eee0b7893a13"},NetworkImageIds:{1:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",42161:"3bff954d-5cb0-47a0-9a23-d20192e74600",43114:"30c46e53-e989-45fb-4549-be3bd4eb3b00",56:"93564157-2e8e-4ce7-81df-b264dbee9b00",250:"06b26297-fe0c-4733-5d6b-ffa5498aac00",10:"ab9c186a-c52f-464b-2906-ca59d760a400",137:"41d04d42-da3b-4453-8506-668cc0727900",5e3:"e86fae9b-b770-4eea-e520-150e12c81100",295:"6a97d510-cac8-4e58-c7ce-e8681b044c00",11155111:"e909ea0a-f92a-4512-c8fc-748044ea6800",84532:"a18a7ecd-e307-4360-4746-283182228e00",1301:"4eeea7ef-0014-4649-5d1d-07271a80f600",130:"2257980a-3463-48c6-cbac-a42d2a956e00",10143:"0a728e83-bacb-46db-7844-948f05434900",100:"02b53f6a-e3d4-479e-1cb4-21178987d100",9001:"f926ff41-260d-4028-635e-91913fc28e00",324:"b310f07f-4ef7-49f3-7073-2a0a39685800",314:"5a73b3dd-af74-424e-cae0-0de859ee9400",4689:"34e68754-e536-40da-c153-6ef2e7188a00",1088:"3897a66d-40b9-4833-162f-a2c90531c900",1284:"161038da-44ae-4ec7-1208-0ea569454b00",1285:"f1d73bb6-5450-4e18-38f7-fb6484264a00",7777777:"845c60df-d429-4991-e687-91ae45791600",42220:"ab781bbc-ccc6-418d-d32d-789b15da1f00",8453:"7289c336-3981-4081-c5f4-efc26ac64a00",1313161554:"3ff73439-a619-4894-9262-4470c773a100",2020:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",2021:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",80094:"e329c2c9-59b0-4a02-83e4-212ff3779900",2741:"fc2427d1-5af9-4a9c-8da5-6f94627cd900","5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp":"a1b58899-f671-4276-6a5e-56ca5bd59700","4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z":"a1b58899-f671-4276-6a5e-56ca5bd59700",EtWTRABZaYq6iMfeYKouRu166VU2xqa1:"a1b58899-f671-4276-6a5e-56ca5bd59700","000000000019d6689c085ae165831e93":"0b4838db-0161-4ffe-022d-532bf03dba00","000000000933ea01ad0ee984209779ba":"39354064-d79b-420b-065d-f980c4b78200"},ConnectorImageIds:{[c.b.CONNECTOR_ID.COINBASE]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[c.b.CONNECTOR_ID.COINBASE_SDK]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[c.b.CONNECTOR_ID.SAFE]:"461db637-8616-43ce-035a-d89b8a1d5800",[c.b.CONNECTOR_ID.LEDGER]:"54a1aa77-d202-4f8d-0fb2-5d2bb6db0300",[c.b.CONNECTOR_ID.WALLET_CONNECT]:"ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400",[c.b.CONNECTOR_ID.INJECTED]:"07ba87ed-43aa-4adf-4540-9e6a2b9cae00"},ConnectorNamesMap:{[c.b.CONNECTOR_ID.INJECTED]:"Browser Wallet",[c.b.CONNECTOR_ID.WALLET_CONNECT]:"WalletConnect",[c.b.CONNECTOR_ID.COINBASE]:"Coinbase",[c.b.CONNECTOR_ID.COINBASE_SDK]:"Coinbase",[c.b.CONNECTOR_ID.LEDGER]:"Ledger",[c.b.CONNECTOR_ID.SAFE]:"Safe"},ConnectorTypesMap:{[c.b.CONNECTOR_ID.INJECTED]:"INJECTED",[c.b.CONNECTOR_ID.WALLET_CONNECT]:"WALLET_CONNECT",[c.b.CONNECTOR_ID.EIP6963]:"ANNOUNCED",[c.b.CONNECTOR_ID.AUTH]:"AUTH"},WalletConnectRpcChainIds:[1,5,11155111,10,420,42161,421613,137,80001,42220,1313161554,1313161555,56,97,43114,43113,100,8453,84531,7777777,999,324,280]};function ee(e,t){const r=new URL("https://rpc.walletconnect.org/v1/");return r.searchParams.set("chainId",e),r.searchParams.set("projectId",t),r.toString()}const te=["near:mainnet","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp","eip155:1101","eip155:56","eip155:42161","eip155:7777777","eip155:59144","eip155:324","solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1","eip155:5000","solana:4sgjmw1sunhzsxgspuhpqldx6wiyjntz","eip155:80084","eip155:5003","eip155:100","eip155:8453","eip155:42220","eip155:1313161555","eip155:17000","eip155:1","eip155:300","eip155:1313161554","eip155:1329","eip155:84532","eip155:421614","eip155:11155111","eip155:8217","eip155:43114","solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z","eip155:999999999","eip155:11155420","eip155:80002","eip155:97","eip155:43113","eip155:137","eip155:10","eip155:1301","bip122:000000000019d6689c085ae165831e93","bip122:000000000933ea01ad0ee984209779ba"],re={extendRpcUrlWithProjectId(e,t){let r=!1;try{r="rpc.walletconnect.org"===new URL(e).host}catch(e){r=!1}if(r){const r=new URL(e);return r.searchParams.has("projectId")||r.searchParams.set("projectId",t),r.toString()}return e},isCaipNetwork(e){return"chainNamespace"in e&&"caipNetworkId"in e},getChainNamespace(e){return this.isCaipNetwork(e)?e.chainNamespace:c.b.CHAIN.EVM},getCaipNetworkId(e){return this.isCaipNetwork(e)?e.caipNetworkId:`${c.b.CHAIN.EVM}:${e.id}`},getDefaultRpcUrl(e,t,r){const s=e.rpcUrls?.default?.http?.[0];return te.includes(t)?ee(t,r):s||""},extendCaipNetwork(e,{customNetworkImageUrls:t,projectId:r,customRpcUrls:s}){const i=this.getChainNamespace(e),n=this.getCaipNetworkId(e),o=e.rpcUrls.default.http?.[0],a=this.getDefaultRpcUrl(e,n,r),c=e?.rpcUrls?.chainDefault?.http?.[0]||o,l=s?.[n]?.map((e=>e.url))||[],h=[...l,a],u=[...l];return c&&!u.includes(c)&&u.push(c),{...e,chainNamespace:i,caipNetworkId:n,assets:{imageId:Q.NetworkImageIds[e.id],imageUrl:t?.[e.id]},rpcUrls:{...e.rpcUrls,default:{http:h},chainDefault:{http:u}}}},extendCaipNetworks(e,{customNetworkImageUrls:t,projectId:r,customRpcUrls:s}){return e.map((e=>re.extendCaipNetwork(e,{customNetworkImageUrls:t,customRpcUrls:s,projectId:r})))}
877,getViemTransport(e,t,r){const s=[];return r?.forEach((e=>{s.push((0,z.d)(e.url,e.config))})),te.includes(e.caipNetworkId)&&s.push((0,z.d)(ee(e.caipNetworkId,t),{fetchOptions:{headers:{"Content-Type":"text/plain"}}})),e?.rpcUrls?.default?.http?.forEach((e=>{s.push((0,z.d)(e))})),Y(s)},extendWagmiTransports(e,t,r){if(te.includes(e.caipNetworkId)){const s=this.getDefaultRpcUrl(e,e.caipNetworkId,t);return Y([r,(0,z.d)(s)])}return r},getUnsupportedNetwork(e){return{id:e.split(":")[1],caipNetworkId:e,name:c.b.UNSUPPORTED_NETWORK_NAME,chainNamespace:e.split(":")[0],nativeCurrency:{name:"",decimals:0,symbol:""},rpcUrls:{default:{http:[]}}}},getCaipNetworkFromStorage(e){const t=g.M.getActiveCaipNetworkId(),r=u.R.getAllRequestedCaipNetworks(),s=Array.from(u.R.state.chains?.keys()||[]),i=t?.split(":")[0],n=!!i&&s.includes(i),o=r?.find((e=>e.caipNetworkId===t));return n&&!o&&t?this.getUnsupportedNetwork(t):o||(e||r?.[0])}};var se=r(99436),ie=r(91011);const ne={createLogger(e,t="error"){const r=(0,ie.jI)({level:t}),{logger:s}=(0,ie.Rt)({opts:r});return s.error=(...t)=>{for(const r of t)if(r instanceof Error)return void e(r,...t);e(void 0,...t)},s}},oe={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0,cosmos:void 0},ae=(0,f.sj)({providers:{...oe},providerIds:{...oe}}),ce={state:ae,subscribeKey(e,t){return(0,m.VW)(ae,e,t)},subscribe(e){return(0,f.Ld)(ae,(()=>{e(ae)}))},subscribeProviders(e){return(0,f.Ld)(ae.providers,(()=>e(ae.providers)))},setProvider(e,t){t&&(ae.providers[e]=(0,f.iH)(t))},getProvider(e){return ae.providers[e]},setProviderId(e,t){t&&(ae.providerIds[e]=t)},getProviderId(e){if(e)return ae.providerIds[e]},reset(){ae.providers={...oe},ae.providerIds={...oe}},resetChain(e){ae.providers[e]=void 0,ae.providerIds[e]=void 0}};var le=r(39578),he=r(92106);const ue=4902,de=5e3,pe=32603,ge=["http://localhost:*","https://*.pages.dev","https://*.vercel.app","https://*.ngrok-free.app","https://secure-mobile.walletconnect.com","https://secure-mobile.walletconnect.org"];function fe(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}const me=fe({id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!1,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",deprecatedCaipNetworkId:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ"}),we=fe({id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",deprecatedCaipNetworkId:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"}),ye=(fe({id:"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",name:"Solana Testnet",network:"solana-testnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"}),fe({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}}),fe({id:"000000000933ea01ad0ee984209779ba",caipNetworkId:"bip122:000000000933ea01ad0ee984209779ba",chainNamespace:"bip122",name:"Bitcoin Testnet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},testnet:!0}),{solana:["solana_signMessage","solana_signTransaction","solana_requestAccounts","solana_getAccounts","solana_signAllTransactions","solana_signAndSendTransaction"],eip155:["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_showCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"],bip122:["sendTransfer","signMessage","signPsbt","getAccountAddresses"]}),be={getMethodsByChainNamespace(e){return ye[e]||[]},createDefaultNamespace(e){return{methods:this.getMethodsByChainNamespace(e),events:["accountsChanged","chainChanged"],chains:[],rpcMap:{}}},applyNamespaceOverrides(e,t){if(!t)return{...e};const r={...e},s=new Set;
877if(t.methods&&Object.keys(t.methods).forEach((e=>s.add(e))),t.chains&&Object.keys(t.chains).forEach((e=>s.add(e))),t.events&&Object.keys(t.events).forEach((e=>s.add(e))),t.rpcMap&&Object.keys(t.rpcMap).forEach((e=>{const[t]=e.split(":");t&&s.add(t)})),s.forEach((e=>{r[e]||(r[e]=this.createDefaultNamespace(e))})),t.methods&&Object.entries(t.methods).forEach((([e,t])=>{r[e]&&(r[e].methods=t)})),t.chains&&Object.entries(t.chains).forEach((([e,t])=>{r[e]&&(r[e].chains=t)})),t.events&&Object.entries(t.events).forEach((([e,t])=>{r[e]&&(r[e].events=t)})),t.rpcMap){const e=new Set;Object.entries(t.rpcMap).forEach((([t,s])=>{const[i,n]=t.split(":");i&&n&&r[i]&&(r[i].rpcMap||(r[i].rpcMap={}),e.has(i)||(r[i].rpcMap={},e.add(i)),r[i].rpcMap[n]=s)}))}return r},createNamespaces(e,t){const r=e.reduce(((e,t)=>{const{id:r,chainNamespace:s,rpcUrls:i}=t,n=i.default.http[0];e[s]||(e[s]=this.createDefaultNamespace(s));const o=`${s}:${r}`,a=e[s];switch(a.chains.push(o),o){case me.caipNetworkId:a.chains.push(me.deprecatedCaipNetworkId);break;case we.caipNetworkId:a.chains.push(we.deprecatedCaipNetworkId)}return a?.rpcMap&&n&&(a.rpcMap[r]=n),e}),{});return this.applyNamespaceOverrides(r,t)},resolveReownName:async e=>{const t=await N.resolveName(e);return(Object.values(t?.addresses)||[])[0]?.address||!1},getChainsFromNamespaces(e={}){return Object.values(e).flatMap((e=>{const t=e.chains||[],r=e.accounts.map((e=>{const[t,r]=e.split(":");return`${t}:${r}`}));return Array.from(new Set([...t,...r]))}))},isSessionEventData(e){return"object"==typeof e&&null!==e&&"id"in e&&"topic"in e&&"params"in e&&"object"==typeof e.params&&null!==e.params&&"chainId"in e.params&&"event"in e.params&&"object"==typeof e.params.event&&null!==e.params.event},isOriginAllowed(e,t,r){for(const s of[...t,...r])if(s.includes("*")){const t=`^${s.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&").replace(/\\\*/gu,".*")}$`;if(new RegExp(t,"u").test(e))return!0}else try{if(new URL(s).origin===e)return!0}catch(t){if(s===e)return!0}return!1}};class ve{constructor({provider:e,namespace:t}){this.id=c.b.CONNECTOR_ID.WALLET_CONNECT,this.name=Q.ConnectorNamesMap[c.b.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=Q.ConnectorImageIds[c.b.CONNECTOR_ID.WALLET_CONNECT],this.getCaipNetworks=u.R.getCaipNetworks.bind(u.R),this.caipNetworks=this.getCaipNetworks(),this.provider=e,this.chain=t}get chains(){return this.getCaipNetworks()}async connectWalletConnect(){if(!await this.authenticate()){const e=this.getCaipNetworks(),t=o.OptionsController.state.universalProviderConfigOverride,r=be.createNamespaces(e,t);await this.provider.connect({optionalNamespaces:r})}return{clientId:await this.provider.client.core.crypto.getClientId(),session:this.provider.session}}async disconnect(){await this.provider.disconnect()}async authenticate(){const e=this.chains.map((e=>e.caipNetworkId));return M.w.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:Ce})}}const Ce=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"];class Ee{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,this.getCaipNetworks=e=>u.R.getCaipNetworks(e),e&&this.construct(e)}construct(e){this.projectId=e.projectId,this.namespace=e.namespace,this.adapterType=e.adapterType}get connectors(){return this.availableConnectors}get networks(){return this.getCaipNetworks(this.namespace)}setAuthProvider(e){this.addConnector({id:c.b.CONNECTOR_ID.AUTH,type:"AUTH",name:c.b.CONNECTOR_NAMES.AUTH,provider:e,imageId:Q.ConnectorImageIds[c.b.CONNECTOR_ID.AUTH],chain:this.namespace,chains:[]})}addConnector(...e){const t=new Set;this.availableConnectors=[...e,...this.availableConnectors].filter((e=>
877!t.has(e.id)&&(t.add(e.id),!0))),this.emit("connectors",this.availableConnectors)}setStatus(e,t){p.N.setStatus(e,t)}on(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e)?.add(t)}off(e,t){const r=this.eventListeners.get(e);r&&r.delete(t)}removeAllEventListeners(){this.eventListeners.forEach((e=>{e.clear()}))}emit(e,t){const r=this.eventListeners.get(e);r&&r.forEach((e=>e(t)))}async connectWalletConnect(e){const t=this.getWalletConnectConnector();return{clientId:(await t.connectWalletConnect()).clientId}}async switchNetwork(e){const{caipNetwork:t,providerType:r}=e;if(!e.provider)return;const s="provider"in e.provider?e.provider.provider:e.provider;if("WALLET_CONNECT"!==r){if(s&&"AUTH"===r){const e=s,r=p.N.state.preferredAccountTypes?.[t.chainNamespace];await e.switchNetwork(t.caipNetworkId);const i=await e.getUser({chainId:t.caipNetworkId,preferredAccountType:r});this.emit("switchNetwork",i)}}else s.setDefaultChain(t.caipNetworkId)}getWalletConnectConnector(){const e=this.connectors.find((e=>e instanceof ve));if(!e)throw new Error("WalletConnectConnector not found");return e}}class Ne extends Ee{setUniversalProvider(e){this.addConnector(new ve({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace}))}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{const e=this.getWalletConnectConnector();await e.disconnect()}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}}async getAccounts({namespace:e}){const t=this.provider?.session?.namespaces?.[e]?.accounts?.map((e=>{const[,,t]=e.split(":");return t})).filter(((e,t,r)=>r.indexOf(e)===t))||[];return Promise.resolve({accounts:t.map((t=>n.j.createAccount(e,t,"bip122"===e?"payment":"eoa")))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){if(!(e.caipNetwork&&A.bq.BALANCE_SUPPORTED_CHAINS.includes(e.caipNetwork?.chainNamespace))||e.caipNetwork?.testnet)return{balance:"0.00",symbol:e.caipNetwork?.nativeCurrency.symbol||""};if(p.N.state.balanceLoading&&e.chainId===u.R.state.activeCaipNetwork?.id)return{balance:p.N.state.balance||"0.00",symbol:p.N.state.balanceSymbol||""};const t=(await p.N.fetchTokenBalance()).find((t=>t.chainId===`${e.caipNetwork?.chainNamespace}:${e.chainId}`&&t.symbol===e.caipNetwork?.nativeCurrency.symbol));return{balance:t?.quantity.numeric||"0.00",symbol:t?.symbol||e.caipNetwork?.nativeCurrency.symbol||""}}async signMessage(e){const{provider:t,message:r,address:s}=e;if(!t)throw new Error("UniversalAdapter:signMessage - provider is undefined");let i="";if(u.R.state.activeCaipNetwork?.chainNamespace===c.b.CHAIN.SOLANA){i=(await t.request({method:"solana_signMessage",params:{message:le.Z.encode((new TextEncoder).encode(r)),pubkey:s}},u.R.state.activeCaipNetwork?.caipNetworkId)).signature}else i=await t.request({method:"personal_sign",params:[r,s]},u.R.state.activeCaipNetwork?.caipNetworkId);return{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:""})}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){const{caipNetwork:t}=e,r=this.getWalletConnectConnector();if(t.chainNamespace===c.b.CHAIN.EVM)try{await(r.provider?.request({method:"wallet_switchEthereumChain",params:[{chainId:(0,he.NC)(t.id)}]}))}catch(e){if(e.code===ue||e.code===pe||e.code===de||e?.data?.originalError?.code===ue)try{await(r.provider?.request({method:"wallet_addEthereumChain",params:[{chainId:(0,he.NC)(t.id),rpcUrls:[t?.rpcUrls.chainDefault?.http],chainName:t.name,nativeCurrency:t.nativeCurrency,blockExplorerUrls:[t.blockExplorers?.default.url]}]}))}catch(e){throw new Error("Chain is not supported")}}r.provider.setDefaultChain(t.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find((e=>"WALLET_CONNECT"===e.type))?.provider;return e}}const Ie=["email","socials","swaps","onramp","activity","reownBranding"],Ae={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:e=>{if(!e?.config)return!1;const t=e.config;return Boolean(e.isEnabled)&&t.includes("email")},processFallback:e=>void 0===e?A.bq.DEFAULT_REMOTE_FEATURES.email:Boolean(e)},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:e=>{if(!e?.config)return!1;const t=e.config;return!!(Boolean(e.isEnabled)&&t.length>0)&&t.filter((e=>"email"!==e))},processFallback:e=>void 0===e?A.bq.DEFAULT_REMOTE_FEATURES.socials:"boolean"==typeof e?!!e&&A.bq.DEFAULT_REMOTE_FEATURES.socials:e},swaps:{apiFeatureName:"swap",localFeatureName:"swaps",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:e=>{if(!e?.config)return!1;const t=e.config;return!!(Boolean(e.isEnabled)&&t.length>0)&&t},processFallback:e=>void 0===e?A.bq.DEFAULT_REMOTE_FEATURES.swaps:"boolean"==typeof e?!!e&&A.bq.DEFAULT_REMOTE_FEATURES.swaps:e},onramp:{apiFeatureName:"onramp",localFeatureName:"onramp",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:e=>{if(!e?.config)return!1;const t=e.config;return!!(Boolean(e.isEnabled)&&t.length>0)&&t},processFallback:e=>void 0===e?A.bq.DEFAULT_REMOTE_FEATURES.onramp:"boolean"==typeof e?!!e&&A.bq.DEFAULT_REMOTE_FEATURES.onramp:e},activity:{apiFeatureName:"activity",localFeatureName:"history",returnType:!1,isLegacy:!0,isAvailableOnBasic:!1,processApi:e=>Boolean(e.isEnabled),processFallback:e=>void 0===e?A.bq.DEFAULT_REMOTE_FEATURES.activity:Boolean(e)},reownBranding:{apiFeatureName:"reown_branding",localFeatureName:"reownBranding",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:e=>Boolean(e.isEnabled),processFallback:e=>void 0===e?A.bq.DEFAULT_REMOTE_FEATURES.reownBranding:Boolean(e)}},Se={localSettingsOverridden:new Set,getApiConfig(e,t){return t?.find((t=>t.id===e))},addWarning(e,t){if(void 0!==e){const e=Ae[t],r=e.isLegacy?`"features.${e.localFeatureName}" (now "${t}")`:`"features.${t}"`;this.localSettingsOverridden.add(r)}},processFeature(e,t,r,s,i){const n=Ae[e],o=t[n.localFeatureName];if(i&&!n.isAvailableOnBasic)return!1;if(s){const t=this.getApiConfig(n.apiFeatureName,r);return null===t?.config?this.processFallbackFeature(e,o):!!t?.config&&(void 0!==o&&this.addWarning(o,e),this.processApiFeature(e,t))}return this.processFallbackFeature(e,o)},processApiFeature(e,t){return Ae[e].processApi(t)},processFallbackFeature(e,t){return Ae[e].processFallback(t)},async fetchRemoteFeatures(e){const t=e.basic??!1,r=e.features||{};this.localSettingsOverridden.clear();let s=null,i=!1;
877try{s=await S.ApiController.fetchProjectConfig(),i=null!=s}catch(e){console.warn("[Reown Config] Failed to fetch remote project configuration. Using local/default values.",e)}const n=i&&!t?A.bq.DEFAULT_REMOTE_FEATURES:A.bq.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const e of Ie){const o=this.processFeature(e,r,s,i,t);Object.assign(n,{[e]:o})}}catch(e){return console.warn("[Reown Config] Failed to process the configuration from Cloud. Using default values.",e),A.bq.DEFAULT_REMOTE_FEATURES}if(i&&this.localSettingsOverridden.size>0){const e=`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.`;x.AlertController.open({shortMessage:"Local configuration ignored",longMessage:`[Reown Config Notice] ${e}`},"warning")}return n}};class _e{constructor(e){this.chainNamespaces=[],this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(e,t)=>{if(e){const r=u.R.getNetworkData(e)?.requestedCaipNetworks?.find((e=>e.id===t));if(r)return r;const s=u.R.getNetworkData(e)?.caipNetwork;if(s)return s;return u.R.getRequestedCaipNetworks(e).filter((t=>t.chainNamespace===e))?.[0]}return u.R.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const e=this.getCaipNetwork();if(e)return e.id},this.getCaipNetworks=e=>u.R.getCaipNetworks(e),this.getActiveChainNamespace=()=>u.R.state.activeChain,this.setRequestedCaipNetworks=(e,t)=>{u.R.setRequestedCaipNetworks(e,t)},this.getApprovedCaipNetworkIds=()=>u.R.getAllApprovedCaipNetworkIds(),this.getCaipAddress=e=>u.R.state.activeChain!==e&&e?u.R.getAccountProp("caipAddress",e):u.R.state.activeCaipAddress,this.setClientId=e=>{d.L.setClientId(e)},this.getProvider=e=>ce.getProvider(e),this.getProviderType=e=>ce.getProviderId(e),this.getPreferredAccountType=e=>p.N.state.preferredAccountTypes?.[e],this.setCaipAddress=(e,t)=>{p.N.setCaipAddress(e,t),e&&o.OptionsController.state.enableEmbedded&&this.close()},this.setBalance=(e,t,r)=>{p.N.setBalance(e,t,r)},this.setProfileName=(e,t)=>{p.N.setProfileName(e,t)},this.setProfileImage=(e,t)=>{p.N.setProfileImage(e,t)},this.setUser=(e,t)=>{p.N.setUser(e,t)},this.resetAccount=e=>{p.N.resetAccount(e)},this.setCaipNetwork=e=>{u.R.setActiveCaipNetwork(e)},this.setCaipNetworkOfNamespace=(e,t)=>{u.R.setChainNetworkData(t,{caipNetwork:e})},this.setAllAccounts=(e,t)=>{p.N.setAllAccounts(e,t),o.OptionsController.setHasMultipleAddresses(e?.length>1)},this.setStatus=(e,t)=>{p.N.setStatus(e,t),s.ConnectorController.isConnected()?g.M.setConnectionStatus("connected"):g.M.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=e=>u.R.getAccountProp("address",e),this.setConnectors=e=>{const t=[...s.ConnectorController.state.allConnectors,...e];s.ConnectorController.setConnectors(t)},this.setConnections=(e,t)=>{i.ConnectionController.setConnections(e,t)},this.fetchIdentity=e=>d.L.fetchIdentity(e),this.getReownName=e=>N.getNamesForAddress(e),this.getConnectors=()=>s.ConnectorController.getConnectors(),this.getConnectorImage=e=>I.f.getConnectorImage(e),this.setConnectedWalletInfo=(e,t)=>{const r=ce.getProviderId(t),s=e?{...e,type:r}:void 0;p.N.setConnectedWalletInfo(s,t)},this.getIsConnectedState=()=>Boolean(u.R.state.activeCaipAddress),this.addAddressLabel=(e,t,r)=>{p.N.addAddressLabel(e,t,r)},this.removeAddressLabel=(e,t)=>
877{p.N.removeAddressLabel(e,t)},this.getAddress=e=>u.R.state.activeChain!==e&&e?u.R.getAccountProp("address",e):p.N.state.address,this.setApprovedCaipNetworksData=e=>u.R.setApprovedCaipNetworksData(e),this.resetNetwork=e=>{u.R.resetNetwork(e)},this.addConnector=e=>{s.ConnectorController.addConnector(e)},this.resetWcConnection=()=>{i.ConnectionController.resetWcConnection()},this.setAddressExplorerUrl=(e,t)=>{p.N.setAddressExplorerUrl(e,t)},this.setSmartAccountDeployed=(e,t)=>{p.N.setSmartAccountDeployed(e,t)},this.setSmartAccountEnabledNetworks=(e,t)=>{u.R.setSmartAccountEnabledNetworks(e,t)},this.setPreferredAccountType=(e,t)=>{p.N.setPreferredAccountType(e,t)},this.setEIP6963Enabled=e=>{o.OptionsController.setEIP6963Enabled(e)},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,t){const r=e?.map((e=>e.namespace)).filter((e=>Boolean(e)));if(r?.length)return[...new Set(r)];const s=t?.map((e=>e.chainNamespace));return[...new Set(s)]}async initialize(e){this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),await this.syncExistingConnection(),this.remoteFeatures=await Se.fetchRemoteFeatures(e),o.OptionsController.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&R.setOnrampProviders(this.remoteFeatures.onramp),(o.OptionsController.state.remoteFeatures?.email||Array.isArray(o.OptionsController.state.remoteFeatures?.socials)&&o.OptionsController.state.remoteFeatures?.socials.length>0)&&await this.checkAllowedOrigins()}async checkAllowedOrigins(){const e=await S.ApiController.fetchAllowedOrigins();if(e&&n.j.isClient()){const t=window.location.origin;be.isOriginAllowed(t,e,ge)||x.AlertController.open(H.ALERT_ERRORS.INVALID_APP_CONFIGURATION,"error")}else x.AlertController.open(H.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error")}sendInitializeEvent(e){const{...t}=e;delete t.adapters,delete t.universalProvider,U.X.sendEvent({type:"track",event:"INITIALIZE",properties:{...t,networks:e.networks.map((e=>e.id)),siweConfig:{options:e.siweConfig?.options||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&D.ThemeController.setThemeMode(e.themeMode),e.themeVariables&&D.ThemeController.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");u.R.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const t=this.getDefaultNetwork();t&&u.R.setActiveCaipNetwork(t)}initializeConnectionController(e){i.ConnectionController.setWcBasic(e.basic??!1)}initializeConnectorController(){s.ConnectorController.initialize(this.chainNamespaces)}initializeProjectSettings(e){o.OptionsController.setProjectId(e.projectId),o.OptionsController.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){o.OptionsController.setDebug(!1!==e.debug),o.OptionsController.setEnableWalletConnect(!1!==e.enableWalletConnect),o.OptionsController.setEnableWalletGuide(!1!==e.enableWalletGuide),o.OptionsController.setEnableWallets(!1!==e.enableWallets),o.OptionsController.setEIP6963Enabled(!1!==e.enableEIP6963),o.OptionsController.setEnableNetworkSwitch(!1!==e.enableNetworkSwitch),o.OptionsController.setEnableAuthLogger(!1!==e.enableAuthLogger),o.OptionsController.setCustomRpcUrls(e.customRpcUrls),o.OptionsController.setEnableEmbedded(e.enableEmbedded),o.OptionsController.setAllWallets(e.allWallets),o.OptionsController.setIncludeWalletIds(e.includeWalletIds),o.OptionsController.setExcludeWalletIds(e.excludeWalletIds),o.OptionsController.setFeaturedWalletIds(e.featuredWalletIds),o.OptionsController.setTokens(e.tokens),o.OptionsController.setTermsConditionsUrl(e.termsConditionsUrl),o.OptionsController.setPrivacyPolicyUrl(e.privacyPolicyUrl),o.OptionsController.setCustomWallets(e.customWallets),o.OptionsController.setFeatures(e.features),o.OptionsController.setAllowUnsupportedChain(e.allowUnsupportedChain),o.OptionsController.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),o.OptionsController.setPreferUniversalLinks(e.experimental_preferUniversalLinks),o.OptionsController.setDefaultAccountTypes(e.defaultAccountTypes);const t=g.M.getPreferredAccountTypes()||{},r={...o.OptionsController.state.defaultAccountTypes,...t};p.N.setPreferredAccountTypes(r);const s=this.getDefaultMetaData();if(!e.metadata&&s&&(e.metadata=s),o.OptionsController.setMetadata(e.metadata),o.OptionsController.setDisableAppend(e.disableAppend),o.OptionsController.setEnableEmbedded(e.enableEmbedded),o.OptionsController.setSIWX(e.siwx),!e.projectId)return void x.AlertController.open(H.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");const i=e.adapters?.find((e=>e.namespace===c.b.CHAIN.EVM));if(i&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");o.OptionsController.setSIWX(e.siweConfig.mapToSIWX())}}
877getDefaultMetaData(){return n.j.isClient()?{name:document.getElementsByTagName("title")?.[0]?.textContent||"",description:document.querySelector('meta[property="og:description"]')?.content||"",url:window.location.origin,icons:[document.querySelector('link[rel~="icon"]')?.href||""]}:null}setUnsupportedNetwork(e){const t=this.getActiveChainNamespace();if(t){const r=re.getUnsupportedNetwork(`${t}:${e}`);u.R.setActiveCaipNetwork(r)}}getDefaultNetwork(){return re.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,t){return re.extendCaipNetwork(e,{customNetworkImageUrls:t.chainImages,projectId:t.projectId})}extendCaipNetworks(e){return re.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const t=e.networks.find((t=>t.id===e.defaultNetwork?.id));return t?re.extendCaipNetwork(t,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectNamespace(e){try{const t=this.getAdapter(e),r=ce.getProvider(e),i=ce.getProviderId(e),{caipAddress:n}=u.R.getAccountData(e)||{};this.setLoading(!0,e),n&&t?.disconnect&&await t.disconnect({provider:r,providerType:i}),g.M.removeConnectedNamespace(e),ce.resetChain(e),this.setUser(void 0,e),this.setStatus("disconnected",e),this.setConnectedWalletInfo(void 0,e),s.ConnectorController.removeConnectorId(e),u.R.resetAccount(e),u.R.resetNetwork(e),this.setLoading(!1,e)}catch(t){throw this.setLoading(!1,e),new Error(`Failed to disconnect chain ${e}: ${t.message}`)}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{const e=u.R.state.activeChain,t=this.getAdapter(e),r=this.getCaipNetwork(e)?.id;if(!t)throw new Error("Adapter not found");const i=await t.connectWalletConnect(r);this.close(),this.setClientId(i?.clientId||null),g.M.setConnectedNamespaces([...u.R.state.chains.keys()]),this.chainNamespaces.forEach((e=>{s.ConnectorController.setConnectorId(Z.b.CONNECTOR_TYPE_WALLET_CONNECT,e)})),await this.syncWalletConnectAccount()},connectExternal:async({id:e,info:t,type:r,provider:s,chain:i,caipNetwork:n,socialUri:o})=>{const a=u.R.state.activeChain,c=i||a,l=this.getAdapter(c);if(i&&i!==a&&!n){const e=this.getCaipNetworks().find((e=>e.chainNamespace===i));e&&this.setCaipNetwork(e)}if(!l)throw new Error("Adapter not found");const h=this.getCaipNetwork(c),d=await l.connect({id:e,info:t,type:r,provider:s,socialUri:o,chainId:n?.id||h?.id,rpcUrl:n?.rpcUrls?.default?.http?.[0]||h?.rpcUrls?.default?.http?.[0]});if(!d)return;g.M.addConnectedNamespace(c),this.syncProvider({...d,chainNamespace:c});const f=p.N.state.allAccounts,{accounts:m}=f?.length>0?{accounts:[...f]}:await l.getAccounts({namespace:c,id:e});this.setAllAccounts(m,c),this.setStatus("connected",c),this.syncConnectedWalletInfo(c)},reconnectExternal:async({id:e,info:t,type:r,provider:s})=>{const i=u.R.state.activeChain,n=this.getAdapter(i);n?.reconnect&&(await(n?.reconnect({id:e,info:t,type:r,provider:s,chainId:this.getCaipNetwork()?.id})),g.M.addConnectedNamespace(i),this.syncConnectedWalletInfo(i))},disconnect:async e=>{const t=function(e){const t=Array.from(u.R.state.chains.keys());let r=[];return e?(r.push([e,u.R.state.chains.get(e)]),q(e,c.b.CONNECTOR_ID.WALLET_CONNECT)?t.forEach((t=>{t!==e&&q(t,c.b.CONNECTOR_ID.WALLET_CONNECT)&&r.push([t,u.R.state.chains.get(t)])})):q(e,c.b.CONNECTOR_ID.AUTH)&&t.forEach((t=>{t!==e&&q(t,c.b.CONNECTOR_ID.AUTH)&&r.push([t,u.R.state.chains.get(t)])}))):r=Array.from(u.R.state.chains.entries()),r}(e);try{const r=await Promise.allSettled(t.map((async([e])=>this.disconnectNamespace(e))));$.S.resetSend(),i.ConnectionController.resetWcConnection(),await M.w.clearSessions(),s.ConnectorController.setFilterByNamespace(void 0);const n=r.filter((e=>"rejected"===e.status));if(n.length>0)throw new Error(n.map((e=>e.reason.message)).join(", "));g.M.deleteConnectedSocialProvider(),U.X.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:e||"all"}})}catch(e){throw new Error(`Failed to disconnect chains: ${e.message}`)}},checkInstalled:e=>e?e.some((e=>Boolean(window.ethereum?.[String(e)]))):Boolean(window.ethereum),signMessage:async e=>{const t=this.getAdapter(u.R.state.activeChain);return(await(t?.signMessage({message:e,address:p.N.state.address,provider:ce.getProvider(u.R.state.activeChain)})))?.signature||""},sendTransaction:async e=>{const t=e.chainNamespace;if(A.bq.SEND_SUPPORTED_NAMESPACES.includes(t)){const r=this.getAdapter(u.R.state.activeChain),s=ce.getProvider(t);return(await(r?.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:s})))?.hash||""}return""},estimateGas:async e=>{if(e.chainNamespace===c.b.CHAIN.EVM){const t=this.getAdapter(u.R.state.activeChain),r=ce.getProvider(u.R.state.activeChain),s=this.getCaipNetwork();if(!s)throw new Error("CaipNetwork is undefined");return(await(t?.estimateGas({...e,provider:r,caipNetwork:s}
877)))?.gas||0n}return 0n},getEnsAvatar:async()=>(await this.syncIdentity({address:p.N.state.address,chainId:Number(this.getCaipNetwork()?.id),chainNamespace:u.R.state.activeChain}),p.N.state.profileImage||!1),getEnsAddress:async e=>await be.resolveReownName(e),writeContract:async e=>{const t=this.getAdapter(u.R.state.activeChain),r=this.getCaipNetwork(),s=this.getCaipAddress(),i=ce.getProvider(u.R.state.activeChain);if(!r||!s)throw new Error("CaipNetwork or CaipAddress is undefined");return(await(t?.writeContract({...e,caipNetwork:r,provider:i,caipAddress:s})))?.hash},parseUnits:(e,t)=>this.getAdapter(u.R.state.activeChain)?.parseUnits({value:e,decimals:t})??0n,formatUnits:(e,t)=>this.getAdapter(u.R.state.activeChain)?.formatUnits({value:e,decimals:t})??"0",getCapabilities:async e=>{const t=this.getAdapter(u.R.state.activeChain);return await(t?.getCapabilities(e))},grantPermissions:async e=>{const t=this.getAdapter(u.R.state.activeChain);return await(t?.grantPermissions(e))},revokePermissions:async e=>{const t=this.getAdapter(u.R.state.activeChain);return t?.revokePermissions?await t.revokePermissions(e):"0x"},walletGetAssets:async e=>{const t=this.getAdapter(u.R.state.activeChain);return await(t?.walletGetAssets(e))??{}},updateBalance:e=>{const t=this.getCaipNetwork(e);t&&p.N.state.address&&this.updateNativeBalance(p.N.state.address,t?.id,e)}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},i.ConnectionController.setClient(this.connectionControllerClient)}getApprovedCaipNetworksData(){if(ce.getProviderId(u.R.state.activeChain)===Z.b.CONNECTOR_TYPE_WALLET_CONNECT){const e=this.universalProvider?.session?.namespaces;return{supportsAllNetworks:"MetaMask Wallet"===this.universalProvider?.session?.peer?.metadata.name,approvedCaipNetworkIds:this.getChainsFromNamespaces(e)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){if(!e)return;const t=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const r=ce.getProvider(t),s=ce.getProviderId(t);if(e.chainNamespace===u.R.state.activeChain){const i=this.getAdapter(t);await(i?.switchNetwork({caipNetwork:e,provider:r,providerType:s}))}else if(this.setCaipNetwork(e),s===Z.b.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const r=this.getAddressByChainNamespace(t);r&&this.syncAccount({address:r,chainId:e.id,chainNamespace:t})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap((e=>{const t=e.chains||[],r=e.accounts.map((e=>{const{chainId:t,chainNamespace:r}=l.parseCaipAddress(e);return`${r}:${t}`}));return Array.from(new Set([...t,...r]))}))}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce(((t,r)=>{const s=e?.find((e=>e.namespace===r));return s?(s.construct({namespace:r,projectId:this.options?.projectId,networks:this.getCaipNetworks()}),t[r]=s):t[r]=new Ne({namespace:r,networks:this.getCaipNetworks()}),t}),{})}async initChainAdapter(e){this.onConnectors(e),this.listenAdapter(e),await(this.chainAdapters?.[e].syncConnectors(this.options,this)),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map((async e=>{await this.initChainAdapter(e)})))}onConnectors(e){this.getAdapter(e)?.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const t=this.getAdapter(e);if(!t)return;const r=g.M.getConnectionStatus();"connected"===r?this.setStatus("connecting",e):"disconnected"===r?(g.M.clearAddressCache(),this.setStatus(r,e)):this.setStatus(r,e),t.on("switchNetwork",(({address:t,chainId:r})=>{const s=this.getCaipNetworks().find((e=>e.id===r||e.caipNetworkId===r)),i=u.R.state.activeChain===e,n=u.R.getAccountProp("address",e);if(s){const r=i&&t?t:n;r&&this.syncAccount({address:r,chainId:s.id,chainNamespace:e})}else this.setUnsupportedNetwork(r)})),t.on("disconnect",this.disconnect.bind(this,e)),t.on("connections",(t=>{this.setConnections(t,e)})),t.on("pendingTransactions",(()=>{const e=p.N.state.address,t=u.R.state.activeCaipNetwork;e&&t?.id&&this.updateNativeBalance(e,t.id,t.chainNamespace)})),t.on("accountChanged",(({address:t,chainId:r})=>{const s=u.R.state.activeChain===e;s&&r?this.syncAccount({address:t,chainId:r,chainNamespace:e}):s&&u.R.state.activeCaipNetwork?.id?this.syncAccount({address:t,chainId:u.R.state.activeCaipNetwork?.id,chainNamespace:e}):this.syncAccountInfo(t,r,e),this.syncAllAccounts(e)}))}async createUniversalProviderForAdapter(e){await this.getUniversalProvider(),this.universalProvider&&this.chainAdapters?.[e]?.setUniversalProvider?.(this.universalProvider)}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map((e=>this.syncNamespaceConnection(e))))}async syncNamespaceConnection(e){try{e===c.b.CHAIN.EVM&&n.j.isSafeApp()&&s.ConnectorController.setConnectorId(c.b.CONNECTOR_ID.SAFE,e);const t=s.ConnectorController.getConnectorId(e);switch(this.setStatus("connecting",e),t){case c.b.CONNECTOR_ID.WALLET_CONNECT:await this.syncWalletConnectAccount();break;case c.b.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(t){console.warn("AppKit couldn't sync existing connection",t),this.setStatus("disconnected",e)}}async syncAdapterConnection(e){const t=this.getAdapter(e),r=s.ConnectorController.getConnectorId(e),i=this.getCaipNetwork(e),o=s.ConnectorController.getConnectors(e).find((e=>e.id===r));try{if(!t||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!i?.id)throw new Error("CaipNetwork not found");const r=await(t?.syncConnection({namespace:e,id:o.id,chainId:i.id,rpcUrl:i?.rpcUrls?.default?.http?.[0]}));if(r){const s=await(t?.getAccounts({namespace:e,id:o.id}));s&&s.accounts.length>0?this.setAllAccounts(s.accounts,e):this.setAllAccounts([n.j.createAccount(e,r.address,"eoa")],e),this.syncProvider({...r,chainNamespace:e}),await this.syncAccount({...r,chainNamespace:e}),this.setStatus("connected",e)}else this.setStatus("disconnected",e)}catch(t){this.setStatus("disconnected",e)}}async syncWalletConnectAccount(){const e=this.chainNamespaces.map((async e=>{const t=this.getAdapter(e),r=this.universalProvider?.session?.namespaces?.[e]?.accounts||[],i=u.R.state.activeCaipNetwork?.id,n=r.find((e=>{const{chainId:t}=l.parseCaipAddress(e);return t===i?.toString()}))||r[0];if(n){const r=l.validateCaipAddress(n),{chainId:i,address:o}=l.parseCaipAddress(r);if(ce.setProviderId(e,Z.b.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&u.R.state.activeCaipNetwork&&t?.namespace!==c.b.CHAIN.EVM){const r=t?.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:u.R.state.activeCaipNetwork});ce.setProvider(e,r)}else ce.setProvider(e,this.universalProvider);s.ConnectorController.setConnectorId(c.b.CONNECTOR_ID.WALLET_CONNECT,e),g.M.addConnectedNamespace(e),this.syncWalletConnectAccounts(e),await this.syncAccount({address:o,chainId:i,chainNamespace:e})}else this.setStatus("disconnected",e);this.syncConnectedWalletInfo(e),await u.R.setApprovedCaipNetworksData(e)}));await Promise.all(e)}syncWalletConnectAccounts(e){const t=this.universalProvider?.session?.namespaces?.[e]?.accounts?.map((e=>{const{address:t}=l.parseCaipAddress(e);return t})).filter(((e,t,r)=>r.indexOf(e)===t));t&&this.setAllAccounts(t.map((t=>n.j.createAccount(e,t,"bip122"===e?"payment":"eoa"))),e)}syncProvider({type:e,provider:t,id:r,chainNamespace:i}){ce.setProviderId(i,e),ce.setProvider(i,t),s.ConnectorController.setConnectorId(r,i)}async syncAllAccounts(e){const t=s.ConnectorController.getConnectorId(e);if(!t)return;const r=this.getAdapter(e),i=await(r?.getAccounts({namespace:e,id:t}));i&&i.accounts.length>0&&this.setAllAccounts(i.accounts,e)}async syncAccount(e){const t=e.chainNamespace===u.R.state.activeChain,r=u.R.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:s,chainId:i,chainNamespace:n}=e,{chainId:a}=g.M.getActiveNetworkProps(),h=i||a,d=u.R.state.activeCaipNetwork?.name===c.b.UNSUPPORTED_NETWORK_NAME,f=u.R.getNetworkProp("supportsAllNetworks",n);if(this.setStatus("connected",n),(!d||f)&&h){let e=this.getCaipNetworks().find((e=>e.id.toString()===h.toString())),i=this.getCaipNetworks().find((e=>e.chainNamespace===n));if(!f&&!e&&!i){const t=this.getApprovedCaipNetworkIds()||[],r=t.find((e=>l.parseCaipNetworkId(e)?.chainId===h.toString())),s=t.find((e=>l.parseCaipNetworkId(e)?.chainNamespace===n));e=this.getCaipNetworks().find((e=>e.caipNetworkId===r)),i=this.getCaipNetworks().find((e=>e.caipNetworkId===s||"deprecatedCaipNetworkId"in e&&e.deprecatedCaipNetworkId===s))}const a=e||i;a?.chainNamespace===u.R.state.activeChain?o.OptionsController.state.enableNetworkSwitch&&!o.OptionsController.state.allowUnsupportedChain&&u.R.state.activeCaipNetwork?.name===c.b.UNSUPPORTED_NETWORK_NAME?u.R.showUnsupportedChainUI():this.setCaipNetwork(a):t||r&&this.setCaipNetworkOfNamespace(r,n),this.syncConnectedWalletInfo(n),se.g.isLowerCaseMatch(s,p.N.state.address)||this.syncAccountInfo(s,a?.id,n),t?await this.syncBalance({address:s,chainId:a?.id,chainNamespace:n}):await this.syncBalance({address:s,chainId:r?.id,chainNamespace:n})}}async syncAccountInfo(e,t,r){const s=this.getCaipAddress(r),i=t||s?.split(":")[1];if(!i)return;const n=`${r}:${i}:${e}`;this.setCaipAddress(n,r),await this.syncIdentity({address:e,chainId:i,chainNamespace:r})}async syncReownName(e,t){try{const r=await this.getReownName(e);
877if(r[0]){const e=r[0];this.setProfileName(e.name,t)}else this.setProfileName(null,t)}catch{this.setProfileName(null,t)}}syncConnectedWalletInfo(e){const t=s.ConnectorController.getConnectorId(e),r=ce.getProviderId(e);if(r===Z.b.CONNECTOR_TYPE_ANNOUNCED||r===Z.b.CONNECTOR_TYPE_INJECTED){if(t){const r=this.getConnectors().find((e=>e.id===t));if(r){const{info:t,name:s,imageUrl:i}=r,n=i||this.getConnectorImage(r);this.setConnectedWalletInfo({name:s,icon:n,...t},e)}}}else if(r===Z.b.CONNECTOR_TYPE_WALLET_CONNECT){const t=ce.getProvider(e);t?.session&&this.setConnectedWalletInfo({...t.session.peer.metadata,name:t.session.peer.metadata.name,icon:t.session.peer.metadata.icons?.[0]},e)}else if(t&&t===c.b.CONNECTOR_ID.COINBASE){const t=this.getConnectors().find((e=>e.id===c.b.CONNECTOR_ID.COINBASE));this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(t)},e)}}async syncBalance(e){h.p.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find((t=>t.id.toString()===e.chainId?.toString()))&&e.chainId&&await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,t,r){const s=this.getAdapter(r),i=u.R.getCaipNetworkByNamespace(r,t);if(s){const n=await s.getBalance({address:e,chainId:t,caipNetwork:i,tokens:this.options.tokens});return this.setBalance(n.balance,n.symbol,r),n}}async initializeUniversalAdapter(){const e=ne.createLogger(((e,...t)=>{e&&this.handleAlertError(e),console.error(...t)})),t={projectId:this.options?.projectId,metadata:{name:this.options?.metadata?this.options?.metadata.name:"",description:this.options?.metadata?this.options?.metadata.description:"",url:this.options?.metadata?this.options?.metadata.url:"",icons:this.options?.metadata?this.options?.metadata.icons:[""]},logger:e};o.OptionsController.setManualWCControl(Boolean(this.options?.manualWCControl)),this.universalProvider=this.options.universalProvider??await a.Z.init(t),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&(this.universalProvider.on("display_uri",(e=>{i.ConnectionController.setUri(e)})),this.universalProvider.on("connect",i.ConnectionController.finalizeWcConnection),this.universalProvider.on("disconnect",(()=>{this.chainNamespaces.forEach((e=>{this.resetAccount(e)})),i.ConnectionController.resetWcConnection()})),this.universalProvider.on("chainChanged",(e=>{const t=this.getCaipNetworks().find((t=>t.id==e)),r=this.getCaipNetwork();t?r?.id!==t?.id&&this.setCaipNetwork(t):this.setUnsupportedNetwork(e)})),this.universalProvider.on("session_event",(e=>{if(be.isSessionEventData(e)){const{name:t,data:r}=e.params.event;"accountsChanged"===t&&Array.isArray(r)&&n.j.isCaipAddress(r[0])&&this.syncAccount(l.parseCaipAddress(r[0]))}})))}createUniversalProvider(){return!this.universalProviderInitPromise&&n.j.isClient()&&this.options?.projectId&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}
877async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){U.X.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}handleAlertError(e){const t=Object.entries(H.UniversalProviderErrors).find((([,{message:t}])=>e.message.includes(t))),[r,s]=t??[],{message:i,alertErrorKey:n}=s??{};if(r&&i&&!this.reportedAlertErrors[r]){const e=H.ALERT_ERRORS[n];e&&(x.AlertController.open(e,"error"),this.reportedAlertErrors[r]=!0)}}getAdapter(e){if(e)return this.chainAdapters?.[e]}createAdapter(e){if(!e)return;const t=e.namespace;if(!t)return;this.createClients();const r=e;r.namespace=t,r.construct({namespace:t,projectId:this.options?.projectId,networks:this.getCaipNetworks()}),this.chainNamespaces.includes(t)||this.chainNamespaces.push(t),this.chainAdapters&&(this.chainAdapters[t]=r)}async open(e){return await this.injectModalUi(),e?.uri&&i.ConnectionController.setUri(e.uri),e?.arguments&&"Swap"===e?.view?L.I.open({...e,data:{swap:e.arguments}}):L.I.open(e)}async close(){await this.injectModalUi(),L.I.close()}setLoading(e,t){L.I.setLoading(e,t)}async disconnect(e){await i.ConnectionController.disconnect(e)}getSIWX(){return o.OptionsController.state.siwx}getError(){return""}getChainId(){return u.R.state.activeCaipNetwork?.id}async switchNetwork(e){const t=this.getCaipNetworks().find((t=>t.id===e.id));t?await u.R.switchActiveNetwork(t):x.AlertController.open(H.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error")}getWalletProvider(){return u.R.state.activeChain?ce.state.providers[u.R.state.activeChain]:null}getWalletProviderType(){return ce.getProviderId(u.R.state.activeChain)}subscribeProviders(e){return ce.subscribeProviders(e)}getThemeMode(){return D.ThemeController.state.themeMode}getThemeVariables(){return D.ThemeController.state.themeVariables}setThemeMode(e){D.ThemeController.setThemeMode(e),(0,F.Hs)(D.ThemeController.state.themeMode)}setTermsConditionsUrl(e){o.OptionsController.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){o.OptionsController.setPrivacyPolicyUrl(e)}setThemeVariables(e){D.ThemeController.setThemeVariables(e),(0,F.R)(D.ThemeController.state.themeVariables)}subscribeTheme(e){return D.ThemeController.subscribe(e)}getWalletInfo(){return p.N.state.connectedWalletInfo}getAccount(e){const t=s.ConnectorController.getAuthConnector(e),r=u.R.getAccountData(e),i=u.R.state.activeChain,o=g.M.getConnectedConnectorId(e||i);if(r)return{allAccounts:r.allAccounts,caipAddress:r.caipAddress,address:n.j.getPlainAddress(r.caipAddress),isConnected:Boolean(r.caipAddress),status:r.status,embeddedWalletInfo:t&&o===c.b.CONNECTOR_ID.AUTH?{user:r.user?{...r.user,username:g.M.getConnectedSocialUsername()}:void 0,authProvider:r.socialProvider||"email",accountType:r.preferredAccountTypes?.[e||i],isSmartAccountDeployed:Boolean(r.smartAccountDeployed)}:void 0}}subscribeAccount(e,t){const r=()=>{const r=this.getAccount(t);r&&e(r)};t?u.R.subscribeChainProp("accountState",r,t):u.R.subscribe(r),s.ConnectorController.subscribe(r)}subscribeNetwork(e){return u.R.subscribe((({activeCaipNetwork:t})=>{e({caipNetwork:t,chainId:t?.id,caipNetworkId:t?.caipNetworkId})}))}subscribeWalletInfo(e){return p.N.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){p.N.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){u.R.subscribeKey("activeCaipNetwork",e)}getState(){return j.I.state}subscribeState(e){return j.I.subscribe(e)}showErrorMessage(e){B.SnackController.showError(e)}showSuccessMessage(e){B.SnackController.showSuccess(e)}getEvent(){return{...U.X.state}}subscribeEvents(e){return U.X.subscribe(e)}replace(e){v.RouterController.replace(e)}redirect(e){v.RouterController.push(e)}popTransactionStack(e){v.RouterController.popTransactionStack(e)}isOpen(){return L.I.state.open}isTransactionStackEmpty(){return 0===v.RouterController.state.transactionStack.length}static getInstance(){return this.instance}updateFeatures(e){o.OptionsController.setFeatures(e)}updateRemoteFeatures(e){o.OptionsController.setRemoteFeatures(e)}updateOptions(e){const t={...o.OptionsController.state||{},...e};o.OptionsController.setOptions(t)}setConnectMethodsOrder(e){o.OptionsController.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){o.OptionsController.setWalletFeaturesOrder(e)}setCollapseWallets(e){o.OptionsController.setCollapseWallets(e)}setSocialsOrder(e){o.OptionsController.setSocialsOrder(e)}getConnectMethodsOrder(){return W.J.getConnectOrderMethod(o.OptionsController.state.features,s.ConnectorController.getConnectors())}addNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const r=this.extendCaipNetwork(t,this.options);this.getCaipNetworks().find((e=>e.id===r.id))||u.R.addNetwork(r)}removeNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);this.getCaipNetworks().find((e=>e.id===t))&&u.R.removeNetwork(e,t)}}let Oe=!1;class Pe extends _e{async open(e){s.ConnectorController.isConnected()||await super.open(e)}async close(){await super.close(),this.options.manualWCControl&&i.ConnectionController.finalizeWcConnection()}async syncIdentity(e){return Promise.resolve()}async syncBalance(e){return Promise.resolve()}
877async injectModalUi(){if(!Oe&&n.j.isClient()){await Promise.all([r.e(6911),r.e(635)]).then(r.bind(r,70635)),await Promise.all([r.e(6911),r.e(7612)]).then(r.bind(r,57612));if(!document.querySelector("w3m-modal")){const e=document.createElement("w3m-modal");o.OptionsController.state.disableAppend||o.OptionsController.state.enableEmbedded||document.body.insertAdjacentElement("beforeend",e)}Oe=!0}}}function Te(e){return new Pe({...e,basic:!0,sdkVersion:"html-core-1.7.8"})}},44098:function(e,t,r){"use strict";r.d(t,{sj:function(){return y},iH:function(){return C},CO:function(){return v},Ld:function(){return b}});var s=r(19632),i=r(5574),n=r(52677);Symbol();const o=Symbol();const a=Object.getPrototypeOf,c=new WeakMap,l=e=>e&&(c.has(e)?c.get(e):a(e)===Object.prototype||a(e)===Array.prototype),h=e=>l(e)&&e[o]||null,u=(e,t=!0)=>{c.set(e,t)};var d=function(e){return"object"===n(e)&&null!==e},p=new WeakMap,g=new WeakSet,f=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:Object.is,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:function(e,t){return new Proxy(e,t)},r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(e){return d(e)&&!g.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)},n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:function(e){switch(e.status){case"fulfilled":return e.value;case"rejected":throw e.reason;default:throw e}},o=arguments.length>4&&void 0!==arguments[4]?arguments[4]:new WeakMap,a=arguments.length>5&&void 0!==arguments[5]?arguments[5]:function(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:n,s=o.get(e);if((null==s?void 0:s[0])===t)return s[1];var c=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return u(c,!0),o.set(e,[t,c]),Reflect.ownKeys(e).forEach((function(t){if(!Object.getOwnPropertyDescriptor(c,t)){var s=Reflect.get(e,t),n=Reflect.getOwnPropertyDescriptor(e,t).enumerable,o={value:s,enumerable:n,configurable:!0};if(g.has(s))u(s,!1);else if(s instanceof Promise)delete o.value,o.get=function(){return r(s)};else if(p.has(s)){var l=p.get(s),h=i(l,2),d=h[0],f=h[1];o.value=a(d,f(),r)}Object.defineProperty(c,t,o)}})),Object.preventExtensions(c)},c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:new WeakMap,l=arguments.length>7&&void 0!==arguments[7]?arguments[7]:[1,1],f=arguments.length>8&&void 0!==arguments[8]?arguments[8]:function(n){if(!d(n))throw new Error("object required");var o=c.get(n);if(o)return o;var u=l[0],m=new Set,w=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:++l[0];u!==t&&(u=t,m.forEach((function(r){return r(e,t)})))},y=l[1],b=function(e){return function(t,r){var i=s(t);i[1]=[e].concat(s(i[1])),w(i,r)}},v=new Map,C=function(e){var t,r=v.get(e);r&&(v.delete(e),null==(t=r[1])||t.call(r))},E=Array.isArray(n)?[]:Object.create(Object.getPrototypeOf(n)),N={deleteProperty:function(e,t){var r=Reflect.get(e,t);C(t);var s=Reflect.deleteProperty(e,t);return s&&w(["delete",[t],r]),s},set:function(t,s,i,n){var o=Reflect.has(t,s),a=Reflect.get(t,s,n);if(o&&(e(a,i)||c.has(i)&&e(a,c.get(i))))return!0;C(s),d(i)&&(i=h(i)||i);var l=i;if(i instanceof Promise)i.then((function(e){i.status="fulfilled",i.value=e,w(["resolve",[s],e])})).catch((function(e){i.status="rejected",i.reason=e,w(["reject",[s],e])}));else{!p.has(i)&&r(i)&&(l=f(i));var u=!g.has(l)&&p.get(l);u&&function(e,t){if(v.has(e))throw new Error("prop listener already exists");if(m.size){var r=t[3](b(e));v.set(e,[t,r])}else v.set(e,[t])}(s,u)}return Reflect.set(t,s,l,n),w(["set",[s],i,a]),!0}},I=t(E,N);c.set(n,I);var A=[E,function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:++l[1];return y===e||m.size||(y=e,v.forEach((function(t){var r=i(t,1)[0][1](e);r>u&&(u=r)}))),u},a,function(e){m.add(e),1===m.size&&v.forEach((function(e,t){var r=i(e,2),s=r[0];if(r[1])throw new Error("remove already exists");var n=s[3](b(t));v.set(t,[s,n])}));return function(){m.delete(e),0===m.size&&v.forEach((function(e,t){var r=i(e,2),s=r[0],n=r[1];n&&(n(),v.set(t,[s]))}))}}];
877return p.set(I,A),Reflect.ownKeys(n).forEach((function(e){var t=Object.getOwnPropertyDescriptor(n,e);"value"in t&&(I[e]=n[e],delete t.value,delete t.writable),Object.defineProperty(E,e,t)})),I};return[f,p,g,e,t,r,n,o,a,c,l]},m=f(),w=i(m,1)[0];function y(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return w(e)}function b(e,t,r){var s,i=p.get(e);i||console.warn("Please use proxy object");var n=[],o=i[3],a=!1,c=o((function(e){n.push(e),r?t(n.splice(0)):s||(s=Promise.resolve().then((function(){s=void 0,a&&t(n.splice(0))})))}));return a=!0,function(){a=!1,c()}}function v(e,t){var r=p.get(e);r||console.warn("Please use proxy object");var s=i(r,3),n=s[0],o=s[1];return(0,s[2])(n,o(),t)}function C(e){return g.add(e),e}},87178:function(e,t,r){"use strict";r.d(t,{VW:function(){return o},Yr:function(){return a}});var s=r(9783),i=r(81491),n=(r(52677),r(5574),r(97857),r(13769),r(15009),r(99289),r(44098));function o(e,t,r,s){var i=e[t];return(0,n.Ld)(e,(function(){var s=e[t];Object.is(i,s)||r(i=s)}),s)}Symbol();function a(e){var t=(0,n.sj)(s(i("get",{data:Array.from(e||[]),has:function(e){return this.data.some((function(t){return t[0]===e}))},set:function(e,t){var r=this.data.find((function(t){return t[0]===e}));return r?r[1]=t:this.data.push([e,t]),this},get:function(e){var t;return null==(t=this.data.find((function(t){return t[0]===e})))?void 0:t[1]},delete:function(e){var t=this.data.findIndex((function(t){return t[0]===e}));return-1!==t&&(this.data.splice(t,1),!0)},clear:function(){this.data.splice(0)},get size(){return this.data.length},toJSON:function(){return new Map(this.data)},forEach:function(e){var t=this;this.data.forEach((function(r){e(r[1],r[0],t)}))},keys:function(){return this.data.map((function(e){return e[0]})).values()},values:function(){return this.data.map((function(e){return e[1]})).values()},entries:function(){return new Map(this.data).entries()}},Symbol.toStringTag,(function(){return"Map"})),Symbol.iterator,(function(){return this.entries()})));return Object.defineProperties(t,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(t),t}},47305:function(e,t,r){"use strict";function s(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function i(e,...t){if(!((r=e)instanceof Uint8Array||ArrayBuffer.isView(r)&&"Uint8Array"===r.constructor.name))throw new Error("Uint8Array expected");var r;if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function n(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");s(e.outputLen),s(e.blockLen)}function o(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function a(e,t){i(e);const r=t.outputLen;if(e.length<r)throw new Error("digestInto() expects output buffer of length at least "+r)}r.d(t,{$h:function(){return o},eB:function(){return a},gk:function(){return i},k8:function(){return s},z3:function(){return n}})},62216:function(e,t,r){"use strict";r.d(t,{kb:function(){return p},l1:function(){return h},eV:function(){return d},GL:function(){return o},iA:function(){return c},O6:function(){return f},np:function(){return a},O0:function(){return u},Jq:function(){return n},hE:function(){return g}});const s="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;var i=r(47305);function n(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function o(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function a(e,t){return e<<32-t|e>>>t}const c=(()=>68===new Uint8Array(new Uint32Array([287454020]).buffer)[0])();function l(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function h(e){for(let t=0;t<e.length;t++)e[t]=l(e[t])}function u(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),(0,i.gk)(e),e}function d(...e){let t=0;for(let r=0;r<e.length;r++){const s=e[r];(0,i.gk)(s),t+=s.length}
vendor: 6,892 bytes, line 877
877const r=new Uint8Array(t);for(let t=0,s=0;t<e.length;t++){const i=e[t];r.set(i,s),s+=i.length}return r}class p{clone(){return this._cloneInto()}}function g(e){const t=t=>e().update(u(t)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function f(e=32){if(s&&"function"==typeof s.getRandomValues)return s.getRandomValues(new Uint8Array(e));if(s&&"function"==typeof s.randomBytes)return s.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}},33692:function(e,t,r){"use strict";r.d(t,{Jb:function(){return S},Ld:function(){return _},YP:function(){return A},_$LH:function(){return q},dy:function(){return I},sY:function(){return W}});const s=globalThis,i=s.trustedTypes,n=i?i.createPolicy("lit-html",{createHTML:e=>e}):void 0,o="$lit$",a=`lit$${Math.random().toFixed(9).slice(2)}$`,c="?"+a,l=`<${c}>`,h=document,u=()=>h.createComment(""),d=e=>null===e||"object"!=typeof e&&"function"!=typeof e,p=Array.isArray,g=e=>p(e)||"function"==typeof e?.[Symbol.iterator],f="[ \t\n\f\r]",m=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,w=/-->/g,y=/>/g,b=RegExp(`>|${f}(?:([^\\s"'>=/]+)(${f}*=${f}*(?:[^ \t\n\f\r"'\`<>=]|("|')|))|$)`,"g"),v=/'/g,C=/"/g,E=/^(?:script|style|textarea|title)$/i,N=e=>(t,...r)=>({_$litType$:e,strings:t,values:r}),I=N(1),A=N(2),S=(N(3),Symbol.for("lit-noChange")),_=Symbol.for("lit-nothing"),O=new WeakMap,P=h.createTreeWalker(h,129);function T(e,t){if(!p(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==n?n.createHTML(t):t}const k=(e,t)=>{const r=e.length-1,s=[];let i,n=2===t?"<svg>":3===t?"<math>":"",c=m;for(let t=0;t<r;t++){const r=e[t];let h,u,d=-1,p=0;for(;p<r.length&&(c.lastIndex=p,u=c.exec(r),null!==u);)p=c.lastIndex,c===m?"!--"===u[1]?c=w:void 0!==u[1]?c=y:void 0!==u[2]?(E.test(u[2])&&(i=RegExp("</"+u[2],"g")),c=b):void 0!==u[3]&&(c=b):c===b?">"===u[0]?(c=i??m,d=-1):void 0===u[1]?d=-2:(d=c.lastIndex-u[2].length,h=u[1],c=void 0===u[3]?b:'"'===u[3]?C:v):c===C||c===v?c=b:c===w||c===y?c=m:(c=b,i=void 0);const g=c===b&&e[t+1].startsWith("/>")?" ":"";n+=c===m?r+l:d>=0?(s.push(h),r.slice(0,d)+o+r.slice(d)+a+g):r+a+(-2===d?t:g)}return[T(e,n+(e[r]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),s]};class R{constructor({strings:e,_$litType$:t},r){let s;this.parts=[];let n=0,l=0;const h=e.length-1,d=this.parts,[p,g]=k(e,t);if(this.el=R.createElement(p,r),P.currentNode=this.el.content,2===t||3===t){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(s=P.nextNode())&&d.length<h;){if(1===s.nodeType){if(s.hasAttributes())for(const e of s.getAttributeNames())if(e.endsWith(o)){const t=g[l++],r=s.getAttribute(e).split(a),i=/([.?@])?(.*)/.exec(t);d.push({type:1,index:n,name:i[2],strings:r,ctor:"."===i[1]?M:"?"===i[1]?L:"@"===i[1]?j:$}),s.removeAttribute(e)}else e.startsWith(a)&&(d.push({type:6,index:n}),s.removeAttribute(e));if(E.test(s.tagName)){const e=s.textContent.split(a),t=e.length-1;if(t>0){s.textContent=i?i.emptyScript:"";for(let r=0;r<t;r++)s.append(e[r],u()),P.nextNode(),d.push({type:2,index:++n});s.append(e[t],u())}}}else if(8===s.nodeType)if(s.data===c)d.push({type:2,index:n});else{let e=-1;for(;-1!==(e=s.data.indexOf(a,e+1));)d.push({type:7,index:n}),e+=a.length-1}n++}}static createElement(e,t){const r=h.createElement("template");return r.innerHTML=e,r}}function x(e,t,r=e,s){if(t===S)return t;let i=void 0!==s?r._$Co?.[s]:r._$Cl;const n=d(t)?void 0:t._$litDirective$;return i?.constructor!==n&&(i?._$AO?.(!1),void 0===n?i=void 0:(i=new n(e),i._$AT(e,r,s)),void 0!==s?(r._$Co??=[])[s]=i:r._$Cl=i),void 0!==i&&(t=x(e,i._$AS(e,t.values),i,s)),t}class U{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:t},parts:r}=this._$AD,s=(e?.creationScope??h).importNode(t,!0);P.currentNode=s;let i=P.nextNode(),n=0,o=0,a=r[0];for(;void 0!==a;){if(n===a.index){let t;2===a.type?t=new D(i,i.nextSibling,this,e):1===a.type?t=new a.ctor(i,a.name,a.strings,this,e):6===a.type&&(t=new B(i,this,e)),this._$AV.push(t),a=r[++o]}n!==a?.index&&(i=P.nextNode(),n++)}return P.currentNode=h,s}p(e){let t=0;for(const r of this._$AV)void 0!==r&&(void 0!==r.strings?(r._$AI(e,r,t),t+=r.strings.length-2):r._$AI(e[t])),t++}}class D{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,t,r,s){this.type=2,this._$AH=_,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=r,this.options=s,this._$Cv=s?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const t=this._$AM;return void 0!==t&&11===e?.nodeType&&(e=t.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,t=this){e=x(this,e,t),d(e)?e===_||null==e||""===e?(this._$AH!==_&&this._$AR(),this._$AH=_):e!==this._$AH&&e!==S&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):g(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==_&&d(this._$AH)?this._$AA.nextSibling.data=e:this.T(h.createTextNode(e)),this._$AH=e}$(e){const{values:t,_$litType$:r}=e,s="number"==typeof r?this._$AC(e):(void 0===r.el&&(r.el=R.createElement(T(r.h,r.h[0]),this.options)),r);if(this._$AH?._$AD===s)this._$AH.p(t);else{const e=new U(s,this),r=e.u(this.options);e.p(t),this.T(r),this._$AH=e}}_$AC(e){let t=O.get(e.strings);return void 0===t&&O.set(e.strings,t=new R(e)),t}k(e){p(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let r,s=0;for(const i of e)s===t.length?t.push(r=new D(this.O(u()),this.O(u()),this,this.options)):r=t[s],r._$AI(i),s++;s<t.length&&(this._$AR(r&&r._$AB.nextSibling,s),t.length=s)}_$AR(e=this._$AA.nextSibling,t){for(this._$AP?.(!1,!0,t);e!==this._$AB;){const t=e.nextSibling;e.remove(),e=t}}setConnected(e){void 0===this._$AM&&(this._$Cv=e,this._$AP?.(e))}}class ${get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,r,s,i){this.type=1,this._$AH=_,this._$AN=void 0,this.element=e,this.name=t,this._$AM=s,this.options=i,r.length>2||""!==r[0]||""!==r[1]?(this._$AH=Array(r.length-1).fill(new String),this.strings=r):this._$AH=_}_$AI(e,t=this,r,s){const i=this.strings;let n=!1;if(void 0===i)e=x(this,e,t,0),n=!d(e)||e!==this._$AH&&e!==S,n&&(this._$AH=e);else{const s=e;let o,a;for(e=i[0],o=0;o<i.length-1;o++)a=x(this,s[r+o],t,o),a===S&&(a=this._$AH[o]),n||=!d(a)||a!==this._$AH[o],a===_?e=_:e!==_&&(e+=(a??"")+i[o+1]),this._$AH[o]=a}n&&!s&&this.j(e)}j(e){e===_?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class M extends ${constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===_?void 0:e}}class L extends ${constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==_)}}class j extends ${constructor(e,t,r,s,i){super(e,t,r,s,i),this.type=5}
877_$AI(e,t=this){if((e=x(this,e,t,0)??_)===S)return;const r=this._$AH,s=e===_&&r!==_||e.capture!==r.capture||e.once!==r.once||e.passive!==r.passive,i=e!==_&&(r===_||s);s&&this.element.removeEventListener(this.name,this,r),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){"function"==typeof this._$AH?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class B{constructor(e,t,r){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=r}get _$AU(){return this._$AM._$AU}_$AI(e){x(this,e)}}const q={M:o,P:a,A:c,C:1,L:k,R:U,D:g,V:x,I:D,H:$,N:L,U:j,B:M,F:B};(0,s.litHtmlPolyfillSupport)?.(R,D),(s.litHtmlVersions??=[]).push("3.3.1");const W=(e,t,r)=>{const s=r?.renderBefore??t;let i=s._$litPart$;if(void 0===i){const e=r?.renderBefore??null;s._$litPart$=i=new D(t.insertBefore(u(),e),e,void 0,r??{})}return i._$AI(e),i}},19064:function(e,t,r){"use strict";r.d(t,{oi:function(){return o},iv:function(){return s.iv},dy:function(){return i.dy},YP:function(){return i.YP},$m:function(){return s.$m}});var s=r(23588),i=r(33692);const n=globalThis;class o extends s.fl{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=(0,i.sY)(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return i.Jb}}o._$litElement$=!0,o.finalized=!0,n.litElementHydrateSupport?.({LitElement:o});(0,n.litElementPolyfillSupport)?.({LitElement:o});(n.litElementVersions??=[]).push("4.2.1")}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.