1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[601],{12238:function(e,t,i){"use strict";function r(){return(null===i.g||void 0===i.g?void 0:i.g.crypto)||(null===i.g||void 0===i.g?void 0:i.g.msCrypto)||{}}function s(){let e=r();return e.subtle||e.webkitSubtle}Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowserCryptoAvailable=t.getSubtleCrypto=t.getBrowerCrypto=void 0,t.getBrowerCrypto=r,t.getSubtleCrypto=s,t.isBrowserCryptoAvailable=function(){return!!r()&&!!s()}},33531:function(e,t,i){"use strict";var r=i(40257);function s(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product}function n(){return void 0!==r&&void 0!==r.versions&&void 0!==r.versions.node}Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowser=t.isNode=t.isReactNative=void 0,t.isReactNative=s,t.isNode=n,t.isBrowser=function(){return!s()&&!n()}},13303:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let r=i(45161);r.__exportStar(i(12238),t),r.__exportStar(i(33531),t)},45161:function(e,t,i){"use strict";i.r(t),i.d(t,{__assign:function(){return n},__asyncDelegator:function(){return v},__asyncGenerator:function(){return w},__asyncValues:function(){return E},__await:function(){return b},__awaiter:function(){return h},__classPrivateFieldGet:function(){return O},__classPrivateFieldSet:function(){return P},__createBinding:function(){return u},__decorate:function(){return a},__exportStar:function(){return p},__extends:function(){return s},__generator:function(){return d},__importDefault:function(){return x},__importStar:function(){return I}
vendor: 5,306 bytes, line 1
1,__makeTemplateObject:function(){return _},__metadata:function(){return l},__param:function(){return c},__read:function(){return f},__rest:function(){return o},__spread:function(){return m},__spreadArrays:function(){return y},__values:function(){return g}});var r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};function s(e,t){function i(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var n=function(){return(n=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var s in t=arguments[i])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)};function o(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(i[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)0>t.indexOf(r[s])&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(i[r[s]]=e[r[s]]);return i}function a(e,t,i,r){var s,n=arguments.length,o=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(n<3?s(o):n>3?s(t,i,o):s(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o}function c(e,t){return function(i,r){t(i,r,e)}}function l(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function h(e,t,i,r){return new(i||(i=Promise))(function(s,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function a(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?s(e.value):((t=e.value)instanceof i?t:new i(function(e){e(t)})).then(o,a)}c((r=r.apply(e,t||[])).next())})}function d(e,t){var i,r,s,n,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return n={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function a(n){return function(a){return function(n){if(i)throw TypeError("Generator is already executing.");for(;o;)try{if(i=1,r&&(s=2&n[0]?r.return:n[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,n[1])).done)return s;switch(r=0,s&&(n=[2&n[0],s.value]),n[0]){case 0:case 1:s=n;break;case 4:return o.label++,{value:n[1],done:!1};case 5:o.label++,r=n[1],n=[0];continue;case 7:n=o.ops.pop(),o.trys.pop();continue;default:if(!(s=(s=o.trys).length>0&&s[s.length-1])&&(6===n[0]||2===n[0])){o=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]<s[3])){o.label=n[1];break}if(6===n[0]&&o.label<s[1]){o.label=s[1],s=n;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(n);break}s[2]&&o.ops.pop(),o.trys.pop();continue}n=t.call(e,o)}catch(e){n=[6,e],r=0}finally{i=s=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,a])}}}function u(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}function p(e,t){for(var i in e)"default"===i||t.hasOwnProperty(i)||(t[i]=e[i])}function g(e){var t="function"==typeof Symbol&&Symbol.iterator,i=t&&e[t],r=0;if(i)return i.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function f(e,t){var i="function"==typeof Symbol&&e[Symbol.iterator];if(!i)return e;var r,s,n=i.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=n.next()).done;)o.push(r.value)}catch(e){s={error:e}}finally{try{r&&!r.done&&(i=n.return)&&i.call(n)}finally{if(s)throw s.error}}return o}function m(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(f(arguments[t]));return e}function y(){for(var e=0,t=0,i=arguments.length;t<i;t++)e+=arguments[t].length;for(var r=Array(e),s=0,t=0;t<i;t++)for(var n=arguments[t],o=0,a=n.length;o<a;o++,s++)r[s]=n[o];return r}function b(e){return this instanceof b?(this.v=e,this):new b(e)}function w(e,t,i){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var r,s=i.apply(e,t||[]),n=[];return r={},o("next"),o("throw"),o("return"),r[Symbol.asyncIterator]=function(){return this},r;function o(e){s[e]&&(r[e]=function(t){return new Promise(function(i,r){n.push([e,t,i,r])>1||a(e,t)})})}function a(e,t){try{var i;(i=s[e](t)).value instanceof b?Promise.resolve(i.value.v).then(c,l):h(n[0][2],i)}catch(e){h(n[0][3],e)}}function c(e){a("next",e)}function l(e){a("throw",e)}function h(e,t){e(t),n.shift(),n.length&&a(n[0][0],n[0][1])}}function v(e){var t,i;return t={},r("next"),r("throw",function(e){throw e}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,s){t[r]=e[r]?function(t){return(i=!i)?{value:b(e[r](t)),done:"return"===r}:s?s(t):t}:s}}function E(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,i=e[Symbol.asyncIterator];return i?i.call(e):(e=g(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(i){t[i]=e[i]&&function(t){return new Promise(function(r,s){!function(e,t,i,r){Promise.resolve(r).then(function(t){e({value:t,done:i})},t)}(r,s,(t=e[i](t)).done,t.value)})}}}function _(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}
1function I(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}function x(e){return e&&e.__esModule?e:{default:e}}function O(e,t){if(!t.has(e))throw TypeError("attempted to get private field on non-instance");return t.get(e)}function P(e,t,i){if(!t.has(e))throw TypeError("attempted to set private field on non-instance");return t.set(e,i),i}},17619:function(e,t,i){"use strict";i.r(t),i.d(t,{EthereumProvider:function(){return uj},OPTIONAL_EVENTS:function(){return u_},OPTIONAL_METHODS:function(){return uv},REQUIRED_EVENTS:function(){return uE},REQUIRED_METHODS:function(){return uw},default:function(){return u$}});var r,s,n,o,a,c,l,h,d,u,p,g,f,m,y,b,w,v,E,_,I,x,O,P,S=i(55445),C=i.n(S),R=i(65383),A=i(40537),T=i(76454),N=i(3897),k=i(76548),L=i(80577);function $(e,...t){if(!(e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function j(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}let D="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,M=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);function U(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}(e)),$(e),e}class q{clone(){return this._cloneInto()}}function B(e=32){if(D&&"function"==typeof D.getRandomValues)return D.getRandomValues(new Uint8Array(e));if(D&&"function"==typeof D.randomBytes)return D.randomBytes(e);throw Error("crypto.getRandomValues must be defined")}class z extends q{constructor(e,t,i,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=M(this.buffer)}update(e){j(this);let{view:t,buffer:i,blockLen:r}=this,s=(e=U(e)).length;for(let n=0;n<s;){let o=Math.min(r-this.pos,s-n);if(o===r){let t=M(e);for(;r<=s-n;n+=r)this.process(t,n);continue}i.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){j(this),function(e,t){$(e);let i=t.outputLen;if(e.length<i)throw Error("digestInto() expects output buffer of length at least "+i)}(e,this),this.finished=!0;let{buffer:t,view:i,blockLen:r,isLE:s}=this,{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>r-n&&(this.process(i,0),n=0);for(let e=n;e<r;e++)t[e]=0;(function(e,t,i,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,i,r);let s=BigInt(32),n=BigInt(4294967295),o=Number(i>>s&n),a=Number(i&n),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,a,r)})(i,r-8,BigInt(8*this.length),s),this.process(i,0);let o=M(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen should be aligned to 32bit");let c=a/4,l=this.get();if(c>l.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,l[e],s)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:i,length:r,finished:s,destroyed:n,pos:o}=this;return e.length=r,e.pos=o,e.finished=s,e.destroyed=n,r%t&&e.buffer.set(i),e}}let H=BigInt(4294967296-1),V=BigInt(32),W={split:function(e,t=!1){let i=new Uint32Array(e.length),r=new
1Uint32Array(e.length);for(let s=0;s<e.length;s++){let{h:n,l:o}=function(e,t=!1){return t?{h:Number(e&H),l:Number(e>>V&H)}:{h:0|Number(e>>V&H),l:0|Number(e&H)}}(e[s],t);[i[s],r[s]]=[n,o]}return[i,r]},shrSH:(e,t,i)=>e>>>i,shrSL:(e,t,i)=>e<<32-i|t>>>i,rotrSH:(e,t,i)=>e>>>i|t<<32-i,rotrSL:(e,t,i)=>e<<32-i|t>>>i,rotrBH:(e,t,i)=>e<<64-i|t>>>i-32,rotrBL:(e,t,i)=>e>>>i-32|t<<64-i,add:function(e,t,i,r){let s=(t>>>0)+(r>>>0);return{h:e+i+(s/4294967296|0)|0,l:0|s}},add3L:(e,t,i)=>(e>>>0)+(t>>>0)+(i>>>0),add3H:(e,t,i,r)=>t+i+r+(e/4294967296|0)|0,add4L:(e,t,i,r)=>(e>>>0)+(t>>>0)+(i>>>0)+(r>>>0),add4H:(e,t,i,r,s)=>t+i+r+s+(e/4294967296|0)|0,add5H:(e,t,i,r,s,n)=>t+i+r+s+n+(e/4294967296|0)|0,add5L:(e,t,i,r,s)=>(e>>>0)+(t>>>0)+(i>>>0)+(r>>>0)+(s>>>0)},[K,F]=W.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e3585
15771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),J=new Uint32Array(80),G=new Uint32Array(80);class Y extends z{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){let{Ah:e,Al:t,Bh:i,Bl:r,Ch:s,Cl:n,Dh:o,Dl:a,Eh:c,El:l,Fh:h,Fl:d,Gh:u,Gl:p,Hh:g,Hl:f}=this;return[e,t,i,r,s,n,o,a,c,l,h,d,u,p,g,f]}set(e,t,i,r,s,n,o,a,c,l,h,d,u,p,g,f){this.Ah=0|e,this.Al=0|t,this.Bh=0|i,this.Bl=0|r,this.Ch=0|s,this.Cl=0|n,this.Dh=0|o,this.Dl=0|a,this.Eh=0|c,this.El=0|l,this.Fh=0|h,this.Fl=0|d,this.Gh=0|u,this.Gl=0|p,this.Hh=0|g,this.Hl=0|f}process(e,t){for(let i=0;i<16;i++,t+=4)J[i]=e.getUint32(t),G[i]=e.getUint32(t+=4);for(let e=16;e<80;e++){let t=0|J[e-15],i=0|G[e-15],r=W.rotrSH(t,i,1)^W.rotrSH(t,i,8)^W.shrSH(t,i,7),s=W.rotrSL(t,i,1)^W.rotrSL(t,i,8)^W.shrSL(t,i,7),n=0|J[e-2],o=0|G[e-2],a=W.rotrSH(n,o,19)^W.rotrBH(n,o,61)^W.shrSH(n,o,6),c=W.rotrSL(n,o,19)^W.rotrBL(n,o,61)^W.shrSL(n,o,6),l=W.add4L(s,c,G[e-7],G[e-16]),h=W.add4H(l,r,a,J[e-7],J[e-16]);J[e]=0|h,G[e]=0|l}let{Ah:i,Al:r,Bh:s,Bl:n,Ch:o,Cl:a,Dh:c,Dl:l,Eh:h,El:d,Fh:u,Fl:p,Gh:g,Gl:f,Hh:m,Hl:y}=this;for(let e=0;e<80;e++){let t=W.rotrSH(h,d,14)^W.rotrSH(h,d,18)^W.rotrBH(h,d,41),b=W.rotrSL(h,d,14)^W.rotrSL(h,d,18)^W.rotrBL(h,d,41),w=h&u^~h&g,v=d&p^~d&f,E=W.add5L(y,b,v,F[e],G[e]),_=W.add5H(E,m,t,w,K[e],J[e]),I=0|E,x=W.rotrSH(i,r,28)^W.rotrBH(i,r,34)^W.rotrBH(i,r,39),O=W.rotrSL(i,r,28)^W.rotrBL(i,r,34)^W.rotrBL(i,r,39),P=i&s^i&o^s&o,S=r&n^r&a^n&a;m=0|g,y=0|f,g=0|u,f=0|p,u=0|h,p=0|d,({h:h,l:d}=W.add(0|c,0|l,0|_,0|I)),c=0|o,l=0|a,o=0|s,a=0|n,s=0|i,n=0|r;let C=W.add3L(I,O,S);i=W.add3H(C,_,x,P),r=0|C}({h:i,l:r}=W.add(0|this.Ah,0|this.Al,0|i,0|r)),({h:s,l:n}=W.add(0|this.Bh,0|this.Bl,0|s,0|n)),({h:o,l:a}=W.add(0|this.Ch,0|this.Cl,0|o,0|a)),({h:c,l:l}=W.add(0|this.Dh,0|this.Dl,0|c,0|l)),({h:h,l:d}=W.add(0|this.Eh,0|this.El,0|h,0|d)),({h:u,l:p}=W.add(0|this.Fh,0|this.Fl,0|u,0|p)),({h:g,l:f}=W.add(0|this.Gh,0|this.Gl,0|g,0|f)),({h:m,l:y}=W.add(0|this.Hh,0|this.Hl,0|m,0|y)),this.set(i,r,s,n,o,a,c,l,h,d,u,p,g,f,m,y)}roundClean(){J.fill(0),G.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}let Z=function(e){let t=t=>e().update(U(t)).digest(),i=e();return t.outputLen=i.outputLen,t.blockLen=i.blockLen,t.create=()=>e(),t}(()=>new Y),Q=BigInt(0),X=BigInt(1),ee=BigInt(2);function et(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function ei(e){if(!et(e))throw Error("Uint8Array expected")}function er(e,t){if("boolean"!=typeof t)throw Error(e+" boolean expected, got "+t)}let es=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function en(e){ei(e);let t="";for(let i=0;i<e.length;i++)t+=es[e[i]];return t}function eo(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);return""===e?Q:BigInt("0x"+e)}let ea={_0:48,_9:57,A:65,F:70,a:97,f:102};function ec(e){return e>=ea._0&&e<=ea._9?e-ea._0:e>=ea.A&&e<=ea.F?e-(ea.A-10):e>=ea.a&&e<=ea.f?e-(ea.a-10):void 0}function el(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);let t=e.length,i=t/2;if(t%2)throw Error("hex string expected, got unpadded hex of length "+t);let r=new Uint8Array(i);for(let t=0,s=0;t<i;t++,s+=2){let i=ec(e.charCodeAt(s)),n=ec(e.charCodeAt(s+1));if(void 0===i||void 0===n)throw Error('hex string expected, got non-hex character "'+(e[s]+e[s+1])+'" at index '+s);r[t]=16*i+n}return r}function eh(e){return ei(e),eo(en(Uint8Array.from(e).reverse()))}function ed(e,t){return el(e.toString(16).padStart(2*t,"0"))}function eu(e,t){return ed(e,t).reverse()}function ep(e,t,i){let r;if("string"==typeof t)try{r=el(t)}catch(t){throw Error(e+" must be hex string or Uint8Array, cause: "+t)}else if(et(t))r=Uint8Array.from(t);else throw Error(e+" must be hex string or Uint8Array");let s=r.length;if("number"==typeof i&&s!==i)throw Error(e+" of length "+i+" expected, got "+s);return r}function eg(...e){let t=0;for(let i=0;i<e.length;i++){let r=e[i];ei(r),t+=r.length}let i=new Uint8Array(t);for(let t=0,r=0;t<e.length;t++){let s=e[t];i.set(s,r),r+=s.length}return i}let ef=e=>"bigint"==typeof e&&Q<=e;function em(e,t,i,r){if(!(ef(t)&&ef(i)&&ef(r))||!(i<=t)||!(t<r))throw Error("expected valid "+e+": "+i+" <= n < "+r+", got "+t)}let ey=e=>(ee<<BigInt(e-1))-X,eb={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||et(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 ew(e,t,i={}){let r=(t,i,r)=>{let s=eb[i];if("function"!=typeof s)throw Error("invalid validator function");let n=e[t];if(!(r&&void 0===n)&&!s(n,e))throw Error("param "+String(t)+" is invali
1d. Expected "+i+", got "+n)};for(let[e,i]of Object.entries(t))r(e,i,!1);for(let[e,t]of Object.entries(i))r(e,t,!0);return e}function ev(e){let t=new WeakMap;return(i,...r)=>{let s=t.get(i);if(void 0!==s)return s;let n=e(i,...r);return t.set(i,n),n}}let eE=BigInt(0),e_=BigInt(1),eI=BigInt(2),ex=BigInt(3),eO=BigInt(4),eP=BigInt(5),eS=BigInt(8);function eC(e,t){let i=e%t;return i>=eE?i:t+i}function eR(e,t,i){let r=e;for(;t-- >eE;)r*=r,r%=i;return r}function eA(e,t){if(e===eE)throw Error("invert: expected non-zero number");if(t<=eE)throw Error("invert: expected positive modulus, got "+t);let i=eC(e,t),r=t,s=eE,n=e_;for(;i!==eE;){let e=r/i,t=r%i,o=s-n*e;r=i,i=t,s=n,n=o}if(r!==e_)throw Error("invert: does not exist");return eC(s,t)}let eT=(e,t)=>(eC(e,t)&e_)===e_,eN=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function ek(e,t){let i=void 0!==t?t:e.toString(2).length;return{nBitLength:i,nByteLength:Math.ceil(i/8)}}function eL(e,t,i=!1,r={}){let s;if(e<=eE)throw Error("invalid field: expected ORDER > 0, got "+e);let{nBitLength:n,nByteLength:o}=ek(e,t);if(o>2048)throw Error("invalid field: expected ORDER of <= 2048 bytes");let a=Object.freeze({ORDER:e,isLE:i,BITS:n,BYTES:o,MASK:ey(n),ZERO:eE,ONE:e_,create:t=>eC(t,e),isValid:t=>{if("bigint"!=typeof t)throw Error("invalid field element: expected bigint, got "+typeof t);return eE<=t&&t<e},is0:e=>e===eE,isOdd:e=>(e&e_)===e_,neg:t=>eC(-t,e),eql:(e,t)=>e===t,sqr:t=>eC(t*t,e),add:(t,i)=>eC(t+i,e),sub:(t,i)=>eC(t-i,e),mul:(t,i)=>eC(t*i,e),pow:(e,t)=>(function(e,t,i){if(i<eE)throw Error("invalid exponent, negatives unsupported");if(i===eE)return e.ONE;if(i===e_)return t;let r=e.ONE,s=t;for(;i>eE;)i&e_&&(r=e.mul(r,s)),s=e.sqr(s),i>>=e_;return r})(a,e,t),div:(t,i)=>eC(t*eA(i,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>eA(t,e),sqrt:r.sqrt||(t=>(s||(s=function(e){if(e%eO===ex){let t=(e+e_)/eO;return function(e,i){let r=e.pow(i,t);if(!e.eql(e.sqr(r),i))throw Error("Cannot find square root");return r}}if(e%eS===eP){let t=(e-eP)/eS;return function(e,i){let r=e.mul(i,eI),s=e.pow(r,t),n=e.mul(i,s),o=e.mul(e.mul(n,eI),s),a=e.mul(n,e.sub(o,e.ONE));if(!e.eql(e.sqr(a),i))throw Error("Cannot find square root");return a}}return function(e){let t,i,r;let s=(e-e_)/eI;for(t=e-e_,i=0;t%eI===eE;t/=eI,i++);for(r=eI;r<e&&function(e,t,i){if(t<eE)throw Error("invalid exponent, negatives unsupported");if(i<=eE)throw Error("invalid modulus");if(i===e_)return eE;let r=e_;for(;t>eE;)t&e_&&(r=r*e%i),e=e*e%i,t>>=e_;return r}(r,s,e)!==e-e_;r++)if(r>1e3)throw Error("Cannot find square root: likely non-prime P");if(1===i){let t=(e+e_)/eO;return function(e,i){let r=e.pow(i,t);if(!e.eql(e.sqr(r),i))throw Error("Cannot find square root");return r}}let n=(t+e_)/eI;return function(e,o){if(e.pow(o,s)===e.neg(e.ONE))throw Error("Cannot find square root");let a=i,c=e.pow(e.mul(e.ONE,r),t),l=e.pow(o,n),h=e.pow(o,t);for(;!e.eql(h,e.ONE);){if(e.eql(h,e.ZERO))return e.ZERO;let t=1;for(let i=e.sqr(h);t<a&&!e.eql(i,e.ONE);t++)i=e.sqr(i);let i=e.pow(c,e_<<BigInt(a-t-1));c=e.sqr(i),l=e.mul(l,i),h=e.mul(h,c),a=t}return l}}(e)}(e)),s(a,t))),invertBatch:e=>(function(e,t){let i=Array(t.length),r=t.reduce((t,r,s)=>e.is0(r)?t:(i[s]=t,e.mul(t,r)),e.ONE),s=e.inv(r);return t.reduceRight((t,r,s)=>e.is0(r)?t:(i[s]=e.mul(t,i[s]),e.mul(t,r)),s),i})(a,e),cmov:(e,t,i)=>i?t:e,toBytes:e=>i?eu(e,o):ed(e,o),fromBytes:e=>{if(e.length!==o)throw Error("Field.fromBytes: expected "+o+" bytes, got "+e.length);return i?eh(e):eo(en(e))}});return Object.freeze(a)}let e$=BigInt(0),ej=BigInt(1);function eD(e,t){let i=t.negate();return e?i:t}function eM(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw Error("invalid window size, expected [1.."+t+"], got W="+e)}function eU(e,t){return eM(e,t),{windows:Math.ceil(t/e)+1,windowSize:2**(e-1)}}let eq=new WeakMap,eB=new WeakMap;function ez(e){return eB.get(e)||1}let eH=BigInt(0),eV=BigInt(1),eW=BigInt(2),eK=BigInt(8),eF={zip215:!0};BigInt(0),BigInt(1);let eJ=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),eG=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);let eY=BigInt(1),eZ=BigInt(2);BigInt(3);let eQ=BigInt(5),eX=BigInt(8),e0=eL(eJ,void 0,!0),e1=function(e){var t;let i=function(e){let t=(ew(e.Fp,eN.reduce((e,t)=>
1(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),ew(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...ek(e.n,e.nBitLength),...e,p:e.Fp.ORDER}));return ew(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:r,n:s,prehash:n,hash:o,randomBytes:a,nByteLength:c,h:l}=i,h=eW<<BigInt(8*c)-eV,d=r.create,u=eL(i.n,i.nBitLength),p=i.uvRatio||((e,t)=>{try{return{isValid:!0,value:r.sqrt(e*r.inv(t))}}catch{return{isValid:!1,value:eH}}}),g=i.adjustScalarBytes||(e=>e),f=i.domain||((e,t,i)=>{if(er("phflag",i),t.length||i)throw Error("Contexts/pre-hash are not supported");return e});function m(e,t){em("coordinate "+e,t,eH,h)}function y(e){if(!(e instanceof v))throw Error("ExtendedPoint expected")}let b=ev((e,t)=>{let{ex:i,ey:s,ez:n}=e,o=e.is0();null==t&&(t=o?eK:r.inv(n));let a=d(i*t),c=d(s*t),l=d(n*t);if(o)return{x:eH,y:eV};if(l!==eV)throw Error("invZ was invalid");return{x:a,y:c}}),w=ev(e=>{let{a:t,d:r}=i;if(e.is0())throw Error("bad point: ZERO");let{ex:s,ey:n,ez:o,et:a}=e,c=d(s*s),l=d(n*n),h=d(o*o),u=d(h*h),p=d(c*t);if(d(h*d(p+l))!==d(u+d(r*d(c*l))))throw Error("bad point: equation left != right (1)");if(d(s*n)!==d(o*a))throw Error("bad point: equation left != right (2)");return!0});class v{constructor(e,t,i,r){this.ex=e,this.ey=t,this.ez=i,this.et=r,m("x",e),m("y",t),m("z",i),m("t",r),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof v)throw Error("extended point not allowed");let{x:t,y:i}=e||{};return m("x",t),m("y",i),new v(t,i,eV,d(t*i))}static normalizeZ(e){let t=r.invertBatch(e.map(e=>e.ez));return e.map((e,i)=>e.toAffine(t[i])).map(v.fromAffine)}static msm(e,t){return function(e,t,i,r){if(function(e,t){if(!Array.isArray(e))throw Error("array expected");e.forEach((e,i)=>{if(!(e instanceof t))throw Error("invalid point at index "+i)})}(i,e),function(e,t){if(!Array.isArray(e))throw Error("array of scalars expected");e.forEach((e,i)=>{if(!t.isValid(e))throw Error("invalid scalar at index "+i)})}(r,t),i.length!==r.length)throw Error("arrays of points and scalars must have equal length");let s=e.ZERO,n=function(e){let t;for(t=0;e>Q;e>>=X,t+=1);return t}(BigInt(i.length)),o=n>12?n-3:n>4?n-2:n?2:1,a=(1<<o)-1,c=Array(a+1).fill(s),l=Math.floor((t.BITS-1)/o)*o,h=s;for(let e=l;e>=0;e-=o){c.fill(s);for(let t=0;t<r.length;t++){let s=Number(r[t]>>BigInt(e)&BigInt(a));c[s]=c[s].add(i[t])}let t=s;for(let e=c.length-1,i=s;e>0;e--)i=i.add(c[e]),t=t.add(i);if(h=h.add(t),0!==e)for(let e=0;e<o;e++)h=h.double()}return h}(v,u,e,t)}_setWindowSize(e){I.setWindowSize(this,e)}assertValidity(){w(this)}equals(e){y(e);let{ex:t,ey:i,ez:r}=this,{ex:s,ey:n,ez:o}=e,a=d(t*o),c=d(s*r),l=d(i*o),h=d(n*r);return a===c&&l===h}is0(){return this.equals(v.ZERO)}negate(){return new v(d(-this.ex),this.ey,this.ez,d(-this.et))}double(){let{a:e}=i,{ex:t,ey:r,ez:s}=this,n=d(t*t),o=d(r*r),a=d(eW*d(s*s)),c=d(e*n),l=t+r,h=d(d(l*l)-n-o),u=c+o,p=u-a,g=c-o,f=d(h*p),m=d(u*g),y=d(h*g);return new v(f,m,d(p*u),y)}add(e){y(e);let{a:t,d:r}=i,{ex:s,ey:n,ez:o,et:a}=this,{ex:c,ey:l,ez:h,et:u}=e;if(t===BigInt(-1)){let e=d((n-s)*(l+c)),t=d((n+s)*(l-c)),i=d(t-e);if(i===eH)return this.double();let r=d(o*eW*u),p=d(a*eW*h),g=p+r,f=t+e,m=p-r,y=d(g*i),b=d(f*m),w=d(g*m);return new v(y,b,d(i*f),w)}let p=d(s*c),g=d(n*l),f=d(a*r*u),m=d(o*h),b=d((s+n)*(c+l)-p-g),w=m-f,E=m+f,_=d(g-t*p),I=d(b*w),x=d(E*_),O=d(b*_);return new v(I,x,d(w*E),O)}subtract(e){return this.add(e.negate())}wNAF(e){return I.wNAFCached(this,e,v.normalizeZ)}multiply(e){em("scalar",e,eV,s);let{p:t,f:i}=this.wNAF(e);return v.normalizeZ([t,i])[0]}multiplyUnsafe(e,t=v.ZERO){return em("scalar",e,eH,s),e===eH?_:this.is0()||e===eV?this:I.wNAFCachedUnsafe(this,e,v.normalizeZ,t)}isSmallOrder(){return this.multiplyUnsafe(l).is0()}isTorsionFree(){return I.unsafeLadder(this,s).is0()}toAffine(e){return b(this,e)}clearCofactor(){let{h:e}=i;return e===eV?this:this.multiplyUnsafe(e)}static fromHex(e,t=!1){let{d:s,a:n}=i,o=r.BYTES;e=ep("pointHex",e,o),er("zip215",t);let a=e.slice(),c=e[o-1];a[o-1]=-129&c;let l=eh(a);em("pointHex.y",l,eH,t?h:r.ORDER);let u=d(l*l),{isValid:g,value:f}=p(d(u-eV),d(s*u-n));
1if(!g)throw Error("Point.fromHex: invalid y coordinate");let m=(f&eV)===eV,y=(128&c)!=0;if(!t&&f===eH&&y)throw Error("Point.fromHex: x=0 and x_0=1");return y!==m&&(f=d(-f)),v.fromAffine({x:f,y:l})}static fromPrivateKey(e){return x(e).point}toRawBytes(){let{x:e,y:t}=this.toAffine(),i=eu(t,r.BYTES);return i[i.length-1]|=e&eV?128:0,i}toHex(){return en(this.toRawBytes())}}v.BASE=new v(i.Gx,i.Gy,eV,d(i.Gx*i.Gy)),v.ZERO=new v(eH,eV,eV,eH);let{BASE:E,ZERO:_}=v,I=(t=8*c,{constTimeNegate:eD,hasPrecomputes:e=>1!==ez(e),unsafeLadder(e,t,i=v.ZERO){let r=e;for(;t>e$;)t&ej&&(i=i.add(r)),r=r.double(),t>>=ej;return i},precomputeWindow(e,i){let{windows:r,windowSize:s}=eU(i,t),n=[],o=e,a=o;for(let e=0;e<r;e++){a=o,n.push(a);for(let e=1;e<s;e++)a=a.add(o),n.push(a);o=a.double()}return n},wNAF(e,i,r){let{windows:s,windowSize:n}=eU(e,t),o=v.ZERO,a=v.BASE,c=BigInt(2**e-1),l=2**e,h=BigInt(e);for(let e=0;e<s;e++){let t=e*n,s=Number(r&c);r>>=h,s>n&&(s-=l,r+=ej);let d=t+Math.abs(s)-1,u=e%2!=0,p=s<0;0===s?a=a.add(eD(u,i[t])):o=o.add(eD(p,i[d]))}return{p:o,f:a}},wNAFUnsafe(e,i,r,s=v.ZERO){let{windows:n,windowSize:o}=eU(e,t),a=BigInt(2**e-1),c=2**e,l=BigInt(e);for(let e=0;e<n;e++){let t=e*o;if(r===e$)break;let n=Number(r&a);if(r>>=l,n>o&&(n-=c,r+=ej),0===n)continue;let h=i[t+Math.abs(n)-1];n<0&&(h=h.negate()),s=s.add(h)}return s},getPrecomputes(e,t,i){let r=eq.get(t);return r||(r=this.precomputeWindow(t,e),1!==e&&eq.set(t,i(r))),r},wNAFCached(e,t,i){let r=ez(e);
1return this.wNAF(r,this.getPrecomputes(r,e,i),t)},wNAFCachedUnsafe(e,t,i,r){let s=ez(e);return 1===s?this.unsafeLadder(e,t,r):this.wNAFUnsafe(s,this.getPrecomputes(s,e,i),t,r)},setWindowSize(e,i){eM(i,t),eB.set(e,i),eq.delete(e)}});function x(e){let t=r.BYTES;e=ep("private key",e,t);let i=ep("hashed private key",o(e),2*t),n=g(i.slice(0,t)),a=i.slice(t,2*t),c=eC(eh(n),s),l=E.multiply(c),h=l.toRawBytes();return{head:n,prefix:a,scalar:c,point:l,pointBytes:h}}function O(e=new Uint8Array,...t){return eC(eh(o(f(eg(...t),ep("context",e),!!n))),s)}return E._setWindowSize(8),{CURVE:i,getPublicKey:function(e){return x(e).pointBytes},sign:function(e,t,i={}){e=ep("message",e),n&&(e=n(e));let{prefix:o,scalar:a,pointBytes:c}=x(t),l=O(i.context,o,e),h=E.multiply(l).toRawBytes(),d=eC(l+O(i.context,h,c,e)*a,s);return em("signature.s",d,eH,s),ep("result",eg(h,eu(d,r.BYTES)),2*r.BYTES)},verify:function(e,t,i,s=eF){let o,a,c;let{context:l,zip215:h}=s,d=r.BYTES;e=ep("signature",e,2*d),t=ep("message",t),i=ep("publicKey",i,d),void 0!==h&&er("zip215",h),n&&(t=n(t));let u=eh(e.slice(d,2*d));try{o=v.fromHex(i,h),a=v.fromHex(e.slice(0,d),h),c=E.multiplyUnsafe(u)}catch{return!1}if(!h&&o.isSmallOrder())return!1;let p=O(l,a.toRawBytes(),o.toRawBytes(),t);return a.add(o.multiplyUnsafe(p)).subtract(c).clearCofactor().equals(v.ZERO)},ExtendedPoint:v,utils:{getExtendedPublicKey:x,randomPrivateKey:()=>a(r.BYTES),precompute:(e=8,t=v.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)}}}({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:e0,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:eX,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:Z,randomBytes:B,adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},uvRatio:function(e,t){let i=eC(t*t*t,eJ),r=function(e){let t=BigInt(10),i=BigInt(20),r=BigInt(40),s=BigInt(80),n=e*e%eJ*e%eJ,o=eR(n,eZ,eJ)*n%eJ,a=eR(o,eY,eJ)*e%eJ,c=eR(a,eQ,eJ)*a%eJ,l=eR(c,t,eJ)*c%eJ,h=eR(l,i,eJ)*l%eJ,d=eR(h,r,eJ)*h%eJ,u=eR(d,s,eJ)*d%eJ,p=eR(u,s,eJ)*d%eJ,g=eR(p,t,eJ)*c%eJ;return{pow_p_5_8:eR(g,eZ,eJ)*e%eJ,b2:n}}(e*eC(i*i*t,eJ)).pow_p_5_8,s=eC(e*i*r,eJ),n=eC(t*s*s,eJ),o=s,a=eC(s*eG,eJ),c=n===e,l=n===eC(-e,eJ),h=n===eC(-e*eG,eJ);return c&&(s=o),(l||h)&&(s=a),eT(s,eJ)&&(s=eC(-s,eJ)),{isValid:c||l,value:s}}}),e2="base64url",e5="utf8",e3="utf8",e4="base58btc";function e8(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function e6(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?e8(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function e7(e,t){t||(t=e.reduce((e,t)=>e+t.length,0));let i=e6(t),r=0;for(let t of e)i.set(t,r),r+=t.length;return e8(i)}var e9=function(e,t){if(e.length>=255)throw TypeError("Alphabet too long");for(var i=new Uint8Array(256),r=0;r<i.length;r++)i[r]=255;for(var s=0;s<e.length;s++){var n=e.charAt(s),o=n.charCodeAt(0);if(255!==i[o])throw TypeError(n+" is ambiguous");i[o]=s}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function d(e){if("string"!=typeof e)throw TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[0]){for(var r=0,s=0;e[t]===c;)r++,t++;for(var n=(e.length-t)*l+1>>>0,o=new Uint8Array(n);e[t];){var h=i[e.charCodeAt(t)];if(255===h)return;for(var d=0,u=n-1;(0!==h||d<s)&&-1!==u;u--,d++)h+=a*o[u]>>>0,o[u]=h%256>>>0,h=h/256>>>0;if(0!==h)throw Error("Non-zero carry");s=d,t++}if(" "!==e[t]){for(var p=n-s;p!==n&&0===o[p];)p++;for(var g=new Uint8Array(r+(n-p)),f=r;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 TypeError("Expected Uint8Array");if(0===t.length)return"";for(var i=0,r=0,s=0,n=t.length;s!==n&&0===t[s];)s++,i++;for(var o=(n-s)*h+1>>>0,l=new Uint8Array(o);s!==n;){for(var d=t[s],u=0,p=o-1;(0!==d||u<r)&&-1!==p;p--,u++)d+=256*l[p]>>>0,l[p]=d%a>>>0,d=d/a>>>0;if(0!==d)throw Error("Non-zero carry");r=u,s++}for(var g=o-r;g!==o&&0===l[g];)g++;for(var f=c.repeat(i);g<o;++g)f+=e.charAt(l[g]);return f},decodeUnsafe:d,decode:function(e){var i=d(e);if(i)return i;throw Error(`Non-${t} character`)}}};let te=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 Error("Unknown type, must be binary type")},tt=e=>new TextEncoder().encode(e),ti=e=>
1new TextDecoder().decode(e);class tr{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class ts{constructor(e,t,i){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}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 to(this,e)}}class tn{constructor(e){this.decoders=e}or(e){return to(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}let to=(e,t)=>new tn({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class ta{constructor(e,t,i,r){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=r,this.encoder=new tr(e,t,i),this.decoder=new ts(e,t,r)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}let tc=({name:e,prefix:t,encode:i,decode:r})=>new ta(e,t,i,r),tl=({prefix:e,name:t,alphabet:i})=>{let{encode:r,decode:s}=e9(i,t);return tc({prefix:e,name:t,encode:r,decode:e=>te(s(e))})},th=(e,t,i,r)=>{let s={};for(let e=0;e<t.length;++e)s[t[e]]=e;let n=e.length;for(;"="===e[n-1];)--n;let o=new Uint8Array(n*i/8|0),a=0,c=0,l=0;for(let t=0;t<n;++t){let n=s[e[t]];if(void 0===n)throw SyntaxError(`Non-${r} character`);c=c<<i|n,(a+=i)>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=i||255&c<<8-a)throw SyntaxError("Unexpected end of data");return o},td=(e,t,i)=>{let r="="===t[t.length-1],s=(1<<i)-1,n="",o=0,a=0;for(let r=0;r<e.length;++r)for(a=a<<8|e[r],o+=8;o>i;)o-=i,n+=t[s&a>>o];if(o&&(n+=t[s&a<<i-o]),r)for(;n.length*i&7;)n+="=";return n},tu=({name:e,prefix:t,bitsPerChar:i,alphabet:r})=>tc({prefix:t,name:e,encode:e=>td(e,r,i),decode:t=>th(t,r,i,e)});var tp=Object.freeze({__proto__:null,identity:tc({prefix:"\0",name:"identity",encode:e=>ti(e),decode:e=>tt(e)})}),tg=Object.freeze({__proto__:null,base2:tu({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1})}),tf=Object.freeze({__proto__:null,base8:tu({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3})}),tm=Object.freeze({__proto__:null,base10:tl({prefix:"9",name:"base10",alphabet:"0123456789"})}),ty=Object.freeze({__proto__:null,base16:tu({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper:tu({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4})});let tb=tu({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),tw=tu({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),tv=tu({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),tE=tu({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),t_=tu({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),tI=tu({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5});var tx=Object.freeze({__proto__:null,base32:tb,base32upper:tw,base32pad:tv,base32padupper:tE,base32hex:t_,base32hexupper:tI,base32hexpad:tu({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper:tu({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z:tu({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5})}),tO=Object.freeze({__proto__:null,base36:tl({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper:tl({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"})}),tP=Object.freeze({__proto__:null,base58btc:tl({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr:tl({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"})});let tS=tu({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
1+/",bitsPerChar:6});var tC=Object.freeze({__proto__:null,base64:tS,base64pad:tu({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url:tu({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad:tu({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6})});let tR=Array.from("\uD83D\uDE80\uD83E\uDE90â\uD83D\uDEF0\uD83C\uDF0C\uD83C\uDF11\uD83C\uDF12\uD83C\uDF13\uD83C\uDF14\uD83C\uDF15\uD83C\uDF16\uD83C\uDF17\uD83C\uDF18\uD83C\uDF0D\uD83C\uDF0F\uD83C\uDF0E\uD83D\uDC09â\uD83D\uDCBB\uD83D\uDDA5\uD83D\uDCBE\uD83D\uDCBF\uD83D\uDE02â¤\uD83D\uDE0D\uD83E\uDD23\uD83D\uDE0A\uD83D\uDE4F\uD83D\uDC95\uD83D\uDE2D\uD83D\uDE18\uD83D\uDC4D\uD83D\uDE05\uD83D\uDC4F\uD83D\uDE01\uD83D\uDD25\uD83E\uDD70\uD83D\uDC94\uD83D\uDC96\uD83D\uDC99\uD83D\uDE22\uD83E\uDD14\uD83D\uDE06\uD83D\uDE44\uD83D\uDCAA\uD83D\uDE09âº\uD83D\uDC4C\uD83E\uDD17\uD83D\uDC9C\uD83D\uDE14\uD83D\uDE0E\uD83D\uDE07\uD83C\uDF39\uD83E\uDD26\uD83C\uDF89\uD83D\uDC9Eââ¨\uD83E\uDD37\uD83D\uDE31\uD83D\uDE0C\uD83C\uDF38\uD83D\uDE4C\uD83D\uDE0B\uD83D\uDC97\uD83D\uDC9A\uD83D\uDE0F\uD83D\uDC9B\uD83D\uDE42\uD83D\uDC93\uD83E\uDD29\uD83D\uDE04\uD83D\uDE00\uD83D\uDDA4\uD83D\uDE03\uD83D\uDCAF\uD83D\uDE48\uD83D\uDC47\uD83C\uDFB6\uD83D\uDE12\uD83E\uDD2Dâ£\uD83D\uDE1C\uD83D\uDC8B\uD83D\uDC40\uD83D\uDE2A\uD83D\uDE11\uD83D\uDCA5\uD83D\uDE4B\uD83D\uDE1E\uD83D\uDE29\uD83D\uDE21\uD83E\uDD2A\uD83D\uDC4A\uD83E\uDD73\uD83D\uDE25\uD83E\uDD24\uD83D\uDC49\uD83D\uDC83\uD83D\uDE33â\uD83D\uDE1A\uD83D\uDE1D\uD83D\uDE34\uD83C\uDF1F\uD83D\uDE2C\uD83D\uDE43\uD83C\uDF40\uD83C\uDF37\uD83D\uDE3B\uD83D\uDE13ââ
\uD83E\uDD7A\uD83C\uDF08\uD83D\uDE08\uD83E\uDD18\uD83D\uDCA6â\uD83D\uDE23\uD83C\uDFC3\uD83D\uDC90â¹\uD83C\uDF8A\uD83D\uDC98\uD83D\uDE20â\uD83D\uDE15\uD83C\uDF3A\uD83C\uDF82\uD83C\uDF3B\uD83D\uDE10\uD83D\uDD95\uD83D\uDC9D\uD83D\uDE4A\uD83D\uDE39\uD83D\uDDE3\uD83D\uDCAB\uD83D\uDC80\uD83D\uDC51\uD83C\uDFB5\uD83E\uDD1E\uD83D\uDE1B\uD83D\uDD34\uD83D\uDE24\uD83C\uDF3C\uD83D\uDE2Bâ½\uD83E\uDD19â\uD83C\uDFC6\uD83E\uDD2B\uD83D\uDC48\uD83D\uDE2E\uD83D\uDE46\uD83C\uDF7B\uD83C\uDF43\uD83D\uDC36\uD83D\uDC81\uD83D\uDE32\uD83C\uDF3F\uD83E\uDDE1\uD83C\uDF81â¡\uD83C\uDF1E\uD83C\uDF88ââ\uD83D\uDC4B\uD83D\uDE30\uD83E\uDD28\uD83D\uDE36\uD83E\uDD1D\uD83D\uDEB6\uD83D\uDCB0\uD83C\uDF53\uD83D\uDCA2\uD83E\uDD1F\uD83D\uDE41\uD83D\uDEA8\uD83D\uDCA8\uD83E\uDD2Câ\uD83C\uDF80\uD83C\uDF7A\uD83E\uDD13\uD83D\uDE19\uD83D\uDC9F\uD83C\uDF31\uD83D\uDE16\uD83D\uDC76\uD83E\uDD74â¶â¡â\uD83D\uDC8E\uD83D\uDCB8â¬\uD83D\uDE28\uD83C\uDF1A\uD83E\uDD8B\uD83D\uDE37\uD83D\uDD7Aâ \uD83D\uDE45\uD83D\uDE1F\uD83D\uDE35\uD83D\uDC4E\uD83E\uDD32\uD83E\uDD20\uD83E\uDD27\uD83D\uDCCC\uD83D\uDD35\uD83D\uDC85\uD83E\uDDD0\uD83D\uDC3E\uD83C\uDF52\uD83D\uDE17\uD83E\uDD11\uD83C\uDF0A\uD83E\uDD2F\uD83D\uDC37â\uD83D\uDCA7\uD83D\uDE2F\uD83D\uDC86\uD83D\uDC46\uD83C\uDFA4\uD83D\uDE47\uD83C\uDF51â\uD83C\uDF34\uD83D\uDCA3\uD83D\uDC38\uD83D\uDC8C\uD83D\uDCCD\uD83E\uDD40\uD83E\uDD22\uD83D\uDC45\uD83D\uDCA1\uD83D\uDCA9\uD83D\uDC50\uD83D\uDCF8\uD83D\uDC7B\uD83E\uDD10\uD83E\uDD2E\uD83C\uDFBC\uD83E\uDD75\uD83D\uDEA9\uD83C\uDF4E\uD83C\uDF4A\uD83D\uDC7C\uD83D\uDC8D\uD83D\uDCE3\uD83E\uDD42"),tA=tR.reduce((e,t,i)=>(e[i]=t,e),[]),tT=tR.reduce((e,t,i)=>(e[t.codePointAt(0)]=i,e),[]);var tN=Object.freeze({__proto__:null,base256emoji:tc({prefix:"\uD83D\uDE80",name:"base256emoji",encode:function(e){return e.reduce((e,t)=>e+=tA[t],"")},decode:function(e){let t=[];for(let i of e){let e=tT[i.codePointAt(0)];if(void 0===e)throw Error(`Non-base256emoji character: ${i}`);t.push(e)}return new Uint8Array(t)}})});function tk(e,t){var i,r=0,t=t||0,s=0,n=t,o=e.length;do{if(n>=o)throw tk.bytes=0,RangeError("Could not decode varint");i=e[n++],r+=s<28?(127&i)<<s:(127&i)*Math.pow(2,s),s+=7}while(i>=128);return tk.bytes=n-t,r}var tL=function e(t,i,r){i=i||[],r=r||0;for(var s=r;t>=2147483648;)i[r++]=255&t|128,t/=128;for(;-128&t;)i[r++]=255&t|128,t>>>=7;return i[r]=0|t,e.bytes=r-s+1,i};let t$=(e,t,i=0)=>(tL(e,t,i),t),tj=e=>e<128?1:e<16384?2:e<2097152?3:e<268435456?4:e<34359738368?5:e<4398046511104?6:e<562949953421312?7:e<72057594037927940?8:e<0x7fffffffffffffff?9:10,tD=(e,t)=>{let i=t.byteLength,r=tj(e),s=r+tj(i),n=new Uint8Array(s+i);return t$(e,n,0),t$(i,n,r),n.set(t,s),new tM(e,i,t,n)};
1class tM{constructor(e,t,i,r){this.code=e,this.size=t,this.digest=i,this.bytes=r}}let tU=({name:e,code:t,encode:i})=>new tq(e,t,i);class tq{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?tD(this.code,t):t.then(e=>tD(this.code,e))}throw Error("Unknown type, must be binary type")}}let tB=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t));var tz=Object.freeze({__proto__:null,sha256:tU({name:"sha2-256",code:18,encode:tB("SHA-256")}),sha512:tU({name:"sha2-512",code:19,encode:tB("SHA-512")})}),tH=Object.freeze({__proto__:null,identity:{code:0,name:"identity",encode:te,digest:e=>tD(0,te(e))}});new TextEncoder,new TextDecoder;let tV={...tp,...tg,...tf,...tm,...ty,...tx,...tO,...tP,...tC,...tN};function tW(e,t,i,r){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:i},decoder:{decode:r}}}({...tz,...tH});let tK=tW("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),tF=tW("ascii","a",e=>{let t="a";for(let i=0;i<e.length;i++)t+=String.fromCharCode(e[i]);return t},e=>{let t=e6((e=e.substring(1)).length);for(let i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}),tJ={utf8:tK,"utf-8":tK,hex:tV.base16,latin1:tF,ascii:tF,binary:tF,...tV};function tG(e,t="utf8"){let i=tJ[t];if(!i)throw Error(`Unsupported encoding "${t}"`);return("utf8"===t||"utf-8"===t)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):i.encoder.encode(e).substring(1)}function tY(e,t="utf8"){let i=tJ[t];if(!i)throw Error(`Unsupported encoding "${t}"`);return("utf8"===t||"utf-8"===t)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?e8(globalThis.Buffer.from(e,"utf-8")):i.decoder.decode(`${i.prefix}${e}`)}function tZ(e){return(0,L.D)(tG(tY(e,e2),e5))}function tQ(e){return tG(tY((0,L.u)(e),e5),e2)}function tX(e){return["did","key","z"+tG(e7([tY("K36",e4),e]),e4)].join(":")}function t0(e){let t=e.split("."),i=tZ(t[0]);return{header:i,payload:tZ(t[1]),signature:tY(t[2],e2),data:tY(t.slice(0,2).join("."),e3)}}function t1(e=B(32)){let t=e1.getPublicKey(e);return{secretKey:e7([e,t]),publicKey:t}}async function t2(e,t,i,r,s=(0,A.fromMiliseconds)(Date.now())){var n,o;let a={alg:"EdDSA",typ:"JWT"},c={iss:tX(r.publicKey),sub:e,aud:t,iat:s,exp:s+i},l=tY([tQ((n={header:a,payload:c}).header),tQ(n.payload)].join("."),e3);return[tQ((o={header:a,payload:c,signature:e1.sign(l,r.secretKey.slice(0,32))}).header),tQ(o.payload),tG(o.signature,e2)].join(".")}var t5=i(6208),t3=i(61984);let t4={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var t8=i(40257),t6=i(82957).Buffer;function t7(e){let[t,i]=e.split(":");return{namespace:t,reference:i}}function t9(e,t=[]){let i=[];return Object.keys(e).forEach(r=>{if(t.length&&!t.includes(r))return;let s=e[r];i.push(...s.accounts)}),i}function ie(e,t){return e.includes(":")?[e]:t.chains||[]}let it={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};function ii(){return"u">typeof t8&&"u">typeof t8.versions&&"u">typeof t8.versions.node}function ir(){return!(0,T.getDocument)()&&!!(0,T.getNavigator)()&&"ReactNative"===navigator.product}function is(){return!ii()&&!!(0,T.getNavigator)()&&!!(0,T.getDocument)()}function io(){return ir()?it.reactNative:ii()?it.node:is()?it.browser:it.unknown}function ia(){var e;try{return ir()&&"u">typeof i.g&&"u">typeof(null==i.g?void 0:i.g.Application)?null==(e=i.g.Application)?void 0:e.applicationId:void 0}catch{return}}function ic(){return(0,N.D)()||{name:"",description:"",url:"",icons:[""]}}function il(e,t,r){let s=function(){if(io()===it.reactNative&&"u">typeof i.g&&"u">typeof(null==i.g?void 0:i.g.Platform)){let{OS:e,Version:t}=i.g.Platform;return[e,t].join("-")}let e=(0,R.qY)();if(null===e)return"unknown";let 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;let t=io();return t===it.browser?[t,(null==(e=(0,T.getLocation)())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),["js",r].join("-"),s,n].join("/")}function ih(e,t){return e.filter(e=>t.includes(e)).length===e.length}function id(e){return Object.fromEntries(e.entries())}function iu(e){return new Map(Object.entries(e))}function ip(e=A.FIVE_MINUTES,t){let i,r,s,n;let o=(0,A.toMiliseconds)(e||A.FIVE_MINUTES);return{resolve:e=>{s&&i&&(clearTimeout(s),i(e),n=Promise.resolve(e))},reject:e=>{s&&r&&(clearTimeout(s),r(e))},done:()=>new Promise((e,a)=>{if(n)return e(n);s=setTimeout(()=>{let e=Error(t);n=Promise.reject(e),a(e)},o),i=e,r=a})}}function ig(e,t,i){return new Promise(async(r,s)=>{let n=setTimeout(()=>s(Error(i)),t);try{let t=await e;r(t)}catch(e){s(e)}clearTimeout(n)})}function im(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw Error(`Unknown expirer target type: ${e}`)}function iy(e){let[t,i]=e.split(":"),r={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof i)r.topic=i;else if("id"===t&&Number.isInteger(Number(i)))r.id=Number(i);else throw Error(`Invalid target, expected id:number or topic:string, got ${t}:${i}`);return r}function ib(e,t){return(0,A.fromMiliseconds)((t||Date.now())+(0,A.toMiliseconds)(e))}function iw(e){return Date.now()>=(0,A.toMiliseconds)(e)}function iv(e,t){return`${e}${t?`:${t}`:""}`}function iE(e=[],t=[]){return[...new Set([...e,...t])]}async function i_({id:e,topic:t,wcDeepLink:r}){var s;try{if(!r)return;let n="string"==typeof r?JSON.parse(r):r,o=n?.href;if("string"!=typeof o)return;let a=function(e,t,i){let r=`requestId=${t}&sessionTopic=${i}`;e.endsWith("/")&&(e=e.slice(0,-1));let s=`${e}`;if(e.startsWith("https://t.me")){let t=e.includes("?")?"&startapp=":"?startapp=";s=`${s}${t}${function(e,t=!1){let i=t6.from(e).toString("base64");return t?i.replace(/[=]/g,""):i}(r,!0)}`}else s=`${s}/wc?${r}`;return s}(o,e,t),c=io();if(c===it.browser){let e;if(!(null!=(s=(0,T.getDocument)())&&s.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}e="_self",function(){try{return window.self!==window.top}catch{return!1}}()?e="_top":("u">typeof window&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)||a.startsWith("https://")||a.startsWith("http://"))&&(e="_blank"),window.open(a,e,"noreferrer noopener")}else c===it.reactNative&&"u">typeof(null==i.g?void 0:i.g.Linking)&&await i.g.Linking.openURL(a)}catch(e){console.error(e)}}async function iI(e,t){let i="";try{if(is()&&(i=localStorage.getItem(t)))return i;i=await e.getItem(t)}catch(e){console.error(e)}return i}function ix(e,t){if(!e.includes(t))return null;let i=e.split(/([&,?,=])/),r=i.indexOf(t);return i[r+2]}function iO(){return"u">typeof crypto&&null!=crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,e=>{let t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function iP(){return"u">typeof t8&&"true"===t8.env.IS_VITEST}function iS(e){return t6.from(e,"base64").toString("utf-8")}function iC(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, got "+e)}function iR(e,...t){if(!(e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function iA(e){if("function"!=typeof e||"function"!=typeof e.create)throw Error("Hash should be wrapped by utils.wrapConstructor");iC(e.outputLen),iC(e.blockLen)}function iT(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function iN(e,t){iR(e);let i=t.outputLen;if(e.length<i)throw Error("digestInto() expects output buffer of length at least "+i)}let ik=BigInt(4294967296-1),iL=BigInt(32),i$=(e,t,i)=>e<<i|t>>>32-i,ij=(e,t,i)=>t<<i|e>>>32-i,iD=(e,t,i)=>t<<i-32|e>>>64-i,iM=(e,t,i)=>e<<i-32|t>>>64-i,iU="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function iq(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function iB(e,t){return e<<32-t|e>>>t}let iz=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function iH(e){for(let i=0;i<e.length;i++){var t;e[i]=(t=e[i])<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}}function iV(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array(new TextEncoder().encode(e))}(e)),iR(e),e}class iW{clone(){return this._cloneInto()}}function iK(e){let t=t=>e().update(iV(t)).digest(),i=e();return t.outputLen=i.outputLen,t.blockLen=i.blockLen,t.create=()=>e(),t}function iF(e=32){if(iU&&"function"==typeof iU.getRandomValues)return iU.getRandomValues(new Uint8Array(e));if(iU&&"function"==typeof iU.randomBytes)return iU.randomBytes(e);throw Error("crypto.getRandomValues must be defined")}let iJ=[],iG=[],iY=[],iZ=BigInt(0),iQ=BigInt(1),iX=BigInt(2),i0=BigInt(7),i1=BigInt(256),i2=BigInt(113);for(let e=0,t=iQ,i=1,r=0;e<24;e++){[i,r]=[r,(2*i+3*r)%5],iJ.push(2*(5*r+i)),iG.push((e+1)*(e+2)/2%64);let s=iZ;for(let e=0;e<7;e++)(t=(t<<iQ^(t>>i0)*i2)%i1)&iX&&(s^=iQ<<(iQ<<BigInt(e))-iQ);iY.push(s)}let[i5,i3]=function(e,t=!1){let i=new Uint32Array(e.length),r=new
1Uint32Array(e.length);for(let s=0;s<e.length;s++){let{h:n,l:o}=function(e,t=!1){return t?{h:Number(e&ik),l:Number(e>>iL&ik)}:{h:0|Number(e>>iL&ik),l:0|Number(e&ik)}}(e[s],t);[i[s],r[s]]=[n,o]}return[i,r]}(iY,!0),i4=(e,t,i)=>i>32?iD(e,t,i):i$(e,t,i),i8=(e,t,i)=>i>32?iM(e,t,i):ij(e,t,i);class i6 extends iW{constructor(e,t,i,r=!1,s=24){var n;if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=s,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,iC(i),0>=this.blockLen||this.blockLen>=200)throw Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=new Uint32Array((n=this.state).buffer,n.byteOffset,Math.floor(n.byteLength/4))}keccak(){iz||iH(this.state32),function(e,t=24){let i=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let t=0;t<10;t++)i[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let r=(t+8)%10,s=(t+2)%10,n=i[s],o=i[s+1],a=i4(n,o,1)^i[r],c=i8(n,o,1)^i[r+1];for(let i=0;i<50;i+=10)e[t+i]^=a,e[t+i+1]^=c}let t=e[2],s=e[3];for(let i=0;i<24;i++){let r=iG[i],n=i4(t,s,r),o=i8(t,s,r),a=iJ[i];t=e[a],s=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let r=0;r<10;r++)i[r]=e[t+r];for(let r=0;r<10;r++)e[t+r]^=~i[(r+2)%10]&i[(r+4)%10]}e[0]^=i5[r],e[1]^=i3[r]}i.fill(0)}(this.state32,this.rounds),iz||iH(this.state32),this.posOut=0,this.pos=0}update(e){iT(this);let{blockLen:t,state:i}=this,r=(e=iV(e)).length;for(let s=0;s<r;){let n=Math.min(t-this.pos,r-s);for(let t=0;t<n;t++)i[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;let{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,(128&t)!=0&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){iT(this,!1),iR(e),this.finish();let t=this.state,{blockLen:i}=this;for(let r=0,s=e.length;r<s;){this.posOut>=i&&this.keccak();let n=Math.min(i-this.posOut,s-r);e.set(t.subarray(this.posOut,this.posOut+n),r),this.posOut+=n,r+=n}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return iC(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(iN(e,this),this.finished)throw 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){let{blockLen:t,suffix:i,outputLen:r,rounds:s,enableXOF:n}=this;return e||(e=new i6(t,i,r,n,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=i,e.outputLen=r,e.enableXOF=n,e.destroyed=this.destroyed,e}}let i7=iK(()=>new i6(136,1,32));function i9(e){let t=`�Ethereum Signed Message: 2${e.length}`,i=new TextEncoder().encode(t+e);return"0x"+t6.from(i7(i)).toString("hex")}async function re(e,t,i,r,s,n){switch(i.t){case"eip191":return await rt(e,t,i.s);case"eip1271":return await ri(e,t,i.s,r,s,n);default:throw Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${i.t}`)}}async function rt(e,t,i){return(await (0,k.R)({hash:i9(t),signature:i})).toLowerCase()===e.toLowerCase()}async function ri(e,t,i,r,s,n){let o=t7(r);if(!o.namespace||!o.reference)throw Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${r}`);try{let o="0x1626ba7e",a=i.substring(2),c=i9(t).substring(2),l=await fetch(`${n||"https://rpc.walletconnect.org/v1"}/?chainId=${r}&projectId=${s}`,{method:"POST",body:JSON.stringify({id:Date.now()+Math.floor(1e3*Math.random()),jsonrpc:"2.0",method:"eth_call",params:[{to:e,data:o+c+"00000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000041"+a},"latest"]})}),{result:h}=await l.json();return!!h&&h.slice(0,o.length).toLowerCase()===o.toLowerCase()}catch(e){return console.error("isValidEip1271Signature: ",e),!1}}var rr=Object.defineProperty,rs=Object.defineProperties,rn=Object.getOwnPropertyDescriptors,ro=Object.getOwnPropertySymbols,ra=Object.prototype.hasOwnProperty,rc=Object.prototype.propertyIsEnumerable,rl=(e,t,i)=>t in e?rr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,rh=(e,t)=>{for(var i in t||(t={}))ra.call(t,i)&&rl(e,i,t[i]);if(ro)for(var i of ro(t))rc.call(t,i)&&rl(e,i,t[i]);return e},rd=(e,t)=>rs(e,rn(t));let ru=e=>e?.split(":"),rp=e=>{let t=e&&ru(e);
2if(t)return e.includes("did:pkh:")?t[3]:t[1]},rg=e=>{let t=e&&ru(e);if(t)return t[2]+":"+t[3]},rf=e=>{let t=e&&ru(e);if(t)return t.pop()};async function rm(e){let{cacao:t,projectId:i}=e,{s:r,p:s}=t,n=ry(s,s.iss),o=rf(s.iss);return await re(o,n,r,rg(s.iss),i)}let ry=(e,t)=>{let i=`${e.domain} wants you to sign in with your Ethereum account:`,r=rf(t);if(!e.aud&&!e.uri)throw Error("Either `aud` or `uri` is required to construct the message");let s=e.statement||void 0,n=`URI: ${e.aud||e.uri}`,o=`Version: ${e.version}`,a=`Chain ID: ${rp(t)}`,c=`Nonce: ${e.nonce}`,l=`Issued At: ${e.iat}`,h=e.exp?`Expiration Time: ${e.exp}`:void 0,d=e.nbf?`Not Before: ${e.nbf}`:void 0,u=e.requestId?`Request ID: ${e.requestId}`:void 0,p=e.resources?`Resources:${e.resources.map(e=>` 3- ${e}`).join("")}`:void 0,g=rI(e.resources);return g&&(s=function(e="",t){rb(t);let i="I further authorize the stated URI to perform the following actions on my behalf: ";if(e.includes(i))return e;let r=[],s=0;Object.keys(t.att).forEach(e=>{let i=Object.keys(t.att[e]).map(e=>({ability:e.split("/")[0],action:e.split("/")[1]}));i.sort((e,t)=>e.action.localeCompare(t.action));let n={};i.forEach(e=>{n[e.ability]||(n[e.ability]=[]),n[e.ability].push(e.action)});let o=Object.keys(n).map(t=>(s++,`(${s}) '${t}': '${n[t].join("', '")}' for '${e}'.`));r.push(o.join(", ").replace(".,","."))});let n=r.join(" "),o=`${i}${n}`;return`${e?e+" ":""}${o}`}(s,rv(g))),[i,r,"",s,"",n,o,a,c,l,h,d,u,p].filter(e=>null!=e).join(` 4`)};function rb(e){if(!e)throw Error("No recap provided, value is undefined");if(!e.att)throw Error("No `att` property found");let t=Object.keys(e.att);if(!(null!=t&&t.length))throw Error("No resources found in `att` property");t.forEach(t=>{let i=e.att[t];if(Array.isArray(i)||"object"!=typeof i)throw Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw Error(`Resource object is empty: ${t}`);
4Object.keys(i).forEach(e=>{let t=i[e];if(!Array.isArray(t))throw Error(`Ability limits ${e} must be an array of objects, found: ${t}`);if(!t.length)throw Error(`Value of ${e} is empty array, must be an array with objects`);t.forEach(t=>{if("object"!=typeof t)throw Error(`Ability limits (${e}) must be an array of objects, found: ${t}`)})})})}function rw(e){return rb(e),`urn:recap:${t6.from(JSON.stringify(e)).toString("base64").replace(/=/g,"")}`}function rv(e){var t;let i=(t=e.replace("urn:recap:",""),JSON.parse(t6.from(t,"base64").toString("utf-8")));return rb(i),i}function rE(e){var t;let i=rv(e);rb(i);let r=null==(t=i.att)?void 0:t.eip155;return r?Object.keys(r).map(e=>e.split("/")[1]):[]}function r_(e){let t=rv(e);rb(t);let i=[];return Object.values(t.att).forEach(e=>{Object.values(e).forEach(e=>{var t;null!=(t=e?.[0])&&t.chains&&i.push(e[0].chains)})}),[...new Set(i.flat())]}function rI(e){if(!e)return;let t=e?.[e.length-1];return t&&t.includes("urn:recap:")?t:void 0}function rx(e){if(!Number.isSafeInteger(e)||e<0)throw Error("positive integer expected, got "+e)}function rO(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function rP(e,...t){if(!rO(e))throw Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw Error("Uint8Array expected of length "+t+", got length="+e.length)}function rS(e,t=!0){if(e.destroyed)throw Error("Hash instance has been destroyed");if(t&&e.finished)throw Error("Hash#digest() has already been called")}function rC(e){if("boolean"!=typeof e)throw Error(`boolean expected, not ${e}`)}let rR=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),rA=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw Error("Non little-endian hardware is not supported");function rT(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}(e);else if(rO(e))e=rL(e);else throw Error("Uint8Array expected, got "+typeof e);return e}function rN(e,t,i=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw Error("invalid output length, expected "+e+", got: "+t.length);if(i&&t.byteOffset%4!=0)throw Error("invalid output, must be aligned");return t}function rk(e,t,i,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,i,r);let s=BigInt(32),n=BigInt(4294967295),o=Number(i>>s&n),a=Number(i&n),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,a,r)}function rL(e){return Uint8Array.from(e)}function r$(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}let rj=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),rD=rj("expand 16-byte k"),rM=rj("expand 32-byte k"),rU=rR(rD),rq=rR(rM);function rB(e,t){return e<<t|e>>>32-t}function rz(e){return e.byteOffset%4==0}let rH=4294967296-1,rV=new Uint32Array,rW=(e,t)=>255&e[t++]|(255&e[t++])<<8;class rK{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,rP(e=rT(e),32);let t=rW(e,0),i=rW(e,2),r=rW(e,4),s=rW(e,6),n=rW(e,8),o=rW(e,10),a=rW(e,12),c=rW(e,14);this.r[0]=8191&t,this.r[1]=(t>>>13|i<<3)&8191,this.r[2]=(i>>>10|r<<6)&7939,this.r[3]=(r>>>7|s<<9)&8191,this.r[4]=(s>>>4|n<<12)&255,this.r[5]=n>>>1&8190,this.r[6]=(n>>>14|o<<2)&8191,this.r[7]=(o>>>11|a<<5)&8065,this.r[8]=(a>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=rW(e,16+2*t)}process(e,t,i=!1){let{h:r,r:s}=this,n=s[0],o=s[1],a=s[2],c=s[3],l=s[4],h=s[5],d=s[6],u=s[7],p=s[8],g=s[9],f=rW(e,t+0),m=rW(e,t+2),y=rW(e,t+4),b=rW(e,t+6),w=rW(e,t+8),v=rW(e,t+10),E=rW(e,t+12),_=rW(e,t+14),I=r[0]+(8191&f),x=r[1]+((f>>>13|m<<3)&8191),O=r[2]+((m>>>10|y<<6)&8191),P=r[3]+((y>>>7|b<<9)&8191),S=r[4]+((b>>>4|w<<12)&8191),C=r[5]+(w>>>1&8191),R=r[6]+((w>>>14|v<<2)&8191),A=r[7]+((v>>>11|E<<5)&8191),T=r[8]+((E>>>8|_<<8)&8191),N=r[9]+(_>>>5|(i?0:2048)),k=0,L=0+I*n+5*g*x+5*p*O+5*u*P+5*d*S;k=L>>>13,L&=8191,L+=5*h*C+5*l*R+5*c*A+5*a*T+5*o*N,k+=L>>>13,L&=8191;let $=k+I*o+x*n+5*g*O+5*p*P+5*u*S;k=$>>>13,$&=8191,$+=5*d*C+5*h*R+5*l*A+5*c*T+5*a*N,k+=$>>>13,$&=8191;let j=k+I*a+x*o+O*n+5*g*P+5*p*S;k=j>>>13,j&=8191,j+=5*u*C+5*d*R+5*h*A+5*l*T+5*c*N,k+=j>>>13,j&=8191;let D=k+I*c+x*a+O*o+P*n+5*g*S;k=D>>>13,D&=8191,D+=5*p*C+5*u*R+5*d*A+5*h*T+5*l*N,k+=D>>>13,D&=8191;let M=k+I*l+x*c+O*a+P*o+S*n;k=M>>>13,M&=8191,M+=5*g*C+5*p*R+5*u*A+5*d*T+5*h*N,k+=M>>>13,M&=8191;let U=k+I*h+x*l+O*c+P*a+S*o;k=U>>>13,U&=8191,U+=C*n+5*g*R+5*p*A+5*u*T+5*d*N,k+=U>>>13,U&=8191;let q=k+I*d+x*h+O*l+P*c+S*a;k=q>>>13,q&=8191,q+=C*o+R*n+5*g*A+5*p*T+5*u*N,k+=q>>>13,q&=8191;let B=k+I*u+x*d+O*h+P*l+S*c;k=B>>>13,B&=8191,B+=C*a+R*o+A*n+5*g*T+5*p*N,k+=B>>>13,B&=8191;let z=k+I*p+x*u+O*d+P*h+S*l;k=z>>>13,z&=8191,z+=C*c+R*a+A*o+T*n+5*g*N,k+=z>>>13,z&=8191;let H=k+I*g+x*p+O*u+P*d+S*h;k=H>>>13,H&=8191,H+=C*l+R*c+A*a+T*o+N*n,k+=H>>>13,H&=8191,L=8191&(k=(k=(k<<2)+k|0)+L|0),k>>>=13,$+=k,r[0]=L,r[1]=$,r[2]=j,r[3]=D,r[4]=M,r[5]=U,r[6]=q,r[7]=B,r[8]=z,r[9]=H}finalize(){let{h:e,pad:t}=this,i=new Uint16Array(10),r=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=r,r=e[t]>>>13,e[t]&=8191;e[0]+=5*r,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,i[0]=e[0]+5,r=i[0]>>>13,i[0]&=8191;for(let t=1;t<10;t++)i[t]=e[t]+r,r=i[t]>>>13,i[t]&=8191;i[9]-=8192;let s=(1^r)-1;for(let e=0;e<10;e++)i[e]&=s;s=~s;for(let t=0;t<10;t++)e[t]=e[t]&s|i[t];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let n=e[0]+t[0];e[0]=65535&n;for(let i=1;i<8;i++)n=(e[i]+t[i]|0)+(n>>>16)|0,e[i]=65535&n;r$(i)}update(e){rS(this);let{buffer:t,blockLen:i}=this,r=(e=rT(e)).length;for(let s=0;s<r;){let n=Math.min(i-this.pos,r-s);if(n===i){for(;i<=r-s;s+=i)this.process(e,s);continue}t.set(e.subarray(s,s+n),this.pos),this.pos+=n,s+=n,this.pos===i&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){r$(this.h,this.r,this.buffer,this.pad)}digestInto(e){rS(this),function(e,t){rP(e);let i=t.outputLen;if(e.length<i)throw Error("digestInto() expects output buffer of length at least "+i)}(e,this),this.finished=!0;let{buffer:t,h:i}=this,{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let s=0;for(let t=0;t<8;t++)e[s++]=i[t]>>>0,e[s++]=i[t]>>>8;return e}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let i=e.slice(0,t);return this.destroy(),i}}let rF=function(e){let t=(t,i)=>e(i).update(rT(t)).digest(),i=e(new Uint8Array(32));return t.outputLen=i.outputLen,t.blockLen=i.blockLen,t.create=t=>e(t),t}(e=>
4new rK(e)),rJ=function(e,t){let{allowShortKeys:i,extendNonceFn:r,counterLength:s,counterRight:n,rounds:o}=function(e,t){if(null==t||"object"!=typeof t)throw Error("options must be defined");return Object.assign(e,t)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw Error("core must be a function");return rx(s),rx(o),rC(n),rC(i),(t,a,c,l,h=0)=>{rP(t),rP(a),rP(c);let d=c.length;if(void 0===l&&(l=new Uint8Array(d)),rP(l),rx(h),h<0||h>=rH)throw Error("arx: counter overflow");if(l.length<d)throw Error(`arx: output (${l.length}) is shorter than data (${d})`);let u=[],p=t.length,g,f;if(32===p)u.push(g=rL(t)),f=rq;else if(16===p&&i)(g=new Uint8Array(32)).set(t),g.set(t,16),f=rU,u.push(g);else throw Error(`arx: invalid 32-byte key, got length=${p}`);rz(a)||u.push(a=rL(a));let m=rR(g);if(r){if(24!==a.length)throw Error("arx: extended nonce must be 24 bytes");r(f,m,rR(a.subarray(0,16)),m),a=a.subarray(16)}let y=16-s;if(y!==a.length)throw Error(`arx: nonce must be ${y} or 16 bytes`);if(12!==y){let e=new Uint8Array(12);e.set(a,n?0:12-a.length),a=e,u.push(a)}return function(e,t,i,r,s,n,o,a){let c=s.length,l=new Uint8Array(64),h=rR(l),d=rz(s)&&rz(n),u=d?rR(s):rV,p=d?rR(n):rV;for(let g=0;g<c;o++){if(e(t,i,r,h,o,a),o>=rH)throw Error("arx: counter overflow");let f=Math.min(64,c-g);if(d&&64===f){let e=g/4;if(g%4!=0)throw Error("arx: invalid block position");for(let t=0,i;t<16;t++)p[i=e+t]=u[i]^h[t];g+=64;continue}for(let e=0,t;e<f;e++)n[t=g+e]=s[t]^l[e];g+=f}}(e,f,m,rR(a),c,l,h,o),r$(...u),l}}(function(e,t,i,r,s,n=20){let o=e[0],a=e[1],c=e[2],l=e[3],h=t[0],d=t[1],u=t[2],p=t[3],g=t[4],f=t[5],m=t[6],y=t[7],b=i[0],w=i[1],v=i[2],E=o,_=a,I=c,x=l,O=h,P=d,S=u,C=p,R=g,A=f,T=m,N=y,k=s,L=b,$=w,j=v;for(let e=0;e<n;e+=2)R=R+(k=rB(k^(E=E+O|0),16))|0,E=E+(O=rB(O^R,12))|0,R=R+(k=rB(k^E,8))|0,O=rB(O^R,7),A=A+(L=rB(L^(_=_+P|0),16))|0,_=_+(P=rB(P^A,12))|0,A=A+(L=rB(L^_,8))|0,P=rB(P^A,7),T=T+($=rB($^(I=I+S|0),16))|0,I=I+(S=rB(S^T,12))|0,T=T+($=rB($^I,8))|0,S=rB(S^T,7),N=N+(j=rB(j^(x=x+C|0),16))|0,x=x+(C=rB(C^N,12))|0,N=N+(j=rB(j^x,8))|0,C=rB(C^N,7),T=T+(j=rB(j^(E=E+P|0),16))|0,E=E+(P=rB(P^T,12))|0,T=T+(j=rB(j^E,8))|0,P=rB(P^T,7),N=N+(k=rB(k^(_=_+S|0),16))|0,_=_+(S=rB(S^N,12))|0,N=N+(k=rB(k^_,8))|0,S=rB(S^N,7),R=R+(L=rB(L^(I=I+C|0),16))|0,I=I+(C=rB(C^R,12))|0,R=R+(L=rB(L^I,8))|0,C=rB(C^R,7),A=A+($=rB($^(x=x+O|0),16))|0,x=x+(O=rB(O^A,12))|0,A=A+($=rB($^x,8))|0,O=rB(O^A,7);let D=0;r[D++]=o+E|0,r[D++]=a+_|0,r[D++]=c+I|0,r[D++]=l+x|0,r[D++]=h+O|0,r[D++]=d+P|0,r[D++]=u+S|0,r[D++]=p+C|0,r[D++]=g+R|0,r[D++]=f+A|0,r[D++]=m+T|0,r[D++]=y+N|0,r[D++]=s+k|0,r[D++]=b+L|0,r[D++]=w+$|0,r[D++]=v+j|0},{counterRight:!1,counterLength:4,allowShortKeys:!1}),rG=new Uint8Array(16),rY=(e,t)=>{e.update(t);let i=t.length%16;i&&e.update(rG.subarray(i))},rZ=new Uint8Array(32);function rQ(e,t,i,r,s){let n=e(t,i,rZ),o=rF.create(n);s&&rY(o,s),rY(o,r);let a=new Uint8Array(16),c=rA(a);rk(c,0,BigInt(s?s.length:0),!0),rk(c,8,BigInt(r.length),!0),o.update(a);let l=o.digest();return r$(n,a),l}let rX=((e,t)=>{function i(r,...s){if(rP(r),void 0!==e.nonceLength){let t=s[0];if(!t)throw Error("nonce / iv required");e.varSizeNonce?rP(t):rP(t,e.nonceLength)}let n=e.tagLength;n&&void 0!==s[1]&&rP(s[1]);let o=t(r,...s),a=(e,t)=>{if(void 0!==t){if(2!==e)throw Error("cipher output not supported");rP(t)}},c=!1;return{encrypt(e,t){if(c)throw Error("cannot encrypt() twice with same key + nonce");return c=!0,rP(e),a(o.encrypt.length,t),o.encrypt(e,t)},decrypt(e,t){if(rP(e),n&&e.length<n)throw Error("invalid ciphertext length: smaller than tagLength="+n);return a(o.decrypt.length,t),o.decrypt(e,t)}}}return Object.assign(i,e),i})({blockSize:64,nonceLength:12,tagLength:16},(e,t,i)=>({encrypt(r,s){let n=r.length;(s=rN(n+16,s,!1)).set(r);let o=s.subarray(0,-16);rJ(e,t,o,o,1);let a=rQ(rJ,e,t,o,i);return s.set(a,n),r$(a),s},decrypt(r,s){s=rN(r.length-16,s,!1);let n=r.subarray(0,-16),o=r.subarray(-16),a=rQ(rJ,e,t,n,i);if(!function(e,t){if(e.length!==t.length)return!1;let i=0;for(let r=0;r<e.length;r++)i|=e[r]^t[r];return 0===i}(o,a))throw Error("invalid tag");return s.set(r.subarray(0,-16)),rJ(e,t,s,s,1),r$(a),s}}));class r0 extends iW{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,iA(e);let i=iV(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;let r=this.blockLen,s=new Uint8Array(r);s.set(i.length>r?e.create().update(i).digest():i);for(let e=0;e<s.length;e++)s[e]^=54;this.iHash.update(s),this.oHash=e.create();for(let e=0;e<s.length;e++)s[e]^=106;this.oHash.update(s),s.fill(0)}update(e){return iT(this),this.iHash.update(e),this}digestInto(e){iT(this),iR(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){let e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));let{oHash:t,iHash:i,finished:r,destroyed:s,blockLen:n,outputLen:o}=this;return e.finished=r,e.destroyed=s,e.blockLen=n,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}let r1=(e,t,i)=>new r0(e,t).update(i).digest();r1.create=(e,t)=>
4new r0(e,t);let r2=new Uint8Array([0]),r5=new Uint8Array,r3=(e,t,i,r,s)=>{var n;return function(e,t,i,r=32){if(iA(e),iC(r),r>255*e.outputLen)throw Error("Length should be <= 255*HashLen");let s=Math.ceil(r/e.outputLen);void 0===i&&(i=r5);let n=new Uint8Array(s*e.outputLen),o=r1.create(e,t),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let t=0;t<s;t++)r2[0]=t+1,a.update(0===t?r5:c).update(i).update(r2).digestInto(c),n.set(c,e.outputLen*t),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),r2.fill(0),n.slice(0,r)}(e,(n=i,iA(e),void 0===n&&(n=new Uint8Array(e.outputLen)),r1(e,iV(n),iV(t))),r,s)};class r4 extends iW{constructor(e,t,i,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=iq(this.buffer)}update(e){iT(this);let{view:t,buffer:i,blockLen:r}=this,s=(e=iV(e)).length;for(let n=0;n<s;){let o=Math.min(r-this.pos,s-n);if(o===r){let t=iq(e);for(;r<=s-n;n+=r)this.process(t,n);continue}i.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){iT(this),iN(e,this),this.finished=!0;let{buffer:t,view:i,blockLen:r,isLE:s}=this,{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>r-n&&(this.process(i,0),n=0);for(let e=n;e<r;e++)t[e]=0;(function(e,t,i,r){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,i,r);let s=BigInt(32),n=BigInt(4294967295),o=Number(i>>s&n),a=Number(i&n),c=r?4:0,l=r?0:4;e.setUint32(t+c,o,r),e.setUint32(t+l,a,r)})(i,r-8,BigInt(8*this.length),s),this.process(i,0);let o=iq(e),a=this.outputLen;if(a%4)throw Error("_sha2: outputLen should be aligned to 32bit");let c=a/4,l=this.get();if(c>l.length)throw Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,l[e],s)}digest(){let{buffer:e,outputLen:t}=this;this.digestInto(e);let i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());let{blockLen:t,buffer:i,length:r,finished:s,destroyed:n,pos:o}=this;return e.length=r,e.pos=o,e.finished=s,e.destroyed=n,r%t&&e.buffer.set(i),e}}let r8=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,2756734187,3204031479,3329325298]),r6=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),r7=new Uint32Array(64);class r9 extends r4{constructor(){super(64,32,8,!1),this.A=0|r6[0],this.B=0|r6[1],this.C=0|r6[2],this.D=0|r6[3],this.E=0|r6[4],this.F=0|r6[5],this.G=0|r6[6],this.H=0|r6[7]}get(){let{A:e,B:t,C:i,D:r,E:s,F:n,G:o,H:a}=this;return[e,t,i,r,s,n,o,a]}set(e,t,i,r,s,n,o,a){this.A=0|e,this.B=0|t,this.C=0|i,this.D=0|r,this.E=0|s,this.F=0|n,this.G=0|o,this.H=0|a}process(e,t){for(let i=0;i<16;i++,t+=4)r7[i]=e.getUint32(t,!1);for(let e=16;e<64;e++){let t=r7[e-15],i=r7[e-2],r=iB(t,7)^iB(t,18)^t>>>3,s=iB(i,17)^iB(i,19)^i>>>10;r7[e]=s+r7[e-7]+r+r7[e-16]|0}let{A:i,B:r,C:s,D:n,E:o,F:a,G:c,H:l}=this;for(let e=0;e<64;e++){var h,d,u,p;let t=l+(iB(o,6)^iB(o,11)^iB(o,25))+((h=o)&a^~h&c)+r8[e]+r7[e]|0,g=(iB(i,2)^iB(i,13)^iB(i,22))+((d=i)&(u=r)^d&(p=s)^u&p)|0;l=c,c=a,a=o,o=n+t|0,n=s,s=r,r=i,i=t+g|0}i=i+this.A|0,r=r+this.B|0,s=s+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(i,r,s,n,o,a,c,l)}roundClean(){r7.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}let se=iK(()=>new r9),st=BigInt(0);function si(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function sr(e){if(!si(e))throw Error("Uint8Array expected")}let ss=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0")),sn={_0:48,_9:57,A:65,F:70,a:97,f:102};function so(e){return e>=sn._0&&e<=sn._9?e-sn._0:e>=sn.A&&e<=sn.F?e-(sn.A-10):e>=sn.a&&e<=sn.f?e-(sn.a-10):void 0}function sa(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);let t=e.length,i=t/2;if(t%2)throw Error("hex string expected, got unpadded hex of length "+t);let r=new Uint8Array(i);for(let t=0,s=0;t<i;t++,s+=2){let i=so(e.charCodeAt(s)),n=so(e.charCodeAt(s+1));if(void 0===i||void 0===n)throw Error('hex string expected, got non-hex character "'+(e[s]+e[s+1])+'" at index '+s);r[t]=16*i+n}return r}function sc(e){return sr(e),function(e){if("string"!=typeof e)throw Error("hex string expected, got "+typeof e);return""===e?st:BigInt("0x"+e)}(function(e){sr(e);let t="";for(let i=0;i<e.length;i++)t+=ss[e[i]];return t}(Uint8Array.from(e).reverse()))}function sl(e,t,i){let r;if("string"==typeof t)try{r=sa(t)}catch(t){throw Error(e+" must be hex string or Uint8Array, cause: "+t)}else if(si(t))r=Uint8Array.from(t);else throw Error(e+" must be hex string or Uint8Array");let s=r.length;if("number"==typeof i&&s!==i)throw Error(e+" of length "+i+" expected, got "+s);return r}let sh=e=>"bigint"==typeof e&&st<=e;function sd(e,t,i,r){if(!(sh(t)&&sh(i)&&sh(r))||!(i<=t)||!(t<r))throw Error("expected valid "+e+": "+i+" <= n < "+r+", got "+t)}let su={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||si(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)},sp=BigInt(0),sg=BigInt(1);function sf(e,t){let i=e%t;return i>=sp?i:t+i}function sm(e,t,i){let r=e;for(;t-- >sp;)r*=r,r%=i;return r}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);let sy=BigInt(0),sb=BigInt(1),sw=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);let sv=BigInt(1),sE=BigInt(2),s_=BigInt(3),sI=BigInt(5);BigInt(8);let sx=function(e){let t=(function(e,t,i={}){let r=(t,i,r)=>{let s=su[i];if("function"!=typeof s)throw Error("invalid validator function");let n=e[t];if(!(r&&void 0===n)&&!s(n,e))throw Error("param "+String(t)+" is invali
4d. Expected "+i+", got "+n)};for(let[e,i]of Object.entries(t))r(e,i,!1);for(let[e,t]of Object.entries(i))r(e,t,!0)}(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})),{P:i}=t,r=e=>sf(e,i),s=t.montgomeryBits,n=Math.ceil(s/8),o=t.nByteLength,a=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>(function(e,t,i){if(t<sp)throw Error("invalid exponent, negatives unsupported");if(i<=sp)throw Error("invalid modulus");if(i===sg)return sp;let r=sg;for(;t>sp;)t&sg&&(r=r*e%i),e=e*e%i,t>>=sg;return r})(e,i-BigInt(2),i));function l(e,t,i){let s=r(e*(t-i));return[t=r(t-s),i=r(i+s)]}let h=(t.a-BigInt(2))/BigInt(4);function d(e){var t;return sa(r(e).toString(16).padStart(2*n,"0")).reverse()}function u(e,t){let u=function(e,t){sd("u",e,sy,i),sd("scalar",t,sy,i);let n=sb,o=sy,a=e,d=sb,u=sy,p;for(let i=BigInt(s-1);i>=sy;i--){let s=t>>i&sb;u^=s,n=(p=l(u,n,a))[0],a=p[1],o=(p=l(u,o,d))[0],d=p[1],u=s;let c=n+o,g=r(c*c),f=n-o,m=r(f*f),y=g-m,b=a+d,w=r((a-d)*c),v=r(b*f),E=w+v,_=w-v;a=r(E*E),d=r(e*r(_*_)),n=r(g*m),o=r(y*(g+r(h*y)))}return n=(p=l(u,n,a))[0],a=p[1],o=(p=l(u,o,d))[0],d=p[1],r(n*c(o))}(function(e){let t=sl("u coordinate",e,n);return 32===o&&(t[31]&=127),sc(t)}(t),function(e){let t=sl("scalar",e),i=t.length;if(i!==n&&i!==o)throw Error("invalid scalar, expected "+n+" or "+o+" bytes, got "+i);return sc(a(t))}(e));if(u===sy)throw Error("invalid private or public key received");return d(u)}let p=d(t.Gu);function g(e){return u(e,p)}return{scalarMult:u,scalarMultBase:g,getSharedSecret:(e,t)=>u(e,t),getPublicKey:e=>g(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:p}}({P:sw,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{let{pow_p_5_8:t,b2:i}=function(e){let t=BigInt(10),i=BigInt(20),r=BigInt(40),s=BigInt(80),n=e*e%sw*e%sw,o=sm(n,sE,sw)*n%sw,a=sm(o,sv,sw)*e%sw,c=sm(a,sI,sw)*a%sw,l=sm(c,t,sw)*c%sw,h=sm(l,i,sw)*l%sw,d=sm(h,r,sw)*h%sw,u=sm(d,s,sw)*d%sw,p=sm(u,s,sw)*d%sw,g=sm(p,t,sw)*c%sw;return{pow_p_5_8:sm(g,sE,sw)*e%sw,b2:n}}(e);return sf(sm(t,s_,sw)*i,sw)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},randomBytes:iF}),sO="base10",sP="base16",sS="base64pad",sC="base64url",sR="utf8";function sA(){let e=iF(32);return(0,t5.BB)(e,sP)}function sT(e){let t=se((0,t5.mL)(e,sP));return(0,t5.BB)(t,sP)}function sN(e){let t=se((0,t5.mL)(e,sR));return(0,t5.BB)(t,sP)}function sk(e){return(0,t5.mL)(`${e}`,sO)}function sL(e){return Number((0,t5.BB)(e,sO))}function s$(e){let{encoding:t=sS}=e;if(2===sL(e.type))return(0,t5.BB)((0,t5.zo)([e.type,e.sealed]),t);if(1===sL(e.type)){if(typeof e.senderPublicKey>"u")throw Error("Missing sender public key for type 1 envelope");return(0,t5.BB)((0,t5.zo)([e.type,e.senderPublicKey,e.iv,e.sealed]),t)}return(0,t5.BB)((0,t5.zo)([e.type,e.iv,e.sealed]),t)}function sj(e){let{encoded:t,encoding:i=sS}=e,r=(0,t5.mL)(t,i),s=r.slice(0,1);if(1===sL(s)){let e=r.slice(1,33),t=r.slice(33,45);return{type:s,sealed:r.slice(45),iv:t,senderPublicKey:e}}if(2===sL(s))return{type:s,sealed:r.slice(1),iv:iF(12)};let n=r.slice(1,13);return{type:s,sealed:r.slice(13),iv:n}}function sD(e){let t=e?.type||0;if(1===t){if(typeof e?.senderPublicKey>"u")throw Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function sM(e){return 1===e.type&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}function sU(e){return e?.relay||{protocol:"irn"}}function sq(e){let t=t4[e];if(typeof t>"u")throw Error(`Relay Protocol not supported: ${e}`);return t}function sB(e){var t;if(!e.includes("wc:")){let t=iS(e);null!=t&&t.includes("wc:")&&(e=t)}let i=(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,i),n=e.substring(i+1,r).split("@"),o=new URLSearchParams("u">typeof r?e.substring(r):""),a={};o.forEach((e,t)=>{a[t]=e});let c="string"==typeof a.methods?a.methods.split(","):void 0;return{protocol:s,topic:(t=n[0]).startsWith("//")?t.substring(2):t,version:parseInt(n[1],10),symKey:a.symKey,relay:function(e,t="-"){let i={},r="relay"+t;return Object.keys(e).forEach(t=>{if(t.startsWith(r)){let s=t.replace(r,""),n=e[t];i[s]=n}}),i}(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function sz(e){let t=new URLSearchParams,i=function(e,t="-"){let i={};return Object.keys(e).forEach(r=>{e[r]&&(i["relay"+t+r]=e[r])}),i}(e.relay);
4Object.keys(i).sort().forEach(e=>{t.set(e,i[e])}),t.set("symKey",e.symKey),e.expiryTimestamp&&t.set("expiryTimestamp",e.expiryTimestamp.toString()),e.methods&&t.set("methods",e.methods.join(","));let r=t.toString();return`${e.protocol}:${e.topic}@${e.version}?${r}`}function sH(e,t,i){return`${e}?wc_ev=${i}&topic=${t}`}function sV(e){let t=[];return e.forEach(e=>{let[i,r]=e.split(":");t.push(`${i}:${r}`)}),t}function sW(e){return e.includes(":")}function sK(e){return sW(e)?e.split(":")[0]:e}function sF(e,t){let i=function(e){let t={};return e?.forEach(e=>{var i;let[r,s]=e.split(":");t[r]||(t[r]={accounts:[],chains:[],events:[],methods:[]}),t[r].accounts.push(e),null==(i=t[r].chains)||i.push(`${r}:${s}`)}),t}(t=t.map(e=>e.replace("did:pkh:","")));for(let[t,r]of Object.entries(i))r.methods?r.methods=iE(r.methods,e):r.methods=e,r.events=["chainChanged","accountsChanged"];return i}Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;let sJ={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}},sG={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 sY(e,t){let{message:i,code:r}=sG[e];return{message:t?`${i} ${t}`:i,code:r}}function sZ(e,t){let{message:i,code:r}=sJ[e];return{message:t?`${i} ${t}`:i,code:r}}function sQ(e,t){return!!Array.isArray(e)&&(!("u">typeof t)||!e.length||e.every(t))}function sX(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function s0(e){return typeof e>"u"}function s1(e,t){return!!(t&&s0(e))||"string"==typeof e&&!!e.trim().length}function s2(e,t){return!!(t&&s0(e))||"number"==typeof e&&!isNaN(e)}function s5(e){return!!(s1(e,!1)&&e.includes(":"))&&2===e.split(":").length}function s3(e){let t=!0;return sQ(e)?e.length&&(t=e.every(e=>s1(e,!1))):t=!1,t}function s4(e,t){let i=null;return Object.values(e).forEach(e=>{var r;let s;if(i)return;let n=(r=`${t}, namespace`,s=null,s3(e?.methods)?s3(e?.events)||(s=sZ("UNSUPPORTED_EVENTS",`${r}, events should be an array of strings or empty array for no events`)):s=sZ("UNSUPPORTED_METHODS",`${r}, methods should be an array of strings or empty array for no methods`),s);n&&(i=n)}),i}function s8(e,t){let i=null;if(e&&sX(e)){let r;let s=s4(e,t);s&&(i=s);let n=(r=null,Object.values(e).forEach(e=>{var i,s;let n;if(r)return;let o=(i=e?.accounts,s=`${t} namespace`,n=null,sQ(i)?i.forEach(e=>{n||function(e){if(s1(e,!1)&&e.includes(":")){let t=e.split(":");if(3===t.length){let e=t[0]+":"+t[1];return!!t[2]&&s5(e)}}return!1}(e)||(n=sZ("UNSUPPORTED_ACCOUNTS",`${s}, account ${e} should be a string and conform to "namespace:chainId:address" format`))}):n=sZ("UNSUPPORTED_ACCOUNTS",`${s}
4, accounts should be an array of strings conforming to "namespace:chainId:address" format`),n);o&&(r=o)}),r);n&&(i=n)}else i=sY("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return i}function s6(e){return s1(e.protocol,!0)}function s7(e){return"u">typeof e}function s9(e,t){return!(!s5(t)||!(function(e){let t=[];return Object.values(e).forEach(e=>{t.push(...sV(e.accounts))}),t})(e).includes(t))}function ne(e,t,i){let r=null,s=function(e){let t={};return Object.keys(e).forEach(i=>{var r;i.includes(":")?t[i]=e[i]:null==(r=e[i].chains)||r.forEach(r=>{t[r]={methods:e[i].methods,events:e[i].events}})}),t}(e),n=function(e){let t={};return Object.keys(e).forEach(i=>{if(i.includes(":"))t[i]=e[i];else{let r=sV(e[i].accounts);r?.forEach(r=>{t[r]={accounts:e[i].accounts.filter(e=>e.includes(`${r}:`)),methods:e[i].methods,events:e[i].events}})}}),t}(t),o=Object.keys(s),a=Object.keys(n),c=nt(Object.keys(e)),l=nt(Object.keys(t)),h=c.filter(e=>!l.includes(e));return h.length&&(r=sY("NON_CONFORMING_NAMESPACES",`${i} namespaces keys don't satisfy requiredNamespaces. 5 Required: ${h.toString()} 6 Received: ${Object.keys(t).toString()}`)),ih(o,a)||(r=sY("NON_CONFORMING_NAMESPACES",`${i} namespaces chains don't satisfy required namespaces. 7 Required: ${o.toString()} 8 Approved: ${a.toString()}`)),Object.keys(t).forEach(e=>{if(!e.includes(":")||r)return;let s=sV(t[e].accounts);s.includes(e)||(r=sY("NON_CONFORMING_NAMESPACES",`${i} namespaces accounts don't satisfy namespace accounts for ${e} 9 Required: ${e} 10 Approved: ${s.toString()}`))}),o.forEach(e=>{r||(ih(s[e].methods,n[e].methods)?ih(s[e].events,n[e].events)||(r=sY("NON_CONFORMING_NAMESPACES",`${i} namespaces events don't satisfy namespace events for ${e}`)):r=sY("NON_CONFORMING_NAMESPACES",`${i} namespaces methods don't satisfy namespace methods for ${e}`))}),r}function nt(e){return[...new Set(e.map(e=>e.includes(":")?e.split(":")[0]:e))]}function ni(){let e=io();return new Promise(t=>{switch(e){case it.browser:t(is()&&navigator?.onLine);break;case it.reactNative:t(nr());break;case it.node:default:t(!0)}})}async function nr(){if(ir()&&"u">typeof i.g&&null!=i.g&&i.g.NetInfo){let e=await (null==i.g?void 0:i.g.NetInfo.fetch());return e?.isConnected}return!0}let ns={};class nn{static get(e){return ns[e]}static set(e,t){ns[e]=t}static delete(e){delete ns[e]}}class no{}class na extends no{constructor(e){super()}}let nc=A.FIVE_SECONDS,nl="heartbeat_pulse";class nh extends na{constructor(e){super(e),this.events=new S.EventEmitter,this.interval=nc,this.interval=e?.interval||nc}static async init(e){let t=new nh(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}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 initialize(){this.intervalRef=setInterval(()=>this.pulse(),(0,A.toMiliseconds)(this.interval))}pulse(){this.events.emit(nl)}}var nd=i(57724),nu=i(27600),np=(e={})=>{let t;let i=e.base&&e.base.length>0?`${e.base}:`:"",r=e=>i+e;return e.dbName&&e.storeName&&(t=(0,nu.MT)(e.dbName,e.storeName)),{name:"idb-keyval",options:e,hasItem:async e=>!(typeof await (0,nu.U2)(r(e),t)>"u"),getItem:async e=>await (0,nu.U2)(r(e),t)??null,setItem:(e,i)=>(0,nu.t8)(r(e),i,t),removeItem:e=>
10(0,nu.IV)(r(e),t),getKeys:()=>(0,nu.XP)(t),clear:()=>(0,nu.ZH)(t)}};class ng{constructor(){this.indexedDb=(0,nd.o6)({driver:np({dbName:"WALLET_CONNECT_V2_INDEXED_DB",storeName:"keyvaluestorage"})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){let t=await this.indexedDb.getItem(e);if(null!==t)return t}async setItem(e,t){await this.indexedDb.setItem(e,(0,L.u)(t))}async removeItem(e){await this.indexedDb.removeItem(e)}}var nf="u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof i.g?i.g:"u">typeof self?self:{},nm={exports:{}};function ny(e){var t;return[e[0],(0,L.D)(null!=(t=e[1])?t:"")]}!function(){function e(){}e.prototype.getItem=function(e){return this.hasOwnProperty(e)?String(this[e]):null},e.prototype.setItem=function(e,t){this[e]=String(t)},e.prototype.removeItem=function(e){delete this[e]},e.prototype.clear=function(){let e=this;Object.keys(e).forEach(function(t){e[t]=void 0,delete e[t]})},e.prototype.key=function(e){return e=e||0,Object.keys(this)[e]},e.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),"u">typeof nf&&nf.localStorage?nm.exports=nf.localStorage:"u">typeof window&&window.localStorage?nm.exports=window.localStorage:nm.exports=new e}();class nb{constructor(){this.localStorage=nm.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(ny)}async getItem(e){let t=this.localStorage.getItem(e);if(null!==t)return(0,L.D)(t)}async setItem(e,t){this.localStorage.setItem(e,(0,L.u)(t))}async removeItem(e){this.localStorage.removeItem(e)}}let nw=async(e,t,i)=>{let r="wc_storage_version",s=await t.getItem(r);if(s&&s>=1){i(t);return}let n=await e.getKeys();if(!n.length){i(t);return}let o=[];for(;n.length;){let i=n.shift();if(!i)continue;let r=i.toLowerCase();if(r.includes("wc@")||r.includes("walletconnect")||r.includes("wc_")||r.includes("wallet_connect")){let r=await e.getItem(i);await t.setItem(i,r),o.push(i)}}await t.setItem(r,1),i(t),nv(e,o)},nv=async(e,t)=>{t.length&&t.forEach(async t=>{await e.removeItem(t)})};class nE{constructor(){this.initialized=!1,this.setInitialized=e=>{this.storage=e,this.initialized=!0};let e=new nb;this.storage=e;try{let t=new ng;nw(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{let t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}}var n_=i(97435),nI=i.n(n_);let nx={level:"info"},nO="custom_context";class nP{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}class nS{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){let t=new nP(e);if(t.size>this.maxSizeInBytes)throw Error(`[LinkedList] Value too big to insert into list: ${e} with size ${t.size}`);for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?this.tail&&(this.tail.next=t):this.head=t,this.tail=t,this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;let e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){let e=[],t=this.head;for(;null!==t;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};let t=e.value;return e=e.next,{done:!1,value:t}}}}}class nC{constructor(e,t=1024e3){this.level=e??"error",this.levelValue=n_.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new nS(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===n_.levels.values.error?console.error(e):t===n_.levels.values.warn?console.warn(e):t===n_.levels.values.debug?console.debug(e):t===n_.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append((0,L.u)({timestamp:new Date().toISOString(),log:e}));let t="string"==typeof e?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new nS(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){let t=this.getLogArray();return t.push((0,L.u)({extraMetadata:e})),new Blob(t,{type:"application/json"})}}class nR{constructor(e,t=1024e3){this.baseChunkLogger=new nC(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){let t=URL.createObjectURL(this.logsToBlob(e)),i=document.createElement("a");i.href=t,i.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(i),i.click(),document.body.removeChild(i),URL.revokeObjectURL(t)}}class nA{constructor(e,t=1024e3){this.baseChunkLogger=new nC(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}}var nT=Object.defineProperty,nN=Object.defineProperties,nk=Object.getOwnPropertyDescriptors,nL=Object.getOwnPropertySymbols,n$=Object.prototype.hasOwnProperty,nj=Object.prototype.propertyIsEnumerable,nD=(e,t,i)=>t in e?nT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,nM=(e,t)=>{for(var i in t||(t={}))n$.call(t,i)&&nD(e,i,t[i]);if(nL)for(var i of nL(t))nj.call(t,i)&&nD(e,i,t[i]);return e},nU=(e,t)=>nN(e,nk(t));function nq(e){return nU(nM({},e),{level:e?.level||nx.level})}function nB(e,t=nO){return typeof e.bindings>"u"?function(e,t=nO){return e[t]||""}(e,t):e.bindings().context||""}function nz(e,t,i=nO){let r=function(e,t,i=nO){let r=nB(e,i);return r.trim()?`${r}/${t}`:t}(e,t,i);return function(e,t,i=nO){return e[i]=t,e}(e.child({context:r}),r,i)}var nH=Object.defineProperty,nV=(e,t,i)=>t in e?nH(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,nW=(e,t,i)=>nV(e,"symbol"!=typeof t?t+"":t,i);
10class nK extends no{constructor(e){super(),this.opts=e,nW(this,"protocol","wc"),nW(this,"version",2)}}var nF=Object.defineProperty,nJ=(e,t,i)=>t in e?nF(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,nG=(e,t,i)=>nJ(e,"symbol"!=typeof t?t+"":t,i);class nY extends no{constructor(e,t){super(),this.core=e,this.logger=t,nG(this,"records",new Map)}}class nZ{constructor(e,t){this.logger=e,this.core=t}}class nQ extends no{constructor(e,t){super(),this.relayer=e,this.logger=t}}class nX extends no{constructor(e){super()}}class n0{constructor(e,t,i,r){this.core=e,this.logger=t,this.name=i}}class n1 extends no{constructor(e,t){super(),this.relayer=e,this.logger=t}}class n2 extends no{constructor(e,t){super(),this.core=e,this.logger=t}}class n5{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}}class n3{constructor(e,t){this.projectId=e,this.logger=t}}class n4{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}}var n8=Object.defineProperty,n6=(e,t,i)=>t in e?n8(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,n7=(e,t,i)=>n6(e,"symbol"!=typeof t?t+"":t,i);class n9{constructor(e){this.opts=e,n7(this,"protocol","wc"),n7(this,"version",2)}}class oe{constructor(e){this.client=e}}var ot=i(38979),oi=i(5276);let or=()=>"u">typeof WebSocket||"u">typeof i.g&&"u">typeof i.g.WebSocket||"u">typeof window&&"u">typeof window.WebSocket||"u">typeof self&&"u">typeof self.WebSocket,os=e=>e.split("?")[0],on="u">typeof WebSocket?WebSocket:"u">typeof i.g&&"u">typeof i.g.WebSocket?i.g.WebSocket:"u">typeof window&&"u">typeof window.WebSocket?window.WebSocket:"u">typeof self&&"u">typeof self.WebSocket?self.WebSocket:i(16854);class oo{constructor(e){if(this.url=e,this.events=new S.EventEmitter,this.registering=!1,!(0,oi.isWsUrl)(e))throw Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return"u">typeof this.socket}get connecting(){return this.registering}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 open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(Error("Connection already closed"));return}this.socket.onclose=t=>{this.onClose(t),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send((0,L.u)(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!(0,oi.isWsUrl)(e))throw Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){let e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise((e,t)=>{this.events.once("register_error",e=>{this.resetMaxListeners(),t(e)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return t(Error("WebSocket connection is missing or invalid"));e(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{let r=(0,oi.isReactNative)()?void 0:{rejectUnauthorized:!(0,oi.isLocalhostUrl)(e)},s=new on(e,[],r);or()?s.onerror=e=>{i(this.emitError(e.error))}:s.on("error",e=>{i(this.emitError(e))}),s.onopen=()=>{this.onOpen(s),t(s)}})}onOpen(e){e.onmessage=e=>this.onPayload(e),e.onclose=e=>this.onClose(e),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;let t="string"==typeof e.data?(0,L.D)(e.data):e.data;this.events.emit("payload",t)}onError(e,t){let i=this.parseError(t),r=i.message||i.toString(),s=(0,oi.formatJsonRpcError)(e,r);this.events.emit("payload",s)}parseError(e,t=this.url){return(0,oi.parseConnectionError)(e,os(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}emitError(e){let t=this.parseError(Error(e?.message||`WebSocket connection failed for host: ${os(this.url)}`));return this.events.emit("register_error",t),t}}var oa=i(15586),oc=i.n(oa);let ol="core",oh=`wc@2:${ol}:`,od={logger:"error"},ou={database:":memory:"},op="client_ed25519_seed",og=A.ONE_DAY,of=A.SIX_HOURS,om="wss://relay.walletconnect.org",oy={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",publish:"relayer_publish"},ob={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},ow="2.19.0",ov={link_mode:"link_mode",relay:"relay"},oE="WALLETCONNECT_LINK_MODE_APPS",o_={created:"subscription_created",deleted:"subscription_deleted",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},oI=1e3*A.FIVE_SECONDS,ox={wc_pairingDelete:{req:{ttl:A.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:A.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:A.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:A.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:A.ONE_DAY,prompt:!1,tag:0},res:{ttl:A.ONE_DAY,prompt:!1,tag:0}}},oO={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},oP={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},oS={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},oC="https://verify.walletconnect.org",oR=`${oC}/v3`,oA=["https://verify.walletconnect.com",oC],oT={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal"},oN={no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_listener_not_found:"proposal_listener_not_found"},ok={session_approve_started:"session_approve_started",session_namespaces_validation_success:"session_namespaces_validation_success",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},oL={no_internet_connection:"no_internet_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},o$={authenticated_session_approve_started:"authenticated_session_approve_started",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve"}
10,oj={no_internet_connection:"no_internet_connection",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"};var oD=function(e,t){if(e.length>=255)throw TypeError("Alphabet too long");for(var i=new Uint8Array(256),r=0;r<i.length;r++)i[r]=255;for(var s=0;s<e.length;s++){var n=e.charAt(s),o=n.charCodeAt(0);if(255!==i[o])throw TypeError(n+" is ambiguous");i[o]=s}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function d(e){if("string"!=typeof e)throw TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[0]){for(var r=0,s=0;e[t]===c;)r++,t++;for(var n=(e.length-t)*l+1>>>0,o=new Uint8Array(n);e[t];){var h=i[e.charCodeAt(t)];if(255===h)return;for(var d=0,u=n-1;(0!==h||d<s)&&-1!==u;u--,d++)h+=a*o[u]>>>0,o[u]=h%256>>>0,h=h/256>>>0;if(0!==h)throw Error("Non-zero carry");s=d,t++}if(" "!==e[t]){for(var p=n-s;p!==n&&0===o[p];)p++;for(var g=new Uint8Array(r+(n-p)),f=r;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 TypeError("Expected Uint8Array");if(0===t.length)return"";for(var i=0,r=0,s=0,n=t.length;s!==n&&0===t[s];)s++,i++;for(var o=(n-s)*h+1>>>0,l=new Uint8Array(o);s!==n;){for(var d=t[s],u=0,p=o-1;(0!==d||u<r)&&-1!==p;p--,u++)d+=256*l[p]>>>0,l[p]=d%a>>>0,d=d/a>>>0;if(0!==d)throw Error("Non-zero carry");r=u,s++}for(var g=o-r;g!==o&&0===l[g];)g++;for(var f=c.repeat(i);g<o;++g)f+=e.charAt(l[g]);return f},decodeUnsafe:d,decode:function(e){var i=d(e);if(i)return i;throw Error(`Non-${t} character`)}}};let oM=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 Error("Unknown type, must be binary type")},oU=e=>new TextEncoder().encode(e),oq=e=>new TextDecoder().decode(e);class oB{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class oz{constructor(e,t,i){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}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 oV(this,e)}}class oH{constructor(e){this.decoders=e}or(e){return oV(this,e)}decode(e){let t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}let oV=(e,t)=>new oH({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class oW{constructor(e,t,i,r){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=r,this.encoder=new oB(e,t,i),this.decoder=new oz(e,t,r)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}let oK=({name:e,prefix:t,encode:i,decode:r})=>new oW(e,t,i,r),oF=({prefix:e,name:t,alphabet:i})=>{let{encode:r,decode:s}=oD(i,t);return oK({prefix:e,name:t,encode:r,decode:e=>oM(s(e))})},oJ=(e,t,i,r)=>{let s={};for(let e=0;e<t.length;++e)s[t[e]]=e;let n=e.length;for(;"="===e[n-1];)--n;let o=new Uint8Array(n*i/8|0),a=0,c=0,l=0;for(let t=0;t<n;++t){let n=s[e[t]];if(void 0===n)throw SyntaxError(`Non-${r} character`);c=c<<i|n,(a+=i)>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=i||255&c<<8-a)throw SyntaxError("Unexpected end of data");return o},oG=(e,t,i)=>{let r="="===t[t.length-1],s=(1<<i)-1,n="",o=0,a=0;for(let r=0;r<e.length;++r)for(a=a<<8|e[r],o+=8;o>i;)o-=i,n+=t[s&a>>o];if(o&&(n+=t[s&a<<i-o]),r)for(;n.length*i&7;)n+="=";return n},oY=({name:e,prefix:t,bitsPerChar:i,alphabet:r})=>oK({prefix:t,name:e,encode:e=>oG(e,r,i),decode:t=>oJ(t,r,i,e)});var oZ=Object.freeze({__proto__:null,identity:oK({prefix:"\0",name:"identity",encode:e=>oq(e),decode:e=>oU(e)})}),oQ=Object.freeze({__proto__:null,base2:oY({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1})}),oX=Object.freeze({__proto__:null,base8:oY({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3})}),o0=Object.freeze({__proto__:null,base10:oF({prefix:"9",name:"base10",alphabet:"0123456789"})}),o1=Object.freeze({__proto__:null,base16:oY({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),base16upper:oY({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4})});let o2=oY({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),o5=oY({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),o3=oY({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),o4=oY({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),o8=oY({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),o6=oY({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5});
10var o7=Object.freeze({__proto__:null,base32:o2,base32upper:o5,base32pad:o3,base32padupper:o4,base32hex:o8,base32hexupper:o6,base32hexpad:oY({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),base32hexpadupper:oY({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),base32z:oY({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5})}),o9=Object.freeze({__proto__:null,base36:oF({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),base36upper:oF({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"})}),ae=Object.freeze({__proto__:null,base58btc:oF({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),base58flickr:oF({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"})});let at=oY({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6});var ai=Object.freeze({__proto__:null,base64:at,base64pad:oY({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),base64url:oY({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),base64urlpad:oY({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6})});let ar=Array.from("\uD83D\uDE80\uD83E\uDE90â\uD83D\uDEF0\uD83C\uDF0C\uD83C\uDF11\uD83C\uDF12\uD83C\uDF13\uD83C\uDF14\uD83C\uDF15\uD83C\uDF16\uD83C\uDF17\uD83C\uDF18\uD83C\uDF0D\uD83C\uDF0F\uD83C\uDF0E\uD83D\uDC09â\uD83D\uDCBB\uD83D\uDDA5\uD83D\uDCBE\uD83D\uDCBF\uD83D\uDE02â¤\uD83D\uDE0D\uD83E\uDD23\uD83D\uDE0A\uD83D\uDE4F\uD83D\uDC95\uD83D\uDE2D\uD83D\uDE18\uD83D\uDC4D\uD83D\uDE05\uD83D\uDC4F\uD83D\uDE01\uD83D\uDD25\uD83E\uDD70\uD83D\uDC94\uD83D\uDC96\uD83D\uDC99\uD83D\uDE22\uD83E\uDD14\uD83D\uDE06\uD83D\uDE44\uD83D\uDCAA\uD83D\uDE09âº\uD83D\uDC4C\uD83E\uDD17\uD83D\uDC9C\uD83D\uDE14\uD83D\uDE0E\uD83D\uDE07\uD83C\uDF39\uD83E\uDD26\uD83C\uDF89\uD83D\uDC9Eââ¨\uD83E\uDD37\uD83D\uDE31\uD83D\uDE0C\uD83C\uDF38\uD83D\uDE4C\uD83D\uDE0B\uD83D\uDC97\uD83D\uDC9A\uD83D\uDE0F\uD83D\uDC9B\uD83D\uDE42\uD83D\uDC93\uD83E\uDD29\uD83D\uDE04\uD83D\uDE00\uD83D\uDDA4\uD83D\uDE03\uD83D\uDCAF\uD83D\uDE48\uD83D\uDC47\uD83C\uDFB6\uD83D\uDE12\uD83E\uDD2Dâ£\uD83D\uDE1C\uD83D\uDC8B\uD83D\uDC40\uD83D\uDE2A\uD83D\uDE11\uD83D\uDCA5\uD83D\uDE4B\uD83D\uDE1E\uD83D\uDE29\uD83D\uDE21\uD83E\uDD2A\uD83D\uDC4A\uD83E\uDD73\uD83D\uDE25\uD83E\uDD24\uD83D\uDC49\uD83D\uDC83\uD83D\uDE33â\uD83D\uDE1A\uD83D\uDE1D\uD83D\uDE34\uD83C\uDF1F\uD83D\uDE2C\uD83D\uDE43\uD83C\uDF40\uD83C\uDF37\uD83D\uDE3B\uD83D\uDE13ââ
\uD83E\uDD7A\uD83C\uDF08\uD83D\uDE08\uD83E\uDD18\uD83D\uDCA6â\uD83D\uDE23\uD83C\uDFC3\uD83D\uDC90â¹\uD83C\uDF8A\uD83D\uDC98\uD83D\uDE20â\uD83D\uDE15\uD83C\uDF3A\uD83C\uDF82\uD83C\uDF3B\uD83D\uDE10\uD83D\uDD95\uD83D\uDC9D\uD83D\uDE4A\uD83D\uDE39\uD83D\uDDE3\uD83D\uDCAB\uD83D\uDC80\uD83D\uDC51\uD83C\uDFB5\uD83E\uDD1E\uD83D\uDE1B\uD83D\uDD34\uD83D\uDE24\uD83C\uDF3C\uD83D\uDE2Bâ½\uD83E\uDD19â\uD83C\uDFC6\uD83E\uDD2B\uD83D\uDC48\uD83D\uDE2E\uD83D\uDE46\uD83C\uDF7B\uD83C\uDF43\uD83D\uDC36\uD83D\uDC81\uD83D\uDE32\uD83C\uDF3F\uD83E\uDDE1\uD83C\uDF81â¡\uD83C\uDF1E\uD83C\uDF88ââ\uD83D\uDC4B\uD83D\uDE30\uD83E\uDD28\uD83D\uDE36\uD83E\uDD1D\uD83D\uDEB6\uD83D\uDCB0\uD83C\uDF53\uD83D\uDCA2\uD83E\uDD1F\uD83D\uDE41\uD83D\uDEA8\uD83D\uDCA8\uD83E\uDD2Câ\uD83C\uDF80\uD83C\uDF7A\uD83E\uDD13\uD83D\uDE19\uD83D\uDC9F\uD83C\uDF31\uD83D\uDE16\uD83D\uDC76\uD83E\uDD74â¶â¡â\uD83D\uDC8E\uD83D\uDCB8â¬\uD83D\uDE28\uD83C\uDF1A\uD83E\uDD8B\uD83D\uDE37\uD83D\uDD7Aâ \uD83D\uDE45\uD83D\uDE1F\uD83D\uDE35\uD83D\uDC4E\uD83E\uDD32\uD83E\uDD20\uD83E\uDD27\uD83D\uDCCC\uD83D\uDD35\uD83D\uDC85\uD83E\uDDD0\uD83D\uDC3E\uD83C\uDF52\uD83D\uDE17\uD83E\uDD11\uD83C\uDF0A\uD83E\uDD2F\uD83D\uDC37â\uD83D\uDCA7\uD83D\uDE2F\uD83D\uDC86\uD83D\uDC46\uD83C\uDFA4\uD83D\uDE47\uD83C\uDF51â\uD83C\uDF34\uD83D\uDCA3\uD83D\uDC38\uD83D\uDC8C\uD83D\uDCCD\uD83E\uDD40\uD83E\uDD22\uD83D\uDC45\uD83D\uDCA1\uD83D\uDCA9\uD83D\uDC50\uD83D\uDCF8\uD83D\uDC7B\uD83E\uDD10\uD83E\uDD2E\uD83C\uDFBC\uD83E\uDD75\uD83D\uDEA9\uD83C\uDF4E\uD83C\uDF4A\uD83D\uDC7C\uD83D\uDC8D\uD83D\uDCE3\uD83E\uDD42"),as=ar.reduce((e,t,i)=>(e[i]=t,e),[]),an=ar.reduce((e,t,i)=>(e[t.codePointAt(0)]=i,e),[]);var ao=Object.freeze({__proto__:null,base256emoji:oK({prefix:"\uD83D\uDE80",name:"base256emoji",encode:function(e){return e.reduce((e,t)=>
10e+=as[t],"")},decode:function(e){let t=[];for(let i of e){let e=an[i.codePointAt(0)];if(void 0===e)throw Error(`Non-base256emoji character: ${i}`);t.push(e)}return new Uint8Array(t)}})});function aa(e,t){var i,r=0,t=t||0,s=0,n=t,o=e.length;do{if(n>=o)throw aa.bytes=0,RangeError("Could not decode varint");i=e[n++],r+=s<28?(127&i)<<s:(127&i)*Math.pow(2,s),s+=7}while(i>=128);return aa.bytes=n-t,r}var ac=function e(t,i,r){i=i||[],r=r||0;for(var s=r;t>=2147483648;)i[r++]=255&t|128,t/=128;for(;-128&t;)i[r++]=255&t|128,t>>>=7;return i[r]=0|t,e.bytes=r-s+1,i};let al=(e,t,i=0)=>(ac(e,t,i),t),ah=e=>e<128?1:e<16384?2:e<2097152?3:e<268435456?4:e<34359738368?5:e<4398046511104?6:e<562949953421312?7:e<72057594037927940?8:e<0x7fffffffffffffff?9:10,ad=(e,t)=>{let i=t.byteLength,r=ah(e),s=r+ah(i),n=new Uint8Array(s+i);return al(e,n,0),al(i,n,r),n.set(t,s),new au(e,i,t,n)};class au{constructor(e,t,i,r){this.code=e,this.size=t,this.digest=i,this.bytes=r}}let ap=({name:e,code:t,encode:i})=>new ag(e,t,i);class ag{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){let t=this.encode(e);return t instanceof Uint8Array?ad(this.code,t):t.then(e=>ad(this.code,e))}throw Error("Unknown type, must be binary type")}}let af=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t));var am=Object.freeze({__proto__:null,sha256:ap({name:"sha2-256",code:18,encode:af("SHA-256")}),sha512:ap({name:"sha2-512",code:19,encode:af("SHA-512")})}),ay=Object.freeze({__proto__:null,identity:{code:0,name:"identity",encode:oM,digest:e=>ad(0,oM(e))}});new TextEncoder,new TextDecoder;let ab={...oZ,...oQ,...oX,...o0,...o1,...o7,...o9,...ae,...ai,...ao};function aw(e,t,i,r){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:i},decoder:{decode:r}}}({...am,...ay});let av=aw("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),aE=aw("ascii","a",e=>{let t="a";for(let i=0;i<e.length;i++)t+=String.fromCharCode(e[i]);return t},e=>{let 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 i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}),a_={utf8:av,"utf-8":av,hex:ab.base16,latin1:aE,ascii:aE,binary:aE,...ab};var aI=Object.defineProperty,ax=(e,t,i)=>t in e?aI(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,aO=(e,t,i)=>ax(e,"symbol"!=typeof t?t+"":t,i);class aP{constructor(e,t){this.core=e,this.logger=t,aO(this,"keychain",new Map),aO(this,"name","keychain"),aO(this,"version","0.3"),aO(this,"initialized",!1),aO(this,"storagePrefix",oh),aO(this,"init",async()=>{if(!this.initialized){let e=await this.getKeyChain();"u">typeof e&&(this.keychain=e),this.initialized=!0}}),aO(this,"has",e=>(this.isInitialized(),this.keychain.has(e))),aO(this,"set",async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()}),aO(this,"get",e=>{this.isInitialized();let t=this.keychain.get(e);if(typeof t>"u"){let{message:t}=sY("NO_MATCHING_KEY",`${this.name}: ${e}`);throw Error(t)}return t}),aO(this,"del",async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()}),this.core=e,this.logger=nz(t,this.name)}get context(){return nB(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,id(e))}async getKeyChain(){let e=await this.core.storage.getItem(this.storageKey);return"u">typeof e?iu(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){let{message:e}=sY("NOT_INITIALIZED",this.name);throw Error(e)}}}var aS=Object.defineProperty,aC=(e,t,i)=>t in e?aS(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,aR=(e,t,i)=>aC(e,"symbol"!=typeof t?t+"":t,i);class aA{constructor(e,t,i){this.core=e,this.logger=t,aR(this,"name","crypto"),aR(this,"keychain"),aR(this,"randomSessionIdentifier",sA()),aR(this,"initialized",!1),aR(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),aR(this,"hasKeys",e=>(this.isInitialized(),this.keychain.has(e))),aR(this,"getClientId",async()=>(this.isInitialized(),tX(t1(await this.getClientSeed()).publicKey))),aR(this,"generateKeyPair",()=>{this.isInitialized();let e=function(){let e=sx.utils.randomPrivateKey(),t=sx.getPublicKey(e);return{privateKey:(0,t5.BB)(e,sP),publicKey:(0,t5.BB)(t,sP)}}();return this.setPrivateKey(e.publicKey,e.privateKey)}),aR(this,"signJWT",async e=>{this.isInitialized();let t=t1(await this.getClientSeed()),i=this.randomSessionIdentifier;return await t2(i,e,og,t)}),aR(this,"generateSharedKey",(e,t,i)=>{this.isInitialized();let r=function(e,t){let i=r3(se,sx.getSharedSecret((0,t5.mL)(e,sP),(0,t5.mL)(t,sP)),void 0,void 0,32);return(0,t5.BB)(i,sP)}(this.getPrivateKey(e),t);return this.setSymKey(r,i)}),aR(this,"setSymKey",async(e,t)=>{this.isInitialized();let i=t||sT(e);return await this.keychain.set(i,e),i}),aR(this,"deleteKeyPair",async e=>{this.isInitialized(),await this.keychain.del(e)}),aR(this,"deleteSymKey",async e=>{this.isInitialized(),await this.keychain.del(e)}),aR(this,"encode",async(e,t,i)=>{this.isInitialized();let r=sD(i),s=(0,L.u)(t);if(2===r.type)return function(e,t){let i=sk(2),r=iF(12);return s$({type:i,sealed:(0,t5.mL)(e,sR),iv:r,encoding:t})}(s,i?.encoding);
10if(sM(r)){let t=r.senderPublicKey,i=r.receiverPublicKey;e=await this.generateSharedKey(t,i)}let n=this.getSymKey(e),{type:o,senderPublicKey:a}=r;return function(e){let t=sk("u">typeof e.type?e.type:0);if(1===sL(t)&&typeof e.senderPublicKey>"u")throw Error("Missing sender public key for type 1 envelope");let i="u">typeof e.senderPublicKey?(0,t5.mL)(e.senderPublicKey,sP):void 0,r="u">typeof e.iv?(0,t5.mL)(e.iv,sP):iF(12);return s$({type:t,sealed:rX((0,t5.mL)(e.symKey,sP),r).encrypt((0,t5.mL)(e.message,sR)),iv:r,senderPublicKey:i,encoding:e.encoding})}({type:o,symKey:n,message:s,senderPublicKey:a,encoding:i?.encoding})}),aR(this,"decode",async(e,t,i)=>{this.isInitialized();let r=function(e,t){let i=sj({encoded:e,encoding:t?.encoding});return sD({type:sL(i.type),senderPublicKey:"u">typeof i.senderPublicKey?(0,t5.BB)(i.senderPublicKey,sP):void 0,receiverPublicKey:t?.receiverPublicKey})}(t,i);if(2===r.type){let e=function(e,t){let{sealed:i}=sj({encoded:e,encoding:t});return(0,t5.BB)(i,sR)}(t,i?.encoding);return(0,L.D)(e)}if(sM(r)){let t=r.receiverPublicKey,i=r.senderPublicKey;e=await this.generateSharedKey(t,i)}try{let r=this.getSymKey(e),s=function(e){let t=(0,t5.mL)(e.symKey,sP),{sealed:i,iv:r}=sj(e),s=rX(t,r).decrypt(i);if(null===s)throw Error("Failed to decrypt");return(0,t5.BB)(s,sR)}({symKey:r,encoded:t,encoding:i?.encoding});return(0,L.D)(s)}catch(t){this.logger.error(`Failed to decode message from topic: '${e}', clientId: '${await this.getClientId()}'`),this.logger.error(t)}}),aR(this,"getPayloadType",(e,t=sS)=>sL(sj({encoded:e,encoding:t}).type)),aR(this,"getPayloadSenderPublicKey",(e,t=sS)=>{let i=sj({encoded:e,encoding:t});return i.senderPublicKey?(0,t5.BB)(i.senderPublicKey,sP):void 0}),this.core=e,this.logger=nz(t,this.name),this.keychain=i||new aP(this.core,this.logger)}get context(){return nB(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(op)}catch{e=sA(),await this.keychain.set(op,e)}return function(e,t="utf8"){let i=a_[t];if(!i)throw Error(`Unsupported encoding "${t}"`);return("utf8"===t||"utf-8"===t)&&null!=globalThis.Buffer&&null!=globalThis.Buffer.from?globalThis.Buffer.from(e,"utf8"):i.decoder.decode(`${i.prefix}${e}`)}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){let{message:e}=sY("NOT_INITIALIZED",this.name);throw Error(e)}}}var aT=Object.defineProperty,aN=(e,t,i)=>t in e?aT(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,ak=(e,t,i)=>aN(e,"symbol"!=typeof t?t+"":t,i);class aL extends nZ{constructor(e,t){super(e,t),this.logger=e,this.core=t,ak(this,"messages",new Map),ak(this,"name","messages"),ak(this,"version","0.3"),ak(this,"initialized",!1),ak(this,"storagePrefix",oh),ak(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{let e=await this.getRelayerMessages();"u">typeof e&&(this.messages=e),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}}}),ak(this,"set",async(e,t)=>{this.isInitialized();let i=sN(t),r=this.messages.get(e);return typeof r>"u"&&(r={}),"u">typeof r[i]||(r[i]=t,this.messages.set(e,r),await this.persist()),i}),ak(this,"get",e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t}),ak(this,"has",(e,t)=>(this.isInitialized(),"u">typeof this.get(e)[sN(t)])),ak(this,"del",async e=>{this.isInitialized(),this.messages.delete(e),await this.persist()}),this.logger=nz(e,this.name),this.core=t}get context(){return nB(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,id(e))}async getRelayerMessages(){let e=await this.core.storage.getItem(this.storageKey);return"u">typeof e?iu(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){let{message:e}=sY("NOT_INITIALIZED",this.name);throw Error(e)}}}var a$=Object.defineProperty,aj=Object.defineProperties,aD=Object.getOwnPropertyDescriptors,aM=Object.getOwnPropertySymbols,aU=Object.prototype.hasOwnProperty,aq=Object.prototype.propertyIsEnumerable,aB=(e,t,i)=>t in e?a$(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,az=(e,t)=>
10{for(var i in t||(t={}))aU.call(t,i)&&aB(e,i,t[i]);if(aM)for(var i of aM(t))aq.call(t,i)&&aB(e,i,t[i]);return e},aH=(e,t)=>aj(e,aD(t)),aV=(e,t,i)=>aB(e,"symbol"!=typeof t?t+"":t,i);class aW extends nQ{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,aV(this,"events",new S.EventEmitter),aV(this,"name","publisher"),aV(this,"queue",new Map),aV(this,"publishTimeout",(0,A.toMiliseconds)(A.ONE_MINUTE)),aV(this,"initialPublishTimeout",(0,A.toMiliseconds)(15*A.ONE_SECOND)),aV(this,"needsTransportRestart",!1),aV(this,"publish",async(e,t,i)=>{var r;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:i}});let s=i?.ttl||of,n=sU(i),o=i?.prompt||!1,a=i?.tag||0,c=i?.id||(0,oi.getBigIntRpcId)().toString(),l={topic:e,message:t,opts:{ttl:s,relay:n,prompt:o,tag:a,id:c,attestation:i?.attestation,tvf:i?.tvf}},h=`Failed to publish payload, please try again. id:${c} tag:${a}`;try{let r=new Promise(async r=>{let n=({id:e})=>{l.opts.id===e&&(this.removeRequestFromQueue(e),this.relayer.events.removeListener(oy.publish,n),r(l))};this.relayer.events.on(oy.publish,n);let h=ig(new Promise((r,n)=>{this.rpcPublish({topic:e,message:t,ttl:s,prompt:o,tag:a,id:c,attestation:i?.attestation,tvf:i?.tvf}).then(r).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(oy.publish,n)}catch(e){this.queue.set(c,aH(az({},l),{attempt:1})),this.logger.warn(e,e?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:c,topic:e,message:t,opts:i}}),await ig(r,this.publishTimeout,h)}catch(e){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(e),null!=(r=i?.internal)&&r.throwOnFailedPublish)throw e}finally{this.queue.delete(c)}}),aV(this,"on",(e,t)=>{this.events.on(e,t)}),aV(this,"once",(e,t)=>{this.events.once(e,t)}),aV(this,"off",(e,t)=>{this.events.off(e,t)}),aV(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.relayer=e,this.logger=nz(t,this.name),this.registerEventListeners()}get context(){return nB(this.logger)}async rpcPublish(e){var t,i,r,s;let{topic:n,message:o,ttl:a=of,prompt:c,tag:l,id:h,attestation:d,tvf:u}=e,p={method:sq(sU().protocol).publish,params:az({topic:n,message:o,ttl:a,prompt:c,tag:l,attestation:d},u),id:h};s0(null==(t=p.params)?void 0:t.prompt)&&(null==(i=p.params)||delete i.prompt),s0(null==(r=p.params)?void 0:r.tag)&&(null==(s=p.params)||delete s.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:p});let g=await this.relayer.request(p);return this.relayer.events.emit(oy.publish,e),this.logger.debug("Successfully Published Payload"),g}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{let i=e.attempt+1;this.queue.set(t,aH(az({},e),{attempt:i}));let{topic:r,message:s,opts:n,attestation:o}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish(aH(az({},e),{topic:r,message:s,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(nl,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(oy.connection_stalled);return}this.checkQueue()}),this.relayer.on(oy.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var aK=Object.defineProperty,aF=(e,t,i)=>t in e?aK(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,aJ=(e,t,i)=>aF(e,"symbol"!=typeof t?t+"":t,i);class aG{constructor(){aJ(this,"map",new Map),aJ(this,"set",(e,t)=>{let i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])}),aJ(this,"get",e=>this.map.get(e)||[]),aJ(this,"exists",(e,t)=>this.get(e).includes(t)),aJ(this,"delete",(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;let i=this.get(e);if(!this.exists(e,t))return;let r=i.filter(e=>e!==t);if(!r.length){this.map.delete(e);return}this.map.set(e,r)}),aJ(this,"clear",()=>{this.map.clear()})}
10get topics(){return Array.from(this.map.keys())}}var aY=Object.defineProperty,aZ=Object.defineProperties,aQ=Object.getOwnPropertyDescriptors,aX=Object.getOwnPropertySymbols,a0=Object.prototype.hasOwnProperty,a1=Object.prototype.propertyIsEnumerable,a2=(e,t,i)=>t in e?aY(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,a5=(e,t)=>{for(var i in t||(t={}))a0.call(t,i)&&a2(e,i,t[i]);if(aX)for(var i of aX(t))a1.call(t,i)&&a2(e,i,t[i]);return e},a3=(e,t)=>aZ(e,aQ(t)),a4=(e,t,i)=>a2(e,"symbol"!=typeof t?t+"":t,i);class a8 extends n1{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,a4(this,"subscriptions",new Map),a4(this,"topicMap",new aG),a4(this,"events",new S.EventEmitter),a4(this,"name","subscription"),a4(this,"version","0.3"),a4(this,"pending",new Map),a4(this,"cached",[]),a4(this,"initialized",!1),a4(this,"pendingSubscriptionWatchLabel","pending_sub_watch_label"),a4(this,"pollingInterval",20),a4(this,"storagePrefix",oh),a4(this,"subscribeTimeout",(0,A.toMiliseconds)(A.ONE_MINUTE)),a4(this,"initialSubscribeTimeout",(0,A.toMiliseconds)(15*A.ONE_SECOND)),a4(this,"clientId"),a4(this,"batchSubscribeTopicsLimit",500),a4(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),a4(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{let i=sU(t),r={topic:e,relay:i,transportType:t?.transportType};this.pending.set(e,r);let s=await this.rpcSubscribe(e,i,t);return"string"==typeof s&&(this.onSubscribe(s,r),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}})),s}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}}),a4(this,"unsubscribe",async(e,t)=>{this.isInitialized(),"u">typeof t?.id?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)}),a4(this,"isSubscribed",async e=>{if(this.topics.includes(e))return!0;let t=`${this.pendingSubscriptionWatchLabel}_${e}`;return await new Promise((i,r)=>{let s=new A.Watch;s.start(t);let n=setInterval(()=>{(!this.pending.has(e)&&this.topics.includes(e)||this.cached.some(t=>t.topic===e))&&(clearInterval(n),s.stop(t),i(!0)),s.elapsed(t)>=oI&&(clearInterval(n),s.stop(t),r(Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)}),a4(this,"on",(e,t)=>{this.events.on(e,t)}),a4(this,"once",(e,t)=>{this.events.once(e,t)}),a4(this,"off",(e,t)=>{this.events.off(e,t)}),a4(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),a4(this,"start",async()=>{await this.onConnect()}),a4(this,"stop",async()=>{await this.onDisconnect()}),a4(this,"restart",async()=>{await this.restore(),await this.onRestart()}),a4(this,"checkPending",async()=>{if(0===this.pending.size&&(!this.initialized||!this.relayer.connected))return;let e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e)}),a4(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(nl,async()=>{await this.checkPending()}),this.events.on(o_.created,async e=>{let t=o_.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(o_.deleted,async e=>{let t=o_.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}),this.relayer=e,this.logger=nz(t,this.name),this.clientId=""}get context(){return nB(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 i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){let i=this.topicMap.get(e);await Promise.all(i.map(async i=>await this.unsubscribeById(e,i,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{let r=sU(i);await this.restartToComplete({topic:e,id:t,relay:r}),await this.rpcUnsubscribe(e,t,r);let s=sZ("USER_DISCONNECTED",`${this.name}, ${e}`);
10await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t,i){var r;i&&i?.transportType!==ov.relay||await this.restartToComplete({topic:e,id:e,relay:t});let s={method:sq(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});let n=null==(r=i?.internal)?void 0:r.throwOnFailedPublish;try{let t=await this.getSubscriptionId(e);if(i?.transportType===ov.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(e=>this.logger.warn(e))},(0,A.toMiliseconds)(A.ONE_SECOND)),t;let r=new Promise(async t=>{let i=r=>{r.topic===e&&(this.events.removeListener(o_.created,i),t(r.id))};this.events.on(o_.created,i);try{let r=await ig(new Promise((e,t)=>{this.relayer.request(s).catch(e=>{this.logger.warn(e,e?.message),t(e)}).then(e)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(o_.created,i),t(r)}catch{}}),o=await ig(r,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!o&&n)throw 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(oy.connection_stalled),n)throw e}return null}async rpcBatchSubscribe(e){if(!e.length)return;let t={method:sq(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 ig(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(oy.connection_stalled)}}async rpcBatchFetchMessages(e){let t;if(!e.length)return;let i={method:sq(e[0].relay.protocol).batchFetchMessages,params:{topics:e.map(e=>e.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{t=await await ig(new Promise((e,t)=>{this.relayer.request(i).catch(e=>{this.logger.warn(e),t(e)}).then(e)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(oy.connection_stalled)}return t}rpcUnsubscribe(e,t,i){let r={method:sq(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r}),this.relayer.request(r)}onSubscribe(e,t){this.setSubscription(e,a3(a5({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(e=>{this.setSubscription(e.id,a5({},e)),this.pending.delete(e.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),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,a5({},t)),this.topicMap.set(t.topic,e),this.events.emit(o_.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});let t=this.subscriptions.get(e);if(!t){let{message:t}=sY("NO_MATCHING_KEY",`${this.name}: ${e}`);throw Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});let i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(o_.deleted,a3(a5({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(o_.sync)}
10async onRestart(){if(this.cached.length){let e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<t;i++){let t=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(t)}}this.events.emit(o_.resubscribed)}async restore(){try{let e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){let{message:e}=sY("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),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=>a3(a5({},e),{id:await this.getSubscriptionId(e.topic)})))))}async batchFetchMessages(e){var t;if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);let i=await this.rpcBatchFetchMessages(e);i&&i.messages&&(await (t=(0,A.toMiliseconds)(A.ONE_SECOND),new Promise(e=>setTimeout(e,t))),await this.relayer.handleBatchMessageEvents(i.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){let{message:e}=sY("NOT_INITIALIZED",this.name);throw 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 sN(e+await this.getClientId())}}var a6=Object.defineProperty,a7=Object.getOwnPropertySymbols,a9=Object.prototype.hasOwnProperty,ce=Object.prototype.propertyIsEnumerable,ct=(e,t,i)=>t in e?a6(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,ci=(e,t)=>{for(var i in t||(t={}))a9.call(t,i)&&ct(e,i,t[i]);if(a7)for(var i of a7(t))ce.call(t,i)&&ct(e,i,t[i]);return e},cr=(e,t,i)=>ct(e,"symbol"!=typeof t?t+"":t,i);class cs extends nX{constructor(e){super(e),cr(this,"protocol","wc"),cr(this,"version",2),cr(this,"core"),cr(this,"logger"),cr(this,"events",new S.EventEmitter),cr(this,"provider"),cr(this,"messages"),cr(this,"subscriber"),cr(this,"publisher"),cr(this,"name","relayer"),cr(this,"transportExplicitlyClosed",!1),cr(this,"initialized",!1),cr(this,"connectionAttemptInProgress",!1),cr(this,"relayUrl"),cr(this,"projectId"),cr(this,"packageName"),cr(this,"bundleId"),cr(this,"hasExperiencedNetworkDisruption",!1),cr(this,"pingTimeout"),cr(this,"heartBeatTimeout",(0,A.toMiliseconds)(A.THIRTY_SECONDS+A.FIVE_SECONDS)),cr(this,"reconnectTimeout"),cr(this,"connectPromise"),cr(this,"reconnectInProgress",!1),cr(this,"requestsInFlight",[]),cr(this,"connectTimeout",(0,A.toMiliseconds)(15*A.ONE_SECOND)),cr(this,"request",async e=>{var t,i;this.logger.debug("Publishing Request Payload");let r=e.id||(0,oi.getBigIntRpcId)().toString();await this.toEstablishConnection();try{this.logger.trace({id:r,method:e.method,topic:null==(t=e.params)?void 0:t.topic},"relayer.request - publishing...");let s=`${r}:${(null==(i=e.params)?void 0:i.tag)||""}`;this.requestsInFlight.push(s);let n=await this.provider.request(e);return this.requestsInFlight=this.requestsInFlight.filter(e=>e!==s),n}catch(e){throw this.logger.debug(`Failed to Publish Request: ${r}`),e}}),cr(this,"resetPingTimeout",()=>{if(ii())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var e,t,i;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),null==(i=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)||i.terminate()},this.heartBeatTimeout)}catch(e){this.logger.warn(e,e?.message)}}),cr(this,"onPayloadHandler",e=>{this.onProviderPayload(e),this.resetPingTimeout()}),cr(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected \uD83D\uDEDC"),this.startPingTimeout(),this.events.emit(oy.connect)}),cr(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected \uD83D\uDED1"),this.requestsInFlight=[],this.onProviderDisconnect()}),cr(this,"onProviderErrorHandler",e=>{this.logger.fatal(`Fatal socket error: ${e.message}`),this.events.emit(oy.error,e),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),cr(this,"registerProviderListeners",()=>{this.provider.on(ob.payload,this.onPayloadHandler),this.provider.on(ob.connect,this.onConnectHandler),this.provider.on(ob.disconnect,this.onDisconnectHandler),this.provider.on(ob.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger="u">typeof e.logger&&"string"!=typeof e.logger?nz(e.logger,this.name):nI()(nq({level:e.logger||"error"})),this.messages=new aL(this.logger,e.core),this.subscriber=new a8(this,this.logger),this.publisher=new aW(this,this.logger),this.relayUrl=e?.relayUrl||om,this.projectId=e.projectId,ir()&&"u">typeof i.g&&"u">typeof(null==i.g?void 0:i.g.Platform)&&(null==i.g?void 0:i.g.Platform.OS)==="android"?this.packageName=ia():ir()&&"u">typeof i.g&&"u">typeof(null==i.g?void 0:i.g.Platform)&&(null==i.g?void 0:i.g.Platform.OS)==="ios"&&(this.bundleId=ia()),this.provider={}}
10async 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 nB(this.logger)}get connected(){var e,t,i;return(null==(i=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:i.readyState)===1}get connecting(){var e,t,i;return(null==(i=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:i.readyState)===0||void 0!==this.connectPromise}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:ov.relay})}async subscribe(e,t){var i,r,s;this.isInitialized(),null!=t&&t.transportType&&t?.transportType!=="relay"||await this.toEstablishConnection();let n=typeof(null==(i=t?.internal)?void 0:i.throwOnFailedPublish)>"u"||(null==(r=t?.internal)?void 0:r.throwOnFailedPublish),o=(null==(s=this.subscriber.topicMap.get(e))?void 0:s[0])||"",a,c=t=>{t.topic===e&&(this.subscriber.off(o_.created,c),a())};return await Promise.all([new Promise(e=>{a=e,this.subscriber.on(o_.created,c)}),new Promise(async(i,r)=>{o=await this.subscriber.subscribe(e,ci({internal:{throwOnFailedPublish:n}},t)).catch(e=>{n&&r(e)})||o,i()})]),o}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 ig(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){this.logger.warn("Starting WS connection skipped because the client has no topics to work with.");return}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,i)=>{await this.connect(e).then(t).catch(i).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}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 ni())throw Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}let t=e.sort((e,t)=>e.publishedAt-t.publishedAt);for(let e of(this.logger.debug(`Batch of ${t.length} message events sorted`),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){let{topic:i}=e;if(!t.sessionExists){let e=ib(A.FIVE_MINUTES);await this.core.pairing.pairings.set(i,{topic:i,expiry:e,relay:{protocol:"irn"},active:!1})}this.events.emit(oy.message,e),await this.recordMessageEvent(e)}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)=>{let i=()=>{t(Error("Connection interrupted while trying to subscribe"))};
10this.provider.once(ob.disconnect,i),await ig(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(ob.disconnect,i),clearTimeout(this.reconnectTimeout)}),await new Promise(async(e,t)=>{let i=()=>{t(Error("Connection interrupted while trying to subscribe"))};this.provider.once(ob.disconnect,i),await this.subscriber.start().then(e).catch(t).finally(()=>{this.provider.off(ob.disconnect,i)})}),this.hasExperiencedNetworkDisruption=!1,e()})}catch(e){await this.subscriber.stop(),this.logger.warn({},e.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,A.toMiliseconds)(1*t))),t++}}startPingTimeout(){var e,t,i,r,s;if(ii())try{null!=(t=null==(e=this.provider)?void 0:e.connection)&&t.socket&&(null==(s=null==(r=null==(i=this.provider)?void 0:i.connection)?void 0:r.socket)||s.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(e){this.logger.warn(e,e?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();let e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new ot.JsonRpcProvider(new oo(function({protocol:e,version:t,relayUrl:i,sdkVersion:r,auth:s,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){let l=i.split("?"),h=il(e,t,r),d=function(e,t){let i=new URLSearchParams(e);for(let e of Object.keys(t).sort())if(t.hasOwnProperty(e)){let r=t[e];void 0!==r&&i.set(e,r)}return i.toString()}(l[1]||"",{auth:s,ua:h,projectId:n,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0});return l[0]+"?"+d}({sdkVersion:ow,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){let{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){let{topic:t,message:i}=e;if(!i||0===i.length)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.warn(`Ignoring message for non-subscribed topic ${t}`),!0;let r=this.messages.has(t,i);return r&&this.logger.warn(`Ignoring duplicate message: ${i}`),r}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),(0,oi.isJsonRpcRequest)(e)){if(!e.method.endsWith("_subscription"))return;let t=e.params,{topic:i,message:r,publishedAt:s,attestation:n}=t.data,o={topic:i,message:r,publishedAt:s,transportType:ov.relay,attestation:n};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(ci({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o)}else(0,oi.isJsonRpcResponse)(e)&&this.events.emit(oy.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(oy.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){let t=(0,oi.formatJsonRpcResult)(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(ob.payload,this.onPayloadHandler),this.provider.off(ob.connect,this.onConnectHandler),this.provider.off(ob.disconnect,this.onDisconnectHandler),this.provider.off(ob.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await ni();!function(e){switch(io()){case it.browser:!ir()&&is()&&(window.addEventListener("online",()=>e(!0)),window.addEventListener("offline",()=>e(!1)));break;case it.reactNative:ir()&&"u">typeof i.g&&null!=i.g&&i.g.NetInfo&&i.g?.NetInfo.addEventListener(t=>e(t?.isConnected));case it.node:}}(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))})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(oy.disconnect),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,A.toMiliseconds)(.1)))))}isInitialized(){if(!this.initialized){let{message:e}=sY("NOT_INITIALIZED",this.name);throw Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),this.connected||await this.connect()}}var cn=Object.defineProperty,co=Object.getOwnPropertySymbols,ca=Object.prototype.hasOwnProperty,cc=Object.prototype.propertyIsEnumerable,cl=(e,t,i)=>t in e?cn(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,ch=(e,t)=>{for(var i in t||(t={}))ca.call(t,i)&&cl(e,i,t[i]);if(co)for(var i of co(t))cc.call(t,i)&&cl(e,i,t[i]);return e}
10,cd=(e,t,i)=>cl(e,"symbol"!=typeof t?t+"":t,i);class cu extends n0{constructor(e,t,i,r=oh,s){super(e,t,i,r),this.core=e,this.logger=t,this.name=i,cd(this,"map",new Map),cd(this,"version","0.3"),cd(this,"cached",[]),cd(this,"initialized",!1),cd(this,"getKey"),cd(this,"storagePrefix",oh),cd(this,"recentlyDeleted",[]),cd(this,"recentlyDeletedLimit",200),cd(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>{var t;this.getKey&&null!==e&&!s0(e)?this.map.set(this.getKey(e),e):(null==(t=e?.proposer)?void 0:t.publicKey)?this.map.set(e.id,e):e?.topic&&this.map.set(e.topic,e)}),this.cached=[],this.initialized=!0)}),cd(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())}),cd(this,"get",e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e))),cd(this,"getAll",e=>(this.isInitialized(),e?this.values.filter(t=>Object.keys(e).every(i=>oc()(t[i],e[i]))):this.values)),cd(this,"update",async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});let i=ch(ch({},this.getData(e)),t);this.map.set(e,i),await this.persist()}),cd(this,"delete",async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:e,reason:t}),this.map.delete(e),this.addToRecentlyDeleted(e),await this.persist())}),this.logger=nz(t,this.name),this.storagePrefix=r,this.getKey=s}get context(){return nB(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){let t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){let{message:t}=sY("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(t),Error(t)}let{message:t}=sY("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{let e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){let{message:e}=sY("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),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){let{message:e}=sY("NOT_INITIALIZED",this.name);throw Error(e)}}}var cp=Object.defineProperty,cg=(e,t,i)=>t in e?cp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,cf=(e,t,i)=>cg(e,"symbol"!=typeof t?t+"":t,i);class cm{constructor(e,t){this.core=e,this.logger=t,cf(this,"name","pairing"),cf(this,"version","0.3"),cf(this,"events",new(C())),cf(this,"pairings"),cf(this,"initialized",!1),cf(this,"storagePrefix",oh),cf(this,"ignoredPayloadTypes",[1]),cf(this,"registeredMethods",[]),cf(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),cf(this,"register",({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]}),cf(this,"create",async e=>{this.isInitialized();let t=sA(),i=await this.core.crypto.setSymKey(t),r=ib(A.FIVE_MINUTES),s={protocol:"irn"},n={topic:i,expiry:r,relay:s,active:!1,methods:e?.methods},o=sz({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:t,relay:s,expiryTimestamp:r,methods:e?.methods});return this.events.emit(oO.create,n),this.core.expirer.set(i,r),await this.pairings.set(i,n),await this.core.relayer.subscribe(i,{transportType:e?.transportType}),{topic:i,uri:o}}),cf(this,"pair",async e=>{let t;this.isInitialized();let i=this.core.eventClient.createEvent({properties:{topic:e?.uri,trace:[oT.pairing_started]}});this.isValidPair(e,i);let{topic:r,symKey:s,relay:n,expiryTimestamp:o,methods:a}=sB(e.uri);if(i.props.properties.topic=r,i.addTrace(oT.pairing_uri_validation_success),i.addTrace(oT.pairing_uri_not_expired),this.pairings.keys.includes(r)){if(t=this.pairings.get(r),i.addTrace(oT.existing_pairing),t.active)throw i.setError(oN.active_pairing_already_exists),Error(`Pairing already exists: ${r}. Please try again with a new connection URI.`);
10i.addTrace(oT.pairing_not_expired)}let c=o||ib(A.FIVE_MINUTES),l={topic:r,relay:n,expiry:c,active:!1,methods:a};this.core.expirer.set(r,c),await this.pairings.set(r,l),i.addTrace(oT.store_new_pairing),e.activatePairing&&await this.activate({topic:r}),this.events.emit(oO.create,l),i.addTrace(oT.emit_inactive_pairing),this.core.crypto.keychain.has(r)||await this.core.crypto.setSymKey(s,r),i.addTrace(oT.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{i.setError(oN.no_internet_connection)}try{await this.core.relayer.subscribe(r,{relay:n})}catch(e){throw i.setError(oN.subscribe_pairing_topic_failure),e}return i.addTrace(oT.subscribe_pairing_topic_success),l}),cf(this,"activate",async({topic:e})=>{this.isInitialized();let t=ib(A.FIVE_MINUTES);this.core.expirer.set(e,t),await this.pairings.update(e,{active:!0,expiry:t})}),cf(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.");let{topic:t}=e;if(this.pairings.keys.includes(t)){let e=await this.sendRequest(t,"wc_pairingPing",{}),{done:i,resolve:r,reject:s}=ip();this.events.once(iv("pairing_ping",e),({error:e})=>{e?s(e):r()}),await i()}}),cf(this,"updateExpiry",async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})}),cf(this,"updateMetadata",async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})}),cf(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),cf(this,"disconnect",async e=>{this.isInitialized(),await this.isValidDisconnect(e);let{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",sZ("USER_DISCONNECTED")),await this.deletePairing(t))}),cf(this,"formatUriFromPairing",e=>{this.isInitialized();let{topic:t,relay:i,expiry:r,methods:s}=e,n=this.core.crypto.keychain.get(t);return sz({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:n,relay:i,expiryTimestamp:r,methods:s})}),cf(this,"sendRequest",async(e,t,i)=>{let r=(0,oi.formatJsonRpcRequest)(t,i),s=await this.core.crypto.encode(e,r),n=ox[t].req;return this.core.history.set(e,r),this.core.relayer.publish(e,s,n),r.id}),cf(this,"sendResult",async(e,t,i)=>{let r=(0,oi.formatJsonRpcResult)(e,i),s=await this.core.crypto.encode(t,r),n=ox[(await this.core.history.get(t,e)).request.method].res;await this.core.relayer.publish(t,s,n),await this.core.history.resolve(r)}),cf(this,"sendError",async(e,t,i)=>{let r=(0,oi.formatJsonRpcError)(e,i),s=await this.core.crypto.encode(t,r),n=(await this.core.history.get(t,e)).request.method,o=ox[n]?ox[n].res:ox.unregistered_method.res;await this.core.relayer.publish(t,s,o),await this.core.history.resolve(r)}),cf(this,"deletePairing",async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,sZ("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])}),cf(this,"cleanup",async()=>{let e=this.pairings.getAll().filter(e=>iw(e.expiry));await Promise.all(e.map(e=>this.deletePairing(e.topic)))}),cf(this,"onRelayEventRequest",e=>{let{topic:t,payload:i}=e;switch(i.method){case"wc_pairingPing":return this.onPairingPingRequest(t,i);case"wc_pairingDelete":return this.onPairingDeleteRequest(t,i);default:return this.onUnknownRpcMethodRequest(t,i)}}),cf(this,"onRelayEventResponse",async e=>{let{topic:t,payload:i}=e,r=(await this.core.history.get(t,i.id)).request.method;return"wc_pairingPing"===r?this.onPairingPingResponse(t,i):this.onUnknownRpcMethodResponse(r)}),cf(this,"onPairingPingRequest",async(e,t)=>{let{id:i}=t;try{this.isValidPing({topic:e}),await this.sendResult(i,e,!0),this.events.emit(oO.ping,{id:i,topic:e})}catch(t){await this.sendError(i,e,t),this.logger.error(t)}}),cf(this,"onPairingPingResponse",(e,t)=>{let{id:i}=t;setTimeout(()=>{(0,oi.isJsonRpcResult)(t)?this.events.emit(iv("pairing_ping",i),{}):(0,oi.isJsonRpcError)(t)&&this.events.emit(iv("pairing_ping",i),{error:t.error})},500)}),cf(this,"onPairingDeleteRequest",async(e,t)=>{let{id:i}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit(oO.delete,{id:i,topic:e})}catch(t){await this.sendError(i,e,t),this.logger.error(t)}}),cf(this,"onUnknownRpcMethodRequest",async(e,t)=>{let{id:i,method:r}=t;try{if(this.registeredMethods.includes(r))return;let t=sZ("WC_METHOD_UNSUPPORTED",r);await this.sendError(i,e,t),this.logger.error(t)}catch(t){await this.sendError(i,e,t),this.logger.error(t)}}),cf(this,"onUnknownRpcMethodResponse",e=>{this.registeredMethods.includes(e)||this.logger.error(sZ("WC_METHOD_UNSUPPORTED",e))}),cf(this,"isValidPair",(e,t)=>{var i;if(!s7(e)){let{message:i}=sY("MISSING_OR_INVALID",`pair() params: ${e}`);throw t.setError(oN.malformed_pairing_uri),Error(i)}if(!function(e){function t(e){try{return"u">typeof new URL(e)}catch{return!1}}try{if(s1(e,!1)){if(t(e))return!0;let i=iS(e);return t(i)}}catch{}return!1}(e.uri)){let{message:i}=sY("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw t.setError(oN.malformed_pairing_uri),Error(i)}let r=sB(e?.uri);if(!(null!=(i=r?.relay)&&i.protocol)){let{message:e}=sY("MISSING_OR_INVALID","pair() uri#relay-protocol");throw t.setError(oN.malformed_pairing_uri),Error(e)}if(!(null!=r&&r.symKey)){let{message:e}=sY("MISSING_OR_INVALID","pair() uri#symKey");throw t.setError(oN.malformed_pairing_uri),Error(e)}if(null!=r&&r.expiryTimestamp&&(0,A.toMiliseconds)(r?.expiryTimestamp)<Date.now()){t.setError(oN.pairing_expired);let{message:e}=sY("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw Error(e)}}),cf(this,"isValidPing",async e=>
10{if(!s7(e)){let{message:t}=sY("MISSING_OR_INVALID",`ping() params: ${e}`);throw Error(t)}let{topic:t}=e;await this.isValidPairingTopic(t)}),cf(this,"isValidDisconnect",async e=>{if(!s7(e)){let{message:t}=sY("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw Error(t)}let{topic:t}=e;await this.isValidPairingTopic(t)}),cf(this,"isValidPairingTopic",async e=>{if(!s1(e,!1)){let{message:t}=sY("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw Error(t)}if(!this.pairings.keys.includes(e)){let{message:t}=sY("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw Error(t)}if(iw(this.pairings.get(e).expiry)){await this.deletePairing(e);let{message:t}=sY("EXPIRED",`pairing topic: ${e}`);throw Error(t)}}),this.core=e,this.logger=nz(t,this.name),this.pairings=new cu(this.core,this.logger,this.name,this.storagePrefix)}get context(){return nB(this.logger)}isInitialized(){if(!this.initialized){let{message:e}=sY("NOT_INITIALIZED",this.name);throw Error(e)}}registerRelayerEvents(){this.core.relayer.on(oy.message,async e=>{let{topic:t,message:i,transportType:r}=e;if(!this.pairings.keys.includes(t)||r===ov.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;let s=await this.core.crypto.decode(t,i);try{(0,oi.isJsonRpcRequest)(s)?(this.core.history.set(t,s),this.onRelayEventRequest({topic:t,payload:s})):(0,oi.isJsonRpcResponse)(s)&&(await this.core.history.resolve(s),await this.onRelayEventResponse({topic:t,payload:s}),this.core.history.delete(t,s.id))}catch(e){this.logger.error(e)}})}registerExpirerEvents(){this.core.expirer.on(oS.expired,async e=>{let{topic:t}=iy(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(oO.expire,{topic:t}))})}}var cy=Object.defineProperty,cb=(e,t,i)=>t in e?cy(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,cw=(e,t,i)=>cb(e,"symbol"!=typeof t?t+"":t,i);class cv extends nY{constructor(e,t){super(e,t),this.core=e,this.logger=t,cw(this,"records",new Map),cw(this,"events",new S.EventEmitter),cw(this,"name","history"),cw(this,"version","0.3"),cw(this,"cached",[]),cw(this,"initialized",!1),cw(this,"storagePrefix",oh),cw(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)}),cw(this,"set",(e,t,i)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:i}),this.records.has(t.id))return;let r={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:i,expiry:ib(A.THIRTY_DAYS)};this.records.set(r.id,r),this.persist(),this.events.emit(oP.created,r)}),cw(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;let t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=(0,oi.isJsonRpcError)(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.persist(),this.events.emit(oP.updated,t))}),cw(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))),cw(this,"delete",(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach(i=>{i.topic!==e||"u">typeof t&&i.id!==t||(this.records.delete(i.id),this.events.emit(oP.deleted,i))}),this.persist()}),cw(this,"exists",async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e)),cw(this,"on",(e,t)=>{this.events.on(e,t)}),cw(this,"once",(e,t)=>{this.events.once(e,t)}),cw(this,"off",(e,t)=>{this.events.off(e,t)}),cw(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=nz(t,this.name)}get context(){return nB(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(){let e=[];
10return this.values.forEach(t=>{if("u">typeof t.response)return;let i={topic:t.topic,request:(0,oi.formatJsonRpcRequest)(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),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();let t=this.records.get(e);if(!t){let{message:t}=sY("NO_MATCHING_KEY",`${this.name}: ${e}`);throw Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(oP.sync)}async restore(){try{let e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){let{message:e}=sY("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),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(oP.created,e=>{let t=oP.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(oP.updated,e=>{let t=oP.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(oP.deleted,e=>{let t=oP.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(nl,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,A.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(oP.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){let{message:e}=sY("NOT_INITIALIZED",this.name);throw Error(e)}}}var cE=Object.defineProperty,c_=(e,t,i)=>t in e?cE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,cI=(e,t,i)=>c_(e,"symbol"!=typeof t?t+"":t,i);class cx extends n2{constructor(e,t){super(e,t),this.core=e,this.logger=t,cI(this,"expirations",new Map),cI(this,"events",new S.EventEmitter),cI(this,"name","expirer"),cI(this,"version","0.3"),cI(this,"cached",[]),cI(this,"initialized",!1),cI(this,"storagePrefix",oh),cI(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)}),cI(this,"has",e=>{try{let t=this.formatTarget(e);return"u">typeof this.getExpiration(t)}catch{return!1}}),cI(this,"set",(e,t)=>{this.isInitialized();let i=this.formatTarget(e),r={target:i,expiry:t};this.expirations.set(i,r),this.checkExpiry(i,r),this.events.emit(oS.created,{target:i,expiration:r})}),cI(this,"get",e=>{this.isInitialized();let t=this.formatTarget(e);return this.getExpiration(t)}),cI(this,"del",e=>{if(this.isInitialized(),this.has(e)){let t=this.formatTarget(e),i=this.getExpiration(t);this.expirations.delete(t),this.events.emit(oS.deleted,{target:t,expiration:i})}}),cI(this,"on",(e,t)=>{this.events.on(e,t)}),cI(this,"once",(e,t)=>{this.events.once(e,t)}),cI(this,"off",(e,t)=>{this.events.off(e,t)}),cI(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=nz(t,this.name)}get context(){return nB(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 im("topic",e);if("number"==typeof e)return im("id",e);let{message:t}=sY("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw 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(oS.sync)}
10async restore(){try{let e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){let{message:e}=sY("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),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){let t=this.expirations.get(e);if(!t){let{message:t}=sY("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(t),Error(t)}return t}checkExpiry(e,t){let{expiry:i}=t;(0,A.toMiliseconds)(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(oS.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(nl,()=>this.checkExpirations()),this.events.on(oS.created,e=>{let t=oS.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(oS.expired,e=>{let t=oS.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(oS.deleted,e=>{let t=oS.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){let{message:e}=sY("NOT_INITIALIZED",this.name);throw Error(e)}}}var cO=Object.defineProperty,cP=(e,t,i)=>t in e?cO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,cS=(e,t,i)=>cP(e,"symbol"!=typeof t?t+"":t,i);class cC extends n5{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,cS(this,"name","verify-api"),cS(this,"abortController"),cS(this,"isDevEnv"),cS(this,"verifyUrlV3",oR),cS(this,"storagePrefix",oh),cS(this,"version",2),cS(this,"publicKey"),cS(this,"fetchPromise"),cS(this,"init",async()=>{var e;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,A.toMiliseconds)(null==(e=this.publicKey)?void 0:e.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),cS(this,"register",async e=>{if(!is()||this.isDevEnv)return;let t=window.location.origin,{id:i,decryptedId:r}=e,s=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${t}&id=${i}&decryptedId=${r}`;try{let e=(0,T.getDocument)(),t=this.startAbortTimer(5*A.ONE_SECOND),r=await new Promise((r,n)=>{let o=()=>{window.removeEventListener("message",c),e.body.removeChild(a),n("attestation aborted")};this.abortController.signal.addEventListener("abort",o);let a=e.createElement("iframe");a.src=s,a.style.display="none",a.addEventListener("error",o,{signal:this.abortController.signal});let c=s=>{if(s.data&&"string"==typeof s.data)try{let n=JSON.parse(s.data);if("verify_attestation"===n.type){if(t0(n.attestation).payload.id!==i)return;clearInterval(t),e.body.removeChild(a),this.abortController.signal.removeEventListener("abort",o),window.removeEventListener("message",c),r(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",r),r}catch(e){this.logger.warn(e)}return""}),cS(this,"resolve",async e=>{if(this.isDevEnv)return"";let{attestationId:t,hash:i,encryptedId:r}=e;if(""===t){this.logger.debug("resolve: attestationId is empty, skipping");return}if(t){if(t0(t).payload.id!==r)return;let e=await this.isValidJwtAttestation(t);if(e){if(!e.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return e}}if(!i)return;let s=this.getVerifyUrl(e?.verifyUrl);return this.fetchAttestation(i,s)}),cS(this,"fetchAttestation",async(e,t)=>{this.logger.debug(`resolving attestation: ${e} from url: ${t}`);let i=this.startAbortTimer(5*A.ONE_SECOND),r=await fetch(`${t}/attestation/${e}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(i),200===r.status?await r.json():void 0}),cS(this,"getVerifyUrl",e=>{let t=e||oC;return oA.includes(t)||(this.logger.info(`verify url: ${t}, not included in trusted list, assigning default: ${oC}`),t=oC),t}),cS(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let e=this.startAbortTimer(A.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)}}),cS(this,"persistPublicKey",async e=>{this.logger.debug("persisting public key to local storage",e),await this.store.setItem(this.storeKey,e),this.publicKey=e}),cS(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),cS(this,"isValidJwtAttestation",async e=>{let t=await this.getPublicKey();try{if(t)return this.validateAttestation(e,t)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}let i=await this.fetchAndPersistPublicKey();try{if(i)return this.validateAttestation(e,i)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}}),cS(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),cS(this,"fetchAndPersistPublicKey",async()=>
10{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async e=>{let t=await this.fetchPublicKey();t&&(await this.persistPublicKey(t),e(t))});let e=await this.fetchPromise;return this.fetchPromise=void 0,e}),cS(this,"validateAttestation",(e,t)=>{let i=function(e,t){let[i,r,s]=e.split("."),n=t6.from(function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/"),i=t.length%4;return i>0&&(t+="=".repeat(4-i)),t}(s),"base64");if(64!==n.length)throw Error("Invalid signature length");let o=n.slice(0,32).toString("hex"),a=n.slice(32,64).toString("hex"),c=se(`${i}.${r}`),l=new t3.ec("p256").keyFromPublic({x:t6.from(t.x,"base64").toString("hex"),y:t6.from(t.y,"base64").toString("hex")},"hex"),h=(0,t5.BB)(c,sP);if(!l.verify(h,{r:o,s:a}))throw Error("Invalid signature");return t0(e).payload}(e,t.publicKey),r={hasExpired:(0,A.toMiliseconds)(i.exp)<Date.now(),payload:i};if(r.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),Error("JWT attestation expired");return{origin:r.payload.origin,isScam:r.payload.isScam,isVerified:r.payload.isVerified}}),this.logger=nz(t,this.name),this.abortController=new AbortController,this.isDevEnv=iP(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return nB(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),(0,A.toMiliseconds)(e))}}var cR=Object.defineProperty,cA=(e,t,i)=>t in e?cR(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,cT=(e,t,i)=>cA(e,"symbol"!=typeof t?t+"":t,i);class cN extends n3{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,cT(this,"context","echo"),cT(this,"registerDeviceToken",async e=>{let{clientId:t,token:i,notificationType:r,enableEncrypted:s=!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:r,token:i,always_raw:s})})}),this.logger=nz(t,this.context)}}var ck=Object.defineProperty,cL=Object.getOwnPropertySymbols,c$=Object.prototype.hasOwnProperty,cj=Object.prototype.propertyIsEnumerable,cD=(e,t,i)=>t in e?ck(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,cM=(e,t)=>{for(var i in t||(t={}))c$.call(t,i)&&cD(e,i,t[i]);if(cL)for(var i of cL(t))cj.call(t,i)&&cD(e,i,t[i]);return e},cU=(e,t,i)=>cD(e,"symbol"!=typeof t?t+"":t,i);class cq extends n4{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,cU(this,"context","event-client"),cU(this,"storagePrefix",oh),cU(this,"storageVersion",.1),cU(this,"events",new Map),cU(this,"shouldPersist",!1),cU(this,"init",async()=>{if(!iP())try{let e={eventId:iO(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:il(this.core.relayer.protocol,this.core.relayer.version,ow)}}};await this.sendEvent([e])}catch(e){this.logger.warn(e)}}),cU(this,"createEvent",e=>{let{event:t="ERROR",type:i="",properties:{topic:r,trace:s}}=e,n=iO(),o=this.core.projectId||"",a=cM({eventId:n,timestamp:Date.now(),props:{event:t,type:i,properties:{topic:r,trace:s}},bundleId:o,domain:this.getAppDomain()},this.setMethods(n));return this.telemetryEnabled&&(this.events.set(n,a),this.shouldPersist=!0),a}),cU(this,"getEvent",e=>{let{eventId:t,topic:i}=e;if(t)return this.events.get(t);let r=Array.from(this.events.values()).find(e=>e.props.properties.topic===i);if(r)return cM(cM({},r),this.setMethods(r.eventId))}),cU(this,"deleteEvent",e=>{let{eventId:t}=e;this.events.delete(t),this.shouldPersist=!0}),cU(this,"setEventListeners",()=>{this.core.heartbeat.on(nl,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(e=>{(0,A.fromMiliseconds)(Date.now())-(0,A.fromMiliseconds)(e.timestamp)>86400&&(this.events.delete(e.eventId),this.shouldPersist=!0)})})}),cU(this,"setMethods",e=>({addTrace:t=>this.addTrace(e,t),setError:t=>this.setError(e,t)})),cU(this,"addTrace",(e,t)=>{let i=this.events.get(e);i&&(i.props.properties.trace.push(t),this.events.set(e,i),this.shouldPersist=!0)}),cU(this,"setError",(e,t)=>{let i=this.events.get(e);i&&(i.props.type=t,i.timestamp=Date.now(),this.events.set(e,i),this.shouldPersist=!0)}),cU(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())
10),this.shouldPersist=!1}),cU(this,"restore",async()=>{try{let e=await this.core.storage.getItem(this.storageKey)||[];if(!e.length)return;e.forEach(e=>{this.events.set(e.eventId,cM(cM({},e),this.setMethods(e.eventId)))})}catch(e){this.logger.warn(e)}}),cU(this,"submit",async()=>{if(!this.telemetryEnabled||0===this.events.size)return;let e=[];for(let[t,i]of this.events)i.props.type&&e.push(i);if(0!==e.length)try{if((await this.sendEvent(e)).ok)for(let t of e)this.events.delete(t.eventId),this.shouldPersist=!0}catch(e){this.logger.warn(e)}}),cU(this,"sendEvent",async e=>{let t=this.getAppDomain()?"":"&sp=desktop";return await fetch(`https://pulse.walletconnect.org/batch?projectId=${this.core.projectId}&st=events_sdk&sv=js-${ow}${t}`,{method:"POST",body:JSON.stringify(e)})}),cU(this,"getAppDomain",()=>ic().url),this.logger=nz(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var cB=Object.defineProperty,cz=Object.getOwnPropertySymbols,cH=Object.prototype.hasOwnProperty,cV=Object.prototype.propertyIsEnumerable,cW=(e,t,i)=>t in e?cB(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,cK=(e,t)=>{for(var i in t||(t={}))cH.call(t,i)&&cW(e,i,t[i]);if(cz)for(var i of cz(t))cV.call(t,i)&&cW(e,i,t[i]);return e},cF=(e,t,i)=>cW(e,"symbol"!=typeof t?t+"":t,i);class cJ extends nK{constructor(e){var t,i;super(e),cF(this,"protocol","wc"),cF(this,"version",2),cF(this,"name",ol),cF(this,"relayUrl"),cF(this,"projectId"),cF(this,"customStoragePrefix"),cF(this,"events",new S.EventEmitter),cF(this,"logger"),cF(this,"heartbeat"),cF(this,"relayer"),cF(this,"crypto"),cF(this,"storage"),cF(this,"history"),cF(this,"expirer"),cF(this,"pairing"),cF(this,"verify"),cF(this,"echoClient"),cF(this,"linkModeSupportedApps"),cF(this,"eventClient"),cF(this,"initialized",!1),cF(this,"logChunkController"),cF(this,"on",(e,t)=>this.events.on(e,t)),cF(this,"once",(e,t)=>this.events.once(e,t)),cF(this,"off",(e,t)=>this.events.off(e,t)),cF(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),cF(this,"dispatchEnvelope",({topic:e,message:t,sessionExists:i})=>{if(!e||!t)return;let r={topic:e,message:t,publishedAt:Date.now(),transportType:ov.link_mode};this.relayer.onLinkMessageEvent(r,{sessionExists:i})}),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||om,this.customStoragePrefix=null!=e&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";let{logger:r,chunkLoggerController:s}="u">typeof(i={opts:nq({level:"string"==typeof e?.logger&&e.logger?e.logger:od.logger,name:ol}),maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger}).loggerOverride&&"string"!=typeof i.loggerOverride?{logger:i.loggerOverride,chunkLoggerController:null}:"u">typeof window?function(e){var t,i;let r=new nR(null==(t=e.opts)?void 0:t.level,e.maxSizeInBytes);return{logger:nI()(nU(nM({},e.opts),{level:"trace",browser:nU(nM({},null==(i=e.opts)?void 0:i.browser),{write:e=>r.write(e)})})),chunkLoggerController:r}}(i):function(e){var t;let i=new nA(null==(t=e.opts)?void 0:t.level,e.maxSizeInBytes);return{logger:nI()(nU(nM({},e.opts),{level:"trace"}),i),chunkLoggerController:i}}(i);this.logChunkController=s,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=nz(r,this.name),this.heartbeat=new nh,this.crypto=new aA(this,this.logger,e?.keychain),this.history=new cv(this,this.logger),this.expirer=new cx(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new nE(cK(cK({},ou),e?.storageOptions)),this.relayer=new cs({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new cm(this,this.logger),this.verify=new cC(this,this.logger,this.storage),this.echoClient=new cN(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new cq(this,this.logger,e?.telemetryEnabled)}static async init(e){let t=new cJ(e);await t.initialize();let i=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",i),t}get context(){return nB(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(oE,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(
10),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(oE)||[],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}}}let cG="client",cY=`wc@2:${cG}:`,cZ={name:cG,logger:"error"},cQ="WALLETCONNECT_DEEPLINK_CHOICE",cX="Proposal expired",c0=A.SEVEN_DAYS,c1={wc_sessionPropose:{req:{ttl:A.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:A.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:A.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:A.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:A.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:A.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:A.ONE_DAY,prompt:!1,tag:1104},res:{ttl:A.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:A.ONE_DAY,prompt:!1,tag:1106},res:{ttl:A.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:A.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:A.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:A.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:A.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:A.ONE_DAY,prompt:!1,tag:1112},res:{ttl:A.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:A.ONE_DAY,prompt:!1,tag:1114},res:{ttl:A.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:A.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:A.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:A.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:A.FIVE_MINUTES,prompt:!1,tag:1119}}},c2={min:A.FIVE_MINUTES,max:A.SEVEN_DAYS},c5={idle:"IDLE",active:"ACTIVE"},c3={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},c4=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],c8="[email protected]:auth:",c6=`${c8}:PUB_KEY`;var c7=Object.defineProperty,c9=Object.defineProperties,le=Object.getOwnPropertyDescriptors,lt=Object.getOwnPropertySymbols,li=Object.prototype.hasOwnProperty,lr=Object.prototype.propertyIsEnumerable,ls=(e,t,i)=>t in e?c7(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,ln=(e,t)=>{for(var i in t||(t={}))li.call(t,i)&&ls(e,i,t[i]);if(lt)for(var i of lt(t))lr.call(t,i)&&ls(e,i,t[i]);return e},lo=(e,t)=>c9(e,le(t)),la=(e,t,i)=>ls(e,"symbol"!=typeof t?t+"":t,i);class lc extends oe{constructor(e){super(e),la(this,"name","engine"),la(this,"events",new(C())),la(this,"initialized",!1),la(this,"requestQueue",{state:c5.idle,queue:[]}),la(this,"sessionRequestQueue",{state:c5.idle,queue:[]}),la(this,"requestQueueDelay",A.ONE_SECOND),la(this,"expectedPairingMethodMap",new Map),la(this,"recentlyDeletedMap",new Map),la(this,"recentlyDeletedLimit",200),la(this,"relayMessageCache",[]),la(this,"pendingSessions",new Map),la(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(c1)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,A.toMiliseconds)(this.requestQueueDelay)))}),la(this,"connect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();let t=lo(ln({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);let{pairingTopic:i,requiredNamespaces:r,optionalNamespaces:s,sessionProperties:n,relays:o}=t,a=i,c,l=!1;try{if(a){let e=this.client.core.pairing.pairings.get(a);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),l=e.active}}catch(e){throw this.client.logger.error(`connect() -> pairing.get(${a}) failed`),e}if(!a||!l){let{topic:e,uri:t}=await this.client.core.pairing.create();a=e,c=t}if(!a){let{message:e}=sY("NO_MATCHING_KEY",`connect() pairing topic: ${a}`);throw Error(e)}let h=await this.client.core.crypto.generateKeyPair(),d=c1.wc_sessionPropose.req.ttl||A.FIVE_MINUTES,u=ib(d),p=lo(ln({requiredNamespaces:r,optionalNamespaces:s,relays:o??[{protocol:"irn"}],proposer:{publicKey:h,metadata:this.client.metadata},expiryTimestamp:u,pairingTopic:a},n&&{sessionProperties:n}),{id:(0,oi.payloadId)()}),g=iv("session_connect",p.id),{reject:f,resolve:m,done:y}=ip(d,cX),b=({id:e})=>{e===p.id&&(this.client.events.off("proposal_expire",b),this.pendingSessions.delete(p.id),this.events.emit(g,{error:{message:cX,code:0}}))};return this.client.events.on("proposal_expire",b),this.events.once(g,({error:e,session:t})=>{this.client.events.off("proposal_expire",b),e?f(e):t&&m(t)}),await this.sendRequest({topic:a,method:"wc_sessionPropose",params:p,throwOnFailedPublish:!0,clientRpcId:p.id}),await this.setProposal(p.id,p),{uri:c,approval:y}}),la(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}}),la(this,"approve",async e=>{var t,i,r;let s=this.client.core.eventClient.createEvent({properties:{topic:null==(t=e?.id)?void 0:t.toString(),trace:[ok.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(e){throw s.setError(oL.no_internet_connection),e}try{await this.isValidProposalId(e?.id)}catch(t){throw this.client.logger.error(`approve() -> proposal.get(${e?.id}) failed`),s.setError(oL.proposal_not_found),t}try{await this.isValidApprove(e)}catch(e){throw this.client.logger.error("approve() -> isValidApprove() failed"),s.setError(oL.session_approve_namespace_validation_failure),e}let{id:n,relayProtocol:o,namespaces:a,sessionProperties:c,sessionConfig:l}=e,h=this.client.proposal.get(n);this.client.core.eventClient.deleteEvent({eventId:s.eventId});let{pairingTopic:d,proposer:u,requiredNamespaces:p,optionalNamespaces:g}=h,f=null==(i=this.client.core.eventClient)?void 0:i.getEvent({topic:d});f||(f=null==(r=this.client.core.eventClient)?void 0:r.createEvent({type:ok.session_approve_started,properties:{topic:d,trace:[ok.session_approve_started,ok.session_namespaces_validation_success]}}));let m=await this.client.core.crypto.generateKeyPair(),y=u.publicKey,b=await this.client.core.crypto.generateSharedKey(m,y),w=ln(l
10n({relay:{protocol:o??"irn"},namespaces:a,controller:{publicKey:m,metadata:this.client.metadata},expiry:ib(c0)},c&&{sessionProperties:c}),l&&{sessionConfig:l}),v=ov.relay;f.addTrace(ok.subscribing_session_topic);try{await this.client.core.relayer.subscribe(b,{transportType:v})}catch(e){throw f.setError(oL.subscribe_session_topic_failure),e}f.addTrace(ok.subscribe_session_topic_success);let E=lo(ln({},w),{topic:b,requiredNamespaces:p,optionalNamespaces:g,pairingTopic:d,acknowledged:!1,self:w.controller,peer:{publicKey:u.publicKey,metadata:u.metadata},controller:m,transportType:ov.relay});await this.client.session.set(b,E),f.addTrace(ok.store_session);try{f.addTrace(ok.publishing_session_settle),await this.sendRequest({topic:b,method:"wc_sessionSettle",params:w,throwOnFailedPublish:!0}).catch(e=>{throw f?.setError(oL.session_settle_publish_failure),e}),f.addTrace(ok.session_settle_publish_success),f.addTrace(ok.publishing_session_approve),await this.sendResult({id:n,topic:d,result:{relay:{protocol:o??"irn"},responderPublicKey:m},throwOnFailedPublish:!0}).catch(e=>{throw f?.setError(oL.session_approve_publish_failure),e}),f.addTrace(ok.session_approve_publish_success)}catch(e){throw this.client.logger.error(e),this.client.session.delete(b,sZ("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(b),e}return this.client.core.eventClient.deleteEvent({eventId:f.eventId}),await this.client.core.pairing.updateMetadata({topic:d,metadata:u.metadata}),await this.client.proposal.delete(n,sZ("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:d}),await this.setExpiry(b,ib(c0)),{topic:b,acknowledged:()=>Promise.resolve(this.client.session.get(b))}}),la(this,"reject",async e=>{let t;this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(e)}catch(e){throw this.client.logger.error("reject() -> isValidReject() failed"),e}let{id:i,reason:r}=e;try{t=this.client.proposal.get(i).pairingTopic}catch(e){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),e}t&&(await this.sendError({id:i,topic:t,error:r,rpcOpts:c1.wc_sessionPropose.reject}),await this.client.proposal.delete(i,sZ("USER_DISCONNECTED")))}),la(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}let{topic:t,namespaces:i}=e,{done:r,resolve:s,reject:n}=ip(),o=(0,oi.payloadId)(),a=(0,oi.getBigIntRpcId)().toString(),c=this.client.session.get(t).namespaces;return this.events.once(iv("session_update",o),({error:e})=>{e?n(e):s()}),await this.client.session.update(t,{namespaces:i}),await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:i},throwOnFailedPublish:!0,clientRpcId:o,relayRpcId:a}).catch(e=>{this.client.logger.error(e),this.client.session.update(t,{namespaces:c}),n(e)}),{acknowledged:r}}),la(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}let{topic:t}=e,i=(0,oi.payloadId)(),{done:r,resolve:s,reject:n}=ip();return this.events.once(iv("session_extend",i),({error:e})=>{e?n(e):s()}),await this.setExpiry(t,ib(c0)),this.sendRequest({topic:t,method:"wc_sessionExtend",params:{},clientRpcId:i,throwOnFailedPublish:!0}).catch(e=>{n(e)}),{acknowledged:r}}),la(this,"request",async e=>{this.isInitialized();try{await this.isValidRequest(e)}catch(e){throw this.client.logger.error("request() -> isValidRequest() failed"),e}let{chainId:t,request:i,topic:r,expiry:s=c1.wc_sessionRequest.req.ttl}=e,n=this.client.session.get(r);n?.transportType===ov.relay&&await this.confirmOnlineStateOrThrow();let o=(0,oi.payloadId)(),a=(0,oi.getBigIntRpcId)().toString(),{done:c,resolve:l,reject:h}=ip(s,"Request expired. Please try again.");this.events.once(iv("session_request",o),({error:e,result:t})=>{e?h(e):l(t)});let d="wc_sessionRequest",u=this.getAppLinkIfEnabled(n.peer.metadata,n.transportType);if(u)return await this.sendRequest({clientRpcId:o,relayRpcId:a,topic:r,method:d,params:{request:lo(ln({},i),{expiryTimestamp:ib(s)}),chainId:t},expiry:s,throwOnFailedPublish:!0,appLink:u}).catch(e=>h(e)),this.client.events.emit("session_request_sent",{topic:r,request:i,
10chainId:t,id:o}),await c();let p={request:lo(ln({},i),{expiryTimestamp:ib(s)}),chainId:t},g=this.shouldSetTVF(d,p);return await Promise.all([new Promise(async e=>{await this.sendRequest(ln({clientRpcId:o,relayRpcId:a,topic:r,method:d,params:p,expiry:s,throwOnFailedPublish:!0},g&&{tvf:this.getTVFParams(o,p)})).catch(e=>h(e)),this.client.events.emit("session_request_sent",{topic:r,request:i,chainId:t,id:o}),e()}),new Promise(async e=>{var t;if(!(null!=(t=n.sessionConfig)&&t.disableDeepLink)){let e=await iI(this.client.core.storage,cQ);await i_({id:o,topic:r,wcDeepLink:e})}e()}),c()]).then(e=>e[2])}),la(this,"respond",async e=>{this.isInitialized(),await this.isValidRespond(e);let{topic:t,response:i}=e,{id:r}=i,s=this.client.session.get(t);s.transportType===ov.relay&&await this.confirmOnlineStateOrThrow();let n=this.getAppLinkIfEnabled(s.peer.metadata,s.transportType);(0,oi.isJsonRpcResult)(i)?await this.sendResult({id:r,topic:t,result:i.result,throwOnFailedPublish:!0,appLink:n}):(0,oi.isJsonRpcError)(i)&&await this.sendError({id:r,topic:t,error:i.error,appLink:n}),this.cleanupAfterResponse(e)}),la(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}let{topic:t}=e;if(this.client.session.keys.includes(t)){let e=(0,oi.payloadId)(),i=(0,oi.getBigIntRpcId)().toString(),{done:r,resolve:s,reject:n}=ip();this.events.once(iv("session_ping",e),({error:e})=>{e?n(e):s()}),await Promise.all([this.sendRequest({topic:t,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:e,relayRpcId:i}),r()])}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}))}),la(this,"emit",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(e);let{topic:t,event:i,chainId:r}=e,s=(0,oi.getBigIntRpcId)().toString(),n=(0,oi.payloadId)();await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:i,
10chainId:r},throwOnFailedPublish:!0,relayRpcId:s,clientRpcId:n})}),la(this,"disconnect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(e);let{topic:t}=e;if(this.client.session.keys.includes(t))await this.sendRequest({topic:t,method:"wc_sessionDelete",params:sZ("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:t,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(t))await this.client.core.pairing.disconnect({topic:t});else{let{message:e}=sY("MISMATCHED_TOPIC",`Session or pairing topic not found: ${t}`);throw Error(e)}}),la(this,"find",e=>(this.isInitialized(),this.client.session.getAll().filter(t=>(function(e,t){let{requiredNamespaces:i}=t,r=Object.keys(e.namespaces),s=Object.keys(i),n=!0;return!!ih(s,r)&&(r.forEach(t=>{let{accounts:r,methods:s,events:o}=e.namespaces[t],a=sV(r),c=i[t];ih(ie(t,c),a)&&ih(c.methods,s)&&ih(c.events,o)||(n=!1)}),n)})(t,e)))),la(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),la(this,"authenticate",async(e,t)=>{var i,r,s;let n;this.isInitialized(),this.isValidAuthenticate(e);let o=t&&this.client.core.linkModeSupportedApps.includes(t)&&(null==(i=this.client.metadata.redirect)?void 0:i.linkMode),a=o?ov.link_mode:ov.relay;a===ov.relay&&await this.confirmOnlineStateOrThrow();let{chains:c,statement:l="",uri:h,domain:d,nonce:u,type:p,exp:g,nbf:f,methods:m=[],expiry:y}=e,b=[...e.resources||[]],{topic:w,uri:v}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:a});this.client.logger.info({message:"Generated new pairing",pairing:{topic:w,uri:v}});let E=await this.client.core.crypto.generateKeyPair(),_=sT(E);if(await Promise.all([this.client.auth.authKeys.set(c6,{responseTopic:_,publicKey:E}),this.client.auth.pairingTopics.set(_,{topic:_,pairingTopic:w})]),await this.client.core.relayer.subscribe(_,{transportType:a}),this.client.logger.info(`sending request to new pairing topic: ${w}`),m.length>0){let{namespace:e}=t7(c[0]),t=rw(function(e,t,i,r={}){return i?.sort((e,t)=>e.localeCompare(t)),{att:{[e]:function(e,t,i={}){return Object.assign({},...(t=t?.sort((e,t)=>e.localeCompare(t))).map(t=>({[`${e}/${t}`]:[i]})))}(t,i,r)}}}(e,"request",m));rI(b)&&(r=t,s=b.pop(),t=rw(function(e,t){rb(e),rb(t);let i=Object.keys(e.att).concat(Object.keys(t.att)).sort((e,t)=>e.localeCompare(t)),r={att:{}};return i.forEach(i=>{var s,n;Object.keys((null==(s=e.att)?void 0:s[i])||{}).concat(Object.keys((null==(n=t.att)?void 0:n[i])||{})).sort((e,t)=>e.localeCompare(t)).forEach(s=>{var n,o;r.att[i]=rd(rh({},r.att[i]),{[s]:(null==(n=e.att[i])?void 0:n[s])||(null==(o=t.att[i])?void 0:o[s])})})}),r}(rv(r),rv(s)))),b.push(t)}let I=y&&y>c1.wc_sessionAuthenticate.req.ttl?y:c1.wc_sessionAuthenticate.req.ttl,x={authPayload:{type:p??"caip122",chains:c,statement:l,aud:h,domain:d,version:"1",nonce:u,iat:new Date().toISOString(),exp:g,nbf:f,resources:b},requester:{publicKey:E,metadata:this.client.metadata},expiryTimestamp:ib(I)},O={requiredNamespaces:{},optionalNamespaces:{eip155:{chains:c,methods:[...new Set(["personal_sign",...m])],events:["chainChanged","accountsChanged"]}},relays:[{protocol:"irn"}],pairingTopic:w,proposer:{publicKey:E,metadata:this.client.metadata},expiryTimestamp:ib(c1.wc_sessionPropose.req.ttl),id:(0,oi.payloadId)()},{done:P,resolve:S,reject:C}=ip(I,"Request expired"),R=(0,oi.payloadId)(),A=iv("session_connect",O.id),T=iv("session_request",R),N=async({error:e,session:t})=>{this.events.off(T,k),e?C(e):t&&S({session:t})},k=async e=>{var i,r,s;let n;if(await this.deletePendingAuthRequest(R,{message:"fulfilled",code:0}),e.error){let t=sZ("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return e.error.code===t.code?void 0:(this.events.off(A,N),C(e.error.message))}await this.deleteProposal(O.id),this.events.off(A,N);let{cacaos:o,responder:c}=e.result,l=[],h=[];for(let e of o){await rm({cacao:e,projectId:this.client.core.projectId})||(this.client.logger.error(e,"Signature verification failed"),C(sZ("SESSION_SETTLEMENT_FAILED","Signature verification failed")));let{p:t}=e,i=rI(t.resources),r=[rg(t.iss)],s=rf(t.iss);if(i){let e=rE(i),t=r_(i);l.push(...e),r.push(...t)}for(let e of r)h.push(`${e}:${s}`)}let d=await this.client.core.crypto.generateSharedKey(E,c.publicKey);l.length>0&&(n={topic:d,acknowledged:!0,self:{publicKey:E,metadata:this.client.metadata},peer:c,controller:c.publicKey,expiry:ib(c0),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:w,namespaces:sF([...new Set(l)],[...new Set(h)]),transportType:a},await this.client.core.relayer.subscribe(d,{transportType:a}),await this.client.session.set(d,n),w&&await this.client.core.pairing.updateMetadata({topic:w,metadata:c.metadata}),n=this.client.session.get(d)),null!=(i=this.client.metadata.redirect)&&i.linkMode&&null!=(r=c.metadata.redirect)&&r.linkMode&&null!=(s=c.metadata.redirect)&&s.universal&&t&&(this.client.core.addLinkModeSupportedApp(c.metadata.redirect.universal),this.client.session.update(d,{transportType:ov.link_mode})),S({auths:o,session:n})};this.events.once(A,N),this.events.once(T,k);try{if(o){let e=(0,oi.formatJsonRpcRequest)("wc_sessionAuthenticate",x,R);this.client.core.history.set(w,e);let i=await this.client.core.crypto.encode("",e,{type:2,encoding:sC});n=sH(t,w,i)}else await Promise.all([this.sendRequest({topic:w,method:"wc_sessionAuthenticate",params:x,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:R}),this.sendRequest({topic:w,method:"wc_sessionPropose",params:O,expiry:c1.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:O.id})])}catch(e){throw this.events.off(A,N),this.events.off(T,k),e}return await this.setProposal(O.id,O),await this.setAuthRequest(R,{request:lo(ln({},x),{verifyContext:{}}),pairingTopic:w,transportType:a}),{uri:n??v,response:P}}),la(this,"approveSessionAuthenticate",async e=>{let t;let{id:i,auths:r}=e,s=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[o$.authenticated_session_approve_started]}});try{this.isInitialized()}catch(e){throw s.setError(oj.no_internet_connection),e}let n=this.getPendingAuthRequest(i);if(!n)throw s.setError(oj.authenticated_session_pending_request_not_found),Error(`Could not find pending auth request with id ${i}`);let o=n.transportType||ov.relay;o===ov.relay&&await this.confirmOnlineStateOrThrow();let a=n.requester.publicKey,c=await this.client.core.crypto.generateKeyPair(),l=sT(a),h={type:1,receiverPublicKey:a,senderPublicKey:c},d=[],u=[];for(let e of r){if(!await rm({cacao:e,projectId:this.client.core.projectId})){s.setError(oj.invalid_cacao);let e=sZ("SESSION_SETTLEMENT_FAILED","Signature verification failed");
10throw await this.sendError({id:i,topic:l,error:e,encodeOpts:h}),Error(e.message)}s.addTrace(o$.cacaos_verified);let{p:t}=e,r=rI(t.resources),n=[rg(t.iss)],o=rf(t.iss);if(r){let e=rE(r),t=r_(r);d.push(...e),n.push(...t)}for(let e of n)u.push(`${e}:${o}`)}let p=await this.client.core.crypto.generateSharedKey(c,a);if(s.addTrace(o$.create_authenticated_session_topic),d?.length>0){t={topic:p,acknowledged:!0,self:{publicKey:c,metadata:this.client.metadata},peer:{publicKey:a,metadata:n.requester.metadata},controller:a,expiry:ib(c0),authentication:r,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:n.pairingTopic,namespaces:sF([...new Set(d)],[...new Set(u)]),transportType:o},s.addTrace(o$.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(p,{transportType:o})}catch(e){throw s.setError(oj.subscribe_authenticated_session_topic_failure),e}s.addTrace(o$.subscribe_authenticated_session_topic_success),await this.client.session.set(p,t),s.addTrace(o$.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:n.pairingTopic,metadata:n.requester.metadata})}s.addTrace(o$.publishing_authenticated_session_approve);try{await this.sendResult({topic:l,id:i,result:{cacaos:r,responder:{publicKey:c,metadata:this.client.metadata}},encodeOpts:h,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(n.requester.metadata,o)})}catch(e){throw s.setError(oj.authenticated_session_approve_publish_failure),e}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:n.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:s.eventId}),{session:t}}),la(this,"rejectSessionAuthenticate",async e=>{this.isInitialized();let{id:t,reason:i}=e,r=this.getPendingAuthRequest(t);if(!r)throw Error(`Could not find pending auth request with id ${t}`);r.transportType===ov.relay&&await this.confirmOnlineStateOrThrow();let s=r.requester.publicKey,n=await this.client.core.crypto.generateKeyPair(),o=sT(s);await this.sendError({id:t,topic:o,error:i,encodeOpts:{type:1,receiverPublicKey:s,senderPublicKey:n},rpcOpts:c1.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(r.requester.metadata,r.transportType)}),await this.client.auth.requests.delete(t,{message:"rejected",code:0}),await this.client.proposal.delete(t,sZ("USER_DISCONNECTED"))}),la(this,"formatAuthMessage",e=>{this.isInitialized();let{request:t,iss:i}=e;return ry(t,i)}),la(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(0!==this.relayMessageCache.length)for(;this.relayMessageCache.length>0;)try{let e=this.relayMessageCache.shift();e&&await this.onRelayMessage(e)}catch(e){this.client.logger.error(e)}},50)}),la(this,"cleanupDuplicatePairings",async e=>{if(e.pairingTopic)try{let t=this.client.core.pairing.pairings.get(e.pairingTopic),i=this.client.core.pairing.pairings.getAll().filter(i=>{var r,s;return(null==(r=i.peerMetadata)?void 0:r.url)&&(null==(s=i.peerMetadata)?void 0:s.url)===e.peer.metadata.url&&i.topic&&i.topic!==t.topic});if(0===i.length)return;this.client.logger.info(`Cleaning up ${i.length} duplicate pairing(s)`),await Promise.all(i.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)}}),la(this,"deleteSession",async e=>{var t;let{topic:i,expirerHasDeleted:r=!1,emitEvent:s=!0,id:n=0}=e,{self:o}=this.client.session.get(i);await this.client.core.relayer.unsubscribe(i),await this.client.session.delete(i,sZ("USER_DISCONNECTED")),this.addToRecentlyDeleted(i,"session"),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(i)&&await this.client.core.crypto.deleteSymKey(i),r||this.client.core.expirer.del(i),this.client.core.storage.removeItem(cQ).catch(e=>this.client.logger.warn(e)),this.getPendingSessionRequests().forEach(e=>{e.topic===i&&this.deletePendingSessionRequest(e.id,sZ("USER_DISCONNECTED"))}),i===(null==(t=this.sessionRequestQueue.queue[0])?void 0:t.topic)&&(this.sessionRequestQueue.state=c5.idle),s&&this.client.events.emit("session_delete",{id:n,topic:i})}),la(this,"deleteProposal",async(e,t)=>{if(t)try{let t=this.client.proposal.get(e),i=this.client.core.eventClient.getEvent({topic:t.pairingTopic});i?.setError(oL.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(e,sZ("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")}),la(this,"deletePendingSessionRequest",async(e,t,i=!1)=>
10{await Promise.all([this.client.pendingRequest.delete(e,t),i?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(t=>t.id!==e),i&&(this.sessionRequestQueue.state=c5.idle,this.client.events.emit("session_request_expire",{id:e}))}),la(this,"deletePendingAuthRequest",async(e,t,i=!1)=>{await Promise.all([this.client.auth.requests.delete(e,t),i?Promise.resolve():this.client.core.expirer.del(e)])}),la(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}))}),la(this,"setProposal",async(e,t)=>{this.client.core.expirer.set(e,ib(c1.wc_sessionPropose.req.ttl)),await this.client.proposal.set(e,t)}),la(this,"setAuthRequest",async(e,t)=>{let{request:i,pairingTopic:r,transportType:s=ov.relay}=t;this.client.core.expirer.set(e,i.expiryTimestamp),await this.client.auth.requests.set(e,{authPayload:i.authPayload,requester:i.requester,expiryTimestamp:i.expiryTimestamp,id:e,pairingTopic:r,verifyContext:i.verifyContext,transportType:s})}),la(this,"setPendingSessionRequest",async e=>{let{id:t,topic:i,params:r,verifyContext:s}=e,n=r.request.expiryTimestamp||ib(c1.wc_sessionRequest.req.ttl);this.client.core.expirer.set(t,n),await this.client.pendingRequest.set(t,{id:t,topic:i,params:r,verifyContext:s})}),la(this,"sendRequest",async e=>{let t,r;let{topic:s,method:n,params:o,expiry:a,relayRpcId:c,clientRpcId:l,throwOnFailedPublish:h,appLink:d,tvf:u}=e,p=(0,oi.formatJsonRpcRequest)(n,o,l),g=!!d;try{let e=g?sC:sS;t=await this.client.core.crypto.encode(s,p,{encoding:e})}catch(e){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${s} failed`),e}if(c4.includes(n)){let e=sN(JSON.stringify(p)),i=sN(t);r=await this.client.core.verify.register({id:i,decryptedId:e})}let f=c1[n].req;if(f.attestation=r,a&&(f.ttl=a),c&&(f.id=c),this.client.core.history.set(s,p),g){let e=sH(d,s,t);await i.g.Linking.openURL(e,this.client.name)}else{let e=c1[n].req;a&&(e.ttl=a),c&&(e.id=c),e.tvf=lo(ln({},u),{correlationId:p.id}),h?(e.internal=lo(ln({},e.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,t,e)):this.client.core.relayer.publish(s,t,e).catch(e=>this.client.logger.error(e))}return p.id}),la(this,"sendResult",async e=>{let t,r,s;let{id:n,topic:o,result:a,throwOnFailedPublish:c,encodeOpts:l,appLink:h}=e,d=(0,oi.formatJsonRpcResult)(n,a),u=h&&"u">typeof(null==i.g?void 0:i.g.Linking);try{let e=u?sC:sS;t=await this.client.core.crypto.encode(o,d,lo(ln({},l||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${o} failed`),e}try{let e=(r=await this.client.core.history.get(o,n)).request;try{this.shouldSetTVF(e.method,e.params)&&(s=this.getTVFParams(n,e.params,a))}catch(e){this.client.logger.warn("sendResult() -> getTVFParams() failed",e)}}catch(e){throw this.client.logger.error(`sendResult() -> history.get(${o}, ${n}) failed`),e}if(u){let e=sH(h,o,t);await i.g.Linking.openURL(e,this.client.name)}else{let e=c1[r.request.method].res;e.tvf=lo(ln({},s),{correlationId:n}),c?(e.internal=lo(ln({},e.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(o,t,e)):this.client.core.relayer.publish(o,t,e).catch(e=>this.client.logger.error(e))}await this.client.core.history.resolve(d)}),la(this,"sendError",async e=>{let t,r;let{id:s,topic:n,error:o,encodeOpts:a,rpcOpts:c,appLink:l}=e,h=(0,oi.formatJsonRpcError)(s,o),d=l&&"u">typeof(null==i.g?void 0:i.g.Linking);try{let e=d?sC:sS;t=await this.client.core.crypto.encode(n,h,lo(ln({},a||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${n} failed`),e}try{r=await this.client.core.history.get(n,s)}catch(e){throw this.client.logger.error(`sendError() -> history.get(${n}, ${s}) failed`),e}if(d){let e=sH(l,n,t);await i.g.Linking.openURL(e,this.client.name)}else{let e=r.request.method,i=c||c1[e].res;this.client.core.relayer.publish(n,t,i)}await this.client.core.history.resolve(h)}),la(this,"cleanup",async()=>{let e=[],t=[];
10this.client.session.getAll().forEach(t=>{let i=!1;iw(t.expiry)&&(i=!0),this.client.core.crypto.keychain.has(t.topic)||(i=!0),i&&e.push(t.topic)}),this.client.proposal.getAll().forEach(e=>{iw(e.expiryTimestamp)&&t.push(e.id)}),await Promise.all([...e.map(e=>this.deleteSession({topic:e})),...t.map(e=>this.deleteProposal(e))])}),la(this,"onRelayEventRequest",async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()}),la(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===c5.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=c5.active;let e=this.requestQueue.queue.shift();if(e)try{await this.processRequest(e)}catch(e){this.client.logger.warn(e)}}this.requestQueue.state=c5.idle}),la(this,"processRequest",async e=>{let{topic:t,payload:i,attestation:r,transportType:s,encryptedId:n}=e,o=i.method;if(!this.shouldIgnorePairingRequest({topic:t,requestMethod:o}))switch(o){case"wc_sessionPropose":return await this.onSessionProposeRequest
10({topic:t,payload:i,attestation:r,encryptedId:n});case"wc_sessionSettle":return await this.onSessionSettleRequest(t,i);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(t,i);case"wc_sessionExtend":return await this.onSessionExtendRequest(t,i);case"wc_sessionPing":return await this.onSessionPingRequest(t,i);case"wc_sessionDelete":return await this.onSessionDeleteRequest(t,i);case"wc_sessionRequest":return await this.onSessionRequest({topic:t,payload:i,attestation:r,encryptedId:n,transportType:s});case"wc_sessionEvent":return await this.onSessionEventRequest(t,i);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:t,payload:i,attestation:r,encryptedId:n,transportType:s});default:return this.client.logger.info(`Unsupported request method ${o}`)}}),la(this,"onRelayEventResponse",async e=>{let{topic:t,payload:i,transportType:r}=e,s=(await this.client.core.history.get(t,i.id)).request.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeResponse(t,i,r);case"wc_sessionSettle":return this.onSessionSettleResponse(t,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,i);case"wc_sessionExtend":return this.onSessionExtendResponse(t,i);case"wc_sessionPing":return this.onSessionPingResponse(t,i);case"wc_sessionRequest":return this.onSessionRequestResponse(t,i);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(t,i);default:return this.client.logger.info(`Unsupported response method ${s}`)}}),la(this,"onRelayEventUnknownPayload",e=>{let{topic:t}=e,{message:i}=sY("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw Error(i)}),la(this,"shouldIgnorePairingRequest",e=>{let{topic:t,requestMethod:i}=e,r=this.expectedPairingMethodMap.get(t);return!(!r||r.includes(i))&&!!(r.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),la(this,"onSessionProposeRequest",async e=>{let{topic:t,payload:i,attestation:r,encryptedId:s}=e,{params:n,id:o}=i;try{let 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(oN.proposal_listener_not_found)),this.isValidConnect(ln({},i.params));let a=n.expiryTimestamp||ib(c1.wc_sessionPropose.req.ttl),c=ln({id:o,pairingTopic:t,expiryTimestamp:a},n);await this.setProposal(o,c);let l=await this.getVerifyContext({attestationId:r,hash:sN(JSON.stringify(i)),encryptedId:s,metadata:c.proposer.metadata});e?.addTrace(oT.emit_session_proposal),this.client.events.emit("session_proposal",{id:o,params:c,verifyContext:l})}catch(e){await this.sendError({id:o,topic:t,error:e,rpcOpts:c1.wc_sessionPropose.autoReject}),this.client.logger.error(e)}}),la(this,"onSessionProposeResponse",async(e,t,i)=>{let{id:r}=t;if((0,oi.isJsonRpcResult)(t)){let{result:s}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:s});let n=this.client.proposal.get(r);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});let o=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});let a=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});let c=await this.client.core.crypto.generateSharedKey(o,a);this.pendingSessions.set(r,{sessionTopic:c,pairingTopic:e,proposalId:r,publicKey:o});let l=await this.client.core.relayer.subscribe(c,{transportType:i});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:l}),await this.client.core.pairing.activate({topic:e})}else if((0,oi.isJsonRpcError)(t)){await this.client.proposal.delete(r,sZ("USER_DISCONNECTED"));let e=iv("session_connect",r);if(0===this.events.listenerCount(e))throw Error(`emitting ${e} without any listeners, 954`);this.events.emit(e,{error:t.error})}}),la(this,"onSessionSettleRequest",async(e,t)=>{let{id:i,params:r}=t;try{this.isValidSessionSettleRequest(r);let{relay:i,controller:s,expiry:n,namespaces:o,sessionProperties:a,sessionConfig:c}=t.params,l=[...this.pendingSessions.values()].find(t=>t.sessionTopic===e);if(!l)return this.client.logger.error(`Pending session not found for topic ${e}`);
10let h=this.client.proposal.get(l.proposalId),d=lo(ln(ln({topic:e,relay:i,expiry:n,namespaces:o,acknowledged:!0,pairingTopic:l.pairingTopic,requiredNamespaces:h.requiredNamespaces,optionalNamespaces:h.optionalNamespaces,controller:s.publicKey,self:{publicKey:l.publicKey,metadata:this.client.metadata},peer:{publicKey:s.publicKey,metadata:s.metadata}},a&&{sessionProperties:a}),c&&{sessionConfig:c}),{transportType:ov.relay});await this.client.session.set(d.topic,d),await this.setExpiry(d.topic,d.expiry),await this.client.core.pairing.updateMetadata({topic:l.pairingTopic,metadata:d.peer.metadata}),this.client.events.emit("session_connect",{session:d}),this.events.emit(iv("session_connect",l.proposalId),{session:d}),this.pendingSessions.delete(l.proposalId),this.deleteProposal(l.proposalId,!1),this.cleanupDuplicatePairings(d),await this.sendResult({id:t.id,topic:e,result:!0,throwOnFailedPublish:!0})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),la(this,"onSessionSettleResponse",async(e,t)=>{let{id:i}=t;(0,oi.isJsonRpcResult)(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(iv("session_approve",i),{})):(0,oi.isJsonRpcError)(t)&&(await this.client.session.delete(e,sZ("USER_DISCONNECTED")),this.events.emit(iv("session_approve",i),{error:t.error}))}),la(this,"onSessionUpdateRequest",async(e,t)=>{let{params:i,id:r}=t;try{let t=`${e}_session_update`,s=nn.get(t);if(s&&this.isRequestOutOfSync(s,r)){this.client.logger.warn(`Discarding out of sync request - ${r}`),this.sendError({id:r,topic:e,error:sZ("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(ln({topic:e},i));try{nn.set(t,r),await this.client.session.update(e,{namespaces:i.namespaces}),await this.sendResult({id:r,topic:e,result:!0,throwOnFailedPublish:!0})}catch(e){throw nn.delete(t),e}this.client.events.emit("session_update",{id:r,topic:e,params:i})}catch(t){await this.sendError({id:r,topic:e,error:t}),this.client.logger.error(t)}}),la(this,"isRequestOutOfSync",(e,t)=>t.toString().slice(0,-3)<e.toString().slice(0,-3)),la(this,"onSessionUpdateResponse",(e,t)=>{let{id:i}=t,r=iv("session_update",i);if(0===this.events.listenerCount(r))throw Error(`emitting ${r} without any listeners`);(0,oi.isJsonRpcResult)(t)?this.events.emit(iv("session_update",i),{}):(0,oi.isJsonRpcError)(t)&&this.events.emit(iv("session_update",i),{error:t.error})}),la(this,"onSessionExtendRequest",async(e,t)=>{let{id:i}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,ib(c0)),await this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:i,topic:e})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),la(this,"onSessionExtendResponse",(e,t)=>{let{id:i}=t,r=iv("session_extend",i);if(0===this.events.listenerCount(r))throw Error(`emitting ${r} without any listeners`);(0,oi.isJsonRpcResult)(t)?this.events.emit(iv("session_extend",i),{}):(0,oi.isJsonRpcError)(t)&&this.events.emit(iv("session_extend",i),{error:t.error})}),la(this,"onSessionPingRequest",async(e,t)=>{let{id:i}=t;try{this.isValidPing({topic:e}),await this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:i,topic:e})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),la(this,"onSessionPingResponse",(e,t)=>{let{id:i}=t,r=iv("session_ping",i);if(0===this.events.listenerCount(r))throw Error(`emitting ${r} without any listeners`);setTimeout(()=>{(0,oi.isJsonRpcResult)(t)?this.events.emit(iv("session_ping",i),{}):(0,oi.isJsonRpcError)(t)&&this.events.emit(iv("session_ping",i),{error:t.error})},500)}),la(this,"onSessionDeleteRequest",async(e,t)=>{let{id:i}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),Promise.all([new Promise(t=>{this.client.core.relayer.once(oy.publish,async()=>{t(await this.deleteSession({topic:e,id:i}))})}),this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:sZ("USER_DISCONNECTED")})]).catch(e=>this.client.logger.error(e))}catch(e){this.client.logger.error(e)}}),la(this,"onSessionRequest",async e=>{var t,i,r;let{topic:s,payload:n,attestation:o,encryptedId:a,transportType:c}=e,{id:l,params:h}=n;try{await this.isValidRequest(ln({topic:s},h));let e=this.client.session.get(s),n=await this.getVerifyContext({attestationId:o,hash:sN(JSON.stringify((0,oi.formatJsonRpcRequest)("wc_sessionRequest",h,l))),encryptedId:a,metadata:e.peer.metadata,transportType:c}),d={id:l,topic:s,params:h,verifyContext:n};await this.setPendingSessionRequest(d),c===ov.link_mode&&null!=(t=e.peer.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(null==(i=e.peer.metadata.redirect)?void 0:i.universal),null!=(r=this.client.signConfig)&&r.disableRequestQueue?this.emitSessionRequest(d):(this.addSessionRequestToSessionRequestQueue(d),this.processSessionRequestQueue())}
10catch(e){await this.sendError({id:l,topic:s,error:e}),this.client.logger.error(e)}}),la(this,"onSessionRequestResponse",(e,t)=>{let{id:i}=t,r=iv("session_request",i);if(0===this.events.listenerCount(r))throw Error(`emitting ${r} without any listeners`);(0,oi.isJsonRpcResult)(t)?this.events.emit(iv("session_request",i),{result:t.result}):(0,oi.isJsonRpcError)(t)&&this.events.emit(iv("session_request",i),{error:t.error})}),la(this,"onSessionEventRequest",async(e,t)=>{let{id:i,params:r}=t;try{let t=`${e}_session_event_${r.event.name}`,s=nn.get(t);if(s&&this.isRequestOutOfSync(s,i)){this.client.logger.info(`Discarding out of sync request - ${i}`);return}this.isValidEmit(ln({topic:e},r)),this.client.events.emit("session_event",{id:i,topic:e,params:r}),nn.set(t,i)}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),la(this,"onSessionAuthenticateResponse",(e,t)=>{let{id:i}=t;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:t}),(0,oi.isJsonRpcResult)(t)?this.events.emit(iv("session_request",i),{result:t.result}):(0,oi.isJsonRpcError)(t)&&this.events.emit(iv("session_request",i),{error:t.error})}),la(this,"onSessionAuthenticateRequest",async e=>{var t;let{topic:i,payload:r,attestation:s,encryptedId:n,transportType:o}=e;try{let{requester:e,authPayload:a,expiryTimestamp:c}=r.params,l=await this.getVerifyContext({attestationId:s,hash:sN(JSON.stringify(r)),encryptedId:n,metadata:e.metadata,transportType:o}),h={requester:e,pairingTopic:i,id:r.id,authPayload:a,verifyContext:l,expiryTimestamp:c};await this.setAuthRequest(r.id,{request:h,pairingTopic:i,transportType:o}),o===ov.link_mode&&null!=(t=e.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(e.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:i,params:r.params,id:r.id,verifyContext:l})}catch(n){this.client.logger.error(n);let e=r.params.requester.publicKey,t=await this.client.core.crypto.generateKeyPair(),s=this.getAppLinkIfEnabled(r.params.requester.metadata,o);await this.sendError({id:r.id,topic:i,error:n,encodeOpts:{type:1,receiverPublicKey:e,senderPublicKey:t},rpcOpts:c1.wc_sessionAuthenticate.autoReject,appLink:s})}}),la(this,"addSessionRequestToSessionRequestQueue",e=>{this.sessionRequestQueue.queue.push(e)}),la(this,"cleanupAfterResponse",e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=c5.idle,this.processSessionRequestQueue()},(0,A.toMiliseconds)(this.requestQueueDelay))}),la(this,"cleanupPendingSentRequestsForTopic",({topic:e,error:t})=>{let i=this.client.core.history.pending;i.length>0&&i.filter(t=>t.topic===e&&"wc_sessionRequest"===t.request.method).forEach(e=>{let i=iv("session_request",e.request.id);if(0===this.events.listenerCount(i))throw Error(`emitting ${i} without any listeners`);this.events.emit(iv("session_request",e.request.id),{error:t})})}),la(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===c5.active){this.client.logger.info("session request queue is already active.");return}let e=this.sessionRequestQueue.queue[0];if(!e){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=c5.active,this.emitSessionRequest(e)}catch(e){this.client.logger.error(e)}}),la(this,"emitSessionRequest",e=>{this.client.events.emit("session_request",e)}),la(this,"onPairingCreated",e=>{if(e.methods&&this.expectedPairingMethodMap.set(e.topic,e.methods),e.active)return;let t=this.client.proposal.getAll().find(t=>t.pairingTopic===e.topic);
10t&&this.onSessionProposeRequest({topic:e.topic,payload:(0,oi.formatJsonRpcRequest)("wc_sessionPropose",{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties},t.id)})}),la(this,"isValidConnect",async e=>{let t;if(!s7(e)){let{message:t}=sY("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw Error(t)}let{pairingTopic:i,requiredNamespaces:r,optionalNamespaces:s,sessionProperties:n,relays:o}=e;if(s0(i)||await this.isValidPairingTopic(i),t=!1,o?o&&sQ(o)&&o.length&&o.forEach(e=>{t=s6(e)}):t=!0,!t){let{message:e}=sY("MISSING_OR_INVALID",`connect() relays: ${o}`);throw Error(e)}s0(r)||0===sX(r)||this.validateNamespaces(r,"requiredNamespaces"),s0(s)||0===sX(s)||this.validateNamespaces(s,"optionalNamespaces"),s0(n)||this.validateSessionProps(n,"sessionProperties")}),la(this,"validateNamespaces",(e,t)=>{let i=function(e,t,i){let r=null;if(e&&sX(e)){let s;let n=s4(e,t);n&&(r=n);let o=(s=null,Object.entries(e).forEach(([e,r])=>{var n,o;let a;if(s)return;let c=(n=ie(e,r),o=`${t} ${i}`,a=null,sQ(n)&&n.length?n.forEach(e=>{a||s5(e)||(a=sZ("UNSUPPORTED_CHAINS",`${o}, chain ${e} should be a string and conform to "namespace:chainId" format`))}):s5(e)||(a=sZ("UNSUPPORTED_CHAINS",`${o}, 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"] }`)),a);c&&(s=c)}),s);o&&(r=o)}else r=sY("MISSING_OR_INVALID",`${t}, ${i} should be an object with data`);return r}(e,"connect()",t);if(i)throw Error(i.message)}),la(this,"isValidApprove",async e=>{if(!s7(e))throw Error(sY("MISSING_OR_INVALID",`approve() params: ${e}`).message);let{id:t,namespaces:i,relayProtocol:r,sessionProperties:s}=e;this.checkRecentlyDeleted(t),await this.isValidProposalId(t);let n=this.client.proposal.get(t),o=s8(i,"approve()");if(o)throw Error(o.message);let a=ne(n.requiredNamespaces,i,"approve()");if(a)throw Error(a.message);if(!s1(r,!0)){let{message:e}=sY("MISSING_OR_INVALID",`approve() relayProtocol: ${r}`);throw Error(e)}s0(s)||this.validateSessionProps(s,"sessionProperties")}),la(this,"isValidReject",async e=>{if(!s7(e)){let{message:t}=sY("MISSING_OR_INVALID",`reject() params: ${e}`);throw Error(t)}let{id:t,reason:i}=e;if(this.checkRecentlyDeleted(t),await this.isValidProposalId(t),!i||"object"!=typeof i||!i.code||!s2(i.code,!1)||!i.message||!s1(i.message,!1)){let{message:e}=sY("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw Error(e)}}),la(this,"isValidSessionSettleRequest",e=>{let t;if(!s7(e)){let{message:t}=sY("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw Error(t)}
10let{relay:i,controller:r,namespaces:s,expiry:n}=e;if(!s6(i)){let{message:e}=sY("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw Error(e)}let o=(t=null,s1(r?.publicKey,!1)||(t=sY("MISSING_OR_INVALID","onSessionSettleRequest() controller public key should be a string")),t);if(o)throw Error(o.message);let a=s8(s,"onSessionSettleRequest()");if(a)throw Error(a.message);if(iw(n)){let{message:e}=sY("EXPIRED","onSessionSettleRequest()");throw Error(e)}}),la(this,"isValidUpdate",async e=>{if(!s7(e)){let{message:t}=sY("MISSING_OR_INVALID",`update() params: ${e}`);throw Error(t)}let{topic:t,namespaces:i}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);let r=this.client.session.get(t),s=s8(i,"update()");if(s)throw Error(s.message);let n=ne(r.requiredNamespaces,i,"update()");if(n)throw Error(n.message)}),la(this,"isValidExtend",async e=>{if(!s7(e)){let{message:t}=sY("MISSING_OR_INVALID",`extend() params: ${e}`);throw Error(t)}let{topic:t}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t)}),la(this,"isValidRequest",async e=>{var t;if(!s7(e)){let{message:t}=sY("MISSING_OR_INVALID",`request() params: ${e}`);throw Error(t)}let{topic:i,request:r,chainId:s,expiry:n}=e;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);let{namespaces:o}=this.client.session.get(i);if(!s9(o,s)){let{message:e}=sY("MISSING_OR_INVALID",`request() chainId: ${s}`);throw Error(e)}if(s0(r)||!s1(r.method,!1)){let{message:e}=sY("MISSING_OR_INVALID",`request() ${JSON.stringify(r)}`);throw Error(e)}if(!(s1(t=r.method,!1)&&(function(e,t){let i=[];return Object.values(e).forEach(e=>{sV(e.accounts).includes(t)&&i.push(...e.methods)}),i})(o,s).includes(t))){let{message:e}=sY("MISSING_OR_INVALID",`request() method: ${r.method}`);throw Error(e)}if(n&&(!s2(n,!1)||!(n<=c2.max)||!(n>=c2.min))){let{message:e}=sY("MISSING_OR_INVALID",`request() expiry: ${n}. Expiry must be a number (in seconds) between ${c2.min} and ${c2.max}`);throw Error(e)}}),la(this,"isValidRespond",async e=>{var t;if(!s7(e)){let{message:t}=sY("MISSING_OR_INVALID",`respond() params: ${e}`);throw Error(t)}let{topic:i,response:r}=e;try{await this.isValidSessionTopic(i)}catch(i){throw null!=(t=e?.response)&&t.id&&this.cleanupAfterResponse(e),i}if(s0(r)||s0(r.result)&&s0(r.error)||!s2(r.id,!1)||!s1(r.jsonrpc,!1)){let{message:e}=sY("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(r)}`);throw Error(e)}}),la(this,"isValidPing",async e=>{if(!s7(e)){let{message:t}=sY("MISSING_OR_INVALID",`ping() params: ${e}`);throw Error(t)}let{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),la(this,"isValidEmit",async e=>{var t;if(!s7(e)){let{message:t}=sY("MISSING_OR_INVALID",`emit() params: ${e}`);throw Error(t)}let{topic:i,event:r,chainId:s}=e;await this.isValidSessionTopic(i);let{namespaces:n}=this.client.session.get(i);if(!s9(n,s)){let{message:e}=sY("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw Error(e)}if(s0(r)||!s1(r.name,!1)){let{message:e}=sY("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw Error(e)}if(!(s1(t=r.name,!1)&&(function(e,t){let i=[];return Object.values(e).forEach(e=>{sV(e.accounts).includes(t)&&i.push(...e.events)}),i})(n,s).includes(t))){let{message:e}=sY("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw Error(e)}}),la(this,"isValidDisconnect",async e=>{if(!s7(e)){let{message:t}=sY("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw Error(t)}let{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),la(this,"isValidAuthenticate",e=>{let{chains:t,uri:i,domain:r,nonce:s}=e;if(!Array.isArray(t)||0===t.length)throw Error("chains is required and must be a non-empty array");if(!s1(i,!1))throw Error("uri is required parameter");if(!s1(r,!1))throw Error("domain is required parameter");if(!s1(s,!1))throw Error("nonce is required parameter");if([...new Set(t.map(e=>t7(e).namespace))].length>1)throw Error("Multi-namespace requests are not supported. Please request single namespace only.");let{namespace:n}=t7(t[0]);if("eip155"!==n)throw Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),la(this,"getVerifyContext",async e=>{let{attestationId:t,hash:i,encryptedId:r,metadata:s,transportType:n}=e,o={verified:{verifyUrl:s.verifyUrl||oC,validation:"UNKNOWN",origin:s.url||""}};try{if(n===ov.link_mode){let e=this.getAppLinkIfEnabled(s,n);return o.verified.validation=e&&new URL(e).origin===new URL(s.url).origin?"VALID":"INVALID",o}let e=await this.client.core.verify.resolve({attestationId:t,hash:i,encryptedId:r,verifyUrl:s.verifyUrl});e&&(o.verified.origin=e.origin,o.verified.isScam=e.isScam,o.verified.validation=e.origin===new URL(s.url).origin?"VALID":"INVALID")}catch(e){this.client.logger.warn(e)}return this.client.logger.debug(`Verify context: ${JSON.stringify(o)}`),o}),la(this,"validateSessionProps",(e,t)=>
10{Object.values(e).forEach(e=>{if(!s1(e,!1)){let{message:i}=sY("MISSING_OR_INVALID",`${t} must be in Record<string, string> format. Received: ${JSON.stringify(e)}`);throw Error(i)}})}),la(this,"getPendingAuthRequest",e=>{let t=this.client.auth.requests.get(e);return"object"==typeof t?t:void 0}),la(this,"addToRecentlyDeleted",(e,t)=>{if(this.recentlyDeletedMap.set(e,t),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let e=0,t=this.recentlyDeletedLimit/2;for(let i of this.recentlyDeletedMap.keys()){if(e++>=t)break;this.recentlyDeletedMap.delete(i)}}}),la(this,"checkRecentlyDeleted",e=>{let t=this.recentlyDeletedMap.get(e);if(t){let{message:i}=sY("MISSING_OR_INVALID",`Record was recently deleted - ${t}: ${e}`);throw Error(i)}}),la(this,"isLinkModeEnabled",(e,t)=>{var r,s,n,o,a,c,l,h,d;return!!e&&t===ov.link_mode&&(null==(s=null==(r=this.client.metadata)?void 0:r.redirect)?void 0:s.linkMode)===!0&&(null==(o=null==(n=this.client.metadata)?void 0:n.redirect)?void 0:o.universal)!==void 0&&(null==(c=null==(a=this.client.metadata)?void 0:a.redirect)?void 0:c.universal)!==""&&(null==(l=e?.redirect)?void 0:l.universal)!==void 0&&(null==(h=e?.redirect)?void 0:h.universal)!==""&&(null==(d=e?.redirect)?void 0:d.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(e.redirect.universal)&&"u">typeof(null==i.g?void 0:i.g.Linking)}),la(this,"getAppLinkIfEnabled",(e,t)=>{var i;return this.isLinkModeEnabled(e,t)?null==(i=e?.redirect)?void 0:i.universal:void 0}),la(this,"handleLinkModeMessage",({url:e})=>{if(!e||!e.includes("wc_ev")||!e.includes("topic"))return;let t=ix(e,"topic")||"",i=decodeURIComponent(ix(e,"wc_ev")||""),r=this.client.session.keys.includes(t);r&&this.client.session.update(t,{transportType:ov.link_mode}),this.client.core.dispatchEnvelope({topic:t,message:i,sessionExists:r})}),la(this,"registerLinkModeListeners",async()=>{var e;if(iP()||ir()&&null!=(e=this.client.metadata.redirect)&&e.linkMode){let e=null==i.g?void 0:i.g.Linking;if("u">typeof e){e.addEventListener("url",this.handleLinkModeMessage,this.client.name);let t=await e.getInitialURL();t&&setTimeout(()=>{this.handleLinkModeMessage({url:t})},50)}}}),la(this,"shouldSetTVF",(e,t)=>{if(!t||"wc_sessionRequest"!==e)return!1;let{request:i}=t;return Object.keys(c3).includes(i.method)}),la(this,"getTVFParams",(e,t,i)=>{var r,s;try{let n=t.request.method,o=this.extractTxHashesFromResult(n,i);return lo(ln({correlationId:e,rpcMethods:[n],chainId:t.chainId},this.isValidContractData(t.request.params)&&{contractAddresses:[null==(s=null==(r=t.request.params)?void 0:r[0])?void 0:s.to]}),{txHashes:o})}catch(e){this.client.logger.warn("Error getting TVF params",e)}return{}}),la(this,"isValidContractData",e=>{var t;if(!e)return!1;try{let i=e?.data||(null==(t=e?.[0])?void 0:t.data);if(!i.startsWith("0x"))return!1;let r=i.slice(2);return!!/^[0-9a-fA-F]*$/.test(r)&&r.length%2==0}catch{}return!1}),la(this,"extractTxHashesFromResult",(e,t)=>{try{let i=c3[e];if("string"==typeof t)return[t];let r=t[i.key];if(sQ(r))return r;if("string"==typeof r)return[r]}catch(e){this.client.logger.warn("Error extracting tx hashes from result",e)}return[]})}isInitialized(){if(!this.initialized){let{message:e}=sY("NOT_INITIALIZED",this.name);throw Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(oy.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){let{topic:t,message:i,attestation:r,transportType:s}=e,{publicKey:n}=this.client.auth.authKeys.keys.includes(c6)?this.client.auth.authKeys.get(c6):{responseTopic:void 0,publicKey:void 0},o=await this.client.core.crypto.decode(t,i,{receiverPublicKey:n,encoding:s===ov.link_mode?sC:sS});try{(0,oi.isJsonRpcRequest)(o)?(this.client.core.history.set(t,o),this.onRelayEventRequest({topic:t,payload:o,attestation:r,transportType:s,encryptedId:sN(i)})):(0,oi.isJsonRpcResponse)(o)?(await this.client.core.history.resolve(o),await this.onRelayEventResponse({topic:t,payload:o,transportType:s}),this.client.core.history.delete(t,o.id)):this.onRelayEventUnknownPayload({topic:t,payload:o,transportType:s})}catch(e){this.client.logger.error(e)}}registerExpirerEvents(){this.client.core.expirer.on(oS.expired,async e=>
10{let{topic:t,id:i}=iy(e.target);return i&&this.client.pendingRequest.keys.includes(i)?await this.deletePendingSessionRequest(i,sY("EXPIRED"),!0):i&&this.client.auth.requests.keys.includes(i)?await this.deletePendingAuthRequest(i,sY("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})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i})))})}registerPairingEvents(){this.client.core.pairing.events.on(oO.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(oO.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!s1(e,!1)){let{message:t}=sY("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){let{message:t}=sY("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw Error(t)}if(iw(this.client.core.pairing.pairings.get(e).expiry)){let{message:t}=sY("EXPIRED",`pairing topic: ${e}`);throw Error(t)}}async isValidSessionTopic(e){if(!s1(e,!1)){let{message:t}=sY("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){let{message:t}=sY("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw Error(t)}if(iw(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});let{message:t}=sY("EXPIRED",`session topic: ${e}`);throw Error(t)}if(!this.client.core.crypto.keychain.has(e)){let{message:t}=sY("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),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))this.isValidPairingTopic(e);else if(s1(e,!1)){let{message:t}=sY("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw Error(t)}else{let{message:t}=sY("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw Error(t)}}async isValidProposalId(e){if("number"!=typeof e){let{message:t}=sY("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw Error(t)}if(!this.client.proposal.keys.includes(e)){let{message:t}=sY("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw Error(t)}if(iw(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);let{message:t}=sY("EXPIRED",`proposal id: ${e}`);throw Error(t)}}}class ll extends cu{constructor(e,t){super(e,t,"proposal",cY),this.core=e,this.logger=t}}class lh extends cu{constructor(e,t){super(e,t,"session",cY),this.core=e,this.logger=t}}class ld extends cu{constructor(e,t){super(e,t,"request",cY,e=>e.id),this.core=e,this.logger=t}}class lu extends cu{constructor(e,t){super(e,t,"authKeys",c8,()=>c6),this.core=e,this.logger=t}}class lp extends cu{constructor(e,t){super(e,t,"pairingTopics",c8),this.core=e,this.logger=t}}class lg extends cu{constructor(e,t){super(e,t,"requests",c8,e=>e.id),this.core=e,this.logger=t}}var lf=Object.defineProperty,lm=(e,t,i)=>t in e?lf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,ly=(e,t,i)=>lm(e,"symbol"!=typeof t?t+"":t,i);class lb{constructor(e,t){this.core=e,this.logger=t,ly(this,"authKeys"),ly(this,"pairingTopics"),ly(this,"requests"),this.authKeys=new lu(this.core,this.logger),this.pairingTopics=new lp(this.core,this.logger),this.requests=new lg(this.core,this.logger)}
10async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var lw=Object.defineProperty,lv=(e,t,i)=>t in e?lw(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,lE=(e,t,i)=>lv(e,"symbol"!=typeof t?t+"":t,i);class l_ extends n9{constructor(e){super(e),lE(this,"protocol","wc"),lE(this,"version",2),lE(this,"name",cZ.name),lE(this,"metadata"),lE(this,"core"),lE(this,"logger"),lE(this,"events",new S.EventEmitter),lE(this,"engine"),lE(this,"session"),lE(this,"proposal"),lE(this,"pendingRequest"),lE(this,"auth"),lE(this,"signConfig"),lE(this,"on",(e,t)=>this.events.on(e,t)),lE(this,"once",(e,t)=>this.events.once(e,t)),lE(this,"off",(e,t)=>this.events.off(e,t)),lE(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),lE(this,"removeAllListeners",e=>this.events.removeAllListeners(e)),lE(this,"connect",async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}}),lE(this,"pair",async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}}),lE(this,"approve",async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}}),lE(this,"reject",async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}}),lE(this,"update",async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}}),lE(this,"extend",async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}}),lE(this,"request",async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}}),lE(this,"respond",async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}}),lE(this,"ping",async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}}),lE(this,"emit",async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}}),lE(this,"disconnect",async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}}),lE(this,"find",e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}}),lE(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}}),lE(this,"authenticate",async(e,t)=>{try{return await this.engine.authenticate(e,t)}catch(e){throw this.logger.error(e.message),e}}),lE(this,"formatAuthMessage",e=>{try{return this.engine.formatAuthMessage(e)}catch(e){throw this.logger.error(e.message),e}}),lE(this,"approveSessionAuthenticate",async e=>{try{return await this.engine.approveSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),lE(this,"rejectSessionAuthenticate",async e=>{try{return await this.engine.rejectSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),this.name=e?.name||cZ.name,this.metadata=e?.metadata||ic(),this.signConfig=e?.signConfig;let t="u">typeof e?.logger&&"string"!=typeof e?.logger?e.logger:nI()(nq({level:e?.logger||cZ.logger}));this.core=e?.core||new cJ(e),this.logger=nz(t,this.name),this.session=new lh(this.core,this.logger),this.proposal=new ll(this.core,this.logger),this.pendingRequest=new ld(this.core,this.logger),this.engine=new lc(this),this.auth=new lb(this.core,this.logger)}static async init(e){let t=new l_(e);return await t.initialize(),t}get context(){return nB(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,A.toMiliseconds)(A.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}var lI=i(5071);let lx="error",lO="wc@2:universal_provider:",lP="https://rpc.walletconnect.org/v1/",lS="generic",lC=`${lP}bundler`,lR="default_chain_changed";var lA="u">typeof globalThis?globalThis:"u">typeof window?window:"u">typeof i.g?i.g:"u">typeof self?self:{},lT=function(e,t){return e===t||e!=e&&t!=t},lN=function(e,t){for(var i=e.length;i--;)if(lT(e[i][0],t))return i;return -1},lk=Array.prototype.splice;function lL(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}lL.prototype.clear=function(){this.__data__=[],this.size=0},lL.prototype.delete=function(e){var t=this.__data__,i=lN(t,e);return!(i<0)&&(i==t.length-1?t.pop():lk.call(t,i,1),--this.size,!0)},lL.prototype.get=function(e){var t=this.__data__,i=lN(t,e);return i<0?void 0:t[i][1]},lL.prototype.has=function(e){return lN(this.__data__,e)>-1},lL.prototype.set=function(e,t){var i=this.__data__,r=lN(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this};var l$="object"==typeof lA&&lA&&lA.Object===Object&&lA,lj="object"==typeof self&&self&&self.Object===Object&&self,lD=l$||lj||Function("return this")(),lM=lD.Symbol,lU=Object.prototype,lq=lU.hasOwnProperty,lB=lU.toString,lz=lM?lM.toStringTag:void 0,lH=Object.prototype.toString,lV=function(e){var t=lq.call(e,lz),i=e[lz];try{e[lz]=void 0;var r=!0}catch{}var s=lB.call(e);return r&&(t?e[lz]=i:delete e[lz]),s},lW=lM?lM.toStringTag:void 0,lK=function(e){return null==e?void 0===e?"[object Undef
10ined]":"[object Null]":lW&&lW in Object(e)?lV(e):lH.call(e)},lF=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},lJ=function(e){if(!lF(e))return!1;var t=lK(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},lG=lD["__core-js_shared__"],lY=(o=/[^.]+$/.exec(lG&&lG.keys&&lG.keys.IE_PROTO||""))?"Symbol(src)_1."+o:"",lZ=Function.prototype.toString,lQ=function(e){if(null!=e){try{return lZ.call(e)}catch{}try{return e+""}catch{}}return""},lX=/^\[object .+?Constructor\]$/,l0=Object.prototype,l1=Function.prototype.toString,l2=l0.hasOwnProperty,l5=RegExp("^"+l1.call(l2).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),l3=function(e,t){var i,r=e?.[t];return lF(i=r)&&(!lY||!(lY in i))&&(lJ(i)?l5:lX).test(lQ(i))?r:void 0},l4=l3(lD,"Map"),l8=l3(Object,"create"),l6=Object.prototype.hasOwnProperty,l7=Object.prototype.hasOwnProperty;function l9(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}l9.prototype.clear=function(){this.__data__=l8?l8(null):{},this.size=0},l9.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},l9.prototype.get=function(e){var t=this.__data__;if(l8){var i=t[e];return"__lodash_hash_undefined__"===i?void 0:i}return l6.call(t,e)?t[e]:void 0},l9.prototype.has=function(e){var t=this.__data__;return l8?void 0!==t[e]:l7.call(t,e)},l9.prototype.set=function(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=l8&&void 0===t?"__lodash_hash_undefined__":t,this};var he=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e},ht=function(e,t){var i=e.__data__;return he(t)?i["string"==typeof t?"string":"hash"]:i.map};function hi(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}function hr(e){var t=this.__data__=new lL(e);this.size=t.size}hi.prototype.clear=function(){this.size=0,this.__data__={hash:new l9,map:new(l4||lL),string:new l9}},hi.prototype.delete=function(e){var t=ht(this,e).delete(e);return this.size-=t?1:0,t},hi.prototype.get=function(e){return ht(this,e).get(e)},hi.prototype.has=function(e){return ht(this,e).has(e)},hi.prototype.set=function(e,t){var i=ht(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this},hr.prototype.clear=function(){this.__data__=new lL,this.size=0},hr.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},hr.prototype.get=function(e){return this.__data__.get(e)},hr.prototype.has=function(e){return this.__data__.has(e)},hr.prototype.set=function(e,t){var i=this.__data__;if(i instanceof lL){var r=i.__data__;if(!l4||r.length<199)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new hi(r)}return i.set(e,t),this.size=i.size,this};var hs=function(){try{var e=l3(Object,"defineProperty");return e({},"",{}),e}catch{}}(),hn=function(e,t,i){"__proto__"==t&&hs?hs(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i},ho=function(e,t,i){(void 0===i||lT(e[t],i))&&(void 0!==i||t in e)||hn(e,t,i)}
10,ha={exports:{}};d=(h=(l=(c=(a=ha.exports)&&!a.nodeType&&a)&&ha&&!ha.nodeType&&ha)&&l.exports===c?lD.Buffer:void 0)?h.allocUnsafe:void 0,ha.exports=function(e,t){if(t)return e.slice();var i=e.length,r=d?d(i):new e.constructor(i);return e.copy(r),r};var hc=lD.Uint8Array,hl=function(e){var t=new e.constructor(e.byteLength);return new hc(t).set(new hc(e)),t},hh=Object.create,hd=function(){function e(){}return function(t){if(!lF(t))return{};if(hh)return hh(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),hu=(u=Object.getPrototypeOf,p=Object,function(e){return u(p(e))}),hp=Object.prototype,hg=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||hp)},hf=function(e){return null!=e&&"object"==typeof e},hm=function(e){return hf(e)&&"[object Arguments]"==lK(e)},hy=Object.prototype,hb=hy.hasOwnProperty,hw=hy.propertyIsEnumerable,hv=hm(function(){return arguments}())?hm:function(e){return hf(e)&&hb.call(e,"callee")&&!hw.call(e,"callee")},hE=Array.isArray,h_=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991},hI=function(e){return null!=e&&h_(e.length)&&!lJ(e)},hx={exports:{}};b=(y=(m=(f=(g=hx.exports)&&!g.nodeType&&g)&&hx&&!hx.nodeType&&hx)&&m.exports===f?lD.Buffer:void 0)?y.isBuffer:void 0,hx.exports=b||function(){return!1};var hO=Object.prototype,hP=Function.prototype.toString,hS=hO.hasOwnProperty,hC=hP.call(Object),hR={};hR["[object Float32Array]"]=hR["[object Float64Array]"]=hR["[object Int8Array]"]=hR["[object Int16Array]"]=hR["[object Int32Array]"]=hR["[object Uint8Array]"]=hR["[object Uint8ClampedArray]"]=hR["[object Uint16Array]"]=hR["[object Uint32Array]"]=!0,hR["[object Arguments]"]=hR["[object Array]"]=hR["[object ArrayBuffer]"]=hR["[object Boolean]"]=hR["[object DataView]"]=hR["[object Date]"]=hR["[object Error]"]=hR["[object Function]"]=hR["[object Map]"]=hR["[object Number]"]=hR["[object Object]"]=hR["[object RegExp]"]=hR["[object Set]"]=hR["[object String]"]=hR["[object WeakMap]"]=!1;var hA={exports:{}};_=(E=(v=(w=hA.exports)&&!w.nodeType&&w)&&hA&&!hA.nodeType&&hA)&&E.exports===v&&l$.process,I=function(){try{return E&&E.require&&E.require("util").types||_&&_.binding&&_.binding("util")}catch{}}(),hA.exports=I;var hT=hA.exports,hN=hT&&hT.isTypedArray,hk=hN?function(e){return hN(e)}:function(e){return hf(e)&&h_(e.length)&&!!hR[lK(e)]},hL=function(e,t){if(!("constructor"===t&&"function"==typeof e[t])&&"__proto__"!=t)return e[t]},h$=Object.prototype.hasOwnProperty,hj=function(e,t,i){var r=e[t];h$.call(e,t)&&lT(r,i)&&(void 0!==i||t in e)||hn(e,t,i)},hD=/^(?:0|[1-9]\d*)$/,hM=function(e,t){var i=typeof e;return!!(t=t??9007199254740991)&&("number"==i||"symbol"!=i&&hD.test(e))&&e>-1&&e%1==0&&e<t},hU=function(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r},hq=hx.exports,hB=Object.prototype.hasOwnProperty,hz=function(e){var t=[];if(null!=e)for(var i in Object(e))t.push(i);return t},hH=Object.prototype.hasOwnProperty,hV=function(e,t){var i=hE(e),r=!i&&hv(e),s=!i&&!r&&hq(e),n=!i&&!r&&!s&&hk(e),o=i||r||s||n,a=o?hU(e.length,String):[],c=a.length;for(var l in e)(t||hB.call(e,l))&&!(o&&("length"==l||s&&("offset"==l||"parent"==l)||n&&("buffer"==l||"byteLength"==l||"byteOffset"==l)||hM(l,c)))&&a.push(l);return a},hW=function(e){if(!lF(e))return hz(e);var t=hg(e),i=[];for(var r in e)"constructor"==r&&(t||!hH.call(e,r))||i.push(r);return i},hK=function(e){return hI(e)?hV(e,!0):hW(e)},hF=function(e,t,i,r){var s=!i;i||(i={});for(var n=-1,o=t.length;++n<o;){var a=t[n],c=r?r(i[a],e[a],a,i,e):void 0;void 0===c&&(c=e[a]),s?hn(i,a,c):hj(i,a,c)}return i},hJ=ha.exports,hG=function(e,t){var i=t?hl(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)},hY=function(e,t){var i=-1,r=e.length;for(t||(t=Array(r));++i<r;)t[i]=e[i];return t},hZ=hx.exports,hQ=function(e){if(!hf(e)||"[object Object]"!=lK(e))return!1;var t=hu(e);if(null===t)return!0;var i=hS.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&hP.call(i)==hC},hX=function(e,t,i){for(var r=-1,s=Object(e),n=i(e),o=n.length;o--;){var a=n[++r];if(!1===t(s[a],a,s))break}return e},h0=function(e,t,i,r,s,n,o){var a=hL(e,i),c=hL(t,i),l=o.get(c);if(l){ho(e,i,l);return}var h=n?n(a,c,i+"",e,t,o):void 0,d=void 0===h;if(d){var u=hE(c),p=!u&&hZ(c),g=!u&&!p&&hk(c);h=c,u||p||g?hE(a)?h=a:hf(a)&&hI(a)?h=hY(a):p?(d=!1,h=hJ(c,!0)):g?(d=!1,h=hG(c,!0)):h=[]:hQ(c)||hv(c)?(h=a,hv(a)?h=hF(a,hK(a)):(!lF(a)||lJ(a))&&(h="function"!=typeof c.constructor||hg(c)?{}
10:hd(hu(c)))):d=!1}d&&(o.set(c,h),s(h,c,r,n,o),o.delete(c)),ho(e,i,h)},h1=function(e){return e},h2=function(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)},h5=Math.max,h3=hs?function(e,t){return hs(e,"toString",{configurable:!0,enumerable:!1,value:function(){return t},writable:!0})}:h1,h4=Date.now,h8=(x=0,O=0,function(){var e=h4(),t=16-(e-O);if(O=e,t>0){if(++x>=800)return arguments[0]}else x=0;return h3.apply(void 0,arguments)}),h6=function(e,t,i){if(!lF(i))return!1;var r=typeof t;return("number"==r?!!(hI(i)&&hM(t,i.length)):"string"==r&&t in i)&&lT(i[t],e)},h7=function e(t,i,r,s,n){t!==i&&hX(i,function(o,a){if(n||(n=new hr),lF(o))h0(t,i,a,r,e,s,n);else{var c=s?s(hL(t,a),o,a+"",t,i,n):void 0;void 0===c&&(c=o),ho(t,a,c)}},hK)},h9=(P=function(e,t,i){h7(e,t,i)},r=function(e,t){var i=-1,r=t.length,s=r>1?t[r-1]:void 0,n=r>2?t[2]:void 0;for(s=P.length>3&&"function"==typeof s?(r--,s):void 0,n&&h6(t[0],t[1],n)&&(s=r<3?void 0:s,r=1),e=Object(e);++i<r;){var o=t[i];o&&P(e,o,i,s)}return e},h8((n=h5(void 0===(n=s)?r.length-1:n,0),function(){for(var e=arguments,t=-1,i=h5(e.length-n,0),s=Array(i);++t<i;)s[t]=e[n+t];t=-1;for(var o=Array(n+1);++t<n;)o[t]=e[t];return o[n]=h1(s),h2(r,this,o)}),r+"")),de=Object.defineProperty,dt=Object.defineProperties,di=Object.getOwnPropertyDescriptors,dr=Object.getOwnPropertySymbols,ds=Object.prototype.hasOwnProperty,dn=Object.prototype.propertyIsEnumerable,da=(e,t,i)=>t in e?de(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,dc=(e,t)=>{for(var i in t||(t={}))ds.call(t,i)&&da(e,i,t[i]);if(dr)for(var i of dr(t))dn.call(t,i)&&da(e,i,t[i]);return e},dl=(e,t)=>dt(e,di(t));function dh(e,t,i){var r;let s=t7(e);return(null==(r=t.rpcMap)?void 0:r[s.reference])||`${lP}?chainId=${s.namespace}:${s.reference}&projectId=${i}`}function dd(e){return e.includes(":")?e.split(":")[1]:e}function du(e){return e.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function dp(e={},t={}){return h9(dg(e),dg(t))}function dg(e){var t,i,r,s;let n={};if(!sX(e))return n;for(let[o,a]of Object.entries(e)){let e=sW(o)?[o]:a.chains,c=a.methods||[],l=a.events||[],h=a.rpcMap||{},d=sK(o);n[d]=dl(dc(dc({},n[d]),a),{chains:iE(e,null==(t=n[d])?void 0:t.chains),methods:iE(c,null==(i=n[d])?void 0:i.methods),events:iE(l,null==(r=n[d])?void 0:r.events),rpcMap:dc(dc({},h),null==(s=n[d])?void 0:s.rpcMap)})}return n}function df(e){return e.includes(":")?e.split(":")[2]:e}function dm(e){let t={};for(let[i,r]of Object.entries(e)){let e=r.methods||[],s=r.events||[],n=r.accounts||[],o=sW(i)?[i]:r.chains?r.chains:du(r.accounts);t[i]={chains:o,methods:e,events:s,accounts:n}}return t}function dy(e){return"number"==typeof e?e:e.includes("0x")?parseInt(e,16):isNaN(Number(e=e.includes(":")?e.split(":")[1]:e))?e:Number(e)}let db={},dw=e=>db[e],dv=(e,t)=>{db[e]=t};var dE=Object.defineProperty,d_=(e,t,i)=>t in e?dE(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,dI=(e,t,i)=>d_(e,"symbol"!=typeof t?t+"":t,i);class dx{constructor(e){dI(this,"name","polkadot"),dI(this,"client"),dI(this,"httpProviders"),dI(this,"events"),dI(this,"namespace"),dI(this,"chainId"),this.namespace=e.namespace,this.events=dw("events"),this.client=dw("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;let e=this.namespace.chains[0];if(!e)throw 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(lR,`${this.name}:${e}`)}getAccounts(){let e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var i;let r=dd(t);e[r]=this.createHttpProvider(r,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){let i=t||dh(e,this.namespace,this.client.core.projectId);if(!i)throw Error(`No RPC url provided for chainId: ${e}`);return new ot.JsonRpcProvider(new lI.default(i,dw("disableProviderPing")))}}var dO=Object.defineProperty,dP=Object.defineProperties,dS=Object.getOwnPropertyDescriptors,dC=Object.getOwnPropertySymbols,dR=Object.prototype.hasOwnProperty,dA=Object.prototype.propertyIsEnumerable,dT=(e,t,i)=>t in e?dO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,dN=(e,t)=>{for(var i in t||(t={}))dR.call(t,i)&&dT(e,i,t[i]);if(dC)for(var i of dC(t))dA.call(t,i)&&dT(e,i,t[i]);return e},dk=(e,t)=>dP(e,dS(t)),dL=(e,t,i)=>dT(e,"symbol"!=typeof t?t+"":t,i);class d${constructor(e){dL(this,"name","eip155"),dL(this,"client"),dL(this,"chainId"),dL(this,"namespace"),dL(this,"httpProviders"),dL(this,"events"),this.namespace=e.namespace,this.events=dw("events"),this.client=dw("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(lR,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){let i=t||dh(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw Error(`No RPC url provided for chainId: ${e}`);return new ot.JsonRpcProvider(new lI.HttpConnection(i,dw("disableProviderPing")))}setHttpProvider(e,t){let i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var i;let r=parseInt(dd(t));e[r]=this.createHttpProvider(r,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){let e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,i;let r=e.request.params?null==(t=e.request.params[0])?void 0:t.chainId:"0x0",s=parseInt(r=r.startsWith("0x")?r:`0x${r}`,16);if(this.isChainApproved(s))this.setDefaultChain(`${s}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:r}]},chainId:null==(i=this.namespace.chains)?void 0:i[0]}),this.setDefaultChain(`${s}`);else throw Error(`Failed to switch to chain 'eip155:${s}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,i,r;let s=null==(i=null==(t=e.request)?void 0:t.params)?void 0:i[0];if(!s)throw Error("Missing address parameter in `wallet_getCapabilities` request");let n=this.client.session.get(e.topic),o=(null==(r=n?.sessionProperties)?void 0:r.capabilities)||{};if(null!=o&&o[s])return o?.[s];let a=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:dk(dN({},n.sessionProperties||{}),{capabilities:dk(dN({},o||{}),{[s]:a})})})}catch(e){console.warn("Failed to update session with capabilities",e)}return a}
10async getCallStatus(e){var t,i;let r=this.client.session.get(e.topic),s=null==(t=r.sessionProperties)?void 0:t.bundler_name;if(s){let t=this.getBundlerUrl(e.chainId,s);try{return await this.getUserOperationReceipt(t,e)}catch(e){console.warn("Failed to fetch call status from bundler",e,t)}}let n=null==(i=r.sessionProperties)?void 0:i.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 Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var i;let r=new URL(e),s=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,oi.formatJsonRpcRequest)("eth_getUserOperationReceipt",[null==(i=t.request.params)?void 0:i[0]]))});if(!s.ok)throw Error(`Failed to fetch user operation receipt - ${s.status}`);return await s.json()}getBundlerUrl(e,t){return`${lC}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}var dj=Object.defineProperty,dD=(e,t,i)=>t in e?dj(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,dM=(e,t,i)=>dD(e,"symbol"!=typeof t?t+"":t,i);class dU{constructor(e){dM(this,"name","solana"),dM(this,"client"),dM(this,"httpProviders"),dM(this,"events"),dM(this,"namespace"),dM(this,"chainId"),this.namespace=e.namespace,this.events=dw("events"),this.client=dw("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(lR,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var i;let r=dd(t);e[r]=this.createHttpProvider(r,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){let i=t||dh(e,this.namespace,this.client.core.projectId);if(!i)throw Error(`No RPC url provided for chainId: ${e}`);return new ot.JsonRpcProvider(new lI.default(i,dw("disableProviderPing")))}}var dq=Object.defineProperty,dB=(e,t,i)=>t in e?dq(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,dz=(e,t,i)=>dB(e,"symbol"!=typeof t?t+"":t,i);class dH{constructor(e){dz(this,"name","cosmos"),dz(this,"client"),dz(this,"httpProviders"),dz(this,"events"),dz(this,"namespace"),dz(this,"chainId"),this.namespace=e.namespace,this.events=dw("events"),this.client=dw("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;let e=this.namespace.chains[0];if(!e)throw 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(lR,`${this.name}:${this.chainId}`)}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var i;let r=dd(t);e[r]=this.createHttpProvider(r,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){let i=t||dh(e,this.namespace,this.client.core.projectId);if(!i)throw Error(`No RPC url provided for chainId: ${e}`);return new ot.JsonRpcProvider(new lI.default(i,dw("disableProviderPing")))}}var dV=Object.defineProperty,dW=(e,t,i)=>t in e?dV(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,dK=(e,t,i)=>dW(e,"symbol"!=typeof t?t+"":t,i);class dF{constructor(e){dK(this,"name","algorand"),dK(this,"client"),dK(this,"httpProviders"),dK(this,"events"),dK(this,"namespace"),dK(this,"chainId"),this.namespace=e.namespace,this.events=dw("events"),this.client=dw("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]){let i=t||dh(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(lR,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){let i=t||dh(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new ot.JsonRpcProvider(new lI.default(i,dw("disableProviderPing")))}}var dJ=Object.defineProperty,dG=(e,t,i)=>t in e?dJ(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,dY=(e,t,i)=>dG(e,"symbol"!=typeof t?t+"":t,i);class dZ{constructor(e){dY(this,"name","cip34"),dY(this,"client"),dY(this,"httpProviders"),dY(this,"events"),dY(this,"namespace"),dY(this,"chainId"),this.namespace=e.namespace,this.events=dw("events"),this.client=dw("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;let e=this.namespace.chains[0];if(!e)throw 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(lR,`${this.name}:${this.chainId}`)}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{let i=this.getCardanoRPCUrl(t),r=dd(t);e[r]=this.createHttpProvider(r,i)}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){let t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){let i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){let i=t||this.getCardanoRPCUrl(e);if(!i)throw Error(`No RPC url provided for chainId: ${e}`);return new ot.JsonRpcProvider(new lI.default(i,dw("disableProviderPing")))}}var dQ=Object.defineProperty,dX=(e,t,i)=>t in e?dQ(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,d0=(e,t,i)=>dX(e,"symbol"!=typeof t?t+"":t,i);class d1{constructor(e){d0(this,"name","elrond"),d0(this,"client"),d0(this,"httpProviders"),d0(this,"events"),d0(this,"namespace"),d0(this,"chainId"),this.namespace=e.namespace,this.events=dw("events"),this.client=dw("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(lR,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var i;let r=dd(t);e[r]=this.createHttpProvider(r,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){let i=t||dh(e,this.namespace,this.client.core.projectId);if(!i)throw Error(`No RPC url provided for chainId: ${e}`);return new ot.JsonRpcProvider(new lI.default(i,dw("disableProviderPing")))}}var d2=Object.defineProperty,d5=(e,t,i)=>t in e?d2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,d3=(e,t,i)=>d5(e,"symbol"!=typeof t?t+"":t,i);class d4{constructor(e){d3(this,"name","multiversx"),d3(this,"client"),d3(this,"httpProviders"),d3(this,"events"),d3(this,"namespace"),d3(this,"chainId"),this.namespace=e.namespace,this.events=dw("events"),this.client=dw("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(lR,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var i;let r=dd(t);e[r]=this.createHttpProvider(r,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){let i=t||dh(e,this.namespace,this.client.core.projectId);if(!i)throw Error(`No RPC url provided for chainId: ${e}`);return new ot.JsonRpcProvider(new lI.default(i,dw("disableProviderPing")))}}var d8=Object.defineProperty,d6=(e,t,i)=>t in e?d8(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,d7=(e,t,i)=>d6(e,"symbol"!=typeof t?t+"":t,i);class d9{constructor(e){d7(this,"name","near"),d7(this,"client"),d7(this,"httpProviders"),d7(this,"events"),d7(this,"namespace"),d7(this,"chainId"),this.namespace=e.namespace,this.events=dw("events"),this.client=dw("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;let e=this.namespace.chains[0];if(!e)throw 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]){let i=t||dh(`${this.name}:${e}`,this.namespace);if(!i)throw Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(lR,`${this.name}:${this.chainId}`)}getAccounts(){let e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){let i=t||dh(e,this.namespace);return typeof i>"u"?void 0:new ot.JsonRpcProvider(new lI.default(i,dw("disableProviderPing")))}}var ue=Object.defineProperty,ut=(e,t,i)=>t in e?ue(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,ui=(e,t,i)=>ut(e,"symbol"!=typeof t?t+"":t,i);class ur{constructor(e){ui(this,"name","tezos"),ui(this,"client"),ui(this,"httpProviders"),ui(this,"events"),ui(this,"namespace"),ui(this,"chainId"),this.namespace=e.namespace,this.events=dw("events"),this.client=dw("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;let e=this.namespace.chains[0];if(!e)throw 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]){let i=t||dh(`${this.name}:${e}`,this.namespace);if(!i)throw Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(lR,`${this.name}:${this.chainId}`)}getAccounts(){let e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){let e={};return this.namespace.chains.forEach(t=>{e[t]=this.createHttpProvider(t)}),e}getHttpProvider(){let e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){let i=t||dh(e,this.namespace);return typeof i>"u"?void 0:new ot.JsonRpcProvider(new lI.default(i))}}var us=Object.defineProperty,un=(e,t,i)=>t in e?us(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,uo=(e,t,i)=>un(e,"symbol"!=typeof t?t+"":t,i);class ua{constructor(e){uo(this,"name",lS),uo(this,"client"),uo(this,"httpProviders"),uo(this,"events"),uo(this,"namespace"),uo(this,"chainId"),this.namespace=e.namespace,this.events=dw("events"),this.client=dw("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||
10[]).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(lR,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;let e=this.namespace.chains[0];if(!e)throw Error("ChainId not found");return e.split(":")[1]}getAccounts(){let e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){var e,t;let i={};return null==(t=null==(e=this.namespace)?void 0:e.accounts)||t.forEach(e=>{let t=t7(e);i[`${t.namespace}:${t.reference}`]=this.createHttpProvider(e)}),i}getHttpProvider(e){let t=this.httpProviders[e];if(typeof t>"u")throw Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){let i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){let i=t||dh(e,this.namespace,this.client.core.projectId);if(!i)throw Error(`No RPC url provided for chainId: ${e}`);return new ot.JsonRpcProvider(new lI.default(i,dw("disableProviderPing")))}}var uc=Object.defineProperty,ul=Object.defineProperties,uh=Object.getOwnPropertyDescriptors,ud=Object.getOwnPropertySymbols,uu=Object.prototype.hasOwnProperty,up=Object.prototype.propertyIsEnumerable,ug=(e,t,i)=>t in e?uc(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,uf=(e,t)=>{for(var i in t||(t={}))uu.call(t,i)&&ug(e,i,t[i]);if(ud)for(var i of ud(t))up.call(t,i)&&ug(e,i,t[i]);return e},um=(e,t)=>ul(e,uh(t)),uy=(e,t,i)=>ug(e,"symbol"!=typeof t?t+"":t,i);class ub{constructor(e){uy(this,"client"),uy(this,"namespaces"),uy(this,"optionalNamespaces"),uy(this,"sessionProperties"),uy(this,"events",new(C())),uy(this,"rpcProviders",{}),uy(this,"session"),uy(this,"providerOpts"),uy(this,"logger"),uy(this,"uri"),uy(this,"disableProviderPing",!1),this.providerOpts=e,this.logger="u">typeof e?.logger&&"string"!=typeof e?.logger?e.logger:nI()(nq({level:e?.logger||lx})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){let t=new ub(e);return await t.initialize(),t}async request(e,t,i){let[r,s]=this.validateChain(t);if(!this.session)throw Error("Please call connect() before request()");return await this.getProvider(r).request({request:uf({},e),chainId:`${r}:${s}`,topic:this.session.topic,expiry:i})}sendAsync(e,t,i,r){let s=new Date().getTime();this.request(e,i,r).then(e=>t(null,(0,oi.formatJsonRpcResult)(s,e))).catch(e=>t(e,void 0))}async enable(){if(!this.client)throw Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw Error("Please call connect() before enable()");await this.client.disconnect({topic:null==(e=this.session)?void 0:e.topic,reason:sZ("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw 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 Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();let{uri:i,response:r}=await this.client.authenticate(e,t);i&&(this.uri=i,this.events.emit("display_uri",i));let s=await r();if(this.session=s.session,this.session){let e=dm(this.session.namespaces);this.namespaces=dp(this.namespaces,e),this.persist("namespaces",this.namespaces),this.onConnect()}return s}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){let{uri:t,approval:i}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});t&&(this.uri=t,this.events.emit("display_uri",t));let r=await i();this.session=r;let s=dm(r.namespaces);return this.namespaces=dp(this.namespaces,s),this.persist("namespaces",this.namespaces),this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;let[i,r]=this.validateChain(e),s=this.getProvider(i);s.name===lS?s.setDefaultChain(`${i}:${r}`,t):s.setDefaultChain(r,t)}catch(e){if(!/Please call connect/.test(e.message))throw e}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");let t=this.client.pairing.getAll();if(sQ(t)){for(let i of t)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){let e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await l_.init({core:this.providerOpts.core,logger:this.providerOpts.logger||lx,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.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw Error("Sign Client not initialized");if(!this.session)throw Error("Session not initialized. Please call connect() before enable()");let e=[...new Set(Object.keys(this.session.namespaces).map(e=>sK(e)))];dv("client",this.client),dv("events",this.events),dv("disableProviderPing",this.disableProviderPing),e.forEach(e
10=>{if(!this.session)return;let t=function(e,t){let i=Object.keys(t.namespaces).filter(t=>t.includes(e));if(!i.length)return[];let r=[];return i.forEach(e=>{let i=t.namespaces[e].accounts;r.push(...i)}),r}(e,this.session),i=du(t),r=um(uf({},dp(this.namespaces,this.optionalNamespaces)[e]),{accounts:t,chains:i});switch(e){case"eip155":this.rpcProviders[e]=new d$({namespace:r});break;case"algorand":this.rpcProviders[e]=new dF({namespace:r});break;case"solana":this.rpcProviders[e]=new dU({namespace:r});break;case"cosmos":this.rpcProviders[e]=new dH({namespace:r});break;case"polkadot":this.rpcProviders[e]=new dx({namespace:r});break;case"cip34":this.rpcProviders[e]=new dZ({namespace:r});break;case"elrond":this.rpcProviders[e]=new d1({namespace:r});break;case"multiversx":this.rpcProviders[e]=new d4({namespace:r});break;case"near":this.rpcProviders[e]=new d9({namespace:r});break;case"tezos":this.rpcProviders[e]=new ur({namespace:r});break;default:this.rpcProviders[lS]?this.rpcProviders[lS].updateNamespace(r):this.rpcProviders[lS]=new ua({namespace:r})}})}registerEventListeners(){if(typeof this.client>"u")throw Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{let{params:t}=e,{event:i}=t;if("accountsChanged"===i.name){let e=i.data;e&&sQ(e)&&this.events.emit("accountsChanged",e.map(df))}else if("chainChanged"===i.name){let e=t.chainId,i=t.event.data,r=sK(e),s=dy(e)!==dy(i)?`${r}:${dy(i)}`:e;this.onChainChanged(s)}else this.events.emit(i.name,i.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var i;let{namespaces:r}=t,s=null==(i=this.client)?void 0:i.session.get(e);this.session=um(uf({},s),{namespaces:r}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",um(uf({},sZ("USER_DISCONNECTED")),{data:e.topic}))}),this.on(lR,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[lS]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace(null==(t=this.session)?void 0:t.namespaces[e])})}setNamespaces(e){let{namespaces:t,optionalNamespaces:i,sessionProperties:r}=e;t&&Object.keys(t).length&&(this.namespaces=t),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=r,this.persist("namespaces",t),this.persist("optionalNamespaces",i)}validateChain(e){let[t,i]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,i];if(t&&!Object.keys(this.namespaces||{}).map(e=>sK(e)).includes(t))throw Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&i)return[t,i];let r=sK(Object.keys(this.namespaces)[0]),s=this.rpcProviders[r].getDefaultChain();return[r,s]}async requestAccounts(){let[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){if(!this.namespaces)return;let[i,r]=this.validateChain(e);r&&(t||this.getProvider(i).setDefaultChain(r),this.namespaces[i]?this.namespaces[i].defaultChain=r:this.namespaces[`${i}:${r}`]?this.namespaces[`${i}:${r}`].defaultChain=r:this.namespaces[`${i}:${r}`]={defaultChain:r},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",r))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${lO}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${lO}/${e}`)}}let uw=["eth_sendTransaction","personal_sign"],uv=["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_sendCalls","wallet_getCapabilities","wallet_getCallsStatus","wallet_showCallsStatus"],uE=["chainChanged","accountsChanged"],u_=["chainChanged","accountsChanged","message","disconnect","connect"];var uI=Object.defineProperty,ux=Object.defineProperties,uO=Object.getOwnPropertyDescriptors,uP=Object.getOwnPropertySymbols,uS=Object.prototype.hasOwnProperty,uC=Object.prototype.propertyIsEnumerable,uR=(e,t,i)=>t in e?uI(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,uA=(e,t)=>
10{for(var i in t||(t={}))uS.call(t,i)&&uR(e,i,t[i]);if(uP)for(var i of uP(t))uC.call(t,i)&&uR(e,i,t[i]);return e},uT=(e,t)=>ux(e,uO(t)),uN=(e,t,i)=>uR(e,"symbol"!=typeof t?t+"":t,i);function uk(e){return Number(e[0].split(":")[1])}function uL(e){return`0x${e.toString(16)}`}class u${constructor(){uN(this,"events",new S.EventEmitter),uN(this,"namespace","eip155"),uN(this,"accounts",[]),uN(this,"signer"),uN(this,"chainId",1),uN(this,"modal"),uN(this,"rpc"),uN(this,"STORAGE_KEY","wc@2:ethereum_provider:"),uN(this,"on",(e,t)=>(this.events.on(e,t),this)),uN(this,"once",(e,t)=>(this.events.once(e,t),this)),uN(this,"removeListener",(e,t)=>(this.events.removeListener(e,t),this)),uN(this,"off",(e,t)=>(this.events.off(e,t),this)),uN(this,"parseAccount",e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e),this.signer={},this.rpc={}}static async init(e){let t=new u$;return await t.initialize(e),t}async request(e,t){return await this.signer.request(e,this.formatChainId(this.chainId),t)}sendAsync(e,t,i){this.signer.sendAsync(e,t,this.formatChainId(this.chainId),i)}get connected(){return!!this.signer.client&&this.signer.client.core.relayer.connected}get connecting(){return!!this.signer.client&&this.signer.client.core.relayer.connecting}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){if(!this.signer.client)throw Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);let{required:t,optional:i}=function(e){let{chains:t,optionalChains:i,methods:r,optionalMethods:s,events:n,optionalEvents:o,rpcMap:a}=e;if(!sQ(t))throw Error("Invalid chains");let c={chains:t,methods:r||uw,events:n||uE,rpcMap:uA({},t.length?{[uk(t)]:a[uk(t)]}:{})},l=n?.filter(e=>!uE.includes(e)),h=r?.filter(e=>!uw.includes(e));if(!i&&!o&&!s&&!(null!=l&&l.length)&&!(null!=h&&h.length))return{required:t.length?c:void 0};let d={chains:[...new Set(l?.length&&h?.length||!i?c.chains.concat(i||[]):i)],methods:[...new Set(c.methods.concat(null!=s&&s.length?s:uv))],events:[...new Set(c.events.concat(null!=o&&o.length?o:u_))],rpcMap:a};return{required:t.length?c:void 0,optional:i.length?d:void 0}}(this.rpc);try{let r=await new Promise(async(r,s)=>{var n;this.rpc.showQrModal&&(null==(n=this.modal)||n.subscribeModal(e=>{e.open||this.signer.session||(this.signer.abortPairingAttempt(),s(Error("Connection request reset. Please try again.")))})),await this.signer.connect(uT(uA({namespaces:uA({},t&&{[this.namespace]:t})},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:e?.pairingTopic})).then(e=>{r(e)}).catch(e=>{s(Error(e.message))})});if(!r)return;let s=t9(r.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:s),this.setAccounts(s),this.events.emit("connect",{chainId:uL(this.chainId)})}catch(e){throw this.signer.logger.error(e),e}finally{this.modal&&this.modal.closeModal()}}async authenticate(e,t){if(!this.signer.client)throw Error("Provider not initialized. Call init() first");this.loadConnectOpts({chains:e?.chains});try{let i=await new Promise(async(i,r)=>{var s;this.rpc.showQrModal&&(null==(s=this.modal)||s.subscribeModal(e=>{e.open||this.signer.session||(this.signer.abortPairingAttempt(),r(Error("Connection request reset. Please try again.")))})),await this.signer.authenticate(uT(uA({},e),{chains:this.rpc.chains}),t).then(e=>{i(e)}).catch(e=>{r(Error(e.message))})}),r=i.session;if(r){let e=t9(r.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:e),this.setAccounts(e),this.events.emit("connect",{chainId:uL(this.chainId)})}return i}catch(e){throw this.signer.logger.error(e),e}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{let{params:t}=e,{event:i}=t;"accountsChanged"===i.name?(this.accounts=this.parseAccounts(i.data),this.events.emit("accountsChanged",this.accounts)):"chainChanged"===i.name?this.setChainId(this.formatChainId(i.data)):this.events.emit(i.name,i.data),this.events.emit("session_event",e)}),this.signer.on("chainChanged",e=>{let t=parseInt(e);this.chainId=t,this.events.emit("chainChanged",uL(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",uT(uA({},sZ("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var t,i;this.rpc.showQrModal&&(null==(t=this.modal)||t.closeModal(),null==(i=this.modal)||i.openModal({uri:e})),this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return"string"==typeof e&&e.startsWith(`${this.namespace}:`)}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){let t=e.filter(e=>this.isCompatibleChainId(e)).map(e=>this.parseChainId(e));t.length&&(this.chainId=t[0],this.events.emit("chainChanged",uL(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){let t=this.parseChainId(e);this.chainId=t,this.switchEthereumChain(t)}}parseAccountId(e){let[t,i,r]=e.split(":");return{chainId:`${t}:${i}`,address:r}}setAccounts(e){this.accounts=e.filter(e=>this.parseChainId(this.parseAccountId(e).chainId)===this.chainId).map(e=>this.parseAccountId(e).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var t,i;let r=null!=(t=e?.chains)?t:[],s=null!=(i=e?.optionalChains)?i:[],n=r.concat(s);if(!n.length)throw Error("No chains specified in either `chains` or `optionalChains`");let o=r.length?e?.methods||uw:[],a=r.length?e?.events||uE:[],c=e?.optionalMethods||[],l=e?.optionalEvents||[],h=e?.rpcMap||this.buildRpcMap(n,e.projectId),d=e?.qrModalOptions||void 0;return{chains:r?.map(e=>this.formatChainId(e)),optionalChains:s.map(e=>this.formatChainId(e)),methods:o,events:a,optionalMethods:c,optionalEvents:l,rpcMap:h,showQrModal:!!(null!=e&&e.showQrModal),qrModalOptions:d,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,t){let i={};
10return e.forEach(e=>{i[e]=this.getRpcUrl(e,t)}),i}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?uk(this.rpc.chains):uk(this.rpc.optionalChains),this.signer=await ub.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storage:e.storage,storageOptions:e.storageOptions,customStoragePrefix:e.customStoragePrefix,telemetryEnabled:e.telemetryEnabled,logger:e.logger}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let e;try{let{WalletConnectModal:t}=await Promise.all([i.e(601),i.e(1216)]).then(i.bind(i,44978));e=t}catch{throw Error("To use QR modal, please install @walletconnect/modal package")}if(e)try{this.modal=new e(uA({projectId:this.rpc.projectId},this.rpc.qrModalOptions))}catch(e){throw this.signer.logger.error(e),Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;let{chains:t,optionalChains:i,rpcMap:r}=e;t&&sQ(t)&&(this.rpc.chains=t.map(e=>this.formatChainId(e)),t.forEach(e=>{this.rpc.rpcMap[e]=r?.[e]||this.getRpcUrl(e)})),i&&sQ(i)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=i?.map(e=>this.formatChainId(e)),i.forEach(e=>{this.rpc.rpcMap[e]=r?.[e]||this.getRpcUrl(e)}))}getRpcUrl(e,t){var i;return(null==(i=this.rpc.rpcMap)?void 0:i[e])||`https://rpc.walletconnect.org/v1/?chainId=eip155:${e}&projectId=${t||this.rpc.projectId}`}async loadPersistedSession(){if(this.session)try{let e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),t=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:t?.accounts),this.setAccounts(t?.accounts)}catch(e){this.signer.logger.error("Failed to load persisted session, clearing state..."),this.signer.logger.error(e),await this.disconnect().catch(e=>this.signer.logger.warn(e))}}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return"string"==typeof e||e instanceof String?[this.parseAccount(e)]:e.map(e=>this.parseAccount(e))}}let uj=u$},5071:function(e,t,i){"use strict";i.r(t),i.d(t,{HttpConnection:function(){return b},default:function(){return b}});var r=i(55445),s=i(5108),n=i.n(s),o=i(80577),a=i(5276),c=Object.defineProperty,l=Object.defineProperties,h=Object.getOwnPropertyDescriptors,d=Object.getOwnPropertySymbols,u=Object.prototype.hasOwnProperty,p=Object.prototype.propertyIsEnumerable,g=(e,t,i)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,f=(e,t)=>{for(var i in t||(t={}))u.call(t,i)&&g(e,i,t[i]);if(d)for(var i of d(t))p.call(t,i)&&g(e,i,t[i]);return e},m=(e,t)=>l(e,h(t));let y={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"};class b{constructor(e,t=!1){if(this.url=e,this.disableProviderPing=t,this.events=new r.EventEmitter,this.isAvailable=!1,this.registering=!1,!(0,a.isHttpUrl)(e))throw Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=t}get connected(){return this.isAvailable}get connecting(){return this.registering}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 open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{let t=(0,o.u)(e),i=await (await n()(this.url,m(f({},y),{body:t}))).json();this.onPayload({data:i})}catch(t){this.onError(e.id,t)}}async register(e=this.url){if(!(0,a.isHttpUrl)(e))throw Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){let e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise((e,t)=>{this.events.once("register_error",e=>{this.resetMaxListeners(),t(e)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return t(Error("HTTP connection is missing or invalid"));e()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){let t=(0,o.u)({id:1,jsonrpc:"2.0",method:"test",params:[]});
10await n()(e,m(f({},y),{body:t}))}this.onOpen()}catch(t){let e=this.parseError(t);throw this.events.emit("register_error",e),this.onClose(),e}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;let t="string"==typeof e.data?(0,o.D)(e.data):e.data;this.events.emit("payload",t)}onError(e,t){let i=this.parseError(t),r=i.message||i.toString(),s=(0,a.formatJsonRpcError)(e,r);this.events.emit("payload",s)}parseError(e,t=this.url){return(0,a.parseConnectionError)(e,t,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}}},5108:function(e,t,i){var r="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==i.g&&i.g,s=function(){function e(){this.fetch=!1,this.DOMException=r.DOMException}return e.prototype=r,new e}();(function(e){var t=void 0!==s&&s||"undefined"!=typeof self&&self||void 0!==i.g&&i.g||{},r={searchParams:"URLSearchParams"in t,iterable:"Symbol"in t&&"iterator"in Symbol,blob:"FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(e){return!1}}(),formData:"FormData"in t,arrayBuffer:"ArrayBuffer"in t};if(r.arrayBuffer)var n=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],o=ArrayBuffer.isView||function(e){return e&&n.indexOf(Object.prototype.toString.call(e))>-1};function a(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function c(e){return"string"!=typeof e&&(e=String(e)),e}function l(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return r.iterable&&(t[Symbol.iterator]=function(){return t}),t}function h(e){this.map={},e instanceof h?e.forEach(function(e,t){this.append(t,e)},this):Array.isArray(e)?e.forEach(function(e){if(2!=e.length)throw TypeError("Headers constructor: expected name/value pair to be length 2, found"+e.length);this.append(e[0],e[1])},this):e&&Object.getOwnPropertyNames(e).forEach(function(t){this.append(t,e[t])},this)}function d(e){if(!e._noBody){if(e.bodyUsed)return Promise.reject(TypeError("Already read"));e.bodyUsed=!0}}function u(e){return new Promise(function(t,i){e.onload=function(){t(e.result)},e.onerror=function(){i(e.error)}})}function p(e){var t=new FileReader,i=u(t);return t.readAsArrayBuffer(e),i}function g(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function f(){return this.bodyUsed=!1,this._initBody=function(e){if(this.bodyUsed=this.bodyUsed,this._bodyInit=e,e){if("string"==typeof e)this._bodyText=e;else if(r.blob&&Blob.prototype.isPrototypeOf(e))this._bodyBlob=e;else if(r.formData&&FormData.prototype.isPrototypeOf(e))this._bodyFormData=e;else if(r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e))this._bodyText=e.toString();else{var t;r.arrayBuffer&&r.blob&&(t=e)&&DataView.prototype.isPrototypeOf(t)?(this._bodyArrayBuffer=g(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):r.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(e)||o(e))?this._bodyArrayBuffer=g(e):this._bodyText=e=Object.prototype.toString.call(e)}}else this._noBody=!0,this._bodyText="";!this.headers.get("content-type")&&("string"==typeof e?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r.searchParams&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},r.blob&&(this.blob=function(){var e=d(this);if(e)return e;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(!this._bodyFormData)return Promise.resolve(new Blob([this._bodyText]));throw Error("could not read FormData body as blob")}),this.arrayBuffer=function(){if(this._bodyArrayBuffer)return d(this)||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer));if(r.blob)return this.blob().then(p);throw Error("could not read as ArrayBuffer")},this.text=function(){var e,t,i,r,s,n=d(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,i=u(t=new FileReader),s=(r=/charset=([A-Za-z0-9_-]+)/.exec(e.type))?r[1]:"utf-8",t.readAsText(e,s),i;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),i=Array(t.length),r=0;r<t.length;r++)i[r]=String.fromCharCode(t[r]);return i.join("")}(this._bodyArrayBuffer));if(!this._bodyFormData)return Promise.resolve(this._bodyText);throw Error("could not read FormData body as text")},r.formData&&(this.formData=function(){return this.text().then(b)}),this.json=function(){return this.text().then(JSON.parse)},this}h.prototype.append=function(e,t){e=a(e),t=c(t);var i=this.map[e];this.map[e]=i?i+", "+t:t},h.prototype.delete=function(e){delete this.map[a(e)]},h.prototype.get=function(e){return e=a(e),this.has(e)?this.map[e]:null},h.prototype.has=function(e){return this.map.hasOwnProperty(a(e))},h.prototype.set=function(e,t){this.map[a(e)]=c(t)},h.prototype.forEach=function(e,t){for(var i in this.map)this.map.hasOwnProperty(i)&&e.call(t,this.map[i],i,this)},h.prototype.keys=function(){var e=[];return this.forEach(function(t,i){e.push(i)}),l(e)},h.prototype.values=function(){var e=[];return this.forEach(function(t){e.push(t)}),l(e)},h.prototype.entries=function(){var e=[];return this.forEach(function(t,i){e.push([i,t])}),l(e)},r.iterable&&(h.prototype[Symbol.iterator]=h.prototype.entries);var m=["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"];function y(e,i){if(!(this instanceof y))throw TypeError('Please use the "new" operator, this DOM object c
10onstructor cannot be called as a function.');var r,s,n=(i=i||{}).body;if(e instanceof y){if(e.bodyUsed)throw TypeError("Already read");this.url=e.url,this.credentials=e.credentials,i.headers||(this.headers=new h(e.headers)),this.method=e.method,this.mode=e.mode,this.signal=e.signal,n||null==e._bodyInit||(n=e._bodyInit,e.bodyUsed=!0)}else this.url=String(e);if(this.credentials=i.credentials||this.credentials||"same-origin",(i.headers||!this.headers)&&(this.headers=new h(i.headers)),this.method=(s=(r=i.method||this.method||"GET").toUpperCase(),m.indexOf(s)>-1?s:r),this.mode=i.mode||this.mode||null,this.signal=i.signal||this.signal||function(){if("AbortController"in t)return new AbortController().signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(n),("GET"===this.method||"HEAD"===this.method)&&("no-store"===i.cache||"no-cache"===i.cache)){var o=/([?&])_=[^&]*/;o.test(this.url)?this.url=this.url.replace(o,"$1_="+new Date().getTime()):this.url+=(/\?/.test(this.url)?"&":"?")+"_="+new Date().getTime()}}function b(e){var t=new FormData;return e.trim().split("&").forEach(function(e){if(e){var i=e.split("="),r=i.shift().replace(/\+/g," "),s=i.join("=").replace(/\+/g," ");t.append(decodeURIComponent(r),decodeURIComponent(s))}}),t}function w(e,t){if(!(this instanceof w))throw TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');if(t||(t={}),this.type="default",this.status=void 0===t.status?200:t.status,this.status<200||this.status>599)throw RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");this.ok=this.status>=200&&this.status<300,this.statusText=void 0===t.statusText?"":""+t.statusText,this.headers=new h(t.headers),this.url=t.url||"",this._initBody(e)}y.prototype.clone=function(){return new y(this,{body:this._bodyInit})},f.call(y.prototype),f.call(w.prototype),w.prototype.clone=function(){return new w(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new h(this.headers),url:this.url})},w.error=function(){var e=new w(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var v=[301,302,303,307,308];w.redirect=function(e,t){if(-1===v.indexOf(t))throw RangeError("Invalid status code");return new w(null,{status:t,headers:{location:e}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(e,t){this.message=e,this.name=t;var i=Error(e);this.stack=i.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function E(i,s){return new Promise(function(n,o){var l=new y(i,s);if(l.signal&&l.signal.aborted)return o(new e.DOMException("Aborted","AbortError"));var d=new XMLHttpRequest;function u(){d.abort()}if(d.onload=function(){var e,t,i={statusText:d.statusText,headers:(e=d.getAllResponseHeaders()||"",t=new h,e.replace(/\r?\n[\t ]+/g," ").split("\r").map(function(e){return 0===e.indexOf("\n")?e.substr(1,e.length):e}).forEach(function(e){var i=e.split(":"),r=i.shift().trim();if(r){var s=i.join(":").trim();try{t.append(r,s)}catch(e){console.warn("Response "+e.message)}}}),t)};0===l.url.indexOf("file://")&&(d.status<200||d.status>599)?i.status=200:i.status=d.status,i.url="responseURL"in d?d.responseURL:i.headers.get("X-Request-URL");var r="response"in d?d.response:d.responseText;setTimeout(function(){n(new w(r,i))},0)},d.onerror=function(){setTimeout(function(){o(TypeError("Network request failed"))},0)},d.ontimeout=function(){setTimeout(function(){o(TypeError("Network request timed out"))},0)},d.onabort=function(){setTimeout(function(){o(new e.DOMException("Aborted","AbortError"))},0)},d.open(l.method,function(e){try{return""===e&&t.location.href?t.location.href:e}catch(t){return e}}(l.url),!0),"include"===l.credentials?d.withCredentials=!0:"omit"===l.credentials&&(d.withCredentials=!1),"responseType"in d&&(r.blob?d.responseType="blob":r.arrayBuffer&&(d.responseType="arraybuffer")),s&&"object"==typeof s.headers&&!(s.headers instanceof h||t.Headers&&s.headers instanceof t.Headers)){var p=[];
10Object.getOwnPropertyNames(s.headers).forEach(function(e){p.push(a(e)),d.setRequestHeader(e,c(s.headers[e]))}),l.headers.forEach(function(e,t){-1===p.indexOf(t)&&d.setRequestHeader(t,e)})}else l.headers.forEach(function(e,t){d.setRequestHeader(t,e)});l.signal&&(l.signal.addEventListener("abort",u),d.onreadystatechange=function(){4===d.readyState&&l.signal.removeEventListener("abort",u)}),d.send(void 0===l._bodyInit?null:l._bodyInit)})}E.polyfill=!0,t.fetch||(t.fetch=E,t.Headers=h,t.Request=y,t.Response=w),e.Headers=h,e.Request=y,e.Response=w,e.fetch=E,Object.defineProperty(e,"__esModule",{value:!0})})({}),s.fetch.ponyfill=!0,delete s.fetch.polyfill;var n=r.fetch?r:s;(t=n.fetch).default=n.fetch,t.fetch=n.fetch,t.Headers=n.Headers,t.Request=n.Request,t.Response=n.Response,e.exports=t},38979:function(e,t,i){"use strict";i.r(t),i.d(t,{JsonRpcProvider:function(){return n},default:function(){return n}});var r=i(55445),s=i(5276);class n extends s.IJsonRpcProvider{constructor(e){super(e),this.events=new r.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}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 request(e,t){return this.requestStrict((0,s.formatJsonRpcRequest)(e.method,e.params||[],e.id||(0,s.getBigIntRpcId)().toString()),t)}async requestStrict(e,t){return new Promise(async(i,r)=>{if(!this.connection.connected)try{await this.open()}catch(e){r(e)}this.events.on(`${e.id}`,e=>{(0,s.isJsonRpcError)(e)?r(e.error):i(e.result)});try{await this.connection.send(e,t)}catch(e){r(e)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),(0,s.isJsonRpcResponse)(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&3e3===e.code&&this.events.emit("error",Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),"string"==typeof e&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}},44265:function(e,t,i){"use strict";i.d(t,{CA:function(){return s},JV:function(){return a},O4:function(){return r},dQ:function(){return n},xK:function(){return o}});let r="INTERNAL_ERROR",s="SERVER_ERROR",n=[-32700,-32600,-32601,-32602,-32603],o={PARSE_ERROR:{code:-32700,message:"Parse error"},INVALID_REQUEST:{code:-32600,message:"Invalid Request"},METHOD_NOT_FOUND:{code:-32601,message:"Method not found"},INVALID_PARAMS:{code:-32602,message:"Invalid params"},[r]:{code:-32603,message:"Internal error"},[s]:{code:-32e3,message:"Server error"}},a=s},23497:function(e,t,i){"use strict";var r=i(13303);i.o(r,"IJsonRpcProvider")&&i.d(t,{IJsonRpcProvider:function(){return r.IJsonRpcProvider}}),i.o(r,"formatJsonRpcError")&&i.d(t,{formatJsonRpcError:function(){return r.formatJsonRpcError}}),i.o(r,"formatJsonRpcRequest")&&i.d(t,{formatJsonRpcRequest:function(){return r.formatJsonRpcRequest}}),i.o(r,"formatJsonRpcResult")&&i.d(t,{formatJsonRpcResult:function(){return r.formatJsonRpcResult}}),i.o(r,"getBigIntRpcId")&&i.d(t,{getBigIntRpcId:function(){return r.getBigIntRpcId}}),i.o(r,"isHttpUrl")&&i.d(t,{isHttpUrl:function(){return r.isHttpUrl}}),i.o(r,"isJsonRpcError")&&i.d(t,{isJsonRpcError:function(){return r.isJsonRpcError}}),i.o(r,"isJsonRpcRequest")&&i.d(t,{isJsonRpcRequest:function(){return r.isJsonRpcRequest}}),i.o(r,"isJsonRpcResponse")&&i.d(t,{isJsonRpcResponse:function(){return r.isJsonRpcResponse}}),i.o(r,"isJsonRpcResult")&&i.d(t,{isJsonRpcResult:function(){return r.isJsonRpcResult}}),i.o(r,"isLocalhostUrl")&&i.d(t,{isLocalhostUrl:function(){return r.isLocalhostUrl}}),i.o(r,"isReactNative")&&i.d(t,{isReactNative:function(){return r.isReactNative}}),i.o(r,"isWsUrl")&&i.d(t,{isWsUrl:function(){return r.isWsUrl}}),i.o(r,"payloadId")&&i.d(t,{payloadId:function(){return r.payloadId}})},28418:function(e,t,i){"use strict";i.d(t,{CX:function(){return a},L2:function(){return o},by:function(){return n},i5:function(){return s}});var r=i(44265);function s(e){return r.dQ.includes(e)}function n(e){return Object.keys(r.xK).includes(e)?r.xK[e]:r.xK[r.JV]}function o(e){return Object.values(r.xK).find(t=>t.code===e)||r.xK[r.JV]}function a(e,t,i){return e.message.includes("getaddrinfo ENOTFOUND")||e.message.includes("connect ECONNREFUSED")?Error(`Unavailable ${i} RPC url at ${t}`):e}},74947:function(e,t,i){"use strict";i.d(t,{CS:function(){return o},RI:function(){return l},o0:function(){return n},sT:function(){return a},tm:function(){return c}});var r=i(28418),s=i(44265);
10function n(e=3){return Date.now()*Math.pow(10,e)+Math.floor(Math.random()*Math.pow(10,e))}function o(e=6){return BigInt(n(e))}function a(e,t,i){return{id:i||n(),jsonrpc:"2.0",method:e,params:t}}function c(e,t){return{id:e,jsonrpc:"2.0",result:t}}function l(e,t,i){var n;return{id:e,jsonrpc:"2.0",error:void 0===(n=t)?(0,r.by)(s.O4):("string"==typeof n&&(n=Object.assign(Object.assign({},(0,r.by)(s.CA)),{message:n})),void 0!==i&&(n.data=i),(0,r.i5)(n.code)&&(n=(0,r.L2)(n.code)),n)}}},5276:function(e,t,i){"use strict";i.d(t,{IJsonRpcProvider:function(){return o.x0},formatJsonRpcError:function(){return n.RI},formatJsonRpcRequest:function(){return n.sT},formatJsonRpcResult:function(){return n.tm},getBigIntRpcId:function(){return n.CS},isHttpUrl:function(){return a.jK},isJsonRpcError:function(){return c.jg},isJsonRpcRequest:function(){return c.DW},isJsonRpcResponse:function(){return c.u},isJsonRpcResult:function(){return c.k4},isLocalhostUrl:function(){return a.JF},isWsUrl:function(){return a.UZ},parseConnectionError:function(){return r.CX},payloadId:function(){return n.o0}}),i(44265);var r=i(28418),s=i(23497);i.o(s,"IJsonRpcProvider")&&i.d(t,{IJsonRpcProvider:function(){return s.IJsonRpcProvider}}),i.o(s,"formatJsonRpcError")&&i.d(t,{formatJsonRpcError:function(){return s.formatJsonRpcError}}),i.o(s,"formatJsonRpcRequest")&&i.d(t,{formatJsonRpcRequest:function(){return s.formatJsonRpcRequest}}),i.o(s,"formatJsonRpcResult")&&i.d(t,{formatJsonRpcResult:function(){return s.formatJsonRpcResult}}),i.o(s,"getBigIntRpcId")&&i.d(t,{getBigIntRpcId:function(){return s.getBigIntRpcId}}),i.o(s,"isHttpUrl")&&i.d(t,{isHttpUrl:function(){return s.isHttpUrl}}),i.o(s,"isJsonRpcError")&&i.d(t,{isJsonRpcError:function(){return s.isJsonRpcError}}),i.o(s,"isJsonRpcRequest")&&i.d(t,{isJsonRpcRequest:function(){return s.isJsonRpcRequest}}),i.o(s,"isJsonRpcResponse")&&i.d(t,{isJsonRpcResponse:function(){return s.isJsonRpcResponse}}),i.o(s,"isJsonRpcResult")&&i.d(t,{isJsonRpcResult:function(){return s.isJsonRpcResult}}),i.o(s,"isLocalhostUrl")&&i.d(t,{isLocalhostUrl:function(){return s.isLocalhostUrl}}),i.o(s,"isReactNative")&&i.d(t,{isReactNative:function(){return s.isReactNative}}),i.o(s,"isWsUrl")&&i.d(t,{isWsUrl:function(){return s.isWsUrl}}),i.o(s,"payloadId")&&i.d(t,{payloadId:function(){return s.payloadId}});var n=i(74947),o=i(75826),a=i(20276),c=i(65505)},75826:function(e,t,i){"use strict";i.d(t,{x0:function(){return n}});class r{}class s extends r{constructor(){super()}}class n extends s{constructor(e){super()}}},20276:function(e,t,i){"use strict";function r(e,t){let i=function(e){let t=e.match(RegExp(/^\w+:/,"gi"));if(t&&t.length)return t[0]}(e);return void 0!==i&&new RegExp(t).test(i)}function s(e){return r(e,"^https?:")}function n(e){return r(e,"^wss?:")}function o(e){return RegExp("wss?://localhost(:d{2,5})?").test(e)}i.d(t,{JF:function(){return o},UZ:function(){return n},jK:function(){return s}})},65505:function(e,t,i){"use strict";function r(e){return"object"==typeof e&&"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}function s(e){return r(e)&&"method"in e}function n(e){return r(e)&&(o(e)||a(e))}function o(e){return"result"in e}function a(e){return"error"in e}i.d(t,{DW:function(){return s},jg:function(){return a},k4:function(){return o},u:function(){return n}})},16854:function(e){"use strict";e.exports=function(){throw Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},80577:function(e,t,i){"use strict";i.d(t,{D:function(){return n},u:function(){return o}});let r=e=>JSON.stringify(e,(e,t)=>"bigint"==typeof t?t.toString()+"n":t),s=e=>JSON.parse(e.replace(/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,'$1"$2n"$3'),(e,t)=>"string"==typeof t&&t.match(/^\d+n$/)?BigInt(t.substring(0,t.length-1)):t);function n(e){if("string"!=typeof e)throw Error(`Cannot safe json parse value of type ${typeof e}`);try{return s(e)}catch(t){return e}}function o(e){return"string"==typeof e?e:r(e)||""}},70213:function(e,t,i){"use strict";
10Object.defineProperty(t,"__esModule",{value:!0});let r=i(62494);r.__exportStar(i(12658),t),r.__exportStar(i(75127),t)},12658:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_THOUSAND=t.ONE_HUNDRED=void 0,t.ONE_HUNDRED=100,t.ONE_THOUSAND=1e3},75127:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.ONE_YEAR=t.FOUR_WEEKS=t.THREE_WEEKS=t.TWO_WEEKS=t.ONE_WEEK=t.THIRTY_DAYS=t.SEVEN_DAYS=t.FIVE_DAYS=t.THREE_DAYS=t.ONE_DAY=t.TWENTY_FOUR_HOURS=t.TWELVE_HOURS=t.SIX_HOURS=t.THREE_HOURS=t.ONE_HOUR=t.SIXTY_MINUTES=t.THIRTY_MINUTES=t.TEN_MINUTES=t.FIVE_MINUTES=t.ONE_MINUTE=t.SIXTY_SECONDS=t.THIRTY_SECONDS=t.TEN_SECONDS=t.FIVE_SECONDS=t.ONE_SECOND=void 0,t.ONE_SECOND=1,t.FIVE_SECONDS=5,t.TEN_SECONDS=10,t.THIRTY_SECONDS=30,t.SIXTY_SECONDS=60,t.ONE_MINUTE=t.SIXTY_SECONDS,t.FIVE_MINUTES=5*t.ONE_MINUTE,t.TEN_MINUTES=10*t.ONE_MINUTE,t.THIRTY_MINUTES=30*t.ONE_MINUTE,t.SIXTY_MINUTES=60*t.ONE_MINUTE,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=3*t.ONE_HOUR,t.SIX_HOURS=6*t.ONE_HOUR,t.TWELVE_HOURS=12*t.ONE_HOUR,t.TWENTY_FOUR_HOURS=24*t.ONE_HOUR,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=3*t.ONE_DAY,t.FIVE_DAYS=5*t.ONE_DAY,t.SEVEN_DAYS=7*t.ONE_DAY,t.THIRTY_DAYS=30*t.ONE_DAY,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=2*t.ONE_WEEK,t.THREE_WEEKS=3*t.ONE_WEEK,t.FOUR_WEEKS=4*t.ONE_WEEK,t.ONE_YEAR=365*t.ONE_DAY},40537:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let r=i(62494);r.__exportStar(i(78627),t),r.__exportStar(i(59854),t),r.__exportStar(i(3205),t),r.__exportStar(i(70213),t)},3205:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),i(62494).__exportStar(i(71146),t)},71146:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IWatch=void 0;class i{}t.IWatch=i},68353:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fromMiliseconds=t.toMiliseconds=void 0;let r=i(70213);t.toMiliseconds=function(e){return e*r.ONE_THOUSAND},t.fromMiliseconds=function(e){return Math.floor(e/r.ONE_THOUSAND)}},86029:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.delay=void 0,t.delay=function(e){return new Promise(t=>{setTimeout(()=>{t(!0)},e)})}},78627:function(e,t,i){"use strict";Object.defineProperty(t,"__esModule",{value:!0});let r=i(62494);r.__exportStar(i(86029),t),r.__exportStar(i(68353),t)},59854:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Watch=void 0;class i{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){let t=this.get(e);if(void 0!==t.elapsed)throw Error(`Watch already stopped for label: ${e}`);let i=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:i})}get(e){let t=this.timestamps.get(e);if(void 0===t)throw Error(`No timestamp found for label: ${e}`);return t}elapsed(e){let t=this.get(e);return t.elapsed||Date.now()-t.started}}t.Watch=i,t.default=i},62494:function(e,t,i){"use strict";i.r(t),i.d(t,{__assign:function(){return n},__asyncDelegator:function(){return v},__asyncGenerator:function(){return w},__asyncValues:function(){return E},__await:function(){return b},__awaiter:function(){return h},__classPrivateFieldGet:function(){return O},__classPrivateFieldSet:function(){return P},__createBinding:function(){return u},__decorate:function(){return a},__exportStar:function(){return p},__extends:function(){return s},__generator:function(){return d},__importDefault:function(){return x},__importStar:function(){return I}
vendor: 5,306 bytes, line 10
10,__makeTemplateObject:function(){return _},__metadata:function(){return l},__param:function(){return c},__read:function(){return f},__rest:function(){return o},__spread:function(){return m},__spreadArrays:function(){return y},__values:function(){return g}});var r=function(e,t){return(r=Object.setPrototypeOf||({__proto__:[]})instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};function s(e,t){function i(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(i.prototype=t.prototype,new i)}var n=function(){return(n=Object.assign||function(e){for(var t,i=1,r=arguments.length;i<r;i++)for(var s in t=arguments[i])Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e}).apply(this,arguments)};function o(e,t){var i={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&0>t.indexOf(r)&&(i[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols)for(var s=0,r=Object.getOwnPropertySymbols(e);s<r.length;s++)0>t.indexOf(r[s])&&Object.prototype.propertyIsEnumerable.call(e,r[s])&&(i[r[s]]=e[r[s]]);return i}function a(e,t,i,r){var s,n=arguments.length,o=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,i):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,r);else for(var a=e.length-1;a>=0;a--)(s=e[a])&&(o=(n<3?s(o):n>3?s(t,i,o):s(t,i))||o);return n>3&&o&&Object.defineProperty(t,i,o),o}function c(e,t){return function(i,r){t(i,r,e)}}function l(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function h(e,t,i,r){return new(i||(i=Promise))(function(s,n){function o(e){try{c(r.next(e))}catch(e){n(e)}}function a(e){try{c(r.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?s(e.value):((t=e.value)instanceof i?t:new i(function(e){e(t)})).then(o,a)}c((r=r.apply(e,t||[])).next())})}function d(e,t){var i,r,s,n,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return n={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(n[Symbol.iterator]=function(){return this}),n;function a(n){return function(a){return function(n){if(i)throw TypeError("Generator is already executing.");for(;o;)try{if(i=1,r&&(s=2&n[0]?r.return:n[0]?r.throw||((s=r.return)&&s.call(r),0):r.next)&&!(s=s.call(r,n[1])).done)return s;switch(r=0,s&&(n=[2&n[0],s.value]),n[0]){case 0:case 1:s=n;break;case 4:return o.label++,{value:n[1],done:!1};case 5:o.label++,r=n[1],n=[0];continue;case 7:n=o.ops.pop(),o.trys.pop();continue;default:if(!(s=(s=o.trys).length>0&&s[s.length-1])&&(6===n[0]||2===n[0])){o=0;continue}if(3===n[0]&&(!s||n[1]>s[0]&&n[1]<s[3])){o.label=n[1];break}if(6===n[0]&&o.label<s[1]){o.label=s[1],s=n;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(n);break}s[2]&&o.ops.pop(),o.trys.pop();continue}n=t.call(e,o)}catch(e){n=[6,e],r=0}finally{i=s=0}if(5&n[0])throw n[1];return{value:n[0]?n[1]:void 0,done:!0}}([n,a])}}}function u(e,t,i,r){void 0===r&&(r=i),e[r]=t[i]}function p(e,t){for(var i in e)"default"===i||t.hasOwnProperty(i)||(t[i]=e[i])}function g(e){var t="function"==typeof Symbol&&Symbol.iterator,i=t&&e[t],r=0;if(i)return i.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function f(e,t){var i="function"==typeof Symbol&&e[Symbol.iterator];if(!i)return e;var r,s,n=i.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=n.next()).done;)o.push(r.value)}catch(e){s={error:e}}finally{try{r&&!r.done&&(i=n.return)&&i.call(n)}finally{if(s)throw s.error}}return o}function m(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(f(arguments[t]));return e}function y(){for(var e=0,t=0,i=arguments.length;t<i;t++)e+=arguments[t].length;for(var r=Array(e),s=0,t=0;t<i;t++)for(var n=arguments[t],o=0,a=n.length;o<a;o++,s++)r[s]=n[o];return r}function b(e){return this instanceof b?(this.v=e,this):new b(e)}function w(e,t,i){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var r,s=i.apply(e,t||[]),n=[];return r={},o("next"),o("throw"),o("return"),r[Symbol.asyncIterator]=function(){return this},r;function o(e){s[e]&&(r[e]=function(t){return new Promise(function(i,r){n.push([e,t,i,r])>1||a(e,t)})})}function a(e,t){try{var i;(i=s[e](t)).value instanceof b?Promise.resolve(i.value.v).then(c,l):h(n[0][2],i)}catch(e){h(n[0][3],e)}}function c(e){a("next",e)}function l(e){a("throw",e)}function h(e,t){e(t),n.shift(),n.length&&a(n[0][0],n[0][1])}}function v(e){var t,i;return t={},r("next"),r("throw",function(e){throw e}),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,s){t[r]=e[r]?function(t){return(i=!i)?{value:b(e[r](t)),done:"return"===r}:s?s(t):t}:s}}function E(e){if(!Symbol.asyncIterator)throw TypeError("Symbol.asyncIterator is not defined.");var t,i=e[Symbol.asyncIterator];return i?i.call(e):(e=g(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(i){t[i]=e[i]&&function(t){return new Promise(function(r,s){!function(e,t,i,r){Promise.resolve(r).then(function(t){e({value:t,done:i})},t)}(r,s,(t=e[i](t)).done,t.value)})}}}function _(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}
10function I(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=e[i]);return t.default=e,t}function x(e){return e&&e.__esModule?e:{default:e}}function O(e,t){if(!t.has(e))throw TypeError("attempted to get private field on non-instance");return t.get(e)}function P(e,t,i){if(!t.has(e))throw TypeError("attempted to set private field on non-instance");return t.set(e,i),i}},76454:function(e,t){"use strict";function i(e){let t;return"undefined"!=typeof window&&void 0!==window[e]&&(t=window[e]),t}function r(e){let t=i(e);if(!t)throw Error(`${e} is not defined in Window`);return t}Object.defineProperty(t,"__esModule",{value:!0}),t.getLocalStorage=t.getLocalStorageOrThrow=t.getCrypto=t.getCryptoOrThrow=t.getLocation=t.getLocationOrThrow=t.getNavigator=t.getNavigatorOrThrow=t.getDocument=t.getDocumentOrThrow=t.getFromWindowOrThrow=t.getFromWindow=void 0,t.getFromWindow=i,t.getFromWindowOrThrow=r,t.getDocumentOrThrow=function(){return r("document")},t.getDocument=function(){return i("document")},t.getNavigatorOrThrow=function(){return r("navigator")},t.getNavigator=function(){return i("navigator")},t.getLocationOrThrow=function(){return r("location")},t.getLocation=function(){return i("location")},t.getCryptoOrThrow=function(){return r("crypto")},t.getCrypto=function(){return i("crypto")},t.getLocalStorageOrThrow=function(){return r("localStorage")},t.getLocalStorage=function(){return i("localStorage")}},3897:function(e,t,i){"use strict";t.D=void 0;let r=i(76454);t.D=function(){let e,t,i;try{e=r.getDocumentOrThrow(),t=r.getLocationOrThrow()}catch(e){return null}function s(...t){let i=e.getElementsByTagName("meta");for(let e=0;e<i.length;e++){let r=i[e],s=["itemprop","property","name"].map(e=>r.getAttribute(e)).filter(e=>!!e&&t.includes(e));if(s.length&&s){let e=r.getAttribute("content");if(e)return e}}return""}let n=((i=s("name","og:site_name","og:title","twitter:title"))||(i=e.title),i),o=s("description","og:description","twitter:description","keywords");return{description:o,url:t.origin,icons:function(){let i=e.getElementsByTagName("link"),r=[];for(let e=0;e<i.length;e++){let s=i[e],n=s.getAttribute("rel");if(n&&n.toLowerCase().indexOf("icon")>-1){let e=s.getAttribute("href");if(e){if(-1===e.toLowerCase().indexOf("https:")&&-1===e.toLowerCase().indexOf("http:")&&0!==e.indexOf("//")){let i=t.protocol+"//"+t.host;if(0===e.indexOf("/"))i+=e;else{let r=t.pathname.split("/");r.pop(),i+=r.join("/")+"/"+e}r.push(i)}else if(0===e.indexOf("//")){let i=t.protocol+e;r.push(i)}else r.push(e)}}}return r}(),name:n}}},85810:function(e,t,i){"use strict";i.d(t,{AV:function(){return o},ConfigCtrl:function(){return g},ExplorerCtrl:function(){return k},OptionsCtrl:function(){return u},ThemeCtrl:function(){return H},ToastCtrl:function(){return W},jb:function(){return $},uA:function(){return h},zv:function(){return a}});var r=i(33085),s=i(82957).Buffer;let n=(0,r.sj)({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),o={state:n,subscribe:e=>(0,r.Ld)(n,()=>e(n)),push(e,t){e!==n.view&&(n.view=e,t&&(n.data=t),n.history.push(e))},reset(e){n.view=e,n.history=[e]},replace(e){n.history.length>1&&(n.history[n.history.length-1]=e,n.view=e)},goBack(){if(n.history.length>1){n.history.pop();let[e]=n.history.slice(-1);n.view=e}},setData(e){n.data=e}},a={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile:()=>"undefined"!=typeof window&&!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)),isAndroid:()=>a.isMobile()&&navigator.userAgent.toLowerCase().includes("android"),isIos(){let e=navigator.userAgent.toLowerCase();return a.isMobile()&&(e.includes("iphone")||e.includes("ipad"))},isHttpUrl:e=>e.startsWith("http://")||e.startsWith("https://"),isArray:e=>Array.isArray(e)&&e.length>0,isTelegram:()=>"undefined"!=typeof window&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto),formatNativeUrl(e,t,i){if(a.isHttpUrl(e))return this.formatUniversalUrl(e,t,i);let r=e;r.includes("://")||(r=e.replaceAll("/","").replaceAll(":",""),r=`${r}://`),r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,i);let s=encodeURIComponent(t);return`${r}wc?uri=${s}`},formatUniversalUrl(e,t,i){if(!a.isHttpUrl(e))return this.formatNativeUrl(e,t,i);let r=e;if(r.startsWith("https://t.me")){let e=s.from(t).toString("base64").replace(/[=]/g,"");r.endsWith("/")&&(r=r.slice(0,-1)),this.setWalletConnectDeepLink(r,i);let n=new URL(r);return n.searchParams.set("startapp",e),n.toString()}r.endsWith("/")||(r=`${r}/`),this.setWalletConnectDeepLink(r,i);let n=encodeURIComponent(t);return`${r}wc?uri=${n}`},wait:async e=>new Promise(t=>{setTimeout(t,e)}),openHref(e,t){let i=this.isTelegram()?"_blank":t;window.open(e,i,"noreferrer noopener")},setWalletConnectDeepLink(e,t){try{localStorage.setItem(a.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch(e){console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(e){try{let[t]=e.split("?");localStorage.setItem(a.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:t,name:"Android"}))}catch(e){console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(a.WALLETCONNECT_DEEPLINK_CHOICE)}catch(e){console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{"undefined"!=typeof localStorage&&localStorage.setItem(a.WCM_VERSION,"2.7.0")}catch(e){console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var e;let t=null==(e=o.state.data)?void 0:e.Wallet;if(!t)throw Error('Missing "Wallet" view data');return t}},c="undefined"!=typeof location&&(location.hostname.includes("localhost")||location.protocol.includes("https")),l=(0,r.sj)({enabled:c,userSessionId:"",events:[],connectedWalletId:void 0}),h={state:l,subscribe:e=>(0,r.Ld)(l.events,()=>e((0,r.CO)(l.events[l.events.length-1]))),initialize(){l.enabled&&void 0!==(null==crypto?void 0:crypto.randomUUID)&&(l.userSessionId=crypto.randomUUID())},setConnectedWalletId(e){l.connectedWalletId=e},click(e){if(l.enabled){let t={type:"CLICK",name:e.name,userSessionId:l.userSessionId,timestamp:Date.now(),data:e};l.events.push(t)}},track(e){if(l.enabled){let t={type:"TRACK",name:e.name,userSessionId:l.userSessionId,timestamp:Date.now(),data:e};l.events.push(t)}},view(e){if(l.enabled){let t={type:"VIEW",name:e.name,userSessionId:l.userSessionId,timestamp:Date.now(),data:e};l.events.push(t)}}},d=(0,r.sj)({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCu
10stomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),u={state:d,subscribe:e=>(0,r.Ld)(d,()=>e(d)),setChains(e){d.chains=e},setWalletConnectUri(e){d.walletConnectUri=e},setIsCustomDesktop(e){d.isCustomDesktop=e},setIsCustomMobile(e){d.isCustomMobile=e},setIsDataLoaded(e){d.isDataLoaded=e},setIsUiLoaded(e){d.isUiLoaded=e},setIsAuth(e){d.isAuth=e}},p=(0,r.sj)({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),g={state:p,subscribe:e=>(0,r.Ld)(p,()=>e(p)),setConfig(e){var t,i;h.initialize(),u.setChains(e.chains),u.setIsAuth(!!e.enableAuthMode),u.setIsCustomMobile(!!(null==(t=e.mobileWallets)?void 0:t.length)),u.setIsCustomDesktop(!!(null==(i=e.desktopWallets)?void 0:i.length)),a.setModalVersionInStorage(),Object.assign(p,e)}};var f=Object.defineProperty,m=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable,w=(e,t,i)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,v=(e,t)=>{for(var i in t||(t={}))y.call(t,i)&&w(e,i,t[i]);if(m)for(var i of m(t))b.call(t,i)&&w(e,i,t[i]);return e};let E="https://explorer-api.walletconnect.com",_="js-2.7.0";async function I(e,t){let i=v({sdkType:"wcm",sdkVersion:_},t),r=new URL(e,E);return r.searchParams.append("projectId",g.state.projectId),Object.entries(i).forEach(([e,t])=>{t&&r.searchParams.append(e,String(t))}),(await fetch(r)).json()}let x={getDesktopListings:async e=>I("/w3m/v1/getDesktopListings",e),getMobileListings:async e=>I("/w3m/v1/getMobileListings",e),getAllListings:async e=>I("/w3m/v1/getAllListings",e),getWalletImageUrl:e=>`${E}/w3m/v1/getWalletImage/${e}?projectId=${g.state.projectId}&sdkType=wcm&sdkVersion=${_}`,getAssetImageUrl:e=>`${E}/w3m/v1/getAssetImage/${e}?projectId=${g.state.projectId}&sdkType=wcm&sdkVersion=${_}`};var O=Object.defineProperty,P=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,C=Object.prototype.propertyIsEnumerable,R=(e,t,i)=>t in e?O(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,A=(e,t)=>
10{for(var i in t||(t={}))S.call(t,i)&&R(e,i,t[i]);if(P)for(var i of P(t))C.call(t,i)&&R(e,i,t[i]);return e};let T=a.isMobile(),N=(0,r.sj)({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),k={state:N,async getRecomendedWallets(){let{explorerRecommendedWalletIds:e,explorerExcludedWalletIds:t}=g.state;if("NONE"===e||"ALL"===t&&!e)return N.recomendedWallets;if(a.isArray(e)){let t=e.join(","),{listings:i}=await x.getAllListings({recommendedIds:t}),r=Object.values(i);r.sort((t,i)=>e.indexOf(t.id)-e.indexOf(i.id)),N.recomendedWallets=r}else{let{chains:e,isAuth:i}=u.state,r=null==e?void 0:e.join(","),s=a.isArray(t),n={page:1,sdks:i?"auth_v1":void 0,entries:a.RECOMMENDED_WALLET_AMOUNT,chains:r,version:2,excludedIds:s?t.join(","):void 0},{listings:o}=T?await x.getMobileListings(n):await x.getDesktopListings(n);N.recomendedWallets=Object.values(o)}return N.recomendedWallets},async getWallets(e){let t=A({},e),{explorerRecommendedWalletIds:i,explorerExcludedWalletIds:r}=g.state,{recomendedWallets:s}=N;if("ALL"===r)return N.wallets;s.length?t.excludedIds=s.map(e=>e.id).join(","):a.isArray(i)&&(t.excludedIds=i.join(",")),a.isArray(r)&&(t.excludedIds=[t.excludedIds,r].filter(Boolean).join(",")),u.state.isAuth&&(t.sdks="auth_v1");let{page:n,search:o}=e,{listings:c,total:l}=T?await x.getMobileListings(t):await x.getDesktopListings(t),h=Object.values(c),d=o?"search":"wallets";return N[d]={listings:[...N[d].listings,...h],total:l,page:null!=n?n:1},{listings:h,total:l}},getWalletImageUrl:e=>x.getWalletImageUrl(e),getAssetImageUrl:e=>x.getAssetImageUrl(e),resetSearch(){N.search={listings:[],total:0,page:1}}},L=(0,r.sj)({open:!1}),$={state:L,subscribe:e=>(0,r.Ld)(L,()=>e(L)),open:async e=>new Promise(t=>{let{isUiLoaded:i,isDataLoaded:r}=u.state;if(a.removeWalletConnectDeepLink(),u.setWalletConnectUri(null==e?void 0:e.uri),u.setChains(null==e?void 0:e.chains),o.reset("ConnectWallet"),i&&r)L.open=!0,t();else{let e=setInterval(()=>{let i=u.state;i.isUiLoaded&&i.isDataLoaded&&(clearInterval(e),L.open=!0,t())},200)}}),close(){L.open=!1}};var j=Object.defineProperty,D=Object.getOwnPropertySymbols,M=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,q=(e,t,i)=>t in e?j(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,B=(e,t)=>{for(var i in t||(t={}))M.call(t,i)&&q(e,i,t[i]);if(D)for(var i of D(t))U.call(t,i)&&q(e,i,t[i]);return e};let z=(0,r.sj)({themeMode:"undefined"!=typeof matchMedia&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}),H={state:z,subscribe:e=>(0,r.Ld)(z,()=>e(z)),setThemeConfig(e){let{themeMode:t,themeVariables:i}=e;t&&(z.themeMode=t),i&&(z.themeVariables=B({},i))}},V=(0,r.sj)({open:!1,message:"",variant:"success"}),W={state:V,subscribe:e=>(0,r.Ld)(V,()=>e(V)),openToast(e,t){V.open=!0,V.message=e,V.variant=t},closeToast(){V.open=!1}}},20331:function(e,t,i){"use strict";i.r(t),i.d(t,{WcmModal:function(){return tl},WcmQrCode:function(){return eg}});var r=i(50714),s=i(23227),n=i(17067),o=i(85810),a=i(81997),c=i(89866),l=i(32801),h=i(35819),d=Object.defineProperty,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,g=Object.prototype.propertyIsEnumerable,f=(e,t,i)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,m=(e,t)=>{for(var i in t||(t={}))p.call(t,i)&&f(e,i,t[i]);if(u)for(var i of u(t))g.call(t,i)&&f(e,i,t[i]);return e};function y(){return{"--wcm-accent-color":"#3396FF","--wcm-accent-fill-color":"#FFFFFF","--wcm-z-index":"89","--wcm-background-color":"#3396FF","--wcm-background-border-radius":"8px","--wcm-container-border-radius":"30px","--wcm-wallet-icon-border-radius":"15px","--wcm-wallet-icon-large-border-radius":"30px","--wcm-wallet-icon-small-border-radius":"7px","--wcm-input-border-radius":"28px","--wcm-button-border-radius":"10px","--wcm-notification-border-radius":"36px","--wcm-secondary-button-border-radius":"28px","--wcm-icon-button-border-radius":"50%","--wcm-button-hover-highlight-border-radius":"10px","--wcm-text-big-bold-size":"20px","--wcm-text-big-bold-weight":"600","--wcm-text-big-bold-line-height":"24px","--wcm-text-big-bold-letter-spacing":"-0.03em","--wcm-text-big-bold-text-transform":"none","--wcm-text-xsmall-bold-size":"10px","--wcm-text-xsmall-bold-weight":"700","--wcm-text-xsmall-bold-line-height":"12px","--wcm-text-xsmall-bold-letter-spacing":"0.02em","--wcm-text-xsmall-bold-text-transform":"uppercase","--wcm-text-xsmall-regular-size":"12px","--wcm-text-xsmall-regular-weight":"600","--wcm-text-xsmall-regular-line-height":"14px","--wcm-text-xsmall-regular-letter-spacing":"-0.03em","--wcm-text-xsmall-regular-text-transform":"none","--wcm-text-small-thin-size":"14px","--wcm-text-small-thin-weight":"500","--wcm-text-small-thin-line-height":"16px","--wcm-text-small-thin-letter-spacing":"-0.03em","--wcm-text-small-thin-text-transform":"none","--wcm-text-small-regular-size":"14px","--wcm-text-small-regular-weight":"600","--wcm-text-small-regular-line-height":"16px","--wcm-text-small-regular-letter-spacing":"-0.03em","--wcm-text-small-regular-text-transform":"none","--wcm-text-medium-regular-size":"16px","--wcm-text-medium-regular-weight":"600","--wcm-text-medium-regular-line-height":"20px","--wcm-text-medium-regular-letter-spacing":"-0.03em","--wcm-text-medium-regular-text-transform":"none","--wcm-font-family":"-apple-system, system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, Ubuntu, 'Helvetica Neue', sans-serif","--wcm-font-feature-settings":"'tnum' on, 'lnum' on, 'case' on","--wcm-success-color":"rgb(38,181,98)","--wcm-error-color":"rgb(242, 90, 103)","--wcm-overlay-background-color":"rgba(0, 0, 0, 0.3)","--wcm-overlay-backdrop-filter":"none"}}let b={getPreset:e=>y()[e],setTheme(){let e=document.querySelector(":root"),{themeVariables:t}
10=o.ThemeCtrl.state;e&&Object.entries(m(m(m({},function(){var e;let t={light:{foreground:{1:"rgb(20,20,20)",2:"rgb(121,134,134)",3:"rgb(158,169,169)"},background:{1:"rgb(255,255,255)",2:"rgb(241,243,243)",3:"rgb(228,231,231)"},overlay:"rgba(0,0,0,0.1)"},dark:{foreground:{1:"rgb(228,231,231)",2:"rgb(148,158,158)",3:"rgb(110,119,119)"},background:{1:"rgb(20,20,20)",2:"rgb(39,42,42)",3:"rgb(59,64,64)"},overlay:"rgba(255,255,255,0.1)"}}[null!=(e=o.ThemeCtrl.state.themeMode)?e:"dark"];return{"--wcm-color-fg-1":t.foreground[1],"--wcm-color-fg-2":t.foreground[2],"--wcm-color-fg-3":t.foreground[3],"--wcm-color-bg-1":t.background[1],"--wcm-color-bg-2":t.background[2],"--wcm-color-bg-3":t.background[3],"--wcm-color-overlay":t.overlay}}()),y()),t)).forEach(([t,i])=>e.style.setProperty(t,i))},globalCss:(0,r.iv)`*,::after,::before{margin:0;padding:0;box-sizing:border-box;font-style:normal;text-rendering:optimizeSpeed;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-webkit-tap-highlight-color:transparent;backface-visibility:hidden}button{cursor:pointer;display:flex;justify-content:center;align-items:center;position:relative;border:none;background-color:transparent;transition:all .2s ease}@media (hover:hover) and (pointer:fine){button:active{transition:all .1s ease;transform:scale(.93)}}button::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;transition:background-color,.2s ease}button:disabled{cursor:not-allowed}button svg,button wcm-text{position:relative;z-index:1}input{border:none;outline:0;appearance:none}img{display:block}::selection{color:var(--wcm-accent-fill-color);background:var(--wcm-accent-color)}`},w=(0,r.iv)`button{border-radius:var(--wcm-secondary-button-border-radius);height:28px;padding:0 10px;background-color:var(--wcm-accent-color)}button path{fill:var(--wcm-accent-fill-color)}button::after{border-radius:inherit;border:1px solid var(--wcm-color-overlay)}button:disabled::after{background-color:transparent}.wcm-icon-left svg{margin-right:5px}.wcm-icon-right svg{margin-left:5px}button:active::after{background-color:var(--wcm-color-overlay)}.wcm-ghost,.wcm-ghost:active::after,.wcm-outline{background-color:transparent}.wcm-ghost:active{opacity:.5}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}.wcm-ghost:hover::after{background-color:transparent}.wcm-ghost:hover{opacity:.5}}button:disabled{background-color:var(--wcm-color-bg-3);pointer-events:none}.wcm-ghost::after{border-color:transparent}.wcm-ghost path{fill:var(--wcm-color-fg-2)}.wcm-outline path{fill:var(--wcm-accent-color)}.wcm-outline:disabled{background-color:transparent;opacity:.5}`;var v=Object.defineProperty,E=Object.getOwnPropertyDescriptor,_=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?E(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&v(t,i,n),n};let I=class extends r.oi{constructor(){super(...arguments),this.disabled=!1,this.iconLeft=void 0,this.iconRight=void 0,this.onClick=()=>null,this.variant="default"}render(){let e={"wcm-icon-left":void 0!==this.iconLeft,"wcm-icon-right":void 0!==this.iconRight,"wcm-ghost":"ghost"===this.variant,"wcm-outline":"outline"===this.variant},t="inverse";return"ghost"===this.variant&&(t="secondary"),"outline"===this.variant&&(t="accent"),(0,r.dy)`<button class="${(0,n.$)(e)}" ?disabled="${this.disabled}" @click="${this.onClick}">${this.iconLeft}<wcm-text variant="small-regular" color="${t}"><slot></slot></wcm-text>${this.iconRight}</button>`}};I.styles=[b.globalCss,w],_([(0,s.Cb)({type:Boolean})],I.prototype,"disabled",2),_([(0,s.Cb)()],I.prototype,"iconLeft",2),_([(0,s.Cb)()],I.prototype,"iconRight",2),_([(0,s.Cb)()],I.prototype,"onClick",2),_([(0,s.Cb)()],I.prototype,"variant",2),I=_([(0,s.Mo)("wcm-button")],I);let x=(0,r.iv)`:host{display:inline-block}button{padding:0 15px 1px;height:40px;border-radius:var(--wcm-button-border-radius);color:var(--wcm-accent-fill-color);background-color:var(--wcm-accent-color)}button::after{content:'';top:0;bottom:0;left:0;right:0;position:absolute;background-color:transparent;border-radius:inherit;transition:background-color .2s ease;border:1px solid var(--wcm-color-overlay)}button:active::after{background-color:var(--wcm-color-overlay)}button:disabled{padding-bottom:0;background-color:var(--wcm-color-bg-3);color:var(--wcm-color-fg-3)}.wcm-secondary{color:var(--wcm-accent-color);background-color:transparent}.wcm-secondary::after{display:none}@media(hover:hover){button:hover::after{background-color:var(--wcm-color-overlay)}}`;var O=Object.defineProperty,P=Object.getOwnPropertyDescriptor,S=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?P(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&O(t,i,n),n};let C=class extends r.oi{constructor(){super(...arguments),this.disabled=!1,this.variant="primary"}render(){let e={"wcm-secondary":"secondary"===this.variant};return(0,r.dy)`<button ?disabled="${this.disabled}" class="${(0,n.$)(e)}"><slot></slot></button>`}}
10;C.styles=[b.globalCss,x],S([(0,s.Cb)({type:Boolean})],C.prototype,"disabled",2),S([(0,s.Cb)()],C.prototype,"variant",2),C=S([(0,s.Mo)("wcm-button-big")],C);let R=(0,r.iv)`:host{background-color:var(--wcm-color-bg-2);border-top:1px solid var(--wcm-color-bg-3)}div{padding:10px 20px;display:inherit;flex-direction:inherit;align-items:inherit;width:inherit;justify-content:inherit}`;var A=Object.defineProperty,T=Object.getOwnPropertyDescriptor;let N=class extends r.oi{render(){return(0,r.dy)`<div><slot></slot></div>`}};N.styles=[b.globalCss,R],N=((e,t,i,r)=>{for(var s,n=r>1?void 0:r?T(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&A(t,i,n),n})([(0,s.Mo)("wcm-info-footer")],N);let k={CROSS_ICON:(0,a.YP)`<svg width="12" height="12" viewBox="0 0 12 12"><path d="M9.94 11A.75.75 0 1 0 11 9.94L7.414 6.353a.5.5 0 0 1 0-.708L11 2.061A.75.75 0 1 0 9.94 1L6.353 4.586a.5.5 0 0 1-.708 0L2.061 1A.75.75 0 0 0 1 2.06l3.586 3.586a.5.5 0 0 1 0 .708L1 9.939A.75.75 0 1 0 2.06 11l3.586-3.586a.5.5 0 0 1 .708 0L9.939 11Z" fill="#fff"/></svg>`,WALLET_CONNECT_LOGO:(0,a.YP)`<svg width="178" height="29" viewBox="0 0 178 29" id="wcm-wc-logo"><path d="M10.683 7.926c5.284-5.17 13.85-5.17 19.134 0l.636.623a.652.652 0 0 1 0 .936l-2.176 2.129a.343.343 0 0 1-.478 0l-.875-.857c-3.686-3.607-9.662-3.607-13.348 0l-.937.918a.343.343 0 0 1-.479 0l-2.175-2.13a.652.652 0 0 1 0-.936l.698-.683Zm23.633 4.403 1.935 1.895a.652.652 0 0 1 0 .936l-8.73 8.543a.687.687 0 0 1-.956 0L20.37 17.64a.172.172 0 0 0-.239 0l-6.195 6.063a.687.687 0 0 1-.957 0l-8.73-8.543a.652.652 0 0 1 0-.936l1.936-1.895a.687.687 0 0 1 .957 0l6.196 6.064a.172.172 0 0 0 .239 0l6.195-6.064a.687.687 0 0 1 .957 0l6.196 6.064a.172.172 0 0 0 .24 0l6.195-6.064a.687.687 0 0 1 .956 0ZM48.093 20.948l2.338-9.355c.139-.515.258-1.07.416-1.942.12.872.258 1.427.357 1.942l2.022 9.355h4.181l3.528-13.874h-3.21l-1.943 8.523a24.825 24.825 0 0 0-.456 2.457c-.158-.931-.317-1.625-.495-2.438l-1.883-8.542h-4.201l-2.042 8.542a41.204 41.204 0 0 0-.475 2.438 41.208 41.208 0 0 0-.476-2.438l-1.903-8.542h-3.349l3.508 13.874h4.083ZM63.33 21.304c1.585 0 2.596-.654 3.11-1.605-.059.297-.078.595-.078.892v.357h2.655V15.22c0-2.735-1.248-4.32-4.3-4.32-2.636 0-4.36 1.466-4.52 3.487h2.914c.1-.891.734-1.426 1.705-1.426.911 0 1.407.515 1.407 1.11 0 .435-.258.693-1.03.792l-1.388.159c-2.061.257-3.825 1.01-3.825 3.19 0 1.982 1.645 3.092 3.35 3.092Zm.891-2.041c-.773 0-1.348-.436-1.348-1.19 0-.733.655-1.09 1.645-1.268l.674-.119c.575-.118.892-.218 1.09-.396v.912c0 1.228-.892 2.06-2.06 2.06ZM70.398 7.074v13.874h2.874V7.074h-2.874ZM74.934 7.074v13.874h2.874V7.074h-2.874ZM84.08 21.304c2.735 0 4.5-1.546 4.697-3.567h-2.893c-.139.892-.892 1.387-1.804 1.387-1.228 0-2.12-.99-2.14-2.358h6.897v-.555c0-3.21-1.764-5.312-4.816-5.312-2.933 0-4.994 2.062-4.994 5.173 0 3.37 2.12 5.232 5.053 5.232Zm-2.16-6.421c.119-1.11.932-1.922 2.081-1.922 1.11 0 1.883.772 1.903 1.922H81.92ZM94.92 21.146c.633 0 1.248-.1 1.525-.179v-2.18c-.218.04-.475.06-.693.06-1.05 0-1.427-.595-1.427-1.566v-3.805h2.338v-2.24h-2.338V7.788H91.47v3.448H89.37v2.24h2.1v4.201c0 2.3 1.15 3.469 3.45 3.469ZM104.62 21.304c3.924 0 6.302-2.299 6.599-5.608h-3.111c-.238 1.803-1.506 3.032-3.369 3.032-2.2 0-3.746-1.784-3.746-4.796 0-2.953 1.605-4.638 3.805-4.638 1.883 0 2.953 1.15 3.171 2.834h3.191c-.317-3.448-2.854-5.41-6.342-5.41-3.984 0-7.036 2.695-7.036 7.214 0 4.677 2.676 7.372 6.838 7.372ZM117.449 21.304c2.993 0 5.114-1.882 5.114-5.172 0-3.23-2.121-5.233-5.114-5.233-2.972 0-5.093 2.002-5.093 5.233 0 3.29 2.101 5.172 5.093 5.172Zm0-2.22c-1.327 0-2.18-1.09-2.18-2.952 0-1.903.892-2.973 2.18-2.973 1.308 0 2.2 1.07 2.2 2.973 0 1.862-.872 2.953-2.2 2.953ZM126.569 20.948v-5.689c0-1.208.753-2.1 1.823-2.1 1.011 0 1.606.773 1.606 2.06v5.729h2.873v-6.144c0-2.339-1.229-3.905-3.428-3.905-1.526 0-2.458.734-2.953 1.606a5.31 5.31 0 0 0 .079-.892v-.377h-2.874v9.712h2.874ZM137.464 20.948v-5.689c0-1.208.753-2.1 1.823-2.1 1.011 0 1.606.773 1.606 2.06v5.729h2.873v-6.144c0-2.339-1.228-3.905-3.428-3.905-1.526 0-2.458.734-2.953 1.606a5.31 5.31 0 0 0 .079-.892v-.377h-2.874v9.712h2.874ZM149.949 21.304c2.735 0 4.499-1.546 4.697-3.567h-2.893c-.139.892-.892 1.387-1.804 1.387-1.228 0-2.12-.99-2.14-2.358h6.897v-.555c0-3.21-1.764-5.312-4.816-5.312-2.933 0-4.994 2.062-4.994 5.173 0 3.37 2.12 5.232 5.053 5.232Zm-2.16-6.421c.119-1.11.932-1.922 2.081-1.922 1.11 0 1.883.772 1.903 1.922h-3.984ZM160.876 21.304c3.013 0 4.658-1.645 4.975-4.201h-2.874c-.099 1.07-.713 1.982-2.001 1.982-1.309 0-2.2-1.21-2.2-2.993 0-1.942 1.03-2.933 2.259-2.933 1.209 0 1.803.872 1.883 1.882h2.873c-.218-2.358-1.823-4.142-4.776-4.142-2.874 0-5.153 1.903-5.153 5.193 0 3.25 1.923 5.212 5.014 5.212ZM172.067 21.146c.634 0 1.248-.1 1.526-.179v-2.18c-.218.04-.476.06-.694.06-1.05 0-1.427-.595-1.427-1.566v-3.805h2.339v-2.24h-2.339V7.788h-2.854v3.448h-2.1v2.24h2.1v4.201c0 2.3 1.15 3.469 3.449 3.469Z" fill="#fff"/></svg>`,WALLET_CONNECT_ICON:(0,a.YP)`<svg width="28" height="20" viewBox="0 0 28 20"><g clip-path="url(#a)"><path d="M7.386 6.482c3.653-3.576 9.575-3.576 13.228 0l.44.43a.451.451 0 0 1 0 .648L19.55 9.033a.237.237 0 0 1-.33 0l-.606-.592c-2.548-2.496-6.68-2.496-9.228 0l-.648.634a.237.237 0 0 1-.33 0L6.902 7.602a.451.451 0 0 1 0-.647l.483-.473Zm16.338 3.046 1.339 1.31
10a.451.451 0 0 1 0 .648l-6.035 5.909a.475.475 0 0 1-.662 0L14.083 13.2a.119.119 0 0 0-.166 0l-4.283 4.194a.475.475 0 0 1-.662 0l-6.035-5.91a.451.451 0 0 1 0-.647l1.338-1.31a.475.475 0 0 1 .662 0l4.283 4.194c.046.044.12.044.166 0l4.283-4.194a.475.475 0 0 1 .662 0l4.283 4.194c.046.044.12.044.166 0l4.283-4.194a.475.475 0 0 1 .662 0Z" fill="#000000"/></g><defs><clipPath id="a"><path fill="#ffffff" d="M0 0h28v20H0z"/></clipPath></defs></svg>`,WALLET_CONNECT_ICON_COLORED:(0,a.YP)`<svg width="96" height="96" fill="none"><path fill="#fff" d="M25.322 33.597c12.525-12.263 32.83-12.263 45.355 0l1.507 1.476a1.547 1.547 0 0 1 0 2.22l-5.156 5.048a.814.814 0 0 1-1.134 0l-2.074-2.03c-8.737-8.555-22.903-8.555-31.64 0l-2.222 2.175a.814.814 0 0 1-1.134 0l-5.156-5.049a1.547 1.547 0 0 1 0-2.22l1.654-1.62Zm56.019 10.44 4.589 4.494a1.547 1.547 0 0 1 0 2.22l-20.693 20.26a1.628 1.628 0 0 1-2.267 0L48.283 56.632a.407.407 0 0 0-.567 0L33.03 71.012a1.628 1.628 0 0 1-2.268 0L10.07 50.75a1.547 1.547 0 0 1 0-2.22l4.59-4.494a1.628 1.628 0 0 1 2.267 0l14.687 14.38c.156.153.41.153.567 0l14.685-14.38a1.628 1.628 0 0 1 2.268 0l14.687 14.38c.156.153.41.153.567 0l14.686-14.38a1.628 1.628 0 0 1 2.268 0Z"/><path stroke="#000" d="M25.672 33.954c12.33-12.072 32.325-12.072 44.655 0l1.508 1.476a1.047 1.047 0 0 1 0 1.506l-5.157 5.048a.314.314 0 0 1-.434 0l-2.074-2.03c-8.932-8.746-23.409-8.746-32.34 0l-2.222 2.174a.314.314 0 0 1-.434 0l-5.157-5.048a1.047 1.047 0 0 1 0-1.506l1.655-1.62Zm55.319 10.44 4.59 4.494a1.047 1.047 0 0 1 0 1.506l-20.694 20.26a1.128 1.128 0 0 1-1.568 0l-14.686-14.38a.907.907 0 0 0-1.267 0L32.68 70.655a1.128 1.128 0 0 1-1.568 0L10.42 50.394a1.047 1.047 0 0 1 0-1.506l4.59-4.493a1.128 1.128 0 0 1 1.567 0l14.687 14.379a.907.907 0 0 0 1.266 0l-.35-.357.35.357 14.686-14.38a1.128 1.128 0 0 1 1.568 0l14.687 14.38a.907.907 0 0 0 1.267 0l14.686-14.38a1.128 1.128 0 0 1 1.568 0Z"/></svg>`,BACK_ICON:(0,a.YP)`<svg width="10" height="18" viewBox="0 0 10 18"><path fill-rule="evenodd" clip-rule="evenodd" d="M8.735.179a.75.75 0 0 1 .087 1.057L2.92 8.192a1.25 1.25 0 0 0 0 1.617l5.902 6.956a.75.75 0 1 1-1.144.97L1.776 10.78a2.75 2.75 0 0 1 0-3.559L7.678.265A.75.75 0 0 1 8.735.18Z" fill="#fff"/></svg>`,COPY_ICON:(0,a.YP)`<svg width="24" height="24" fill="none"><path fill="#fff" fill-rule="evenodd" d="M7.01 7.01c.03-1.545.138-2.5.535-3.28A5 5 0 0 1 9.73 1.545C10.8 1 12.2 1 15 1c2.8 0 4.2 0 5.27.545a5 5 0 0 1 2.185 2.185C23 4.8 23 6.2 23 9c0 2.8 0 4.2-.545 5.27a5 5 0 0 1-2.185 2.185c-.78.397-1.735.505-3.28.534l-.001.01c-.03 1.54-.138 2.493-.534 3.27a5 5 0 0 1-2.185 2.186C13.2 23 11.8 23 9 23c-2.8 0-4.2 0-5.27-.545a5 5 0 0 1-2.185-2.185C1 19.2 1 17.8 1 15c0-2.8 0-4.2.545-5.27A5 5 0 0 1 3.73 7.545C4.508 7.149 5.46 7.04 7 7.01h.01ZM15 15.5c-1.425 0-2.403-.001-3.162-.063-.74-.06-1.139-.172-1.427-.319a3.5 3.5 0 0 1-1.53-1.529c-.146-.288-.257-.686-.318-1.427C8.501 11.403 8.5 10.425 8.5 9c0-1.425.001-2.403.063-3.162.06-.74.172-1.139.318-1.427a3.5 3.5 0 0 1 1.53-1.53c.288-.146.686-.257 1.427-.318.759-.062 1.737-.063 3.162-.063 1.425 0 2.403.001 3.162.063.74.06 1.139.172 1.427.318a3.5 3.5 0 0 1 1.53 1.53c.146.288.257.686.318 1.427.062.759.063 1.737.063 3.162 0 1.425-.001 2.403-.063 3.162-.06.74-.172 1.139-.319 1.427a3.5 3.5 0 0 1-1.529 1.53c-.288.146-.686.257-1.427.318-.759.062-1.737.063-3.162.063ZM7 8.511c-.444.009-.825.025-1.162.052-.74.06-1.139.172-1.427.318a3.5 3.5 0 0 0-1.53 1.53c-.146.288-.257.686-.318 1.427-.062.759-.063 1.737-.063 3.162 0 1.425.001 2.403.063 3.162.06.74.172 1.139.318 1.427a3.5 3.5 0 0 0 1.53 1.53c.288.146.686.257 1.427.318.759.062 1.737.063 3.162.063 1.425 0 2.403-.001 3.162-.063.74-.06 1.139-.172 1.427-.319a3.5 3.5 0 0 0 1.53-1.53c.146-.287.257-.685.318-1.426.027-.337.043-.718.052-1.162H15c-2.8 0-4.2 0-5.27-.545a5 5 0 0 1-2.185-2.185C7 13.2 7 11.8 7 9v-.489Z" clip-rule="evenodd"/></svg>`,RETRY_ICON:(0,a.YP)`<svg width="15" height="16" viewBox="0 0 15 16"><path d="M6.464 2.03A.75.75 0 0 0 5.403.97L2.08 4.293a1 1 0 0 0 0 1.414L5.403 9.03a.75.75 0 0 0 1.06-1.06L4.672 6.177a.25.25 0 0 1 .177-.427h2.085a4 4 0 1 1-3.93 4.746c-.077-.407-.405-.746-.82-.746-.414 0-.755.338-.7.748a5.501 5.501 0 1 0 5.45-6.248H4.848a.25.25 0 0 1-.177-.427L6.464 2.03Z" fill="#fff"/></svg>
10`,DESKTOP_ICON:(0,a.YP)`<svg width="16" height="16" viewBox="0 0 16 16"><path fill-rule="evenodd" clip-rule="evenodd" d="M0 5.98c0-1.85 0-2.775.394-3.466a3 3 0 0 1 1.12-1.12C2.204 1 3.13 1 4.98 1h6.04c1.85 0 2.775 0 3.466.394a3 3 0 0 1 1.12 1.12C16 3.204 16 4.13 16 5.98v1.04c0 1.85 0 2.775-.394 3.466a3 3 0 0 1-1.12 1.12C13.796 12 12.87 12 11.02 12H4.98c-1.85 0-2.775 0-3.466-.394a3 3 0 0 1-1.12-1.12C0 9.796 0 8.87 0 7.02V5.98ZM4.98 2.5h6.04c.953 0 1.568.001 2.034.043.446.04.608.108.69.154a1.5 1.5 0 0 1 .559.56c.046.08.114.243.154.69.042.465.043 1.08.043 2.033v1.04c0 .952-.001 1.568-.043 2.034-.04.446-.108.608-.154.69a1.499 1.499 0 0 1-.56.559c-.08.046-.243.114-.69.154-.466.042-1.08.043-2.033.043H4.98c-.952 0-1.568-.001-2.034-.043-.446-.04-.608-.108-.69-.154a1.5 1.5 0 0 1-.559-.56c-.046-.08-.114-.243-.154-.69-.042-.465-.043-1.08-.043-2.033V5.98c0-.952.001-1.568.043-2.034.04-.446.108-.608.154-.69a1.5 1.5 0 0 1 .56-.559c.08-.046.243-.114.69-.154.465-.042 1.08-.043 2.033-.043Z" fill="#fff"/><path d="M4 14.25a.75.75 0 0 1 .75-.75h6.5a.75.75 0 0 1 0 1.5h-6.5a.75.75 0 0 1-.75-.75Z" fill="#fff"/></svg>`,MOBILE_ICON:(0,a.YP)`<svg width="16" height="16" viewBox="0 0 16 16"><path d="M6.75 5a1.25 1.25 0 1 0 0-2.5 1.25 1.25 0 0 0 0 2.5Z" fill="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M3 4.98c0-1.85 0-2.775.394-3.466a3 3 0 0 1 1.12-1.12C5.204 0 6.136 0 8 0s2.795 0 3.486.394a3 3 0 0 1 1.12 1.12C13 2.204 13 3.13 13 4.98v6.04c0 1.85 0 2.775-.394 3.466a3 3 0 0 1-1.12 1.12C10.796 16 9.864 16 8 16s-2.795 0-3.486-.394a3 3 0 0 1-1.12-1.12C3 13.796 3 12.87 3 11.02V4.98Zm8.5 0v6.04c0 .953-.001 1.568-.043 2.034-.04.446-.108.608-.154.69a1.499 1.499 0 0 1-.56.559c-.08.045-.242.113-.693.154-.47.042-1.091.043-2.05.043-.959 0-1.58-.001-2.05-.043-.45-.04-.613-.109-.693-.154a1.5 1.5 0 0 1-.56-.56c-.046-.08-.114-.243-.154-.69-.042-.466-.043-1.08-.043-2.033V4.98c0-.952.001-1.568.043-2.034.04-.446.108-.608.154-.69a1.5 1.5 0 0 1 .56-.559c.08-.045.243-.113.693-.154C6.42 1.501 7.041 1.5 8 1.5c.959 0 1.58.001 2.05.043.45.04.613.109.693.154a1.5 1.5 0 0 1 .56.56c.046.08.114.243.154.69.042.465.043 1.08.043 2.033Z" fill="#fff"/></svg>`,ARROW_DOWN_ICON:(0,a.YP)`<svg width="14" height="14" viewBox="0 0 14 14"><path d="M2.28 7.47a.75.75 0 0 0-1.06 1.06l5.25 5.25a.75.75 0 0 0 1.06 0l5.25-5.25a.75.75 0 0 0-1.06-1.06l-3.544 3.543a.25.25 0 0 1-.426-.177V.75a.75.75 0 0 0-1.5 0v10.086a.25.25 0 0 1-.427.176L2.28 7.47Z" fill="#fff"/></svg>`,ARROW_UP_RIGHT_ICON:(0,a.YP)`<svg width="15" height="14" fill="none"><path d="M4.5 1.75A.75.75 0 0 1 5.25 1H12a1.5 1.5 0 0 1 1.5 1.5v6.75a.75.75 0 0 1-1.5 0V4.164a.25.25 0 0 0-.427-.176L4.061 11.5A.75.75 0 0 1 3 10.44l7.513-7.513a.25.25 0 0 0-.177-.427H5.25a.75.75 0 0 1-.75-.75Z" fill="#fff"/></svg>`,ARROW_RIGHT_ICON:(0,a.YP)`<svg width="6" height="14" viewBox="0 0 6 14"><path fill-rule="evenodd" clip-rule="evenodd" d="M2.181 1.099a.75.75 0 0 1 1.024.279l2.433 4.258a2.75 2.75 0 0 1 0 2.729l-2.433 4.257a.75.75 0 1 1-1.303-.744L4.335 7.62a1.25 1.25 0 0 0 0-1.24L1.902 2.122a.75.75 0 0 1 .28-1.023Z" fill="#fff"/></svg>`,QRCODE_ICON:(0,a.YP)`<svg width="25" height="24" viewBox="0 0 25 24"><path d="M23.748 9a.748.748 0 0 0 .748-.752c-.018-2.596-.128-4.07-.784-5.22a6 6 0 0 0-2.24-2.24c-1.15-.656-2.624-.766-5.22-.784a.748.748 0 0 0-.752.748c0 .414.335.749.748.752 1.015.007 1.82.028 2.494.088.995.09 1.561.256 1.988.5.7.398 1.28.978 1.679 1.678.243.427.41.993.498 1.988.061.675.082 1.479.09 2.493a.753.753 0 0 0 .75.749ZM3.527.788C4.677.132 6.152.022 8.747.004A.748.748 0 0 1 9.5.752a.753.753 0 0 1-.749.752c-1.014.007-1.818.028-2.493.088-.995.09-1.561.256-1.988.5-.7.398-1.28.978-1.679 1.678-.243.427-.41.993-.499 1.988-.06.675-.081 1.479-.088 2.493A.753.753 0 0 1 1.252 9a.748.748 0 0 1-.748-.752c.018-2.596.128-4.07.784-5.22a6 6 0 0 1 2.24-2.24ZM1.252 15a.748.748 0 0 0-.748.752c.018 2.596.128 4.07.784 5.22a6 6 0 0 0 2.24 2.24c1.15.656 2.624.766 5.22.784a.748.748 0 0 0 .752-.748.753.753 0 0 0-.749-.752c-1.014-.007-1.818-.028-2.493-.089-.995-.089-1.561-.255-1.988-.498a4.5 4.5 0 0 1-1.679-1.68c-.243-.426-.41-.992-.499-1.987-.06-.675-.081-1.479-.088-2.493A.753.753 0 0 0 1.252 15ZM22.996 15.749a.753.753 0 0 1 .752-.749c.415 0 .751.338.748.752-.018 2.596-.128 4.07-.784 5.22a6 6 0 0 1-2.24 2.24c-1.15.656-2.624.766-5.22.784a.748.748 0 0 1-.752-.748c0-.414.335-.749.748-.752 1.015-.007 1.82-.028 2.494-.089.995-.089 1.561-.255 1.988-.498a4.5 4.5 0 0 0 1.679-1.68c.243-.426.41-.992.498-1.987.061-.675.082-1.479.09-2.493Z" fill="#fff"/><path fill-rule="evenodd" clip-rule="evenodd" d="M7 4a2.5 2.5 0 0 0-2.5 2.5v2A2.5 2.5 0 0 0 7 11h2a2.5 2.5 0 0 0 2.5-2.5v-2A2.5 2.5 0 0 0 9 4H7Zm2 1.5H7a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1ZM13.5 6.5A2.5 2.5 0 0 1 16 4h2a2.5 2.5 0 0 1 2.5 2.5v2A2.5 2.5 0 0 1 18 11h-2a2.5 2.5 0 0 1-2.5-2.5v-2Zm2.5-1h2a1 1 0 0 1 1 1v2a1 1 0 0 1-1 1h-2a1 1 0 0 1-1-1v-2a1 1 0 0 1 1-1ZM7 13a2.5 2.5 0 0 0-2.5 2.5v2A2.5 2.5 0 0 0 7 20h2a2.5 2.5 0 0 0 2.5-2.5v-2A2.5 2.5 0 0 0 9 13H7Zm2 1.5H7a1 1 0 0 0-1 1v2a1 1 0 0 0 1 1h2a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1Z" fill="#fff"/><path d="M13.5 15.5c0-.465 0-.697.038-.89a2 2 0 0 1 1.572-1.572C15.303 13 15.535 13 16 13v2.5h-2.5ZM18 13c.465 0 .697 0 .89.038a2 2 0 0 1 1.572 1.572c.038.193.038.425.038.89H18V13ZM18 17.5h2.5c0 .465 0 .697-.
10038.89a2 2 0 0 1-1.572 1.572C18.697 20 18.465 20 18 20v-2.5ZM13.5 17.5H16V20c-.465 0-.697 0-.89-.038a2 2 0 0 1-1.572-1.572c-.038-.193-.038-.425-.038-.89Z" fill="#fff"/></svg>`,SCAN_ICON:(0,a.YP)`<svg width="16" height="16" fill="none"><path fill="#fff" d="M10 15.216c0 .422.347.763.768.74 1.202-.064 2.025-.222 2.71-.613a5.001 5.001 0 0 0 1.865-1.866c.39-.684.549-1.507.613-2.709a.735.735 0 0 0-.74-.768.768.768 0 0 0-.76.732c-.009.157-.02.306-.032.447-.073.812-.206 1.244-.384 1.555-.31.545-.761.996-1.306 1.306-.311.178-.743.311-1.555.384-.141.013-.29.023-.447.032a.768.768 0 0 0-.732.76ZM10 .784c0 .407.325.737.732.76.157.009.306.02.447.032.812.073 1.244.206 1.555.384a3.5 3.5 0 0 1 1.306 1.306c.178.311.311.743.384 1.555.013.142.023.29.032.447a.768.768 0 0 0 .76.732.734.734 0 0 0 .74-.768c-.064-1.202-.222-2.025-.613-2.71A5 5 0 0 0 13.477.658c-.684-.39-1.507-.549-2.709-.613a.735.735 0 0 0-.768.74ZM5.232.044A.735.735 0 0 1 6 .784a.768.768 0 0 1-.732.76c-.157.009-.305.02-.447.032-.812.073-1.244.206-1.555.384A3.5 3.5 0 0 0 1.96 3.266c-.178.311-.311.743-.384 1.555-.013.142-.023.29-.032.447A.768.768 0 0 1 .784 6a.735.735 0 0 1-.74-.768c.064-1.202.222-2.025.613-2.71A5 5 0 0 1 2.523.658C3.207.267 4.03.108 5.233.044ZM5.268 14.456a.768.768 0 0 1 .732.76.734.734 0 0 1-.768.74c-1.202-.064-2.025-.222-2.71-.613a5 5 0 0 1-1.865-1.866c-.39-.684-.549-1.507-.613-2.709A.735.735 0 0 1 .784 10c.407 0 .737.325.76.732.009.157.02.306.032.447.073.812.206 1.244.384 1.555a3.5 3.5 0 0 0 1.306 1.306c.311.178.743.311 1.555.384.142.013.29.023.447.032Z"/></svg>`,CHECKMARK_ICON:(0,a.YP)`<svg width="13" height="12" viewBox="0 0 13 12"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.155.132a.75.75 0 0 1 .232 1.035L5.821 11.535a1 1 0 0 1-1.626.09L.665 7.21a.75.75 0 1 1 1.17-.937L4.71 9.867a.25.25 0 0 0 .406-.023L11.12.364a.75.75 0 0 1 1.035-.232Z" fill="#fff"/></svg>`,SEARCH_ICON:(0,a.YP)`<svg width="20" height="21"><path fill-rule="evenodd" clip-rule="evenodd" d="M12.432 13.992c-.354-.353-.91-.382-1.35-.146a5.5 5.5 0 1 1 2.265-2.265c-.237.441-.208.997.145 1.35l3.296 3.296a.75.75 0 1 1-1.06 1.061l-3.296-3.296Zm.06-5a4 4 0 1 1-8 0 4 4 0 0 1 8 0Z" fill="#949E9E"/></svg>`,WALLET_PLACEHOLDER:(0,a.YP)`<svg width="60" height="60" fill="none" viewBox="0 0 60 60"><g clip-path="url(#q)"><path id="wallet-placeholder-fill" fill="#fff" d="M0 24.9c0-9.251 0-13.877 1.97-17.332a15 15 0 0 1 5.598-5.597C11.023 0 15.648 0 24.9 0h10.2c9.252 0 13.877 0 17.332 1.97a15 15 0 0 1 5.597 5.598C60 11.023 60 15.648 60 24.9v10.2c0 9.252 0 13.877-1.97 17.332a15.001 15.001 0 0 1-5.598 5.597C48.977 60 44.352 60 35.1 60H24.9c-9.251 0-13.877 0-17.332-1.97a15 15 0 0 1-5.597-5.598C0 48.977 0 44.352 0 35.1V24.9Z"/><path id="wallet-placeholder-dash" stroke="#000" stroke-dasharray="4 4" stroke-width="1.5" d="M.04 41.708a231.598 231.598 0 0 1-.039-4.403l.75-.001L.75 35.1v-2.55H0v-5.1h.75V24.9l.001-2.204h-.75c.003-1.617.011-3.077.039-4.404l.75.016c.034-1.65.099-3.08.218-4.343l-.746-.07c.158-1.678.412-3.083.82-4.316l.713.236c.224-.679.497-1.296.827-1.875a14.25 14.25 0 0 1 1.05-1.585L3.076 5.9A15 15 0 0 1 5.9 3.076l.455.596a14.25 14.25 0 0 1 1.585-1.05c.579-.33 1.196-.603 1.875-.827l-.236-.712C10.812.674 12.217.42 13.895.262l.07.746C15.23.89 16.66.824 18.308.79l-.016-.75C19.62.012 21.08.004 22.695.001l.001.75L24.9.75h2.55V0h5.1v.75h2.55l2.204.001v-.75c1.617.003 3.077.011 4.404.039l-.016.75c1.65.034 3.08.099 4.343.218l.07-.746c1.678.158 3.083.412 4.316.82l-.236.713c.679.224 1.296.497 1.875.827a14.24 14.24 0 0 1 1.585 1.05l.455-.596A14.999 14.999 0 0 1 56.924 5.9l-.596.455c.384.502.735 1.032 1.05 1.585.33.579.602 1.196.827 1.875l.712-.236c.409 1.233.663 2.638.822 4.316l-.747.07c.119 1.264.184 2.694.218 4.343l.75-.016c.028 1.327.036 2.787.039 4.403l-.75.001.001 2.204v2.55H60v5.1h-.75v2.55l-.001 2.204h.75a231.431 231.431 0 0 1-.039 4.404l-.75-.016c-.034 1.65-.099 3.08-.218 4.343l.747.07c-.159 1.678-.413 3.083-.822 4.316l-.712-.236a10.255 10.255 0 0 1-.827 1.875 14.242 14.242 0 0 1-1.05 1.585l.596.455a14.997 14.997 0 0 1-2.824 2.824l-.455-.596c-.502.384-1.032.735-1.585 1.05-.579.33-1.196.602-1.875.827l.236.712c-1.233.409-2.638.663-4.316.822l-.07-.747c-1.264.119-2.694.184-4.343.218l.016.75c-1.327.028-2.787.036-4.403.039l-.001-.75-2.204.001h-2.55V60h-5.1v-.75H24.9l-2.204-.001v.75a231.431 231.431 0 0 1-4.404-.039l.016-.75c-1.
1065-.034-3.08-.099-4.343-.218l-.07.747c-1.678-.159-3.083-.413-4.316-.822l.236-.712a10.258 10.258 0 0 1-1.875-.827 14.252 14.252 0 0 1-1.585-1.05l-.455.596A14.999 14.999 0 0 1 3.076 54.1l.596-.455a14.24 14.24 0 0 1-1.05-1.585 10.259 10.259 0 0 1-.827-1.875l-.712.236C.674 49.188.42 47.783.262 46.105l.746-.07C.89 44.77.824 43.34.79 41.692l-.75.016Z"/><path fill="#fff" fill-rule="evenodd" d="M35.643 32.145c-.297-.743-.445-1.114-.401-1.275a.42.42 0 0 1 .182-.27c.134-.1.463-.1 1.123-.1.742 0 1.499.046 2.236-.05a6 6 0 0 0 5.166-5.166c.051-.39.051-.855.051-1.784 0-.928 0-1.393-.051-1.783a6 6 0 0 0-5.166-5.165c-.39-.052-.854-.052-1.783-.052h-7.72c-4.934 0-7.401 0-9.244 1.051a8 8 0 0 0-2.985 2.986C16.057 22.28 16.003 24.58 16 29 15.998 31.075 16 33.15 16 35.224A7.778 7.778 0 0 0 23.778 43H28.5c1.394 0 2.09 0 2.67-.116a6 6 0 0 0 4.715-4.714c.115-.58.115-1.301.115-2.744 0-1.31 0-1.964-.114-2.49a4.998 4.998 0 0 0-.243-.792Z" clip-rule="evenodd"/><path fill="#9EA9A9" fill-rule="evenodd" d="M37 18h-7.72c-2.494 0-4.266.002-5.647.126-1.361.122-2.197.354-2.854.728a6.5 6.5 0 0 0-2.425 2.426c-.375.657-.607 1.492-.729 2.853-.11 1.233-.123 2.777-.125 4.867 0 .7 0 1.05.097 1.181.096.13.182.181.343.2.163.02.518-.18 1.229-.581a6.195 6.195 0 0 1 3.053-.8H37c.977 0 1.32-.003 1.587-.038a4.5 4.5 0 0 0 3.874-3.874c.036-.268.039-.611.039-1.588 0-.976-.003-1.319-.038-1.587a4.5 4.5 0 0 0-3.875-3.874C38.32 18.004 37.977 18 37 18Zm-7.364 12.5h-7.414a4.722 4.722 0 0 0-4.722 4.723 6.278 6.278 0 0 0 6.278 6.278H28.5c1.466 0 1.98-.008 2.378-.087a4.5 4.5 0 0 0 3.535-3.536c.08-.397.087-.933.087-2.451 0-1.391-.009-1.843-.08-2.17a3.5 3.5 0 0 0-2.676-2.676c-.328-.072-.762-.08-2.108-.08Z" clip-rule="evenodd"/></g><defs><clipPath id="q"><path fill="#fff" d="M0 0h60v60H0z"/></clipPath></defs></svg>`,GLOBE_ICON:(0,a.YP)`<svg width="16" height="16" fill="none" viewBox="0 0 16 16"><path fill="#fff" fill-rule="evenodd" d="M15.5 8a7.5 7.5 0 1 1-15 0 7.5 7.5 0 0 1 15 0Zm-2.113.75c.301 0 .535.264.47.558a6.01 6.01 0 0 1-2.867 3.896c-.203.116-.42-.103-.334-.32.409-1.018.691-2.274.797-3.657a.512.512 0 0 1 .507-.477h1.427Zm.47-2.058c.065.294-.169.558-.47.558H11.96a.512.512 0 0 1-.507-.477c-.106-1.383-.389-2.638-.797-3.656-.087-.217.13-.437.333-.32a6.01 6.01 0 0 1 2.868 3.895Zm-4.402.558c.286 0 .515-.24.49-.525-.121-1.361-.429-2.534-.83-3.393-.279-.6-.549-.93-.753-1.112a.535.535 0 0 0-.724 0c-.204.182-.474.513-.754 1.112-.4.859-.708 2.032-.828 3.393a.486.486 0 0 0 .49.525h2.909Zm-5.415 0c.267 0 .486-.21.507-.477.106-1.383.389-2.638.797-3.656.087-.217-.13-.437-.333-.32a6.01 6.01 0 0 0-2.868 3.895c-.065.294.169.558.47.558H4.04ZM2.143 9.308c-.065-.294.169-.558.47-.558H4.04c.267 0 .486.21.507.477.106 1.383.389 2.639.797 3.657.087.217-.13.436-.333.32a6.01 6.01 0 0 1-2.868-3.896Zm3.913-.033a.486.486 0 0 1 .49-.525h2.909c.286 0 .515.24.49.525-.121 1.361-.428 2.535-.83 3.394-.279.6-.549.93-.753 1.112a.535.535 0 0 1-.724 0c-.204-.182-.474-.513-.754-1.112-.4-.859-.708-2.033-.828-3.394Z" clip-rule="evenodd"/></svg>`},L=(0,r.iv)`.wcm-toolbar-placeholder{top:0;bottom:0;left:0;right:0;width:100%;position:absolute;display:block;pointer-events:none;height:100px;border-radius:calc(var(--wcm-background-border-radius) * .9);background-color:var(--wcm-background-color);background-position:center;background-size:cover}.wcm-toolbar{height:38px;display:flex;position:relative;margin:5px 15px 5px 5px;justify-content:space-between;align-items:center}.wcm-toolbar img,.wcm-toolbar svg{height:28px;object-position:left center;object-fit:contain}#wcm-wc-logo path{fill:var(--wcm-accent-fill-color)}button{width:28px;height:28px;border-radius:var(--wcm-icon-button-border-radius);border:0;display:flex;justify-content:center;align-items:center;cursor:pointer;background-color:var(--wcm-color-bg-1);box-shadow:0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-bg-2)}button svg{display:block;object-position:center}button path{fill:var(--wcm-color-fg-1)}.wcm-toolbar div{display:flex}@media(hover:hover){button:hover{background-color:var(--wcm-color-bg-2)}}`;var $=Object.defineProperty,j=Object.getOwnPropertyDescriptor;let D=class extends r.oi{render(){return(0,r.dy)`<div class="wcm-toolbar-placeholder"></div><div class="wcm-toolbar">${k.WALLET_CONNECT_LOGO} <button @click="${o.jb.close}">${k.CROSS_ICON}</button></div>`}};D.styles=[b.globalCss,L],D=((e,t,i,r)=>{for(var s,n=r>1?void 0:r?j(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&$(t,i,n),n})([(0,s.Mo)("wcm-modal-backcard")],D);let M=(0,r.iv)`main{padding:20px;padding-top:0;width:100%}`;var U=Object.defineProperty,q=Object.getOwnPropertyDescriptor;let B=class extends r.oi{render(){return(0,r.dy)`<main><slot></slot></main>`}};B.styles=[b.globalCss,M],B=((e,t,i,r)=>{for(var s,n=r>1?void 0:r?q(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&U(t,i,n),n})([(0,s.Mo)("wcm-modal-content")],B);let z=(0,r.iv)`footer{padding:10px;display:flex;flex-direction:column;align-items:inherit;justify-content:inherit;border-top:1px solid var(--wcm-color-bg-2)}`;var H=Object.defineProperty,V=Object.getOwnPropertyDescriptor;let W=class extends r.oi{render(){return(0,r.dy)`<footer><slot></slot></footer>`}};W.styles=[b.globalCss,z],W=((e,t,i,r)=>{for(var s,n=r>1?void 0:r?V(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&H(t,i,n),n})([(0,s.Mo)("wcm-modal-footer")],W);let K=(0,r.iv)`header{display:flex;justify-content:center;align-items:center;padding:20px;position:relative}.wcm-border{border-bottom:1px solid var(--wcm-color-bg-2);margin-bottom:20px}header button{padding:15px 20px}header button:active{opacity:.5}@media(hover:hover){header button:hover{opacity:.5}}.wcm-back-btn{position:absolute;
10left:0}.wcm-action-btn{position:absolute;right:0}path{fill:var(--wcm-accent-color)}`;var F=Object.defineProperty,J=Object.getOwnPropertyDescriptor,G=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?J(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&F(t,i,n),n};let Y=class extends r.oi{constructor(){super(...arguments),this.title="",this.onAction=void 0,this.actionIcon=void 0,this.border=!1}backBtnTemplate(){return(0,r.dy)`<button class="wcm-back-btn" @click="${o.AV.goBack}">${k.BACK_ICON}</button>`}actionBtnTemplate(){return(0,r.dy)`<button class="wcm-action-btn" @click="${this.onAction}">${this.actionIcon}</button>`}render(){let e={"wcm-border":this.border},t=o.AV.state.history.length>1,i=this.title?(0,r.dy)`<wcm-text variant="big-bold">${this.title}</wcm-text>`:(0,r.dy)`<slot></slot>`;return(0,r.dy)`<header class="${(0,n.$)(e)}">${t?this.backBtnTemplate():null} ${i} ${this.onAction?this.actionBtnTemplate():null}</header>`}};Y.styles=[b.globalCss,K],G([(0,s.Cb)()],Y.prototype,"title",2),G([(0,s.Cb)()],Y.prototype,"onAction",2),G([(0,s.Cb)()],Y.prototype,"actionIcon",2),G([(0,s.Cb)({type:Boolean})],Y.prototype,"border",2),Y=G([(0,s.Mo)("wcm-modal-header")],Y);let Z={MOBILE_BREAKPOINT:600,WCM_RECENT_WALLET_DATA:"WCM_RECENT_WALLET_DATA",EXPLORER_WALLET_URL:"https://explorer.walletconnect.com/?type=wallet",getShadowRootElement(e,t){let i=e.renderRoot.querySelector(t);if(!i)throw Error(`${t} not found`);return i},getWalletIcon({id:e,image_id:t}){let{walletImages:i}=o.ConfigCtrl.state;return(null==i?void 0:i[e])?i[e]:t?o.ExplorerCtrl.getWalletImageUrl(t):""},getWalletName:(e,t=!1)=>t&&e.length>8?`${e.substring(0,8)}..`:e,isMobileAnimation:()=>window.innerWidth<=Z.MOBILE_BREAKPOINT,preloadImage:async e=>Promise.race([new Promise((t,i)=>{let r=new Image;r.onload=t,r.onerror=i,r.crossOrigin="anonymous",r.src=e}),o.zv.wait(3e3)]),getErrorMessage:e=>e instanceof Error?e.message:"Unknown Error",debounce(e,t=500){let i;return(...r)=>{i&&clearTimeout(i),i=setTimeout(function(){e(...r)},t)}},handleMobileLinking(e,t="_self"){let{walletConnectUri:i}=o.OptionsCtrl.state,{mobile:r,name:s}=e,n=null==r?void 0:r.native,a=null==r?void 0:r.universal;Z.setRecentWallet(e),i&&function(e){if(n){let i=o.zv.formatNativeUrl(n,e,s);o.zv.openHref(i,t)}else if(a){let i=o.zv.formatUniversalUrl(a,e,s);o.zv.openHref(i,t)}}(i)},handleAndroidLinking(){let{walletConnectUri:e}=o.OptionsCtrl.state;e&&(o.zv.setWalletConnectAndroidDeepLink(e),o.zv.openHref(e,o.zv.isTelegram()?"_blank":"_self"))},async handleUriCopy(){let{walletConnectUri:e}=o.OptionsCtrl.state;if(e)try{await navigator.clipboard.writeText(e),o.ToastCtrl.openToast("Link copied","success")}catch(e){o.ToastCtrl.openToast("Failed to copy","error")}},getCustomImageUrls(){let{walletImages:e}=o.ConfigCtrl.state;return Object.values(Object.values(null!=e?e:{}))},truncate:(e,t=8)=>e.length<=t?e:`${e.substring(0,4)}...${e.substring(e.length-4)}`,setRecentWallet(e){try{localStorage.setItem(Z.WCM_RECENT_WALLET_DATA,JSON.stringify(e))}catch(e){console.info("Unable to set recent wallet")}},getRecentWallet(){try{let e=localStorage.getItem(Z.WCM_RECENT_WALLET_DATA);if(e)return JSON.parse(e)}catch(e){console.info("Unable to get recent wallet")}},caseSafeIncludes:(e,t)=>e.toUpperCase().includes(t.toUpperCase()),openWalletExplorerUrl(){o.zv.openHref(Z.EXPLORER_WALLET_URL,"_blank")},getCachedRouterWalletPlatforms(){let{desktop:e,mobile:t}=o.zv.getWalletRouterData(),i=!!(null==e?void 0:e.native),r=!!(null==e?void 0:e.universal);return{isDesktop:i,isMobile:!!(null==t?void 0:t.native)||!!(null==t?void 0:t.universal),isWeb:r}},goToConnectingView(e){o.AV.setData({Wallet:e});let t=o.zv.isMobile(),{isDesktop:i,isWeb:r,isMobile:s}=Z.getCachedRouterWalletPlatforms();t?s?(o.AV.push("MobileConnecting"),!o.zv.isAndroid()&&o.zv.isTelegram()&&this.handleMobileLinking(e,"_blank")):r?o.AV.push("WebConnecting"):o.AV.push("InstallWallet"):i?o.AV.push("DesktopConnecting"):r?o.AV.push("WebConnecting"):s?o.AV.push("MobileQrcodeConnecting"):o.AV.push("InstallWallet")}},Q=(0,r.iv)`.wcm-router{overflow:hidden;will-change:transform}.wcm-content{display:flex;flex-direction:column}`;var X=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,et=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?ee(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&X(t,i,n),n};let ei=class extends r.oi{constructor(){super(),this.view=o.AV.state.view,this.prevView=o.AV.state.view,this.unsubscribe=void 0,this.oldHeight="0px",this.resizeObserver=void 0,this.unsubscribe=o.AV.subscribe(e=>{this.view!==e.view&&this.onChangeRoute()})}firstUpdated(){this.resizeObserver=new ResizeObserver(([e])=>{let t=`${e.contentRect.height}px`;"0px"!==this.oldHeight&&(0,c.j)(this.routerEl,{height:[this.oldHeight,t]},{duration:.2}),this.oldHeight=t}),this.resizeObserver.observe(this.contentEl)}disconnectedCallback(){var e,t;null==(e=this.unsubscribe)||e.call(this),null==(t=this.resizeObserver)||t.disconnect()}get routerEl(){return Z.getShadowRootElement(this,".wcm-router")}get contentEl(){return Z.getShadowRootElement(this,".wcm-content")}viewTemplate(){switch(this.view){case"ConnectWallet":return(0,r.dy)`<wcm-connect-wallet-view></wcm-connect-wallet-view>`;case"DesktopConnecting":return(0,r.dy)`<wcm-desktop-connecting-view></wcm-desktop-connecting-view>`;case"MobileConnecting":return(0,r.dy)`<wcm-mobile-connecting-view></wcm-mobile-connecting-view>`;case"WebConnecting":return(0,r.dy)`<wcm-web-connecting-view></wcm-web-connecting-view>`;case"MobileQrcodeConnecting":return(0,r.dy)`<wcm-mobile-qr-connecting-view></wcm-mobile-qr-connecting-view>`;case"WalletExplorer":return(0,r.dy)`<wcm-wallet-explorer-view></wcm-wallet-explorer-view>`;case"Qrcode":return(0,r.dy)`<wcm-qrcode-view></wcm-qrcode-view>`;case"InstallWallet":return(0,r.dy)`<wcm-install-wallet-view></wcm-install-wallet-view>`;default:return(0,r.dy)`<div>Not Found</div>`}}async onChangeRoute(){await (0,c.j)(this.routerEl,{opacity:[1,0],scale:[1,1.02]},{duration:.15,delay:.1}).finished,this.view=o.AV.state.view,(0,c.j)(this.routerEl,{opacity:[0,1],scale:[.99,1]},{duration:.37,delay:.05})}render(){return(0,r.dy)`<div class="wcm-router"><div class="wcm-content">${this.viewTemplate()}</div></div>`}};ei.styles=[b.globalCss,Q],et([(0,s.SB)()],ei.prototype,"view",2),et([(0,s.SB)()],ei.prototype,"prevView",2),ei=et([(0,s.Mo)("wcm-modal-router")],ei);let er=(0,r.iv)`div{height:36px;width:max-content;display:flex;justify-content:center;align-items:center;padding:9px 15px 11px;position:absolute;top:12px;box-shadow:0 6px 14px -6px rgba(10,16,31,.3),0 10px 32px -4px rgba(10,16,31,.15);z-index:2;left:50%;transform:translateX(-50%);pointer-events:none;backdrop-filter:blur(20px) saturate(1.8);-webkit-backdrop-filter:blur(20px) saturate(1.8);border-radius:var(--wcm-notification-border-radius);border:1px solid var(--wcm-color-overlay);background-color:var(--wcm-color-overlay)}svg{margin-right:5px}@-moz-document url-prefix(){div{background-color:var(--wcm-color-bg-3)}}
10.wcm-success path{fill:var(--wcm-accent-color)}.wcm-error path{fill:var(--wcm-error-color)}`;var es=Object.defineProperty,en=Object.getOwnPropertyDescriptor,eo=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?en(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&es(t,i,n),n};let ea=class extends r.oi{constructor(){super(),this.open=!1,this.unsubscribe=void 0,this.timeout=void 0,this.unsubscribe=o.ToastCtrl.subscribe(e=>{e.open?(this.open=!0,this.timeout=setTimeout(()=>o.ToastCtrl.closeToast(),2200)):(this.open=!1,clearTimeout(this.timeout))})}disconnectedCallback(){var e;null==(e=this.unsubscribe)||e.call(this),clearTimeout(this.timeout),o.ToastCtrl.closeToast()}render(){let{message:e,variant:t}=o.ToastCtrl.state;return this.open?(0,r.dy)`<div class="${(0,n.$)({"wcm-success":"success"===t,"wcm-error":"error"===t})}">${"success"===t?k.CHECKMARK_ICON:null} ${"error"===t?k.CROSS_ICON:null}<wcm-text variant="small-regular">${e}</wcm-text></div>`:null}};function ec(e,t,i){return e!==t&&(e-t<0?t-e:e-t)<=i+.1}ea.styles=[b.globalCss,er],eo([(0,s.SB)()],ea.prototype,"open",2),ea=eo([(0,s.Mo)("wcm-modal-toast")],ea);let el={generate(e,t,i){let s="#141414",n=[],o=function(e,t){let i=Array.prototype.slice.call(h.create(e,{errorCorrectionLevel:"Q"}).modules.data,0),r=Math.sqrt(i.length);return i.reduce((e,t,i)=>(i%r==0?e.push([t]):e[e.length-1].push(t))&&e,[])}(e,0),a=t/o.length,c=[{x:0,y:0},{x:1,y:0},{x:0,y:1}];c.forEach(({x:e,y:t})=>{let i=(o.length-7)*a*e,l=(o.length-7)*a*t;for(let e=0;e<c.length;e+=1){let t=a*(7-2*e);n.push((0,r.YP)`<rect fill="${e%2==0?s:"#ffffff"}" height="${t}" rx="${.45*t}" ry="${.45*t}" width="${t}" x="${i+a*e}" y="${l+a*e}">`)}});let l=Math.floor((i+25)/a),d=o.length/2-l/2,u=o.length/2+l/2-1,p=[];o.forEach((e,t)=>{e.forEach((e,i)=>{!o[t][i]||t<7&&i<7||t>o.length-8&&i<7||t<7&&i>o.length-8||t>d&&t<u&&i>d&&i<u||p.push([t*a+a/2,i*a+a/2])})});let g={};return p.forEach(([e,t])=>{g[e]?g[e].push(t):g[e]=[t]}),Object.entries(g).map(([e,t])=>{let i=t.filter(e=>t.every(t=>!ec(e,t,a)));return[Number(e),i]}).forEach(([e,t])=>{t.forEach(t=>{n.push((0,r.YP)`<circle cx="${e}" cy="${t}" fill="${s}" r="${a/2.5}">`)})}),Object.entries(g).filter(([e,t])=>t.length>1).map(([e,t])=>{let i=t.filter(e=>t.some(t=>
10ec(e,t,a)));return[Number(e),i]}).map(([e,t])=>{t.sort((e,t)=>e<t?-1:1);let i=[];for(let e of t){let t=i.find(t=>t.some(t=>ec(e,t,a)));t?t.push(e):i.push([e])}return[e,i.map(e=>[e[0],e[e.length-1]])]}).forEach(([e,t])=>{t.forEach(([t,i])=>{n.push((0,r.YP)`<line x1="${e}" x2="${e}" y1="${t}" y2="${i}" stroke="${s}" stroke-width="${a/1.25}" stroke-linecap="round">`)})}),n}},eh=(0,r.iv)`@keyframes fadeIn{0%{opacity:0}100%{opacity:1}}div{position:relative;user-select:none;display:block;overflow:hidden;aspect-ratio:1/1;animation:fadeIn ease .2s}.wcm-dark{background-color:#fff;border-radius:var(--wcm-container-border-radius);padding:18px;box-shadow:0 2px 5px #000}svg:first-child,wcm-wallet-image{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{transform:translateY(-50%) translateX(-50%)}wcm-wallet-image{width:25%;height:25%;border-radius:var(--wcm-wallet-icon-border-radius)}svg:first-child{transform:translateY(-50%) translateX(-50%) scale(.9)}svg:first-child path:first-child{fill:var(--wcm-accent-color)}svg:first-child path:last-child{stroke:var(--wcm-color-overlay)}`;var ed=Object.defineProperty,eu=Object.getOwnPropertyDescriptor,ep=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?eu(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&ed(t,i,n),n};let eg=class extends r.oi{constructor(){super(...arguments),this.uri="",this.size=0,this.imageId=void 0,this.walletId=void 0,this.imageUrl=void 0}svgTemplate(){let e="light"===o.ThemeCtrl.state.themeMode?this.size:this.size-36;return(0,r.YP)`<svg height="${e}" width="${e}">${el.generate(this.uri,e,e/4)}</svg>`}render(){let e={"wcm-dark":"dark"===o.ThemeCtrl.state.themeMode};return(0,r.dy)`<div style="${`width: ${this.size}px`}" class="${(0,n.$)(e)}">${this.walletId||this.imageUrl?(0,r.dy)`<wcm-wallet-image walletId="${(0,l.o)(this.walletId)}" imageId="${(0,l.o)(this.imageId)}" imageUrl="${(0,l.o)(this.imageUrl)}"></wcm-wallet-image>`:k.WALLET_CONNECT_ICON_COLORED} ${this.svgTemplate()}</div>`}};eg.styles=[b.globalCss,eh],ep([(0,s.Cb)()],eg.prototype,"uri",2),ep([(0,s.Cb)({type:Number})],eg.prototype,"size",2),ep([(0,s.Cb)()],eg.prototype,"imageId",2),ep([(0,s.Cb)()],eg.prototype,"walletId",2),ep([(0,s.Cb)()],eg.prototype,"imageUrl",2),eg=ep([(0,s.Mo)("wcm-qrcode")],eg);let ef=(0,r.iv)`:host{position:relative;height:28px;width:80%}input{width:100%;height:100%;line-height:28px!important;border-radius:var(--wcm-input-border-radius);font-style:normal;font-family:-apple-system,system-ui,BlinkMacSystemFont,'Segoe UI',Roboto,Ubuntu,'Helvetica Neue',sans-serif;font-feature-settings:'case' on;font-weight:500;font-size:16px;letter-spacing:-.03em;padding:0 10px 0 34px;transition:.2s all ease;color:var(--wcm-color-fg-1);background-color:var(--wcm-color-bg-3);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay);caret-color:var(--wcm-accent-color)}input::placeholder{color:var(--wcm-color-fg-2)}svg{left:10px;top:4px;pointer-events:none;position:absolute;width:20px;height:20px}input:focus-within{box-shadow:inset 0 0 0 1px var(--wcm-accent-color)}path{fill:var(--wcm-color-fg-2)}`;var em=Object.defineProperty,ey=Object.getOwnPropertyDescriptor,eb=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?ey(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&em(t,i,n),n};let ew=class extends r.oi{constructor(){super(...arguments),this.onChange=()=>null}render(){return(0,r.dy)`<input type="text" @input="${this.onChange}" placeholder="Search wallets"> ${k.SEARCH_ICON}`}};ew.styles=[b.globalCss,ef],eb([(0,s.Cb)()],ew.prototype,"onChange",2),ew=eb([(0,s.Mo)("wcm-search-input")],ew);let ev=(0,r.iv)`@keyframes rotate{100%{transform:rotate(360deg)}}@keyframes dash{0%{stroke-dasharray:1,150;stroke-dashoffset:0}50%{stroke-dasharray:90,150;stroke-dashoffset:-35}100%{stroke-dasharray:90,150;stroke-dashoffset:-124}}svg{animation:rotate 2s linear infinite;display:flex;justify-content:center;align-items:center}svg circle{stroke-linecap:round;animation:dash 1.5s ease infinite;stroke:var(--wcm-accent-color)}`;var eE=Object.defineProperty,e_=Object.getOwnPropertyDescriptor;let eI=class extends r.oi{render(){return(0,r.dy)`<svg viewBox="0 0 50 50" width="24" height="24"><circle cx="25" cy="25" r="20" fill="none" stroke-width="4" stroke="#fff"/></svg>`}};eI.styles=[b.globalCss,ev],eI=((e,t,i,r)=>{for(var s,n=r>1?void 0:r?e_(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&eE(t,i,n),n})([(0,s.Mo)("wcm-spinner")],eI);let ex=(0,r.iv)`span{font-style:normal;font-family:var(--wcm-font-family);font-feature-settings:var(--wcm-font-feature-settings)}.wcm-xsmall-bold{font-family:var(--wcm-text-xsmall-bold-font-family);font-weight:var(--wcm-text-xsmall-bold-weight);font-size:var(--wcm-text-xsmall-bold-size);line-height:var(--wcm-text-xsmall-bold-line-height);letter-spacing:var(--wcm-text-xsmall-bold-letter-spacing);text-transform:var(--wcm-text-xsmall-bold-text-transform)}.wcm-xsmall-regular{font-family:var(--wcm-text-xsmall-regular-font-family);font-weight:var(--wcm-text-xsmall-regular-weight);font-size:var(--wcm-text-xsmall-regular-size);line-height:var(--wcm-text-xsmall-regular-line-height);letter-spacing:var(--wcm-text-xsmall-regular-letter-spacing);text-transform:var(--wcm-text-xsmall-regular-text-transform)}.wcm-small-thin{font-family:var(--wcm-text-small-thin-font-family);font-weight:var(--wcm-text-small-thin-weight);font-size:var(--wcm-text-small-thin-size);line-height:var(--wcm-text-small-thin-line-height);letter-spacing:var(--wcm-text-small-thin-letter-spacing);text-transform:var(--wcm-text-small-thin-text-transform)}.wcm-small-regular{font-family:var(--wcm-text-small-regular-font-family);font-weight:var(--wcm-text-small-regular-weight);font-size:var(--wcm-text-small-regular-size);line-height:var(--wcm-text-small-regular-line-height);letter-spacing:var(--wcm-text-small-regular-letter-spacing);text-transform:var(--wcm-text-small-regular-text-transform)}.wcm-medium-regular{font-family:var(--wcm-text-medium-regular-font-family);font-weight:var(--wcm-text-medium-regular-weight);font-size:var(--wcm-text-medium-regular-size);line-height:var(--wcm-text-medium-regular-line-height);letter-spacing:var(--wcm-text-medium-regular-letter-spacing);text-transform:var(--wcm-text-medium-regular-text-transform)}.wcm-big-bold{font-family:var(--wcm-text-big-bold-font-family);font-weight:var(--wcm-text-big-bold-weight);font-size:var(--wcm-text-big-bold-size);line-height:var(--wcm-text-big-bold-line-height);letter-spacing:var(--wcm-text-big-bold-letter-spacing);text-transform:var(--wcm-text-big-bold-text-transform)}:host(*){color:var(--wcm-color-fg-1)}.wcm-color-primary{color:var(--wcm-color-fg-1)}.wcm-color-secondary{color:var(--wcm-color-fg-2)}.wcm-color-tertiary{color:var(--wcm-color-fg-3)}.wcm-color-inverse{color:var(--wcm-accent-fill-color)}.wcm-color-accnt{color:var(--wcm-accent-color)}.wcm-color-error{color:var(--wcm-error-color)}`;var eO=Object.defineProperty,eP=Object.getOwnPropertyDescriptor,eS=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?eP(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&eO(t,i,n),n};let eC=class extends r.oi{constructor(){super(...arguments),this.variant="medium-regular",this.color="primary"}render(){let e={"wcm-big-bold":"big-bold"===this.variant,"wcm-medium-regular":"medium-regular"===this.variant,"wcm-small-regular":"small-regular"===this.variant,"wcm-small-thin":"small-thin"===this.variant,"wcm-xsmall-regular":"xsmall-regular"===this.variant,"wcm-xsmall-bold":"xsmall-bold"===this.variant,"wcm-color-primary":"primary"===this.color,"wcm-color-secondary":"secondary"===this.color,"wcm-color-tertiary":"tertiary"===this.color,"wcm-color-inverse":"inverse"===this.color,"wcm-color-accnt":"accent"===this.color,"wcm-color-error":"error"===this.color};return(0,r.dy)`<span><slot class="${(0,n.$)(e)}"></slot></span>`}};eC.styles=[b.globalCss,ex],eS([(0,s.Cb)()],eC.prototype,"variant",2),eS([(0,s.Cb)()],eC.prototype,"color",2),eC=eS([(0,s.Mo)("wcm-text")],eC);let eR=(0,r.iv)`button{width:100%;height:100%;border-radius:var(--wcm-button-hover-highlight-border-radius);
10display:flex;align-items:flex-start}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}button>div{width:80px;padding:5px 0;display:flex;flex-direction:column;align-items:center}wcm-text{width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;text-align:center}wcm-wallet-image{height:60px;width:60px;transition:all .2s ease;border-radius:var(--wcm-wallet-icon-border-radius);margin-bottom:5px}.wcm-sublabel{margin-top:2px}`;var eA=Object.defineProperty,eT=Object.getOwnPropertyDescriptor,eN=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?eT(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&eA(t,i,n),n};let ek=class extends r.oi{constructor(){super(...arguments),this.onClick=()=>null,this.name="",this.walletId="",this.label=void 0,this.imageId=void 0,this.installed=!1,this.recent=!1}sublabelTemplate(){return this.recent?(0,r.dy)`<wcm-text class="wcm-sublabel" variant="xsmall-bold" color="tertiary">RECENT</wcm-text>`:this.installed?(0,r.dy)`<wcm-text class="wcm-sublabel" variant="xsmall-bold" color="tertiary">INSTALLED</wcm-text>`:null}handleClick(){o.uA.click({name:"WALLET_BUTTON",walletId:this.walletId}),this.onClick()}render(){var e;return(0,r.dy)`<button @click="${this.handleClick.bind(this)}"><div><wcm-wallet-image walletId="${this.walletId}" imageId="${(0,l.o)(this.imageId)}"></wcm-wallet-image><wcm-text variant="xsmall-regular">${null!=(e=this.label)?e:Z.getWalletName(this.name,!0)}</wcm-text>${this.sublabelTemplate()}</div></button>`}};ek.styles=[b.globalCss,eR],eN([(0,s.Cb)()],ek.prototype,"onClick",2),eN([(0,s.Cb)()],ek.prototype,"name",2),eN([(0,s.Cb)()],ek.prototype,"walletId",2),eN([(0,s.Cb)()],ek.prototype,"label",2),eN([(0,s.Cb)()],ek.prototype,"imageId",2),eN([(0,s.Cb)({type:Boolean})],ek.prototype,"installed",2),eN([(0,s.Cb)({type:Boolean})],ek.prototype,"recent",2),ek=eN([(0,s.Mo)("wcm-wallet-button")],ek);let eL=(0,r.iv)`:host{display:block}div{overflow:hidden;position:relative;border-radius:inherit;width:100%;height:100%;background-color:var(--wcm-color-overlay)}svg{position:relative;width:100%;height:100%}div::after{content:'';position:absolute;top:0;bottom:0;left:0;right:0;border-radius:inherit;border:1px solid var(--wcm-color-overlay)}div img{width:100%;height:100%;object-fit:cover;object-position:center}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var e$=Object.defineProperty,ej=Object.getOwnPropertyDescriptor,eD=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?ej(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&e$(t,i,n),n};let eM=class extends r.oi{constructor(){super(...arguments),this.walletId="",this.imageId=void 0,this.imageUrl=void 0}render(){var e;let t=(null==(e=this.imageUrl)?void 0:e.length)?this.imageUrl:Z.getWalletIcon({id:this.walletId,image_id:this.imageId});return(0,r.dy)`${t.length?(0,r.dy)`<div><img crossorigin="anonymous" src="${t}" alt="${this.id}"></div>`:k.WALLET_PLACEHOLDER}`}};eM.styles=[b.globalCss,eL],eD([(0,s.Cb)()],eM.prototype,"walletId",2),eD([(0,s.Cb)()],eM.prototype,"imageId",2),eD([(0,s.Cb)()],eM.prototype,"imageUrl",2),eM=eD([(0,s.Mo)("wcm-wallet-image")],eM);var eU=Object.defineProperty,eq=Object.getOwnPropertyDescriptor,eB=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?eq(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&eU(t,i,n),n};let ez=class extends r.oi{constructor(){super(),this.preload=!0,this.preloadData()}async loadImages(e){try{(null==e?void 0:e.length)&&await Promise.all(e.map(async e=>Z.preloadImage(e)))}catch(t){console.info("Unsuccessful attempt at preloading some images",e)}}async preloadListings(){if(o.ConfigCtrl.state.enableExplorer){await o.ExplorerCtrl.getRecomendedWallets(),o.OptionsCtrl.setIsDataLoaded(!0);let{recomendedWallets:e}=o.ExplorerCtrl.state,t=e.map(e=>Z.getWalletIcon(e));await this.loadImages(t)}else o.OptionsCtrl.setIsDataLoaded(!0)}async preloadCustomImages(){let e=Z.getCustomImageUrls();await this.loadImages(e)}async preloadData(){try{this.preload&&(this.preload=!1,await Promise.all([this.preloadListings(),this.preloadCustomImages()]))}catch(e){console.error(e),o.ToastCtrl.openToast("Failed preloading","error")}}};eB([(0,s.SB)()],ez.prototype,"preload",2),ez=eB([(0,s.Mo)("wcm-explorer-context")],ez);var eH=Object.defineProperty,eV=Object.getOwnPropertyDescriptor;let eW=class extends r.oi{constructor(){super(),this.unsubscribeTheme=void 0,b.setTheme(),this.unsubscribeTheme=o.ThemeCtrl.
10subscribe(b.setTheme)}disconnectedCallback(){var e;null==(e=this.unsubscribeTheme)||e.call(this)}};eW=((e,t,i,r)=>{for(var s,n=r>1?void 0:r?eV(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&eH(t,i,n),n})([(0,s.Mo)("wcm-theme-context")],eW);let eK=(0,r.iv)`@keyframes scroll{0%{transform:translate3d(0,0,0)}100%{transform:translate3d(calc(-70px * 9),0,0)}}.wcm-slider{position:relative;overflow-x:hidden;padding:10px 0;margin:0 -20px;width:calc(100% + 40px)}.wcm-track{display:flex;width:calc(70px * 18);animation:scroll 20s linear infinite;opacity:.7}.wcm-track svg{margin:0 5px}wcm-wallet-image{width:60px;height:60px;margin:0 5px;border-radius:var(--wcm-wallet-icon-border-radius)}.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-title{display:flex;align-items:center;margin-bottom:10px}.wcm-title svg{margin-right:6px}.wcm-title path{fill:var(--wcm-accent-color)}wcm-modal-footer .wcm-title{padding:0 10px}wcm-button-big{position:absolute;top:50%;left:50%;transform:translateY(-50%) translateX(-50%);filter:drop-shadow(0 0 17px var(--wcm-color-bg-1))}wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-info-footer wcm-text{text-align:center;margin-bottom:15px}#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var eF=Object.defineProperty,eJ=Object.getOwnPropertyDescriptor;let eG=class extends r.oi{onGoToQrcode(){o.AV.push("Qrcode")}render(){let{recomendedWallets:e}=o.ExplorerCtrl.state,t=[...e,...e],i=2*o.zv.RECOMMENDED_WALLET_AMOUNT;return(0,r.dy)`<wcm-modal-header title="Connect your wallet" .onAction="${this.onGoToQrcode}" .actionIcon="${k.QRCODE_ICON}"></wcm-modal-header><wcm-modal-content><div class="wcm-title">${k.MOBILE_ICON}<wcm-text variant="small-regular" color="accent">WalletConnect</wcm-text></div><div class="wcm-slider"><div class="wcm-track">${[...Array(i)].map((e,i)=>{let s=t[i%t.length];return s?(0,r.dy)`<wcm-wallet-image walletId="${s.id}" imageId="${s.image_id}"></wcm-wallet-image>`:k.WALLET_PLACEHOLDER})}</div><wcm-button-big @click="${Z.handleAndroidLinking}"><wcm-text variant="medium-regular" color="inverse">Select Wallet</wcm-text></wcm-button-big></div></wcm-modal-content><wcm-info-footer><wcm-text color="secondary" variant="small-thin">Choose WalletConnect to see supported apps on your device</wcm-text></wcm-info-footer>`}};eG.styles=[b.globalCss,eK],eG=((e,t,i,r)=>{for(var s,n=r>1?void 0:r?eJ(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&eF(t,i,n),n})([(0,s.Mo)("wcm-android-wallet-selection")],eG);let eY=(0,r.iv)`@keyframes loading{to{stroke-dashoffset:0}}@keyframes shake{10%,90%{transform:translate3d(-1px,0,0)}20%,80%{transform:translate3d(1px,0,0)}30%,50%,70%{transform:translate3d(-2px,0,0)}40%,60%{transform:translate3d(2px,0,0)}}:host{display:flex;flex-direction:column;align-items:center}div{position:relative;width:110px;height:110px;display:flex;justify-content:center;align-items:center;margin:40px 0 20px 0;transform:translate3d(0,0,0)}svg{position:absolute;width:110px;height:110px;fill:none;stroke:transparent;stroke-linecap:round;stroke-width:2px;top:0;left:0}use{stroke:var(--wcm-accent-color);animation:loading 1s linear infinite}wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:90px;height:90px}wcm-text{margin-bottom:40px}.wcm-error svg{stroke:var(--wcm-error-color)}.wcm-error use{display:none}.wcm-error{animation:shake .4s cubic-bezier(.36,.07,.19,.97) both}.wcm-stale svg,.wcm-stale use{display:none}`;var eZ=Object.defineProperty,eQ=Object.getOwnPropertyDescriptor,eX=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?eQ(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&eZ(t,i,n),n};let e0=class extends r.oi{constructor(){super(...arguments),this.walletId=void 0,this.imageId=void 0,this.isError=!1,this.isStale=!1,this.label=""}svgLoaderTemplate(){var e,t;let i=null!=(t=null==(e=o.ThemeCtrl.state.themeVariables)?void 0:e["--wcm-wallet-icon-large-border-radius"])?t:b.getPreset("--wcm-wallet-icon-large-border-radius"),s=0,n=317-1.57*(s=(i.includes("%")?.88*parseInt(i,10):parseInt(i,10))*1.17),a=425-1.8*s;return(0,r.dy)`<svg viewBox="0 0 110 110" width="110" height="110"><rect id="wcm-loader" x="2" y="2" width="106" height="106" rx="${s}"/><use xlink:href="#wcm-loader" stroke-dasharray="106 ${n}" stroke-dashoffset="${a}"></use></svg>`}render(){let e={"wcm-error":this.isError,"wcm-stale":this.isStale};return(0,r.dy)`<div class="${(0,n.$)(e)}">${this.svgLoaderTemplate()}<wcm-wallet-image walletId="${(0,l.o)(this.walletId)}" imageId="${(0,l.o)(this.imageId)}"></wcm-wallet-image></div><wcm-text variant="medium-regular" color="${this.isError?"error":"primary"}">${this.isError?"Connection declined":this.label}</wcm-text>`}};e0.styles=[b.globalCss,eY],eX([(0,s.Cb)()],e0.prototype,"walletId",2),eX([(0,s.Cb)()],e0.prototype,"imageId",2),eX([(0,s.Cb)({type:Boolean})],e0.prototype,"isError",2),eX([(0,s.Cb)({type:Boolean})],e0.prototype,"isStale",2),eX([(0,s.Cb)()],e0.prototype,"label",2),e0=eX([(0,s.Mo)("wcm-connector-waiting")],e0);let e1={manualWallets(){var e,t;let{mobileWallets:i,desktopWallets:r}=o.ConfigCtrl.state,s=null==(e=e1.recentWallet())?void 0:e.id,n=o.zv.isMobile()?i:r,a=null==n?void 0:n.filter(e=>s!==e.id);return null!=(t=o.zv.isMobile()?null==a?void 0:a.map(({id:e,name:t,links:i})=>({id:e,name:t,mobile:i,links:i})):null==a?void 0:a.map(({id:e,name:t,links:i})=>({id:e,name:t,desktop:i,links:i})))?t:[]},recentWallet:()=>Z.getRecentWallet(),recomendedWallets(e=!1){var t;let i=e?void 0:null==(t=e1.recentWallet())?void 0:t.id,{recomendedWallets:r}=o.ExplorerCtrl.state;return r.filter(e=>i!==e.id)}},e2={onConnecting(e){Z.goToConnectingView(e)},manualWalletsTemplate(){return e1.manualWallets().map(e=>
10(0,r.dy)`<wcm-wallet-button walletId="${e.id}" name="${e.name}" .onClick="${()=>this.onConnecting(e)}"></wcm-wallet-button>`)},recomendedWalletsTemplate(e=!1){return e1.recomendedWallets(e).map(e=>(0,r.dy)`<wcm-wallet-button name="${e.name}" walletId="${e.id}" imageId="${e.image_id}" .onClick="${()=>this.onConnecting(e)}"></wcm-wallet-button>`)},recentWalletTemplate(){let e=e1.recentWallet();if(e)return(0,r.dy)`<wcm-wallet-button name="${e.name}" walletId="${e.id}" imageId="${(0,l.o)(e.image_id)}" .recent="${!0}" .onClick="${()=>this.onConnecting(e)}"></wcm-wallet-button>`}},e5=(0,r.iv)`.wcm-grid{display:grid;grid-template-columns:repeat(4,80px);justify-content:space-between}.wcm-desktop-title,.wcm-mobile-title{display:flex;align-items:center}.wcm-mobile-title{justify-content:space-between;margin-bottom:20px;margin-top:-10px}.wcm-desktop-title{margin-bottom:10px;padding:0 10px}.wcm-subtitle{display:flex;align-items:center}.wcm-subtitle:last-child path{fill:var(--wcm-color-fg-3)}.wcm-desktop-title svg,.wcm-mobile-title svg{margin-right:6px}.wcm-desktop-title path,.wcm-mobile-title path{fill:var(--wcm-accent-color)}`;var e3=Object.defineProperty,e4=Object.getOwnPropertyDescriptor;let e8=class extends r.oi{render(){let{explorerExcludedWalletIds:e,enableExplorer:t}=o.ConfigCtrl.state,i=e2.manualWalletsTemplate(),s=e2.recomendedWalletsTemplate(),n=[e2.recentWalletTemplate(),...i,...s],a=(n=n.filter(Boolean)).length>4||"ALL"!==e&&t,c=[],l=!!(c=a?n.slice(0,3):n).length;return(0,r.dy)`<wcm-modal-header .border="${!0}" title="Connect your wallet" .onAction="${Z.handleUriCopy}" .actionIcon="${k.COPY_ICON}"></wcm-modal-header><wcm-modal-content><div class="wcm-mobile-title"><div class="wcm-subtitle">${k.MOBILE_ICON}<wcm-text variant="small-regular" color="accent">Mobile</wcm-text></div><div class="wcm-subtitle">${k.SCAN_ICON}<wcm-text variant="small-regular" color="secondary">Scan with your wallet</wcm-text></div></div><wcm-walletconnect-qr></wcm-walletconnect-qr></wcm-modal-content>${l?(0,r.dy)`<wcm-modal-footer><div class="wcm-desktop-title">${k.DESKTOP_ICON}<wcm-text variant="small-regular" color="accent">Desktop</wcm-text></div><div class="wcm-grid">${c} ${a?(0,r.dy)`<wcm-view-all-wallets-button></wcm-view-all-wallets-button>`:null}</div></wcm-modal-footer>`:null}`}};e8.styles=[b.globalCss,e5],e8=((e,t,i,r)=>{for(var s,n=r>1?void 0:r?e4(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&e3(t,i,n),n})([(0,s.Mo)("wcm-desktop-wallet-selection")],e8);let e6=(0,r.iv)`div{background-color:var(--wcm-color-bg-2);padding:10px 20px 15px 20px;border-top:1px solid var(--wcm-color-bg-3);text-align:center}a{color:var(--wcm-accent-color);text-decoration:none;transition:opacity .2s ease-in-out;display:inline}a:active{opacity:.8}@media(hover:hover){a:hover{opacity:.8}}`;var e7=Object.defineProperty,e9=Object.getOwnPropertyDescriptor;let te=class extends r.oi{render(){let{termsOfServiceUrl:e,privacyPolicyUrl:t}=o.ConfigCtrl.state;return(null!=e?e:t)?(0,r.dy)`<div><wcm-text variant="small-regular" color="secondary">By connecting your wallet to this app, you agree to the app's ${e?(0,r.dy)`<a href="${e}" target="_blank" rel="noopener noreferrer">Terms of Service</a>`:null} ${e&&t?"and":null} ${t?(0,r.dy)`<a href="${t}" target="_blank" rel="noopener noreferrer">Privacy Policy</a>`:null}</wcm-text></div>`:null}};te.styles=[b.globalCss,e6],te=((e,t,i,r)=>{for(var s,n=r>1?void 0:r?e9(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&e7(t,i,n),n})([(0,s.Mo)("wcm-legal-notice")],te);let tt=(0,r.iv)`div{display:grid;grid-template-columns:repeat(4,80px);margin:0 -10px;justify-content:space-between;row-gap:10px}`;var ti=Object.defineProperty,tr=Object.getOwnPropertyDescriptor;let ts=class extends r.oi{onQrcode(){o.AV.push("Qrcode")}render(){let{explorerExcludedWalletIds:e,enableExplorer:t}=o.ConfigCtrl.state,i=e2.manualWalletsTemplate(),s=e2.recomendedWalletsTemplate(),n=[e2.recentWalletTemplate(),...i,...s],a=(n=n.filter(Boolean)).length>8||"ALL"!==e&&t,c=[],l=!!(c=a?n.slice(0,7):n).length;return(0,r.dy)`<wcm-modal-header title="Connect your wallet" .onAction="${this.onQrcode}" .actionIcon="${k.QRCODE_ICON}"></wcm-modal-header>${l?(0,r.dy)`<wcm-modal-content><div>${c} ${a?(0,r.dy)`<wcm-view-all-wallets-button>
10</wcm-view-all-wallets-button>`:null}</div></wcm-modal-content>`:null}`}};ts.styles=[b.globalCss,tt],ts=((e,t,i,r)=>{for(var s,n=r>1?void 0:r?tr(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&ti(t,i,n),n})([(0,s.Mo)("wcm-mobile-wallet-selection")],ts);let tn=(0,r.iv)`:host{all:initial}.wcm-overlay{top:0;bottom:0;left:0;right:0;position:fixed;z-index:var(--wcm-z-index);overflow:hidden;display:flex;justify-content:center;align-items:center;opacity:0;pointer-events:none;background-color:var(--wcm-overlay-background-color);backdrop-filter:var(--wcm-overlay-backdrop-filter)}@media(max-height:720px) and (orientation:landscape){.wcm-overlay{overflow:scroll;align-items:flex-start;padding:20px 0}}.wcm-active{pointer-events:auto}.wcm-container{position:relative;max-width:360px;width:100%;outline:0;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) var(--wcm-container-border-radius) var(--wcm-container-border-radius);border:1px solid var(--wcm-color-overlay);overflow:hidden}.wcm-card{width:100%;position:relative;border-radius:var(--wcm-container-border-radius);overflow:hidden;box-shadow:0 6px 14px -6px rgba(10,16,31,.12),0 10px 32px -4px rgba(10,16,31,.1),0 0 0 1px var(--wcm-color-overlay);background-color:var(--wcm-color-bg-1);color:var(--wcm-color-fg-1)}@media(max-width:600px){.wcm-container{max-width:440px;border-radius:var(--wcm-background-border-radius) var(--wcm-background-border-radius) 0 0}.wcm-card{border-radius:var(--wcm-container-border-radius) var(--wcm-container-border-radius) 0 0}.wcm-overlay{align-items:flex-end}}@media(max-width:440px){.wcm-container{border:0}}`;var to=Object.defineProperty,ta=Object.getOwnPropertyDescriptor,tc=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?ta(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&to(t,i,n),n};let tl=class extends r.oi{constructor(){super(),this.open=!1,this.active=!1,this.unsubscribeModal=void 0,this.abortController=void 0,this.unsubscribeModal=o.jb.subscribe(e=>{e.open?this.onOpenModalEvent():this.onCloseModalEvent()})}disconnectedCallback(){var e;null==(e=this.unsubscribeModal)||e.call(this)}get overlayEl(){return Z.getShadowRootElement(this,".wcm-overlay")}get containerEl(){return Z.getShadowRootElement(this,".wcm-container")}toggleBodyScroll(e){if(document.querySelector("body")){if(e){let e=document.getElementById("wcm-styles");null==e||e.remove()}else document.head.insertAdjacentHTML("beforeend",'<style id="wcm-styles">html,body{touch-action:none;overflow:hidden;overscroll-behavior:contain;}</style>')}}onCloseModal(e){e.target===e.currentTarget&&o.jb.close()}onOpenModalEvent(){this.toggleBodyScroll(!1),this.addKeyboardEvents(),this.open=!0,setTimeout(async()=>{let e=Z.isMobileAnimation()?{y:["50vh","0vh"]}:{scale:[.98,1]};await Promise.all([(0,c.j)(this.overlayEl,{opacity:[0,1]},{delay:.1,duration:.2}).finished,(0,c.j)(this.containerEl,e,{delay:.1,duration:.2}).finished]),this.active=!0},0)}async onCloseModalEvent(){this.toggleBodyScroll(!0),this.removeKeyboardEvents();let e=Z.isMobileAnimation()?{y:["0vh","50vh"]}:{scale:[1,.98]};await Promise.all([(0,c.j)(this.overlayEl,{opacity:[1,0]},{duration:.2}).finished,(0,c.j)(this.containerEl,e,{duration:.2}).finished]),this.containerEl.removeAttribute("style"),this.active=!1,this.open=!1}addKeyboardEvents(){this.abortController=new AbortController,window.addEventListener("keydown",e=>{var t;"Escape"===e.key?o.jb.close():"Tab"!==e.key||(null==(t=e.target)?void 0:t.tagName.includes("wcm-"))||this.containerEl.focus()},this.abortController),this.containerEl.focus()}removeKeyboardEvents(){var e;null==(e=this.abortController)||e.abort(),this.abortController=void 0}render(){let e={"wcm-overlay":!0,"wcm-active":this.active};return(0,r.dy)`<wcm-explorer-context></wcm-explorer-context><wcm-theme-context></wcm-theme-context><div id="wcm-modal" class="${(0,n.$)(e)}" @click="${this.onCloseModal}" role="alertdialog" aria-modal="true"><div class="wcm-container" tabindex="0">${this.open?(0,r.dy)`<wcm-modal-backcard></wcm-modal-backcard><div class="wcm-card"><wcm-modal-router></wcm-modal-router><wcm-modal-toast></wcm-modal-toast></div>`:null}</div></div>`}};tl.styles=[b.globalCss,tn],tc([(0,s.SB)()],tl.prototype,"open",2),tc([(0,s.SB)()],tl.prototype,"active",2),tl=tc([(0,s.Mo)("wcm-modal")],tl);let th=(0,r.iv)`div{display:flex;margin-top:15px}slot{display:inline-block;margin:0 5px}wcm-button{margin:0 5px}`;var td=Object.defineProperty,tu=Object.getOwnPropertyDescriptor,tp=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?tu(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&td(t,i,n),n};let tg=class extends r.oi{constructor(){super(...arguments),this.isMobile=!1,this.isDesktop=!1,this.isWeb=!1,this.isRetry=!1}onMobile(){o.zv.isMobile()?o.AV.replace("MobileConnecting"):o.AV.replace("MobileQrcodeConnecting")}onDesktop(){o.AV.replace("DesktopConnecting")}onWeb(){o.AV.replace("WebConnecting")}render(){return(0,r.dy)`<div>${this.isRetry?(0,r.dy)`<slot></slot>`:null} ${this.isMobile?(0,r.dy)`<wcm-button .onClick="${this.onMobile}" .iconLeft="${k.MOBILE_ICON}" variant="outline">Mobile</wcm-button>`:null} ${this.isDesktop?(0,r.dy)`<wcm-button .onClick="${this.onDesktop}" .iconLeft="${k.DESKTOP_ICON}" variant="outline">Desktop</wcm-button>`:null} ${this.isWeb?(0,r.dy)`<wcm-button .onClick="${this.onWeb}" .iconLeft="${k.GLOBE_ICON}" variant="outline">Web</wcm-button>`:null}</div>`}};tg.styles=[b.globalCss,th],tp([(0,s.Cb)({type:Boolean})],tg.prototype,"isMobile",2),tp([(0,s.Cb)({type:Boolean})],tg.prototype,"isDesktop",2),tp([(0,s.Cb)({type:Boolean})],tg.prototype,"isWeb",2),tp([(0,s.Cb)({type:Boolean})],tg.prototype,"isRetry",2),tg=tp([(0,s.Mo)("wcm-platform-selection")],tg);let tf=(0,r.iv)`button{display:flex;flex-direction:column;padding:5px 10px;border-radius:var(--wcm-button-hover-highlight-border-radius);height:100%;justify-content:flex-start}.wcm-icons{width:60px;height:60px;display:flex;flex-wrap:wrap;padding:7px;border-radius:var(--wcm-wallet-icon-border-radius);justify-content:space-between;align-items:center;margin-bottom:5px;background-color:var(--wcm-color-bg-2);box-shadow:inset 0 0 0 1px var(--wcm-color-overlay)}button:active{background-color:var(--wcm-color-overlay)}@media(hover:hover){button:hover{background-color:var(--wcm-color-overlay)}}.wcm-icons img{width:21px;height:21px;object-fit:cover;object-position:center;border-radius:calc(var(--wcm-wallet-icon-border-radius)/ 2);border:1px solid var(--wcm-color-overlay)}.wcm-icons svg{width:21px;height:21px}.wcm-icons img:nth-child(1),.wcm-icons img:nth-child(2),.wcm-icons svg:nth-child(1),.wcm-icons svg:nth-child(2){margin-bottom:4px}wcm-text{width:100%;text-align:center}
10#wallet-placeholder-fill{fill:var(--wcm-color-bg-3)}#wallet-placeholder-dash{stroke:var(--wcm-color-overlay)}`;var tm=Object.defineProperty,ty=Object.getOwnPropertyDescriptor;let tb=class extends r.oi{onClick(){o.AV.push("WalletExplorer")}render(){let{recomendedWallets:e}=o.ExplorerCtrl.state,t=[...e,...e1.manualWallets()].reverse().slice(0,4);return(0,r.dy)`<button @click="${this.onClick}"><div class="wcm-icons">${t.map(e=>{let t=Z.getWalletIcon(e);if(t)return(0,r.dy)`<img crossorigin="anonymous" src="${t}">`;let i=Z.getWalletIcon({id:e.id});return i?(0,r.dy)`<img crossorigin="anonymous" src="${i}">`:k.WALLET_PLACEHOLDER})} ${[...Array(4-t.length)].map(()=>k.WALLET_PLACEHOLDER)}</div><wcm-text variant="xsmall-regular">View All</wcm-text></button>`}};tb.styles=[b.globalCss,tf],tb=((e,t,i,r)=>{for(var s,n=r>1?void 0:r?ty(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&tm(t,i,n),n})([(0,s.Mo)("wcm-view-all-wallets-button")],tb);let tw=(0,r.iv)`.wcm-qr-container{width:100%;display:flex;justify-content:center;align-items:center;aspect-ratio:1/1}`;var tv=Object.defineProperty,tE=Object.getOwnPropertyDescriptor,t_=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?tE(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&tv(t,i,n),n};let tI=class extends r.oi{constructor(){super(),this.walletId="",this.imageId="",this.uri="",setTimeout(()=>{let{walletConnectUri:e}=o.OptionsCtrl.state;this.uri=e},0)}get overlayEl(){return Z.getShadowRootElement(this,".wcm-qr-container")}render(){return(0,r.dy)`<div class="wcm-qr-container">${this.uri?(0,r.dy)`<wcm-qrcode size="${this.overlayEl.offsetWidth}" uri="${this.uri}" walletId="${(0,l.o)(this.walletId)}" imageId="${(0,l.o)(this.imageId)}"></wcm-qrcode>`:(0,r.dy)`<wcm-spinner></wcm-spinner>`}</div>`}};tI.styles=[b.globalCss,tw],t_([(0,s.Cb)()],tI.prototype,"walletId",2),t_([(0,s.Cb)()],tI.prototype,"imageId",2),t_([(0,s.SB)()],tI.prototype,"uri",2),tI=t_([(0,s.Mo)("wcm-walletconnect-qr")],tI);var tx=Object.defineProperty,tO=Object.getOwnPropertyDescriptor;let tP=class extends r.oi{viewTemplate(){return o.zv.isAndroid()&&!o.zv.isTelegram()?(0,r.dy)`<wcm-android-wallet-selection></wcm-android-wallet-selection>`:o.zv.isMobile()?(0,r.dy)`<wcm-mobile-wallet-selection></wcm-mobile-wallet-selection>`:(0,r.dy)`<wcm-desktop-wallet-selection></wcm-desktop-wallet-selection>`}render(){return(0,r.dy)`${this.viewTemplate()}<wcm-legal-notice></wcm-legal-notice>`}};tP.styles=[b.globalCss],tP=((e,t,i,r)=>{for(var s,n=r>1?void 0:r?tO(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&tx(t,i,n),n})([(0,s.Mo)("wcm-connect-wallet-view")],tP);let tS=(0,r.iv)`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var tC=Object.defineProperty,tR=Object.getOwnPropertyDescriptor,tA=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?tR(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&tC(t,i,n),n};let tT=class extends r.oi{constructor(){super(),this.isError=!1,this.openDesktopApp()}onFormatAndRedirect(e){let{desktop:t,name:i}=o.zv.getWalletRouterData(),r=null==t?void 0:t.native,s=null==t?void 0:t.universal;if(r){let t=o.zv.formatNativeUrl(r,e,i);o.zv.openHref(t,"_self")}else if(s){let t=o.zv.formatUniversalUrl(s,e,i);o.zv.openHref(t,"_blank")}}openDesktopApp(){let{walletConnectUri:e}=o.OptionsCtrl.state,t=o.zv.getWalletRouterData();Z.setRecentWallet(t),e&&this.onFormatAndRedirect(e)}render(){let{name:e,id:t,image_id:i}=o.zv.getWalletRouterData(),{isMobile:s,isWeb:n}=Z.getCachedRouterWalletPlatforms();return(0,r.dy)`<wcm-modal-header title="${e}" .onAction="${Z.handleUriCopy}" .actionIcon="${k.COPY_ICON}"></wcm-modal-header><wcm-modal-content><wcm-connector-waiting walletId="${t}" imageId="${(0,l.o)(i)}" label="${`Continue in ${e}...`}" .isError="${this.isError}"></wcm-connector-waiting></wcm-modal-content><wcm-info-footer><wcm-text color="secondary" variant="small-thin">${`Connection can continue loading if ${e} is not installed on your device`}</wcm-text><wcm-platform-selection .isMobile="${s}" .isWeb="${n}" .isRetry="${!0}"><wcm-button .onClick="${this.openDesktopApp.bind(this)}" .iconRight="${k.RETRY_ICON}">Retry</wcm-button></wcm-platform-selection></wcm-info-footer>`}};tT.styles=[b.globalCss,tS],tA([(0,s.SB)()],tT.prototype,"isError",2),tT=tA([(0,s.Mo)("wcm-desktop-connecting-view")],tT);let tN=(0,r.iv)`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}wcm-button{margin-top:15px}`;var tk=Object.defineProperty,tL=Object.getOwnPropertyDescriptor;let t$=class extends r.oi{onInstall(e){e&&o.zv.openHref(e,"_blank")}render(){let{name:e,id:t,image_id:i,homepage:s}=o.zv.getWalletRouterData();return(0,r.dy)`<wcm-modal-header title="${e}"></wcm-modal-header><wcm-modal-content><wcm-connector-waiting walletId="${t}" imageId="${(0,l.o)(i)}" label="Not Detected" .isStale="${!0}"></wcm-connector-waiting></wcm-modal-content><wcm-info-footer><wcm-text color="secondary" variant="small-thin">${`Download ${e} to continue. If multiple browser extensions are installed, disable non ${e} ones and try again`}</wcm-text><wcm-button .onClick="${()=>this.onInstall(s)}" .iconLeft="${k.ARROW_DOWN_ICON}">Download</wcm-button></wcm-info-footer>`}};t$.styles=[b.globalCss,tN],t$=((e,t,i,r)=>{for(var s,n=r>1?void 0:r?tL(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&tk(t,i,n),n})([(0,s.Mo)("wcm-install-wallet-view")],t$);let tj=(0,r.iv)`wcm-wallet-image{border-radius:var(--wcm-wallet-icon-large-border-radius);width:96px;height:96px;margin-bottom:20px}wcm-info-footer{display:flex;width:100%}
10.wcm-app-store{justify-content:space-between}.wcm-app-store wcm-wallet-image{margin-right:10px;margin-bottom:0;width:28px;height:28px;border-radius:var(--wcm-wallet-icon-small-border-radius)}.wcm-app-store div{display:flex;align-items:center}.wcm-app-store wcm-button{margin-right:-10px}.wcm-note{flex-direction:column;align-items:center;padding:5px 0}.wcm-note wcm-text{text-align:center}wcm-platform-selection{margin-top:-15px}.wcm-note wcm-text{margin-top:15px}.wcm-note wcm-text span{color:var(--wcm-accent-color)}`;var tD=Object.defineProperty,tM=Object.getOwnPropertyDescriptor,tU=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?tM(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&tD(t,i,n),n};let tq=class extends r.oi{constructor(){super(),this.isError=!1,this.openMobileApp()}onFormatAndRedirect(e,t=!1){let{mobile:i,name:r}=o.zv.getWalletRouterData(),s=null==i?void 0:i.native,n=null==i?void 0:i.universal,a=o.zv.isTelegram()?"_blank":"_self";if(e=o.zv.isTelegram()&&o.zv.isAndroid()?encodeURIComponent(e):e,s&&!t){let t=o.zv.formatNativeUrl(s,e,r);o.zv.openHref(t,a)}else if(n){let t=o.zv.formatUniversalUrl(n,e,r);o.zv.openHref(t,a)}}openMobileApp(e=!1){let{walletConnectUri:t}=o.OptionsCtrl.state,i=o.zv.getWalletRouterData();t&&this.onFormatAndRedirect(t,e),Z.setRecentWallet(i)}onGoToAppStore(e){e&&o.zv.openHref(e,"_blank")}render(){let{name:e,id:t,image_id:i,app:s,mobile:n}=o.zv.getWalletRouterData(),{isWeb:a}=Z.getCachedRouterWalletPlatforms(),c=null==s?void 0:s.ios,h=null==n?void 0:n.universal;return(0,r.dy)`<wcm-modal-header title="${e}"></wcm-modal-header><wcm-modal-content><wcm-connector-waiting walletId="${t}" imageId="${(0,l.o)(i)}" label="Tap 'Open' to continueâ¦" .isError="${this.isError}"></wcm-connector-waiting></wcm-modal-content><wcm-info-footer class="wcm-note"><wcm-platform-selection .isWeb="${a}" .isRetry="${!0}"><wcm-button .onClick="${()=>this.openMobileApp(!1)}" .iconRight="${k.RETRY_ICON}">Retry</wcm-button></wcm-platform-selection>${h?(0,r.dy)`<wcm-text color="secondary" variant="small-thin">Still doesn't work? <span tabindex="0" @click="${()=>this.openMobileApp(!0)}">Try this alternate link</span></wcm-text>`:null}</wcm-info-footer><wcm-info-footer class="wcm-app-store"><div><wcm-wallet-image walletId="${t}" imageId="${(0,l.o)(i)}"></wcm-wallet-image><wcm-text>${`Get ${e}`}</wcm-text></div><wcm-button .iconRight="${k.ARROW_RIGHT_ICON}" .onClick="${()=>this.onGoToAppStore(c)}" variant="ghost">App Store</wcm-button></wcm-info-footer>`}};tq.styles=[b.globalCss,tj],tU([(0,s.SB)()],tq.prototype,"isError",2),tq=tU([(0,s.Mo)("wcm-mobile-connecting-view")],tq);let tB=(0,r.iv)`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var tz=Object.defineProperty,tH=Object.getOwnPropertyDescriptor;let tV=class extends r.oi{render(){let{name:e,id:t,image_id:i}=o.zv.getWalletRouterData(),{isDesktop:s,isWeb:n}=Z.getCachedRouterWalletPlatforms();return(0,r.dy)`<wcm-modal-header title="${e}" .onAction="${Z.handleUriCopy}" .actionIcon="${k.COPY_ICON}"></wcm-modal-header><wcm-modal-content><wcm-walletconnect-qr walletId="${t}" imageId="${(0,l.o)(i)}"></wcm-walletconnect-qr></wcm-modal-content><wcm-info-footer><wcm-text color="secondary" variant="small-thin">${`Scan this QR Code with your phone's camera or inside ${e} app`}</wcm-text><wcm-platform-selection .isDesktop="${s}" .isWeb="${n}"></wcm-platform-selection></wcm-info-footer>`}};tV.styles=[b.globalCss,tB],tV=((e,t,i,r)=>{for(var s,n=r>1?void 0:r?tH(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&tz(t,i,n),n})([(0,s.Mo)("wcm-mobile-qr-connecting-view")],tV);var tW=Object.defineProperty,tK=Object.getOwnPropertyDescriptor;let tF=class extends r.oi{render(){return(0,r.dy)`<wcm-modal-header title="Scan the code" .onAction="${Z.handleUriCopy}" .actionIcon="${k.COPY_ICON}"></wcm-modal-header><wcm-modal-content><wcm-walletconnect-qr></wcm-walletconnect-qr></wcm-modal-content>`}};tF.styles=[b.globalCss],tF=((e,t,i,r)=>{for(var s,n=r>1?void 0:r?tK(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&tW(t,i,n),n})([(0,s.Mo)("wcm-qrcode-view")],tF);let tJ=(0,r.iv)`wcm-modal-content{height:clamp(200px,60vh,600px);display:block;overflow:scroll;scrollbar-width:none;position:relative;margin-top:1px}.wcm-grid{display:grid;
10grid-template-columns:repeat(4,80px);justify-content:space-between;margin:-15px -10px;padding-top:20px}wcm-modal-content::after,wcm-modal-content::before{content:'';position:fixed;pointer-events:none;z-index:1;width:100%;height:20px;opacity:1}wcm-modal-content::before{box-shadow:0 -1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(var(--wcm-color-bg-1),rgba(255,255,255,0))}wcm-modal-content::after{box-shadow:0 1px 0 0 var(--wcm-color-bg-1);background:linear-gradient(rgba(255,255,255,0),var(--wcm-color-bg-1));top:calc(100% - 20px)}wcm-modal-content::-webkit-scrollbar{display:none}.wcm-placeholder-block{display:flex;justify-content:center;align-items:center;height:100px;overflow:hidden}.wcm-empty,.wcm-loading{display:flex}.wcm-loading .wcm-placeholder-block{height:100%}.wcm-end-reached .wcm-placeholder-block{height:0;opacity:0}.wcm-empty .wcm-placeholder-block{opacity:1;height:100%}wcm-wallet-button{margin:calc((100% - 60px)/ 3) 0}`;var tG=Object.defineProperty,tY=Object.getOwnPropertyDescriptor,tZ=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?tY(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&tG(t,i,n),n};let tQ=class extends r.oi{constructor(){super(...arguments),this.loading=!o.ExplorerCtrl.state.wallets.listings.length,this.firstFetch=!o.ExplorerCtrl.state.wallets.listings.length,this.search="",this.endReached=!1,this.intersectionObserver=void 0,this.searchDebounce=Z.debounce(e=>{e.length>=1?(this.firstFetch=!0,this.endReached=!1,this.search=e,o.ExplorerCtrl.resetSearch(),this.fetchWallets()):this.search&&(this.search="",this.endReached=this.isLastPage(),o.ExplorerCtrl.resetSearch())})}firstUpdated(){this.createPaginationObserver()}disconnectedCallback(){var e;null==(e=this.intersectionObserver)||e.disconnect()}get placeholderEl(){return Z.getShadowRootElement(this,".wcm-placeholder-block")}createPaginationObserver(){this.intersectionObserver=new IntersectionObserver(([e])=>{e.isIntersecting&&!(this.search&&this.firstFetch)&&this.fetchWallets()}),this.intersectionObserver.observe(this.placeholderEl)}isLastPage(){let{wallets:e,search:t}=o.ExplorerCtrl.state,{listings:i,total:r}=this.search?t:e;return r<=40||i.length>=r}async fetchWallets(){var e;let{wallets:t,search:i}=o.ExplorerCtrl.state,{listings:r,total:s,page:n}=this.search?i:t;if(!this.endReached&&(this.firstFetch||s>40&&r.length<s))try{this.loading=!0;let t=null==(e=o.OptionsCtrl.state.chains)?void 0:e.join(","),{listings:i}=await o.ExplorerCtrl.getWallets({page:this.firstFetch?1:n+1,entries:40,search:this.search,version:2,chains:t}),r=i.map(e=>Z.getWalletIcon(e));await Promise.all([...r.map(async e=>Z.preloadImage(e)),o.zv.wait(300)]),this.endReached=this.isLastPage()}catch(e){console.error(e),o.ToastCtrl.openToast(Z.getErrorMessage(e),"error")}finally{this.loading=!1,this.firstFetch=!1}}onConnect(e){o.zv.isAndroid()?Z.handleMobileLinking(e):Z.goToConnectingView(e)}onSearchChange(e){let{value:t}=e.target;this.searchDebounce(t)}render(){let{wallets:e,search:t}=o.ExplorerCtrl.state,{listings:i}=this.search?t:e,s=this.loading&&!i.length,a=this.search.length>=3,c=e2.manualWalletsTemplate(),l=e2.recomendedWalletsTemplate(!0);a&&(c=c.filter(({values:e})=>Z.caseSafeIncludes(e[0],this.search)),l=l.filter(({values:e})=>Z.caseSafeIncludes(e[0],this.search)));let h=!this.loading&&!i.length&&!l.length,d={"wcm-loading":s,"wcm-end-reached":this.endReached||!this.loading,"wcm-empty":h};return(0,r.dy)`<wcm-modal-header><wcm-search-input .onChange="${this.onSearchChange.bind(this)}"></wcm-search-input></wcm-modal-header><wcm-modal-content class="${(0,n.$)(d)}"><div class="wcm-grid">${s?null:c} ${s?null:l} ${s?null:i.map(e=>(0,r.dy)`${e?(0,r.dy)`<wcm-wallet-button imageId="${e.image_id}" name="${e.name}" walletId="${e.id}" .onClick="${()=>this.onConnect(e)}"></wcm-wallet-button>`:null}`)}</div><div class="wcm-placeholder-block">${h?(0,r.dy)`<wcm-text variant="big-bold" color="secondary">No results found</wcm-text>`:null} ${!h&&this.loading?(0,r.dy)`<wcm-spinner></wcm-spinner>`:null}</div></wcm-modal-content>`}};tQ.styles=[b.globalCss,tJ],tZ([(0,s.SB)()],tQ.prototype,"loading",2),tZ([(0,s.SB)()],tQ.prototype,"firstFetch",2),tZ([(0,s.SB)()],tQ.prototype,"search",2),tZ([(0,s.SB)()],tQ.prototype,"endReached",2),tQ=tZ([(0,s.Mo)("wcm-wallet-explorer-view")],tQ);let tX=(0,r.iv)`wcm-info-footer{flex-direction:column;align-items:center;display:flex;width:100%;padding:5px 0}wcm-text{text-align:center}`;var t0=Object.defineProperty,t1=Object.getOwnPropertyDescriptor,t2=(e,t,i,r)=>{for(var s,n=r>1?void 0:r?t1(t,i):t,o=e.length-1;o>=0;o--)(s=e[o])&&(n=(r?s(t,i,n):s(n))||n);return r&&n&&t0(t,i,n),n};let t5=class extends r.oi{constructor(){super(),this.isError=!1,this.openWebWallet()}onFormatAndRedirect(e){let{desktop:t,name:i}=o.zv.getWalletRouterData(),r=null==t?void 0:t.universal;if(r){let t=o.zv.formatUniversalUrl(r,e,i);o.zv.openHref(t,"_blank")}}openWebWallet(){let{walletConnectUri:e}=o.OptionsCtrl.state,t=o.zv.getWalletRouterData();Z.setRecentWallet(t),e&&this.onFormatAndRedirect(e)}render(){let{name:e,id:t,image_id:i}=o.zv.getWalletRouterData(),{isMobile:s,isDesktop:n}=Z.getCachedRouterWalletPlatforms(),a=o.zv.isMobile();return(0,r.dy)`<wcm-modal-header title="${e}" .onAction="${Z.handleUriCopy}" .actionIcon="${k.COPY_ICON}"></wcm-modal-header><wcm-modal-content><wcm-connector-waiting walletId="${t}" imageId="${(0,l.o)(i)}" label="${`Continue in ${e}...`}" .isError="${this.isError}"></wcm-connector-waiting></wcm-modal-content><wcm-info-footer><wcm-text color="secondary" variant="small-thin">${`${e} web app has opened in a new tab. Go there, accept the connection, and come back`}</wcm-text><wcm-platform-selection .isMobile="${s}" .isDesktop="${!a&&n}" .isRetry="${!0}"><wcm-button .onClick="${this.openWebWallet.bind(this)}" .iconRight="${k.RETRY_ICON}">Retry</wcm-button></wcm-platform-selection></wcm-info-footer>`}};t5.styles=[b.globalCss,tX],t2([(0,s.SB)()],t5.prototype,"isError",2),t2([(0,s.Mo)("wcm-web-connecting-view")],t5)},44978:function(e,t,i){"use strict";
10i.d(t,{WalletConnectModal:function(){return s}});var r=i(85810);class s{constructor(e){this.openModal=r.jb.open,this.closeModal=r.jb.close,this.subscribeModal=r.jb.subscribe,this.setTheme=r.ThemeCtrl.setThemeConfig,r.ThemeCtrl.setThemeConfig(e),r.ConfigCtrl.setConfig(e),this.initUi()}async initUi(){if("undefined"!=typeof window){await Promise.all([i.e(601),i.e(1216)]).then(i.bind(i,20331));let e=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",e),r.OptionsCtrl.setIsUiLoaded(!0)}}}}}]);
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.