/*! For license information please see bundle.32432cce42a5a9ab8b6e.js.LICENSE.txt */ (self.webpackChunkfrog=self.webpackChunkfrog||[]).push([[7828],{2985:(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)}))}},4556:(e,t,s)=>{"use strict";s.d(t,{H:()=>i});class i{}},13554:(e,t,s)=>{"use strict";s.d(t,{h:()=>o,j:()=>n});const i=e=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString()+"n":t)),r=e=>{const t=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');return JSON.parse(t,((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 new Error("Cannot safe json parse value of type "+typeof e);try{return r(e)}catch(t){return e}}function o(e){return"string"==typeof e?e:i(e)||""}},17182:(e,t,s)=>{"use strict";s.d(t,{A1:()=>a,q$:()=>o,z:()=>c});const i="^https?:",r="^wss?:";function n(e,t){const s=function(e){const t=e.match(new RegExp(/^\w+:/,"gi"));if(t&&t.length)return t[0]}(e);return void 0!==s&&new RegExp(t).test(s)}function o(e){return n(e,i)}function a(e){return n(e,r)}function c(e){return new RegExp("wss?://localhost(:d{2,5})?").test(e)}},21222:(e,t,s)=>{var i="undefined"!=typeof globalThis&&globalThis||"undefined"!=typeof self&&self||void 0!==s.g&&s.g,r=function(){function e(){this.fetch=!1,this.DOMException=i.DOMException}return e.prototype=i,new e}();!function(e){!function(t){var i=void 0!==e&&e||"undefined"!=typeof self&&self||void 0!==s.g&&s.g||{},r="URLSearchParams"in i,n="Symbol"in i&&"iterator"in Symbol,o="FileReader"in i&&"Blob"in i&&function(){try{return new Blob,!0}catch(e){return!1}}(),a="FormData"in i,c="ArrayBuffer"in i;if(c)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(e){return e&&l.indexOf(Object.prototype.toString.call(e))>-1};function u(e){if("string"!=typeof e&&(e=String(e)),/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(e)||""===e)throw new TypeError('Invalid character in header field name: "'+e+'"');return e.toLowerCase()}function p(e){return"string"!=typeof e&&(e=String(e)),e}function d(e){var t={next:function(){var t=e.shift();return{done:void 0===t,value:t}}};return n&&(t[Symbol.iterator]=function(){return t}),t}function f(e){this.map={},e instanceof f?e.forEach((function(e,t){this.append(t,e)}),this):Array.isArray(e)?e.forEach((function(e){if(2!=e.length)throw new 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 g(e){if(!e._noBody)return e.bodyUsed?Promise.reject(new TypeError("Already read")):void(e.bodyUsed=!0)}function y(e){return new Promise((function(t,s){e.onload=function(){t(e.result)},e.onerror=function(){s(e.error)}}))}function w(e){var t=new FileReader,s=y(t);return t.readAsArrayBuffer(e),s}function m(e){if(e.slice)return e.slice(0);var t=new Uint8Array(e.byteLength);return t.set(new Uint8Array(e)),t.buffer}function b(){return this.bodyUsed=!1,this._initBody=function(e){var t;this.bodyUsed=this.bodyUsed,this._bodyInit=e,e?"string"==typeof e?this._bodyText=e:o&&Blob.prototype.isPrototypeOf(e)?this._bodyBlob=e:a&&FormData.prototype.isPrototypeOf(e)?this._bodyFormData=e:r&&URLSearchParams.prototype.isPrototypeOf(e)?this._bodyText=e.toString():c&&o&&((t=e)&&DataView.prototype.isPrototypeOf(t))?(this._bodyArrayBuffer=m(e.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c&&(ArrayBuffer.prototype.isPrototypeOf(e)||h(e))?this._bodyArrayBuffer=m(e):this._bodyText=e=Object.prototype.toString.call(e):(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&&URLSearchParams.prototype.isPrototypeOf(e)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var e=g(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)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))}),this.arrayBuffer=function(){if(this._bodyArrayBuffer){var e=g(this);return e||(ArrayBuffer.isView(this._bodyArrayBuffer)?Promise.resolve(this._bodyArrayBuffer.buffer.slice(this._bodyArrayBuffer.byteOffset,this._bodyArrayBuffer.byteOffset+this._bodyArrayBuffer.byteLength)):Promise.resolve(this._bodyArrayBuffer))}if(o)return this.blob().then(w);throw new Error("could not read as ArrayBuffer")},this.text=function(){var e,t,s,i,r,n=g(this);if(n)return n;if(this._bodyBlob)return e=this._bodyBlob,t=new FileReader,s=y(t),i=/charset=([A-Za-z0-9_-]+)/.exec(e.type),r=i?i[1]:"utf-8",t.readAsText(e,r),s;if(this._bodyArrayBuffer)return Promise.resolve(function(e){for(var t=new Uint8Array(e),s=new Array(t.length),i=0;i-1?r:s),this.mode=t.mode||this.mode||null,this.signal=t.signal||this.signal||function(){if("AbortController"in i)return(new AbortController).signal}(),this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&n)throw new TypeError("Body not allowed for GET or HEAD requests");if(this._initBody(n),!("GET"!==this.method&&"HEAD"!==this.method||"no-store"!==t.cache&&"no-cache"!==t.cache)){var o=/([?&])_=[^&]*/;if(o.test(this.url))this.url=this.url.replace(o,"$1_="+(new Date).getTime());else{this.url+=(/\?/.test(this.url)?"&":"?")+"_="+(new Date).getTime()}}}function _(e){var t=new FormData;return e.trim().split("&").forEach((function(e){if(e){var s=e.split("="),i=s.shift().replace(/\+/g," "),r=s.join("=").replace(/\+/g," ");t.append(decodeURIComponent(i),decodeURIComponent(r))}})),t}function R(e,t){if(!(this instanceof R))throw new 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 new 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 f(t.headers),this.url=t.url||"",this._initBody(e)}E.prototype.clone=function(){return new E(this,{body:this._bodyInit})},b.call(E.prototype),b.call(R.prototype),R.prototype.clone=function(){return new R(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},R.error=function(){var e=new R(null,{status:200,statusText:""});return e.ok=!1,e.status=0,e.type="error",e};var S=[301,302,303,307,308];R.redirect=function(e,t){if(-1===S.indexOf(t))throw new RangeError("Invalid status code");return new R(null,{status:t,headers:{location:e}})},t.DOMException=i.DOMException;try{new t.DOMException}catch(e){t.DOMException=function(e,t){this.message=e,this.name=t;var s=Error(e);this.stack=s.stack},t.DOMException.prototype=Object.create(Error.prototype),t.DOMException.prototype.constructor=t.DOMException}function I(e,s){return new Promise((function(r,n){var a=new E(e,s);if(a.signal&&a.signal.aborted)return n(new t.DOMException("Aborted","AbortError"));var l=new XMLHttpRequest;function h(){l.abort()}if(l.onload=function(){var e,t,s={statusText:l.statusText,headers:(e=l.getAllResponseHeaders()||"",t=new f,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 s=e.split(":"),i=s.shift().trim();if(i){var r=s.join(":").trim();try{t.append(i,r)}catch(e){}}})),t)};0===a.url.indexOf("file://")&&(l.status<200||l.status>599)?s.status=200:s.status=l.status,s.url="responseURL"in l?l.responseURL:s.headers.get("X-Request-URL");var i="response"in l?l.response:l.responseText;setTimeout((function(){r(new R(i,s))}),0)},l.onerror=function(){setTimeout((function(){n(new TypeError("Network request failed"))}),0)},l.ontimeout=function(){setTimeout((function(){n(new TypeError("Network request timed out"))}),0)},l.onabort=function(){setTimeout((function(){n(new t.DOMException("Aborted","AbortError"))}),0)},l.open(a.method,function(e){try{return""===e&&i.location.href?i.location.href:e}catch(t){return e}}(a.url),!0),"include"===a.credentials?l.withCredentials=!0:"omit"===a.credentials&&(l.withCredentials=!1),"responseType"in l&&(o?l.responseType="blob":c&&(l.responseType="arraybuffer")),s&&"object"==typeof s.headers&&!(s.headers instanceof f||i.Headers&&s.headers instanceof i.Headers)){var d=[];Object.getOwnPropertyNames(s.headers).forEach((function(e){d.push(u(e)),l.setRequestHeader(e,p(s.headers[e]))})),a.headers.forEach((function(e,t){-1===d.indexOf(t)&&l.setRequestHeader(t,e)}))}else a.headers.forEach((function(e,t){l.setRequestHeader(t,e)}));a.signal&&(a.signal.addEventListener("abort",h),l.onreadystatechange=function(){4===l.readyState&&a.signal.removeEventListener("abort",h)}),l.send(void 0===a._bodyInit?null:a._bodyInit)}))}I.polyfill=!0,i.fetch||(i.fetch=I,i.Headers=f,i.Request=E,i.Response=R),t.Headers=f,t.Request=E,t.Response=R,t.fetch=I,Object.defineProperty(t,"__esModule",{value:!0})}({})}(r),r.fetch.ponyfill=!0,delete r.fetch.polyfill;var n=i.fetch?i:r;(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},25682:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(98186);i.__exportStar(s(77173),t),i.__exportStar(s(91089),t)},27907:(e,t,s)=>{"use strict";s.d(t,{F:()=>n});var i=s(37007),r=s(39031);class n extends r.IJsonRpcProvider{constructor(e){super(e),this.events=new i.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,r.formatJsonRpcRequest)(e.method,e.params||[],e.id||(0,r.getBigIntRpcId)().toString()),t)}async requestStrict(e,t){return new Promise((async(s,i)=>{if(!this.connection.connected)try{await this.open()}catch(e){i(e)}this.events.on(`${e.id}`,(e=>{(0,r.isJsonRpcError)(e)?i(e.error):s(e.result)}));try{await this.connection.send(e,t)}catch(e){i(e)}}))}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),(0,r.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",new 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)}}},29838:(e,t,s)=>{"use strict";s.d(t,{D5:()=>x,U5:()=>I,h6:()=>r.a,iP:()=>R,oI:()=>S});var i=s(44874),r=s.n(i),n=s(13554);const o={level:"info"},a="custom_context",c=1024e3;class l{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 h{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const t=new l(e);if(t.size>this.maxSizeInBytes)throw new 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.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let 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};const t=e.value;return e=e.next,{done:!1,value:t}}}}}class u{constructor(e,t=c){this.level=e??"error",this.levelValue=i.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new h(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===i.levels.values.error||t===i.levels.values.warn||t===i.levels.values.debug||i.levels.values.trace}appendToLogs(e){this.logs.append((0,n.h)({timestamp:(new Date).toISOString(),log:e}));const 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 h(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const t=this.getLogArray();return t.push((0,n.h)({extraMetadata:e})),new Blob(t,{type:"application/json"})}}class p{constructor(e,t=c){this.baseChunkLogger=new u(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){const t=URL.createObjectURL(this.logsToBlob(e)),s=document.createElement("a");s.href=t,s.download=`walletconnect-logs-${(new Date).toISOString()}.txt`,document.body.appendChild(s),s.click(),document.body.removeChild(s),URL.revokeObjectURL(t)}}class d{constructor(e,t=c){this.baseChunkLogger=new u(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 f=Object.defineProperty,g=Object.defineProperties,y=Object.getOwnPropertyDescriptors,w=Object.getOwnPropertySymbols,m=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable,v=(e,t,s)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,E=(e,t)=>{for(var s in t||(t={}))m.call(t,s)&&v(e,s,t[s]);if(w)for(var s of w(t))b.call(t,s)&&v(e,s,t[s]);return e},_=(e,t)=>g(e,y(t));function R(e){return _(E({},e),{level:e?.level||o.level})}function S(e,t=a){let s="";return s=typeof e.bindings>"u"?function(e,t=a){return e[t]||""}(e,t):e.bindings().context||"",s}function I(e,t,s=a){const i=function(e,t,s=a){const i=S(e,s);return i.trim()?`${i}/${t}`:t}(e,t,s);return function(e,t,s=a){return e[s]=t,e}(e.child({context:i}),i,s)}function x(e){return typeof e.loggerOverride<"u"&&"string"!=typeof e.loggerOverride?{logger:e.loggerOverride,chunkLoggerController:null}:typeof window<"u"?function(e){var t,s;const i=new p(null==(t=e.opts)?void 0:t.level,e.maxSizeInBytes);return{logger:r()(_(E({},e.opts),{level:"trace",browser:_(E({},null==(s=e.opts)?void 0:s.browser),{write:e=>i.write(e)})})),chunkLoggerController:i}}(e):function(e){var t;const s=new d(null==(t=e.opts)?void 0:t.level,e.maxSizeInBytes);return{logger:r()(_(E({},e.opts),{level:"trace"}),s),chunkLoggerController:s}}(e)}},30947:(e,t,s)=>{"use strict";s.d(t,{kF:()=>n});class i{}class r extends i{constructor(){super()}}class n extends r{constructor(e){super()}}},31861:(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},36647:(e,t,s)=>{"use strict";s.d(t,{A:()=>m,V:()=>m});var i=s(37007),r=s(21222),n=s.n(r),o=s(13554),a=s(39031),c=Object.defineProperty,l=Object.defineProperties,h=Object.getOwnPropertyDescriptors,u=Object.getOwnPropertySymbols,p=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,f=(e,t,s)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,g=(e,t)=>{for(var s in t||(t={}))p.call(t,s)&&f(e,s,t[s]);if(u)for(var s of u(t))d.call(t,s)&&f(e,s,t[s]);return e},y=(e,t)=>l(e,h(t));const w={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"};class m{constructor(e,t=!1){if(this.url=e,this.disableProviderPing=t,this.events=new i.EventEmitter,this.isAvailable=!1,this.registering=!1,!(0,a.isHttpUrl)(e))throw new 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 new Error("Connection already closed");this.onClose()}async send(e){this.isAvailable||await this.register();try{const t=(0,o.h)(e),s=await(await n()(this.url,y(g({},w),{body:t}))).json();this.onPayload({data:s})}catch(t){this.onError(e.id,t)}}async register(e=this.url){if(!(0,a.isHttpUrl)(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const 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(new Error("HTTP connection is missing or invalid"));e()}))}))}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const t=(0,o.h)({id:1,jsonrpc:"2.0",method:"test",params:[]});await n()(e,y(g({},w),{body:t}))}this.onOpen()}catch(e){const t=this.parseError(e);throw this.events.emit("register_error",t),this.onClose(),t}}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;const t="string"==typeof e.data?(0,o.j)(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const s=this.parseError(t),i=s.message||s.toString(),r=(0,a.formatJsonRpcError)(e,i);this.events.emit("payload",r)}parseError(e,t=this.url){return(0,a.parseConnectionError)(e,t,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}}},38236:(e,t,s)=>{"use strict";s.d(t,{Cq:()=>qs,FA:()=>Us,TZ:()=>Ls,UF:()=>Ps});var i=s(88900),r=s(13554);function n(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function o(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}const a="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,c=e=>new DataView(e.buffer,e.byteOffset,e.byteLength);function l(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),n(e),e}class h{clone(){return this._cloneInto()}}function u(e=32){if(a&&"function"==typeof a.getRandomValues)return a.getRandomValues(new Uint8Array(e));if(a&&"function"==typeof a.randomBytes)return a.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}class p extends h{constructor(e,t,s,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=c(this.buffer)}update(e){o(this);const{view:t,buffer:s,blockLen:i}=this,r=(e=l(e)).length;for(let n=0;ni-a&&(this.process(s,0),a=0);for(let e=a;e>r&n),a=Number(s&n),c=i?4:0,l=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+l,a,i)})(s,i-8,BigInt(8*this.length),r),this.process(s,0);const l=c(e),h=this.outputLen;if(h%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=h/4,p=this.get();if(u>p.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e>f&d)}:{h:0|Number(e>>f&d),l:0|Number(e&d)}}const y={fromBig:g,split:function(e,t=!1){let s=new Uint32Array(e.length),i=new Uint32Array(e.length);for(let r=0;rBigInt(e>>>0)<>>0),shrSH:(e,t,s)=>e>>>s,shrSL:(e,t,s)=>e<<32-s|t>>>s,rotrSH:(e,t,s)=>e>>>s|t<<32-s,rotrSL:(e,t,s)=>e<<32-s|t>>>s,rotrBH:(e,t,s)=>e<<64-s|t>>>s-32,rotrBL:(e,t,s)=>e>>>s-32|t<<64-s,rotr32H:(e,t)=>t,rotr32L:(e,t)=>e,rotlSH:(e,t,s)=>e<>>32-s,rotlSL:(e,t,s)=>t<>>32-s,rotlBH:(e,t,s)=>t<>>64-s,rotlBL:(e,t,s)=>e<>>64-s,add:function(e,t,s,i){const r=(t>>>0)+(i>>>0);return{h:e+s+(r/2**32|0)|0,l:0|r}},add3L:(e,t,s)=>(e>>>0)+(t>>>0)+(s>>>0),add3H:(e,t,s,i)=>t+s+i+(e/2**32|0)|0,add4L:(e,t,s,i)=>(e>>>0)+(t>>>0)+(s>>>0)+(i>>>0),add4H:(e,t,s,i,r)=>t+s+i+r+(e/2**32|0)|0,add5H:(e,t,s,i,r,n)=>t+s+i+r+n+(e/2**32|0)|0,add5L:(e,t,s,i,r)=>(e>>>0)+(t>>>0)+(s>>>0)+(i>>>0)+(r>>>0)},[w,m]=y.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","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map((e=>BigInt(e)))),b=new Uint32Array(80),v=new Uint32Array(80);class E extends p{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(){const{Ah:e,Al:t,Bh:s,Bl:i,Ch:r,Cl:n,Dh:o,Dl:a,Eh:c,El:l,Fh:h,Fl:u,Gh:p,Gl:d,Hh:f,Hl:g}=this;return[e,t,s,i,r,n,o,a,c,l,h,u,p,d,f,g]}set(e,t,s,i,r,n,o,a,c,l,h,u,p,d,f,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|s,this.Bl=0|i,this.Ch=0|r,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|u,this.Gh=0|p,this.Gl=0|d,this.Hh=0|f,this.Hl=0|g}process(e,t){for(let s=0;s<16;s++,t+=4)b[s]=e.getUint32(t),v[s]=e.getUint32(t+=4);for(let e=16;e<80;e++){const t=0|b[e-15],s=0|v[e-15],i=y.rotrSH(t,s,1)^y.rotrSH(t,s,8)^y.shrSH(t,s,7),r=y.rotrSL(t,s,1)^y.rotrSL(t,s,8)^y.shrSL(t,s,7),n=0|b[e-2],o=0|v[e-2],a=y.rotrSH(n,o,19)^y.rotrBH(n,o,61)^y.shrSH(n,o,6),c=y.rotrSL(n,o,19)^y.rotrBL(n,o,61)^y.shrSL(n,o,6),l=y.add4L(r,c,v[e-7],v[e-16]),h=y.add4H(l,i,a,b[e-7],b[e-16]);b[e]=0|h,v[e]=0|l}let{Ah:s,Al:i,Bh:r,Bl:n,Ch:o,Cl:a,Dh:c,Dl:l,Eh:h,El:u,Fh:p,Fl:d,Gh:f,Gl:g,Hh:E,Hl:_}=this;for(let e=0;e<80;e++){const t=y.rotrSH(h,u,14)^y.rotrSH(h,u,18)^y.rotrBH(h,u,41),R=y.rotrSL(h,u,14)^y.rotrSL(h,u,18)^y.rotrBL(h,u,41),S=h&p^~h&f,I=u&d^~u&g,x=y.add5L(_,R,I,m[e],v[e]),O=y.add5H(x,E,t,S,w[e],b[e]),T=0|x,A=y.rotrSH(s,i,28)^y.rotrBH(s,i,34)^y.rotrBH(s,i,39),P=y.rotrSL(s,i,28)^y.rotrBL(s,i,34)^y.rotrBL(s,i,39),N=s&r^s&o^r&o,q=i&n^i&a^n&a;E=0|f,_=0|g,f=0|p,g=0|d,p=0|h,d=0|u,({h,l:u}=y.add(0|c,0|l,0|O,0|T)),c=0|o,l=0|a,o=0|r,a=0|n,r=0|s,n=0|i;const L=y.add3L(T,P,q);s=y.add3H(L,O,A,N),i=0|L}({h:s,l:i}=y.add(0|this.Ah,0|this.Al,0|s,0|i)),({h:r,l:n}=y.add(0|this.Bh,0|this.Bl,0|r,0|n)),({h:o,l:a}=y.add(0|this.Ch,0|this.Cl,0|o,0|a)),({h:c,l}=y.add(0|this.Dh,0|this.Dl,0|c,0|l)),({h,l:u}=y.add(0|this.Eh,0|this.El,0|h,0|u)),({h:p,l:d}=y.add(0|this.Fh,0|this.Fl,0|p,0|d)),({h:f,l:g}=y.add(0|this.Gh,0|this.Gl,0|f,0|g)),({h:E,l:_}=y.add(0|this.Hh,0|this.Hl,0|E,0|_)),this.set(s,i,r,n,o,a,c,l,h,u,p,d,f,g,E,_)}roundClean(){b.fill(0),v.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)}}const _=function(e){const t=t=>e().update(l(t)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}((()=>new E)),R=BigInt(0),S=BigInt(1),I=BigInt(2);function x(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function O(e){if(!x(e))throw new Error("Uint8Array expected")}function T(e,t){if("boolean"!=typeof t)throw new Error(e+" boolean expected, got "+t)}const A=Array.from({length:256},((e,t)=>t.toString(16).padStart(2,"0")));function P(e){O(e);let t="";for(let s=0;s=q&&e<=L?e-q:e>=U&&e<=D?e-(U-10):e>=B&&e<=C?e-(B-10):void 0}function j(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,s=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(s);for(let t=0,r=0;t"bigint"==typeof e&&R<=e;function G(e,t,s,i){if(!function(e,t,s){return z(e)&&z(t)&&z(s)&&t<=e&&e(I<"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||x(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 W(e,t,s={}){const i=(t,s,i)=>{const r=K[s];if("function"!=typeof r)throw new Error("invalid validator function");const n=e[t];if(!(i&&void 0===n||r(n,e)))throw new Error("param "+String(t)+" is invalid. Expected "+s+", got "+n)};for(const[e,s]of Object.entries(t))i(e,s,!1);for(const[e,t]of Object.entries(s))i(e,t,!0);return e}function Y(e){const t=new WeakMap;return(s,...i)=>{const r=t.get(s);if(void 0!==r)return r;const n=e(s,...i);return t.set(s,n),n}}const Q=BigInt(0),X=BigInt(1),Z=BigInt(2),ee=BigInt(3),te=BigInt(4),se=BigInt(5),ie=BigInt(8);function re(e,t){const s=e%t;return s>=Q?s:t+s}function ne(e,t,s){if(tQ;)t&X&&(i=i*e%s),e=e*e%s,t>>=X;return i}function oe(e,t,s){let i=e;for(;t-- >Q;)i*=i,i%=s;return i}function ae(e,t){if(e===Q)throw new Error("invert: expected non-zero number");if(t<=Q)throw new Error("invert: expected positive modulus, got "+t);let s=re(e,t),i=t,r=Q,n=X;for(;s!==Q;){const e=i%s,t=r-n*(i/s);i=s,s=e,r=n,n=t}if(i!==X)throw new Error("invert: does not exist");return re(r,t)}function ce(e){if(e%te===ee){const t=(e+X)/te;return function(e,s){const i=e.pow(s,t);if(!e.eql(e.sqr(i),s))throw new Error("Cannot find square root");return i}}if(e%ie===se){const t=(e-se)/ie;return function(e,s){const i=e.mul(s,Z),r=e.pow(i,t),n=e.mul(s,r),o=e.mul(e.mul(n,Z),r),a=e.mul(n,e.sub(o,e.ONE));if(!e.eql(e.sqr(a),s))throw new Error("Cannot find square root");return a}}return function(e){const t=(e-X)/Z;let s,i,r;for(s=e-X,i=0;s%Z===Q;s/=Z,i++);for(r=Z;r1e3)throw new Error("Cannot find square root: likely non-prime P");if(1===i){const t=(e+X)/te;return function(e,s){const i=e.pow(s,t);if(!e.eql(e.sqr(i),s))throw new Error("Cannot find square root");return i}}const n=(s+X)/Z;return function(e,o){if(e.pow(o,t)===e.neg(e.ONE))throw new Error("Cannot find square root");let a=i,c=e.pow(e.mul(e.ONE,r),s),l=e.pow(o,n),h=e.pow(o,s);for(;!e.eql(h,e.ONE);){if(e.eql(h,e.ZERO))return e.ZERO;let t=1;for(let s=e.sqr(h);t 0, got "+e);const{nBitLength:r,nByteLength:n}=he(e,t);if(n>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let o;const a=Object.freeze({ORDER:e,isLE:s,BITS:r,BYTES:n,MASK:J(r),ZERO:Q,ONE:X,create:t=>re(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return Q<=t&&te===Q,isOdd:e=>(e&X)===X,neg:t=>re(-t,e),eql:(e,t)=>e===t,sqr:t=>re(t*t,e),add:(t,s)=>re(t+s,e),sub:(t,s)=>re(t-s,e),mul:(t,s)=>re(t*s,e),pow:(e,t)=>function(e,t,s){if(sQ;)s&X&&(i=e.mul(i,r)),r=e.sqr(r),s>>=X;return i}(a,e,t),div:(t,s)=>re(t*ae(s,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>ae(t,e),sqrt:i.sqrt||(t=>(o||(o=ce(e)),o(a,t))),invertBatch:e=>function(e,t){const s=new Array(t.length),i=t.reduce(((t,i,r)=>e.is0(i)?t:(s[r]=t,e.mul(t,i))),e.ONE),r=e.inv(i);return t.reduceRight(((t,i,r)=>e.is0(i)?t:(s[r]=e.mul(t,s[r]),e.mul(t,i))),r),s}(a,e),cmov:(e,t,s)=>s?t:e,toBytes:e=>s?H(e,n):V(e,n),fromBytes:e=>{if(e.length!==n)throw new Error("Field.fromBytes: expected "+n+" bytes, got "+e.length);return s?k(e):function(e){return N(P(e))}(e)}});return Object.freeze(a)}const pe=BigInt(0),de=BigInt(1);function fe(e,t){const s=t.negate();return e?s:t}function ge(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function ye(e,t){ge(e,t);return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1)}}const we=new WeakMap,me=new WeakMap;function be(e){return me.get(e)||1}function ve(e,t,s,i){if(function(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach(((e,s)=>{if(!(e instanceof t))throw new Error("invalid point at index "+s)}))}(s,e),function(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach(((e,s)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+s)}))}(i,t),s.length!==i.length)throw new Error("arrays of points and scalars must have equal length");const r=e.ZERO,n=function(e){let t;for(t=0;e>R;e>>=S,t+=1);return t}(BigInt(s.length)),o=n>12?n-3:n>4?n-2:n?2:1,a=(1<=0;e-=o){c.fill(r);for(let t=0;t>BigInt(e)&BigInt(a));c[n]=c[n].add(s[t])}let t=r;for(let e=c.length-1,s=r;e>0;e--)s=s.add(c[e]),t=t.add(s);if(l=l.add(t),0!==e)for(let e=0;e(e[t]="function",e)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"}))}(e.Fp),W(e,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...he(e.n,e.nBitLength),...e,p:e.Fp.ORDER})}const _e=BigInt(0),Re=BigInt(1),Se=BigInt(2),Ie=BigInt(8),xe={zip215:!0};function Oe(e){const t=function(e){const t=Ee(e);return W(e,{hash:"function",a:"bigint",d:"bigint",randomBytes:"function"},{adjustScalarBytes:"function",domain:"function",uvRatio:"function",mapToCurve:"function"}),Object.freeze({...t})}(e),{Fp:s,n:i,prehash:r,hash:n,randomBytes:o,nByteLength:a,h:c}=t,l=Se<{try{return{isValid:!0,value:s.sqrt(e*s.inv(t))}}catch{return{isValid:!1,value:_e}}}),d=t.adjustScalarBytes||(e=>e),f=t.domain||((e,t,s)=>{if(T("phflag",s),t.length||s)throw new Error("Contexts/pre-hash are not supported");return e});function g(e,t){G("coordinate "+e,t,_e,l)}function y(e){if(!(e instanceof b))throw new Error("ExtendedPoint expected")}const w=Y(((e,t)=>{const{ex:i,ey:r,ez:n}=e,o=e.is0();null==t&&(t=o?Ie:s.inv(n));const a=h(i*t),c=h(r*t),l=h(n*t);if(o)return{x:_e,y:Re};if(l!==Re)throw new Error("invZ was invalid");return{x:a,y:c}})),m=Y((e=>{const{a:s,d:i}=t;if(e.is0())throw new Error("bad point: ZERO");const{ex:r,ey:n,ez:o,et:a}=e,c=h(r*r),l=h(n*n),u=h(o*o),p=h(u*u),d=h(c*s);if(h(u*h(d+l))!==h(p+h(i*h(c*l))))throw new Error("bad point: equation left != right (1)");if(h(r*n)!==h(o*a))throw new Error("bad point: equation left != right (2)");return!0}));class b{constructor(e,t,s,i){this.ex=e,this.ey=t,this.ez=s,this.et=i,g("x",e),g("y",t),g("z",s),g("t",i),Object.freeze(this)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static fromAffine(e){if(e instanceof b)throw new Error("extended point not allowed");const{x:t,y:s}=e||{};return g("x",t),g("y",s),new b(t,s,Re,h(t*s))}static normalizeZ(e){const t=s.invertBatch(e.map((e=>e.ez)));return e.map(((e,s)=>e.toAffine(t[s]))).map(b.fromAffine)}static msm(e,t){return ve(b,u,e,t)}_setWindowSize(e){_.setWindowSize(this,e)}assertValidity(){m(this)}equals(e){y(e);const{ex:t,ey:s,ez:i}=this,{ex:r,ey:n,ez:o}=e,a=h(t*o),c=h(r*i),l=h(s*o),u=h(n*i);return a===c&&l===u}is0(){return this.equals(b.ZERO)}negate(){return new b(h(-this.ex),this.ey,this.ez,h(-this.et))}double(){const{a:e}=t,{ex:s,ey:i,ez:r}=this,n=h(s*s),o=h(i*i),a=h(Se*h(r*r)),c=h(e*n),l=s+i,u=h(h(l*l)-n-o),p=c+o,d=p-a,f=c-o,g=h(u*d),y=h(p*f),w=h(u*f),m=h(d*p);return new b(g,y,m,w)}add(e){y(e);const{a:s,d:i}=t,{ex:r,ey:n,ez:o,et:a}=this,{ex:c,ey:l,ez:u,et:p}=e;if(s===BigInt(-1)){const e=h((n-r)*(l+c)),t=h((n+r)*(l-c)),s=h(t-e);if(s===_e)return this.double();const i=h(o*Se*p),d=h(a*Se*u),f=d+i,g=t+e,y=d-i,w=h(f*s),m=h(g*y),v=h(f*y),E=h(s*g);return new b(w,m,E,v)}const d=h(r*c),f=h(n*l),g=h(a*i*p),w=h(o*u),m=h((r+n)*(c+l)-d-f),v=w-g,E=w+g,_=h(f-s*d),R=h(m*v),S=h(E*_),I=h(m*_),x=h(v*E);return new b(R,S,x,I)}subtract(e){return this.add(e.negate())}wNAF(e){return _.wNAFCached(this,e,b.normalizeZ)}multiply(e){const t=e;G("scalar",t,Re,i);const{p:s,f:r}=this.wNAF(t);return b.normalizeZ([s,r])[0]}multiplyUnsafe(e,t=b.ZERO){const s=e;return G("scalar",s,_e,i),s===_e?E:this.is0()||s===Re?this:_.wNAFCachedUnsafe(this,s,b.normalizeZ,t)}isSmallOrder(){return this.multiplyUnsafe(c).is0()}isTorsionFree(){return _.unsafeLadder(this,i).is0()}toAffine(e){return w(this,e)}clearCofactor(){const{h:e}=t;return e===Re?this:this.multiplyUnsafe(e)}static fromHex(e,i=!1){const{d:r,a:n}=t,o=s.BYTES;e=$("pointHex",e,o),T("zip215",i);const a=e.slice(),c=e[o-1];a[o-1]=-129&c;const u=k(a),d=i?l:s.ORDER;G("pointHex.y",u,_e,d);const f=h(u*u),g=h(f-Re),y=h(r*f-n);let{isValid:w,value:m}=p(g,y);if(!w)throw new Error("Point.fromHex: invalid y coordinate");const v=(m&Re)===Re,E=!!(128&c);if(!i&&m===_e&&E)throw new Error("Point.fromHex: x=0 and x_0=1");return E!==v&&(m=h(-m)),b.fromAffine({x:m,y:u})}static fromPrivateKey(e){return I(e).point}toRawBytes(){const{x:e,y:t}=this.toAffine(),i=H(t,s.BYTES);return i[i.length-1]|=e&Re?128:0,i}toHex(){return P(this.toRawBytes())}}b.BASE=new b(t.Gx,t.Gy,Re,h(t.Gx*t.Gy)),b.ZERO=new b(_e,Re,Re,_e);const{BASE:v,ZERO:E}=b,_=function(e,t){return{constTimeNegate:fe,hasPrecomputes:e=>1!==be(e),unsafeLadder(t,s,i=e.ZERO){let r=t;for(;s>pe;)s&de&&(i=i.add(r)),r=r.double(),s>>=de;return i},precomputeWindow(e,s){const{windows:i,windowSize:r}=ye(s,t),n=[];let o=e,a=o;for(let e=0;e>=u,s>o&&(s-=h,r+=de);const n=t,p=t+Math.abs(s)-1,d=e%2!=0,f=s<0;0===s?c=c.add(fe(d,i[n])):a=a.add(fe(f,i[p]))}return{p:a,f:c}},wNAFUnsafe(s,i,r,n=e.ZERO){const{windows:o,windowSize:a}=ye(s,t),c=BigInt(2**s-1),l=2**s,h=BigInt(s);for(let e=0;e>=h,s>a&&(s-=l,r+=de),0===s)continue;let o=i[t+Math.abs(s)-1];s<0&&(o=o.negate()),n=n.add(o)}return n},getPrecomputes(e,t,s){let i=we.get(t);return i||(i=this.precomputeWindow(t,e),1!==e&&we.set(t,s(i))),i},wNAFCached(e,t,s){const i=be(e);return this.wNAF(i,this.getPrecomputes(i,e,s),t)},wNAFCachedUnsafe(e,t,s,i){const r=be(e);return 1===r?this.unsafeLadder(e,t,i):this.wNAFUnsafe(r,this.getPrecomputes(r,e,s),t,i)},setWindowSize(e,s){ge(s,t),me.set(e,s),we.delete(e)}}}(b,8*a);function R(e){return re(e,i)}function S(e){return R(k(e))}function I(e){const t=s.BYTES;e=$("private key",e,t);const i=$("hashed private key",n(e),2*t),r=d(i.slice(0,t)),o=i.slice(t,2*t),a=S(r),c=v.multiply(a),l=c.toRawBytes();return{head:r,prefix:o,scalar:a,point:c,pointBytes:l}}function x(e=new Uint8Array,...t){const s=F(...t);return S(n(f(s,$("context",e),!!r)))}const O=xe;return v._setWindowSize(8),{CURVE:t,getPublicKey:function(e){return I(e).pointBytes},sign:function(e,t,n={}){e=$("message",e),r&&(e=r(e));const{prefix:o,scalar:a,pointBytes:c}=I(t),l=x(n.context,o,e),h=v.multiply(l).toRawBytes(),u=R(l+x(n.context,h,c,e)*a);return G("signature.s",u,_e,i),$("result",F(h,H(u,s.BYTES)),2*s.BYTES)},verify:function(e,t,i,n=O){const{context:o,zip215:a}=n,c=s.BYTES;e=$("signature",e,2*c),t=$("message",t),i=$("publicKey",i,c),void 0!==a&&T("zip215",a),r&&(t=r(t));const l=k(e.slice(c,2*c));let h,u,p;try{h=b.fromHex(i,a),u=b.fromHex(e.slice(0,c),a),p=v.multiplyUnsafe(l)}catch{return!1}if(!a&&h.isSmallOrder())return!1;const d=x(o,u.toRawBytes(),h.toRawBytes(),t);return u.add(h.multiplyUnsafe(d)).subtract(p).clearCofactor().equals(b.ZERO)},ExtendedPoint:b,utils:{getExtendedPublicKey:I,randomPrivateKey:()=>o(s.BYTES),precompute:(e=8,t=b.BASE)=>(t._setWindowSize(e),t.multiply(BigInt(3)),t)}}}BigInt(0),BigInt(1);const Te=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949"),Ae=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");BigInt(0);const Pe=BigInt(1),Ne=BigInt(2);BigInt(3);const qe=BigInt(5),Le=BigInt(8);function Ue(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}function De(e,t){const s=Te,i=re(t*t*t,s),r=function(e){const t=BigInt(10),s=BigInt(20),i=BigInt(40),r=BigInt(80),n=Te,o=e*e%n*e%n,a=oe(o,Ne,n)*o%n,c=oe(a,Pe,n)*e%n,l=oe(c,qe,n)*c%n,h=oe(l,t,n)*l%n,u=oe(h,s,n)*h%n,p=oe(u,i,n)*u%n,d=oe(p,r,n)*p%n,f=oe(d,r,n)*p%n,g=oe(f,t,n)*l%n;return{pow_p_5_8:oe(g,Ne,n)*e%n,b2:o}}(e*re(i*i*t,s)).pow_p_5_8;let n=re(e*i*r,s);const o=re(t*n*n,s),a=n,c=re(n*Ae,s),l=o===e,h=o===re(-e,s),u=o===re(-e*Ae,s);return l&&(n=a),(h||u)&&(n=c),((e,t)=>(re(e,t)&X)===X)(n,s)&&(n=re(-n,s)),{isValid:l||h,value:n}}const Be=ue(Te,void 0,!0),Ce=Oe({a:BigInt(-1),d:BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),Fp:Be,n:BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),h:Le,Gx:BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),Gy:BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),hash:_,randomBytes:u,adjustScalarBytes:Ue,uvRatio:De}),Me="EdDSA",je="JWT",ke=".",Ve="base64url",He="utf8",$e="utf8",Fe=":",ze="did",Ge="key",Je="base58btc",Ke="z",We="K36",Ye=32;function Qe(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function Xe(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?Qe(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function Ze(e,t){t||(t=e.reduce(((e,t)=>e+t.length),0));const s=Xe(t);let i=0;for(const t of e)s.set(t,i),i+=t.length;return Qe(s)}var et=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),i=0;i>>0,o=new Uint8Array(n);e[t];){var h=s[e.charCodeAt(t)];if(255===h)return;for(var u=0,p=n-1;(0!==h||u>>0,o[p]=h%256>>>0,h=h/256>>>0;if(0!==h)throw new Error("Non-zero carry");r=u,t++}if(" "!==e[t]){for(var d=n-r;d!==n&&0===o[d];)d++;for(var f=new Uint8Array(i+(n-d)),g=i;d!==n;)f[g++]=o[d++];return f}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var s=0,i=0,r=0,n=t.length;r!==n&&0===t[r];)r++,s++;for(var o=(n-r)*h+1>>>0,l=new Uint8Array(o);r!==n;){for(var u=t[r],p=0,d=o-1;(0!==u||p>>0,l[d]=u%a>>>0,u=u/a>>>0;if(0!==u)throw new Error("Non-zero carry");i=p,r++}for(var f=o-i;f!==o&&0===l[f];)f++;for(var g=c.repeat(s);f{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class st{constructor(e,t,s){this.name=e,this.prefix=t,this.baseEncode=s}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class it{constructor(e,t,s){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=s}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 nt(this,e)}}class rt{constructor(e){this.decoders=e}or(e){return nt(this,e)}decode(e){const t=e[0],s=this.decoders[t];if(s)return s.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const nt=(e,t)=>new rt({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class ot{constructor(e,t,s,i){this.name=e,this.prefix=t,this.baseEncode=s,this.baseDecode=i,this.encoder=new st(e,t,s),this.decoder=new it(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const at=({name:e,prefix:t,encode:s,decode:i})=>new ot(e,t,s,i),ct=({prefix:e,name:t,alphabet:s})=>{const{encode:i,decode:r}=et(s,t);return at({prefix:e,name:t,encode:i,decode:e=>tt(r(e))})},lt=({name:e,prefix:t,bitsPerChar:s,alphabet:i})=>at({prefix:t,name:e,encode:e=>((e,t,s)=>{const i="="===t[t.length-1],r=(1<s;)o-=s,n+=t[r&a>>o];if(o&&(n+=t[r&a<((e,t,s,i)=>{const r={};for(let e=0;e=8&&(a-=8,o[l++]=255&c>>a)}if(a>=s||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,i,s,e)}),ht=at({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var ut=Object.freeze({__proto__:null,identity:ht});const pt=lt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var dt=Object.freeze({__proto__:null,base2:pt});const ft=lt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var gt=Object.freeze({__proto__:null,base8:ft});const yt=ct({prefix:"9",name:"base10",alphabet:"0123456789"});var wt=Object.freeze({__proto__:null,base10:yt});const mt=lt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),bt=lt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var vt=Object.freeze({__proto__:null,base16:mt,base16upper:bt});const Et=lt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),_t=lt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Rt=lt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),St=lt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),It=lt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),xt=lt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ot=lt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Tt=lt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),At=lt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Pt=Object.freeze({__proto__:null,base32:Et,base32upper:_t,base32pad:Rt,base32padupper:St,base32hex:It,base32hexupper:xt,base32hexpad:Ot,base32hexpadupper:Tt,base32z:At});const Nt=ct({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),qt=ct({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Lt=Object.freeze({__proto__:null,base36:Nt,base36upper:qt});const Ut=ct({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Dt=ct({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Bt=Object.freeze({__proto__:null,base58btc:Ut,base58flickr:Dt});const Ct=lt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Mt=lt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),jt=lt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),kt=lt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Vt=Object.freeze({__proto__:null,base64:Ct,base64pad:Mt,base64url:jt,base64urlpad:kt});const Ht=Array.from("๐Ÿš€๐Ÿชโ˜„๐Ÿ›ฐ๐ŸŒŒ๐ŸŒ‘๐ŸŒ’๐ŸŒ“๐ŸŒ”๐ŸŒ•๐ŸŒ–๐ŸŒ—๐ŸŒ˜๐ŸŒ๐ŸŒ๐ŸŒŽ๐Ÿ‰โ˜€๐Ÿ’ป๐Ÿ–ฅ๐Ÿ’พ๐Ÿ’ฟ๐Ÿ˜‚โค๐Ÿ˜๐Ÿคฃ๐Ÿ˜Š๐Ÿ™๐Ÿ’•๐Ÿ˜ญ๐Ÿ˜˜๐Ÿ‘๐Ÿ˜…๐Ÿ‘๐Ÿ˜๐Ÿ”ฅ๐Ÿฅฐ๐Ÿ’”๐Ÿ’–๐Ÿ’™๐Ÿ˜ข๐Ÿค”๐Ÿ˜†๐Ÿ™„๐Ÿ’ช๐Ÿ˜‰โ˜บ๐Ÿ‘Œ๐Ÿค—๐Ÿ’œ๐Ÿ˜”๐Ÿ˜Ž๐Ÿ˜‡๐ŸŒน๐Ÿคฆ๐ŸŽ‰๐Ÿ’žโœŒโœจ๐Ÿคท๐Ÿ˜ฑ๐Ÿ˜Œ๐ŸŒธ๐Ÿ™Œ๐Ÿ˜‹๐Ÿ’—๐Ÿ’š๐Ÿ˜๐Ÿ’›๐Ÿ™‚๐Ÿ’“๐Ÿคฉ๐Ÿ˜„๐Ÿ˜€๐Ÿ–ค๐Ÿ˜ƒ๐Ÿ’ฏ๐Ÿ™ˆ๐Ÿ‘‡๐ŸŽถ๐Ÿ˜’๐Ÿคญโฃ๐Ÿ˜œ๐Ÿ’‹๐Ÿ‘€๐Ÿ˜ช๐Ÿ˜‘๐Ÿ’ฅ๐Ÿ™‹๐Ÿ˜ž๐Ÿ˜ฉ๐Ÿ˜ก๐Ÿคช๐Ÿ‘Š๐Ÿฅณ๐Ÿ˜ฅ๐Ÿคค๐Ÿ‘‰๐Ÿ’ƒ๐Ÿ˜ณโœ‹๐Ÿ˜š๐Ÿ˜๐Ÿ˜ด๐ŸŒŸ๐Ÿ˜ฌ๐Ÿ™ƒ๐Ÿ€๐ŸŒท๐Ÿ˜ป๐Ÿ˜“โญโœ…๐Ÿฅบ๐ŸŒˆ๐Ÿ˜ˆ๐Ÿค˜๐Ÿ’ฆโœ”๐Ÿ˜ฃ๐Ÿƒ๐Ÿ’โ˜น๐ŸŽŠ๐Ÿ’˜๐Ÿ˜ โ˜๐Ÿ˜•๐ŸŒบ๐ŸŽ‚๐ŸŒป๐Ÿ˜๐Ÿ–•๐Ÿ’๐Ÿ™Š๐Ÿ˜น๐Ÿ—ฃ๐Ÿ’ซ๐Ÿ’€๐Ÿ‘‘๐ŸŽต๐Ÿคž๐Ÿ˜›๐Ÿ”ด๐Ÿ˜ค๐ŸŒผ๐Ÿ˜ซโšฝ๐Ÿค™โ˜•๐Ÿ†๐Ÿคซ๐Ÿ‘ˆ๐Ÿ˜ฎ๐Ÿ™†๐Ÿป๐Ÿƒ๐Ÿถ๐Ÿ’๐Ÿ˜ฒ๐ŸŒฟ๐Ÿงก๐ŸŽโšก๐ŸŒž๐ŸŽˆโŒโœŠ๐Ÿ‘‹๐Ÿ˜ฐ๐Ÿคจ๐Ÿ˜ถ๐Ÿค๐Ÿšถ๐Ÿ’ฐ๐Ÿ“๐Ÿ’ข๐ŸคŸ๐Ÿ™๐Ÿšจ๐Ÿ’จ๐Ÿคฌโœˆ๐ŸŽ€๐Ÿบ๐Ÿค“๐Ÿ˜™๐Ÿ’Ÿ๐ŸŒฑ๐Ÿ˜–๐Ÿ‘ถ๐Ÿฅดโ–ถโžกโ“๐Ÿ’Ž๐Ÿ’ธโฌ‡๐Ÿ˜จ๐ŸŒš๐Ÿฆ‹๐Ÿ˜ท๐Ÿ•บโš ๐Ÿ™…๐Ÿ˜Ÿ๐Ÿ˜ต๐Ÿ‘Ž๐Ÿคฒ๐Ÿค ๐Ÿคง๐Ÿ“Œ๐Ÿ”ต๐Ÿ’…๐Ÿง๐Ÿพ๐Ÿ’๐Ÿ˜—๐Ÿค‘๐ŸŒŠ๐Ÿคฏ๐Ÿทโ˜Ž๐Ÿ’ง๐Ÿ˜ฏ๐Ÿ’†๐Ÿ‘†๐ŸŽค๐Ÿ™‡๐Ÿ‘โ„๐ŸŒด๐Ÿ’ฃ๐Ÿธ๐Ÿ’Œ๐Ÿ“๐Ÿฅ€๐Ÿคข๐Ÿ‘…๐Ÿ’ก๐Ÿ’ฉ๐Ÿ‘๐Ÿ“ธ๐Ÿ‘ป๐Ÿค๐Ÿคฎ๐ŸŽผ๐Ÿฅต๐Ÿšฉ๐ŸŽ๐ŸŠ๐Ÿ‘ผ๐Ÿ’๐Ÿ“ฃ๐Ÿฅ‚"),$t=Ht.reduce(((e,t,s)=>(e[s]=t,e)),[]),Ft=Ht.reduce(((e,t,s)=>(e[t.codePointAt(0)]=s,e)),[]);const zt=at({prefix:"๐Ÿš€",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=$t[t]),"")},decode:function(e){const t=[];for(const s of e){const e=Ft[s.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${s}`);t.push(e)}return new Uint8Array(t)}});var Gt=Object.freeze({__proto__:null,base256emoji:zt}),Jt=function e(t,s,i){s=s||[];for(var r=i=i||0;t>=Yt;)s[i++]=255&t|Kt,t/=128;for(;t&Wt;)s[i++]=255&t|Kt,t>>>=7;return s[i]=0|t,e.bytes=i-r+1,s},Kt=128,Wt=-128,Yt=Math.pow(2,31);var Qt=function e(t,s){var i,r=0,n=0,o=s=s||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");i=t[o++],r+=n<28?(i&Zt)<=Xt);return e.bytes=o-s,r},Xt=128,Zt=127;var es=Math.pow(2,7),ts=Math.pow(2,14),ss=Math.pow(2,21),is=Math.pow(2,28),rs=Math.pow(2,35),ns=Math.pow(2,42),os=Math.pow(2,49),as=Math.pow(2,56),cs=Math.pow(2,63),ls={encode:Jt,decode:Qt,encodingLength:function(e){return e(ls.encode(e,t,s),t),us=e=>ls.encodingLength(e),ps=(e,t)=>{const s=t.byteLength,i=us(e),r=i+us(s),n=new Uint8Array(r+s);return hs(e,n,0),hs(s,n,i),n.set(t,r),new ds(e,s,t,n)};class ds{constructor(e,t,s,i){this.code=e,this.size=t,this.digest=s,this.bytes=i}}const fs=({name:e,code:t,encode:s})=>new gs(e,t,s);class gs{constructor(e,t,s){this.name=e,this.code=t,this.encode=s}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ps(this.code,t):t.then((e=>ps(this.code,e)))}throw Error("Unknown type, must be binary type")}}const ys=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),ws=fs({name:"sha2-256",code:18,encode:ys("SHA-256")}),ms=fs({name:"sha2-512",code:19,encode:ys("SHA-512")});Object.freeze({__proto__:null,sha256:ws,sha512:ms});const bs=tt,vs={code:0,name:"identity",encode:bs,digest:e=>ps(0,bs(e))};Object.freeze({__proto__:null,identity:vs});new TextEncoder,new TextDecoder;const Es={...ut,...dt,...gt,...wt,...vt,...Pt,...Lt,...Bt,...Vt,...Gt};function _s(e,t,s,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:s},decoder:{decode:i}}}const Rs=_s("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Ss=_s("ascii","a",(e=>{let t="a";for(let s=0;s{const t=Xe((e=e.substring(1)).length);for(let s=0;s{"use strict";s.d(t,{IJsonRpcProvider:()=>o.kF,formatJsonRpcError:()=>n.dZ,formatJsonRpcRequest:()=>n.e_,formatJsonRpcResult:()=>n.Im,getBigIntRpcId:()=>n.eX,isHttpUrl:()=>a.q$,isJsonRpcError:()=>c.U$,isJsonRpcRequest:()=>c.p3,isJsonRpcResponse:()=>c.tq,isJsonRpcResult:()=>c.xT,isLocalhostUrl:()=>a.z,isWsUrl:()=>a.A1,parseConnectionError:()=>i.eF,payloadId:()=>n.ER});s(44410);var i=s(75845),r=s(59872);s.o(r,"IJsonRpcProvider")&&s.d(t,{IJsonRpcProvider:function(){return r.IJsonRpcProvider}}),s.o(r,"formatJsonRpcError")&&s.d(t,{formatJsonRpcError:function(){return r.formatJsonRpcError}}),s.o(r,"formatJsonRpcRequest")&&s.d(t,{formatJsonRpcRequest:function(){return r.formatJsonRpcRequest}}),s.o(r,"formatJsonRpcResult")&&s.d(t,{formatJsonRpcResult:function(){return r.formatJsonRpcResult}}),s.o(r,"getBigIntRpcId")&&s.d(t,{getBigIntRpcId:function(){return r.getBigIntRpcId}}),s.o(r,"isHttpUrl")&&s.d(t,{isHttpUrl:function(){return r.isHttpUrl}}),s.o(r,"isJsonRpcError")&&s.d(t,{isJsonRpcError:function(){return r.isJsonRpcError}}),s.o(r,"isJsonRpcRequest")&&s.d(t,{isJsonRpcRequest:function(){return r.isJsonRpcRequest}}),s.o(r,"isJsonRpcResponse")&&s.d(t,{isJsonRpcResponse:function(){return r.isJsonRpcResponse}}),s.o(r,"isJsonRpcResult")&&s.d(t,{isJsonRpcResult:function(){return r.isJsonRpcResult}}),s.o(r,"isLocalhostUrl")&&s.d(t,{isLocalhostUrl:function(){return r.isLocalhostUrl}}),s.o(r,"isReactNative")&&s.d(t,{isReactNative:function(){return r.isReactNative}}),s.o(r,"isWsUrl")&&s.d(t,{isWsUrl:function(){return r.isWsUrl}}),s.o(r,"payloadId")&&s.d(t,{payloadId:function(){return r.payloadId}});var n=s(86668),o=s(30947),a=s(17182),c=s(99784)},43228:(e,t,s)=>{"use strict";s.d(t,{CG:()=>i});const i={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"}}},44410:(e,t,s)=>{"use strict";s.d(t,{Uf:()=>h,XW:()=>u,fO:()=>c,jf:()=>l,zR:()=>a});const i="PARSE_ERROR",r="INVALID_REQUEST",n="METHOD_NOT_FOUND",o="INVALID_PARAMS",a="INTERNAL_ERROR",c="SERVER_ERROR",l=[-32700,-32600,-32601,-32602,-32603],h={[i]:{code:-32700,message:"Parse error"},[r]:{code:-32600,message:"Invalid Request"},[n]:{code:-32601,message:"Method not found"},[o]:{code:-32602,message:"Invalid params"},[a]:{code:-32603,message:"Internal error"},[c]:{code:-32e3,message:"Server error"}},u=c},49026:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(80584);i.__exportStar(s(79244),t),i.__exportStar(s(31861),t)},55669:(e,t,s)=>{"use strict";s.d(t,{A:()=>d});var i=s(43984),r=s(77783),n=s(13554);var o=(e={})=>{const t=e.base&&e.base.length>0?`${e.base}:`:"",s=e=>t+e;let i;return e.dbName&&e.storeName&&(i=(0,r.y$)(e.dbName,e.storeName)),{name:"idb-keyval",options:e,hasItem:async e=>!(typeof await(0,r.Jt)(s(e),i)>"u"),getItem:async e=>await(0,r.Jt)(s(e),i)??null,setItem:(e,t)=>(0,r.hZ)(s(e),t,i),removeItem:e=>(0,r.yH)(s(e),i),getKeys:()=>(0,r.HP)(i),clear:()=>(0,r.IU)(i)}};class a{constructor(){this.indexedDb=(0,i.wE)({driver:o({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){const t=await this.indexedDb.getItem(e);if(null!==t)return t}async setItem(e,t){await this.indexedDb.setItem(e,(0,n.h)(t))}async removeItem(e){await this.indexedDb.removeItem(e)}}var c=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof s.g<"u"?s.g:typeof self<"u"?self:{},l={exports:{}};function h(e){var t;return[e[0],(0,n.j)(null!=(t=e[1])?t:"")]}!function(){let e;function t(){}e=t,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(){const 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})),typeof c<"u"&&c.localStorage?l.exports=c.localStorage:typeof window<"u"&&window.localStorage?l.exports=window.localStorage:l.exports=new t}();class u{constructor(){this.localStorage=l.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(h)}async getItem(e){const t=this.localStorage.getItem(e);if(null!==t)return(0,n.j)(t)}async setItem(e,t){this.localStorage.setItem(e,(0,n.h)(t))}async removeItem(e){this.localStorage.removeItem(e)}}const p=async(e,t)=>{t.length&&t.forEach((async t=>{await e.removeItem(t)}))};class d{constructor(){this.initialized=!1,this.setInitialized=e=>{this.storage=e,this.initialized=!0};const e=new u;this.storage=e;try{(async(e,t,s)=>{const i="wc_storage_version",r=await t.getItem(i);if(r&&r>=1)return void s(t);const n=await e.getKeys();if(!n.length)return void s(t);const o=[];for(;n.length;){const s=n.shift();if(!s)continue;const i=s.toLowerCase();if(i.includes("wc@")||i.includes("walletconnect")||i.includes("wc_")||i.includes("wallet_connect")){const i=await e.getItem(s);await t.setItem(s,i),o.push(s)}}await t.setItem(i,1),s(t),p(e,o)})(e,new a,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=>{const t=setInterval((()=>{this.initialized&&(clearInterval(t),e())}),20)}))}}},59872:(e,t,s)=>{"use strict";var i=s(25682);s.o(i,"IJsonRpcProvider")&&s.d(t,{IJsonRpcProvider:function(){return i.IJsonRpcProvider}}),s.o(i,"formatJsonRpcError")&&s.d(t,{formatJsonRpcError:function(){return i.formatJsonRpcError}}),s.o(i,"formatJsonRpcRequest")&&s.d(t,{formatJsonRpcRequest:function(){return i.formatJsonRpcRequest}}),s.o(i,"formatJsonRpcResult")&&s.d(t,{formatJsonRpcResult:function(){return i.formatJsonRpcResult}}),s.o(i,"getBigIntRpcId")&&s.d(t,{getBigIntRpcId:function(){return i.getBigIntRpcId}}),s.o(i,"isHttpUrl")&&s.d(t,{isHttpUrl:function(){return i.isHttpUrl}}),s.o(i,"isJsonRpcError")&&s.d(t,{isJsonRpcError:function(){return i.isJsonRpcError}}),s.o(i,"isJsonRpcRequest")&&s.d(t,{isJsonRpcRequest:function(){return i.isJsonRpcRequest}}),s.o(i,"isJsonRpcResponse")&&s.d(t,{isJsonRpcResponse:function(){return i.isJsonRpcResponse}}),s.o(i,"isJsonRpcResult")&&s.d(t,{isJsonRpcResult:function(){return i.isJsonRpcResult}}),s.o(i,"isLocalhostUrl")&&s.d(t,{isLocalhostUrl:function(){return i.isLocalhostUrl}}),s.o(i,"isReactNative")&&s.d(t,{isReactNative:function(){return i.isReactNative}}),s.o(i,"isWsUrl")&&s.d(t,{isWsUrl:function(){return i.isWsUrl}}),s.o(i,"payloadId")&&s.d(t,{payloadId:function(){return i.payloadId}})},60221:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fromMiliseconds=t.toMiliseconds=void 0;const i=s(49026);t.toMiliseconds=function(e){return e*i.ONE_THOUSAND},t.fromMiliseconds=function(e){return Math.floor(e/i.ONE_THOUSAND)}},62010:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});s(80584).__exportStar(s(63093),t)},63093:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.IWatch=void 0;t.IWatch=class{}},66023:(e,t,s)=>{"use strict";s.d(t,{Ay:()=>H,L6:()=>y});var i=s(32573),r=s(29838),n=s(72225),o=s(88900),a=s(36525),c=s(37007),l=s.n(c),h=s(39031);const u="client",p=`wc@2:${u}:`,d=u,f="error",g="WALLETCONNECT_DEEPLINK_CHOICE",y="Proposal expired",w=o.SEVEN_DAYS,m={wc_sessionPropose:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1104},res:{ttl:o.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1106},res:{ttl:o.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1112},res:{ttl:o.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1114},res:{ttl:o.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:o.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:o.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1119}}},b={min:o.FIVE_MINUTES,max:o.SEVEN_DAYS},v="IDLE",E="ACTIVE",_=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],R="wc@1.5:auth:",S=`${R}:PUB_KEY`;var I=Object.defineProperty,x=Object.defineProperties,O=Object.getOwnPropertyDescriptors,T=Object.getOwnPropertySymbols,A=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,N=(e,t,s)=>t in e?I(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,q=(e,t)=>{for(var s in t||(t={}))A.call(t,s)&&N(e,s,t[s]);if(T)for(var s of T(t))P.call(t,s)&&N(e,s,t[s]);return e},L=(e,t)=>x(e,O(t));class U extends n.yJ{constructor(e){super(e),this.name="engine",this.events=new(l()),this.initialized=!1,this.requestQueue={state:v,queue:[]},this.sessionRequestQueue={state:v,queue:[]},this.requestQueueDelay=o.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],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(m)}),this.initialized=!0,setTimeout((()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()}),(0,o.toMiliseconds)(this.requestQueueDelay)))},this.connect=async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const t=L(q({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);const{pairingTopic:s,requiredNamespaces:r,optionalNamespaces:n,sessionProperties:c,relays:l}=t;let h,u=s,p=!1;try{if(u){const e=this.client.core.pairing.pairings.get(u);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),p=e.active}}catch(e){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),e}if(!u||!p){const{topic:e,uri:t}=await this.client.core.pairing.create();u=e,h=t}if(!u){const{message:e}=(0,a.GuA)("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(e)}const d=await this.client.core.crypto.generateKeyPair(),f=m.wc_sessionPropose.req.ttl||o.FIVE_MINUTES,g=(0,a.Xw0)(f),w=q({requiredNamespaces:r,optionalNamespaces:n,relays:l??[{protocol:i.sD}],proposer:{publicKey:d,metadata:this.client.metadata},expiryTimestamp:g,pairingTopic:u},c&&{sessionProperties:c}),{reject:b,resolve:v,done:E}=(0,a.Wx8)(f,y);this.events.once((0,a.hEn)("session_connect"),(async({error:e,session:t})=>{if(e)b(e);else if(t){t.self.publicKey=d;const e=L(q({},t),{pairingTopic:w.pairingTopic,requiredNamespaces:w.requiredNamespaces,optionalNamespaces:w.optionalNamespaces,transportType:i.cV.relay});await this.client.session.set(t.topic,e),await this.setExpiry(t.topic,t.expiry),u&&await this.client.core.pairing.updateMetadata({topic:u,metadata:t.peer.metadata}),this.cleanupDuplicatePairings(e),v(e)}}));const _=await this.sendRequest({topic:u,method:"wc_sessionPropose",params:w,throwOnFailedPublish:!0});return await this.setProposal(_,q({id:_},w)),{uri:h,approval:E}},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}},this.approve=async e=>{var t,s,r;const n=this.client.core.eventClient.createEvent({properties:{topic:null==(t=e?.id)?void 0:t.toString(),trace:[i.$I.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(e){throw n.setError(i.U.no_internet_connection),e}try{await this.isValidProposalId(e?.id)}catch(t){throw this.client.logger.error(`approve() -> proposal.get(${e?.id}) failed`),n.setError(i.U.proposal_not_found),t}try{await this.isValidApprove(e)}catch(e){throw this.client.logger.error("approve() -> isValidApprove() failed"),n.setError(i.U.session_approve_namespace_validation_failure),e}const{id:o,relayProtocol:c,namespaces:l,sessionProperties:h,sessionConfig:u}=e,p=this.client.proposal.get(o);this.client.core.eventClient.deleteEvent({eventId:n.eventId});const{pairingTopic:d,proposer:f,requiredNamespaces:g,optionalNamespaces:y}=p;let m=null==(s=this.client.core.eventClient)?void 0:s.getEvent({topic:d});m||(m=null==(r=this.client.core.eventClient)?void 0:r.createEvent({type:i.$I.session_approve_started,properties:{topic:d,trace:[i.$I.session_approve_started,i.$I.session_namespaces_validation_success]}}));const b=await this.client.core.crypto.generateKeyPair(),v=f.publicKey,E=await this.client.core.crypto.generateSharedKey(b,v),_=q(q({relay:{protocol:c??"irn"},namespaces:l,controller:{publicKey:b,metadata:this.client.metadata},expiry:(0,a.Xw0)(w)},h&&{sessionProperties:h}),u&&{sessionConfig:u}),R=i.cV.relay;m.addTrace(i.$I.subscribing_session_topic);try{await this.client.core.relayer.subscribe(E,{transportType:R})}catch(e){throw m.setError(i.U.subscribe_session_topic_failure),e}m.addTrace(i.$I.subscribe_session_topic_success);const S=L(q({},_),{topic:E,requiredNamespaces:g,optionalNamespaces:y,pairingTopic:d,acknowledged:!1,self:_.controller,peer:{publicKey:f.publicKey,metadata:f.metadata},controller:b,transportType:i.cV.relay});await this.client.session.set(E,S),m.addTrace(i.$I.store_session);try{m.addTrace(i.$I.publishing_session_settle),await this.sendRequest({topic:E,method:"wc_sessionSettle",params:_,throwOnFailedPublish:!0}).catch((e=>{throw m?.setError(i.U.session_settle_publish_failure),e})),m.addTrace(i.$I.session_settle_publish_success),m.addTrace(i.$I.publishing_session_approve),await this.sendResult({id:o,topic:d,result:{relay:{protocol:c??"irn"},responderPublicKey:b},throwOnFailedPublish:!0}).catch((e=>{throw m?.setError(i.U.session_approve_publish_failure),e})),m.addTrace(i.$I.session_approve_publish_success)}catch(e){throw this.client.logger.error(e),this.client.session.delete(E,(0,a.Hjj)("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(E),e}return this.client.core.eventClient.deleteEvent({eventId:m.eventId}),await this.client.core.pairing.updateMetadata({topic:d,metadata:f.metadata}),await this.client.proposal.delete(o,(0,a.Hjj)("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:d}),await this.setExpiry(E,(0,a.Xw0)(w)),{topic:E,acknowledged:()=>Promise.resolve(this.client.session.get(E))}},this.reject=async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(e)}catch(e){throw this.client.logger.error("reject() -> isValidReject() failed"),e}const{id:t,reason:s}=e;let i;try{i=this.client.proposal.get(t).pairingTopic}catch(e){throw this.client.logger.error(`reject() -> proposal.get(${t}) failed`),e}i&&(await this.sendError({id:t,topic:i,error:s,rpcOpts:m.wc_sessionPropose.reject}),await this.client.proposal.delete(t,(0,a.Hjj)("USER_DISCONNECTED")))},this.update=async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(e)}catch(e){throw this.client.logger.error("update() -> isValidUpdate() failed"),e}const{topic:t,namespaces:s}=e,{done:i,resolve:r,reject:n}=(0,a.Wx8)(),o=(0,h.payloadId)(),c=(0,h.getBigIntRpcId)().toString(),l=this.client.session.get(t).namespaces;return this.events.once((0,a.hEn)("session_update",o),(({error:e})=>{e?n(e):r()})),await this.client.session.update(t,{namespaces:s}),await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:!0,clientRpcId:o,relayRpcId:c}).catch((e=>{this.client.logger.error(e),this.client.session.update(t,{namespaces:l}),n(e)})),{acknowledged:i}},this.extend=async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(e)}catch(e){throw this.client.logger.error("extend() -> isValidExtend() failed"),e}const{topic:t}=e,s=(0,h.payloadId)(),{done:i,resolve:r,reject:n}=(0,a.Wx8)();return this.events.once((0,a.hEn)("session_extend",s),(({error:e})=>{e?n(e):r()})),await this.setExpiry(t,(0,a.Xw0)(w)),this.sendRequest({topic:t,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:!0}).catch((e=>{n(e)})),{acknowledged:i}},this.request=async e=>{this.isInitialized();try{await this.isValidRequest(e)}catch(e){throw this.client.logger.error("request() -> isValidRequest() failed"),e}const{chainId:t,request:s,topic:r,expiry:n=m.wc_sessionRequest.req.ttl}=e,o=this.client.session.get(r);o?.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const c=(0,h.payloadId)(),l=(0,h.getBigIntRpcId)().toString(),{done:u,resolve:p,reject:d}=(0,a.Wx8)(n,"Request expired. Please try again.");this.events.once((0,a.hEn)("session_request",c),(({error:e,result:t})=>{e?d(e):p(t)}));const f=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);return f?(await this.sendRequest({clientRpcId:c,relayRpcId:l,topic:r,method:"wc_sessionRequest",params:{request:L(q({},s),{expiryTimestamp:(0,a.Xw0)(n)}),chainId:t},expiry:n,throwOnFailedPublish:!0,appLink:f}).catch((e=>d(e))),this.client.events.emit("session_request_sent",{topic:r,request:s,chainId:t,id:c}),await u()):await Promise.all([new Promise((async e=>{await this.sendRequest({clientRpcId:c,relayRpcId:l,topic:r,method:"wc_sessionRequest",params:{request:L(q({},s),{expiryTimestamp:(0,a.Xw0)(n)}),chainId:t},expiry:n,throwOnFailedPublish:!0}).catch((e=>d(e))),this.client.events.emit("session_request_sent",{topic:r,request:s,chainId:t,id:c}),e()})),new Promise((async e=>{var t;if(null==(t=o.sessionConfig)||!t.disableDeepLink){const e=await(0,a.jTh)(this.client.core.storage,g);await(0,a.n3s)({id:c,topic:r,wcDeepLink:e})}e()})),u()]).then((e=>e[2]))},this.respond=async e=>{this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:s}=e,{id:r}=s,n=this.client.session.get(t);n.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const o=this.getAppLinkIfEnabled(n.peer.metadata,n.transportType);(0,h.isJsonRpcResult)(s)?await this.sendResult({id:r,topic:t,result:s.result,throwOnFailedPublish:!0,appLink:o}):(0,h.isJsonRpcError)(s)&&await this.sendError({id:r,topic:t,error:s.error,appLink:o}),this.cleanupAfterResponse(e)},this.ping=async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(e)}catch(e){throw this.client.logger.error("ping() -> isValidPing() failed"),e}const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=(0,h.payloadId)(),s=(0,h.getBigIntRpcId)().toString(),{done:i,resolve:r,reject:n}=(0,a.Wx8)();this.events.once((0,a.hEn)("session_ping",e),(({error:e})=>{e?n(e):r()})),await Promise.all([this.sendRequest({topic:t,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:e,relayRpcId:s}),i()])}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}))},this.emit=async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(e);const{topic:t,event:s,chainId:i}=e,r=(0,h.getBigIntRpcId)().toString(),n=(0,h.payloadId)();await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:s,chainId:i},throwOnFailedPublish:!0,relayRpcId:r,clientRpcId:n})},this.disconnect=async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(e);const{topic:t}=e;if(this.client.session.keys.includes(t))await this.sendRequest({topic:t,method:"wc_sessionDelete",params:(0,a.Hjj)("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:t,emitEvent:!1});else{if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=(0,a.GuA)("MISMATCHED_TOPIC",`Session or pairing topic not found: ${t}`);throw new Error(e)}await this.client.core.pairing.disconnect({topic:t})}},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter((t=>(0,a.HNf)(t,e)))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(e,t)=>{var s;this.isInitialized(),this.isValidAuthenticate(e);const r=t&&this.client.core.linkModeSupportedApps.includes(t)&&(null==(s=this.client.metadata.redirect)?void 0:s.linkMode),n=r?i.cV.link_mode:i.cV.relay;n===i.cV.relay&&await this.confirmOnlineStateOrThrow();const{chains:o,statement:c="",uri:l,domain:u,nonce:p,type:d,exp:f,nbf:g,methods:y=[],expiry:b}=e,v=[...e.resources||[]],{topic:E,uri:_}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:n});this.client.logger.info({message:"Generated new pairing",pairing:{topic:E,uri:_}});const R=await this.client.core.crypto.generateKeyPair(),I=(0,a.EN$)(R);if(await Promise.all([this.client.auth.authKeys.set(S,{responseTopic:I,publicKey:R}),this.client.auth.pairingTopics.set(I,{topic:I,pairingTopic:E})]),await this.client.core.relayer.subscribe(I,{transportType:n}),this.client.logger.info(`sending request to new pairing topic: ${E}`),y.length>0){const{namespace:e}=(0,a._Yb)(o[0]);let t=(0,a.e8_)(e,"request",y);(0,a.VBM)(v)&&(t=(0,a.hVC)(t,v.pop())),v.push(t)}const x=b&&b>m.wc_sessionAuthenticate.req.ttl?b:m.wc_sessionAuthenticate.req.ttl,O={authPayload:{type:d??"caip122",chains:o,statement:c,aud:l,domain:u,version:"1",nonce:p,iat:(new Date).toISOString(),exp:f,nbf:g,resources:v},requester:{publicKey:R,metadata:this.client.metadata},expiryTimestamp:(0,a.Xw0)(x)},T={requiredNamespaces:{},optionalNamespaces:{eip155:{chains:o,methods:[...new Set(["personal_sign",...y])],events:["chainChanged","accountsChanged"]}},relays:[{protocol:"irn"}],pairingTopic:E,proposer:{publicKey:R,metadata:this.client.metadata},expiryTimestamp:(0,a.Xw0)(m.wc_sessionPropose.req.ttl)},{done:A,resolve:P,reject:N}=(0,a.Wx8)(x,"Request expired"),U=async({error:e,session:t})=>{if(this.events.off((0,a.hEn)("session_request",B),D),e)N(e);else if(t){t.self.publicKey=R,await this.client.session.set(t.topic,t),await this.setExpiry(t.topic,t.expiry),E&&await this.client.core.pairing.updateMetadata({topic:E,metadata:t.peer.metadata});const e=this.client.session.get(t.topic);await this.deleteProposal(C),P({session:e})}},D=async e=>{var s,r,o;if(await this.deletePendingAuthRequest(B,{message:"fulfilled",code:0}),e.error){const t=(0,a.Hjj)("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return e.error.code===t.code?void 0:(this.events.off((0,a.hEn)("session_connect"),U),N(e.error.message))}await this.deleteProposal(C),this.events.off((0,a.hEn)("session_connect"),U);const{cacaos:c,responder:l}=e.result,h=[],u=[];for(const e of c){await(0,a.IjX)({cacao:e,projectId:this.client.core.projectId})||(this.client.logger.error(e,"Signature verification failed"),N((0,a.Hjj)("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:t}=e,s=(0,a.VBM)(t.resources),i=[(0,a.xkc)(t.iss)],r=(0,a.q_h)(t.iss);if(s){const e=(0,a.sc_)(s),t=(0,a.WWN)(s);h.push(...e),i.push(...t)}for(const e of i)u.push(`${e}:${r}`)}const p=await this.client.core.crypto.generateSharedKey(R,l.publicKey);let d;h.length>0&&(d={topic:p,acknowledged:!0,self:{publicKey:R,metadata:this.client.metadata},peer:l,controller:l.publicKey,expiry:(0,a.Xw0)(w),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:E,namespaces:(0,a.Van)([...new Set(h)],[...new Set(u)]),transportType:n},await this.client.core.relayer.subscribe(p,{transportType:n}),await this.client.session.set(p,d),E&&await this.client.core.pairing.updateMetadata({topic:E,metadata:l.metadata}),d=this.client.session.get(p)),null!=(s=this.client.metadata.redirect)&&s.linkMode&&null!=(r=l.metadata.redirect)&&r.linkMode&&null!=(o=l.metadata.redirect)&&o.universal&&t&&(this.client.core.addLinkModeSupportedApp(l.metadata.redirect.universal),this.client.session.update(p,{transportType:i.cV.link_mode})),P({auths:c,session:d})},B=(0,h.payloadId)(),C=(0,h.payloadId)();let M;this.events.once((0,a.hEn)("session_connect"),U),this.events.once((0,a.hEn)("session_request",B),D);try{if(r){const e=(0,h.formatJsonRpcRequest)("wc_sessionAuthenticate",O,B);this.client.core.history.set(E,e);const s=await this.client.core.crypto.encode("",e,{type:a.EHS,encoding:a.Pa8});M=(0,a.$Bq)(t,E,s)}else await Promise.all([this.sendRequest({topic:E,method:"wc_sessionAuthenticate",params:O,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:B}),this.sendRequest({topic:E,method:"wc_sessionPropose",params:T,expiry:m.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:C})])}catch(e){throw this.events.off((0,a.hEn)("session_connect"),U),this.events.off((0,a.hEn)("session_request",B),D),e}return await this.setProposal(C,q({id:C},T)),await this.setAuthRequest(B,{request:L(q({},O),{verifyContext:{}}),pairingTopic:E,transportType:n}),{uri:M??_,response:A}},this.approveSessionAuthenticate=async e=>{const{id:t,auths:s}=e,r=this.client.core.eventClient.createEvent({properties:{topic:t.toString(),trace:[i.U$.authenticated_session_approve_started]}});try{this.isInitialized()}catch(e){throw r.setError(i.Tn.no_internet_connection),e}const n=this.getPendingAuthRequest(t);if(!n)throw r.setError(i.Tn.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${t}`);const o=n.transportType||i.cV.relay;o===i.cV.relay&&await this.confirmOnlineStateOrThrow();const c=n.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),h=(0,a.EN$)(c),u={type:a.Lp_,receiverPublicKey:c,senderPublicKey:l},p=[],d=[];for(const e of s){if(!await(0,a.IjX)({cacao:e,projectId:this.client.core.projectId})){r.setError(i.Tn.invalid_cacao);const e=(0,a.Hjj)("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:t,topic:h,error:e,encodeOpts:u}),new Error(e.message)}r.addTrace(i.U$.cacaos_verified);const{p:s}=e,n=(0,a.VBM)(s.resources),o=[(0,a.xkc)(s.iss)],c=(0,a.q_h)(s.iss);if(n){const e=(0,a.sc_)(n),t=(0,a.WWN)(n);p.push(...e),o.push(...t)}for(const e of o)d.push(`${e}:${c}`)}const f=await this.client.core.crypto.generateSharedKey(l,c);let g;if(r.addTrace(i.U$.create_authenticated_session_topic),p?.length>0){g={topic:f,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:c,metadata:n.requester.metadata},controller:c,expiry:(0,a.Xw0)(w),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:n.pairingTopic,namespaces:(0,a.Van)([...new Set(p)],[...new Set(d)]),transportType:o},r.addTrace(i.U$.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(f,{transportType:o})}catch(e){throw r.setError(i.Tn.subscribe_authenticated_session_topic_failure),e}r.addTrace(i.U$.subscribe_authenticated_session_topic_success),await this.client.session.set(f,g),r.addTrace(i.U$.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:n.pairingTopic,metadata:n.requester.metadata})}r.addTrace(i.U$.publishing_authenticated_session_approve);try{await this.sendResult({topic:h,id:t,result:{cacaos:s,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:u,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(n.requester.metadata,o)})}catch(e){throw r.setError(i.Tn.authenticated_session_approve_publish_failure),e}return await this.client.auth.requests.delete(t,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:n.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:r.eventId}),{session:g}},this.rejectSessionAuthenticate=async e=>{this.isInitialized();const{id:t,reason:s}=e,r=this.getPendingAuthRequest(t);if(!r)throw new Error(`Could not find pending auth request with id ${t}`);r.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const n=r.requester.publicKey,o=await this.client.core.crypto.generateKeyPair(),c=(0,a.EN$)(n),l={type:a.Lp_,receiverPublicKey:n,senderPublicKey:o};await this.sendError({id:t,topic:c,error:s,encodeOpts:l,rpcOpts:m.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,(0,a.Hjj)("USER_DISCONNECTED"))},this.formatAuthMessage=e=>{this.isInitialized();const{request:t,iss:s}=e;return(0,a.hwK)(t,s)},this.processRelayMessageCache=()=>{setTimeout((async()=>{if(0!==this.relayMessageCache.length)for(;this.relayMessageCache.length>0;)try{const e=this.relayMessageCache.shift();e&&await this.onRelayMessage(e)}catch(e){this.client.logger.error(e)}}),50)},this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter((s=>{var i,r;return(null==(i=s.peerMetadata)?void 0:i.url)&&(null==(r=s.peerMetadata)?void 0:r.url)===e.peer.metadata.url&&s.topic&&s.topic!==t.topic}));if(0===s.length)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.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)}},this.deleteSession=async e=>{var t;const{topic:s,expirerHasDeleted:i=!1,emitEvent:r=!0,id:n=0}=e,{self:o}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,(0,a.Hjj)("USER_DISCONNECTED")),this.addToRecentlyDeleted(s,"session"),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),i||this.client.core.expirer.del(s),this.client.core.storage.removeItem(g).catch((e=>this.client.logger.warn(e))),this.getPendingSessionRequests().forEach((e=>{e.topic===s&&this.deletePendingSessionRequest(e.id,(0,a.Hjj)("USER_DISCONNECTED"))})),s===(null==(t=this.sessionRequestQueue.queue[0])?void 0:t.topic)&&(this.sessionRequestQueue.state=v),r&&this.client.events.emit("session_delete",{id:n,topic:s})},this.deleteProposal=async(e,t)=>{if(t)try{const t=this.client.proposal.get(e),s=this.client.core.eventClient.getEvent({topic:t.pairingTopic});s?.setError(i.U.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(e,(0,a.Hjj)("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")},this.deletePendingSessionRequest=async(e,t,s=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,t),s?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter((t=>t.id!==e)),s&&(this.sessionRequestQueue.state=v,this.client.events.emit("session_request_expire",{id:e}))},this.deletePendingAuthRequest=async(e,t,s=!1)=>{await Promise.all([this.client.auth.requests.delete(e,t),s?Promise.resolve():this.client.core.expirer.del(e)])},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}))},this.setProposal=async(e,t)=>{this.client.core.expirer.set(e,(0,a.Xw0)(m.wc_sessionPropose.req.ttl)),await this.client.proposal.set(e,t)},this.setAuthRequest=async(e,t)=>{const{request:s,pairingTopic:r,transportType:n=i.cV.relay}=t;this.client.core.expirer.set(e,s.expiryTimestamp),await this.client.auth.requests.set(e,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:e,pairingTopic:r,verifyContext:s.verifyContext,transportType:n})},this.setPendingSessionRequest=async e=>{const{id:t,topic:s,params:i,verifyContext:r}=e,n=i.request.expiryTimestamp||(0,a.Xw0)(m.wc_sessionRequest.req.ttl);this.client.core.expirer.set(t,n),await this.client.pendingRequest.set(t,{id:t,topic:s,params:i,verifyContext:r})},this.sendRequest=async e=>{const{topic:t,method:i,params:r,expiry:n,relayRpcId:o,clientRpcId:c,throwOnFailedPublish:l,appLink:u}=e,p=(0,h.formatJsonRpcRequest)(i,r,c);let d;const f=!!u;try{const e=f?a.Pa8:a.EWt;d=await this.client.core.crypto.encode(t,p,{encoding:e})}catch(e){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${t} failed`),e}let g;if(_.includes(i)){const e=(0,a.ALl)(JSON.stringify(p)),t=(0,a.ALl)(d);g=await this.client.core.verify.register({id:t,decryptedId:e})}const y=m[i].req;if(y.attestation=g,n&&(y.ttl=n),o&&(y.id=o),this.client.core.history.set(t,p),f){const e=(0,a.$Bq)(u,t,d);await s.g.Linking.openURL(e,this.client.name)}else{const e=m[i].req;n&&(e.ttl=n),o&&(e.id=o),l?(e.internal=L(q({},e.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,d,e)):this.client.core.relayer.publish(t,d,e).catch((e=>this.client.logger.error(e)))}return p.id},this.sendResult=async e=>{const{id:t,topic:i,result:r,throwOnFailedPublish:n,encodeOpts:o,appLink:c}=e,l=(0,h.formatJsonRpcResult)(t,r);let u;const p=c&&typeof(null==s.g?void 0:s.g.Linking)<"u";try{const e=p?a.Pa8:a.EWt;u=await this.client.core.crypto.encode(i,l,L(q({},o||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`),e}let d;try{d=await this.client.core.history.get(i,t)}catch(e){throw this.client.logger.error(`sendResult() -> history.get(${i}, ${t}) failed`),e}if(p){const e=(0,a.$Bq)(c,i,u);await s.g.Linking.openURL(e,this.client.name)}else{const e=m[d.request.method].res;n?(e.internal=L(q({},e.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,u,e)):this.client.core.relayer.publish(i,u,e).catch((e=>this.client.logger.error(e)))}await this.client.core.history.resolve(l)},this.sendError=async e=>{const{id:t,topic:i,error:r,encodeOpts:n,rpcOpts:o,appLink:c}=e,l=(0,h.formatJsonRpcError)(t,r);let u;const p=c&&typeof(null==s.g?void 0:s.g.Linking)<"u";try{const e=p?a.Pa8:a.EWt;u=await this.client.core.crypto.encode(i,l,L(q({},n||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${i} failed`),e}let d;try{d=await this.client.core.history.get(i,t)}catch(e){throw this.client.logger.error(`sendError() -> history.get(${i}, ${t}) failed`),e}if(p){const e=(0,a.$Bq)(c,i,u);await s.g.Linking.openURL(e,this.client.name)}else{const e=o||m[d.request.method].res;this.client.core.relayer.publish(i,u,e)}await this.client.core.history.resolve(l)},this.cleanup=async()=>{const e=[],t=[];this.client.session.getAll().forEach((t=>{let s=!1;(0,a._dF)(t.expiry)&&(s=!0),this.client.core.crypto.keychain.has(t.topic)||(s=!0),s&&e.push(t.topic)})),this.client.proposal.getAll().forEach((e=>{(0,a._dF)(e.expiryTimestamp)&&t.push(e.id)})),await Promise.all([...e.map((e=>this.deleteSession({topic:e}))),...t.map((e=>this.deleteProposal(e)))])},this.onRelayEventRequest=async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state!==E){for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=E;const e=this.requestQueue.queue.shift();if(e)try{await this.processRequest(e)}catch(e){this.client.logger.warn(e)}}this.requestQueue.state=v}else this.client.logger.info("Request queue already active, skipping...")},this.processRequest=async e=>{const{topic:t,payload:s,attestation:i,transportType:r,encryptedId:n}=e,o=s.method;if(!this.shouldIgnorePairingRequest({topic:t,requestMethod:o}))switch(o){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:t,payload:s,attestation:i,encryptedId:n});case"wc_sessionSettle":return await this.onSessionSettleRequest(t,s);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(t,s);case"wc_sessionExtend":return await this.onSessionExtendRequest(t,s);case"wc_sessionPing":return await this.onSessionPingRequest(t,s);case"wc_sessionDelete":return await this.onSessionDeleteRequest(t,s);case"wc_sessionRequest":return await this.onSessionRequest({topic:t,payload:s,attestation:i,encryptedId:n,transportType:r});case"wc_sessionEvent":return await this.onSessionEventRequest(t,s);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:t,payload:s,attestation:i,encryptedId:n,transportType:r});default:return this.client.logger.info(`Unsupported request method ${o}`)}},this.onRelayEventResponse=async e=>{const{topic:t,payload:s,transportType:i}=e,r=(await this.client.core.history.get(t,s.id)).request.method;switch(r){case"wc_sessionPropose":return this.onSessionProposeResponse(t,s,i);case"wc_sessionSettle":return this.onSessionSettleResponse(t,s);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,s);case"wc_sessionExtend":return this.onSessionExtendResponse(t,s);case"wc_sessionPing":return this.onSessionPingResponse(t,s);case"wc_sessionRequest":return this.onSessionRequestResponse(t,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(t,s);default:return this.client.logger.info(`Unsupported response method ${r}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:t}=e,{message:s}=(0,a.GuA)("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)},this.shouldIgnorePairingRequest=e=>{const{topic:t,requestMethod:s}=e,i=this.expectedPairingMethodMap.get(t);return!(!i||i.includes(s))&&!!(i.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async e=>{const{topic:t,payload:s,attestation:r,encryptedId:n}=e,{params:o,id:c}=s;try{const e=this.client.core.eventClient.getEvent({topic:t});0===this.client.events.listenerCount("session_proposal")&&e?.setError(i.S$.proposal_listener_not_found),this.isValidConnect(q({},s.params));const l=o.expiryTimestamp||(0,a.Xw0)(m.wc_sessionPropose.req.ttl),h=q({id:c,pairingTopic:t,expiryTimestamp:l},o);await this.setProposal(c,h);const u=await this.getVerifyContext({attestationId:r,hash:(0,a.ALl)(JSON.stringify(s)),encryptedId:n,metadata:h.proposer.metadata});e?.addTrace(i.$w.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:h,verifyContext:u})}catch(e){await this.sendError({id:c,topic:t,error:e,rpcOpts:m.wc_sessionPropose.autoReject}),this.client.logger.error(e)}},this.onSessionProposeResponse=async(e,t,s)=>{const{id:i}=t;if((0,h.isJsonRpcResult)(t)){const{result:r}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:r});const n=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const o=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const a=r.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});const c=await this.client.core.crypto.generateSharedKey(o,a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:c});const l=await this.client.core.relayer.subscribe(c,{transportType:s});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:l}),await this.client.core.pairing.activate({topic:e})}else if((0,h.isJsonRpcError)(t)){await this.client.proposal.delete(i,(0,a.Hjj)("USER_DISCONNECTED"));const e=(0,a.hEn)("session_connect");if(0===this.events.listenerCount(e))throw new Error(`emitting ${e} without any listeners, 954`);this.events.emit((0,a.hEn)("session_connect"),{error:t.error})}},this.onSessionSettleRequest=async(e,t)=>{const{id:s,params:r}=t;try{this.isValidSessionSettleRequest(r);const{relay:s,controller:n,expiry:o,namespaces:c,sessionProperties:l,sessionConfig:h}=t.params,u=L(q(q({topic:e,relay:s,expiry:o,namespaces:c,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:n.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:n.publicKey,metadata:n.metadata}},l&&{sessionProperties:l}),h&&{sessionConfig:h}),{transportType:i.cV.relay}),p=(0,a.hEn)("session_connect");if(0===this.events.listenerCount(p))throw new Error(`emitting ${p} without any listeners 997`);this.events.emit((0,a.hEn)("session_connect"),{session:u}),await this.sendResult({id:t.id,topic:e,result:!0,throwOnFailedPublish:!0})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}},this.onSessionSettleResponse=async(e,t)=>{const{id:s}=t;(0,h.isJsonRpcResult)(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit((0,a.hEn)("session_approve",s),{})):(0,h.isJsonRpcError)(t)&&(await this.client.session.delete(e,(0,a.Hjj)("USER_DISCONNECTED")),this.events.emit((0,a.hEn)("session_approve",s),{error:t.error}))},this.onSessionUpdateRequest=async(e,t)=>{const{params:s,id:i}=t;try{const t=`${e}_session_update`,r=a.nyL.get(t);if(r&&this.isRequestOutOfSync(r,i))return this.client.logger.warn(`Discarding out of sync request - ${i}`),void this.sendError({id:i,topic:e,error:(0,a.Hjj)("INVALID_UPDATE_REQUEST")});this.isValidUpdate(q({topic:e},s));try{a.nyL.set(t,i),await this.client.session.update(e,{namespaces:s.namespaces}),await this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0})}catch(e){throw a.nyL.delete(t),e}this.client.events.emit("session_update",{id:i,topic:e,params:s})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}},this.isRequestOutOfSync=(e,t)=>t.toString().slice(0,-3){const{id:s}=t,i=(0,a.hEn)("session_update",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,h.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_update",s),{}):(0,h.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_update",s),{error:t.error})},this.onSessionExtendRequest=async(e,t)=>{const{id:s}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,(0,a.Xw0)(w)),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:s,topic:e})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}},this.onSessionExtendResponse=(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_extend",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,h.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_extend",s),{}):(0,h.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_extend",s),{error:t.error})},this.onSessionPingRequest=async(e,t)=>{const{id:s}=t;try{this.isValidPing({topic:e}),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:e})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}},this.onSessionPingResponse=(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_ping",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);setTimeout((()=>{(0,h.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_ping",s),{}):(0,h.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_ping",s),{error:t.error})}),500)},this.onSessionDeleteRequest=async(e,t)=>{const{id:s}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),Promise.all([new Promise((t=>{this.client.core.relayer.once(i.Jf.publish,(async()=>{t(await this.deleteSession({topic:e,id:s}))}))})),this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:(0,a.Hjj)("USER_DISCONNECTED")})]).catch((e=>this.client.logger.error(e)))}catch(e){this.client.logger.error(e)}},this.onSessionRequest=async e=>{var t,s,r;const{topic:n,payload:o,attestation:c,encryptedId:l,transportType:u}=e,{id:p,params:d}=o;try{await this.isValidRequest(q({topic:n},d));const e=this.client.session.get(n),o={id:p,topic:n,params:d,verifyContext:await this.getVerifyContext({attestationId:c,hash:(0,a.ALl)(JSON.stringify((0,h.formatJsonRpcRequest)("wc_sessionRequest",d,p))),encryptedId:l,metadata:e.peer.metadata,transportType:u})};await this.setPendingSessionRequest(o),u===i.cV.link_mode&&null!=(t=e.peer.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(null==(s=e.peer.metadata.redirect)?void 0:s.universal),null!=(r=this.client.signConfig)&&r.disableRequestQueue?this.emitSessionRequest(o):(this.addSessionRequestToSessionRequestQueue(o),this.processSessionRequestQueue())}catch(e){await this.sendError({id:p,topic:n,error:e}),this.client.logger.error(e)}},this.onSessionRequestResponse=(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_request",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,h.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_request",s),{result:t.result}):(0,h.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_request",s),{error:t.error})},this.onSessionEventRequest=async(e,t)=>{const{id:s,params:i}=t;try{const t=`${e}_session_event_${i.event.name}`,r=a.nyL.get(t);if(r&&this.isRequestOutOfSync(r,s))return void this.client.logger.info(`Discarding out of sync request - ${s}`);this.isValidEmit(q({topic:e},i)),this.client.events.emit("session_event",{id:s,topic:e,params:i}),a.nyL.set(t,s)}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}},this.onSessionAuthenticateResponse=(e,t)=>{const{id:s}=t;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:t}),(0,h.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_request",s),{result:t.result}):(0,h.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_request",s),{error:t.error})},this.onSessionAuthenticateRequest=async e=>{var t;const{topic:s,payload:r,attestation:n,encryptedId:o,transportType:c}=e;try{const{requester:e,authPayload:l,expiryTimestamp:h}=r.params,u=await this.getVerifyContext({attestationId:n,hash:(0,a.ALl)(JSON.stringify(r)),encryptedId:o,metadata:e.metadata,transportType:c}),p={requester:e,pairingTopic:s,id:r.id,authPayload:l,verifyContext:u,expiryTimestamp:h};await this.setAuthRequest(r.id,{request:p,pairingTopic:s,transportType:c}),c===i.cV.link_mode&&null!=(t=e.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(e.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:s,params:r.params,id:r.id,verifyContext:u})}catch(e){this.client.logger.error(e);const t=r.params.requester.publicKey,i=await this.client.core.crypto.generateKeyPair(),n=this.getAppLinkIfEnabled(r.params.requester.metadata,c),o={type:a.Lp_,receiverPublicKey:t,senderPublicKey:i};await this.sendError({id:r.id,topic:s,error:e,encodeOpts:o,rpcOpts:m.wc_sessionAuthenticate.autoReject,appLink:n})}},this.addSessionRequestToSessionRequestQueue=e=>{this.sessionRequestQueue.queue.push(e)},this.cleanupAfterResponse=e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout((()=>{this.sessionRequestQueue.state=v,this.processSessionRequestQueue()}),(0,o.toMiliseconds)(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:e,error:t})=>{const s=this.client.core.history.pending;s.length>0&&s.filter((t=>t.topic===e&&"wc_sessionRequest"===t.request.method)).forEach((e=>{const s=e.request.id,i=(0,a.hEn)("session_request",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);this.events.emit((0,a.hEn)("session_request",e.request.id),{error:t})}))},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===E)return void this.client.logger.info("session request queue is already active.");const e=this.sessionRequestQueue.queue[0];if(e)try{this.sessionRequestQueue.state=E,this.emitSessionRequest(e)}catch(e){this.client.logger.error(e)}else this.client.logger.info("session request queue is empty.")},this.emitSessionRequest=e=>{this.client.events.emit("session_request",e)},this.onPairingCreated=e=>{if(e.methods&&this.expectedPairingMethodMap.set(e.topic,e.methods),e.active)return;const t=this.client.proposal.getAll().find((t=>t.pairingTopic===e.topic));t&&this.onSessionProposeRequest({topic:e.topic,payload:(0,h.formatJsonRpcRequest)("wc_sessionPropose",{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties},t.id)})},this.isValidConnect=async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(t)}const{pairingTopic:t,requiredNamespaces:s,optionalNamespaces:i,sessionProperties:r,relays:n}=e;if((0,a.b07)(t)||await this.isValidPairingTopic(t),!(0,a.V9G)(n,!0)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`connect() relays: ${n}`);throw new Error(e)}!(0,a.b07)(s)&&0!==(0,a.aF0)(s)&&this.validateNamespaces(s,"requiredNamespaces"),!(0,a.b07)(i)&&0!==(0,a.aF0)(i)&&this.validateNamespaces(i,"optionalNamespaces"),(0,a.b07)(r)||this.validateSessionProps(r,"sessionProperties")},this.validateNamespaces=(e,t)=>{const s=(0,a.esh)(e,"connect()",t);if(s)throw new Error(s.message)},this.isValidApprove=async e=>{if(!(0,a.TeY)(e))throw new Error((0,a.GuA)("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:t,namespaces:s,relayProtocol:i,sessionProperties:r}=e;this.checkRecentlyDeleted(t),await this.isValidProposalId(t);const n=this.client.proposal.get(t),o=(0,a.FiO)(s,"approve()");if(o)throw new Error(o.message);const c=(0,a.XqR)(n.requiredNamespaces,s,"approve()");if(c)throw new Error(c.message);if(!(0,a.Qhg)(i,!0)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw new Error(e)}(0,a.b07)(r)||this.validateSessionProps(r,"sessionProperties")},this.isValidReject=async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(t)}const{id:t,reason:s}=e;if(this.checkRecentlyDeleted(t),await this.isValidProposalId(t),!(0,a.X3c)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(e)}},this.isValidSessionSettleRequest=e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}const{relay:t,controller:s,namespaces:i,expiry:r}=e;if(!(0,a.kuU)(t)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const n=(0,a.tk0)(s,"onSessionSettleRequest()");if(n)throw new Error(n.message);const o=(0,a.FiO)(i,"onSessionSettleRequest()");if(o)throw new Error(o.message);if((0,a._dF)(r)){const{message:e}=(0,a.GuA)("EXPIRED","onSessionSettleRequest()");throw new Error(e)}},this.isValidUpdate=async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(t)}const{topic:t,namespaces:s}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const i=this.client.session.get(t),r=(0,a.FiO)(s,"update()");if(r)throw new Error(r.message);const n=(0,a.XqR)(i.requiredNamespaces,s,"update()");if(n)throw new Error(n.message)},this.isValidExtend=async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:t}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t)},this.isValidRequest=async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(t)}const{topic:t,request:s,chainId:i,expiry:r}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const{namespaces:n}=this.client.session.get(t);if(!(0,a.tLy)(n,i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() chainId: ${i}`);throw new Error(e)}if(!(0,a.iV1)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(e)}if(!(0,a.oKp)(n,i,s.method)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(e)}if(r&&!(0,a.Hbs)(r,b)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() expiry: ${r}. Expiry must be a number (in seconds) between ${b.min} and ${b.max}`);throw new Error(e)}},this.isValidRespond=async e=>{var t;if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:s,response:i}=e;try{await this.isValidSessionTopic(s)}catch(s){throw null!=(t=e?.response)&&t.id&&this.cleanupAfterResponse(e),s}if(!(0,a.M8n)(i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(e)}},this.isValidPing=async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.isValidEmit=async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(t)}const{topic:t,event:s,chainId:i}=e;await this.isValidSessionTopic(t);const{namespaces:r}=this.client.session.get(t);if(!(0,a.tLy)(r,i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw new Error(e)}if(!(0,a.FR8)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(e)}if(!(0,a.z2N)(r,i,s.name)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(e)}},this.isValidDisconnect=async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.isValidAuthenticate=e=>{const{chains:t,uri:s,domain:i,nonce:r}=e;if(!Array.isArray(t)||0===t.length)throw new Error("chains is required and must be a non-empty array");if(!(0,a.Qhg)(s,!1))throw new Error("uri is required parameter");if(!(0,a.Qhg)(i,!1))throw new Error("domain is required parameter");if(!(0,a.Qhg)(r,!1))throw new Error("nonce is required parameter");if([...new Set(t.map((e=>(0,a._Yb)(e).namespace)))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:n}=(0,a._Yb)(t[0]);if("eip155"!==n)throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async e=>{const{attestationId:t,hash:s,encryptedId:r,metadata:n,transportType:o}=e,a={verified:{verifyUrl:n.verifyUrl||i.WB,validation:"UNKNOWN",origin:n.url||""}};try{if(o===i.cV.link_mode){const e=this.getAppLinkIfEnabled(n,o);return a.verified.validation=e&&new URL(e).origin===new URL(n.url).origin?"VALID":"INVALID",a}const e=await this.client.core.verify.resolve({attestationId:t,hash:s,encryptedId:r,verifyUrl:n.verifyUrl});e&&(a.verified.origin=e.origin,a.verified.isScam=e.isScam,a.verified.validation=e.origin===new URL(n.url).origin?"VALID":"INVALID")}catch(e){this.client.logger.warn(e)}return this.client.logger.debug(`Verify context: ${JSON.stringify(a)}`),a},this.validateSessionProps=(e,t)=>{Object.values(e).forEach((e=>{if(!(0,a.Qhg)(e,!1)){const{message:s}=(0,a.GuA)("MISSING_OR_INVALID",`${t} must be in Record format. Received: ${JSON.stringify(e)}`);throw new Error(s)}}))},this.getPendingAuthRequest=e=>{const t=this.client.auth.requests.get(e);return"object"==typeof t?t:void 0},this.addToRecentlyDeleted=(e,t)=>{if(this.recentlyDeletedMap.set(e,t),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let e=0;const t=this.recentlyDeletedLimit/2;for(const s of this.recentlyDeletedMap.keys()){if(e++>=t)break;this.recentlyDeletedMap.delete(s)}}},this.checkRecentlyDeleted=e=>{const t=this.recentlyDeletedMap.get(e);if(t){const{message:s}=(0,a.GuA)("MISSING_OR_INVALID",`Record was recently deleted - ${t}: ${e}`);throw new Error(s)}},this.isLinkModeEnabled=(e,t)=>{var r,n,o,a,c,l,h,u,p;return!(!e||t!==i.cV.link_mode)&&(!0===(null==(n=null==(r=this.client.metadata)?void 0:r.redirect)?void 0:n.linkMode)&&void 0!==(null==(a=null==(o=this.client.metadata)?void 0:o.redirect)?void 0:a.universal)&&""!==(null==(l=null==(c=this.client.metadata)?void 0:c.redirect)?void 0:l.universal)&&void 0!==(null==(h=e?.redirect)?void 0:h.universal)&&""!==(null==(u=e?.redirect)?void 0:u.universal)&&!0===(null==(p=e?.redirect)?void 0:p.linkMode)&&this.client.core.linkModeSupportedApps.includes(e.redirect.universal)&&typeof(null==s.g?void 0:s.g.Linking)<"u")},this.getAppLinkIfEnabled=(e,t)=>{var s;return this.isLinkModeEnabled(e,t)?null==(s=e?.redirect)?void 0:s.universal:void 0},this.handleLinkModeMessage=({url:e})=>{if(!e||!e.includes("wc_ev")||!e.includes("topic"))return;const t=(0,a.$hI)(e,"topic")||"",s=decodeURIComponent((0,a.$hI)(e,"wc_ev")||""),r=this.client.session.keys.includes(t);r&&this.client.session.update(t,{transportType:i.cV.link_mode}),this.client.core.dispatchEnvelope({topic:t,message:s,sessionExists:r})},this.registerLinkModeListeners=async()=>{var e;if((0,a.w8K)()||(0,a.lVv)()&&null!=(e=this.client.metadata.redirect)&&e.linkMode){const e=null==s.g?void 0:s.g.Linking;if(typeof e<"u"){e.addEventListener("url",this.handleLinkModeMessage,this.client.name);const t=await e.getInitialURL();t&&setTimeout((()=>{this.handleLinkModeMessage({url:t})}),50)}}}}isInitialized(){if(!this.initialized){const{message:e}=(0,a.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(i.Jf.message,(e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)}))}async onRelayMessage(e){const{topic:t,message:s,attestation:r,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(S)?this.client.auth.authKeys.get(S):{responseTopic:void 0,publicKey:void 0},c=await this.client.core.crypto.decode(t,s,{receiverPublicKey:o,encoding:n===i.cV.link_mode?a.Pa8:a.EWt});try{(0,h.isJsonRpcRequest)(c)?(this.client.core.history.set(t,c),this.onRelayEventRequest({topic:t,payload:c,attestation:r,transportType:n,encryptedId:(0,a.ALl)(s)})):(0,h.isJsonRpcResponse)(c)?(await this.client.core.history.resolve(c),await this.onRelayEventResponse({topic:t,payload:c,transportType:n}),this.client.core.history.delete(t,c.id)):this.onRelayEventUnknownPayload({topic:t,payload:c,transportType:n})}catch(e){this.client.logger.error(e)}}registerExpirerEvents(){this.client.core.expirer.on(i.wn.expired,(async e=>{const{topic:t,id:s}=(0,a.c82)(e.target);return s&&this.client.pendingRequest.keys.includes(s)?await this.deletePendingSessionRequest(s,(0,a.GuA)("EXPIRED"),!0):s&&this.client.auth.requests.keys.includes(s)?await this.deletePendingAuthRequest(s,(0,a.GuA)("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})):s&&(await this.deleteProposal(s,!0),this.client.events.emit("proposal_expire",{id:s})))}))}registerPairingEvents(){this.client.core.pairing.events.on(i.zN.create,(e=>this.onPairingCreated(e))),this.client.core.pairing.events.on(i.zN.delete,(e=>{this.addToRecentlyDeleted(e.topic,"pairing")}))}isValidPairingTopic(e){if(!(0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=(0,a.GuA)("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!(0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=(0,a.GuA)("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else{if(!this.client.core.pairing.pairings.keys.includes(e)){if((0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if(!(0,a.Alu)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=(0,a.GuA)("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class D extends i.il{constructor(e,t){super(e,t,"proposal",p),this.core=e,this.logger=t}}class B extends i.il{constructor(e,t){super(e,t,"session",p),this.core=e,this.logger=t}}class C extends i.il{constructor(e,t){super(e,t,"request",p,(e=>e.id)),this.core=e,this.logger=t}}class M extends i.il{constructor(e,t){super(e,t,"authKeys",R,(()=>S)),this.core=e,this.logger=t}}class j extends i.il{constructor(e,t){super(e,t,"pairingTopics",R),this.core=e,this.logger=t}}class k extends i.il{constructor(e,t){super(e,t,"requests",R,(e=>e.id)),this.core=e,this.logger=t}}class V{constructor(e,t){this.core=e,this.logger=t,this.authKeys=new M(this.core,this.logger),this.pairingTopics=new j(this.core,this.logger),this.requests=new k(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}class H extends n.S9{constructor(e){super(e),this.protocol="wc",this.version=2,this.name=d,this.events=new c.EventEmitter,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.removeAllListeners=e=>this.events.removeAllListeners(e),this.connect=async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}},this.pair=async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}},this.approve=async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}},this.reject=async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}},this.update=async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}},this.extend=async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}},this.request=async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}},this.respond=async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}},this.ping=async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}},this.emit=async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}},this.disconnect=async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}},this.find=e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}},this.authenticate=async(e,t)=>{try{return await this.engine.authenticate(e,t)}catch(e){throw this.logger.error(e.message),e}},this.formatAuthMessage=e=>{try{return this.engine.formatAuthMessage(e)}catch(e){throw this.logger.error(e.message),e}},this.approveSessionAuthenticate=async e=>{try{return await this.engine.approveSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}},this.rejectSessionAuthenticate=async e=>{try{return await this.engine.rejectSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}},this.name=e?.name||d,this.metadata=e?.metadata||(0,a.lFF)(),this.signConfig=e?.signConfig;const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,r.h6)((0,r.iP)({level:e?.logger||f}));this.core=e?.core||new i.iJ(e),this.logger=(0,r.U5)(t,this.name),this.session=new B(this.core,this.logger),this.proposal=new D(this.core,this.logger),this.pendingRequest=new C(this.core,this.logger),this.engine=new U(this),this.auth=new V(this.core,this.logger)}static async init(e){const t=new H(e);return await t.initialize(),t}get context(){return(0,r.oI)(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout((()=>{this.engine.processRelayMessageCache()}),(0,o.toMiliseconds)(o.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}},75845:(e,t,s)=>{"use strict";s.d(t,{eF:()=>a,mE:()=>r,rI:()=>o,vG:()=>n});var i=s(44410);function r(e){return i.jf.includes(e)}function n(e){return Object.keys(i.Uf).includes(e)?i.Uf[e]:i.Uf[i.XW]}function o(e){const t=Object.values(i.Uf).find((t=>t.code===e));return t||i.Uf[i.XW]}function a(e,t,s){return e.message.includes("getaddrinfo ENOTFOUND")||e.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${s} RPC url at ${t}`):e}},77173:(e,t,s)=>{"use strict";function i(){return(null===s.g||void 0===s.g?void 0:s.g.crypto)||(null===s.g||void 0===s.g?void 0:s.g.msCrypto)||{}}function r(){const e=i();return e.subtle||e.webkitSubtle}Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowserCryptoAvailable=t.getSubtleCrypto=t.getBrowerCrypto=void 0,t.getBrowerCrypto=i,t.getSubtleCrypto=r,t.isBrowserCryptoAvailable=function(){return!!i()&&!!r()}},79244:(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},80584:(e,t,s)=>{"use strict";s.r(t),s.d(t,{__assign:()=>n,__asyncDelegator:()=>v,__asyncGenerator:()=>b,__asyncValues:()=>E,__await:()=>m,__awaiter:()=>h,__classPrivateFieldGet:()=>I,__classPrivateFieldSet:()=>x,__createBinding:()=>p,__decorate:()=>a,__exportStar:()=>d,__extends:()=>r,__generator:()=>u,__importDefault:()=>S,__importStar:()=>R,__makeTemplateObject:()=>_,__metadata:()=>l,__param:()=>c,__read:()=>g,__rest:()=>o,__spread:()=>y,__spreadArrays:()=>w,__values:()=>f});var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var s in t)t.hasOwnProperty(s)&&(e[s]=t[s])},i(e,t)};function r(e,t){function s(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(s.prototype=t.prototype,new s)}var n=function(){return n=Object.assign||function(e){for(var t,s=1,i=arguments.length;s=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,s,o):r(t,s))||o);return n>3&&o&&Object.defineProperty(t,s,o),o}function c(e,t){return function(s,i){t(s,i,e)}}function l(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function h(e,t,s,i){return new(s||(s=Promise))((function(r,n){function o(e){try{c(i.next(e))}catch(e){n(e)}}function a(e){try{c(i.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))}function u(e,t){var s,i,r,n,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[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(s)throw new TypeError("Generator is already executing.");for(;o;)try{if(s=1,i&&(r=2&n[0]?i.return:n[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,n[1])).done)return r;switch(i=0,r&&(n=[2&n[0],r.value]),n[0]){case 0:case 1:r=n;break;case 4:return o.label++,{value:n[1],done:!1};case 5:o.label++,i=n[1],n=[0];continue;case 7:n=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==n[0]&&2!==n[0])){o=0;continue}if(3===n[0]&&(!r||n[1]>r[0]&&n[1]=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(e,t){var s="function"==typeof Symbol&&e[Symbol.iterator];if(!s)return e;var i,r,n=s.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(s=n.return)&&s.call(n)}finally{if(r)throw r.error}}return o}function y(){for(var e=[],t=0;t1||a(e,t)}))})}function a(e,t){try{(s=r[e](t)).value instanceof m?Promise.resolve(s.value.v).then(c,l):h(n[0][2],s)}catch(e){h(n[0][3],e)}var s}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,s;return t={},i("next"),i("throw",(function(e){throw e})),i("return"),t[Symbol.iterator]=function(){return this},t;function i(i,r){t[i]=e[i]?function(t){return(s=!s)?{value:m(e[i](t)),done:"return"===i}:r?r(t):t}:r}}function E(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,s=e[Symbol.asyncIterator];return s?s.call(e):(e=f(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=e[s]&&function(t){return new Promise((function(i,r){(function(e,t,s,i){Promise.resolve(i).then((function(t){e({value:t,done:s})}),t)})(i,r,(t=e[s](t)).done,t.value)}))}}}function _(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function R(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)Object.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t.default=e,t}function S(e){return e&&e.__esModule?e:{default:e}}function I(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function x(e,t,s){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,s),s}},84365:(e,t,s)=>{"use strict";s.d(t,{A:()=>c});var i=s(37007),r=s(13554),n=s(39031);const o=e=>e.split("?")[0],a=typeof WebSocket<"u"?WebSocket:typeof s.g<"u"&&typeof s.g.WebSocket<"u"?s.g.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:s(90796);class c{constructor(e){if(this.url=e,this.events=new i.EventEmitter,this.registering=!1,!(0,n.isWsUrl)(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}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)=>{typeof this.socket>"u"?t(new Error("Connection already closed")):(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,r.h)(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!(0,n.isWsUrl)(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const 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(new Error("WebSocket connection is missing or invalid"));e(this.socket)}))}))}return this.url=e,this.registering=!0,new Promise(((t,i)=>{const r=(0,n.isReactNative)()?void 0:{rejectUnauthorized:!(0,n.isLocalhostUrl)(e)},o=new a(e,[],r);typeof WebSocket<"u"||typeof s.g<"u"&&typeof s.g.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u"?o.onerror=e=>{const t=e;i(this.emitError(t.error))}:o.on("error",(e=>{i(this.emitError(e))})),o.onopen=()=>{this.onOpen(o),t(o)}}))}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;const t="string"==typeof e.data?(0,r.j)(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const s=this.parseError(t),i=s.message||s.toString(),r=(0,n.formatJsonRpcError)(e,i);this.events.emit("payload",r)}parseError(e,t=this.url){return(0,n.parseConnectionError)(e,o(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}emitError(e){const t=this.parseError(new Error(e?.message||`WebSocket connection failed for host: ${o(this.url)}`));return this.events.emit("register_error",t),t}}},86668:(e,t,s)=>{"use strict";s.d(t,{ER:()=>n,Im:()=>c,dZ:()=>l,eX:()=>o,e_:()=>a});var i=s(75845),r=s(44410);function 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,s){return{id:s||n(),jsonrpc:"2.0",method:e,params:t}}function c(e,t){return{id:e,jsonrpc:"2.0",result:t}}function l(e,t,s){return{id:e,jsonrpc:"2.0",error:h(t,s)}}function h(e,t){return void 0===e?(0,i.vG)(r.zR):("string"==typeof e&&(e=Object.assign(Object.assign({},(0,i.vG)(r.fO)),{message:e})),void 0!==t&&(e.data=t),(0,i.mE)(e.code)&&(e=(0,i.rI)(e.code)),e)}},88900:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(80584);i.__exportStar(s(99606),t),i.__exportStar(s(89883),t),i.__exportStar(s(62010),t),i.__exportStar(s(49026),t)},89883:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Watch=void 0;class s{constructor(){this.timestamps=new Map}start(e){if(this.timestamps.has(e))throw new Error(`Watch already started for label: ${e}`);this.timestamps.set(e,{started:Date.now()})}stop(e){const t=this.get(e);if(void 0!==t.elapsed)throw new Error(`Watch already stopped for label: ${e}`);const s=Date.now()-t.started;this.timestamps.set(e,{started:t.started,elapsed:s})}get(e){const t=this.timestamps.get(e);if(void 0===t)throw new Error(`No timestamp found for label: ${e}`);return t}elapsed(e){const t=this.get(e);return t.elapsed||Date.now()-t.started}}t.Watch=s,t.default=s},90796:e=>{"use strict";e.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},91089:(e,t)=>{"use strict";function s(){return"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product}function i(){return"undefined"!=typeof process&&void 0!==process.versions&&void 0!==process.versions.node}Object.defineProperty(t,"__esModule",{value:!0}),t.isBrowser=t.isNode=t.isReactNative=void 0,t.isReactNative=s,t.isNode=i,t.isBrowser=function(){return!s()&&!i()}},93532:(e,t,s)=>{"use strict";s.d(t,{VH:()=>l,li:()=>c});var i=s(37007),r=s(88900),n=s(4556);class o extends n.H{constructor(e){super()}}const a=r.FIVE_SECONDS,c={pulse:"heartbeat_pulse"};class l extends o{constructor(e){super(e),this.events=new i.EventEmitter,this.interval=a,this.interval=e?.interval||a}static async init(e){const t=new l(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,r.toMiliseconds)(this.interval))}pulse(){this.events.emit(c.pulse)}}},98186:(e,t,s)=>{"use strict";s.r(t),s.d(t,{__assign:()=>n,__asyncDelegator:()=>v,__asyncGenerator:()=>b,__asyncValues:()=>E,__await:()=>m,__awaiter:()=>h,__classPrivateFieldGet:()=>I,__classPrivateFieldSet:()=>x,__createBinding:()=>p,__decorate:()=>a,__exportStar:()=>d,__extends:()=>r,__generator:()=>u,__importDefault:()=>S,__importStar:()=>R,__makeTemplateObject:()=>_,__metadata:()=>l,__param:()=>c,__read:()=>g,__rest:()=>o,__spread:()=>y,__spreadArrays:()=>w,__values:()=>f});var i=function(e,t){return i=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var s in t)t.hasOwnProperty(s)&&(e[s]=t[s])},i(e,t)};function r(e,t){function s(){this.constructor=e}i(e,t),e.prototype=null===t?Object.create(t):(s.prototype=t.prototype,new s)}var n=function(){return n=Object.assign||function(e){for(var t,s=1,i=arguments.length;s=0;a--)(r=e[a])&&(o=(n<3?r(o):n>3?r(t,s,o):r(t,s))||o);return n>3&&o&&Object.defineProperty(t,s,o),o}function c(e,t){return function(s,i){t(s,i,e)}}function l(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function h(e,t,s,i){return new(s||(s=Promise))((function(r,n){function o(e){try{c(i.next(e))}catch(e){n(e)}}function a(e){try{c(i.throw(e))}catch(e){n(e)}}function c(e){var t;e.done?r(e.value):(t=e.value,t instanceof s?t:new s((function(e){e(t)}))).then(o,a)}c((i=i.apply(e,t||[])).next())}))}function u(e,t){var s,i,r,n,o={label:0,sent:function(){if(1&r[0])throw r[1];return r[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(s)throw new TypeError("Generator is already executing.");for(;o;)try{if(s=1,i&&(r=2&n[0]?i.return:n[0]?i.throw||((r=i.return)&&r.call(i),0):i.next)&&!(r=r.call(i,n[1])).done)return r;switch(i=0,r&&(n=[2&n[0],r.value]),n[0]){case 0:case 1:r=n;break;case 4:return o.label++,{value:n[1],done:!1};case 5:o.label++,i=n[1],n=[0];continue;case 7:n=o.ops.pop(),o.trys.pop();continue;default:if(!(r=o.trys,(r=r.length>0&&r[r.length-1])||6!==n[0]&&2!==n[0])){o=0;continue}if(3===n[0]&&(!r||n[1]>r[0]&&n[1]=e.length&&(e=void 0),{value:e&&e[i++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(e,t){var s="function"==typeof Symbol&&e[Symbol.iterator];if(!s)return e;var i,r,n=s.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(i=n.next()).done;)o.push(i.value)}catch(e){r={error:e}}finally{try{i&&!i.done&&(s=n.return)&&s.call(n)}finally{if(r)throw r.error}}return o}function y(){for(var e=[],t=0;t1||a(e,t)}))})}function a(e,t){try{(s=r[e](t)).value instanceof m?Promise.resolve(s.value.v).then(c,l):h(n[0][2],s)}catch(e){h(n[0][3],e)}var s}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,s;return t={},i("next"),i("throw",(function(e){throw e})),i("return"),t[Symbol.iterator]=function(){return this},t;function i(i,r){t[i]=e[i]?function(t){return(s=!s)?{value:m(e[i](t)),done:"return"===i}:r?r(t):t}:r}}function E(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,s=e[Symbol.asyncIterator];return s?s.call(e):(e=f(e),t={},i("next"),i("throw"),i("return"),t[Symbol.asyncIterator]=function(){return this},t);function i(s){t[s]=e[s]&&function(t){return new Promise((function(i,r){(function(e,t,s,i){Promise.resolve(i).then((function(t){e({value:t,done:s})}),t)})(i,r,(t=e[s](t)).done,t.value)}))}}}function _(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function R(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var s in e)Object.hasOwnProperty.call(e,s)&&(t[s]=e[s]);return t.default=e,t}function S(e){return e&&e.__esModule?e:{default:e}}function I(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function x(e,t,s){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,s),s}},99606:(e,t,s)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0});const i=s(80584);i.__exportStar(s(2985),t),i.__exportStar(s(60221),t)},99784:(e,t,s)=>{"use strict";function i(e){return"object"==typeof e&&"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}function r(e){return i(e)&&"method"in e}function n(e){return i(e)&&(o(e)||a(e))}function o(e){return"result"in e}function a(e){return"error"in e}s.d(t,{U$:()=>a,p3:()=>r,tq:()=>n,xT:()=>o})}}]);