@walletconnect/ethereum-provider 2.0.0-85d2bf46 → 2.0.0-8b4dd35c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.umd.js CHANGED
@@ -1,2 +1,2 @@
1
- (function(mt,Z){typeof exports=="object"&&typeof module<"u"?Z(exports):typeof define=="function"&&define.amd?define(["exports"],Z):(mt=typeof globalThis<"u"?globalThis:mt||self,Z(mt["@walletconnect/ethereum-provider"]={}))})(this,function(mt){"use strict";var Z=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ja(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function wn(t){var e=t.default;if(typeof e=="function"){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}function Ke(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var vr=Ke;Ke.EventEmitter=Ke,Ke.prototype._events=void 0,Ke.prototype._maxListeners=void 0,Ke.defaultMaxListeners=10,Ke.prototype.setMaxListeners=function(t){if(!Xa(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ke.prototype.emit=function(t){var e,r,n,i,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||yr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],Ri(r))return!1;if(Nt(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(yr(r))for(i=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,s=0;s<n;s++)c[s].apply(this,i);return!0},Ke.prototype.addListener=function(t,e){var r;if(!Nt(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Nt(e.listener)?e.listener:e),this._events[t]?yr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,yr(this._events[t])&&!this._events[t].warned&&(Ri(this._maxListeners)?r=Ke.defaultMaxListeners:r=this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),typeof console.trace=="function"&&console.trace())),this},Ke.prototype.on=Ke.prototype.addListener,Ke.prototype.once=function(t,e){if(!Nt(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},Ke.prototype.removeListener=function(t,e){var r,n,i,s;if(!Nt(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],i=r.length,n=-1,r===e||Nt(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(yr(r)){for(s=i;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(n<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},Ke.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[t]&&delete this._events[t],this;if(arguments.length===0){for(e in this._events)e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],Nt(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},Ke.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Nt(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},Ke.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Nt(e))return 1;if(e)return e.length}return 0},Ke.listenerCount=function(t,e){return t.listenerCount(e)};function Nt(t){return typeof t=="function"}function Xa(t){return typeof t=="number"}function yr(t){return typeof t=="object"&&t!==null}function Ri(t){return t===void 0}const Za="PARSE_ERROR",Qa="INVALID_REQUEST",ec="METHOD_NOT_FOUND",tc="INVALID_PARAMS",Fi="INTERNAL_ERROR",En="SERVER_ERROR",rc=[-32700,-32600,-32601,-32602,-32603],_r={[Za]:{code:-32700,message:"Parse error"},[Qa]:{code:-32600,message:"Invalid Request"},[ec]:{code:-32601,message:"Method not found"},[tc]:{code:-32602,message:"Invalid params"},[Fi]:{code:-32603,message:"Internal error"},[En]:{code:-32e3,message:"Server error"}},Ui=En;function nc(t){return rc.includes(t)}function Mi(t){return Object.keys(_r).includes(t)?_r[t]:_r[Ui]}function ic(t){const e=Object.values(_r).find(r=>r.code===t);return e||_r[Ui]}function ji(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var $i={},$t={};Object.defineProperty($t,"__esModule",{value:!0}),$t.isBrowserCryptoAvailable=$t.getSubtleCrypto=$t.getBrowerCrypto=void 0;function Dn(){return Z?.crypto||Z?.msCrypto||{}}$t.getBrowerCrypto=Dn;function Bi(){const t=Dn();return t.subtle||t.webkitSubtle}$t.getSubtleCrypto=Bi;function sc(){return!!Dn()&&!!Bi()}$t.isBrowserCryptoAvailable=sc;var Bt={};Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.isBrowser=Bt.isNode=Bt.isReactNative=void 0;function zi(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Bt.isReactNative=zi;function Hi(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Bt.isNode=Hi;function oc(){return!zi()&&!Hi()}Bt.isBrowser=oc,function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r($t,t),r(Bt,t)}($i);function ac(){const t=Date.now()*Math.pow(10,3),e=Math.floor(Math.random()*Math.pow(10,3));return t+e}function xn(t,e,r){return{id:r||ac(),jsonrpc:"2.0",method:t,params:e}}function Sn(t,e){return{id:t,jsonrpc:"2.0",result:e}}function qr(t,e,r){return{id:t,jsonrpc:"2.0",error:cc(e,r)}}function cc(t,e){return typeof t>"u"?Mi(Fi):(typeof t=="string"&&(t=Object.assign(Object.assign({},Mi(En)),{message:t})),typeof e<"u"&&(t.data=e),nc(t.code)&&(t=ic(t.code)),t)}class Ki{}class uc extends Ki{constructor(e){super()}}class hc extends Ki{constructor(){super()}}class fc extends hc{constructor(e){super()}}const lc="^https?:",dc="^wss?:";function pc(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function qi(t,e){const r=pc(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function Vi(t){return qi(t,lc)}function Gi(t){return qi(t,dc)}function gc(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function Wi(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function ki(t){return Wi(t)&&"method"in t}function Yi(t){return Wi(t)&&(Pt(t)||wt(t))}function Pt(t){return"result"in t}function wt(t){return"error"in t}class On extends fc{constructor(e){super(e),this.events=new vr.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,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async request(e,r){return this.requestStrict(xn(e.method,e.params||[]),r)}async requestStrict(e,r){return new Promise(async(n,i)=>{if(!this.connection.connected)try{await this.open()}catch(s){i(s)}this.events.on(`${e.id}`,s=>{wt(s)?i(s.error):n(s.result)});try{await this.connection.send(e,r)}catch(s){i(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Yi(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(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",()=>this.events.emit("disconnect")),this.connection.on("error",e=>this.events.emit("error",e)),this.hasRegisteredEventListeners=!0)}}var An={exports:{}};(function(t,e){var r=typeof self<"u"?self:Z,n=function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s}();(function(s){(function(c){var u={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function h(f){return f&&DataView.prototype.isPrototypeOf(f)}if(u.arrayBuffer)var l=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],p=ArrayBuffer.isView||function(f){return f&&l.indexOf(Object.prototype.toString.call(f))>-1};function E(f){if(typeof f!="string"&&(f=String(f)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(f))throw new TypeError("Invalid character in header field name");return f.toLowerCase()}function T(f){return typeof f!="string"&&(f=String(f)),f}function w(f){var _={next:function(){var M=f.shift();return{done:M===void 0,value:M}}};return u.iterable&&(_[Symbol.iterator]=function(){return _}),_}function b(f){this.map={},f instanceof b?f.forEach(function(_,M){this.append(M,_)},this):Array.isArray(f)?f.forEach(function(_){this.append(_[0],_[1])},this):f&&Object.getOwnPropertyNames(f).forEach(function(_){this.append(_,f[_])},this)}b.prototype.append=function(f,_){f=E(f),_=T(_);var M=this.map[f];this.map[f]=M?M+", "+_:_},b.prototype.delete=function(f){delete this.map[E(f)]},b.prototype.get=function(f){return f=E(f),this.has(f)?this.map[f]:null},b.prototype.has=function(f){return this.map.hasOwnProperty(E(f))},b.prototype.set=function(f,_){this.map[E(f)]=T(_)},b.prototype.forEach=function(f,_){for(var M in this.map)this.map.hasOwnProperty(M)&&f.call(_,this.map[M],M,this)},b.prototype.keys=function(){var f=[];return this.forEach(function(_,M){f.push(M)}),w(f)},b.prototype.values=function(){var f=[];return this.forEach(function(_){f.push(_)}),w(f)},b.prototype.entries=function(){var f=[];return this.forEach(function(_,M){f.push([M,_])}),w(f)},u.iterable&&(b.prototype[Symbol.iterator]=b.prototype.entries);function F(f){if(f.bodyUsed)return Promise.reject(new TypeError("Already read"));f.bodyUsed=!0}function y(f){return new Promise(function(_,M){f.onload=function(){_(f.result)},f.onerror=function(){M(f.error)}})}function O(f){var _=new FileReader,M=y(_);return _.readAsArrayBuffer(f),M}function N(f){var _=new FileReader,M=y(_);return _.readAsText(f),M}function L(f){for(var _=new Uint8Array(f),M=new Array(_.length),K=0;K<_.length;K++)M[K]=String.fromCharCode(_[K]);return M.join("")}function S(f){if(f.slice)return f.slice(0);var _=new Uint8Array(f.byteLength);return _.set(new Uint8Array(f)),_.buffer}function C(){return this.bodyUsed=!1,this._initBody=function(f){this._bodyInit=f,f?typeof f=="string"?this._bodyText=f:u.blob&&Blob.prototype.isPrototypeOf(f)?this._bodyBlob=f:u.formData&&FormData.prototype.isPrototypeOf(f)?this._bodyFormData=f:u.searchParams&&URLSearchParams.prototype.isPrototypeOf(f)?this._bodyText=f.toString():u.arrayBuffer&&u.blob&&h(f)?(this._bodyArrayBuffer=S(f.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):u.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(f)||p(f))?this._bodyArrayBuffer=S(f):this._bodyText=f=Object.prototype.toString.call(f):this._bodyText="",this.headers.get("content-type")||(typeof f=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):u.searchParams&&URLSearchParams.prototype.isPrototypeOf(f)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},u.blob&&(this.blob=function(){var f=F(this);if(f)return f;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(){return this._bodyArrayBuffer?F(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(O)}),this.text=function(){var f=F(this);if(f)return f;if(this._bodyBlob)return N(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(L(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},u.formData&&(this.formData=function(){return this.text().then(B)}),this.json=function(){return this.text().then(JSON.parse)},this}var m=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function o(f){var _=f.toUpperCase();return m.indexOf(_)>-1?_:f}function g(f,_){_=_||{};var M=_.body;if(f instanceof g){if(f.bodyUsed)throw new TypeError("Already read");this.url=f.url,this.credentials=f.credentials,_.headers||(this.headers=new b(f.headers)),this.method=f.method,this.mode=f.mode,this.signal=f.signal,!M&&f._bodyInit!=null&&(M=f._bodyInit,f.bodyUsed=!0)}else this.url=String(f);if(this.credentials=_.credentials||this.credentials||"same-origin",(_.headers||!this.headers)&&(this.headers=new b(_.headers)),this.method=o(_.method||this.method||"GET"),this.mode=_.mode||this.mode||null,this.signal=_.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&M)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(M)}g.prototype.clone=function(){return new g(this,{body:this._bodyInit})};function B(f){var _=new FormData;return f.trim().split("&").forEach(function(M){if(M){var K=M.split("="),R=K.shift().replace(/\+/g," "),P=K.join("=").replace(/\+/g," ");_.append(decodeURIComponent(R),decodeURIComponent(P))}}),_}function q(f){var _=new b,M=f.replace(/\r?\n[\t ]+/g," ");return M.split(/\r?\n/).forEach(function(K){var R=K.split(":"),P=R.shift().trim();if(P){var j=R.join(":").trim();_.append(P,j)}}),_}C.call(g.prototype);function V(f,_){_||(_={}),this.type="default",this.status=_.status===void 0?200:_.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in _?_.statusText:"OK",this.headers=new b(_.headers),this.url=_.url||"",this._initBody(f)}C.call(V.prototype),V.prototype.clone=function(){return new V(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new b(this.headers),url:this.url})},V.error=function(){var f=new V(null,{status:0,statusText:""});return f.type="error",f};var J=[301,302,303,307,308];V.redirect=function(f,_){if(J.indexOf(_)===-1)throw new RangeError("Invalid status code");return new V(null,{status:_,headers:{location:f}})},c.DOMException=s.DOMException;try{new c.DOMException}catch{c.DOMException=function(_,M){this.message=_,this.name=M;var K=Error(_);this.stack=K.stack},c.DOMException.prototype=Object.create(Error.prototype),c.DOMException.prototype.constructor=c.DOMException}function X(f,_){return new Promise(function(M,K){var R=new g(f,_);if(R.signal&&R.signal.aborted)return K(new c.DOMException("Aborted","AbortError"));var P=new XMLHttpRequest;function j(){P.abort()}P.onload=function(){var $={status:P.status,statusText:P.statusText,headers:q(P.getAllResponseHeaders()||"")};$.url="responseURL"in P?P.responseURL:$.headers.get("X-Request-URL");var Q="response"in P?P.response:P.responseText;M(new V(Q,$))},P.onerror=function(){K(new TypeError("Network request failed"))},P.ontimeout=function(){K(new TypeError("Network request failed"))},P.onabort=function(){K(new c.DOMException("Aborted","AbortError"))},P.open(R.method,R.url,!0),R.credentials==="include"?P.withCredentials=!0:R.credentials==="omit"&&(P.withCredentials=!1),"responseType"in P&&u.blob&&(P.responseType="blob"),R.headers.forEach(function($,Q){P.setRequestHeader(Q,$)}),R.signal&&(R.signal.addEventListener("abort",j),P.onreadystatechange=function(){P.readyState===4&&R.signal.removeEventListener("abort",j)}),P.send(typeof R._bodyInit>"u"?null:R._bodyInit)})}return X.polyfill=!0,s.fetch||(s.fetch=X,s.Headers=b,s.Request=g,s.Response=V),c.Headers=b,c.Request=g,c.Response=V,c.fetch=X,Object.defineProperty(c,"__esModule",{value:!0}),c})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e})(An,An.exports);var Ji=Ja(An.exports);function In(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return JSON.parse(t)}catch{return t}}function br(t){return typeof t=="string"?t:JSON.stringify(t)}const Xi={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"},Zi=10;class vc{constructor(e){if(this.url=e,this.events=new vr.EventEmitter,this.isAvailable=!1,this.registering=!1,!Vi(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}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,r){this.isAvailable||await this.register();try{const n=br(e),s=await(await Ji(this.url,Object.assign(Object.assign({},Xi),{body:n}))).json();this.onPayload({data:s})}catch(n){this.onError(e.id,n)}}async register(e=this.url){if(!Vi(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));n()})})}this.url=e,this.registering=!0;try{const r=br({id:1,jsonrpc:"2.0",method:"test",params:[]});await Ji(e,Object.assign(Object.assign({},Xi),{body:r})),this.onOpen()}catch(r){const n=this.parseError(r);throw this.events.emit("register_error",n),this.onClose(),n}}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 r=typeof e.data=="string"?In(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=qr(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return ji(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>Zi&&this.events.setMaxListeners(Zi)}}var Ln={},Vr={},re={},Qi={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(u,h){var l=u>>>16&65535,p=u&65535,E=h>>>16&65535,T=h&65535;return p*T+(l*T+p*E<<16>>>0)|0}t.mul=Math.imul||e;function r(u,h){return u+h|0}t.add=r;function n(u,h){return u-h|0}t.sub=n;function i(u,h){return u<<h|u>>>32-h}t.rotl=i;function s(u,h){return u<<32-h|u>>>h}t.rotr=s;function c(u){return typeof u=="number"&&isFinite(u)&&Math.floor(u)===u}t.isInteger=Number.isInteger||c,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(u){return t.isInteger(u)&&u>=-t.MAX_SAFE_INTEGER&&u<=t.MAX_SAFE_INTEGER}})(Qi),Object.defineProperty(re,"__esModule",{value:!0});var es=Qi;function yc(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}re.readInt16BE=yc;function _c(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}re.readUint16BE=_c;function bc(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}re.readInt16LE=bc;function mc(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}re.readUint16LE=mc;function ts(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>8,e[r+1]=t>>>0,e}re.writeUint16BE=ts,re.writeInt16BE=ts;function rs(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e}re.writeUint16LE=rs,re.writeInt16LE=rs;function Cn(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}re.readInt32BE=Cn;function Tn(t,e){return e===void 0&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}re.readUint32BE=Tn;function Nn(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}re.readInt32LE=Nn;function Pn(t,e){return e===void 0&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}re.readUint32LE=Pn;function Gr(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>24,e[r+1]=t>>>16,e[r+2]=t>>>8,e[r+3]=t>>>0,e}re.writeUint32BE=Gr,re.writeInt32BE=Gr;function Wr(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24,e}re.writeUint32LE=Wr,re.writeInt32LE=Wr;function wc(t,e){e===void 0&&(e=0);var r=Cn(t,e),n=Cn(t,e+4);return r*4294967296+n-(n>>31)*4294967296}re.readInt64BE=wc;function Ec(t,e){e===void 0&&(e=0);var r=Tn(t,e),n=Tn(t,e+4);return r*4294967296+n}re.readUint64BE=Ec;function Dc(t,e){e===void 0&&(e=0);var r=Nn(t,e),n=Nn(t,e+4);return n*4294967296+r-(r>>31)*4294967296}re.readInt64LE=Dc;function xc(t,e){e===void 0&&(e=0);var r=Pn(t,e),n=Pn(t,e+4);return n*4294967296+r}re.readUint64LE=xc;function ns(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Gr(t/4294967296>>>0,e,r),Gr(t>>>0,e,r+4),e}re.writeUint64BE=ns,re.writeInt64BE=ns;function is(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Wr(t>>>0,e,r),Wr(t/4294967296>>>0,e,r+4),e}re.writeUint64LE=is,re.writeInt64LE=is;function Sc(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=t/8+r-1;s>=r;s--)n+=e[s]*i,i*=256;return n}re.readUintBE=Sc;function Oc(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s<r+t/8;s++)n+=e[s]*i,i*=256;return n}re.readUintLE=Oc;function Ac(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!es.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var i=1,s=t/8+n-1;s>=n;s--)r[s]=e/i&255,i*=256;return r}re.writeUintBE=Ac;function Ic(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!es.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s<n+t/8;s++)r[s]=e/i&255,i*=256;return r}re.writeUintLE=Ic;function Lc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e)}re.readFloat32BE=Lc;function Cc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e,!0)}re.readFloat32LE=Cc;function Tc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e)}re.readFloat64BE=Tc;function Nc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e,!0)}re.readFloat64LE=Nc;function Pc(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat32(r,t),e}re.writeFloat32BE=Pc;function Rc(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat32(r,t,!0),e}re.writeFloat32LE=Rc;function Fc(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat64(r,t),e}re.writeFloat64BE=Fc;function Uc(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat64(r,t,!0),e}re.writeFloat64LE=Uc;var pt={};Object.defineProperty(pt,"__esModule",{value:!0});function Mc(t){for(var e=0;e<t.length;e++)t[e]=0;return t}pt.wipe=Mc,Object.defineProperty(Vr,"__esModule",{value:!0});var st=re,Rn=pt,jc=20;function $c(t,e,r){for(var n=1634760805,i=857760878,s=2036477234,c=1797285236,u=r[3]<<24|r[2]<<16|r[1]<<8|r[0],h=r[7]<<24|r[6]<<16|r[5]<<8|r[4],l=r[11]<<24|r[10]<<16|r[9]<<8|r[8],p=r[15]<<24|r[14]<<16|r[13]<<8|r[12],E=r[19]<<24|r[18]<<16|r[17]<<8|r[16],T=r[23]<<24|r[22]<<16|r[21]<<8|r[20],w=r[27]<<24|r[26]<<16|r[25]<<8|r[24],b=r[31]<<24|r[30]<<16|r[29]<<8|r[28],F=e[3]<<24|e[2]<<16|e[1]<<8|e[0],y=e[7]<<24|e[6]<<16|e[5]<<8|e[4],O=e[11]<<24|e[10]<<16|e[9]<<8|e[8],N=e[15]<<24|e[14]<<16|e[13]<<8|e[12],L=n,S=i,C=s,m=c,o=u,g=h,B=l,q=p,V=E,J=T,X=w,f=b,_=F,M=y,K=O,R=N,P=0;P<jc;P+=2)L=L+o|0,_^=L,_=_>>>32-16|_<<16,V=V+_|0,o^=V,o=o>>>32-12|o<<12,S=S+g|0,M^=S,M=M>>>32-16|M<<16,J=J+M|0,g^=J,g=g>>>32-12|g<<12,C=C+B|0,K^=C,K=K>>>32-16|K<<16,X=X+K|0,B^=X,B=B>>>32-12|B<<12,m=m+q|0,R^=m,R=R>>>32-16|R<<16,f=f+R|0,q^=f,q=q>>>32-12|q<<12,C=C+B|0,K^=C,K=K>>>32-8|K<<8,X=X+K|0,B^=X,B=B>>>32-7|B<<7,m=m+q|0,R^=m,R=R>>>32-8|R<<8,f=f+R|0,q^=f,q=q>>>32-7|q<<7,S=S+g|0,M^=S,M=M>>>32-8|M<<8,J=J+M|0,g^=J,g=g>>>32-7|g<<7,L=L+o|0,_^=L,_=_>>>32-8|_<<8,V=V+_|0,o^=V,o=o>>>32-7|o<<7,L=L+g|0,R^=L,R=R>>>32-16|R<<16,X=X+R|0,g^=X,g=g>>>32-12|g<<12,S=S+B|0,_^=S,_=_>>>32-16|_<<16,f=f+_|0,B^=f,B=B>>>32-12|B<<12,C=C+q|0,M^=C,M=M>>>32-16|M<<16,V=V+M|0,q^=V,q=q>>>32-12|q<<12,m=m+o|0,K^=m,K=K>>>32-16|K<<16,J=J+K|0,o^=J,o=o>>>32-12|o<<12,C=C+q|0,M^=C,M=M>>>32-8|M<<8,V=V+M|0,q^=V,q=q>>>32-7|q<<7,m=m+o|0,K^=m,K=K>>>32-8|K<<8,J=J+K|0,o^=J,o=o>>>32-7|o<<7,S=S+B|0,_^=S,_=_>>>32-8|_<<8,f=f+_|0,B^=f,B=B>>>32-7|B<<7,L=L+g|0,R^=L,R=R>>>32-8|R<<8,X=X+R|0,g^=X,g=g>>>32-7|g<<7;st.writeUint32LE(L+n|0,t,0),st.writeUint32LE(S+i|0,t,4),st.writeUint32LE(C+s|0,t,8),st.writeUint32LE(m+c|0,t,12),st.writeUint32LE(o+u|0,t,16),st.writeUint32LE(g+h|0,t,20),st.writeUint32LE(B+l|0,t,24),st.writeUint32LE(q+p|0,t,28),st.writeUint32LE(V+E|0,t,32),st.writeUint32LE(J+T|0,t,36),st.writeUint32LE(X+w|0,t,40),st.writeUint32LE(f+b|0,t,44),st.writeUint32LE(_+F|0,t,48),st.writeUint32LE(M+y|0,t,52),st.writeUint32LE(K+O|0,t,56),st.writeUint32LE(R+N|0,t,60)}function ss(t,e,r,n,i){if(i===void 0&&(i=0),t.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<r.length)throw new Error("ChaCha: destination is shorter than source");var s,c;if(i===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),c=s.length-e.length,s.set(e,c)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,c=i}for(var u=new Uint8Array(64),h=0;h<r.length;h+=64){$c(u,s,t);for(var l=h;l<h+64&&l<r.length;l++)n[l]=r[l]^u[l-h];zc(s,0,c)}return Rn.wipe(u),i===0&&Rn.wipe(s),n}Vr.streamXOR=ss;function Bc(t,e,r,n){return n===void 0&&(n=0),Rn.wipe(r),ss(t,e,r,r,n)}Vr.stream=Bc;function zc(t,e,r){for(var n=1;r--;)n=n+(t[e]&255)|0,t[e]=n&255,n>>>=8,e++;if(n>0)throw new Error("ChaCha: counter overflow")}var os={},zt={};Object.defineProperty(zt,"__esModule",{value:!0});function Hc(t,e,r){return~(t-1)&e|t-1&r}zt.select=Hc;function Kc(t,e){return(t|0)-(e|0)-1>>>31&1}zt.lessOrEqual=Kc;function as(t,e){if(t.length!==e.length)return 0;for(var r=0,n=0;n<t.length;n++)r|=t[n]^e[n];return 1&r-1>>>8}zt.compare=as;function qc(t,e){return t.length===0||e.length===0?!1:as(t,e)!==0}zt.equal=qc,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=zt,r=pt;t.DIGEST_LENGTH=16;var n=function(){function c(u){this.digestLength=t.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var h=u[0]|u[1]<<8;this._r[0]=h&8191;var l=u[2]|u[3]<<8;this._r[1]=(h>>>13|l<<3)&8191;var p=u[4]|u[5]<<8;this._r[2]=(l>>>10|p<<6)&7939;var E=u[6]|u[7]<<8;this._r[3]=(p>>>7|E<<9)&8191;var T=u[8]|u[9]<<8;this._r[4]=(E>>>4|T<<12)&255,this._r[5]=T>>>1&8190;var w=u[10]|u[11]<<8;this._r[6]=(T>>>14|w<<2)&8191;var b=u[12]|u[13]<<8;this._r[7]=(w>>>11|b<<5)&8065;var F=u[14]|u[15]<<8;this._r[8]=(b>>>8|F<<8)&8191,this._r[9]=F>>>5&127,this._pad[0]=u[16]|u[17]<<8,this._pad[1]=u[18]|u[19]<<8,this._pad[2]=u[20]|u[21]<<8,this._pad[3]=u[22]|u[23]<<8,this._pad[4]=u[24]|u[25]<<8,this._pad[5]=u[26]|u[27]<<8,this._pad[6]=u[28]|u[29]<<8,this._pad[7]=u[30]|u[31]<<8}return c.prototype._blocks=function(u,h,l){for(var p=this._fin?0:2048,E=this._h[0],T=this._h[1],w=this._h[2],b=this._h[3],F=this._h[4],y=this._h[5],O=this._h[6],N=this._h[7],L=this._h[8],S=this._h[9],C=this._r[0],m=this._r[1],o=this._r[2],g=this._r[3],B=this._r[4],q=this._r[5],V=this._r[6],J=this._r[7],X=this._r[8],f=this._r[9];l>=16;){var _=u[h+0]|u[h+1]<<8;E+=_&8191;var M=u[h+2]|u[h+3]<<8;T+=(_>>>13|M<<3)&8191;var K=u[h+4]|u[h+5]<<8;w+=(M>>>10|K<<6)&8191;var R=u[h+6]|u[h+7]<<8;b+=(K>>>7|R<<9)&8191;var P=u[h+8]|u[h+9]<<8;F+=(R>>>4|P<<12)&8191,y+=P>>>1&8191;var j=u[h+10]|u[h+11]<<8;O+=(P>>>14|j<<2)&8191;var $=u[h+12]|u[h+13]<<8;N+=(j>>>11|$<<5)&8191;var Q=u[h+14]|u[h+15]<<8;L+=($>>>8|Q<<8)&8191,S+=Q>>>5|p;var H=0,ee=H;ee+=E*C,ee+=T*(5*f),ee+=w*(5*X),ee+=b*(5*J),ee+=F*(5*V),H=ee>>>13,ee&=8191,ee+=y*(5*q),ee+=O*(5*B),ee+=N*(5*g),ee+=L*(5*o),ee+=S*(5*m),H+=ee>>>13,ee&=8191;var k=H;k+=E*m,k+=T*C,k+=w*(5*f),k+=b*(5*X),k+=F*(5*J),H=k>>>13,k&=8191,k+=y*(5*V),k+=O*(5*q),k+=N*(5*B),k+=L*(5*g),k+=S*(5*o),H+=k>>>13,k&=8191;var ae=H;ae+=E*o,ae+=T*m,ae+=w*C,ae+=b*(5*f),ae+=F*(5*X),H=ae>>>13,ae&=8191,ae+=y*(5*J),ae+=O*(5*V),ae+=N*(5*q),ae+=L*(5*B),ae+=S*(5*g),H+=ae>>>13,ae&=8191;var I=H;I+=E*g,I+=T*o,I+=w*m,I+=b*C,I+=F*(5*f),H=I>>>13,I&=8191,I+=y*(5*X),I+=O*(5*J),I+=N*(5*V),I+=L*(5*q),I+=S*(5*B),H+=I>>>13,I&=8191;var A=H;A+=E*B,A+=T*g,A+=w*o,A+=b*m,A+=F*C,H=A>>>13,A&=8191,A+=y*(5*f),A+=O*(5*X),A+=N*(5*J),A+=L*(5*V),A+=S*(5*q),H+=A>>>13,A&=8191;var D=H;D+=E*q,D+=T*B,D+=w*g,D+=b*o,D+=F*m,H=D>>>13,D&=8191,D+=y*C,D+=O*(5*f),D+=N*(5*X),D+=L*(5*J),D+=S*(5*V),H+=D>>>13,D&=8191;var a=H;a+=E*V,a+=T*q,a+=w*B,a+=b*g,a+=F*o,H=a>>>13,a&=8191,a+=y*m,a+=O*C,a+=N*(5*f),a+=L*(5*X),a+=S*(5*J),H+=a>>>13,a&=8191;var v=H;v+=E*J,v+=T*V,v+=w*q,v+=b*B,v+=F*g,H=v>>>13,v&=8191,v+=y*o,v+=O*m,v+=N*C,v+=L*(5*f),v+=S*(5*X),H+=v>>>13,v&=8191;var z=H;z+=E*X,z+=T*J,z+=w*V,z+=b*q,z+=F*B,H=z>>>13,z&=8191,z+=y*g,z+=O*o,z+=N*m,z+=L*C,z+=S*(5*f),H+=z>>>13,z&=8191;var Y=H;Y+=E*f,Y+=T*X,Y+=w*J,Y+=b*V,Y+=F*q,H=Y>>>13,Y&=8191,Y+=y*B,Y+=O*g,Y+=N*o,Y+=L*m,Y+=S*C,H+=Y>>>13,Y&=8191,H=(H<<2)+H|0,H=H+ee|0,ee=H&8191,H=H>>>13,k+=H,E=ee,T=k,w=ae,b=I,F=A,y=D,O=a,N=v,L=z,S=Y,h+=16,l-=16}this._h[0]=E,this._h[1]=T,this._h[2]=w,this._h[3]=b,this._h[4]=F,this._h[5]=y,this._h[6]=O,this._h[7]=N,this._h[8]=L,this._h[9]=S},c.prototype.finish=function(u,h){h===void 0&&(h=0);var l=new Uint16Array(10),p,E,T,w;if(this._leftover){for(w=this._leftover,this._buffer[w++]=1;w<16;w++)this._buffer[w]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(p=this._h[1]>>>13,this._h[1]&=8191,w=2;w<10;w++)this._h[w]+=p,p=this._h[w]>>>13,this._h[w]&=8191;for(this._h[0]+=p*5,p=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=p,p=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=p,l[0]=this._h[0]+5,p=l[0]>>>13,l[0]&=8191,w=1;w<10;w++)l[w]=this._h[w]+p,p=l[w]>>>13,l[w]&=8191;for(l[9]-=1<<13,E=(p^1)-1,w=0;w<10;w++)l[w]&=E;for(E=~E,w=0;w<10;w++)this._h[w]=this._h[w]&E|l[w];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,T=this._h[0]+this._pad[0],this._h[0]=T&65535,w=1;w<8;w++)T=(this._h[w]+this._pad[w]|0)+(T>>>16)|0,this._h[w]=T&65535;return u[h+0]=this._h[0]>>>0,u[h+1]=this._h[0]>>>8,u[h+2]=this._h[1]>>>0,u[h+3]=this._h[1]>>>8,u[h+4]=this._h[2]>>>0,u[h+5]=this._h[2]>>>8,u[h+6]=this._h[3]>>>0,u[h+7]=this._h[3]>>>8,u[h+8]=this._h[4]>>>0,u[h+9]=this._h[4]>>>8,u[h+10]=this._h[5]>>>0,u[h+11]=this._h[5]>>>8,u[h+12]=this._h[6]>>>0,u[h+13]=this._h[6]>>>8,u[h+14]=this._h[7]>>>0,u[h+15]=this._h[7]>>>8,this._finished=!0,this},c.prototype.update=function(u){var h=0,l=u.length,p;if(this._leftover){p=16-this._leftover,p>l&&(p=l);for(var E=0;E<p;E++)this._buffer[this._leftover+E]=u[h+E];if(l-=p,h+=p,this._leftover+=p,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(l>=16&&(p=l-l%16,this._blocks(u,h,p),h+=p,l-=p),l){for(var E=0;E<l;E++)this._buffer[this._leftover+E]=u[h+E];this._leftover+=l}return this},c.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var u=new Uint8Array(16);return this.finish(u),u},c.prototype.clean=function(){return r.wipe(this._buffer),r.wipe(this._r),r.wipe(this._h),r.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},c}();t.Poly1305=n;function i(c,u){var h=new n(c);h.update(u);var l=h.digest();return h.clean(),l}t.oneTimeAuth=i;function s(c,u){return c.length!==t.DIGEST_LENGTH||u.length!==t.DIGEST_LENGTH?!1:e.equal(c,u)}t.equal=s}(os),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Vr,r=os,n=pt,i=re,s=zt;t.KEY_LENGTH=32,t.NONCE_LENGTH=12,t.TAG_LENGTH=16;var c=new Uint8Array(16),u=function(){function h(l){if(this.nonceLength=t.NONCE_LENGTH,this.tagLength=t.TAG_LENGTH,l.length!==t.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(l)}return h.prototype.seal=function(l,p,E,T){if(l.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var w=new Uint8Array(16);w.set(l,w.length-l.length);var b=new Uint8Array(32);e.stream(this._key,w,b,4);var F=p.length+this.tagLength,y;if(T){if(T.length!==F)throw new Error("ChaCha20Poly1305: incorrect destination length");y=T}else y=new Uint8Array(F);return e.streamXOR(this._key,w,p,y,4),this._authenticate(y.subarray(y.length-this.tagLength,y.length),b,y.subarray(0,y.length-this.tagLength),E),n.wipe(w),y},h.prototype.open=function(l,p,E,T){if(l.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(p.length<this.tagLength)return null;var w=new Uint8Array(16);w.set(l,w.length-l.length);var b=new Uint8Array(32);e.stream(this._key,w,b,4);var F=new Uint8Array(this.tagLength);if(this._authenticate(F,b,p.subarray(0,p.length-this.tagLength),E),!s.equal(F,p.subarray(p.length-this.tagLength,p.length)))return null;var y=p.length-this.tagLength,O;if(T){if(T.length!==y)throw new Error("ChaCha20Poly1305: incorrect destination length");O=T}else O=new Uint8Array(y);return e.streamXOR(this._key,w,p.subarray(0,p.length-this.tagLength),O,4),n.wipe(w),O},h.prototype.clean=function(){return n.wipe(this._key),this},h.prototype._authenticate=function(l,p,E,T){var w=new r.Poly1305(p);T&&(w.update(T),T.length%16>0&&w.update(c.subarray(T.length%16))),w.update(E),E.length%16>0&&w.update(c.subarray(E.length%16));var b=new Uint8Array(8);T&&i.writeUint64LE(T.length,b),w.update(b),i.writeUint64LE(E.length,b),w.update(b);for(var F=w.digest(),y=0;y<F.length;y++)l[y]=F[y];w.clean(),n.wipe(F),n.wipe(b)},h}();t.ChaCha20Poly1305=u}(Ln);var cs={},mr={},Fn={};Object.defineProperty(Fn,"__esModule",{value:!0});function Vc(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}Fn.isSerializableHash=Vc,Object.defineProperty(mr,"__esModule",{value:!0});var Ot=Fn,Gc=zt,Wc=pt,us=function(){function t(e,r){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var n=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(n).clean():n.set(r);for(var i=0;i<n.length;i++)n[i]^=54;this._inner.update(n);for(var i=0;i<n.length;i++)n[i]^=106;this._outer.update(n),Ot.isSerializableHash(this._inner)&&Ot.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),Wc.wipe(n)}return t.prototype.reset=function(){if(!Ot.isSerializableHash(this._inner)||!Ot.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.clean=function(){Ot.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),Ot.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},t.prototype.update=function(e){return this._inner.update(e),this},t.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype.saveState=function(){if(!Ot.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},t.prototype.restoreState=function(e){if(!Ot.isSerializableHash(this._inner)||!Ot.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.cleanSavedState=function(e){if(!Ot.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},t}();mr.HMAC=us;function kc(t,e,r){var n=new us(t,e);n.update(r);var i=n.digest();return n.clean(),i}mr.hmac=kc,mr.equal=Gc.equal,Object.defineProperty(cs,"__esModule",{value:!0});var hs=mr,fs=pt,Yc=function(){function t(e,r,n,i){n===void 0&&(n=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=i;var s=hs.hmac(this._hash,n,r);this._hmac=new hs.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return t.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},t.prototype.expand=function(e){for(var r=new Uint8Array(e),n=0;n<r.length;n++)this._bufpos===this._buffer.length&&this._fillBuffer(),r[n]=this._buffer[this._bufpos++];return r},t.prototype.clean=function(){this._hmac.clean(),fs.wipe(this._buffer),fs.wipe(this._counter),this._bufpos=0},t}(),Jc=cs.HKDF=Yc,nr={},Un={},Mn={};Object.defineProperty(Mn,"__esModule",{value:!0});var ls=65536,Xc=function(){function t(){this.isAvailable=!1,this.isInstantiated=!1;var e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}return t.prototype.randomBytes=function(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");for(var r=new Uint8Array(e),n=0;n<r.length;n+=ls)this._crypto.getRandomValues(r.subarray(n,n+Math.min(r.length-n,ls)));return r},t}();Mn.BrowserRandomSource=Xc;function Zc(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var jn={},Qc={},eu=Object.freeze({__proto__:null,default:Qc}),tu=wn(eu);Object.defineProperty(jn,"__esModule",{value:!0});var ru=pt,nu=function(){function t(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Zc<"u"){var e=tu;e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}return t.prototype.randomBytes=function(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");var r=this._crypto.randomBytes(e);if(r.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");for(var n=new Uint8Array(e),i=0;i<n.length;i++)n[i]=r[i];return ru.wipe(r),n},t}();jn.NodeRandomSource=nu,Object.defineProperty(Un,"__esModule",{value:!0});var iu=Mn,su=jn,ou=function(){function t(){if(this.isAvailable=!1,this.name="",this._source=new iu.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new su.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}return t.prototype.randomBytes=function(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)},t}();Un.SystemRandomSource=ou,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Un,r=re,n=pt;t.defaultRandomSource=new e.SystemRandomSource;function i(l,p){return p===void 0&&(p=t.defaultRandomSource),p.randomBytes(l)}t.randomBytes=i;function s(l){l===void 0&&(l=t.defaultRandomSource);var p=i(4,l),E=r.readUint32LE(p);return n.wipe(p),E}t.randomUint32=s;var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function u(l,p,E){if(p===void 0&&(p=c),E===void 0&&(E=t.defaultRandomSource),p.length<2)throw new Error("randomString charset is too short");if(p.length>256)throw new Error("randomString charset is too long");for(var T="",w=p.length,b=256-256%w;l>0;){for(var F=i(Math.ceil(l*256/b),E),y=0;y<F.length&&l>0;y++){var O=F[y];O<b&&(T+=p.charAt(O%w),l--)}n.wipe(F)}return T}t.randomString=u;function h(l,p,E){p===void 0&&(p=c),E===void 0&&(E=t.defaultRandomSource);var T=Math.ceil(l/(Math.log(p.length)/Math.LN2));return u(T,p,E)}t.randomStringForEntropy=h}(nr);var kr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=pt;t.DIGEST_LENGTH=32,t.BLOCK_SIZE=64;var n=function(){function u(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return u.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},u.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},u.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},u.prototype.update=function(h,l){if(l===void 0&&(l=h.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var p=0;if(this._bytesHashed+=l,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&l>0;)this._buffer[this._bufferLength++]=h[p++],l--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(l>=this.blockSize&&(p=s(this._temp,this._state,h,p,l),l%=this.blockSize);l>0;)this._buffer[this._bufferLength++]=h[p++],l--;return this},u.prototype.finish=function(h){if(!this._finished){var l=this._bytesHashed,p=this._bufferLength,E=l/536870912|0,T=l<<3,w=l%64<56?64:128;this._buffer[p]=128;for(var b=p+1;b<w-8;b++)this._buffer[b]=0;e.writeUint32BE(E,this._buffer,w-8),e.writeUint32BE(T,this._buffer,w-4),s(this._temp,this._state,this._buffer,0,w),this._finished=!0}for(var b=0;b<this.digestLength/4;b++)e.writeUint32BE(this._state[b],h,b*4);return this},u.prototype.digest=function(){var h=new Uint8Array(this.digestLength);return this.finish(h),h},u.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},u.prototype.restoreState=function(h){return this._state.set(h.state),this._bufferLength=h.bufferLength,h.buffer&&this._buffer.set(h.buffer),this._bytesHashed=h.bytesHashed,this._finished=!1,this},u.prototype.cleanSavedState=function(h){r.wipe(h.state),h.buffer&&r.wipe(h.buffer),h.bufferLength=0,h.bytesHashed=0},u}();t.SHA256=n;var i=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function s(u,h,l,p,E){for(;E>=64;){for(var T=h[0],w=h[1],b=h[2],F=h[3],y=h[4],O=h[5],N=h[6],L=h[7],S=0;S<16;S++){var C=p+S*4;u[S]=e.readUint32BE(l,C)}for(var S=16;S<64;S++){var m=u[S-2],o=(m>>>17|m<<32-17)^(m>>>19|m<<32-19)^m>>>10;m=u[S-15];var g=(m>>>7|m<<32-7)^(m>>>18|m<<32-18)^m>>>3;u[S]=(o+u[S-7]|0)+(g+u[S-16]|0)}for(var S=0;S<64;S++){var o=(((y>>>6|y<<26)^(y>>>11|y<<21)^(y>>>25|y<<7))+(y&O^~y&N)|0)+(L+(i[S]+u[S]|0)|0)|0,g=((T>>>2|T<<32-2)^(T>>>13|T<<32-13)^(T>>>22|T<<32-22))+(T&w^T&b^w&b)|0;L=N,N=O,O=y,y=F+o|0,F=b,b=w,w=T,T=o+g|0}h[0]+=T,h[1]+=w,h[2]+=b,h[3]+=F,h[4]+=y,h[5]+=O,h[6]+=N,h[7]+=L,p+=64,E-=64}return p}function c(u){var h=new n;h.update(u);var l=h.digest();return h.clean(),l}t.hash=c})(kr);var $n={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=nr,r=pt;t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function n(S){var C=new Float64Array(16);if(S)for(var m=0;m<S.length;m++)C[m]=S[m];return C}var i=new Uint8Array(32);i[0]=9;var s=n([56129,1]);function c(S){for(var C=1,m=0;m<16;m++){var o=S[m]+C+65535;C=Math.floor(o/65536),S[m]=o-C*65536}S[0]+=C-1+37*(C-1)}function u(S,C,m){for(var o=~(m-1),g=0;g<16;g++){var B=o&(S[g]^C[g]);S[g]^=B,C[g]^=B}}function h(S,C){for(var m=n(),o=n(),g=0;g<16;g++)o[g]=C[g];c(o),c(o),c(o);for(var B=0;B<2;B++){m[0]=o[0]-65517;for(var g=1;g<15;g++)m[g]=o[g]-65535-(m[g-1]>>16&1),m[g-1]&=65535;m[15]=o[15]-32767-(m[14]>>16&1);var q=m[15]>>16&1;m[14]&=65535,u(o,m,1-q)}for(var g=0;g<16;g++)S[2*g]=o[g]&255,S[2*g+1]=o[g]>>8}function l(S,C){for(var m=0;m<16;m++)S[m]=C[2*m]+(C[2*m+1]<<8);S[15]&=32767}function p(S,C,m){for(var o=0;o<16;o++)S[o]=C[o]+m[o]}function E(S,C,m){for(var o=0;o<16;o++)S[o]=C[o]-m[o]}function T(S,C,m){var o,g,B=0,q=0,V=0,J=0,X=0,f=0,_=0,M=0,K=0,R=0,P=0,j=0,$=0,Q=0,H=0,ee=0,k=0,ae=0,I=0,A=0,D=0,a=0,v=0,z=0,Y=0,fe=0,ye=0,de=0,me=0,Ue=0,Te=0,ve=m[0],pe=m[1],le=m[2],ue=m[3],ce=m[4],oe=m[5],se=m[6],te=m[7],he=m[8],ge=m[9],ne=m[10],_e=m[11],be=m[12],Ee=m[13],De=m[14],we=m[15];o=C[0],B+=o*ve,q+=o*pe,V+=o*le,J+=o*ue,X+=o*ce,f+=o*oe,_+=o*se,M+=o*te,K+=o*he,R+=o*ge,P+=o*ne,j+=o*_e,$+=o*be,Q+=o*Ee,H+=o*De,ee+=o*we,o=C[1],q+=o*ve,V+=o*pe,J+=o*le,X+=o*ue,f+=o*ce,_+=o*oe,M+=o*se,K+=o*te,R+=o*he,P+=o*ge,j+=o*ne,$+=o*_e,Q+=o*be,H+=o*Ee,ee+=o*De,k+=o*we,o=C[2],V+=o*ve,J+=o*pe,X+=o*le,f+=o*ue,_+=o*ce,M+=o*oe,K+=o*se,R+=o*te,P+=o*he,j+=o*ge,$+=o*ne,Q+=o*_e,H+=o*be,ee+=o*Ee,k+=o*De,ae+=o*we,o=C[3],J+=o*ve,X+=o*pe,f+=o*le,_+=o*ue,M+=o*ce,K+=o*oe,R+=o*se,P+=o*te,j+=o*he,$+=o*ge,Q+=o*ne,H+=o*_e,ee+=o*be,k+=o*Ee,ae+=o*De,I+=o*we,o=C[4],X+=o*ve,f+=o*pe,_+=o*le,M+=o*ue,K+=o*ce,R+=o*oe,P+=o*se,j+=o*te,$+=o*he,Q+=o*ge,H+=o*ne,ee+=o*_e,k+=o*be,ae+=o*Ee,I+=o*De,A+=o*we,o=C[5],f+=o*ve,_+=o*pe,M+=o*le,K+=o*ue,R+=o*ce,P+=o*oe,j+=o*se,$+=o*te,Q+=o*he,H+=o*ge,ee+=o*ne,k+=o*_e,ae+=o*be,I+=o*Ee,A+=o*De,D+=o*we,o=C[6],_+=o*ve,M+=o*pe,K+=o*le,R+=o*ue,P+=o*ce,j+=o*oe,$+=o*se,Q+=o*te,H+=o*he,ee+=o*ge,k+=o*ne,ae+=o*_e,I+=o*be,A+=o*Ee,D+=o*De,a+=o*we,o=C[7],M+=o*ve,K+=o*pe,R+=o*le,P+=o*ue,j+=o*ce,$+=o*oe,Q+=o*se,H+=o*te,ee+=o*he,k+=o*ge,ae+=o*ne,I+=o*_e,A+=o*be,D+=o*Ee,a+=o*De,v+=o*we,o=C[8],K+=o*ve,R+=o*pe,P+=o*le,j+=o*ue,$+=o*ce,Q+=o*oe,H+=o*se,ee+=o*te,k+=o*he,ae+=o*ge,I+=o*ne,A+=o*_e,D+=o*be,a+=o*Ee,v+=o*De,z+=o*we,o=C[9],R+=o*ve,P+=o*pe,j+=o*le,$+=o*ue,Q+=o*ce,H+=o*oe,ee+=o*se,k+=o*te,ae+=o*he,I+=o*ge,A+=o*ne,D+=o*_e,a+=o*be,v+=o*Ee,z+=o*De,Y+=o*we,o=C[10],P+=o*ve,j+=o*pe,$+=o*le,Q+=o*ue,H+=o*ce,ee+=o*oe,k+=o*se,ae+=o*te,I+=o*he,A+=o*ge,D+=o*ne,a+=o*_e,v+=o*be,z+=o*Ee,Y+=o*De,fe+=o*we,o=C[11],j+=o*ve,$+=o*pe,Q+=o*le,H+=o*ue,ee+=o*ce,k+=o*oe,ae+=o*se,I+=o*te,A+=o*he,D+=o*ge,a+=o*ne,v+=o*_e,z+=o*be,Y+=o*Ee,fe+=o*De,ye+=o*we,o=C[12],$+=o*ve,Q+=o*pe,H+=o*le,ee+=o*ue,k+=o*ce,ae+=o*oe,I+=o*se,A+=o*te,D+=o*he,a+=o*ge,v+=o*ne,z+=o*_e,Y+=o*be,fe+=o*Ee,ye+=o*De,de+=o*we,o=C[13],Q+=o*ve,H+=o*pe,ee+=o*le,k+=o*ue,ae+=o*ce,I+=o*oe,A+=o*se,D+=o*te,a+=o*he,v+=o*ge,z+=o*ne,Y+=o*_e,fe+=o*be,ye+=o*Ee,de+=o*De,me+=o*we,o=C[14],H+=o*ve,ee+=o*pe,k+=o*le,ae+=o*ue,I+=o*ce,A+=o*oe,D+=o*se,a+=o*te,v+=o*he,z+=o*ge,Y+=o*ne,fe+=o*_e,ye+=o*be,de+=o*Ee,me+=o*De,Ue+=o*we,o=C[15],ee+=o*ve,k+=o*pe,ae+=o*le,I+=o*ue,A+=o*ce,D+=o*oe,a+=o*se,v+=o*te,z+=o*he,Y+=o*ge,fe+=o*ne,ye+=o*_e,de+=o*be,me+=o*Ee,Ue+=o*De,Te+=o*we,B+=38*k,q+=38*ae,V+=38*I,J+=38*A,X+=38*D,f+=38*a,_+=38*v,M+=38*z,K+=38*Y,R+=38*fe,P+=38*ye,j+=38*de,$+=38*me,Q+=38*Ue,H+=38*Te,g=1,o=B+g+65535,g=Math.floor(o/65536),B=o-g*65536,o=q+g+65535,g=Math.floor(o/65536),q=o-g*65536,o=V+g+65535,g=Math.floor(o/65536),V=o-g*65536,o=J+g+65535,g=Math.floor(o/65536),J=o-g*65536,o=X+g+65535,g=Math.floor(o/65536),X=o-g*65536,o=f+g+65535,g=Math.floor(o/65536),f=o-g*65536,o=_+g+65535,g=Math.floor(o/65536),_=o-g*65536,o=M+g+65535,g=Math.floor(o/65536),M=o-g*65536,o=K+g+65535,g=Math.floor(o/65536),K=o-g*65536,o=R+g+65535,g=Math.floor(o/65536),R=o-g*65536,o=P+g+65535,g=Math.floor(o/65536),P=o-g*65536,o=j+g+65535,g=Math.floor(o/65536),j=o-g*65536,o=$+g+65535,g=Math.floor(o/65536),$=o-g*65536,o=Q+g+65535,g=Math.floor(o/65536),Q=o-g*65536,o=H+g+65535,g=Math.floor(o/65536),H=o-g*65536,o=ee+g+65535,g=Math.floor(o/65536),ee=o-g*65536,B+=g-1+37*(g-1),g=1,o=B+g+65535,g=Math.floor(o/65536),B=o-g*65536,o=q+g+65535,g=Math.floor(o/65536),q=o-g*65536,o=V+g+65535,g=Math.floor(o/65536),V=o-g*65536,o=J+g+65535,g=Math.floor(o/65536),J=o-g*65536,o=X+g+65535,g=Math.floor(o/65536),X=o-g*65536,o=f+g+65535,g=Math.floor(o/65536),f=o-g*65536,o=_+g+65535,g=Math.floor(o/65536),_=o-g*65536,o=M+g+65535,g=Math.floor(o/65536),M=o-g*65536,o=K+g+65535,g=Math.floor(o/65536),K=o-g*65536,o=R+g+65535,g=Math.floor(o/65536),R=o-g*65536,o=P+g+65535,g=Math.floor(o/65536),P=o-g*65536,o=j+g+65535,g=Math.floor(o/65536),j=o-g*65536,o=$+g+65535,g=Math.floor(o/65536),$=o-g*65536,o=Q+g+65535,g=Math.floor(o/65536),Q=o-g*65536,o=H+g+65535,g=Math.floor(o/65536),H=o-g*65536,o=ee+g+65535,g=Math.floor(o/65536),ee=o-g*65536,B+=g-1+37*(g-1),S[0]=B,S[1]=q,S[2]=V,S[3]=J,S[4]=X,S[5]=f,S[6]=_,S[7]=M,S[8]=K,S[9]=R,S[10]=P,S[11]=j,S[12]=$,S[13]=Q,S[14]=H,S[15]=ee}function w(S,C){T(S,C,C)}function b(S,C){for(var m=n(),o=0;o<16;o++)m[o]=C[o];for(var o=253;o>=0;o--)w(m,m),o!==2&&o!==4&&T(m,m,C);for(var o=0;o<16;o++)S[o]=m[o]}function F(S,C){for(var m=new Uint8Array(32),o=new Float64Array(80),g=n(),B=n(),q=n(),V=n(),J=n(),X=n(),f=0;f<31;f++)m[f]=S[f];m[31]=S[31]&127|64,m[0]&=248,l(o,C);for(var f=0;f<16;f++)B[f]=o[f];g[0]=V[0]=1;for(var f=254;f>=0;--f){var _=m[f>>>3]>>>(f&7)&1;u(g,B,_),u(q,V,_),p(J,g,q),E(g,g,q),p(q,B,V),E(B,B,V),w(V,J),w(X,g),T(g,q,g),T(q,B,J),p(J,g,q),E(g,g,q),w(B,g),E(q,V,X),T(g,q,s),p(g,g,V),T(q,q,g),T(g,V,X),T(V,B,o),w(B,J),u(g,B,_),u(q,V,_)}for(var f=0;f<16;f++)o[f+16]=g[f],o[f+32]=q[f],o[f+48]=B[f],o[f+64]=V[f];var M=o.subarray(32),K=o.subarray(16);b(M,M),T(K,K,M);var R=new Uint8Array(32);return h(R,K),R}t.scalarMult=F;function y(S){return F(S,i)}t.scalarMultBase=y;function O(S){if(S.length!==t.SECRET_KEY_LENGTH)throw new Error("x25519: seed must be "+t.SECRET_KEY_LENGTH+" bytes");var C=new Uint8Array(S),m=y(C);return{publicKey:m,secretKey:C}}t.generateKeyPairFromSeed=O;function N(S){var C=e.randomBytes(32,S),m=O(C);return r.wipe(C),m}t.generateKeyPair=N;function L(S,C,m){if(m===void 0&&(m=!1),S.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(C.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");var o=F(S,C);if(m){for(var g=0,B=0;B<o.length;B++)g|=o[B];if(g===0)throw new Error("X25519: invalid shared key")}return o}t.sharedKey=L})($n);function Bn(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));const r=new Uint8Array(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function au(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),c=s.charCodeAt(0);if(r[c]!==255)throw new TypeError(s+" is ambiguous");r[c]=i}var u=t.length,h=t.charAt(0),l=Math.log(u)/Math.log(256),p=Math.log(256)/Math.log(u);function E(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var F=0,y=0,O=0,N=b.length;O!==N&&b[O]===0;)O++,F++;for(var L=(N-O)*p+1>>>0,S=new Uint8Array(L);O!==N;){for(var C=b[O],m=0,o=L-1;(C!==0||m<y)&&o!==-1;o--,m++)C+=256*S[o]>>>0,S[o]=C%u>>>0,C=C/u>>>0;if(C!==0)throw new Error("Non-zero carry");y=m,O++}for(var g=L-y;g!==L&&S[g]===0;)g++;for(var B=h.repeat(F);g<L;++g)B+=t.charAt(S[g]);return B}function T(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var F=0;if(b[F]!==" "){for(var y=0,O=0;b[F]===h;)y++,F++;for(var N=(b.length-F)*l+1>>>0,L=new Uint8Array(N);b[F];){var S=r[b.charCodeAt(F)];if(S===255)return;for(var C=0,m=N-1;(S!==0||C<O)&&m!==-1;m--,C++)S+=u*L[m]>>>0,L[m]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");O=C,F++}if(b[F]!==" "){for(var o=N-O;o!==N&&L[o]===0;)o++;for(var g=new Uint8Array(y+(N-o)),B=y;o!==N;)g[B++]=L[o++];return g}}}function w(b){var F=T(b);if(F)return F;throw new Error(`Non-${e} character`)}return{encode:E,decodeUnsafe:T,decode:w}}var cu=au,uu=cu;const ds=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},hu=t=>new TextEncoder().encode(t),fu=t=>new TextDecoder().decode(t);class lu{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class du{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){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))}else throw Error("Can only multibase decode strings")}or(e){return ps(this,e)}}class pu{constructor(e){this.decoders=e}or(e){return ps(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const ps=(t,e)=>new pu({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class gu{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new lu(e,r,n),this.decoder=new du(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Yr=({name:t,prefix:e,encode:r,decode:n})=>new gu(t,e,r,n),wr=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=uu(r,e);return Yr({prefix:t,name:e,encode:n,decode:s=>ds(i(s))})},vu=(t,e,r,n)=>{const i={};for(let p=0;p<e.length;++p)i[e[p]]=p;let s=t.length;for(;t[s-1]==="=";)--s;const c=new Uint8Array(s*r/8|0);let u=0,h=0,l=0;for(let p=0;p<s;++p){const E=i[t[p]];if(E===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<r|E,u+=r,u>=8&&(u-=8,c[l++]=255&h>>u)}if(u>=r||255&h<<8-u)throw new SyntaxError("Unexpected end of data");return c},yu=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",c=0,u=0;for(let h=0;h<t.length;++h)for(u=u<<8|t[h],c+=8;c>r;)c-=r,s+=e[i&u>>c];if(c&&(s+=e[i&u<<r-c]),n)for(;s.length*r&7;)s+="=";return s},tt=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Yr({prefix:e,name:t,encode(i){return yu(i,n,r)},decode(i){return vu(i,n,r,t)}}),_u=Yr({prefix:"\0",name:"identity",encode:t=>fu(t),decode:t=>hu(t)});var bu=Object.freeze({__proto__:null,identity:_u});const mu=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var wu=Object.freeze({__proto__:null,base2:mu});const Eu=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Du=Object.freeze({__proto__:null,base8:Eu});const xu=wr({prefix:"9",name:"base10",alphabet:"0123456789"});var Su=Object.freeze({__proto__:null,base10:xu});const Ou=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Au=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Iu=Object.freeze({__proto__:null,base16:Ou,base16upper:Au});const Lu=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Cu=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Tu=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Nu=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Pu=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ru=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Fu=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Uu=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Mu=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ju=Object.freeze({__proto__:null,base32:Lu,base32upper:Cu,base32pad:Tu,base32padupper:Nu,base32hex:Pu,base32hexupper:Ru,base32hexpad:Fu,base32hexpadupper:Uu,base32z:Mu});const $u=wr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Bu=wr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var zu=Object.freeze({__proto__:null,base36:$u,base36upper:Bu});const Hu=wr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ku=wr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var qu=Object.freeze({__proto__:null,base58btc:Hu,base58flickr:Ku});const Vu=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Gu=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Wu=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ku=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Yu=Object.freeze({__proto__:null,base64:Vu,base64pad:Gu,base64url:Wu,base64urlpad:ku});const gs=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Ju=gs.reduce((t,e,r)=>(t[r]=e,t),[]),Xu=gs.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Zu(t){return t.reduce((e,r)=>(e+=Ju[r],e),"")}function Qu(t){const e=[];for(const r of t){const n=Xu[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const eh=Yr({prefix:"\u{1F680}",name:"base256emoji",encode:Zu,decode:Qu});var th=Object.freeze({__proto__:null,base256emoji:eh}),rh=ys,vs=128,nh=127,ih=~nh,sh=Math.pow(2,31);function ys(t,e,r){e=e||[],r=r||0;for(var n=r;t>=sh;)e[r++]=t&255|vs,t/=128;for(;t&ih;)e[r++]=t&255|vs,t>>>=7;return e[r]=t|0,ys.bytes=r-n+1,e}var oh=zn,ah=128,_s=127;function zn(t,n){var r=0,n=n||0,i=0,s=n,c,u=t.length;do{if(s>=u)throw zn.bytes=0,new RangeError("Could not decode varint");c=t[s++],r+=i<28?(c&_s)<<i:(c&_s)*Math.pow(2,i),i+=7}while(c>=ah);return zn.bytes=s-n,r}var ch=Math.pow(2,7),uh=Math.pow(2,14),hh=Math.pow(2,21),fh=Math.pow(2,28),lh=Math.pow(2,35),dh=Math.pow(2,42),ph=Math.pow(2,49),gh=Math.pow(2,56),vh=Math.pow(2,63),yh=function(t){return t<ch?1:t<uh?2:t<hh?3:t<fh?4:t<lh?5:t<dh?6:t<ph?7:t<gh?8:t<vh?9:10},_h={encode:rh,decode:oh,encodingLength:yh},bs=_h;const ms=(t,e,r=0)=>(bs.encode(t,e,r),e),ws=t=>bs.encodingLength(t),Hn=(t,e)=>{const r=e.byteLength,n=ws(t),i=n+ws(r),s=new Uint8Array(i+r);return ms(t,s,0),ms(r,s,n),s.set(e,i),new bh(t,r,e,s)};class bh{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const Es=({name:t,code:e,encode:r})=>new mh(t,e,r);class mh{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Hn(this.code,r):r.then(n=>Hn(this.code,n))}else throw Error("Unknown type, must be binary type")}}const Ds=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),wh=Es({name:"sha2-256",code:18,encode:Ds("SHA-256")}),Eh=Es({name:"sha2-512",code:19,encode:Ds("SHA-512")});var Dh=Object.freeze({__proto__:null,sha256:wh,sha512:Eh});const xs=0,xh="identity",Ss=ds;var Sh=Object.freeze({__proto__:null,identity:{code:xs,name:xh,encode:Ss,digest:t=>Hn(xs,Ss(t))}});new TextEncoder,new TextDecoder;const Os={...bu,...wu,...Du,...Su,...Iu,...ju,...zu,...qu,...Yu,...th};({...Dh,...Sh});function As(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const Is=As("utf8","u",t=>{const e=new TextDecoder("utf8");return"u"+e.decode(t)},t=>new TextEncoder().encode(t.substring(1))),Kn=As("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Ls={utf8:Is,"utf-8":Is,hex:Os.base16,latin1:Kn,ascii:Kn,binary:Kn,...Os};function ht(t,e="utf8"){const r=Ls[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}function ft(t,e="utf8"){const r=Ls[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return r.encoder.encode(t).substring(1)}var Cs=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},Oh=function(){function t(e,r,n){this.name=e,this.version=r,this.os=n,this.type="browser"}return t}(),Ah=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),Ih=function(){function t(e,r,n,i){this.name=e,this.version=r,this.os=n,this.bot=i,this.type="bot-device"}return t}(),Lh=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),Ch=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Th=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Nh=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Ts=3,Ph=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",Th]],Ns=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function Rh(t){return t?Ps(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Ch:typeof navigator<"u"?Ps(navigator.userAgent):Mh()}function Fh(t){return t!==""&&Ph.reduce(function(e,r){var n=r[0],i=r[1];if(e)return e;var s=i.exec(t);return!!s&&[n,s]},!1)}function Ps(t){var e=Fh(t);if(!e)return null;var r=e[0],n=e[1];if(r==="searchbot")return new Lh;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length<Ts&&(i=Cs(Cs([],i,!0),jh(Ts-i.length),!0)):i=[];var s=i.join("."),c=Uh(t),u=Nh.exec(t);return u&&u[1]?new Ih(r,s,c,u[1]):new Oh(r,s,c)}function Uh(t){for(var e=0,r=Ns.length;e<r;e++){var n=Ns[e],i=n[0],s=n[1],c=s.exec(t);if(c)return i}return null}function Mh(){var t=typeof process<"u"&&process.version;return t?new Ah(process.version.slice(1)):null}function jh(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var Le={},Rs={},Jr={};Object.defineProperty(Jr,"__esModule",{value:!0}),Jr.delay=void 0;function $h(t){return new Promise(e=>{setTimeout(()=>{e(!0)},t)})}Jr.delay=$h;var ir={},qn={},sr={};Object.defineProperty(sr,"__esModule",{value:!0}),sr.ONE_THOUSAND=sr.ONE_HUNDRED=void 0,sr.ONE_HUNDRED=100,sr.ONE_THOUSAND=1e3;var Fs={};(function(t){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=t.ONE_MINUTE*5,t.TEN_MINUTES=t.ONE_MINUTE*10,t.THIRTY_MINUTES=t.ONE_MINUTE*30,t.SIXTY_MINUTES=t.ONE_MINUTE*60,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=t.ONE_HOUR*3,t.SIX_HOURS=t.ONE_HOUR*6,t.TWELVE_HOURS=t.ONE_HOUR*12,t.TWENTY_FOUR_HOURS=t.ONE_HOUR*24,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=t.ONE_DAY*3,t.FIVE_DAYS=t.ONE_DAY*5,t.SEVEN_DAYS=t.ONE_DAY*7,t.THIRTY_DAYS=t.ONE_DAY*30,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=t.ONE_WEEK*2,t.THREE_WEEKS=t.ONE_WEEK*3,t.FOUR_WEEKS=t.ONE_WEEK*4,t.ONE_YEAR=t.ONE_DAY*365})(Fs),function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(sr,t),r(Fs,t)}(qn),Object.defineProperty(ir,"__esModule",{value:!0}),ir.fromMiliseconds=ir.toMiliseconds=void 0;const Us=qn;function Bh(t){return t*Us.ONE_THOUSAND}ir.toMiliseconds=Bh;function zh(t){return Math.floor(t/Us.ONE_THOUSAND)}ir.fromMiliseconds=zh,function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Jr,t),r(ir,t)}(Rs);var Er={};Object.defineProperty(Er,"__esModule",{value:!0}),Er.Watch=void 0;class Ms{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 r=this.get(e);if(typeof r.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);const n=Date.now()-r.started;this.timestamps.set(e,{started:r.started,elapsed:n})}get(e){const r=this.timestamps.get(e);if(typeof r>"u")throw new Error(`No timestamp found for label: ${e}`);return r}elapsed(e){const r=this.get(e);return r.elapsed||Date.now()-r.started}}Er.Watch=Ms,Er.default=Ms;var js={},Xr={};Object.defineProperty(Xr,"__esModule",{value:!0}),Xr.IWatch=void 0;class Hh{}Xr.IWatch=Hh,function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Xr,t)}(js),function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Rs,t),r(Er,t),r(js,t),r(qn,t)}(Le);var Se={};Object.defineProperty(Se,"__esModule",{value:!0}),Se.getLocalStorage=Se.getLocalStorageOrThrow=Se.getCrypto=Se.getCryptoOrThrow=Bs=Se.getLocation=Se.getLocationOrThrow=Vn=Se.getNavigator=Se.getNavigatorOrThrow=$s=Se.getDocument=Se.getDocumentOrThrow=Se.getFromWindowOrThrow=Se.getFromWindow=void 0;function Wt(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}Se.getFromWindow=Wt;function or(t){const e=Wt(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}Se.getFromWindowOrThrow=or;function Kh(){return or("document")}Se.getDocumentOrThrow=Kh;function qh(){return Wt("document")}var $s=Se.getDocument=qh;function Vh(){return or("navigator")}Se.getNavigatorOrThrow=Vh;function Gh(){return Wt("navigator")}var Vn=Se.getNavigator=Gh;function Wh(){return or("location")}Se.getLocationOrThrow=Wh;function kh(){return Wt("location")}var Bs=Se.getLocation=kh;function Yh(){return or("crypto")}Se.getCryptoOrThrow=Yh;function Jh(){return Wt("crypto")}Se.getCrypto=Jh;function Xh(){return or("localStorage")}Se.getLocalStorageOrThrow=Xh;function Zh(){return Wt("localStorage")}Se.getLocalStorage=Zh;var Gn={};Object.defineProperty(Gn,"__esModule",{value:!0});var zs=Gn.getWindowMetadata=void 0;const Hs=Se;function Qh(){let t,e;try{t=Hs.getDocumentOrThrow(),e=Hs.getLocationOrThrow()}catch{return null}function r(){const E=t.getElementsByTagName("link"),T=[];for(let w=0;w<E.length;w++){const b=E[w],F=b.getAttribute("rel");if(F&&F.toLowerCase().indexOf("icon")>-1){const y=b.getAttribute("href");if(y)if(y.toLowerCase().indexOf("https:")===-1&&y.toLowerCase().indexOf("http:")===-1&&y.indexOf("//")!==0){let O=e.protocol+"//"+e.host;if(y.indexOf("/")===0)O+=y;else{const N=e.pathname.split("/");N.pop(),O+=N.join("/")+"/"+y}T.push(O)}else if(y.indexOf("//")===0){const O=e.protocol+y;T.push(O)}else T.push(y)}}return T}function n(...E){const T=t.getElementsByTagName("meta");for(let w=0;w<T.length;w++){const b=T[w],F=["itemprop","property","name"].map(y=>b.getAttribute(y)).filter(y=>y?E.includes(y):!1);if(F.length&&F){const y=b.getAttribute("content");if(y)return y}}return""}function i(){let E=n("name","og:site_name","og:title","twitter:title");return E||(E=t.title),E}function s(){return n("description","og:description","twitter:description","keywords")}const c=i(),u=s(),h=e.origin,l=r();return{description:u,url:h,icons:l,name:c}}zs=Gn.getWindowMetadata=Qh;var Dr={},ef=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Ks="%[a-f0-9]{2}",qs=new RegExp(Ks,"gi"),Vs=new RegExp("("+Ks+")+","gi");function Wn(t,e){try{return decodeURIComponent(t.join(""))}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),n=t.slice(e);return Array.prototype.concat.call([],Wn(r),Wn(n))}function tf(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(qs),r=1;r<e.length;r++)t=Wn(e,r).join(""),e=t.match(qs);return t}}function rf(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=Vs.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var n=tf(r[0]);n!==r[0]&&(e[r[0]]=n)}r=Vs.exec(t)}e["%C2"]="\uFFFD";for(var i=Object.keys(e),s=0;s<i.length;s++){var c=i[s];t=t.replace(new RegExp(c,"g"),e[c])}return t}var nf=function(t){if(typeof t!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof t+"`");try{return t=t.replace(/\+/g," "),decodeURIComponent(t)}catch{return rf(t)}},sf=(t,e)=>{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];const r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]};(function(t){const e=ef,r=nf,n=sf,i=y=>y==null;function s(y){switch(y.arrayFormat){case"index":return O=>(N,L)=>{const S=N.length;return L===void 0||y.skipNull&&L===null||y.skipEmptyString&&L===""?N:L===null?[...N,[h(O,y),"[",S,"]"].join("")]:[...N,[h(O,y),"[",h(S,y),"]=",h(L,y)].join("")]};case"bracket":return O=>(N,L)=>L===void 0||y.skipNull&&L===null||y.skipEmptyString&&L===""?N:L===null?[...N,[h(O,y),"[]"].join("")]:[...N,[h(O,y),"[]=",h(L,y)].join("")];case"comma":case"separator":return O=>(N,L)=>L==null||L.length===0?N:N.length===0?[[h(O,y),"=",h(L,y)].join("")]:[[N,h(L,y)].join(y.arrayFormatSeparator)];default:return O=>(N,L)=>L===void 0||y.skipNull&&L===null||y.skipEmptyString&&L===""?N:L===null?[...N,h(O,y)]:[...N,[h(O,y),"=",h(L,y)].join("")]}}function c(y){let O;switch(y.arrayFormat){case"index":return(N,L,S)=>{if(O=/\[(\d*)\]$/.exec(N),N=N.replace(/\[\d*\]$/,""),!O){S[N]=L;return}S[N]===void 0&&(S[N]={}),S[N][O[1]]=L};case"bracket":return(N,L,S)=>{if(O=/(\[\])$/.exec(N),N=N.replace(/\[\]$/,""),!O){S[N]=L;return}if(S[N]===void 0){S[N]=[L];return}S[N]=[].concat(S[N],L)};case"comma":case"separator":return(N,L,S)=>{const m=typeof L=="string"&&L.split("").indexOf(y.arrayFormatSeparator)>-1?L.split(y.arrayFormatSeparator).map(o=>l(o,y)):L===null?L:l(L,y);S[N]=m};default:return(N,L,S)=>{if(S[N]===void 0){S[N]=L;return}S[N]=[].concat(S[N],L)}}}function u(y){if(typeof y!="string"||y.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function h(y,O){return O.encode?O.strict?e(y):encodeURIComponent(y):y}function l(y,O){return O.decode?r(y):y}function p(y){return Array.isArray(y)?y.sort():typeof y=="object"?p(Object.keys(y)).sort((O,N)=>Number(O)-Number(N)).map(O=>y[O]):y}function E(y){const O=y.indexOf("#");return O!==-1&&(y=y.slice(0,O)),y}function T(y){let O="";const N=y.indexOf("#");return N!==-1&&(O=y.slice(N)),O}function w(y){y=E(y);const O=y.indexOf("?");return O===-1?"":y.slice(O+1)}function b(y,O){return O.parseNumbers&&!Number.isNaN(Number(y))&&typeof y=="string"&&y.trim()!==""?y=Number(y):O.parseBooleans&&y!==null&&(y.toLowerCase()==="true"||y.toLowerCase()==="false")&&(y=y.toLowerCase()==="true"),y}function F(y,O){O=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},O),u(O.arrayFormatSeparator);const N=c(O),L=Object.create(null);if(typeof y!="string"||(y=y.trim().replace(/^[?#&]/,""),!y))return L;for(const S of y.split("&")){let[C,m]=n(O.decode?S.replace(/\+/g," "):S,"=");m=m===void 0?null:["comma","separator"].includes(O.arrayFormat)?m:l(m,O),N(l(C,O),m,L)}for(const S of Object.keys(L)){const C=L[S];if(typeof C=="object"&&C!==null)for(const m of Object.keys(C))C[m]=b(C[m],O);else L[S]=b(C,O)}return O.sort===!1?L:(O.sort===!0?Object.keys(L).sort():Object.keys(L).sort(O.sort)).reduce((S,C)=>{const m=L[C];return Boolean(m)&&typeof m=="object"&&!Array.isArray(m)?S[C]=p(m):S[C]=m,S},Object.create(null))}t.extract=w,t.parse=F,t.stringify=(y,O)=>{if(!y)return"";O=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},O),u(O.arrayFormatSeparator);const N=m=>O.skipNull&&i(y[m])||O.skipEmptyString&&y[m]==="",L=s(O),S={};for(const m of Object.keys(y))N(m)||(S[m]=y[m]);const C=Object.keys(S);return O.sort!==!1&&C.sort(O.sort),C.map(m=>{const o=y[m];return o===void 0?"":o===null?h(m,O):Array.isArray(o)?o.reduce(L(m),[]).join("&"):h(m,O)+"="+h(o,O)}).filter(m=>m.length>0).join("&")},t.parseUrl=(y,O)=>{O=Object.assign({decode:!0},O);const[N,L]=n(y,"#");return Object.assign({url:N.split("?")[0]||"",query:F(w(y),O)},O&&O.parseFragmentIdentifier&&L?{fragmentIdentifier:l(L,O)}:{})},t.stringifyUrl=(y,O)=>{O=Object.assign({encode:!0,strict:!0},O);const N=E(y.url).split("?")[0]||"",L=t.extract(y.url),S=t.parse(L,{sort:!1}),C=Object.assign(S,y.query);let m=t.stringify(C,O);m&&(m=`?${m}`);let o=T(y.url);return y.fragmentIdentifier&&(o=`#${h(y.fragmentIdentifier,O)}`),`${N}${m}${o}`}})(Dr);const of={waku:{publish:"waku_publish",subscribe:"waku_subscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe"},irn:{publish:"irn_publish",subscribe:"irn_subscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe"},iridium:{publish:"iridium_publish",subscribe:"iridium_subscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe"}},Gs=":";function af(t){const{namespace:e,reference:r}=t;return[e,r].join(Gs)}function cf(t){const[e,r,n]=t.split(Gs);return{namespace:e,reference:r,address:n}}function uf(t,e){const r=[];return t.forEach(n=>{const i=e(n);r.includes(i)||r.push(i)}),r}function hf(t){const{namespace:e,reference:r}=cf(t);return af({namespace:e,reference:r})}function ff(t){return uf(t,hf)}function kn(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...i.accounts)}),r}function Yn(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...ff(i.accounts))}),r}function lf(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...i.chains)}),r}const Ws="base10",lt="base16",Jn="base64pad",Xn="utf8",ks=0,xr=1,df=0,Ys=1,Zn=12,Qn=32;function pf(){const t=$n.generateKeyPair();return{privateKey:ft(t.secretKey,lt),publicKey:ft(t.publicKey,lt)}}function ei(){const t=nr.randomBytes(Qn);return ft(t,lt)}function gf(t,e){const r=$n.sharedKey(ht(t,lt),ht(e,lt)),n=new Jc(kr.SHA256,r).expand(Qn);return ft(n,lt)}function vf(t){const e=kr.hash(ht(t,lt));return ft(e,lt)}function Zr(t){const e=kr.hash(ht(t,Xn));return ft(e,lt)}function yf(t){return ht(`${t}`,Ws)}function Qr(t){return Number(ft(t,Ws))}function _f(t){const e=yf(typeof t.type<"u"?t.type:ks);if(Qr(e)===xr&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?ht(t.senderPublicKey,lt):void 0,n=typeof t.iv<"u"?ht(t.iv,lt):nr.randomBytes(Zn),i=new Ln.ChaCha20Poly1305(ht(t.symKey,lt)).seal(n,ht(t.message,Xn));return mf({type:e,sealed:i,iv:n,senderPublicKey:r})}function bf(t){const e=new Ln.ChaCha20Poly1305(ht(t.symKey,lt)),{sealed:r,iv:n}=Js(t.encoded),i=e.open(n,r);if(i===null)throw new Error("Failed to decrypt");return ft(i,Xn)}function mf(t){if(Qr(t.type)===xr){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return ft(Bn([t.type,t.senderPublicKey,t.iv,t.sealed]),Jn)}return ft(Bn([t.type,t.iv,t.sealed]),Jn)}function Js(t){const e=ht(t,Jn),r=e.slice(df,Ys),n=Ys;if(Qr(r)===xr){const u=n+Qn,h=u+Zn,l=e.slice(n,u),p=e.slice(u,h),E=e.slice(h);return{type:r,sealed:E,iv:p,senderPublicKey:l}}const i=n+Zn,s=e.slice(n,i),c=e.slice(i);return{type:r,sealed:c,iv:s}}function wf(t,e){const r=Js(t);return Xs({type:Qr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?ft(r.senderPublicKey,lt):void 0,receiverPublicKey:e?.receiverPublicKey})}function Xs(t){const e=t?.type||ks;if(e===xr){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function Zs(t){return t.type===xr&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}var Ef=Object.defineProperty,Qs=Object.getOwnPropertySymbols,Df=Object.prototype.hasOwnProperty,xf=Object.prototype.propertyIsEnumerable,eo=(t,e,r)=>e in t?Ef(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,to=(t,e)=>{for(var r in e||(e={}))Df.call(e,r)&&eo(t,r,e[r]);if(Qs)for(var r of Qs(e))xf.call(e,r)&&eo(t,r,e[r]);return t};const Sf="ReactNative",Sr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Of="js";function ro(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Af(){return!$s()&&!!Vn()&&navigator.product===Sf}function If(){return!ro()&&!!Vn()}function Lf(){return Af()?Sr.reactNative:ro()?Sr.node:If()?Sr.browser:Sr.unknown}function Cf(t,e){let r=Dr.parse(t);return r=to(to({},r),e),t=Dr.stringify(r),t}function Tf(){return zs()||{name:"",description:"",url:"",icons:[""]}}function Nf(){const t=Rh();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function Pf(){var t;const e=Lf();return e===Sr.browser?[e,((t=Bs())==null?void 0:t.host)||"unknown"].join(":"):e}function Rf(t,e,r){const n=Nf(),i=Pf();return[[t,e].join("-"),[Of,r].join("-"),n,i].join("/")}function Ff({protocol:t,version:e,relayUrl:r,sdkVersion:n,auth:i,projectId:s}){const c=r.split("?"),u=Rf(t,e,n),h={auth:i,ua:u,projectId:s},l=Cf(c[1]||"",h);return c[0]+"?"+l}function dt(t,e){return t.filter(r=>e.includes(r)).length===t.length}function no(t){return Object.fromEntries(t.entries())}function io(t){return new Map(Object.entries(t))}function ar(t,e){return Le.fromMiliseconds((e||Date.now())+Le.toMiliseconds(t))}function kt(t){return Le.fromMiliseconds(Date.now())>=Le.toMiliseconds(t)}function Yt(){const t=Le.toMiliseconds(Le.FIVE_MINUTES);let e,r,n;return{resolve:i=>{n&&e&&(clearTimeout(n),e(i))},reject:i=>{n&&r&&(clearTimeout(n),r(i))},done:()=>new Promise((i,s)=>{n=setTimeout(s,t),e=i,r=s})}}function so(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function Uf(t){return so("topic",t)}function Mf(t){return so("id",t)}function jf(t){const[e,r]=t.split(":"),n={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")n.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))n.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return n}function Fe(t,e){return`${t}${e?`:${e}`:""}`}const $f="irn";function ti(t){return t?.relay||{protocol:$f}}function ri(t){const e=of[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var Bf=Object.defineProperty,oo=Object.getOwnPropertySymbols,zf=Object.prototype.hasOwnProperty,Hf=Object.prototype.propertyIsEnumerable,ao=(t,e,r)=>e in t?Bf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Kf=(t,e)=>{for(var r in e||(e={}))zf.call(e,r)&&ao(t,r,e[r]);if(oo)for(var r of oo(e))Hf.call(e,r)&&ao(t,r,e[r]);return t};function qf(t,e="-"){const r={},n="relay"+e;return Object.keys(t).forEach(i=>{if(i.startsWith(n)){const s=i.replace(n,""),c=t[i];r[s]=c}}),r}function Vf(t){const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,n=t.substring(0,e),i=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",c=Dr.parse(s);return{protocol:n,topic:i[0],version:parseInt(i[1],10),symKey:c.symKey,relay:qf(c)}}function Gf(t,e="-"){const r="relay",n={};return Object.keys(t).forEach(i=>{const s=r+e+i;t[i]&&(n[s]=t[i])}),n}function Wf(t){return`${t.protocol}:${t.topic}@${t.version}?`+Dr.stringify(Kf({symKey:t.symKey},Gf(t.relay)))}function At(t){const e=[];return t.forEach(r=>{const[n,i]=r.split(":");e.push(`${n}:${i}`)}),e}function kf(t){const e=[];return Object.values(t).forEach(r=>{e.push(...At(r.accounts)),r.extension&&r.extension.forEach(n=>{e.push(...At(n.accounts))})}),e}function Yf(t,e){const r=[];return Object.values(t).forEach(n=>{At(n.accounts).includes(e)&&r.push(...n.methods),n.extension&&n.extension.forEach(i=>{At(i.accounts).includes(e)&&r.push(...i.methods)})}),r}function Jf(t,e){const r=[];return Object.values(t).forEach(n=>{At(n.accounts).includes(e)&&r.push(...n.events),n.extension&&n.extension.forEach(i=>{At(i.accounts).includes(e)&&r.push(...i.events)})}),r}const Xf={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3}},Zf={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function G(t,e){const{message:r,code:n}=Zf[t];return{message:e?`${r} ${e}`:r,code:n}}function rt(t,e){const{message:r,code:n}=Xf[t];return{message:e?`${r} ${e}`:r,code:n}}function Or(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function co(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Et(t){return typeof t>"u"}function ot(t,e){return e&&Et(t)?!0:typeof t=="string"&&Boolean(t.trim().length)}function uo(t,e){return e&&Et(t)?!0:typeof t=="number"&&!isNaN(t)}function Qf(t,e){const{requiredNamespaces:r}=e,n=Object.keys(t.namespaces),i=Object.keys(r);let s=!0;return dt(i,n)?(n.forEach(c=>{const{accounts:u,methods:h,events:l,extension:p}=t.namespaces[c],E=At(u),T=r[c];(!dt(T.chains,E)||!dt(T.methods,h)||!dt(T.events,l))&&(s=!1),s&&p&&p.forEach(w=>{var b;const{accounts:F,methods:y,events:O}=w,N=At(F);(b=T.extension)!=null&&b.find(L=>dt(L.chains,N)&&dt(L.methods,y)&&dt(L.events,O))||(s=!1)})}),s):!1}function ni(t){return ot(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function el(t){if(ot(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&ni(r)}}return!1}function tl(t){if(ot(t,!1))try{return typeof new URL(t)<"u"}catch{return!1}return!1}function rl(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function nl(t){return t?.topic}function il(t,e){let r=null;return ot(t?.publicKey,!1)||(r=G("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function ii(t,e){let r=null;return Et(t?.extension)||(!Or(t.extension)||!t.extension.length)&&(r=G("MISSING_OR_INVALID",`${e} extension should be an array of namespaces, or omitted`)),r}function ho(t){let e=!0;return Or(t)?t.length&&(e=t.every(r=>ot(r,!1))):e=!1,e}function fo(t,e,r){let n=null;return Or(e)?e.forEach(i=>{n||(!ni(i)||!i.includes(t))&&(n=rt("UNSUPPORTED_CHAINS",`${r}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):n=rt("UNSUPPORTED_CHAINS",`${r}, chains ${e} should be an array of strings conforming to "namespace:chainId" format`),n}function sl(t,e){let r=null;return Object.entries(t).forEach(([n,i])=>{if(r)return;const s=fo(n,i?.chains,`${e} requiredNamespace`),c=ii(i,e);s?r=s:c?r=c:i.extension&&i.extension.forEach(u=>{if(r)return;const h=fo(n,u.chains,`${e} extension`);h&&(r=h)})}),r}function lo(t,e){let r=null;return Or(t)?t.forEach(n=>{r||el(n)||(r=rt("UNSUPPORTED_ACCOUNTS",`${e}, account ${n} should be a string and conform to "namespace:chainId:address" format`))}):r=rt("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function ol(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=lo(n?.accounts,`${e} namespace`),s=ii(n,e);i?r=i:s?r=s:n.extension&&n.extension.forEach(c=>{if(r)return;const u=lo(c.accounts,`${e} extension`);u&&(r=u)})}),r}function po(t,e){let r=null;return ho(t?.methods)?ho(t?.events)||(r=rt("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=rt("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function go(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=po(n,`${e}, namespace`),s=ii(n,e);i?r=i:s?r=s:n.extension&&n.extension.forEach(c=>{if(r)return;const u=po(c,`${e}, extension`);u&&(r=u)})}),r}function al(t,e){let r=null;if(t&&co(t)){const n=go(t,e);n&&(r=n);const i=sl(t,e);i&&(r=i)}else r=G("MISSING_OR_INVALID",`${e}, requiredNamespaces should be an object with data`);return r}function si(t,e){let r=null;if(t&&co(t)){const n=go(t,e);n&&(r=n);const i=ol(t,e);i&&(r=i)}else r=G("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function vo(t){return ot(t.protocol,!0)}function cl(t,e){let r=!1;return e&&!t?r=!0:t&&Or(t)&&t.length&&t.forEach(n=>{r=vo(n)}),r}function ul(t){return typeof t=="number"}function yt(t){return typeof t<"u"&&typeof t!==null}function hl(t){return!(!t||typeof t!="object"||!t.code||!uo(t.code,!1)||!t.message||!ot(t.message,!1))}function fl(t){return!(Et(t)||!ot(t.method,!1))}function ll(t){return!(Et(t)||Et(t.result)&&Et(t.error)||!uo(t.id,!1)||!ot(t.jsonrpc,!1))}function dl(t){return!(Et(t)||!ot(t.name,!1))}function yo(t,e){return!(!ni(e)||!kf(t).includes(e))}function pl(t,e,r){return ot(r,!1)?Yf(t,e).includes(r):!1}function gl(t,e,r){return ot(r,!1)?Jf(t,e).includes(r):!1}function _o(t,e,r){let n=null;const i=Object.keys(t),s=Object.keys(e);return dt(i,s)?i.forEach(c=>{var u;if(n)return;const h=t[c].chains,l=At(e[c].accounts);dt(h,l)?dt(t[c].methods,e[c].methods)?dt(t[c].events,e[c].events)?t[c].extension&&!e[c].extension?n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${c}`):t[c].extension&&e[c].extension&&((u=t[c].extension)==null||u.forEach(({methods:p,events:E,chains:T})=>{var w;n||(w=e[c].extension)!=null&&w.find(b=>{const F=At(b.accounts);return dt(T,F)&&dt(E,b.events)&&dt(p,b.methods)})||(n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${c}`))})):n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy requiredNamespaces events for ${c}`):n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy requiredNamespaces methods for ${c}`):n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy requiredNamespaces chains for ${c}`)}):n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces`),n}function vl(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var yl=_l;function _l(t,e,r){var n=r&&r.stringify||vl,i=1;if(typeof t=="object"&&t!==null){var s=e.length+i;if(s===1)return t;var c=new Array(s);c[0]=n(t);for(var u=1;u<s;u++)c[u]=n(e[u]);return c.join(" ")}if(typeof t!="string")return t;var h=e.length;if(h===0)return t;for(var l="",p=1-i,E=-1,T=t&&t.length||0,w=0;w<T;){if(t.charCodeAt(w)===37&&w+1<T){switch(E=E>-1?E:0,t.charCodeAt(w+1)){case 100:case 102:if(p>=h||e[p]==null)break;E<w&&(l+=t.slice(E,w)),l+=Number(e[p]),E=w+2,w++;break;case 105:if(p>=h||e[p]==null)break;E<w&&(l+=t.slice(E,w)),l+=Math.floor(Number(e[p])),E=w+2,w++;break;case 79:case 111:case 106:if(p>=h||e[p]===void 0)break;E<w&&(l+=t.slice(E,w));var b=typeof e[p];if(b==="string"){l+="'"+e[p]+"'",E=w+2,w++;break}if(b==="function"){l+=e[p].name||"<anonymous>",E=w+2,w++;break}l+=n(e[p]),E=w+2,w++;break;case 115:if(p>=h)break;E<w&&(l+=t.slice(E,w)),l+=String(e[p]),E=w+2,w++;break;case 37:E<w&&(l+=t.slice(E,w)),l+="%",E=w+2,w++,p--;break}++p}++w}return E===-1?t:(E<T&&(l+=t.slice(E)),l)}var bo=yl,oi=It,Ar=Al().console||{},bl={mapHttpRequest:tn,mapHttpResponse:tn,wrapRequestSerializer:ci,wrapResponseSerializer:ci,wrapErrorSerializer:ci,req:tn,res:tn,err:Dl};function It(t){t=t||{},t.browser=t.browser||{};var e=t.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");var r=t.browser.write||Ar;t.browser.write&&(t.browser.asObject=!0);var n=t.serializers||{},i=Array.isArray(t.browser.serialize)?t.browser.serialize.filter(function(b){return b!=="!stdSerializers.err"}):t.browser.serialize===!0?Object.keys(n):!1,s=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);var c=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),t.enabled===!1&&(t.level="silent");var u=t.level||"info",h=Object.create(r);h.log||(h.log=Ir),Object.defineProperty(h,"levelVal",{get:p}),Object.defineProperty(h,"level",{get:E,set:T});var l={transmit:e,serialize:i,asObject:t.browser.asObject,levels:c,timestamp:xl(t)};h.levels=It.levels,h.level=u,h.setMaxListeners=h.getMaxListeners=h.emit=h.addListener=h.on=h.prependListener=h.once=h.prependOnceListener=h.removeListener=h.removeAllListeners=h.listeners=h.listenerCount=h.eventNames=h.write=h.flush=Ir,h.serializers=n,h._serialize=i,h._stdErrSerialize=s,h.child=w,e&&(h._logEvent=ai());function p(){return this.level==="silent"?1/0:this.levels.values[this.level]}function E(){return this._level}function T(b){if(b!=="silent"&&!this.levels.values[b])throw Error("unknown level "+b);this._level=b,cr(l,h,"error","log"),cr(l,h,"fatal","error"),cr(l,h,"warn","error"),cr(l,h,"info","log"),cr(l,h,"debug","log"),cr(l,h,"trace","log")}function w(b){if(!b)throw new Error("missing bindings for child Pino");var F=b.serializers;if(i&&F){var y=Object.assign({},n,F),O=t.browser.serialize===!0?Object.keys(y):i;delete b.serializers,en([b],O,y,this._stdErrSerialize)}function N(L){this._childLevel=(L._childLevel|0)+1,this.error=ur(L,b,"error"),this.fatal=ur(L,b,"fatal"),this.warn=ur(L,b,"warn"),this.info=ur(L,b,"info"),this.debug=ur(L,b,"debug"),this.trace=ur(L,b,"trace"),y&&(this.serializers=y,this._serialize=O),e&&(this._logEvent=ai([].concat(L._logEvent.bindings,b)))}return N.prototype=this,new N(this)}return h}It.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},It.stdSerializers=bl,It.stdTimeFunctions=Object.assign({},{nullTime:mo,epochTime:wo,unixTime:Sl,isoTime:Ol});function cr(t,e,r,n){var i=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?Ir:i[r]?i[r]:Ar[r]||Ar[n]||Ir,ml(t,e,r)}function ml(t,e,r){!t.transmit&&e[r]===Ir||(e[r]=function(n){return function(){for(var s=t.timestamp(),c=new Array(arguments.length),u=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Ar?Ar:this,h=0;h<c.length;h++)c[h]=arguments[h];if(t.serialize&&!t.asObject&&en(c,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?n.call(u,wl(this,r,c,s)):n.apply(u,c),t.transmit){var l=t.transmit.level||e.level,p=It.levels.values[l],E=It.levels.values[r];if(E<p)return;El(this,{ts:s,methodLevel:r,methodValue:E,transmitLevel:l,transmitValue:It.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},c)}}}(e[r]))}function wl(t,e,r,n){t._serialize&&en(r,t._serialize,t.serializers,t._stdErrSerialize);var i=r.slice(),s=i[0],c={};n&&(c.time=n),c.level=It.levels.values[e];var u=(t._childLevel|0)+1;if(u<1&&(u=1),s!==null&&typeof s=="object"){for(;u--&&typeof i[0]=="object";)Object.assign(c,i.shift());s=i.length?bo(i.shift(),i):void 0}else typeof s=="string"&&(s=bo(i.shift(),i));return s!==void 0&&(c.msg=s),c}function en(t,e,r,n){for(var i in t)if(n&&t[i]instanceof Error)t[i]=It.stdSerializers.err(t[i]);else if(typeof t[i]=="object"&&!Array.isArray(t[i]))for(var s in t[i])e&&e.indexOf(s)>-1&&s in r&&(t[i][s]=r[s](t[i][s]))}function ur(t,e,r){return function(){var n=new Array(1+arguments.length);n[0]=e;for(var i=1;i<n.length;i++)n[i]=arguments[i-1];return t[r].apply(this,n)}}function El(t,e,r){var n=e.send,i=e.ts,s=e.methodLevel,c=e.methodValue,u=e.val,h=t._logEvent.bindings;en(r,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=i,t._logEvent.messages=r.filter(function(l){return h.indexOf(l)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=c,n(s,t._logEvent,u),t._logEvent=ai(h)}function ai(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function Dl(t){var e={type:t.constructor.name,msg:t.message,stack:t.stack};for(var r in t)e[r]===void 0&&(e[r]=t[r]);return e}function xl(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?mo:wo}function tn(){return{}}function ci(t){return t}function Ir(){}function mo(){return!1}function wo(){return Date.now()}function Sl(){return Math.round(Date.now()/1e3)}function Ol(){return new Date(Date.now()).toISOString()}function Al(){function t(e){return typeof e<"u"&&e}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return t(self)||t(window)||t(this)||{}}}var rn={},ui=function(t,e){return ui=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])},ui(t,e)};function Il(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ui(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var hi=function(){return hi=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},hi.apply(this,arguments)};function Ll(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function Cl(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var u=t.length-1;u>=0;u--)(c=t[u])&&(s=(i<3?c(s):i>3?c(e,r,s):c(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function Tl(t,e){return function(r,n){e(r,n,t)}}function Nl(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Pl(t,e,r,n){function i(s){return s instanceof r?s:new r(function(c){c(s)})}return new(r||(r=Promise))(function(s,c){function u(p){try{l(n.next(p))}catch(E){c(E)}}function h(p){try{l(n.throw(p))}catch(E){c(E)}}function l(p){p.done?s(p.value):i(p.value).then(u,h)}l((n=n.apply(t,e||[])).next())})}function Rl(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,c;return c={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function u(l){return function(p){return h([l,p])}}function h(l){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=l[0]&2?i.return:l[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,l[1])).done)return s;switch(i=0,s&&(l=[l[0]&2,s.value]),l[0]){case 0:case 1:s=l;break;case 4:return r.label++,{value:l[1],done:!1};case 5:r.label++,i=l[1],l=[0];continue;case 7:l=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!s||l[1]>s[0]&&l[1]<s[3])){r.label=l[1];break}if(l[0]===6&&r.label<s[1]){r.label=s[1],s=l;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(l);break}s[2]&&r.ops.pop(),r.trys.pop();continue}l=e.call(t,r)}catch(p){l=[6,p],i=0}finally{n=s=0}if(l[0]&5)throw l[1];return{value:l[0]?l[1]:void 0,done:!0}}}var fi=Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]};function Fl(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&fi(e,t,r)}function li(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Eo(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],c;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(u){c={error:u}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(c)throw c.error}}return s}function Ul(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Eo(arguments[e]));return t}function Ml(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],c=0,u=s.length;c<u;c++,i++)n[i]=s[c];return n}function jl(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))}function Lr(t){return this instanceof Lr?(this.v=t,this):new Lr(t)}function $l(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},c("next"),c("throw"),c("return"),i[Symbol.asyncIterator]=function(){return this},i;function c(T){n[T]&&(i[T]=function(w){return new Promise(function(b,F){s.push([T,w,b,F])>1||u(T,w)})})}function u(T,w){try{h(n[T](w))}catch(b){E(s[0][3],b)}}function h(T){T.value instanceof Lr?Promise.resolve(T.value.v).then(l,p):E(s[0][2],T)}function l(T){u("next",T)}function p(T){u("throw",T)}function E(T,w){T(w),s.shift(),s.length&&u(s[0][0],s[0][1])}}function Bl(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(c){return(r=!r)?{value:Lr(t[i](c)),done:i==="return"}:s?s(c):c}:s}}function zl(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof li=="function"?li(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(c){return new Promise(function(u,h){c=t[s](c),i(u,h,c.done,c.value)})}}function i(s,c,u,h){Promise.resolve(h).then(function(l){s({value:l,done:u})},c)}}function Hl(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}var Kl=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e};function ql(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&fi(e,t,r);return Kl(e,t),e}function Vl(t){return t&&t.__esModule?t:{default:t}}function Gl(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)}function Wl(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r}function kl(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}var Yl=Object.freeze({__proto__:null,__extends:Il,get __assign(){return hi},__rest:Ll,__decorate:Cl,__param:Tl,__metadata:Nl,__awaiter:Pl,__generator:Rl,__createBinding:fi,__exportStar:Fl,__values:li,__read:Eo,__spread:Ul,__spreadArrays:Ml,__spreadArray:jl,__await:Lr,__asyncGenerator:$l,__asyncDelegator:Bl,__asyncValues:zl,__makeTemplateObject:Hl,__importStar:ql,__importDefault:Vl,__classPrivateFieldGet:Gl,__classPrivateFieldSet:Wl,__classPrivateFieldIn:kl}),di=wn(Yl),nn={exports:{}},Do;function Jl(){return Do||(Do=1,function(){var t;function e(){}t=e,t.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},t.prototype.setItem=function(r,n){this[r]=String(n)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){var r=this;Object.keys(r).forEach(function(n){r[n]=void 0,delete r[n]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),Z.localStorage?nn.exports=localStorage:nn.exports=new e}()),nn.exports}var Cr={},xo;function So(){if(xo)return Cr;xo=1,Object.defineProperty(Cr,"__esModule",{value:!0});function t(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return JSON.parse(r)}catch{return r}}Cr.safeJsonParse=t;function e(r){return typeof r=="string"?r:JSON.stringify(r,(n,i)=>typeof i>"u"?null:i)}return Cr.safeJsonStringify=e,Cr}var pi={},Tr={},Oo;function Xl(){if(Oo)return Tr;Oo=1,Object.defineProperty(Tr,"__esModule",{value:!0}),Tr.IKeyValueStorage=void 0;class t{}return Tr.IKeyValueStorage=t,Tr}var Nr={},Ao;function Zl(){if(Ao)return Nr;Ao=1,Object.defineProperty(Nr,"__esModule",{value:!0}),Nr.parseEntry=void 0;const t=So();function e(r){var n;return[r[0],t.safeJsonParse((n=r[1])!==null&&n!==void 0?n:"")]}return Nr.parseEntry=e,Nr}var Io;function Ql(){return Io||(Io=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=di;e.__exportStar(Xl(),t),e.__exportStar(Zl(),t)}(pi)),pi}Object.defineProperty(rn,"__esModule",{value:!0}),rn.KeyValueStorage=void 0;const hr=di,ed=hr.__importDefault(Jl()),Lo=So(),td=Ql();class Co{constructor(){this.localStorage=ed.default}getKeys(){return hr.__awaiter(this,void 0,void 0,function*(){return Object.keys(this.localStorage)})}getEntries(){return hr.__awaiter(this,void 0,void 0,function*(){return Object.entries(this.localStorage).map(td.parseEntry)})}getItem(e){return hr.__awaiter(this,void 0,void 0,function*(){const r=this.localStorage.getItem(e);if(r!==null)return Lo.safeJsonParse(r)})}setItem(e,r){return hr.__awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(e,Lo.safeJsonStringify(r))})}removeItem(e){return hr.__awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}}rn.KeyValueStorage=Co;var rd=rn.default=Co,Pr={},sn={},gi={},on={};class Jt{}var nd=Object.freeze({__proto__:null,IEvents:Jt}),id=wn(nd);Object.defineProperty(on,"__esModule",{value:!0}),on.IHeartBeat=void 0;const sd=id;class od extends sd.IEvents{constructor(e){super()}}on.IHeartBeat=od,function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(on,t)}(gi);var vi={},fr={};Object.defineProperty(fr,"__esModule",{value:!0}),fr.HEARTBEAT_EVENTS=fr.HEARTBEAT_INTERVAL=void 0;const ad=Le;fr.HEARTBEAT_INTERVAL=ad.FIVE_SECONDS,fr.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(fr,t)}(vi);var yi=Z&&Z.__awaiter||function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(c){c(s)})}return new(r||(r=Promise))(function(s,c){function u(p){try{l(n.next(p))}catch(E){c(E)}}function h(p){try{l(n.throw(p))}catch(E){c(E)}}function l(p){p.done?s(p.value):i(p.value).then(u,h)}l((n=n.apply(t,e||[])).next())})};Object.defineProperty(sn,"__esModule",{value:!0}),sn.HeartBeat=void 0;const cd=vr,ud=Le,hd=gi,_i=vi;class bi extends hd.IHeartBeat{constructor(e){super(e),this.events=new cd.EventEmitter,this.interval=_i.HEARTBEAT_INTERVAL,this.interval=e?.interval||_i.HEARTBEAT_INTERVAL}static init(e){return yi(this,void 0,void 0,function*(){const r=new bi(e);return yield r.init(),r})}init(){return yi(this,void 0,void 0,function*(){yield this.initialize()})}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}initialize(){return yi(this,void 0,void 0,function*(){setInterval(()=>this.pulse(),ud.toMiliseconds(this.interval))})}pulse(){this.events.emit(_i.HEARTBEAT_EVENTS.pulse)}}sn.HeartBeat=bi,function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(sn,t),r(gi,t),r(vi,t)}(Pr);var Oe={},Xt={},To;function No(){return To||(To=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.PINO_CUSTOM_CONTEXT_KEY=Xt.PINO_LOGGER_DEFAULTS=void 0,Xt.PINO_LOGGER_DEFAULTS={level:"info"},Xt.PINO_CUSTOM_CONTEXT_KEY="custom_context"),Xt}var ct={},Po;function fd(){if(Po)return ct;Po=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.generateChildLogger=ct.formatChildLoggerContext=ct.getLoggerContext=ct.setBrowserLoggerContext=ct.getBrowserLoggerContext=ct.getDefaultLoggerOptions=void 0;const t=No();function e(u){return Object.assign(Object.assign({},u),{level:u?.level||t.PINO_LOGGER_DEFAULTS.level})}ct.getDefaultLoggerOptions=e;function r(u,h=t.PINO_CUSTOM_CONTEXT_KEY){return u[h]||""}ct.getBrowserLoggerContext=r;function n(u,h,l=t.PINO_CUSTOM_CONTEXT_KEY){return u[l]=h,u}ct.setBrowserLoggerContext=n;function i(u,h=t.PINO_CUSTOM_CONTEXT_KEY){let l="";return typeof u.bindings>"u"?l=r(u,h):l=u.bindings().context||"",l}ct.getLoggerContext=i;function s(u,h,l=t.PINO_CUSTOM_CONTEXT_KEY){const p=i(u,l);return p.trim()?`${p}/${h}`:h}ct.formatChildLoggerContext=s;function c(u,h,l=t.PINO_CUSTOM_CONTEXT_KEY){const p=s(u,h,l),E=u.child({context:p});return n(E,p,l)}return ct.generateChildLogger=c,ct}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=di;e.__exportStar(No(),t),e.__exportStar(fd(),t)})(Oe);class ld extends Jt{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class dd extends Jt{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class pd{constructor(e,r){this.logger=e,this.core=r}}class gd extends Jt{constructor(e,r){super(),this.relayer=e,this.logger=r}}class vd extends Jt{constructor(e){super()}}class yd{constructor(e,r,n,i){this.core=e,this.logger=r,this.name=n}}class _d extends Jt{constructor(e,r){super(),this.relayer=e,this.logger=r}}function qe(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var bd=qe;qe.EventEmitter=qe,qe.prototype._events=void 0,qe.prototype._maxListeners=void 0,qe.defaultMaxListeners=10,qe.prototype.setMaxListeners=function(t){if(!md(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},qe.prototype.emit=function(t){var e,r,n,i,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Rr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],Ro(r))return!1;if(Rt(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(Rr(r))for(i=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,s=0;s<n;s++)c[s].apply(this,i);return!0},qe.prototype.addListener=function(t,e){var r;if(!Rt(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Rt(e.listener)?e.listener:e),this._events[t]?Rr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Rr(this._events[t])&&!this._events[t].warned&&(Ro(this._maxListeners)?r=qe.defaultMaxListeners:r=this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),typeof console.trace=="function"&&console.trace())),this},qe.prototype.on=qe.prototype.addListener,qe.prototype.once=function(t,e){if(!Rt(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},qe.prototype.removeListener=function(t,e){var r,n,i,s;if(!Rt(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],i=r.length,n=-1,r===e||Rt(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(Rr(r)){for(s=i;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(n<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},qe.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[t]&&delete this._events[t],this;if(arguments.length===0){for(e in this._events)e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],Rt(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},qe.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Rt(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},qe.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Rt(e))return 1;if(e)return e.length}return 0},qe.listenerCount=function(t,e){return t.listenerCount(e)};function Rt(t){return typeof t=="function"}function md(t){return typeof t=="number"}function Rr(t){return typeof t=="object"&&t!==null}function Ro(t){return t===void 0}class wd{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class O0 extends bd.EventEmitter{constructor(){super()}}class Ed{constructor(e){this.client=e}}class Dd extends Jt{constructor(e,r){super(),this.core=e,this.logger=r}}var mi={},Fo={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=pt;t.DIGEST_LENGTH=64,t.BLOCK_SIZE=128;var n=function(){function u(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return u.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},u.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},u.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},u.prototype.update=function(h,l){if(l===void 0&&(l=h.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var p=0;if(this._bytesHashed+=l,this._bufferLength>0){for(;this._bufferLength<t.BLOCK_SIZE&&l>0;)this._buffer[this._bufferLength++]=h[p++],l--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(l>=this.blockSize&&(p=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,h,p,l),l%=this.blockSize);l>0;)this._buffer[this._bufferLength++]=h[p++],l--;return this},u.prototype.finish=function(h){if(!this._finished){var l=this._bytesHashed,p=this._bufferLength,E=l/536870912|0,T=l<<3,w=l%128<112?128:256;this._buffer[p]=128;for(var b=p+1;b<w-8;b++)this._buffer[b]=0;e.writeUint32BE(E,this._buffer,w-8),e.writeUint32BE(T,this._buffer,w-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,w),this._finished=!0}for(var b=0;b<this.digestLength/8;b++)e.writeUint32BE(this._stateHi[b],h,b*8),e.writeUint32BE(this._stateLo[b],h,b*8+4);return this},u.prototype.digest=function(){var h=new Uint8Array(this.digestLength);return this.finish(h),h},u.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},u.prototype.restoreState=function(h){return this._stateHi.set(h.stateHi),this._stateLo.set(h.stateLo),this._bufferLength=h.bufferLength,h.buffer&&this._buffer.set(h.buffer),this._bytesHashed=h.bytesHashed,this._finished=!1,this},u.prototype.cleanSavedState=function(h){r.wipe(h.stateHi),r.wipe(h.stateLo),h.buffer&&r.wipe(h.buffer),h.bufferLength=0,h.bytesHashed=0},u}();t.SHA512=n;var i=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function s(u,h,l,p,E,T,w){for(var b=l[0],F=l[1],y=l[2],O=l[3],N=l[4],L=l[5],S=l[6],C=l[7],m=p[0],o=p[1],g=p[2],B=p[3],q=p[4],V=p[5],J=p[6],X=p[7],f,_,M,K,R,P,j,$;w>=128;){for(var Q=0;Q<16;Q++){var H=8*Q+T;u[Q]=e.readUint32BE(E,H),h[Q]=e.readUint32BE(E,H+4)}for(var Q=0;Q<80;Q++){var ee=b,k=F,ae=y,I=O,A=N,D=L,a=S,v=C,z=m,Y=o,fe=g,ye=B,de=q,me=V,Ue=J,Te=X;if(f=C,_=X,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=(N>>>14|q<<32-14)^(N>>>18|q<<32-18)^(q>>>41-32|N<<32-(41-32)),_=(q>>>14|N<<32-14)^(q>>>18|N<<32-18)^(N>>>41-32|q<<32-(41-32)),R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,f=N&L^~N&S,_=q&V^~q&J,R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,f=i[Q*2],_=i[Q*2+1],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,f=u[Q%16],_=h[Q%16],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,M=j&65535|$<<16,K=R&65535|P<<16,f=M,_=K,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=(b>>>28|m<<32-28)^(m>>>34-32|b<<32-(34-32))^(m>>>39-32|b<<32-(39-32)),_=(m>>>28|b<<32-28)^(b>>>34-32|m<<32-(34-32))^(b>>>39-32|m<<32-(39-32)),R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,f=b&F^b&y^F&y,_=m&o^m&g^o&g,R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,v=j&65535|$<<16,Te=R&65535|P<<16,f=I,_=ye,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=M,_=K,R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,I=j&65535|$<<16,ye=R&65535|P<<16,F=ee,y=k,O=ae,N=I,L=A,S=D,C=a,b=v,o=z,g=Y,B=fe,q=ye,V=de,J=me,X=Ue,m=Te,Q%16===15)for(var H=0;H<16;H++)f=u[H],_=h[H],R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=u[(H+9)%16],_=h[(H+9)%16],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,M=u[(H+1)%16],K=h[(H+1)%16],f=(M>>>1|K<<32-1)^(M>>>8|K<<32-8)^M>>>7,_=(K>>>1|M<<32-1)^(K>>>8|M<<32-8)^(K>>>7|M<<32-7),R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,M=u[(H+14)%16],K=h[(H+14)%16],f=(M>>>19|K<<32-19)^(K>>>61-32|M<<32-(61-32))^M>>>6,_=(K>>>19|M<<32-19)^(M>>>61-32|K<<32-(61-32))^(K>>>6|M<<32-6),R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,u[H]=j&65535|$<<16,h[H]=R&65535|P<<16}f=b,_=m,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=l[0],_=p[0],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,l[0]=b=j&65535|$<<16,p[0]=m=R&65535|P<<16,f=F,_=o,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=l[1],_=p[1],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,l[1]=F=j&65535|$<<16,p[1]=o=R&65535|P<<16,f=y,_=g,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=l[2],_=p[2],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,l[2]=y=j&65535|$<<16,p[2]=g=R&65535|P<<16,f=O,_=B,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=l[3],_=p[3],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,l[3]=O=j&65535|$<<16,p[3]=B=R&65535|P<<16,f=N,_=q,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=l[4],_=p[4],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,l[4]=N=j&65535|$<<16,p[4]=q=R&65535|P<<16,f=L,_=V,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=l[5],_=p[5],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,l[5]=L=j&65535|$<<16,p[5]=V=R&65535|P<<16,f=S,_=J,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=l[6],_=p[6],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,l[6]=S=j&65535|$<<16,p[6]=J=R&65535|P<<16,f=C,_=X,R=_&65535,P=_>>>16,j=f&65535,$=f>>>16,f=l[7],_=p[7],R+=_&65535,P+=_>>>16,j+=f&65535,$+=f>>>16,P+=R>>>16,j+=P>>>16,$+=j>>>16,l[7]=C=j&65535|$<<16,p[7]=X=R&65535|P<<16,T+=128,w-=128}return T}function c(u){var h=new n;h.update(u);var l=h.digest();return h.clean(),l}t.hash=c})(Fo),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=nr,r=Fo,n=pt;t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function i(I){var A=new Float64Array(16);if(I)for(var D=0;D<I.length;D++)A[D]=I[D];return A}var s=new Uint8Array(32);s[0]=9;var c=i(),u=i([1]),h=i([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),l=i([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),p=i([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),E=i([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),T=i([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function w(I,A){for(var D=0;D<16;D++)I[D]=A[D]|0}function b(I){for(var A=1,D=0;D<16;D++){var a=I[D]+A+65535;A=Math.floor(a/65536),I[D]=a-A*65536}I[0]+=A-1+37*(A-1)}function F(I,A,D){for(var a=~(D-1),v=0;v<16;v++){var z=a&(I[v]^A[v]);I[v]^=z,A[v]^=z}}function y(I,A){for(var D=i(),a=i(),v=0;v<16;v++)a[v]=A[v];b(a),b(a),b(a);for(var z=0;z<2;z++){D[0]=a[0]-65517;for(var v=1;v<15;v++)D[v]=a[v]-65535-(D[v-1]>>16&1),D[v-1]&=65535;D[15]=a[15]-32767-(D[14]>>16&1);var Y=D[15]>>16&1;D[14]&=65535,F(a,D,1-Y)}for(var v=0;v<16;v++)I[2*v]=a[v]&255,I[2*v+1]=a[v]>>8}function O(I,A){for(var D=0,a=0;a<32;a++)D|=I[a]^A[a];return(1&D-1>>>8)-1}function N(I,A){var D=new Uint8Array(32),a=new Uint8Array(32);return y(D,I),y(a,A),O(D,a)}function L(I){var A=new Uint8Array(32);return y(A,I),A[0]&1}function S(I,A){for(var D=0;D<16;D++)I[D]=A[2*D]+(A[2*D+1]<<8);I[15]&=32767}function C(I,A,D){for(var a=0;a<16;a++)I[a]=A[a]+D[a]}function m(I,A,D){for(var a=0;a<16;a++)I[a]=A[a]-D[a]}function o(I,A,D){var a,v,z=0,Y=0,fe=0,ye=0,de=0,me=0,Ue=0,Te=0,ve=0,pe=0,le=0,ue=0,ce=0,oe=0,se=0,te=0,he=0,ge=0,ne=0,_e=0,be=0,Ee=0,De=0,we=0,xt=0,Tt=0,Kt=0,gt=0,Qt=0,zr=0,pn=0,Me=D[0],Ne=D[1],je=D[2],$e=D[3],Be=D[4],Pe=D[5],We=D[6],ke=D[7],Ye=D[8],Je=D[9],Xe=D[10],He=D[11],ze=D[12],Ie=D[13],Ze=D[14],Qe=D[15];a=A[0],z+=a*Me,Y+=a*Ne,fe+=a*je,ye+=a*$e,de+=a*Be,me+=a*Pe,Ue+=a*We,Te+=a*ke,ve+=a*Ye,pe+=a*Je,le+=a*Xe,ue+=a*He,ce+=a*ze,oe+=a*Ie,se+=a*Ze,te+=a*Qe,a=A[1],Y+=a*Me,fe+=a*Ne,ye+=a*je,de+=a*$e,me+=a*Be,Ue+=a*Pe,Te+=a*We,ve+=a*ke,pe+=a*Ye,le+=a*Je,ue+=a*Xe,ce+=a*He,oe+=a*ze,se+=a*Ie,te+=a*Ze,he+=a*Qe,a=A[2],fe+=a*Me,ye+=a*Ne,de+=a*je,me+=a*$e,Ue+=a*Be,Te+=a*Pe,ve+=a*We,pe+=a*ke,le+=a*Ye,ue+=a*Je,ce+=a*Xe,oe+=a*He,se+=a*ze,te+=a*Ie,he+=a*Ze,ge+=a*Qe,a=A[3],ye+=a*Me,de+=a*Ne,me+=a*je,Ue+=a*$e,Te+=a*Be,ve+=a*Pe,pe+=a*We,le+=a*ke,ue+=a*Ye,ce+=a*Je,oe+=a*Xe,se+=a*He,te+=a*ze,he+=a*Ie,ge+=a*Ze,ne+=a*Qe,a=A[4],de+=a*Me,me+=a*Ne,Ue+=a*je,Te+=a*$e,ve+=a*Be,pe+=a*Pe,le+=a*We,ue+=a*ke,ce+=a*Ye,oe+=a*Je,se+=a*Xe,te+=a*He,he+=a*ze,ge+=a*Ie,ne+=a*Ze,_e+=a*Qe,a=A[5],me+=a*Me,Ue+=a*Ne,Te+=a*je,ve+=a*$e,pe+=a*Be,le+=a*Pe,ue+=a*We,ce+=a*ke,oe+=a*Ye,se+=a*Je,te+=a*Xe,he+=a*He,ge+=a*ze,ne+=a*Ie,_e+=a*Ze,be+=a*Qe,a=A[6],Ue+=a*Me,Te+=a*Ne,ve+=a*je,pe+=a*$e,le+=a*Be,ue+=a*Pe,ce+=a*We,oe+=a*ke,se+=a*Ye,te+=a*Je,he+=a*Xe,ge+=a*He,ne+=a*ze,_e+=a*Ie,be+=a*Ze,Ee+=a*Qe,a=A[7],Te+=a*Me,ve+=a*Ne,pe+=a*je,le+=a*$e,ue+=a*Be,ce+=a*Pe,oe+=a*We,se+=a*ke,te+=a*Ye,he+=a*Je,ge+=a*Xe,ne+=a*He,_e+=a*ze,be+=a*Ie,Ee+=a*Ze,De+=a*Qe,a=A[8],ve+=a*Me,pe+=a*Ne,le+=a*je,ue+=a*$e,ce+=a*Be,oe+=a*Pe,se+=a*We,te+=a*ke,he+=a*Ye,ge+=a*Je,ne+=a*Xe,_e+=a*He,be+=a*ze,Ee+=a*Ie,De+=a*Ze,we+=a*Qe,a=A[9],pe+=a*Me,le+=a*Ne,ue+=a*je,ce+=a*$e,oe+=a*Be,se+=a*Pe,te+=a*We,he+=a*ke,ge+=a*Ye,ne+=a*Je,_e+=a*Xe,be+=a*He,Ee+=a*ze,De+=a*Ie,we+=a*Ze,xt+=a*Qe,a=A[10],le+=a*Me,ue+=a*Ne,ce+=a*je,oe+=a*$e,se+=a*Be,te+=a*Pe,he+=a*We,ge+=a*ke,ne+=a*Ye,_e+=a*Je,be+=a*Xe,Ee+=a*He,De+=a*ze,we+=a*Ie,xt+=a*Ze,Tt+=a*Qe,a=A[11],ue+=a*Me,ce+=a*Ne,oe+=a*je,se+=a*$e,te+=a*Be,he+=a*Pe,ge+=a*We,ne+=a*ke,_e+=a*Ye,be+=a*Je,Ee+=a*Xe,De+=a*He,we+=a*ze,xt+=a*Ie,Tt+=a*Ze,Kt+=a*Qe,a=A[12],ce+=a*Me,oe+=a*Ne,se+=a*je,te+=a*$e,he+=a*Be,ge+=a*Pe,ne+=a*We,_e+=a*ke,be+=a*Ye,Ee+=a*Je,De+=a*Xe,we+=a*He,xt+=a*ze,Tt+=a*Ie,Kt+=a*Ze,gt+=a*Qe,a=A[13],oe+=a*Me,se+=a*Ne,te+=a*je,he+=a*$e,ge+=a*Be,ne+=a*Pe,_e+=a*We,be+=a*ke,Ee+=a*Ye,De+=a*Je,we+=a*Xe,xt+=a*He,Tt+=a*ze,Kt+=a*Ie,gt+=a*Ze,Qt+=a*Qe,a=A[14],se+=a*Me,te+=a*Ne,he+=a*je,ge+=a*$e,ne+=a*Be,_e+=a*Pe,be+=a*We,Ee+=a*ke,De+=a*Ye,we+=a*Je,xt+=a*Xe,Tt+=a*He,Kt+=a*ze,gt+=a*Ie,Qt+=a*Ze,zr+=a*Qe,a=A[15],te+=a*Me,he+=a*Ne,ge+=a*je,ne+=a*$e,_e+=a*Be,be+=a*Pe,Ee+=a*We,De+=a*ke,we+=a*Ye,xt+=a*Je,Tt+=a*Xe,Kt+=a*He,gt+=a*ze,Qt+=a*Ie,zr+=a*Ze,pn+=a*Qe,z+=38*he,Y+=38*ge,fe+=38*ne,ye+=38*_e,de+=38*be,me+=38*Ee,Ue+=38*De,Te+=38*we,ve+=38*xt,pe+=38*Tt,le+=38*Kt,ue+=38*gt,ce+=38*Qt,oe+=38*zr,se+=38*pn,v=1,a=z+v+65535,v=Math.floor(a/65536),z=a-v*65536,a=Y+v+65535,v=Math.floor(a/65536),Y=a-v*65536,a=fe+v+65535,v=Math.floor(a/65536),fe=a-v*65536,a=ye+v+65535,v=Math.floor(a/65536),ye=a-v*65536,a=de+v+65535,v=Math.floor(a/65536),de=a-v*65536,a=me+v+65535,v=Math.floor(a/65536),me=a-v*65536,a=Ue+v+65535,v=Math.floor(a/65536),Ue=a-v*65536,a=Te+v+65535,v=Math.floor(a/65536),Te=a-v*65536,a=ve+v+65535,v=Math.floor(a/65536),ve=a-v*65536,a=pe+v+65535,v=Math.floor(a/65536),pe=a-v*65536,a=le+v+65535,v=Math.floor(a/65536),le=a-v*65536,a=ue+v+65535,v=Math.floor(a/65536),ue=a-v*65536,a=ce+v+65535,v=Math.floor(a/65536),ce=a-v*65536,a=oe+v+65535,v=Math.floor(a/65536),oe=a-v*65536,a=se+v+65535,v=Math.floor(a/65536),se=a-v*65536,a=te+v+65535,v=Math.floor(a/65536),te=a-v*65536,z+=v-1+37*(v-1),v=1,a=z+v+65535,v=Math.floor(a/65536),z=a-v*65536,a=Y+v+65535,v=Math.floor(a/65536),Y=a-v*65536,a=fe+v+65535,v=Math.floor(a/65536),fe=a-v*65536,a=ye+v+65535,v=Math.floor(a/65536),ye=a-v*65536,a=de+v+65535,v=Math.floor(a/65536),de=a-v*65536,a=me+v+65535,v=Math.floor(a/65536),me=a-v*65536,a=Ue+v+65535,v=Math.floor(a/65536),Ue=a-v*65536,a=Te+v+65535,v=Math.floor(a/65536),Te=a-v*65536,a=ve+v+65535,v=Math.floor(a/65536),ve=a-v*65536,a=pe+v+65535,v=Math.floor(a/65536),pe=a-v*65536,a=le+v+65535,v=Math.floor(a/65536),le=a-v*65536,a=ue+v+65535,v=Math.floor(a/65536),ue=a-v*65536,a=ce+v+65535,v=Math.floor(a/65536),ce=a-v*65536,a=oe+v+65535,v=Math.floor(a/65536),oe=a-v*65536,a=se+v+65535,v=Math.floor(a/65536),se=a-v*65536,a=te+v+65535,v=Math.floor(a/65536),te=a-v*65536,z+=v-1+37*(v-1),I[0]=z,I[1]=Y,I[2]=fe,I[3]=ye,I[4]=de,I[5]=me,I[6]=Ue,I[7]=Te,I[8]=ve,I[9]=pe,I[10]=le,I[11]=ue,I[12]=ce,I[13]=oe,I[14]=se,I[15]=te}function g(I,A){o(I,A,A)}function B(I,A){var D=i(),a;for(a=0;a<16;a++)D[a]=A[a];for(a=253;a>=0;a--)g(D,D),a!==2&&a!==4&&o(D,D,A);for(a=0;a<16;a++)I[a]=D[a]}function q(I,A){var D=i(),a;for(a=0;a<16;a++)D[a]=A[a];for(a=250;a>=0;a--)g(D,D),a!==1&&o(D,D,A);for(a=0;a<16;a++)I[a]=D[a]}function V(I,A){var D=i(),a=i(),v=i(),z=i(),Y=i(),fe=i(),ye=i(),de=i(),me=i();m(D,I[1],I[0]),m(me,A[1],A[0]),o(D,D,me),C(a,I[0],I[1]),C(me,A[0],A[1]),o(a,a,me),o(v,I[3],A[3]),o(v,v,l),o(z,I[2],A[2]),C(z,z,z),m(Y,a,D),m(fe,z,v),C(ye,z,v),C(de,a,D),o(I[0],Y,fe),o(I[1],de,ye),o(I[2],ye,fe),o(I[3],Y,de)}function J(I,A,D){for(var a=0;a<4;a++)F(I[a],A[a],D)}function X(I,A){var D=i(),a=i(),v=i();B(v,A[2]),o(D,A[0],v),o(a,A[1],v),y(I,a),I[31]^=L(D)<<7}function f(I,A,D){w(I[0],c),w(I[1],u),w(I[2],u),w(I[3],c);for(var a=255;a>=0;--a){var v=D[a/8|0]>>(a&7)&1;J(I,A,v),V(A,I),V(I,I),J(I,A,v)}}function _(I,A){var D=[i(),i(),i(),i()];w(D[0],p),w(D[1],E),w(D[2],u),o(D[3],p,E),f(I,D,A)}function M(I){if(I.length!==t.SEED_LENGTH)throw new Error("ed25519: seed must be "+t.SEED_LENGTH+" bytes");var A=r.hash(I);A[0]&=248,A[31]&=127,A[31]|=64;var D=new Uint8Array(32),a=[i(),i(),i(),i()];_(a,A),X(D,a);var v=new Uint8Array(64);return v.set(I),v.set(D,32),{publicKey:D,secretKey:v}}t.generateKeyPairFromSeed=M;function K(I){var A=e.randomBytes(32,I),D=M(A);return n.wipe(A),D}t.generateKeyPair=K;function R(I){if(I.length!==t.SECRET_KEY_LENGTH)throw new Error("ed25519: secret key must be "+t.SECRET_KEY_LENGTH+" bytes");return new Uint8Array(I.subarray(32))}t.extractPublicKeyFromSecretKey=R;var P=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function j(I,A){var D,a,v,z;for(a=63;a>=32;--a){for(D=0,v=a-32,z=a-12;v<z;++v)A[v]+=D-16*A[a]*P[v-(a-32)],D=Math.floor((A[v]+128)/256),A[v]-=D*256;A[v]+=D,A[a]=0}for(D=0,v=0;v<32;v++)A[v]+=D-(A[31]>>4)*P[v],D=A[v]>>8,A[v]&=255;for(v=0;v<32;v++)A[v]-=D*P[v];for(a=0;a<32;a++)A[a+1]+=A[a]>>8,I[a]=A[a]&255}function $(I){for(var A=new Float64Array(64),D=0;D<64;D++)A[D]=I[D];for(var D=0;D<64;D++)I[D]=0;j(I,A)}function Q(I,A){var D=new Float64Array(64),a=[i(),i(),i(),i()],v=r.hash(I.subarray(0,32));v[0]&=248,v[31]&=127,v[31]|=64;var z=new Uint8Array(64);z.set(v.subarray(32),32);var Y=new r.SHA512;Y.update(z.subarray(32)),Y.update(A);var fe=Y.digest();Y.clean(),$(fe),_(a,fe),X(z,a),Y.reset(),Y.update(z.subarray(0,32)),Y.update(I.subarray(32)),Y.update(A);var ye=Y.digest();$(ye);for(var de=0;de<32;de++)D[de]=fe[de];for(var de=0;de<32;de++)for(var me=0;me<32;me++)D[de+me]+=ye[de]*v[me];return j(z.subarray(32),D),z}t.sign=Q;function H(I,A){var D=i(),a=i(),v=i(),z=i(),Y=i(),fe=i(),ye=i();return w(I[2],u),S(I[1],A),g(v,I[1]),o(z,v,h),m(v,v,I[2]),C(z,I[2],z),g(Y,z),g(fe,Y),o(ye,fe,Y),o(D,ye,v),o(D,D,z),q(D,D),o(D,D,v),o(D,D,z),o(D,D,z),o(I[0],D,z),g(a,I[0]),o(a,a,z),N(a,v)&&o(I[0],I[0],T),g(a,I[0]),o(a,a,z),N(a,v)?-1:(L(I[0])===A[31]>>7&&m(I[0],c,I[0]),o(I[3],I[0],I[1]),0)}function ee(I,A,D){var a=new Uint8Array(32),v=[i(),i(),i(),i()],z=[i(),i(),i(),i()];if(D.length!==t.SIGNATURE_LENGTH)throw new Error("ed25519: signature must be "+t.SIGNATURE_LENGTH+" bytes");if(H(z,I))return!1;var Y=new r.SHA512;Y.update(D.subarray(0,32)),Y.update(I),Y.update(A);var fe=Y.digest();return $(fe),f(v,z,fe),_(z,D.subarray(32)),V(v,z),X(a,v),!O(D,a)}t.verify=ee;function k(I){var A=[i(),i(),i(),i()];if(H(A,I))throw new Error("Ed25519: invalid public key");var D=i(),a=i(),v=A[1];C(D,u,v),m(a,u,v),B(a,a),o(D,D,a);var z=new Uint8Array(32);return y(z,D),z}t.convertPublicKeyToX25519=k;function ae(I){var A=r.hash(I.subarray(0,32));A[0]&=248,A[31]&=127,A[31]|=64;var D=new Uint8Array(A.subarray(0,32));return n.wipe(A),D}t.convertSecretKeyToX25519=ae}(mi);const xd="EdDSA",Sd="JWT",Uo=".",Mo="base64url",Od="utf8",Ad="utf8",Id=":",Ld="did",Cd="key",jo="base58btc",Td="z",Nd="K36",Pd=32;function an(t){return ft(ht(br(t),Od),Mo)}function $o(t){const e=ht(Nd,jo),r=Td+ft(Bn([e,t]),jo);return[Ld,Cd,r].join(Id)}function Rd(t){return ft(t,Mo)}function Fd(t){return ht([an(t.header),an(t.payload)].join(Uo),Ad)}function Ud(t){return[an(t.header),an(t.payload),Rd(t.signature)].join(Uo)}function Bo(t=nr.randomBytes(Pd)){return mi.generateKeyPairFromSeed(t)}async function Md(t,e,r,n,i=Le.fromMiliseconds(Date.now())){const s={alg:xd,typ:Sd},c=$o(n.publicKey),u=i+r,h={iss:c,sub:t,aud:e,iat:i,exp:u},l=Fd({header:s,payload:h}),p=mi.sign(n.secretKey,l);return Ud({header:s,payload:h,signature:p})}const zo=10,jd=typeof global.WebSocket<"u"?global.WebSocket:require("ws");class $d{constructor(e){if(this.url=e,this.events=new vr.EventEmitter,this.registering=!1,!Gi(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,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){if(typeof this.socket>"u")throw new Error("Connection already closed");this.socket.close(),this.onClose()}async send(e,r){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(br(e))}catch(n){this.onError(e.id,n)}}register(e=this.url){if(!Gi(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return i(new Error("WebSocket connection is missing or invalid"));n(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,n)=>{const i=$i.isReactNative()?void 0:{rejectUnauthorized:!gc(e)},s=new jd(e,[],i);s.onopen=()=>{this.onOpen(s),r(s)},s.onerror=c=>{const u=this.parseError(c.error);this.events.emit("register_error",u),this.onClose(),n(u)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=()=>this.onClose(),e.onerror=r=>{const n=this.parseError(r.error);this.events.emit("error",n)},this.socket=e,this.registering=!1,this.events.emit("open")}onClose(){this.socket=void 0,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?In(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=qr(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return ji(e,r,"WS")}resetMaxListeners(){this.events.getMaxListeners()>zo&&this.events.setMaxListeners(zo)}}var wi={exports:{}};(function(t,e){var r=200,n="__lodash_hash_undefined__",i=1,s=2,c=9007199254740991,u="[object Arguments]",h="[object Array]",l="[object AsyncFunction]",p="[object Boolean]",E="[object Date]",T="[object Error]",w="[object Function]",b="[object GeneratorFunction]",F="[object Map]",y="[object Number]",O="[object Null]",N="[object Object]",L="[object Promise]",S="[object Proxy]",C="[object RegExp]",m="[object Set]",o="[object String]",g="[object Symbol]",B="[object Undefined]",q="[object WeakMap]",V="[object ArrayBuffer]",J="[object DataView]",X="[object Float32Array]",f="[object Float64Array]",_="[object Int8Array]",M="[object Int16Array]",K="[object Int32Array]",R="[object Uint8Array]",P="[object Uint8ClampedArray]",j="[object Uint16Array]",$="[object Uint32Array]",Q=/[\\^$.*+?()[\]{}|]/g,H=/^\[object .+?Constructor\]$/,ee=/^(?:0|[1-9]\d*)$/,k={};k[X]=k[f]=k[_]=k[M]=k[K]=k[R]=k[P]=k[j]=k[$]=!0,k[u]=k[h]=k[V]=k[p]=k[J]=k[E]=k[T]=k[w]=k[F]=k[y]=k[N]=k[C]=k[m]=k[o]=k[q]=!1;var ae=typeof Z=="object"&&Z&&Z.Object===Object&&Z,I=typeof self=="object"&&self&&self.Object===Object&&self,A=ae||I||Function("return this")(),D=e&&!e.nodeType&&e,a=D&&!0&&t&&!t.nodeType&&t,v=a&&a.exports===D,z=v&&ae.process,Y=function(){try{return z&&z.binding&&z.binding("util")}catch{}}(),fe=Y&&Y.isTypedArray;function ye(d,x){for(var U=-1,W=d==null?0:d.length,Ae=0,ie=[];++U<W;){var Re=d[U];x(Re,U,d)&&(ie[Ae++]=Re)}return ie}function de(d,x){for(var U=-1,W=x.length,Ae=d.length;++U<W;)d[Ae+U]=x[U];return d}function me(d,x){for(var U=-1,W=d==null?0:d.length;++U<W;)if(x(d[U],U,d))return!0;return!1}function Ue(d,x){for(var U=-1,W=Array(d);++U<d;)W[U]=x(U);return W}function Te(d){return function(x){return d(x)}}function ve(d,x){return d.has(x)}function pe(d,x){return d?.[x]}function le(d){var x=-1,U=Array(d.size);return d.forEach(function(W,Ae){U[++x]=[Ae,W]}),U}function ue(d,x){return function(U){return d(x(U))}}function ce(d){var x=-1,U=Array(d.size);return d.forEach(function(W){U[++x]=W}),U}var oe=Array.prototype,se=Function.prototype,te=Object.prototype,he=A["__core-js_shared__"],ge=se.toString,ne=te.hasOwnProperty,_e=function(){var d=/[^.]+$/.exec(he&&he.keys&&he.keys.IE_PROTO||"");return d?"Symbol(src)_1."+d:""}(),be=te.toString,Ee=RegExp("^"+ge.call(ne).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=v?A.Buffer:void 0,we=A.Symbol,xt=A.Uint8Array,Tt=te.propertyIsEnumerable,Kt=oe.splice,gt=we?we.toStringTag:void 0,Qt=Object.getOwnPropertySymbols,zr=De?De.isBuffer:void 0,pn=ue(Object.keys,Object),Me=gr(A,"DataView"),Ne=gr(A,"Map"),je=gr(A,"Promise"),$e=gr(A,"Set"),Be=gr(A,"WeakMap"),Pe=gr(Object,"create"),We=tr(Me),ke=tr(Ne),Ye=tr(je),Je=tr($e),Xe=tr(Be),He=we?we.prototype:void 0,ze=He?He.valueOf:void 0;function Ie(d){var x=-1,U=d==null?0:d.length;for(this.clear();++x<U;){var W=d[x];this.set(W[0],W[1])}}function Ze(){this.__data__=Pe?Pe(null):{},this.size=0}function Qe(d){var x=this.has(d)&&delete this.__data__[d];return this.size-=x?1:0,x}function Fv(d){var x=this.__data__;if(Pe){var U=x[d];return U===n?void 0:U}return ne.call(x,d)?x[d]:void 0}function Uv(d){var x=this.__data__;return Pe?x[d]!==void 0:ne.call(x,d)}function Mv(d,x){var U=this.__data__;return this.size+=this.has(d)?0:1,U[d]=Pe&&x===void 0?n:x,this}Ie.prototype.clear=Ze,Ie.prototype.delete=Qe,Ie.prototype.get=Fv,Ie.prototype.has=Uv,Ie.prototype.set=Mv;function Mt(d){var x=-1,U=d==null?0:d.length;for(this.clear();++x<U;){var W=d[x];this.set(W[0],W[1])}}function jv(){this.__data__=[],this.size=0}function $v(d){var x=this.__data__,U=vn(x,d);if(U<0)return!1;var W=x.length-1;return U==W?x.pop():Kt.call(x,U,1),--this.size,!0}function Bv(d){var x=this.__data__,U=vn(x,d);return U<0?void 0:x[U][1]}function zv(d){return vn(this.__data__,d)>-1}function Hv(d,x){var U=this.__data__,W=vn(U,d);return W<0?(++this.size,U.push([d,x])):U[W][1]=x,this}Mt.prototype.clear=jv,Mt.prototype.delete=$v,Mt.prototype.get=Bv,Mt.prototype.has=zv,Mt.prototype.set=Hv;function er(d){var x=-1,U=d==null?0:d.length;for(this.clear();++x<U;){var W=d[x];this.set(W[0],W[1])}}function Kv(){this.size=0,this.__data__={hash:new Ie,map:new(Ne||Mt),string:new Ie}}function qv(d){var x=yn(this,d).delete(d);return this.size-=x?1:0,x}function Vv(d){return yn(this,d).get(d)}function Gv(d){return yn(this,d).has(d)}function Wv(d,x){var U=yn(this,d),W=U.size;return U.set(d,x),this.size+=U.size==W?0:1,this}er.prototype.clear=Kv,er.prototype.delete=qv,er.prototype.get=Vv,er.prototype.has=Gv,er.prototype.set=Wv;function gn(d){var x=-1,U=d==null?0:d.length;for(this.__data__=new er;++x<U;)this.add(d[x])}function kv(d){return this.__data__.set(d,n),this}function Yv(d){return this.__data__.has(d)}gn.prototype.add=gn.prototype.push=kv,gn.prototype.has=Yv;function qt(d){var x=this.__data__=new Mt(d);this.size=x.size}function Jv(){this.__data__=new Mt,this.size=0}function Xv(d){var x=this.__data__,U=x.delete(d);return this.size=x.size,U}function Zv(d){return this.__data__.get(d)}function Qv(d){return this.__data__.has(d)}function e0(d,x){var U=this.__data__;if(U instanceof Mt){var W=U.__data__;if(!Ne||W.length<r-1)return W.push([d,x]),this.size=++U.size,this;U=this.__data__=new er(W)}return U.set(d,x),this.size=U.size,this}qt.prototype.clear=Jv,qt.prototype.delete=Xv,qt.prototype.get=Zv,qt.prototype.has=Qv,qt.prototype.set=e0;function t0(d,x){var U=_n(d),W=!U&&v0(d),Ae=!U&&!W&&Pi(d),ie=!U&&!W&&!Ae&&ka(d),Re=U||W||Ae||ie,et=Re?Ue(d.length,String):[],it=et.length;for(var Ce in d)(x||ne.call(d,Ce))&&!(Re&&(Ce=="length"||Ae&&(Ce=="offset"||Ce=="parent")||ie&&(Ce=="buffer"||Ce=="byteLength"||Ce=="byteOffset")||f0(Ce,it)))&&et.push(Ce);return et}function vn(d,x){for(var U=d.length;U--;)if(qa(d[U][0],x))return U;return-1}function r0(d,x,U){var W=x(d);return _n(d)?W:de(W,U(d))}function Hr(d){return d==null?d===void 0?B:O:gt&&gt in Object(d)?u0(d):g0(d)}function Ba(d){return Kr(d)&&Hr(d)==u}function za(d,x,U,W,Ae){return d===x?!0:d==null||x==null||!Kr(d)&&!Kr(x)?d!==d&&x!==x:n0(d,x,U,W,za,Ae)}function n0(d,x,U,W,Ae,ie){var Re=_n(d),et=_n(x),it=Re?h:Vt(d),Ce=et?h:Vt(x);it=it==u?N:it,Ce=Ce==u?N:Ce;var vt=it==N,St=Ce==N,at=it==Ce;if(at&&Pi(d)){if(!Pi(x))return!1;Re=!0,vt=!1}if(at&&!vt)return ie||(ie=new qt),Re||ka(d)?Ha(d,x,U,W,Ae,ie):a0(d,x,it,U,W,Ae,ie);if(!(U&i)){var _t=vt&&ne.call(d,"__wrapped__"),bt=St&&ne.call(x,"__wrapped__");if(_t||bt){var Gt=_t?d.value():d,jt=bt?x.value():x;return ie||(ie=new qt),Ae(Gt,jt,U,W,ie)}}return at?(ie||(ie=new qt),c0(d,x,U,W,Ae,ie)):!1}function i0(d){if(!Wa(d)||d0(d))return!1;var x=Va(d)?Ee:H;return x.test(tr(d))}function s0(d){return Kr(d)&&Ga(d.length)&&!!k[Hr(d)]}function o0(d){if(!p0(d))return pn(d);var x=[];for(var U in Object(d))ne.call(d,U)&&U!="constructor"&&x.push(U);return x}function Ha(d,x,U,W,Ae,ie){var Re=U&i,et=d.length,it=x.length;if(et!=it&&!(Re&&it>et))return!1;var Ce=ie.get(d);if(Ce&&ie.get(x))return Ce==x;var vt=-1,St=!0,at=U&s?new gn:void 0;for(ie.set(d,x),ie.set(x,d);++vt<et;){var _t=d[vt],bt=x[vt];if(W)var Gt=Re?W(bt,_t,vt,x,d,ie):W(_t,bt,vt,d,x,ie);if(Gt!==void 0){if(Gt)continue;St=!1;break}if(at){if(!me(x,function(jt,rr){if(!ve(at,rr)&&(_t===jt||Ae(_t,jt,U,W,ie)))return at.push(rr)})){St=!1;break}}else if(!(_t===bt||Ae(_t,bt,U,W,ie))){St=!1;break}}return ie.delete(d),ie.delete(x),St}function a0(d,x,U,W,Ae,ie,Re){switch(U){case J:if(d.byteLength!=x.byteLength||d.byteOffset!=x.byteOffset)return!1;d=d.buffer,x=x.buffer;case V:return!(d.byteLength!=x.byteLength||!ie(new xt(d),new xt(x)));case p:case E:case y:return qa(+d,+x);case T:return d.name==x.name&&d.message==x.message;case C:case o:return d==x+"";case F:var et=le;case m:var it=W&i;if(et||(et=ce),d.size!=x.size&&!it)return!1;var Ce=Re.get(d);if(Ce)return Ce==x;W|=s,Re.set(d,x);var vt=Ha(et(d),et(x),W,Ae,ie,Re);return Re.delete(d),vt;case g:if(ze)return ze.call(d)==ze.call(x)}return!1}function c0(d,x,U,W,Ae,ie){var Re=U&i,et=Ka(d),it=et.length,Ce=Ka(x),vt=Ce.length;if(it!=vt&&!Re)return!1;for(var St=it;St--;){var at=et[St];if(!(Re?at in x:ne.call(x,at)))return!1}var _t=ie.get(d);if(_t&&ie.get(x))return _t==x;var bt=!0;ie.set(d,x),ie.set(x,d);for(var Gt=Re;++St<it;){at=et[St];var jt=d[at],rr=x[at];if(W)var Ya=Re?W(rr,jt,at,x,d,ie):W(jt,rr,at,d,x,ie);if(!(Ya===void 0?jt===rr||Ae(jt,rr,U,W,ie):Ya)){bt=!1;break}Gt||(Gt=at=="constructor")}if(bt&&!Gt){var bn=d.constructor,mn=x.constructor;bn!=mn&&"constructor"in d&&"constructor"in x&&!(typeof bn=="function"&&bn instanceof bn&&typeof mn=="function"&&mn instanceof mn)&&(bt=!1)}return ie.delete(d),ie.delete(x),bt}function Ka(d){return r0(d,b0,h0)}function yn(d,x){var U=d.__data__;return l0(x)?U[typeof x=="string"?"string":"hash"]:U.map}function gr(d,x){var U=pe(d,x);return i0(U)?U:void 0}function u0(d){var x=ne.call(d,gt),U=d[gt];try{d[gt]=void 0;var W=!0}catch{}var Ae=be.call(d);return W&&(x?d[gt]=U:delete d[gt]),Ae}var h0=Qt?function(d){return d==null?[]:(d=Object(d),ye(Qt(d),function(x){return Tt.call(d,x)}))}:m0,Vt=Hr;(Me&&Vt(new Me(new ArrayBuffer(1)))!=J||Ne&&Vt(new Ne)!=F||je&&Vt(je.resolve())!=L||$e&&Vt(new $e)!=m||Be&&Vt(new Be)!=q)&&(Vt=function(d){var x=Hr(d),U=x==N?d.constructor:void 0,W=U?tr(U):"";if(W)switch(W){case We:return J;case ke:return F;case Ye:return L;case Je:return m;case Xe:return q}return x});function f0(d,x){return x=x??c,!!x&&(typeof d=="number"||ee.test(d))&&d>-1&&d%1==0&&d<x}function l0(d){var x=typeof d;return x=="string"||x=="number"||x=="symbol"||x=="boolean"?d!=="__proto__":d===null}function d0(d){return!!_e&&_e in d}function p0(d){var x=d&&d.constructor,U=typeof x=="function"&&x.prototype||te;return d===U}function g0(d){return be.call(d)}function tr(d){if(d!=null){try{return ge.call(d)}catch{}try{return d+""}catch{}}return""}function qa(d,x){return d===x||d!==d&&x!==x}var v0=Ba(function(){return arguments}())?Ba:function(d){return Kr(d)&&ne.call(d,"callee")&&!Tt.call(d,"callee")},_n=Array.isArray;function y0(d){return d!=null&&Ga(d.length)&&!Va(d)}var Pi=zr||w0;function _0(d,x){return za(d,x)}function Va(d){if(!Wa(d))return!1;var x=Hr(d);return x==w||x==b||x==l||x==S}function Ga(d){return typeof d=="number"&&d>-1&&d%1==0&&d<=c}function Wa(d){var x=typeof d;return d!=null&&(x=="object"||x=="function")}function Kr(d){return d!=null&&typeof d=="object"}var ka=fe?Te(fe):s0;function b0(d){return y0(d)?t0(d):o0(d)}function m0(){return[]}function w0(){return!1}t.exports=_0})(wi,wi.exports);var Bd=wi.exports,zd=Object.defineProperty,Ho=Object.getOwnPropertySymbols,Hd=Object.prototype.hasOwnProperty,Kd=Object.prototype.propertyIsEnumerable,Ko=(t,e,r)=>e in t?zd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ut=(t,e)=>{for(var r in e||(e={}))Hd.call(e,r)&&Ko(t,r,e[r]);if(Ho)for(var r of Ho(e))Kd.call(e,r)&&Ko(t,r,e[r]);return t};function Ve(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var cn=Ve;Ve.EventEmitter=Ve,Ve.prototype._events=void 0,Ve.prototype._maxListeners=void 0,Ve.defaultMaxListeners=10,Ve.prototype.setMaxListeners=function(t){if(!qd(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ve.prototype.emit=function(t){var e,r,n,i,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Fr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],qo(r))return!1;if(Ft(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(Fr(r))for(i=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,s=0;s<n;s++)c[s].apply(this,i);return!0},Ve.prototype.addListener=function(t,e){var r;if(!Ft(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Ft(e.listener)?e.listener:e),this._events[t]?Fr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Fr(this._events[t])&&!this._events[t].warned&&(qo(this._maxListeners)?r=Ve.defaultMaxListeners:r=this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),typeof console.trace=="function"&&console.trace())),this},Ve.prototype.on=Ve.prototype.addListener,Ve.prototype.once=function(t,e){if(!Ft(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},Ve.prototype.removeListener=function(t,e){var r,n,i,s;if(!Ft(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],i=r.length,n=-1,r===e||Ft(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(Fr(r)){for(s=i;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(n<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},Ve.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[t]&&delete this._events[t],this;if(arguments.length===0){for(e in this._events)e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],Ft(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},Ve.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Ft(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},Ve.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Ft(e))return 1;if(e)return e.length}return 0},Ve.listenerCount=function(t,e){return t.listenerCount(e)};function Ft(t){return typeof t=="function"}function qd(t){return typeof t=="number"}function Fr(t){return typeof t=="object"&&t!==null}function qo(t){return t===void 0}function Vd(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),c=s.charCodeAt(0);if(r[c]!==255)throw new TypeError(s+" is ambiguous");r[c]=i}var u=t.length,h=t.charAt(0),l=Math.log(u)/Math.log(256),p=Math.log(256)/Math.log(u);function E(b){if(b instanceof Uint8Array||(ArrayBuffer.isView(b)?b=new Uint8Array(b.buffer,b.byteOffset,b.byteLength):Array.isArray(b)&&(b=Uint8Array.from(b))),!(b instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(b.length===0)return"";for(var F=0,y=0,O=0,N=b.length;O!==N&&b[O]===0;)O++,F++;for(var L=(N-O)*p+1>>>0,S=new Uint8Array(L);O!==N;){for(var C=b[O],m=0,o=L-1;(C!==0||m<y)&&o!==-1;o--,m++)C+=256*S[o]>>>0,S[o]=C%u>>>0,C=C/u>>>0;if(C!==0)throw new Error("Non-zero carry");y=m,O++}for(var g=L-y;g!==L&&S[g]===0;)g++;for(var B=h.repeat(F);g<L;++g)B+=t.charAt(S[g]);return B}function T(b){if(typeof b!="string")throw new TypeError("Expected String");if(b.length===0)return new Uint8Array;var F=0;if(b[F]!==" "){for(var y=0,O=0;b[F]===h;)y++,F++;for(var N=(b.length-F)*l+1>>>0,L=new Uint8Array(N);b[F];){var S=r[b.charCodeAt(F)];if(S===255)return;for(var C=0,m=N-1;(S!==0||C<O)&&m!==-1;m--,C++)S+=u*L[m]>>>0,L[m]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");O=C,F++}if(b[F]!==" "){for(var o=N-O;o!==N&&L[o]===0;)o++;for(var g=new Uint8Array(y+(N-o)),B=y;o!==N;)g[B++]=L[o++];return g}}}function w(b){var F=T(b);if(F)return F;throw new Error(`Non-${e} character`)}return{encode:E,decodeUnsafe:T,decode:w}}var Gd=Vd,Wd=Gd;const Vo=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},kd=t=>new TextEncoder().encode(t),Yd=t=>new TextDecoder().decode(t);class Jd{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Xd{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){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))}else throw Error("Can only multibase decode strings")}or(e){return Go(this,e)}}class Zd{constructor(e){this.decoders=e}or(e){return Go(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Go=(t,e)=>new Zd(ut(ut({},t.decoders||{[t.prefix]:t}),e.decoders||{[e.prefix]:e}));class Qd{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Jd(e,r,n),this.decoder=new Xd(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const un=({name:t,prefix:e,encode:r,decode:n})=>new Qd(t,e,r,n),Ur=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=Wd(r,e);return un({prefix:t,name:e,encode:n,decode:s=>Vo(i(s))})},ep=(t,e,r,n)=>{const i={};for(let p=0;p<e.length;++p)i[e[p]]=p;let s=t.length;for(;t[s-1]==="=";)--s;const c=new Uint8Array(s*r/8|0);let u=0,h=0,l=0;for(let p=0;p<s;++p){const E=i[t[p]];if(E===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<r|E,u+=r,u>=8&&(u-=8,c[l++]=255&h>>u)}if(u>=r||255&h<<8-u)throw new SyntaxError("Unexpected end of data");return c},tp=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",c=0,u=0;for(let h=0;h<t.length;++h)for(u=u<<8|t[h],c+=8;c>r;)c-=r,s+=e[i&u>>c];if(c&&(s+=e[i&u<<r-c]),n)for(;s.length*r&7;)s+="=";return s},nt=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>un({prefix:e,name:t,encode(i){return tp(i,n,r)},decode(i){return ep(i,n,r,t)}}),rp=un({prefix:"\0",name:"identity",encode:t=>Yd(t),decode:t=>kd(t)});var np=Object.freeze({__proto__:null,identity:rp});const ip=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var sp=Object.freeze({__proto__:null,base2:ip});const op=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ap=Object.freeze({__proto__:null,base8:op});const cp=Ur({prefix:"9",name:"base10",alphabet:"0123456789"});var up=Object.freeze({__proto__:null,base10:cp});const hp=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),fp=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var lp=Object.freeze({__proto__:null,base16:hp,base16upper:fp});const dp=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pp=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),gp=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),vp=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),yp=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),_p=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),bp=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),mp=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),wp=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Ep=Object.freeze({__proto__:null,base32:dp,base32upper:pp,base32pad:gp,base32padupper:vp,base32hex:yp,base32hexupper:_p,base32hexpad:bp,base32hexpadupper:mp,base32z:wp});const Dp=Ur({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),xp=Ur({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Sp=Object.freeze({__proto__:null,base36:Dp,base36upper:xp});const Op=Ur({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ap=Ur({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ip=Object.freeze({__proto__:null,base58btc:Op,base58flickr:Ap});const Lp=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Cp=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Tp=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Np=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Pp=Object.freeze({__proto__:null,base64:Lp,base64pad:Cp,base64url:Tp,base64urlpad:Np});const Wo=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Rp=Wo.reduce((t,e,r)=>(t[r]=e,t),[]),Fp=Wo.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Up(t){return t.reduce((e,r)=>(e+=Rp[r],e),"")}function Mp(t){const e=[];for(const r of t){const n=Fp[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const jp=un({prefix:"\u{1F680}",name:"base256emoji",encode:Up,decode:Mp});var $p=Object.freeze({__proto__:null,base256emoji:jp}),Bp=Yo,ko=128,zp=127,Hp=~zp,Kp=Math.pow(2,31);function Yo(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Kp;)e[r++]=t&255|ko,t/=128;for(;t&Hp;)e[r++]=t&255|ko,t>>>=7;return e[r]=t|0,Yo.bytes=r-n+1,e}var qp=Ei,Vp=128,Jo=127;function Ei(t,n){var r=0,n=n||0,i=0,s=n,c,u=t.length;do{if(s>=u)throw Ei.bytes=0,new RangeError("Could not decode varint");c=t[s++],r+=i<28?(c&Jo)<<i:(c&Jo)*Math.pow(2,i),i+=7}while(c>=Vp);return Ei.bytes=s-n,r}var Gp=Math.pow(2,7),Wp=Math.pow(2,14),kp=Math.pow(2,21),Yp=Math.pow(2,28),Jp=Math.pow(2,35),Xp=Math.pow(2,42),Zp=Math.pow(2,49),Qp=Math.pow(2,56),eg=Math.pow(2,63),tg=function(t){return t<Gp?1:t<Wp?2:t<kp?3:t<Yp?4:t<Jp?5:t<Xp?6:t<Zp?7:t<Qp?8:t<eg?9:10},rg={encode:Bp,decode:qp,encodingLength:tg},Xo=rg;const Zo=(t,e,r=0)=>(Xo.encode(t,e,r),e),Qo=t=>Xo.encodingLength(t),Di=(t,e)=>{const r=e.byteLength,n=Qo(t),i=n+Qo(r),s=new Uint8Array(i+r);return Zo(t,s,0),Zo(r,s,n),s.set(e,i),new ng(t,r,e,s)};class ng{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const ea=({name:t,code:e,encode:r})=>new ig(t,e,r);class ig{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Di(this.code,r):r.then(n=>Di(this.code,n))}else throw Error("Unknown type, must be binary type")}}const ta=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),sg=ea({name:"sha2-256",code:18,encode:ta("SHA-256")}),og=ea({name:"sha2-512",code:19,encode:ta("SHA-512")});var ag=Object.freeze({__proto__:null,sha256:sg,sha512:og});const ra=0,cg="identity",na=Vo;var ug=Object.freeze({__proto__:null,identity:{code:ra,name:cg,encode:na,digest:t=>Di(ra,na(t))}});new TextEncoder,new TextDecoder;const ia=ut(ut(ut(ut(ut(ut(ut(ut(ut(ut({},np),sp),ap),up),lp),Ep),Sp),Ip),Pp),$p);ut(ut({},ag),ug);function sa(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const oa=sa("utf8","u",t=>{const e=new TextDecoder("utf8");return"u"+e.decode(t)},t=>new TextEncoder().encode(t.substring(1))),xi=sa("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),hg=ut({utf8:oa,"utf-8":oa,hex:ia.base16,latin1:xi,ascii:xi,binary:xi},ia);function fg(t,e="utf8"){const r=hg[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return r.decoder.decode(`${r.prefix}${t}`)}const aa="wc",lg=2,Si="core",Mr=`${aa}@${2}:${Si}:`,dg={name:Si,logger:"error"},pg={database:":memory:"},gg="crypto",ca="client_ed25519_seed",vg=Le.ONE_DAY,yg="keychain",_g="0.3",bg="messages",mg="0.3",wg=Le.SIX_HOURS,Eg="publisher",ua="irn",Dg="error",xg="wss://relay.walletconnect.com",Sg="relayer",jr={message:"relayer_message",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error"},Og="_subscription",lr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Ag=Le.ONE_SECOND,Ig="2.0.0-rc.1",Lg="0.3",Zt={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync"},Cg="subscription",Tg="0.3",Ng=Le.FIVE_SECONDS*1e3;class Pg{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=yg,this.version=_g,this.initialized=!1,this.storagePrefix=Mr,this.init=async()=>{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}},this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=async(n,i)=>{this.isInitialized(),this.keychain.set(n,i),await this.persist()},this.get=n=>{this.isInitialized();const i=this.keychain.get(n);if(typeof i>"u"){const{message:s}=G("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(s)}return i},this.del=async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()},this.core=e,this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,no(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?io(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Rg{constructor(e,r,n){this.core=e,this.logger=r,this.name=gg,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=i=>(this.isInitialized(),this.keychain.has(i)),this.getClientId=async()=>{this.isInitialized();const i=await this.getClientSeed(),s=Bo(i);return $o(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const i=pf();return this.setPrivateKey(i.publicKey,i.privateKey)},this.signJWT=async i=>{this.isInitialized();const s=await this.getClientSeed(),c=Bo(s),u=ei();return await Md(u,i,vg,c)},this.generateSharedKey=(i,s,c)=>{this.isInitialized();const u=this.getPrivateKey(i),h=gf(u,s);return this.setSymKey(h,c)},this.setSymKey=async(i,s)=>{this.isInitialized();const c=s||vf(i);return await this.keychain.set(c,i),c},this.deleteKeyPair=async i=>{this.isInitialized(),await this.keychain.del(i)},this.deleteSymKey=async i=>{this.isInitialized(),await this.keychain.del(i)},this.encode=async(i,s,c)=>{this.isInitialized();const u=Xs(c),h=br(s);if(Zs(u)){const T=u.senderPublicKey,w=u.receiverPublicKey;i=await this.generateSharedKey(T,w)}const l=this.getSymKey(i),{type:p,senderPublicKey:E}=u;return _f({type:p,symKey:l,message:h,senderPublicKey:E})},this.decode=async(i,s,c)=>{this.isInitialized();const u=wf(s,c);if(Zs(u)){const p=u.receiverPublicKey,E=u.senderPublicKey;i=await this.generateSharedKey(p,E)}const h=this.getSymKey(i),l=bf({symKey:h,encoded:s});return In(l)},this.core=e,this.logger=Oe.generateChildLogger(r,this.name),this.keychain=n||new Pg(this.core,this.logger)}get context(){return Oe.getLoggerContext(this.logger)}async setPrivateKey(e,r){return await this.keychain.set(e,r),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(ca)}catch{e=ei(),await this.keychain.set(ca,e)}return fg(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Fg extends pd{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=bg,this.version=mg,this.initialized=!1,this.storagePrefix=Mr,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}},this.set=async(n,i)=>{this.isInitialized();const s=Zr(i);let c=this.messages.get(n);return typeof c>"u"&&(c={}),typeof c[s]<"u"||(c[s]=i,this.messages.set(n,c),await this.persist()),s},this.get=n=>{this.isInitialized();let i=this.messages.get(n);return typeof i>"u"&&(i={}),i},this.has=(n,i)=>{this.isInitialized();const s=this.get(n),c=Zr(i);return typeof s[c]<"u"},this.del=async n=>{this.isInitialized(),this.messages.delete(n),await this.persist()},this.logger=Oe.generateChildLogger(e,this.name),this.core=r}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,no(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?io(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Ug extends gd{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new cn.EventEmitter,this.name=Eg,this.queue=new Map,this.publish=async(n,i,s)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}});try{const c=s?.ttl||wg,u=ti(s),h=s?.prompt||!1,l=s?.tag||0,p={topic:n,message:i,opts:{ttl:c,relay:u,prompt:h,tag:l}},E=Zr(i);this.queue.set(E,p),await this.rpcPublish(n,i,c,u,h,l),this.onPublish(E,p),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}})}catch(c){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(c),c}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.relayer=e,this.logger=Oe.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return Oe.getLoggerContext(this.logger)}rpcPublish(e,r,n,i,s,c){var u,h,l,p;const E={method:ri(i.protocol).publish,params:{topic:e,message:r,ttl:n,prompt:s,tag:c}};return Et((u=E.params)==null?void 0:u.prompt)&&((h=E.params)==null||delete h.prompt),Et((l=E.params)==null?void 0:l.tag)&&((p=E.params)==null||delete p.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:E}),this.relayer.provider.request(E)}onPublish(e,r){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:r,message:n,opts:{ttl:i,relay:s,prompt:c,tag:u}}=e,h=Zr(n);await this.rpcPublish(r,n,i,s,c,u),this.onPublish(h,e)})}registerEventListeners(){this.relayer.core.heartbeat.on(Pr.HEARTBEAT_EVENTS.pulse,()=>{this.checkQueue()})}}class Mg{constructor(){this.map=new Map,this.set=(e,r)=>{const n=this.get(e);this.exists(e,r)||this.map.set(e,[...n,r])},this.get=e=>this.map.get(e)||[],this.exists=(e,r)=>this.get(e).includes(r),this.delete=(e,r)=>{if(typeof r>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const n=this.get(e);if(!this.exists(e,r))return;const i=n.filter(s=>s!==r);if(!i.length){this.map.delete(e);return}this.map.set(e,i)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var jg=Object.defineProperty,$g=Object.defineProperties,Bg=Object.getOwnPropertyDescriptors,ha=Object.getOwnPropertySymbols,zg=Object.prototype.hasOwnProperty,Hg=Object.prototype.propertyIsEnumerable,fa=(t,e,r)=>e in t?jg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,hn=(t,e)=>{for(var r in e||(e={}))zg.call(e,r)&&fa(t,r,e[r]);if(ha)for(var r of ha(e))Hg.call(e,r)&&fa(t,r,e[r]);return t},Oi=(t,e)=>$g(t,Bg(e));class Kg extends _d{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new Mg,this.events=new cn.EventEmitter,this.name=Cg,this.version=Tg,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pendingSubInterval=20,this.storagePrefix=Mr,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),await this.reset(),this.registerEventListeners(),this.onEnable())},this.subscribe=async(n,i)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}});try{const s=ti(i),c={topic:n,relay:s};this.pending.set(n,c);const u=await this.rpcSubscribe(n,s);return this.onSubscribe(u,c),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}}),u}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(n,i)=>{this.isInitialized(),typeof i?.id<"u"?await this.unsubscribeById(n,i.id,i):await this.unsubscribeByTopic(n,i)},this.isSubscribed=async n=>this.topics.includes(n)?!0:await new Promise((i,s)=>{const c=new Le.Watch;c.start(this.pendingSubscriptionWatchLabel);const u=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(u),c.stop(this.pendingSubscriptionWatchLabel),i(!0)),c.elapsed(this.pendingSubscriptionWatchLabel)>=Ng&&(clearInterval(u),c.stop(this.pendingSubscriptionWatchLabel),s(!1))},this.pendingSubInterval)}),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.relayer=e,this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,r){let n=!1;try{n=this.getSubscription(e).topic===r}catch{}return n}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear(),this.initialized=!1}async unsubscribeByTopic(e,r){const n=this.topicMap.get(e);await Promise.all(n.map(async i=>await this.unsubscribeById(e,i,r)))}async unsubscribeById(e,r,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:n}});try{const i=ti(n);await this.rpcUnsubscribe(e,r,i);const s=rt("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:n}})}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}}async rpcSubscribe(e,r){const n={method:ri(r.protocol).subscribe,params:{topic:e}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),await this.relayer.provider.request(n)}rpcUnsubscribe(e,r,n){const i={method:ri(n.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.provider.request(i)}onSubscribe(e,r){this.setSubscription(e,Oi(hn({},r),{id:e})),this.pending.delete(r.topic)}onResubscribe(e,r){this.addSubscription(e,Oi(hn({},r),{id:e})),this.pending.delete(r.topic)}async onUnsubscribe(e,r,n){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,n),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:r}),this.addSubscription(e,r))}addSubscription(e,r){this.subscriptions.set(e,hn({},r)),this.topicMap.set(r.topic,e),this.events.emit(Zt.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const r=this.subscriptions.get(e);if(!r){const{message:n}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const n=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(n.topic,e),this.events.emit(Zt.deleted,Oi(hn({},n),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Zt.sync)}async reset(){!this.cached.length||await Promise.all(this.cached.map(async e=>await this.resubscribe(e)))}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=G("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async resubscribe(e){if(!this.ids.includes(e.id)){const{topic:r,relay:n}=e,i={topic:r,relay:n};this.pending.set(i.topic,i);const s=await this.rpcSubscribe(i.topic,i.relay);this.onResubscribe(s,i)}}async onConnect(){await this.reset(),this.onEnable()}onDisconnect(){this.onDisable()}checkPending(){this.pending.forEach(async e=>{const r=await this.rpcSubscribe(e.topic,e.relay);this.onSubscribe(r,e)})}registerEventListeners(){this.relayer.core.heartbeat.on(Pr.HEARTBEAT_EVENTS.pulse,()=>{this.checkPending()}),this.relayer.provider.on(lr.connect,async()=>{await this.onConnect()}),this.relayer.provider.on(lr.disconnect,()=>{this.onDisconnect()}),this.events.on(Zt.created,async e=>{const r=Zt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(Zt.deleted,async e=>{const r=Zt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}var qg=Object.defineProperty,la=Object.getOwnPropertySymbols,Vg=Object.prototype.hasOwnProperty,Gg=Object.prototype.propertyIsEnumerable,da=(t,e,r)=>e in t?qg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Wg=(t,e)=>{for(var r in e||(e={}))Vg.call(e,r)&&da(t,r,e[r]);if(la)for(var r of la(e))Gg.call(e,r)&&da(t,r,e[r]);return t};class kg extends vd{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new cn.EventEmitter,this.name=Sg,this.initialized=!1,this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Oe.generateChildLogger(e.logger,this.name):oi(Oe.getDefaultLoggerOptions({level:e.logger||Dg})),this.messages=new Fg(this.logger,e.core),this.subscriber=new Kg(this,this.logger),this.publisher=new Ug(this,this.logger),this.relayUrl=e?.relayUrl||xg,this.projectId=e.projectId,this.provider={}}async init(){this.logger.trace("Initialized");const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=this.createProvider(e),await Promise.all([this.messages.init(),this.provider.connect(),this.subscriber.init()]),this.registerEventListeners(),this.initialized=!0}get context(){return Oe.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,r,n){this.isInitialized(),await this.publisher.publish(e,r,n),await this.recordMessageEvent({topic:e,message:r})}async subscribe(e,r){return this.isInitialized(),await this.subscriber.subscribe(e,r)}async unsubscribe(e,r){this.isInitialized(),await this.subscriber.unsubscribe(e,r)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}createProvider(e){return new On(new $d(Ff({sdkVersion:Ig,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e})))}async recordMessageEvent(e){const{topic:r,message:n}=e;await this.messages.set(r,n)}async shouldIgnoreMessageEvent(e){const{topic:r,message:n}=e;return await this.subscriber.isSubscribed(r)?this.messages.has(r,n):!0}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),ki(e)){if(!e.method.endsWith(Og))return;const r=e.params,{topic:n,message:i}=r.data,s={topic:n,message:i};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Wg({type:"event",event:r.id},s)),this.events.emit(r.id,s),await this.acknowledgePayload(e),await this.onMessageEvent(s)}}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(jr.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=Sn(e.id,!0);await this.provider.connection.send(r)}registerEventListeners(){this.provider.on(lr.payload,e=>this.onProviderPayload(e)),this.provider.on(lr.connect,()=>{this.events.emit(jr.connect)}),this.provider.on(lr.disconnect,()=>{this.events.emit(jr.disconnect),setTimeout(()=>{this.provider.connect()},Le.toMiliseconds(Ag))}),this.provider.on(lr.error,e=>this.events.emit(jr.error,e))}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Yg=Object.defineProperty,pa=Object.getOwnPropertySymbols,Jg=Object.prototype.hasOwnProperty,Xg=Object.prototype.propertyIsEnumerable,ga=(t,e,r)=>e in t?Yg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,va=(t,e)=>{for(var r in e||(e={}))Jg.call(e,r)&&ga(t,r,e[r]);if(pa)for(var r of pa(e))Xg.call(e,r)&&ga(t,r,e[r]);return t};class Ai extends yd{constructor(e,r,n,i=Mr){super(e,r,n,i),this.core=e,this.logger=r,this.name=n,this.map=new Map,this.version=Lg,this.cached=[],this.initialized=!1,this.storagePrefix=Mr,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(s=>{rl(s)?this.map.set(s.id,s):nl(s)&&this.map.set(s.topic,s)}),this.cached=[],this.initialized=!0)},this.set=async(s,c)=>{this.isInitialized(),this.map.has(s)?await this.update(s,c):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:s,value:c}),this.map.set(s,c),await this.persist())},this.get=s=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:s}),this.getData(s)),this.getAll=s=>s?this.values.filter(c=>Object.keys(s).every(u=>Bd(c[u],s[u]))):this.values,this.update=async(s,c)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:s,update:c});const u=va(va({},this.getData(s)),c);this.map.set(s,u),await this.persist()},this.delete=async(s,c)=>{this.isInitialized(),this.map.has(s)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:s,reason:c}),this.map.delete(s),await this.persist())},this.logger=Oe.generateChildLogger(r,this.name),this.storagePrefix=i}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const r=this.map.get(e);if(!r){const{message:n}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:r}=G("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Zg=Object.defineProperty,ya=Object.getOwnPropertySymbols,Qg=Object.prototype.hasOwnProperty,ev=Object.prototype.propertyIsEnumerable,_a=(t,e,r)=>e in t?Zg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ba=(t,e)=>{for(var r in e||(e={}))Qg.call(e,r)&&_a(t,r,e[r]);if(ya)for(var r of ya(e))ev.call(e,r)&&_a(t,r,e[r]);return t};class Ii extends ld{constructor(e){super(e),this.protocol=aa,this.version=lg,this.name=Si,this.events=new cn.EventEmitter,this.initialized=!1,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.projectId=e?.projectId;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:oi(Oe.getDefaultLoggerOptions({level:e?.logger||dg.logger}));this.logger=Oe.generateChildLogger(r,this.name),this.heartbeat=new Pr.HeartBeat,this.crypto=new Rg(this,this.logger,e?.keychain),this.storage=e!=null&&e.storage?e.storage:new rd(ba(ba({},pg),e?.storageOptions)),this.relayer=new kg({core:this,logger:this.logger,relayUrl:e?.relayUrl,projectId:this.projectId})}static async init(e){const r=new Ii(e);return await r.initialize(),r}get context(){return Oe.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.relayer.init(),await this.heartbeat.init(),this.initialized=!0,this.logger.info("Core Initilization Success")}catch(e){throw this.logger.info("Core Initilization Failure"),this.logger.error(e.message),e}}}const tv=Ii;var dr={exports:{}},pr=typeof Reflect=="object"?Reflect:null,ma=pr&&typeof pr.apply=="function"?pr.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},fn;pr&&typeof pr.ownKeys=="function"?fn=pr.ownKeys:Object.getOwnPropertySymbols?fn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:fn=function(e){return Object.getOwnPropertyNames(e)};function rv(t){console&&console.warn&&console.warn(t)}var wa=Number.isNaN||function(e){return e!==e};function xe(){xe.init.call(this)}dr.exports=xe,dr.exports.once=ov,xe.EventEmitter=xe,xe.prototype._events=void 0,xe.prototype._eventsCount=0,xe.prototype._maxListeners=void 0;var Ea=10;function ln(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(xe,"defaultMaxListeners",{enumerable:!0,get:function(){return Ea},set:function(t){if(typeof t!="number"||t<0||wa(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Ea=t}}),xe.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},xe.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||wa(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function Da(t){return t._maxListeners===void 0?xe.defaultMaxListeners:t._maxListeners}xe.prototype.getMaxListeners=function(){return Da(this)},xe.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var c;if(r.length>0&&(c=r[0]),c instanceof Error)throw c;var u=new Error("Unhandled error."+(c?" ("+c.message+")":""));throw u.context=c,u}var h=s[e];if(h===void 0)return!1;if(typeof h=="function")ma(h,this,r);else for(var l=h.length,p=Ia(h,l),n=0;n<l;++n)ma(p[n],this,r);return!0};function xa(t,e,r,n){var i,s,c;if(ln(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),c=s[e]),c===void 0)c=s[e]=r,++t._eventsCount;else if(typeof c=="function"?c=s[e]=n?[r,c]:[c,r]:n?c.unshift(r):c.push(r),i=Da(t),i>0&&c.length>i&&!c.warned){c.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=c.length,rv(u)}return t}xe.prototype.addListener=function(e,r){return xa(this,e,r,!1)},xe.prototype.on=xe.prototype.addListener,xe.prototype.prependListener=function(e,r){return xa(this,e,r,!0)};function nv(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Sa(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=nv.bind(n);return i.listener=r,n.wrapFn=i,i}xe.prototype.once=function(e,r){return ln(r),this.on(e,Sa(this,e,r)),this},xe.prototype.prependOnceListener=function(e,r){return ln(r),this.prependListener(e,Sa(this,e,r)),this},xe.prototype.removeListener=function(e,r){var n,i,s,c,u;if(ln(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,c=n.length-1;c>=0;c--)if(n[c]===r||n[c].listener===r){u=n[c].listener,s=c;break}if(s<0)return this;s===0?n.shift():iv(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,u||r)}return this},xe.prototype.off=xe.prototype.removeListener,xe.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),c;for(i=0;i<s.length;++i)c=s[i],c!=="removeListener"&&this.removeAllListeners(c);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function Oa(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?sv(i):Ia(i,i.length)}xe.prototype.listeners=function(e){return Oa(this,e,!0)},xe.prototype.rawListeners=function(e){return Oa(this,e,!1)},xe.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Aa.call(t,e)},xe.prototype.listenerCount=Aa;function Aa(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}xe.prototype.eventNames=function(){return this._eventsCount>0?fn(this._events):[]};function Ia(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function iv(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function sv(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function ov(t,e){return new Promise(function(r,n){function i(c){t.removeListener(e,s),n(c)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}La(t,e,s,{once:!0}),e!=="error"&&av(t,i,{once:!0})})}function av(t,e,r){typeof t.on=="function"&&La(t,"error",e,r)}function La(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}const Ca="wc",Ta=2,Na="client",$r=`${Ca}@${Ta}:${Na}:`,Li={name:Na,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},cv="expirer",Dt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},uv="0.3",Lt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},hv="history",fv="0.3",lv="pairing",dv="proposal",Pa=ar(Le.THIRTY_DAYS),pv="session",gv=Le.SEVEN_DAYS,dn=ar(gv),vv="engine",Ci={wc_pairingDelete:{req:{prompt:!1,tag:1e3},res:{prompt:!1,tag:1001}},wc_pairingPing:{req:{prompt:!1,tag:1002},res:{prompt:!1,tag:1003}},wc_sessionPropose:{req:{prompt:!0,tag:1100},res:{prompt:!1,tag:1101}},wc_sessionSettle:{req:{prompt:!1,tag:1102},res:{prompt:!1,tag:1103}},wc_sessionUpdate:{req:{prompt:!1,tag:1104},res:{prompt:!1,tag:1105}},wc_sessionExtend:{req:{prompt:!1,tag:1106},res:{prompt:!1,tag:1107}},wc_sessionRequest:{req:{prompt:!0,tag:1108},res:{prompt:!1,tag:1109}},wc_sessionEvent:{req:{prompt:!0,tag:1110},res:{prompt:!1,tag:1111}},wc_sessionDelete:{req:{prompt:!1,tag:1112},res:{prompt:!1,tag:1113}},wc_sessionPing:{req:{prompt:!1,tag:1114},res:{prompt:!1,tag:1115}}};var yv=Object.defineProperty,_v=Object.defineProperties,bv=Object.getOwnPropertyDescriptors,Ra=Object.getOwnPropertySymbols,mv=Object.prototype.hasOwnProperty,wv=Object.prototype.propertyIsEnumerable,Fa=(t,e,r)=>e in t?yv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ht=(t,e)=>{for(var r in e||(e={}))mv.call(e,r)&&Fa(t,r,e[r]);if(Ra)for(var r of Ra(e))wv.call(e,r)&&Fa(t,r,e[r]);return t},Ua=(t,e)=>_v(t,bv(e));class Ev extends Ed{constructor(e){super(e),this.events=new dr.exports,this.initialized=!1,this.name=vv,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0)},this.connect=async r=>{this.isInitialized(),await this.isValidConnect(r);const{pairingTopic:n,requiredNamespaces:i,relays:s}=r;let c=n,u,h=!1;if(c&&(h=this.client.pairing.get(c).active),!c||!h){const{topic:y,uri:O}=await this.createPairing();c=y,u=O}const l=await this.client.core.crypto.generateKeyPair(),p={requiredNamespaces:i,relays:s??[{protocol:ua}],proposer:{publicKey:l,metadata:this.client.metadata}},{reject:E,resolve:T,done:w}=Yt();if(this.events.once(Fe("session_connect"),async({error:y,session:O})=>{if(y)E(y);else if(O){O.self.publicKey=l;const N=Ua(Ht({},O),{requiredNamespaces:i});await this.client.session.set(O.topic,N),await this.setExpiry(O.topic,O.expiry),c&&await this.client.pairing.update(c,{peerMetadata:O.peer.metadata}),T(N)}}),!c){const{message:y}=G("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(y)}const b=await this.sendRequest(c,"wc_sessionPropose",p),F=ar(Le.FIVE_MINUTES);return await this.setProposal(b,Ht({id:b,expiry:F},p)),{uri:u,approval:w}},this.pair=async r=>{this.isInitialized(),this.isValidPair(r);const{topic:n,symKey:i,relay:s}=Vf(r.uri),c=ar(Le.FIVE_MINUTES),u={topic:n,relay:s,expiry:c,active:!1};return await this.client.pairing.set(n,u),await this.client.core.crypto.setSymKey(i,n),await this.client.core.relayer.subscribe(n,{relay:s}),await this.setExpiry(n,c),u},this.approve=async r=>{this.isInitialized(),await this.isValidApprove(r);const{id:n,relayProtocol:i,namespaces:s}=r,{pairingTopic:c,proposer:u,requiredNamespaces:h}=this.client.proposal.get(n),l=await this.client.core.crypto.generateKeyPair(),p=u.publicKey,E=await this.client.core.crypto.generateSharedKey(l,p),T={relay:{protocol:i??"irn"},namespaces:s,requiredNamespaces:h,controller:{publicKey:l,metadata:this.client.metadata},expiry:dn};await this.client.core.relayer.subscribe(E);const w=await this.sendRequest(E,"wc_sessionSettle",T),{done:b,resolve:F,reject:y}=Yt();this.events.once(Fe("session_approve",w),({error:N})=>{N?y(N):F(this.client.session.get(E))});const O=Ua(Ht({},T),{topic:E,acknowledged:!1,self:T.controller,peer:{publicKey:u.publicKey,metadata:u.metadata},controller:l});return await this.client.session.set(E,O),await this.setExpiry(E,dn),c&&await this.client.pairing.update(c,{peerMetadata:O.peer.metadata}),c&&n&&(await this.sendResult(n,c,{relay:{protocol:i??"irn"},responderPublicKey:l}),await this.client.proposal.delete(n,rt("USER_DISCONNECTED")),await this.activatePairing(c)),{topic:E,acknowledged:b}},this.reject=async r=>{this.isInitialized(),await this.isValidReject(r);const{id:n,reason:i}=r,{pairingTopic:s}=this.client.proposal.get(n);s&&(await this.sendError(n,s,i),await this.client.proposal.delete(n,rt("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.isValidUpdate(r);const{topic:n,namespaces:i}=r,s=await this.sendRequest(n,"wc_sessionUpdate",{namespaces:i}),{done:c,resolve:u,reject:h}=Yt();return this.events.once(Fe("session_update",s),({error:l})=>{l?h(l):u()}),await this.client.session.update(n,{namespaces:i}),{acknowledged:c}},this.extend=async r=>{this.isInitialized(),await this.isValidExtend(r);const{topic:n}=r,i=await this.sendRequest(n,"wc_sessionExtend",{}),{done:s,resolve:c,reject:u}=Yt();return this.events.once(Fe("session_extend",i),({error:h})=>{h?u(h):c()}),await this.setExpiry(n,dn),{acknowledged:s}},this.request=async r=>{this.isInitialized(),await this.isValidRequest(r);const{chainId:n,request:i,topic:s}=r,c=await this.sendRequest(s,"wc_sessionRequest",{request:i,chainId:n}),{done:u,resolve:h,reject:l}=Yt();return this.events.once(Fe("session_request",c),({error:p,result:E})=>{p?l(p):h(E)}),await u()},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:n,response:i}=r,{id:s}=i;Pt(i)?await this.sendResult(s,n,i.result):wt(i)&&await this.sendError(s,n,i.error)},this.ping=async r=>{this.isInitialized(),await this.isValidPing(r);const{topic:n}=r;if(this.client.session.keys.includes(n)){const i=await this.sendRequest(n,"wc_sessionPing",{}),{done:s,resolve:c,reject:u}=Yt();this.events.once(Fe("session_ping",i),({error:h})=>{h?u(h):c()}),await s()}else if(this.client.pairing.keys.includes(n)){const i=await this.sendRequest(n,"wc_pairingPing",{}),{done:s,resolve:c,reject:u}=Yt();this.events.once(Fe("pairing_ping",i),({error:h})=>{h?u(h):c()}),await s()}},this.emit=async r=>{this.isInitialized(),await this.isValidEmit(r);const{topic:n,event:i,chainId:s}=r;await this.sendRequest(n,"wc_sessionEvent",{event:i,chainId:s})},this.disconnect=async r=>{this.isInitialized(),await this.isValidDisconnect(r);const{topic:n}=r;this.client.session.keys.includes(n)?(await this.sendRequest(n,"wc_sessionDelete",rt("USER_DISCONNECTED")),await this.deleteSession(n)):this.client.pairing.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",rt("USER_DISCONNECTED")),await this.deletePairing(n))},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(n=>Qf(n,r))),this.activatePairing=async r=>{await this.client.pairing.update(r,{active:!0,expiry:Pa}),await this.setExpiry(r,Pa)},this.deleteSession=async r=>{const{self:n}=this.client.session.get(r);await Promise.all([this.client.core.relayer.unsubscribe(r),this.client.session.delete(r,rt("USER_DISCONNECTED")),this.client.core.crypto.deleteKeyPair(n.publicKey),this.client.core.crypto.deleteSymKey(r),this.client.expirer.del(r)])},this.deletePairing=async r=>{await Promise.all([this.client.core.relayer.unsubscribe(r),this.client.pairing.delete(r,rt("USER_DISCONNECTED")),this.client.core.crypto.deleteSymKey(r),this.client.expirer.del(r)])},this.deleteProposal=async r=>{await Promise.all([this.client.proposal.delete(r,rt("USER_DISCONNECTED")),this.client.expirer.del(r)])},this.setExpiry=async(r,n)=>{this.client.pairing.keys.includes(r)?await this.client.pairing.update(r,{expiry:n}):this.client.session.keys.includes(r)&&await this.client.session.update(r,{expiry:n}),this.client.expirer.set(r,n)},this.setProposal=async(r,n)=>{await this.client.proposal.set(r,n),this.client.expirer.set(r,n.expiry)},this.sendRequest=async(r,n,i)=>{const s=xn(n,i),c=await this.client.core.crypto.encode(r,s),u=Ci[n].req;return await this.client.core.relayer.publish(r,c,u),this.client.history.set(r,s),s.id},this.sendResult=async(r,n,i)=>{const s=Sn(r,i),c=await this.client.core.crypto.encode(n,s),u=await this.client.history.get(n,r),h=Ci[u.request.method].res;await this.client.core.relayer.publish(n,c,h),await this.client.history.resolve(s)},this.sendError=async(r,n,i)=>{const s=qr(r,i),c=await this.client.core.crypto.encode(n,s),u=await this.client.history.get(n,r),h=Ci[u.request.method].res;await this.client.core.relayer.publish(n,c,h),await this.client.history.resolve(s)},this.cleanup=async()=>{const r=[],n=[],i=[];this.client.session.getAll().forEach(s=>{kt(s.expiry)&&r.push(s.topic)}),this.client.pairing.getAll().forEach(s=>{kt(s.expiry)&&n.push(s.topic)}),this.client.proposal.getAll().forEach(s=>{kt(s.expiry)&&i.push(s.id)}),await Promise.all([...r.map(this.deleteSession),...n.map(this.deletePairing),...i.map(this.deleteProposal)])},this.onRelayEventRequest=r=>{const{topic:n,payload:i}=r,s=i.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeRequest(n,i);case"wc_sessionSettle":return this.onSessionSettleRequest(n,i);case"wc_sessionUpdate":return this.onSessionUpdateRequest(n,i);case"wc_sessionExtend":return this.onSessionExtendRequest(n,i);case"wc_sessionPing":return this.onSessionPingRequest(n,i);case"wc_pairingPing":return this.onPairingPingRequest(n,i);case"wc_sessionDelete":return this.onSessionDeleteRequest(n,i);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,i);case"wc_sessionRequest":return this.onSessionRequest(n,i);case"wc_sessionEvent":return this.onSessionEventRequest(n,i);default:return this.client.logger.info(`Unsupported request method ${s}`)}},this.onRelayEventResponse=async r=>{const{topic:n,payload:i}=r,s=(await this.client.history.get(n,i.id)).request.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeResponse(n,i);case"wc_sessionSettle":return this.onSessionSettleResponse(n,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(n,i);case"wc_sessionExtend":return this.onSessionExtendResponse(n,i);case"wc_sessionPing":return this.onSessionPingResponse(n,i);case"wc_pairingPing":return this.onPairingPingResponse(n,i);case"wc_sessionRequest":return this.onSessionRequestResponse(n,i);default:return this.client.logger.info(`Unsupported response method ${s}`)}},this.onSessionProposeRequest=async(r,n)=>{const{params:i,id:s}=n;try{this.isValidConnect(Ht({},n.params));const c=ar(Le.FIVE_MINUTES),u=Ht({id:s,pairingTopic:r,expiry:c},i);await this.setProposal(s,u),this.client.events.emit("session_proposal",{id:s,params:u})}catch(c){await this.sendError(s,r,c),this.client.logger.error(c)}},this.onSessionProposeResponse=async(r,n)=>{const{id:i}=n;if(Pt(n)){const{result:s}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:s});const c=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:c});const u=c.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:u});const h=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:h});const l=await this.client.core.crypto.generateSharedKey(u,h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:l});const p=await this.client.core.relayer.subscribe(l);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:p}),await this.activatePairing(r)}else wt(n)&&(await this.client.proposal.delete(i,rt("USER_DISCONNECTED")),this.events.emit(Fe("session_connect"),{error:n.error}))},this.onSessionSettleRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidSessionSettleRequest(s);const{relay:c,controller:u,expiry:h,namespaces:l}=n.params,p={topic:r,relay:c,expiry:h,namespaces:l,acknowledged:!0,controller:u.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:u.publicKey,metadata:u.metadata}};await this.sendResult(n.id,r,!0),this.events.emit(Fe("session_connect"),{session:p})}catch(c){await this.sendError(i,r,c),this.client.logger.error(c)}},this.onSessionSettleResponse=async(r,n)=>{const{id:i}=n;Pt(n)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Fe("session_approve",i),{})):wt(n)&&(await this.client.session.delete(r,rt("USER_DISCONNECTED")),this.events.emit(Fe("session_approve",i),{error:n.error}))},this.onSessionUpdateRequest=async(r,n)=>{const{params:i,id:s}=n;try{this.isValidUpdate(Ht({topic:r},i)),await this.client.session.update(r,{namespaces:i.namespaces}),await this.sendResult(s,r,!0),this.client.events.emit("session_update",{id:s,topic:r,params:i})}catch(c){await this.sendError(s,r,c),this.client.logger.error(c)}},this.onSessionUpdateResponse=(r,n)=>{const{id:i}=n;Pt(n)?this.events.emit(Fe("session_update",i),{}):wt(n)&&this.events.emit(Fe("session_update",i),{error:n.error})},this.onSessionExtendRequest=async(r,n)=>{const{id:i}=n;try{this.isValidExtend({topic:r}),await this.setExpiry(r,dn),await this.sendResult(i,r,!0),this.client.events.emit("session_extend",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionExtendResponse=(r,n)=>{const{id:i}=n;Pt(n)?this.events.emit(Fe("session_extend",i),{}):wt(n)&&this.events.emit(Fe("session_extend",i),{error:n.error})},this.onSessionPingRequest=async(r,n)=>{const{id:i}=n;try{this.isValidPing({topic:r}),await this.sendResult(i,r,!0),this.client.events.emit("session_ping",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionPingResponse=(r,n)=>{const{id:i}=n;Pt(n)?this.events.emit(Fe("session_ping",i),{}):wt(n)&&this.events.emit(Fe("session_ping",i),{error:n.error})},this.onPairingPingRequest=async(r,n)=>{const{id:i}=n;try{this.isValidPing({topic:r}),await this.sendResult(i,r,!0),this.client.events.emit("pairing_ping",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onPairingPingResponse=(r,n)=>{const{id:i}=n;Pt(n)?this.events.emit(Fe("pairing_ping",i),{}):wt(n)&&this.events.emit(Fe("pairing_ping",i),{error:n.error})},this.onSessionDeleteRequest=async(r,n)=>{const{id:i}=n;try{this.isValidDisconnect({topic:r,reason:n.params}),await this.sendResult(i,r,!0),await this.deleteSession(r),this.client.events.emit("session_delete",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onPairingDeleteRequest=async(r,n)=>{const{id:i}=n;try{this.isValidDisconnect({topic:r,reason:n.params}),await this.sendResult(i,r,!0),await this.deletePairing(r),this.client.events.emit("pairing_delete",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidRequest(Ht({topic:r},s)),this.client.events.emit("session_request",{id:i,topic:r,params:s})}catch(c){await this.sendError(i,r,c),this.client.logger.error(c)}},this.onSessionRequestResponse=(r,n)=>{const{id:i}=n;Pt(n)?this.events.emit(Fe("session_request",i),{result:n.result}):wt(n)&&this.events.emit(Fe("session_request",i),{error:n.error})},this.onSessionEventRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidEmit(Ht({topic:r},s)),this.client.events.emit("session_event",{id:i,topic:r,params:s})}catch(c){await this.sendError(i,r,c),this.client.logger.error(c)}},this.isValidConnect=async r=>{if(!yt(r)){const{message:u}=G("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(u)}const{pairingTopic:n,requiredNamespaces:i,relays:s}=r;Et(n)||await this.isValidPairingTopic(n);const c=al(i,"connect()");if(c)throw new Error(c.message);if(!cl(s,!0)){const{message:u}=G("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(u)}},this.isValidPair=r=>{if(!yt(r)){const{message:n}=G("MISSING_OR_INVALID",`pair() params: ${r}`);throw new Error(n)}if(!tl(r.uri)){const{message:n}=G("MISSING_OR_INVALID",`pair() uri: ${r.uri}`);throw new Error(n)}},this.isValidApprove=async r=>{if(!yt(r))throw new Error(G("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:n,namespaces:i,relayProtocol:s}=r;await this.isValidProposalId(n);const c=this.client.proposal.get(n),u=si(i,"approve()");if(u)throw new Error(u.message);const h=_o(c.requiredNamespaces,i,"update()");if(h)throw new Error(h.message);if(!ot(s,!0)){const{message:l}=G("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(l)}},this.isValidReject=async r=>{if(!yt(r)){const{message:s}=G("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:n,reason:i}=r;if(await this.isValidProposalId(n),!hl(i)){const{message:s}=G("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidSessionSettleRequest=r=>{if(!yt(r)){const{message:l}=G("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(l)}const{relay:n,controller:i,namespaces:s,expiry:c}=r;if(!vo(n)){const{message:l}=G("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const u=il(i,"onSessionSettleRequest()");if(u)throw new Error(u.message);const h=si(s,"onSessionSettleRequest()");if(h)throw new Error(h.message);if(kt(c)){const{message:l}=G("EXPIRED","onSessionSettleRequest()");throw new Error(l)}},this.isValidUpdate=async r=>{if(!yt(r)){const{message:h}=G("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(h)}const{topic:n,namespaces:i}=r;await this.isValidSessionTopic(n);const s=this.client.session.get(n),c=si(i,"update()");if(c)throw new Error(c.message);const u=_o(s.requiredNamespaces,i,"update()");if(u)throw new Error(u.message)},this.isValidExtend=async r=>{if(!yt(r)){const{message:i}=G("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionTopic(n)},this.isValidRequest=async r=>{if(!yt(r)){const{message:u}=G("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(u)}const{topic:n,request:i,chainId:s}=r;await this.isValidSessionTopic(n);const{namespaces:c}=this.client.session.get(n);if(!yo(c,s)){const{message:u}=G("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(u)}if(!fl(i)){const{message:u}=G("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(u)}if(!pl(c,s,i.method)){const{message:u}=G("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(u)}},this.isValidRespond=async r=>{if(!yt(r)){const{message:s}=G("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(s)}const{topic:n,response:i}=r;if(await this.isValidSessionTopic(n),!ll(i)){const{message:s}=G("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidPing=async r=>{if(!yt(r)){const{message:i}=G("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)},this.isValidEmit=async r=>{if(!yt(r)){const{message:u}=G("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(u)}const{topic:n,event:i,chainId:s}=r;await this.isValidSessionTopic(n);const{namespaces:c}=this.client.session.get(n);if(!yo(c,s)){const{message:u}=G("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(u)}if(!dl(i)){const{message:u}=G("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(u)}if(!gl(c,s,i.name)){const{message:u}=G("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(u)}},this.isValidDisconnect=async r=>{if(!yt(r)){const{message:i}=G("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)}}async createPairing(){const e=ei(),r=await this.client.core.crypto.setSymKey(e),n=ar(Le.FIVE_MINUTES),i={protocol:ua},s={topic:r,expiry:n,relay:i,active:!1},c=Wf({protocol:this.client.protocol,version:this.client.version,topic:r,symKey:e,relay:i});return await this.client.pairing.set(r,s),await this.client.core.relayer.subscribe(r),await this.setExpiry(r,n),{topic:r,uri:c}}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(jr.message,async e=>{const{topic:r,message:n}=e,i=await this.client.core.crypto.decode(r,n);ki(i)?(this.client.history.set(r,i),this.onRelayEventRequest({topic:r,payload:i})):Yi(i)&&(await this.client.history.resolve(i),this.onRelayEventResponse({topic:r,payload:i}))})}registerExpirerEvents(){this.client.expirer.on(Dt.expired,async e=>{const{topic:r,id:n}=jf(e.target);r?this.client.session.keys.includes(r)?(await this.deleteSession(r),this.client.events.emit("session_expire",{topic:r})):this.client.pairing.keys.includes(r)&&(await this.deletePairing(r),this.client.events.emit("pairing_expire",{topic:r})):n&&await this.deleteProposal(n)})}async isValidPairingTopic(e){if(!ot(e,!1)){const{message:r}=G("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(r)}if(!this.client.pairing.keys.includes(e)){const{message:r}=G("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(kt(this.client.pairing.get(e).expiry)){await this.deletePairing(e);const{message:r}=G("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!ot(e,!1)){const{message:r}=G("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(!this.client.session.keys.includes(e)){const{message:r}=G("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(kt(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:r}=G("EXPIRED",`session topic: ${e}`);throw new Error(r)}}async isValidSessionOrPairingTopic(e){if(this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.pairing.keys.includes(e))await this.isValidPairingTopic(e);else if(ot(e,!1)){const{message:r}=G("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=G("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!ul(e)){const{message:r}=G("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=G("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(kt(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:r}=G("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class Dv extends Dd{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new dr.exports.EventEmitter,this.name=cv,this.version=uv,this.cached=[],this.initialized=!1,this.storagePrefix=$r,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=n=>{try{const i=this.formatTarget(n);return typeof this.getExpiration(i)<"u"}catch{return!1}},this.set=(n,i)=>{this.isInitialized();const s=this.formatTarget(n),c={target:s,expiry:i};this.expirations.set(s,c),this.checkExpiry(s,c),this.events.emit(Dt.created,{target:s,expiration:c})},this.get=n=>{this.isInitialized();const i=this.formatTarget(n);return this.getExpiration(i)},this.del=n=>{this.isInitialized();const i=this.formatTarget(n);if(this.has(i)){const s=this.getExpiration(i);this.expirations.delete(i),this.events.emit(Dt.deleted,{target:i,expiration:s})}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return Uf(e);if(typeof e=="number")return Mf(e);const{message:r}=G("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(r)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Dt.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=G("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const r=this.expirations.get(e);if(!r){const{message:n}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}return r}checkExpiry(e,r){const{expiry:n}=r;Le.toMiliseconds(n)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(Dt.expired,{target:e,expiration:r})}checkExpirations(){this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(Pr.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(Dt.created,e=>{const r=Dt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Dt.expired,e=>{const r=Dt.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Dt.deleted,e=>{const r=Dt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}class xv extends dd{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new dr.exports.EventEmitter,this.name=hv,this.version=fv,this.cached=[],this.initialized=!1,this.storagePrefix=$r,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(n,i,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:n,request:i,chainId:s}),this.records.has(i.id))return;const c={id:i.id,topic:n,request:{method:i.method,params:i.params||null},chainId:s};this.records.set(c.id,c),this.events.emit(Lt.created,c)},this.resolve=async n=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:n}),!this.records.has(n.id))return;const i=await this.getRecord(n.id);typeof i.response>"u"&&(i.response=wt(n)?{error:n.error}:{result:n.result},this.records.set(i.id,i),this.events.emit(Lt.updated,i))},this.get=async(n,i)=>{this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:i});const s=await this.getRecord(i);if(s.topic!==n){const{message:c}=G("MISMATCHED_TOPIC",`${this.name}, ${i}`);throw this.logger.error(c),new Error(c)}return s},this.delete=(n,i)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:i}),this.values.forEach(s=>{if(s.topic===n){if(typeof i<"u"&&s.id!==i)return;this.records.delete(s.id),this.events.emit(Lt.deleted,s)}})},this.exists=async(n,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===n:!1),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const n={topic:r.topic,request:xn(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(n)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const r=this.records.get(e);if(!r){const{message:n}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Lt.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=G("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Lt.created,e=>{const r=Lt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Lt.updated,e=>{const r=Lt.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Lt.deleted,e=>{const r=Lt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Sv extends Ai{constructor(e,r){super(e,r,lv,$r),this.core=e,this.logger=r}}class Ov extends Ai{constructor(e,r){super(e,r,dv,$r),this.core=e,this.logger=r}}class Av extends Ai{constructor(e,r){super(e,r,pv,$r),this.core=e,this.logger=r}}class Ti extends wd{constructor(e){super(e),this.protocol=Ca,this.version=Ta,this.name=Li.name,this.events=new dr.exports.EventEmitter,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.connect=async n=>{try{return await this.engine.connect(n)}catch(i){throw this.logger.error(i.message),i}},this.pair=async n=>{try{return await this.engine.pair(n)}catch(i){throw this.logger.error(i.message),i}},this.approve=async n=>{try{return await this.engine.approve(n)}catch(i){throw this.logger.error(i.message),i}},this.reject=async n=>{try{return await this.engine.reject(n)}catch(i){throw this.logger.error(i.message),i}},this.update=async n=>{try{return await this.engine.update(n)}catch(i){throw this.logger.error(i.message),i}},this.extend=async n=>{try{return await this.engine.extend(n)}catch(i){throw this.logger.error(i.message),i}},this.request=async n=>{try{return await this.engine.request(n)}catch(i){throw this.logger.error(i.message),i}},this.respond=async n=>{try{return await this.engine.respond(n)}catch(i){throw this.logger.error(i.message),i}},this.ping=async n=>{try{return await this.engine.ping(n)}catch(i){throw this.logger.error(i.message),i}},this.emit=async n=>{try{return await this.engine.emit(n)}catch(i){throw this.logger.error(i.message),i}},this.disconnect=async n=>{try{return await this.engine.disconnect(n)}catch(i){throw this.logger.error(i.message),i}},this.find=n=>{try{return this.engine.find(n)}catch(i){throw this.logger.error(i.message),i}},this.name=e?.name||Li.name,this.metadata=e?.metadata||Tf();const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:oi(Oe.getDefaultLoggerOptions({level:e?.logger||Li.logger}));this.core=e?.core||new tv(e),this.logger=Oe.generateChildLogger(r,this.name),this.pairing=new Sv(this.core,this.logger),this.session=new Av(this.core,this.logger),this.proposal=new Ov(this.core,this.logger),this.history=new xv(this.core,this.logger),this.expirer=new Dv(this.core,this.logger),this.engine=new Ev(this)}static async init(e){const r=new Ti(e);return await r.initialize(),r}get context(){return Oe.getLoggerContext(this.logger)}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.pairing.init(),await this.session.init(),await this.proposal.init(),await this.history.init(),await this.expirer.init(),await this.engine.init(),this.logger.info("SignClient Initilization Success")}catch(e){throw this.logger.info("SignClient Initilization Failure"),this.logger.error(e.message),e}}}function Ge(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var Iv=Ge;Ge.EventEmitter=Ge,Ge.prototype._events=void 0,Ge.prototype._maxListeners=void 0,Ge.defaultMaxListeners=10,Ge.prototype.setMaxListeners=function(t){if(!Lv(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ge.prototype.emit=function(t){var e,r,n,i,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Br(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],Ma(r))return!1;if(Ut(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(Br(r))for(i=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,s=0;s<n;s++)c[s].apply(this,i);return!0},Ge.prototype.addListener=function(t,e){var r;if(!Ut(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Ut(e.listener)?e.listener:e),this._events[t]?Br(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Br(this._events[t])&&!this._events[t].warned&&(Ma(this._maxListeners)?r=Ge.defaultMaxListeners:r=this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),typeof console.trace=="function"&&console.trace())),this},Ge.prototype.on=Ge.prototype.addListener,Ge.prototype.once=function(t,e){if(!Ut(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},Ge.prototype.removeListener=function(t,e){var r,n,i,s;if(!Ut(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],i=r.length,n=-1,r===e||Ut(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(Br(r)){for(s=i;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(n<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},Ge.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[t]&&delete this._events[t],this;if(arguments.length===0){for(e in this._events)e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],Ut(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},Ge.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Ut(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},Ge.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Ut(e))return 1;if(e)return e.length}return 0},Ge.listenerCount=function(t,e){return t.listenerCount(e)};function Ut(t){return typeof t=="function"}function Lv(t){return typeof t=="number"}function Br(t){return typeof t=="object"&&t!==null}function Ma(t){return t===void 0}function Cv(t){return typeof t<"u"&&typeof t.context<"u"}const Ct={init:"signer_init",uri:"signer_uri",created:"signer_created",updated:"signer_updated",deleted:"signer_deleted",event:"signer_event"};class Tv extends uc{constructor(e){super(),this.events=new Iv.EventEmitter,this.pending=!1,this.initializing=!1,this.requiredNamespaces=e?.requiredNamespaces||{},this.opts=e?.client}get connected(){return typeof this.session<"u"}get connecting(){return this.pending}get chains(){return this.session?Yn(this.session.namespaces):lf(this.requiredNamespaces)}get accounts(){return this.session?kn(this.session.namespaces):[]}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(){if(this.pending)return new Promise((e,r)=>{this.events.once("open",()=>{if(this.events.once("open_error",n=>{r(n)}),typeof this.client>"u")return r(new Error("Sign Client not initialized"));e()})});try{this.pending=!0;const e=await this.register(),r=e.find({requiredNamespaces:this.requiredNamespaces});if(r.length)return this.onOpen(r[0]);const{uri:n,approval:i}=await e.connect({requiredNamespaces:this.requiredNamespaces});this.events.emit(Ct.uri,{uri:n}),this.session=await i(),this.events.emit(Ct.created,this.session),this.onOpen()}catch(e){throw this.events.emit("open_error",e),e}}async close(){typeof this.session>"u"||(await(await this.register()).disconnect({topic:this.session.topic,reason:rt("USER_DISCONNECTED")}),this.onClose())}async send(e,r){if(typeof this.client>"u"&&(this.client=await this.register(),this.connected||await this.open()),typeof this.session>"u")throw new Error("Signer connection is missing session");this.client.request({topic:this.session.topic,request:e,chainId:r?.chainId}).then(n=>this.events.emit("payload",Sn(e.id,n))).catch(n=>this.events.emit("payload",qr(e.id,n.message)))}async register(e=this.opts){if(typeof this.client<"u")return this.client;if(this.initializing)return new Promise((r,n)=>{this.events.once("register_error",i=>{n(i)}),this.events.once(Ct.init,()=>{if(typeof this.client>"u")return n(new Error("Sign Client not initialized"));r(this.client)})});if(Cv(e))return this.client=e,this.registerEventListeners(),this.client;try{return this.initializing=!0,this.client=await Ti.init(e),this.initializing=!1,this.registerEventListeners(),this.events.emit(Ct.init),this.client}catch(r){throw this.events.emit("register_error",r),r}}onOpen(e){this.pending=!1,e&&(this.session=e),this.events.emit("open")}onClose(){this.pending=!1,this.client&&(this.client=void 0),this.events.emit("close")}registerEventListeners(){typeof this.client<"u"&&(this.client.on("session_event",e=>{var r;this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||this.events.emit(Ct.event,e.params)}),this.client.on("session_update",e=>{var r;typeof this.client<"u"&&(this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||(this.session=this.client.session.get(e.topic),this.events.emit(Ct.updated,this.session)))}),this.client.on("session_delete",e=>{var r;!this.session||this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||(this.onClose(),this.events.emit(Ct.deleted,this.session),this.session=void 0)}))}}const Nv=["eth_requestAccounts","eth_accounts","eth_chainId","eth_sendTransaction","eth_signTransaction","eth_sign","eth_signTypedData","personal_sign"],Pv=["chainChanged","accountsChanged"];function ja(t){return{chains:t!=null&&t.chainId?[`eip155:${t.chainId}`]:[],methods:t?.methods||[],events:t?.events||[],rpcMap:t?.rpcMap||void 0}}function $a(t,e){let r;return e.rpcMap&&(r=e.rpcMap[Ni([t])]),r}function Ni(t){return Number(t[0].split(":")[1])}class Rv{constructor(e){this.events=new vr.EventEmitter,this.namespace="eip155",this.accounts=[],this.rpc=ja(e),this.signer=this.setSignerProvider(e?.client),this.chainId=Ni(this.rpc.chains),this.http=this.setHttpProvider(this.chainId),this.registerEventListeners()}async request(e){switch(e.method){case"eth_requestAccounts":return await this.connect(),this.accounts;case"eth_accounts":return this.accounts;case"eth_chainId":return this.chainId}if(e.method.startsWith("eth_signTypedData")||this.rpc.methods.includes(e.method))return this.signer.request(e,{chainId:this.formatChainId(this.chainId)});if(typeof this.http>"u")throw new Error(`Cannot request JSON-RPC method (${e.method}) without provided rpc url`);return this.http.request(e)}sendAsync(e,r){this.request(e).then(n=>r(null,n)).catch(n=>r(n,void 0))}get connected(){return this.signer.connection.connected}get connecting(){return this.signer.connection.connecting}async enable(){return await this.request({method:"eth_requestAccounts"})}async connect(){await this.signer.connect()}async disconnect(){await this.signer.disconnect()}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}registerEventListeners(){this.signer.on("connect",()=>{const e=this.signer.connection.chains;e&&e.length&&this.setChainIds(e);const r=this.signer.connection.accounts;r&&r.length&&this.setAccounts(r)}),this.signer.connection.on(Ct.created,e=>{const r=Yn(e.namespaces,[this.namespace]);this.setChainIds(r);const n=kn(e.namespaces,[this.namespace]);this.setAccounts(n)}),this.signer.connection.on(Ct.updated,e=>{const r=Yn(e.namespaces,[this.namespace]);this.setChainIds(r);const n=kn(e.namespaces,[this.namespace]);n!==this.accounts&&this.setAccounts(n)}),this.signer.connection.on(Ct.event,e=>{if(!this.rpc.chains.includes(e.chainId))return;const{event:r}=e;r.name==="accountsChanged"?(this.accounts=r.data,this.events.emit("accountsChanged",this.accounts)):r.name==="chainChanged"?this.setChainId(r.data):this.events.emit(r.name,r.data)}),this.signer.on("disconnect",()=>{this.events.emit("disconnect")}),this.events.on("chainChanged",e=>this.setHttpProvider(e))}setSignerProvider(e){const r=new Tv({requiredNamespaces:{[this.namespace]:{chains:this.rpc.chains,methods:this.rpc.methods,events:this.rpc.events}},client:e});return new On(r)}setHttpProvider(e){const r=$a(`${this.namespace}:${e}`,this.rpc);return typeof r>"u"?void 0:new On(new vc(r))}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const r=e.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n)).filter(n=>n!==this.chainId);r.length&&(this.chainId=r[0],this.events.emit("chainChanged",this.chainId))}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.events.emit("chainChanged",this.chainId)}}parseAccountId(e){const[r,n,i]=e.split(":");return{chainId:`${r}:${n}`,address:i}}setAccounts(e){this.accounts=e.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}}mt.default=Rv,mt.getEthereumChainId=Ni,mt.getRpcConfig=ja,mt.getRpcUrl=$a,mt.signerEvents=Pv,mt.signerMethods=Nv,Object.defineProperty(mt,"__esModule",{value:!0})});
1
+ (function(mt,Z){typeof exports=="object"&&typeof module<"u"?Z(exports):typeof define=="function"&&define.amd?define(["exports"],Z):(mt=typeof globalThis<"u"?globalThis:mt||self,Z(mt["@walletconnect/ethereum-provider"]={}))})(this,function(mt){"use strict";var Z=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Xa(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function wn(t){var e=t.default;if(typeof e=="function"){var r=function(){return e.apply(this,arguments)};r.prototype=e.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(t).forEach(function(n){var i=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return t[n]}})}),r}function Ke(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var vr=Ke;Ke.EventEmitter=Ke,Ke.prototype._events=void 0,Ke.prototype._maxListeners=void 0,Ke.defaultMaxListeners=10,Ke.prototype.setMaxListeners=function(t){if(!Za(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ke.prototype.emit=function(t){var e,r,n,i,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||yr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],Ri(r))return!1;if(Nt(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(yr(r))for(i=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,s=0;s<n;s++)c[s].apply(this,i);return!0},Ke.prototype.addListener=function(t,e){var r;if(!Nt(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Nt(e.listener)?e.listener:e),this._events[t]?yr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,yr(this._events[t])&&!this._events[t].warned&&(Ri(this._maxListeners)?r=Ke.defaultMaxListeners:r=this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),typeof console.trace=="function"&&console.trace())),this},Ke.prototype.on=Ke.prototype.addListener,Ke.prototype.once=function(t,e){if(!Nt(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},Ke.prototype.removeListener=function(t,e){var r,n,i,s;if(!Nt(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],i=r.length,n=-1,r===e||Nt(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(yr(r)){for(s=i;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(n<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},Ke.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[t]&&delete this._events[t],this;if(arguments.length===0){for(e in this._events)e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],Nt(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},Ke.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Nt(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},Ke.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Nt(e))return 1;if(e)return e.length}return 0},Ke.listenerCount=function(t,e){return t.listenerCount(e)};function Nt(t){return typeof t=="function"}function Za(t){return typeof t=="number"}function yr(t){return typeof t=="object"&&t!==null}function Ri(t){return t===void 0}const Qa="PARSE_ERROR",ec="INVALID_REQUEST",tc="METHOD_NOT_FOUND",rc="INVALID_PARAMS",Fi="INTERNAL_ERROR",En="SERVER_ERROR",nc=[-32700,-32600,-32601,-32602,-32603],_r={[Qa]:{code:-32700,message:"Parse error"},[ec]:{code:-32600,message:"Invalid Request"},[tc]:{code:-32601,message:"Method not found"},[rc]:{code:-32602,message:"Invalid params"},[Fi]:{code:-32603,message:"Internal error"},[En]:{code:-32e3,message:"Server error"}},Ui=En;function ic(t){return nc.includes(t)}function Mi(t){return Object.keys(_r).includes(t)?_r[t]:_r[Ui]}function sc(t){const e=Object.values(_r).find(r=>r.code===t);return e||_r[Ui]}function ji(t,e,r){return t.message.includes("getaddrinfo ENOTFOUND")||t.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):t}var $i={},$t={};Object.defineProperty($t,"__esModule",{value:!0}),$t.isBrowserCryptoAvailable=$t.getSubtleCrypto=$t.getBrowerCrypto=void 0;function Dn(){return Z?.crypto||Z?.msCrypto||{}}$t.getBrowerCrypto=Dn;function Bi(){const t=Dn();return t.subtle||t.webkitSubtle}$t.getSubtleCrypto=Bi;function oc(){return!!Dn()&&!!Bi()}$t.isBrowserCryptoAvailable=oc;var Bt={};Object.defineProperty(Bt,"__esModule",{value:!0}),Bt.isBrowser=Bt.isNode=Bt.isReactNative=void 0;function zi(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Bt.isReactNative=zi;function Hi(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}Bt.isNode=Hi;function ac(){return!zi()&&!Hi()}Bt.isBrowser=ac,function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r($t,t),r(Bt,t)}($i);function cc(){const t=Date.now()*Math.pow(10,3),e=Math.floor(Math.random()*Math.pow(10,3));return t+e}function xn(t,e,r){return{id:r||cc(),jsonrpc:"2.0",method:t,params:e}}function Sn(t,e){return{id:t,jsonrpc:"2.0",result:e}}function qr(t,e,r){return{id:t,jsonrpc:"2.0",error:uc(e,r)}}function uc(t,e){return typeof t>"u"?Mi(Fi):(typeof t=="string"&&(t=Object.assign(Object.assign({},Mi(En)),{message:t})),typeof e<"u"&&(t.data=e),ic(t.code)&&(t=sc(t.code)),t)}class Ki{}class hc extends Ki{constructor(e){super()}}class fc extends Ki{constructor(){super()}}class lc extends fc{constructor(e){super()}}const dc="^https?:",pc="^wss?:";function gc(t){const e=t.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function qi(t,e){const r=gc(t);return typeof r>"u"?!1:new RegExp(e).test(r)}function Vi(t){return qi(t,dc)}function Gi(t){return qi(t,pc)}function vc(t){return new RegExp("wss?://localhost(:d{2,5})?").test(t)}function Wi(t){return typeof t=="object"&&"id"in t&&"jsonrpc"in t&&t.jsonrpc==="2.0"}function ki(t){return Wi(t)&&"method"in t}function Yi(t){return Wi(t)&&(Pt(t)||wt(t))}function Pt(t){return"result"in t}function wt(t){return"error"in t}class On extends lc{constructor(e){super(e),this.events=new vr.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,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async request(e,r){return this.requestStrict(xn(e.method,e.params||[]),r)}async requestStrict(e,r){return new Promise(async(n,i)=>{if(!this.connection.connected)try{await this.open()}catch(s){i(s)}this.events.on(`${e.id}`,s=>{wt(s)?i(s.error):n(s.result)});try{await this.connection.send(e,r)}catch(s){i(s)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Yi(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(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",()=>this.events.emit("disconnect")),this.connection.on("error",e=>this.events.emit("error",e)),this.hasRegisteredEventListeners=!0)}}var An={exports:{}};(function(t,e){var r=typeof self<"u"?self:Z,n=function(){function s(){this.fetch=!1,this.DOMException=r.DOMException}return s.prototype=r,new s}();(function(s){(function(c){var u={searchParams:"URLSearchParams"in s,iterable:"Symbol"in s&&"iterator"in Symbol,blob:"FileReader"in s&&"Blob"in s&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in s,arrayBuffer:"ArrayBuffer"in s};function h(l){return l&&DataView.prototype.isPrototypeOf(l)}if(u.arrayBuffer)var f=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],g=ArrayBuffer.isView||function(l){return l&&f.indexOf(Object.prototype.toString.call(l))>-1};function w(l){if(typeof l!="string"&&(l=String(l)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(l))throw new TypeError("Invalid character in header field name");return l.toLowerCase()}function T(l){return typeof l!="string"&&(l=String(l)),l}function E(l){var b={next:function(){var U=l.shift();return{done:U===void 0,value:U}}};return u.iterable&&(b[Symbol.iterator]=function(){return b}),b}function v(l){this.map={},l instanceof v?l.forEach(function(b,U){this.append(U,b)},this):Array.isArray(l)?l.forEach(function(b){this.append(b[0],b[1])},this):l&&Object.getOwnPropertyNames(l).forEach(function(b){this.append(b,l[b])},this)}v.prototype.append=function(l,b){l=w(l),b=T(b);var U=this.map[l];this.map[l]=U?U+", "+b:b},v.prototype.delete=function(l){delete this.map[w(l)]},v.prototype.get=function(l){return l=w(l),this.has(l)?this.map[l]:null},v.prototype.has=function(l){return this.map.hasOwnProperty(w(l))},v.prototype.set=function(l,b){this.map[w(l)]=T(b)},v.prototype.forEach=function(l,b){for(var U in this.map)this.map.hasOwnProperty(U)&&l.call(b,this.map[U],U,this)},v.prototype.keys=function(){var l=[];return this.forEach(function(b,U){l.push(U)}),E(l)},v.prototype.values=function(){var l=[];return this.forEach(function(b){l.push(b)}),E(l)},v.prototype.entries=function(){var l=[];return this.forEach(function(b,U){l.push([U,b])}),E(l)},u.iterable&&(v.prototype[Symbol.iterator]=v.prototype.entries);function P(l){if(l.bodyUsed)return Promise.reject(new TypeError("Already read"));l.bodyUsed=!0}function C(l){return new Promise(function(b,U){l.onload=function(){b(l.result)},l.onerror=function(){U(l.error)}})}function $(l){var b=new FileReader,U=C(b);return b.readAsArrayBuffer(l),U}function x(l){var b=new FileReader,U=C(b);return b.readAsText(l),U}function A(l){for(var b=new Uint8Array(l),U=new Array(b.length),q=0;q<b.length;q++)U[q]=String.fromCharCode(b[q]);return U.join("")}function _(l){if(l.slice)return l.slice(0);var b=new Uint8Array(l.byteLength);return b.set(new Uint8Array(l)),b.buffer}function D(){return this.bodyUsed=!1,this._initBody=function(l){this._bodyInit=l,l?typeof l=="string"?this._bodyText=l:u.blob&&Blob.prototype.isPrototypeOf(l)?this._bodyBlob=l:u.formData&&FormData.prototype.isPrototypeOf(l)?this._bodyFormData=l:u.searchParams&&URLSearchParams.prototype.isPrototypeOf(l)?this._bodyText=l.toString():u.arrayBuffer&&u.blob&&h(l)?(this._bodyArrayBuffer=_(l.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):u.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(l)||g(l))?this._bodyArrayBuffer=_(l):this._bodyText=l=Object.prototype.toString.call(l):this._bodyText="",this.headers.get("content-type")||(typeof l=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):u.searchParams&&URLSearchParams.prototype.isPrototypeOf(l)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},u.blob&&(this.blob=function(){var l=P(this);if(l)return l;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(){return this._bodyArrayBuffer?P(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then($)}),this.text=function(){var l=P(this);if(l)return l;if(this._bodyBlob)return x(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(A(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},u.formData&&(this.formData=function(){return this.text().then(M)}),this.json=function(){return this.text().then(JSON.parse)},this}var m=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function o(l){var b=l.toUpperCase();return m.indexOf(b)>-1?b:l}function d(l,b){b=b||{};var U=b.body;if(l instanceof d){if(l.bodyUsed)throw new TypeError("Already read");this.url=l.url,this.credentials=l.credentials,b.headers||(this.headers=new v(l.headers)),this.method=l.method,this.mode=l.mode,this.signal=l.signal,!U&&l._bodyInit!=null&&(U=l._bodyInit,l.bodyUsed=!0)}else this.url=String(l);if(this.credentials=b.credentials||this.credentials||"same-origin",(b.headers||!this.headers)&&(this.headers=new v(b.headers)),this.method=o(b.method||this.method||"GET"),this.mode=b.mode||this.mode||null,this.signal=b.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&U)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(U)}d.prototype.clone=function(){return new d(this,{body:this._bodyInit})};function M(l){var b=new FormData;return l.trim().split("&").forEach(function(U){if(U){var q=U.split("="),R=q.shift().replace(/\+/g," "),N=q.join("=").replace(/\+/g," ");b.append(decodeURIComponent(R),decodeURIComponent(N))}}),b}function K(l){var b=new v,U=l.replace(/\r?\n[\t ]+/g," ");return U.split(/\r?\n/).forEach(function(q){var R=q.split(":"),N=R.shift().trim();if(N){var j=R.join(":").trim();b.append(N,j)}}),b}D.call(d.prototype);function V(l,b){b||(b={}),this.type="default",this.status=b.status===void 0?200:b.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in b?b.statusText:"OK",this.headers=new v(b.headers),this.url=b.url||"",this._initBody(l)}D.call(V.prototype),V.prototype.clone=function(){return new V(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new v(this.headers),url:this.url})},V.error=function(){var l=new V(null,{status:0,statusText:""});return l.type="error",l};var J=[301,302,303,307,308];V.redirect=function(l,b){if(J.indexOf(b)===-1)throw new RangeError("Invalid status code");return new V(null,{status:b,headers:{location:l}})},c.DOMException=s.DOMException;try{new c.DOMException}catch{c.DOMException=function(b,U){this.message=b,this.name=U;var q=Error(b);this.stack=q.stack},c.DOMException.prototype=Object.create(Error.prototype),c.DOMException.prototype.constructor=c.DOMException}function X(l,b){return new Promise(function(U,q){var R=new d(l,b);if(R.signal&&R.signal.aborted)return q(new c.DOMException("Aborted","AbortError"));var N=new XMLHttpRequest;function j(){N.abort()}N.onload=function(){var B={status:N.status,statusText:N.statusText,headers:K(N.getAllResponseHeaders()||"")};B.url="responseURL"in N?N.responseURL:B.headers.get("X-Request-URL");var Q="response"in N?N.response:N.responseText;U(new V(Q,B))},N.onerror=function(){q(new TypeError("Network request failed"))},N.ontimeout=function(){q(new TypeError("Network request failed"))},N.onabort=function(){q(new c.DOMException("Aborted","AbortError"))},N.open(R.method,R.url,!0),R.credentials==="include"?N.withCredentials=!0:R.credentials==="omit"&&(N.withCredentials=!1),"responseType"in N&&u.blob&&(N.responseType="blob"),R.headers.forEach(function(B,Q){N.setRequestHeader(Q,B)}),R.signal&&(R.signal.addEventListener("abort",j),N.onreadystatechange=function(){N.readyState===4&&R.signal.removeEventListener("abort",j)}),N.send(typeof R._bodyInit>"u"?null:R._bodyInit)})}return X.polyfill=!0,s.fetch||(s.fetch=X,s.Headers=v,s.Request=d,s.Response=V),c.Headers=v,c.Request=d,c.Response=V,c.fetch=X,Object.defineProperty(c,"__esModule",{value:!0}),c})({})})(n),n.fetch.ponyfill=!0,delete n.fetch.polyfill;var i=n;e=i.fetch,e.default=i.fetch,e.fetch=i.fetch,e.Headers=i.Headers,e.Request=i.Request,e.Response=i.Response,t.exports=e})(An,An.exports);var Ji=Xa(An.exports);function In(t){if(typeof t!="string")throw new Error(`Cannot safe json parse value of type ${typeof t}`);try{return JSON.parse(t)}catch{return t}}function br(t){return typeof t=="string"?t:JSON.stringify(t)}const Xi={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"},Zi=10;class yc{constructor(e){if(this.url=e,this.events=new vr.EventEmitter,this.isAvailable=!1,this.registering=!1,!Vi(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}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,r){this.isAvailable||await this.register();try{const n=br(e),s=await(await Ji(this.url,Object.assign(Object.assign({},Xi),{body:n}))).json();this.onPayload({data:s})}catch(n){this.onError(e.id,n)}}async register(e=this.url){if(!Vi(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return i(new Error("HTTP connection is missing or invalid"));n()})})}this.url=e,this.registering=!0;try{const r=br({id:1,jsonrpc:"2.0",method:"test",params:[]});await Ji(e,Object.assign(Object.assign({},Xi),{body:r})),this.onOpen()}catch(r){const n=this.parseError(r);throw this.events.emit("register_error",n),this.onClose(),n}}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 r=typeof e.data=="string"?In(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=qr(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return ji(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>Zi&&this.events.setMaxListeners(Zi)}}var Ln={},Vr={},re={},Qi={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});function e(u,h){var f=u>>>16&65535,g=u&65535,w=h>>>16&65535,T=h&65535;return g*T+(f*T+g*w<<16>>>0)|0}t.mul=Math.imul||e;function r(u,h){return u+h|0}t.add=r;function n(u,h){return u-h|0}t.sub=n;function i(u,h){return u<<h|u>>>32-h}t.rotl=i;function s(u,h){return u<<32-h|u>>>h}t.rotr=s;function c(u){return typeof u=="number"&&isFinite(u)&&Math.floor(u)===u}t.isInteger=Number.isInteger||c,t.MAX_SAFE_INTEGER=9007199254740991,t.isSafeInteger=function(u){return t.isInteger(u)&&u>=-t.MAX_SAFE_INTEGER&&u<=t.MAX_SAFE_INTEGER}})(Qi),Object.defineProperty(re,"__esModule",{value:!0});var es=Qi;function _c(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])<<16>>16}re.readInt16BE=_c;function bc(t,e){return e===void 0&&(e=0),(t[e+0]<<8|t[e+1])>>>0}re.readUint16BE=bc;function mc(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])<<16>>16}re.readInt16LE=mc;function wc(t,e){return e===void 0&&(e=0),(t[e+1]<<8|t[e])>>>0}re.readUint16LE=wc;function ts(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>8,e[r+1]=t>>>0,e}re.writeUint16BE=ts,re.writeInt16BE=ts;function rs(t,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e}re.writeUint16LE=rs,re.writeInt16LE=rs;function Tn(t,e){return e===void 0&&(e=0),t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3]}re.readInt32BE=Tn;function Cn(t,e){return e===void 0&&(e=0),(t[e]<<24|t[e+1]<<16|t[e+2]<<8|t[e+3])>>>0}re.readUint32BE=Cn;function Nn(t,e){return e===void 0&&(e=0),t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e]}re.readInt32LE=Nn;function Pn(t,e){return e===void 0&&(e=0),(t[e+3]<<24|t[e+2]<<16|t[e+1]<<8|t[e])>>>0}re.readUint32LE=Pn;function Gr(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>24,e[r+1]=t>>>16,e[r+2]=t>>>8,e[r+3]=t>>>0,e}re.writeUint32BE=Gr,re.writeInt32BE=Gr;function Wr(t,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=t>>>0,e[r+1]=t>>>8,e[r+2]=t>>>16,e[r+3]=t>>>24,e}re.writeUint32LE=Wr,re.writeInt32LE=Wr;function Ec(t,e){e===void 0&&(e=0);var r=Tn(t,e),n=Tn(t,e+4);return r*4294967296+n-(n>>31)*4294967296}re.readInt64BE=Ec;function Dc(t,e){e===void 0&&(e=0);var r=Cn(t,e),n=Cn(t,e+4);return r*4294967296+n}re.readUint64BE=Dc;function xc(t,e){e===void 0&&(e=0);var r=Nn(t,e),n=Nn(t,e+4);return n*4294967296+r-(r>>31)*4294967296}re.readInt64LE=xc;function Sc(t,e){e===void 0&&(e=0);var r=Pn(t,e),n=Pn(t,e+4);return n*4294967296+r}re.readUint64LE=Sc;function ns(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Gr(t/4294967296>>>0,e,r),Gr(t>>>0,e,r+4),e}re.writeUint64BE=ns,re.writeInt64BE=ns;function is(t,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),Wr(t>>>0,e,r),Wr(t/4294967296>>>0,e,r+4),e}re.writeUint64LE=is,re.writeInt64LE=is;function Oc(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=t/8+r-1;s>=r;s--)n+=e[s]*i,i*=256;return n}re.readUintBE=Oc;function Ac(t,e,r){if(r===void 0&&(r=0),t%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(t/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s<r+t/8;s++)n+=e[s]*i,i*=256;return n}re.readUintLE=Ac;function Ic(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!es.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var i=1,s=t/8+n-1;s>=n;s--)r[s]=e/i&255,i*=256;return r}re.writeUintBE=Ic;function Lc(t,e,r,n){if(r===void 0&&(r=new Uint8Array(t/8)),n===void 0&&(n=0),t%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!es.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s<n+t/8;s++)r[s]=e/i&255,i*=256;return r}re.writeUintLE=Lc;function Tc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e)}re.readFloat32BE=Tc;function Cc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat32(e,!0)}re.readFloat32LE=Cc;function Nc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e)}re.readFloat64BE=Nc;function Pc(t,e){e===void 0&&(e=0);var r=new DataView(t.buffer,t.byteOffset,t.byteLength);return r.getFloat64(e,!0)}re.readFloat64LE=Pc;function Rc(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat32(r,t),e}re.writeFloat32BE=Rc;function Fc(t,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat32(r,t,!0),e}re.writeFloat32LE=Fc;function Uc(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat64(r,t),e}re.writeFloat64BE=Uc;function Mc(t,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(e.buffer,e.byteOffset,e.byteLength);return n.setFloat64(r,t,!0),e}re.writeFloat64LE=Mc;var pt={};Object.defineProperty(pt,"__esModule",{value:!0});function jc(t){for(var e=0;e<t.length;e++)t[e]=0;return t}pt.wipe=jc,Object.defineProperty(Vr,"__esModule",{value:!0});var st=re,Rn=pt,$c=20;function Bc(t,e,r){for(var n=1634760805,i=857760878,s=2036477234,c=1797285236,u=r[3]<<24|r[2]<<16|r[1]<<8|r[0],h=r[7]<<24|r[6]<<16|r[5]<<8|r[4],f=r[11]<<24|r[10]<<16|r[9]<<8|r[8],g=r[15]<<24|r[14]<<16|r[13]<<8|r[12],w=r[19]<<24|r[18]<<16|r[17]<<8|r[16],T=r[23]<<24|r[22]<<16|r[21]<<8|r[20],E=r[27]<<24|r[26]<<16|r[25]<<8|r[24],v=r[31]<<24|r[30]<<16|r[29]<<8|r[28],P=e[3]<<24|e[2]<<16|e[1]<<8|e[0],C=e[7]<<24|e[6]<<16|e[5]<<8|e[4],$=e[11]<<24|e[10]<<16|e[9]<<8|e[8],x=e[15]<<24|e[14]<<16|e[13]<<8|e[12],A=n,_=i,D=s,m=c,o=u,d=h,M=f,K=g,V=w,J=T,X=E,l=v,b=P,U=C,q=$,R=x,N=0;N<$c;N+=2)A=A+o|0,b^=A,b=b>>>32-16|b<<16,V=V+b|0,o^=V,o=o>>>32-12|o<<12,_=_+d|0,U^=_,U=U>>>32-16|U<<16,J=J+U|0,d^=J,d=d>>>32-12|d<<12,D=D+M|0,q^=D,q=q>>>32-16|q<<16,X=X+q|0,M^=X,M=M>>>32-12|M<<12,m=m+K|0,R^=m,R=R>>>32-16|R<<16,l=l+R|0,K^=l,K=K>>>32-12|K<<12,D=D+M|0,q^=D,q=q>>>32-8|q<<8,X=X+q|0,M^=X,M=M>>>32-7|M<<7,m=m+K|0,R^=m,R=R>>>32-8|R<<8,l=l+R|0,K^=l,K=K>>>32-7|K<<7,_=_+d|0,U^=_,U=U>>>32-8|U<<8,J=J+U|0,d^=J,d=d>>>32-7|d<<7,A=A+o|0,b^=A,b=b>>>32-8|b<<8,V=V+b|0,o^=V,o=o>>>32-7|o<<7,A=A+d|0,R^=A,R=R>>>32-16|R<<16,X=X+R|0,d^=X,d=d>>>32-12|d<<12,_=_+M|0,b^=_,b=b>>>32-16|b<<16,l=l+b|0,M^=l,M=M>>>32-12|M<<12,D=D+K|0,U^=D,U=U>>>32-16|U<<16,V=V+U|0,K^=V,K=K>>>32-12|K<<12,m=m+o|0,q^=m,q=q>>>32-16|q<<16,J=J+q|0,o^=J,o=o>>>32-12|o<<12,D=D+K|0,U^=D,U=U>>>32-8|U<<8,V=V+U|0,K^=V,K=K>>>32-7|K<<7,m=m+o|0,q^=m,q=q>>>32-8|q<<8,J=J+q|0,o^=J,o=o>>>32-7|o<<7,_=_+M|0,b^=_,b=b>>>32-8|b<<8,l=l+b|0,M^=l,M=M>>>32-7|M<<7,A=A+d|0,R^=A,R=R>>>32-8|R<<8,X=X+R|0,d^=X,d=d>>>32-7|d<<7;st.writeUint32LE(A+n|0,t,0),st.writeUint32LE(_+i|0,t,4),st.writeUint32LE(D+s|0,t,8),st.writeUint32LE(m+c|0,t,12),st.writeUint32LE(o+u|0,t,16),st.writeUint32LE(d+h|0,t,20),st.writeUint32LE(M+f|0,t,24),st.writeUint32LE(K+g|0,t,28),st.writeUint32LE(V+w|0,t,32),st.writeUint32LE(J+T|0,t,36),st.writeUint32LE(X+E|0,t,40),st.writeUint32LE(l+v|0,t,44),st.writeUint32LE(b+P|0,t,48),st.writeUint32LE(U+C|0,t,52),st.writeUint32LE(q+$|0,t,56),st.writeUint32LE(R+x|0,t,60)}function ss(t,e,r,n,i){if(i===void 0&&(i=0),t.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(n.length<r.length)throw new Error("ChaCha: destination is shorter than source");var s,c;if(i===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");s=new Uint8Array(16),c=s.length-e.length,s.set(e,c)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");s=e,c=i}for(var u=new Uint8Array(64),h=0;h<r.length;h+=64){Bc(u,s,t);for(var f=h;f<h+64&&f<r.length;f++)n[f]=r[f]^u[f-h];Hc(s,0,c)}return Rn.wipe(u),i===0&&Rn.wipe(s),n}Vr.streamXOR=ss;function zc(t,e,r,n){return n===void 0&&(n=0),Rn.wipe(r),ss(t,e,r,r,n)}Vr.stream=zc;function Hc(t,e,r){for(var n=1;r--;)n=n+(t[e]&255)|0,t[e]=n&255,n>>>=8,e++;if(n>0)throw new Error("ChaCha: counter overflow")}var os={},zt={};Object.defineProperty(zt,"__esModule",{value:!0});function Kc(t,e,r){return~(t-1)&e|t-1&r}zt.select=Kc;function qc(t,e){return(t|0)-(e|0)-1>>>31&1}zt.lessOrEqual=qc;function as(t,e){if(t.length!==e.length)return 0;for(var r=0,n=0;n<t.length;n++)r|=t[n]^e[n];return 1&r-1>>>8}zt.compare=as;function Vc(t,e){return t.length===0||e.length===0?!1:as(t,e)!==0}zt.equal=Vc,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=zt,r=pt;t.DIGEST_LENGTH=16;var n=function(){function c(u){this.digestLength=t.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var h=u[0]|u[1]<<8;this._r[0]=h&8191;var f=u[2]|u[3]<<8;this._r[1]=(h>>>13|f<<3)&8191;var g=u[4]|u[5]<<8;this._r[2]=(f>>>10|g<<6)&7939;var w=u[6]|u[7]<<8;this._r[3]=(g>>>7|w<<9)&8191;var T=u[8]|u[9]<<8;this._r[4]=(w>>>4|T<<12)&255,this._r[5]=T>>>1&8190;var E=u[10]|u[11]<<8;this._r[6]=(T>>>14|E<<2)&8191;var v=u[12]|u[13]<<8;this._r[7]=(E>>>11|v<<5)&8065;var P=u[14]|u[15]<<8;this._r[8]=(v>>>8|P<<8)&8191,this._r[9]=P>>>5&127,this._pad[0]=u[16]|u[17]<<8,this._pad[1]=u[18]|u[19]<<8,this._pad[2]=u[20]|u[21]<<8,this._pad[3]=u[22]|u[23]<<8,this._pad[4]=u[24]|u[25]<<8,this._pad[5]=u[26]|u[27]<<8,this._pad[6]=u[28]|u[29]<<8,this._pad[7]=u[30]|u[31]<<8}return c.prototype._blocks=function(u,h,f){for(var g=this._fin?0:2048,w=this._h[0],T=this._h[1],E=this._h[2],v=this._h[3],P=this._h[4],C=this._h[5],$=this._h[6],x=this._h[7],A=this._h[8],_=this._h[9],D=this._r[0],m=this._r[1],o=this._r[2],d=this._r[3],M=this._r[4],K=this._r[5],V=this._r[6],J=this._r[7],X=this._r[8],l=this._r[9];f>=16;){var b=u[h+0]|u[h+1]<<8;w+=b&8191;var U=u[h+2]|u[h+3]<<8;T+=(b>>>13|U<<3)&8191;var q=u[h+4]|u[h+5]<<8;E+=(U>>>10|q<<6)&8191;var R=u[h+6]|u[h+7]<<8;v+=(q>>>7|R<<9)&8191;var N=u[h+8]|u[h+9]<<8;P+=(R>>>4|N<<12)&8191,C+=N>>>1&8191;var j=u[h+10]|u[h+11]<<8;$+=(N>>>14|j<<2)&8191;var B=u[h+12]|u[h+13]<<8;x+=(j>>>11|B<<5)&8191;var Q=u[h+14]|u[h+15]<<8;A+=(B>>>8|Q<<8)&8191,_+=Q>>>5|g;var H=0,ee=H;ee+=w*D,ee+=T*(5*l),ee+=E*(5*X),ee+=v*(5*J),ee+=P*(5*V),H=ee>>>13,ee&=8191,ee+=C*(5*K),ee+=$*(5*M),ee+=x*(5*d),ee+=A*(5*o),ee+=_*(5*m),H+=ee>>>13,ee&=8191;var k=H;k+=w*m,k+=T*D,k+=E*(5*l),k+=v*(5*X),k+=P*(5*J),H=k>>>13,k&=8191,k+=C*(5*V),k+=$*(5*K),k+=x*(5*M),k+=A*(5*d),k+=_*(5*o),H+=k>>>13,k&=8191;var ae=H;ae+=w*o,ae+=T*m,ae+=E*D,ae+=v*(5*l),ae+=P*(5*X),H=ae>>>13,ae&=8191,ae+=C*(5*J),ae+=$*(5*V),ae+=x*(5*K),ae+=A*(5*M),ae+=_*(5*d),H+=ae>>>13,ae&=8191;var L=H;L+=w*d,L+=T*o,L+=E*m,L+=v*D,L+=P*(5*l),H=L>>>13,L&=8191,L+=C*(5*X),L+=$*(5*J),L+=x*(5*V),L+=A*(5*K),L+=_*(5*M),H+=L>>>13,L&=8191;var I=H;I+=w*M,I+=T*d,I+=E*o,I+=v*m,I+=P*D,H=I>>>13,I&=8191,I+=C*(5*l),I+=$*(5*X),I+=x*(5*J),I+=A*(5*V),I+=_*(5*K),H+=I>>>13,I&=8191;var S=H;S+=w*K,S+=T*M,S+=E*d,S+=v*o,S+=P*m,H=S>>>13,S&=8191,S+=C*D,S+=$*(5*l),S+=x*(5*X),S+=A*(5*J),S+=_*(5*V),H+=S>>>13,S&=8191;var a=H;a+=w*V,a+=T*K,a+=E*M,a+=v*d,a+=P*o,H=a>>>13,a&=8191,a+=C*m,a+=$*D,a+=x*(5*l),a+=A*(5*X),a+=_*(5*J),H+=a>>>13,a&=8191;var y=H;y+=w*J,y+=T*V,y+=E*K,y+=v*M,y+=P*d,H=y>>>13,y&=8191,y+=C*o,y+=$*m,y+=x*D,y+=A*(5*l),y+=_*(5*X),H+=y>>>13,y&=8191;var z=H;z+=w*X,z+=T*J,z+=E*V,z+=v*K,z+=P*M,H=z>>>13,z&=8191,z+=C*d,z+=$*o,z+=x*m,z+=A*D,z+=_*(5*l),H+=z>>>13,z&=8191;var Y=H;Y+=w*l,Y+=T*X,Y+=E*J,Y+=v*V,Y+=P*K,H=Y>>>13,Y&=8191,Y+=C*M,Y+=$*d,Y+=x*o,Y+=A*m,Y+=_*D,H+=Y>>>13,Y&=8191,H=(H<<2)+H|0,H=H+ee|0,ee=H&8191,H=H>>>13,k+=H,w=ee,T=k,E=ae,v=L,P=I,C=S,$=a,x=y,A=z,_=Y,h+=16,f-=16}this._h[0]=w,this._h[1]=T,this._h[2]=E,this._h[3]=v,this._h[4]=P,this._h[5]=C,this._h[6]=$,this._h[7]=x,this._h[8]=A,this._h[9]=_},c.prototype.finish=function(u,h){h===void 0&&(h=0);var f=new Uint16Array(10),g,w,T,E;if(this._leftover){for(E=this._leftover,this._buffer[E++]=1;E<16;E++)this._buffer[E]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(g=this._h[1]>>>13,this._h[1]&=8191,E=2;E<10;E++)this._h[E]+=g,g=this._h[E]>>>13,this._h[E]&=8191;for(this._h[0]+=g*5,g=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=g,g=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=g,f[0]=this._h[0]+5,g=f[0]>>>13,f[0]&=8191,E=1;E<10;E++)f[E]=this._h[E]+g,g=f[E]>>>13,f[E]&=8191;for(f[9]-=1<<13,w=(g^1)-1,E=0;E<10;E++)f[E]&=w;for(w=~w,E=0;E<10;E++)this._h[E]=this._h[E]&w|f[E];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,T=this._h[0]+this._pad[0],this._h[0]=T&65535,E=1;E<8;E++)T=(this._h[E]+this._pad[E]|0)+(T>>>16)|0,this._h[E]=T&65535;return u[h+0]=this._h[0]>>>0,u[h+1]=this._h[0]>>>8,u[h+2]=this._h[1]>>>0,u[h+3]=this._h[1]>>>8,u[h+4]=this._h[2]>>>0,u[h+5]=this._h[2]>>>8,u[h+6]=this._h[3]>>>0,u[h+7]=this._h[3]>>>8,u[h+8]=this._h[4]>>>0,u[h+9]=this._h[4]>>>8,u[h+10]=this._h[5]>>>0,u[h+11]=this._h[5]>>>8,u[h+12]=this._h[6]>>>0,u[h+13]=this._h[6]>>>8,u[h+14]=this._h[7]>>>0,u[h+15]=this._h[7]>>>8,this._finished=!0,this},c.prototype.update=function(u){var h=0,f=u.length,g;if(this._leftover){g=16-this._leftover,g>f&&(g=f);for(var w=0;w<g;w++)this._buffer[this._leftover+w]=u[h+w];if(f-=g,h+=g,this._leftover+=g,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(f>=16&&(g=f-f%16,this._blocks(u,h,g),h+=g,f-=g),f){for(var w=0;w<f;w++)this._buffer[this._leftover+w]=u[h+w];this._leftover+=f}return this},c.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var u=new Uint8Array(16);return this.finish(u),u},c.prototype.clean=function(){return r.wipe(this._buffer),r.wipe(this._r),r.wipe(this._h),r.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},c}();t.Poly1305=n;function i(c,u){var h=new n(c);h.update(u);var f=h.digest();return h.clean(),f}t.oneTimeAuth=i;function s(c,u){return c.length!==t.DIGEST_LENGTH||u.length!==t.DIGEST_LENGTH?!1:e.equal(c,u)}t.equal=s}(os),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Vr,r=os,n=pt,i=re,s=zt;t.KEY_LENGTH=32,t.NONCE_LENGTH=12,t.TAG_LENGTH=16;var c=new Uint8Array(16),u=function(){function h(f){if(this.nonceLength=t.NONCE_LENGTH,this.tagLength=t.TAG_LENGTH,f.length!==t.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(f)}return h.prototype.seal=function(f,g,w,T){if(f.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var E=new Uint8Array(16);E.set(f,E.length-f.length);var v=new Uint8Array(32);e.stream(this._key,E,v,4);var P=g.length+this.tagLength,C;if(T){if(T.length!==P)throw new Error("ChaCha20Poly1305: incorrect destination length");C=T}else C=new Uint8Array(P);return e.streamXOR(this._key,E,g,C,4),this._authenticate(C.subarray(C.length-this.tagLength,C.length),v,C.subarray(0,C.length-this.tagLength),w),n.wipe(E),C},h.prototype.open=function(f,g,w,T){if(f.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(g.length<this.tagLength)return null;var E=new Uint8Array(16);E.set(f,E.length-f.length);var v=new Uint8Array(32);e.stream(this._key,E,v,4);var P=new Uint8Array(this.tagLength);if(this._authenticate(P,v,g.subarray(0,g.length-this.tagLength),w),!s.equal(P,g.subarray(g.length-this.tagLength,g.length)))return null;var C=g.length-this.tagLength,$;if(T){if(T.length!==C)throw new Error("ChaCha20Poly1305: incorrect destination length");$=T}else $=new Uint8Array(C);return e.streamXOR(this._key,E,g.subarray(0,g.length-this.tagLength),$,4),n.wipe(E),$},h.prototype.clean=function(){return n.wipe(this._key),this},h.prototype._authenticate=function(f,g,w,T){var E=new r.Poly1305(g);T&&(E.update(T),T.length%16>0&&E.update(c.subarray(T.length%16))),E.update(w),w.length%16>0&&E.update(c.subarray(w.length%16));var v=new Uint8Array(8);T&&i.writeUint64LE(T.length,v),E.update(v),i.writeUint64LE(w.length,v),E.update(v);for(var P=E.digest(),C=0;C<P.length;C++)f[C]=P[C];E.clean(),n.wipe(P),n.wipe(v)},h}();t.ChaCha20Poly1305=u}(Ln);var cs={},mr={},Fn={};Object.defineProperty(Fn,"__esModule",{value:!0});function Gc(t){return typeof t.saveState<"u"&&typeof t.restoreState<"u"&&typeof t.cleanSavedState<"u"}Fn.isSerializableHash=Gc,Object.defineProperty(mr,"__esModule",{value:!0});var Ot=Fn,Wc=zt,kc=pt,us=function(){function t(e,r){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var n=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(n).clean():n.set(r);for(var i=0;i<n.length;i++)n[i]^=54;this._inner.update(n);for(var i=0;i<n.length;i++)n[i]^=106;this._outer.update(n),Ot.isSerializableHash(this._inner)&&Ot.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),kc.wipe(n)}return t.prototype.reset=function(){if(!Ot.isSerializableHash(this._inner)||!Ot.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.clean=function(){Ot.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),Ot.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},t.prototype.update=function(e){return this._inner.update(e),this},t.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},t.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},t.prototype.saveState=function(){if(!Ot.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},t.prototype.restoreState=function(e){if(!Ot.isSerializableHash(this._inner)||!Ot.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},t.prototype.cleanSavedState=function(e){if(!Ot.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},t}();mr.HMAC=us;function Yc(t,e,r){var n=new us(t,e);n.update(r);var i=n.digest();return n.clean(),i}mr.hmac=Yc,mr.equal=Wc.equal,Object.defineProperty(cs,"__esModule",{value:!0});var hs=mr,fs=pt,Jc=function(){function t(e,r,n,i){n===void 0&&(n=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=i;var s=hs.hmac(this._hash,n,r);this._hmac=new hs.HMAC(e,s),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return t.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},t.prototype.expand=function(e){for(var r=new Uint8Array(e),n=0;n<r.length;n++)this._bufpos===this._buffer.length&&this._fillBuffer(),r[n]=this._buffer[this._bufpos++];return r},t.prototype.clean=function(){this._hmac.clean(),fs.wipe(this._buffer),fs.wipe(this._counter),this._bufpos=0},t}(),Xc=cs.HKDF=Jc,nr={},Un={},Mn={};Object.defineProperty(Mn,"__esModule",{value:!0});var ls=65536,Zc=function(){function t(){this.isAvailable=!1,this.isInstantiated=!1;var e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}return t.prototype.randomBytes=function(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");for(var r=new Uint8Array(e),n=0;n<r.length;n+=ls)this._crypto.getRandomValues(r.subarray(n,n+Math.min(r.length-n,ls)));return r},t}();Mn.BrowserRandomSource=Zc;function Qc(t){throw new Error('Could not dynamically require "'+t+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var jn={},eu={},tu=Object.freeze({__proto__:null,default:eu}),ru=wn(tu);Object.defineProperty(jn,"__esModule",{value:!0});var nu=pt,iu=function(){function t(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof Qc<"u"){var e=ru;e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}return t.prototype.randomBytes=function(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");var r=this._crypto.randomBytes(e);if(r.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");for(var n=new Uint8Array(e),i=0;i<n.length;i++)n[i]=r[i];return nu.wipe(r),n},t}();jn.NodeRandomSource=iu,Object.defineProperty(Un,"__esModule",{value:!0});var su=Mn,ou=jn,au=function(){function t(){if(this.isAvailable=!1,this.name="",this._source=new su.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new ou.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}return t.prototype.randomBytes=function(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)},t}();Un.SystemRandomSource=au,function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=Un,r=re,n=pt;t.defaultRandomSource=new e.SystemRandomSource;function i(f,g){return g===void 0&&(g=t.defaultRandomSource),g.randomBytes(f)}t.randomBytes=i;function s(f){f===void 0&&(f=t.defaultRandomSource);var g=i(4,f),w=r.readUint32LE(g);return n.wipe(g),w}t.randomUint32=s;var c="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function u(f,g,w){if(g===void 0&&(g=c),w===void 0&&(w=t.defaultRandomSource),g.length<2)throw new Error("randomString charset is too short");if(g.length>256)throw new Error("randomString charset is too long");for(var T="",E=g.length,v=256-256%E;f>0;){for(var P=i(Math.ceil(f*256/v),w),C=0;C<P.length&&f>0;C++){var $=P[C];$<v&&(T+=g.charAt($%E),f--)}n.wipe(P)}return T}t.randomString=u;function h(f,g,w){g===void 0&&(g=c),w===void 0&&(w=t.defaultRandomSource);var T=Math.ceil(f/(Math.log(g.length)/Math.LN2));return u(T,g,w)}t.randomStringForEntropy=h}(nr);var kr={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=pt;t.DIGEST_LENGTH=32,t.BLOCK_SIZE=64;var n=function(){function u(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return u.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},u.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},u.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},u.prototype.update=function(h,f){if(f===void 0&&(f=h.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var g=0;if(this._bytesHashed+=f,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&f>0;)this._buffer[this._bufferLength++]=h[g++],f--;this._bufferLength===this.blockSize&&(s(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(f>=this.blockSize&&(g=s(this._temp,this._state,h,g,f),f%=this.blockSize);f>0;)this._buffer[this._bufferLength++]=h[g++],f--;return this},u.prototype.finish=function(h){if(!this._finished){var f=this._bytesHashed,g=this._bufferLength,w=f/536870912|0,T=f<<3,E=f%64<56?64:128;this._buffer[g]=128;for(var v=g+1;v<E-8;v++)this._buffer[v]=0;e.writeUint32BE(w,this._buffer,E-8),e.writeUint32BE(T,this._buffer,E-4),s(this._temp,this._state,this._buffer,0,E),this._finished=!0}for(var v=0;v<this.digestLength/4;v++)e.writeUint32BE(this._state[v],h,v*4);return this},u.prototype.digest=function(){var h=new Uint8Array(this.digestLength);return this.finish(h),h},u.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},u.prototype.restoreState=function(h){return this._state.set(h.state),this._bufferLength=h.bufferLength,h.buffer&&this._buffer.set(h.buffer),this._bytesHashed=h.bytesHashed,this._finished=!1,this},u.prototype.cleanSavedState=function(h){r.wipe(h.state),h.buffer&&r.wipe(h.buffer),h.bufferLength=0,h.bytesHashed=0},u}();t.SHA256=n;var i=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function s(u,h,f,g,w){for(;w>=64;){for(var T=h[0],E=h[1],v=h[2],P=h[3],C=h[4],$=h[5],x=h[6],A=h[7],_=0;_<16;_++){var D=g+_*4;u[_]=e.readUint32BE(f,D)}for(var _=16;_<64;_++){var m=u[_-2],o=(m>>>17|m<<32-17)^(m>>>19|m<<32-19)^m>>>10;m=u[_-15];var d=(m>>>7|m<<32-7)^(m>>>18|m<<32-18)^m>>>3;u[_]=(o+u[_-7]|0)+(d+u[_-16]|0)}for(var _=0;_<64;_++){var o=(((C>>>6|C<<26)^(C>>>11|C<<21)^(C>>>25|C<<7))+(C&$^~C&x)|0)+(A+(i[_]+u[_]|0)|0)|0,d=((T>>>2|T<<32-2)^(T>>>13|T<<32-13)^(T>>>22|T<<32-22))+(T&E^T&v^E&v)|0;A=x,x=$,$=C,C=P+o|0,P=v,v=E,E=T,T=o+d|0}h[0]+=T,h[1]+=E,h[2]+=v,h[3]+=P,h[4]+=C,h[5]+=$,h[6]+=x,h[7]+=A,g+=64,w-=64}return g}function c(u){var h=new n;h.update(u);var f=h.digest();return h.clean(),f}t.hash=c})(kr);var $n={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=nr,r=pt;t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=32,t.SHARED_KEY_LENGTH=32;function n(_){var D=new Float64Array(16);if(_)for(var m=0;m<_.length;m++)D[m]=_[m];return D}var i=new Uint8Array(32);i[0]=9;var s=n([56129,1]);function c(_){for(var D=1,m=0;m<16;m++){var o=_[m]+D+65535;D=Math.floor(o/65536),_[m]=o-D*65536}_[0]+=D-1+37*(D-1)}function u(_,D,m){for(var o=~(m-1),d=0;d<16;d++){var M=o&(_[d]^D[d]);_[d]^=M,D[d]^=M}}function h(_,D){for(var m=n(),o=n(),d=0;d<16;d++)o[d]=D[d];c(o),c(o),c(o);for(var M=0;M<2;M++){m[0]=o[0]-65517;for(var d=1;d<15;d++)m[d]=o[d]-65535-(m[d-1]>>16&1),m[d-1]&=65535;m[15]=o[15]-32767-(m[14]>>16&1);var K=m[15]>>16&1;m[14]&=65535,u(o,m,1-K)}for(var d=0;d<16;d++)_[2*d]=o[d]&255,_[2*d+1]=o[d]>>8}function f(_,D){for(var m=0;m<16;m++)_[m]=D[2*m]+(D[2*m+1]<<8);_[15]&=32767}function g(_,D,m){for(var o=0;o<16;o++)_[o]=D[o]+m[o]}function w(_,D,m){for(var o=0;o<16;o++)_[o]=D[o]-m[o]}function T(_,D,m){var o,d,M=0,K=0,V=0,J=0,X=0,l=0,b=0,U=0,q=0,R=0,N=0,j=0,B=0,Q=0,H=0,ee=0,k=0,ae=0,L=0,I=0,S=0,a=0,y=0,z=0,Y=0,fe=0,ye=0,de=0,me=0,Ue=0,Ce=0,ve=m[0],pe=m[1],le=m[2],ue=m[3],ce=m[4],oe=m[5],se=m[6],te=m[7],he=m[8],ge=m[9],ne=m[10],_e=m[11],be=m[12],Ee=m[13],De=m[14],we=m[15];o=D[0],M+=o*ve,K+=o*pe,V+=o*le,J+=o*ue,X+=o*ce,l+=o*oe,b+=o*se,U+=o*te,q+=o*he,R+=o*ge,N+=o*ne,j+=o*_e,B+=o*be,Q+=o*Ee,H+=o*De,ee+=o*we,o=D[1],K+=o*ve,V+=o*pe,J+=o*le,X+=o*ue,l+=o*ce,b+=o*oe,U+=o*se,q+=o*te,R+=o*he,N+=o*ge,j+=o*ne,B+=o*_e,Q+=o*be,H+=o*Ee,ee+=o*De,k+=o*we,o=D[2],V+=o*ve,J+=o*pe,X+=o*le,l+=o*ue,b+=o*ce,U+=o*oe,q+=o*se,R+=o*te,N+=o*he,j+=o*ge,B+=o*ne,Q+=o*_e,H+=o*be,ee+=o*Ee,k+=o*De,ae+=o*we,o=D[3],J+=o*ve,X+=o*pe,l+=o*le,b+=o*ue,U+=o*ce,q+=o*oe,R+=o*se,N+=o*te,j+=o*he,B+=o*ge,Q+=o*ne,H+=o*_e,ee+=o*be,k+=o*Ee,ae+=o*De,L+=o*we,o=D[4],X+=o*ve,l+=o*pe,b+=o*le,U+=o*ue,q+=o*ce,R+=o*oe,N+=o*se,j+=o*te,B+=o*he,Q+=o*ge,H+=o*ne,ee+=o*_e,k+=o*be,ae+=o*Ee,L+=o*De,I+=o*we,o=D[5],l+=o*ve,b+=o*pe,U+=o*le,q+=o*ue,R+=o*ce,N+=o*oe,j+=o*se,B+=o*te,Q+=o*he,H+=o*ge,ee+=o*ne,k+=o*_e,ae+=o*be,L+=o*Ee,I+=o*De,S+=o*we,o=D[6],b+=o*ve,U+=o*pe,q+=o*le,R+=o*ue,N+=o*ce,j+=o*oe,B+=o*se,Q+=o*te,H+=o*he,ee+=o*ge,k+=o*ne,ae+=o*_e,L+=o*be,I+=o*Ee,S+=o*De,a+=o*we,o=D[7],U+=o*ve,q+=o*pe,R+=o*le,N+=o*ue,j+=o*ce,B+=o*oe,Q+=o*se,H+=o*te,ee+=o*he,k+=o*ge,ae+=o*ne,L+=o*_e,I+=o*be,S+=o*Ee,a+=o*De,y+=o*we,o=D[8],q+=o*ve,R+=o*pe,N+=o*le,j+=o*ue,B+=o*ce,Q+=o*oe,H+=o*se,ee+=o*te,k+=o*he,ae+=o*ge,L+=o*ne,I+=o*_e,S+=o*be,a+=o*Ee,y+=o*De,z+=o*we,o=D[9],R+=o*ve,N+=o*pe,j+=o*le,B+=o*ue,Q+=o*ce,H+=o*oe,ee+=o*se,k+=o*te,ae+=o*he,L+=o*ge,I+=o*ne,S+=o*_e,a+=o*be,y+=o*Ee,z+=o*De,Y+=o*we,o=D[10],N+=o*ve,j+=o*pe,B+=o*le,Q+=o*ue,H+=o*ce,ee+=o*oe,k+=o*se,ae+=o*te,L+=o*he,I+=o*ge,S+=o*ne,a+=o*_e,y+=o*be,z+=o*Ee,Y+=o*De,fe+=o*we,o=D[11],j+=o*ve,B+=o*pe,Q+=o*le,H+=o*ue,ee+=o*ce,k+=o*oe,ae+=o*se,L+=o*te,I+=o*he,S+=o*ge,a+=o*ne,y+=o*_e,z+=o*be,Y+=o*Ee,fe+=o*De,ye+=o*we,o=D[12],B+=o*ve,Q+=o*pe,H+=o*le,ee+=o*ue,k+=o*ce,ae+=o*oe,L+=o*se,I+=o*te,S+=o*he,a+=o*ge,y+=o*ne,z+=o*_e,Y+=o*be,fe+=o*Ee,ye+=o*De,de+=o*we,o=D[13],Q+=o*ve,H+=o*pe,ee+=o*le,k+=o*ue,ae+=o*ce,L+=o*oe,I+=o*se,S+=o*te,a+=o*he,y+=o*ge,z+=o*ne,Y+=o*_e,fe+=o*be,ye+=o*Ee,de+=o*De,me+=o*we,o=D[14],H+=o*ve,ee+=o*pe,k+=o*le,ae+=o*ue,L+=o*ce,I+=o*oe,S+=o*se,a+=o*te,y+=o*he,z+=o*ge,Y+=o*ne,fe+=o*_e,ye+=o*be,de+=o*Ee,me+=o*De,Ue+=o*we,o=D[15],ee+=o*ve,k+=o*pe,ae+=o*le,L+=o*ue,I+=o*ce,S+=o*oe,a+=o*se,y+=o*te,z+=o*he,Y+=o*ge,fe+=o*ne,ye+=o*_e,de+=o*be,me+=o*Ee,Ue+=o*De,Ce+=o*we,M+=38*k,K+=38*ae,V+=38*L,J+=38*I,X+=38*S,l+=38*a,b+=38*y,U+=38*z,q+=38*Y,R+=38*fe,N+=38*ye,j+=38*de,B+=38*me,Q+=38*Ue,H+=38*Ce,d=1,o=M+d+65535,d=Math.floor(o/65536),M=o-d*65536,o=K+d+65535,d=Math.floor(o/65536),K=o-d*65536,o=V+d+65535,d=Math.floor(o/65536),V=o-d*65536,o=J+d+65535,d=Math.floor(o/65536),J=o-d*65536,o=X+d+65535,d=Math.floor(o/65536),X=o-d*65536,o=l+d+65535,d=Math.floor(o/65536),l=o-d*65536,o=b+d+65535,d=Math.floor(o/65536),b=o-d*65536,o=U+d+65535,d=Math.floor(o/65536),U=o-d*65536,o=q+d+65535,d=Math.floor(o/65536),q=o-d*65536,o=R+d+65535,d=Math.floor(o/65536),R=o-d*65536,o=N+d+65535,d=Math.floor(o/65536),N=o-d*65536,o=j+d+65535,d=Math.floor(o/65536),j=o-d*65536,o=B+d+65535,d=Math.floor(o/65536),B=o-d*65536,o=Q+d+65535,d=Math.floor(o/65536),Q=o-d*65536,o=H+d+65535,d=Math.floor(o/65536),H=o-d*65536,o=ee+d+65535,d=Math.floor(o/65536),ee=o-d*65536,M+=d-1+37*(d-1),d=1,o=M+d+65535,d=Math.floor(o/65536),M=o-d*65536,o=K+d+65535,d=Math.floor(o/65536),K=o-d*65536,o=V+d+65535,d=Math.floor(o/65536),V=o-d*65536,o=J+d+65535,d=Math.floor(o/65536),J=o-d*65536,o=X+d+65535,d=Math.floor(o/65536),X=o-d*65536,o=l+d+65535,d=Math.floor(o/65536),l=o-d*65536,o=b+d+65535,d=Math.floor(o/65536),b=o-d*65536,o=U+d+65535,d=Math.floor(o/65536),U=o-d*65536,o=q+d+65535,d=Math.floor(o/65536),q=o-d*65536,o=R+d+65535,d=Math.floor(o/65536),R=o-d*65536,o=N+d+65535,d=Math.floor(o/65536),N=o-d*65536,o=j+d+65535,d=Math.floor(o/65536),j=o-d*65536,o=B+d+65535,d=Math.floor(o/65536),B=o-d*65536,o=Q+d+65535,d=Math.floor(o/65536),Q=o-d*65536,o=H+d+65535,d=Math.floor(o/65536),H=o-d*65536,o=ee+d+65535,d=Math.floor(o/65536),ee=o-d*65536,M+=d-1+37*(d-1),_[0]=M,_[1]=K,_[2]=V,_[3]=J,_[4]=X,_[5]=l,_[6]=b,_[7]=U,_[8]=q,_[9]=R,_[10]=N,_[11]=j,_[12]=B,_[13]=Q,_[14]=H,_[15]=ee}function E(_,D){T(_,D,D)}function v(_,D){for(var m=n(),o=0;o<16;o++)m[o]=D[o];for(var o=253;o>=0;o--)E(m,m),o!==2&&o!==4&&T(m,m,D);for(var o=0;o<16;o++)_[o]=m[o]}function P(_,D){for(var m=new Uint8Array(32),o=new Float64Array(80),d=n(),M=n(),K=n(),V=n(),J=n(),X=n(),l=0;l<31;l++)m[l]=_[l];m[31]=_[31]&127|64,m[0]&=248,f(o,D);for(var l=0;l<16;l++)M[l]=o[l];d[0]=V[0]=1;for(var l=254;l>=0;--l){var b=m[l>>>3]>>>(l&7)&1;u(d,M,b),u(K,V,b),g(J,d,K),w(d,d,K),g(K,M,V),w(M,M,V),E(V,J),E(X,d),T(d,K,d),T(K,M,J),g(J,d,K),w(d,d,K),E(M,d),w(K,V,X),T(d,K,s),g(d,d,V),T(K,K,d),T(d,V,X),T(V,M,o),E(M,J),u(d,M,b),u(K,V,b)}for(var l=0;l<16;l++)o[l+16]=d[l],o[l+32]=K[l],o[l+48]=M[l],o[l+64]=V[l];var U=o.subarray(32),q=o.subarray(16);v(U,U),T(q,q,U);var R=new Uint8Array(32);return h(R,q),R}t.scalarMult=P;function C(_){return P(_,i)}t.scalarMultBase=C;function $(_){if(_.length!==t.SECRET_KEY_LENGTH)throw new Error("x25519: seed must be "+t.SECRET_KEY_LENGTH+" bytes");var D=new Uint8Array(_),m=C(D);return{publicKey:m,secretKey:D}}t.generateKeyPairFromSeed=$;function x(_){var D=e.randomBytes(32,_),m=$(D);return r.wipe(D),m}t.generateKeyPair=x;function A(_,D,m){if(m===void 0&&(m=!1),_.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(D.length!==t.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");var o=P(_,D);if(m){for(var d=0,M=0;M<o.length;M++)d|=o[M];if(d===0)throw new Error("X25519: invalid shared key")}return o}t.sharedKey=A})($n);function ds(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function Bn(t,e){e||(e=t.reduce((i,s)=>i+s.length,0));const r=ds(e);let n=0;for(const i of t)r.set(i,n),n+=i.length;return r}function cu(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),c=s.charCodeAt(0);if(r[c]!==255)throw new TypeError(s+" is ambiguous");r[c]=i}var u=t.length,h=t.charAt(0),f=Math.log(u)/Math.log(256),g=Math.log(256)/Math.log(u);function w(v){if(v instanceof Uint8Array||(ArrayBuffer.isView(v)?v=new Uint8Array(v.buffer,v.byteOffset,v.byteLength):Array.isArray(v)&&(v=Uint8Array.from(v))),!(v instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(v.length===0)return"";for(var P=0,C=0,$=0,x=v.length;$!==x&&v[$]===0;)$++,P++;for(var A=(x-$)*g+1>>>0,_=new Uint8Array(A);$!==x;){for(var D=v[$],m=0,o=A-1;(D!==0||m<C)&&o!==-1;o--,m++)D+=256*_[o]>>>0,_[o]=D%u>>>0,D=D/u>>>0;if(D!==0)throw new Error("Non-zero carry");C=m,$++}for(var d=A-C;d!==A&&_[d]===0;)d++;for(var M=h.repeat(P);d<A;++d)M+=t.charAt(_[d]);return M}function T(v){if(typeof v!="string")throw new TypeError("Expected String");if(v.length===0)return new Uint8Array;var P=0;if(v[P]!==" "){for(var C=0,$=0;v[P]===h;)C++,P++;for(var x=(v.length-P)*f+1>>>0,A=new Uint8Array(x);v[P];){var _=r[v.charCodeAt(P)];if(_===255)return;for(var D=0,m=x-1;(_!==0||D<$)&&m!==-1;m--,D++)_+=u*A[m]>>>0,A[m]=_%256>>>0,_=_/256>>>0;if(_!==0)throw new Error("Non-zero carry");$=D,P++}if(v[P]!==" "){for(var o=x-$;o!==x&&A[o]===0;)o++;for(var d=new Uint8Array(C+(x-o)),M=C;o!==x;)d[M++]=A[o++];return d}}}function E(v){var P=T(v);if(P)return P;throw new Error(`Non-${e} character`)}return{encode:w,decodeUnsafe:T,decode:E}}var uu=cu,hu=uu;const ps=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},fu=t=>new TextEncoder().encode(t),lu=t=>new TextDecoder().decode(t);class du{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class pu{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){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))}else throw Error("Can only multibase decode strings")}or(e){return gs(this,e)}}class gu{constructor(e){this.decoders=e}or(e){return gs(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const gs=(t,e)=>new gu({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class vu{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new du(e,r,n),this.decoder=new pu(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Yr=({name:t,prefix:e,encode:r,decode:n})=>new vu(t,e,r,n),wr=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=hu(r,e);return Yr({prefix:t,name:e,encode:n,decode:s=>ps(i(s))})},yu=(t,e,r,n)=>{const i={};for(let g=0;g<e.length;++g)i[e[g]]=g;let s=t.length;for(;t[s-1]==="=";)--s;const c=new Uint8Array(s*r/8|0);let u=0,h=0,f=0;for(let g=0;g<s;++g){const w=i[t[g]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<r|w,u+=r,u>=8&&(u-=8,c[f++]=255&h>>u)}if(u>=r||255&h<<8-u)throw new SyntaxError("Unexpected end of data");return c},_u=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",c=0,u=0;for(let h=0;h<t.length;++h)for(u=u<<8|t[h],c+=8;c>r;)c-=r,s+=e[i&u>>c];if(c&&(s+=e[i&u<<r-c]),n)for(;s.length*r&7;)s+="=";return s},tt=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>Yr({prefix:e,name:t,encode(i){return _u(i,n,r)},decode(i){return yu(i,n,r,t)}}),bu=Yr({prefix:"\0",name:"identity",encode:t=>lu(t),decode:t=>fu(t)});var mu=Object.freeze({__proto__:null,identity:bu});const wu=tt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Eu=Object.freeze({__proto__:null,base2:wu});const Du=tt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var xu=Object.freeze({__proto__:null,base8:Du});const Su=wr({prefix:"9",name:"base10",alphabet:"0123456789"});var Ou=Object.freeze({__proto__:null,base10:Su});const Au=tt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Iu=tt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Lu=Object.freeze({__proto__:null,base16:Au,base16upper:Iu});const Tu=tt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Cu=tt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Nu=tt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Pu=tt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ru=tt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Fu=tt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Uu=tt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Mu=tt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),ju=tt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var $u=Object.freeze({__proto__:null,base32:Tu,base32upper:Cu,base32pad:Nu,base32padupper:Pu,base32hex:Ru,base32hexupper:Fu,base32hexpad:Uu,base32hexpadupper:Mu,base32z:ju});const Bu=wr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),zu=wr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Hu=Object.freeze({__proto__:null,base36:Bu,base36upper:zu});const Ku=wr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),qu=wr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Vu=Object.freeze({__proto__:null,base58btc:Ku,base58flickr:qu});const Gu=tt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Wu=tt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),ku=tt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Yu=tt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Ju=Object.freeze({__proto__:null,base64:Gu,base64pad:Wu,base64url:ku,base64urlpad:Yu});const vs=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Xu=vs.reduce((t,e,r)=>(t[r]=e,t),[]),Zu=vs.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function Qu(t){return t.reduce((e,r)=>(e+=Xu[r],e),"")}function eh(t){const e=[];for(const r of t){const n=Zu[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const th=Yr({prefix:"\u{1F680}",name:"base256emoji",encode:Qu,decode:eh});var rh=Object.freeze({__proto__:null,base256emoji:th}),nh=_s,ys=128,ih=127,sh=~ih,oh=Math.pow(2,31);function _s(t,e,r){e=e||[],r=r||0;for(var n=r;t>=oh;)e[r++]=t&255|ys,t/=128;for(;t&sh;)e[r++]=t&255|ys,t>>>=7;return e[r]=t|0,_s.bytes=r-n+1,e}var ah=zn,ch=128,bs=127;function zn(t,n){var r=0,n=n||0,i=0,s=n,c,u=t.length;do{if(s>=u)throw zn.bytes=0,new RangeError("Could not decode varint");c=t[s++],r+=i<28?(c&bs)<<i:(c&bs)*Math.pow(2,i),i+=7}while(c>=ch);return zn.bytes=s-n,r}var uh=Math.pow(2,7),hh=Math.pow(2,14),fh=Math.pow(2,21),lh=Math.pow(2,28),dh=Math.pow(2,35),ph=Math.pow(2,42),gh=Math.pow(2,49),vh=Math.pow(2,56),yh=Math.pow(2,63),_h=function(t){return t<uh?1:t<hh?2:t<fh?3:t<lh?4:t<dh?5:t<ph?6:t<gh?7:t<vh?8:t<yh?9:10},bh={encode:nh,decode:ah,encodingLength:_h},ms=bh;const ws=(t,e,r=0)=>(ms.encode(t,e,r),e),Es=t=>ms.encodingLength(t),Hn=(t,e)=>{const r=e.byteLength,n=Es(t),i=n+Es(r),s=new Uint8Array(i+r);return ws(t,s,0),ws(r,s,n),s.set(e,i),new mh(t,r,e,s)};class mh{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const Ds=({name:t,code:e,encode:r})=>new wh(t,e,r);class wh{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Hn(this.code,r):r.then(n=>Hn(this.code,n))}else throw Error("Unknown type, must be binary type")}}const xs=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),Eh=Ds({name:"sha2-256",code:18,encode:xs("SHA-256")}),Dh=Ds({name:"sha2-512",code:19,encode:xs("SHA-512")});var xh=Object.freeze({__proto__:null,sha256:Eh,sha512:Dh});const Ss=0,Sh="identity",Os=ps;var Oh=Object.freeze({__proto__:null,identity:{code:Ss,name:Sh,encode:Os,digest:t=>Hn(Ss,Os(t))}});new TextEncoder,new TextDecoder;const As={...mu,...Eu,...xu,...Ou,...Lu,...$u,...Hu,...Vu,...Ju,...rh};({...xh,...Oh});function Is(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const Ls=Is("utf8","u",t=>{const e=new TextDecoder("utf8");return"u"+e.decode(t)},t=>new TextEncoder().encode(t.substring(1))),Kn=Is("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=ds(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),Ts={utf8:Ls,"utf-8":Ls,hex:As.base16,latin1:Kn,ascii:Kn,binary:Kn,...As};function ht(t,e="utf8"){const r=Ts[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}function ft(t,e="utf8"){const r=Ts[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):r.encoder.encode(t).substring(1)}var Cs=function(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))},Ah=function(){function t(e,r,n){this.name=e,this.version=r,this.os=n,this.type="browser"}return t}(),Ih=function(){function t(e){this.version=e,this.type="node",this.name="node",this.os=process.platform}return t}(),Lh=function(){function t(e,r,n,i){this.name=e,this.version=r,this.os=n,this.bot=i,this.type="bot-device"}return t}(),Th=function(){function t(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return t}(),Ch=function(){function t(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return t}(),Nh=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,Ph=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Ns=3,Rh=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",Nh]],Ps=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function Fh(t){return t?Rs(t):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new Ch:typeof navigator<"u"?Rs(navigator.userAgent):jh()}function Uh(t){return t!==""&&Rh.reduce(function(e,r){var n=r[0],i=r[1];if(e)return e;var s=i.exec(t);return!!s&&[n,s]},!1)}function Rs(t){var e=Uh(t);if(!e)return null;var r=e[0],n=e[1];if(r==="searchbot")return new Th;var i=n[1]&&n[1].split(".").join("_").split("_").slice(0,3);i?i.length<Ns&&(i=Cs(Cs([],i,!0),$h(Ns-i.length),!0)):i=[];var s=i.join("."),c=Mh(t),u=Ph.exec(t);return u&&u[1]?new Lh(r,s,c,u[1]):new Ah(r,s,c)}function Mh(t){for(var e=0,r=Ps.length;e<r;e++){var n=Ps[e],i=n[0],s=n[1],c=s.exec(t);if(c)return i}return null}function jh(){var t=typeof process<"u"&&process.version;return t?new Ih(process.version.slice(1)):null}function $h(t){for(var e=[],r=0;r<t;r++)e.push("0");return e}var Le={},Fs={},Jr={};Object.defineProperty(Jr,"__esModule",{value:!0}),Jr.delay=void 0;function Bh(t){return new Promise(e=>{setTimeout(()=>{e(!0)},t)})}Jr.delay=Bh;var ir={},qn={},sr={};Object.defineProperty(sr,"__esModule",{value:!0}),sr.ONE_THOUSAND=sr.ONE_HUNDRED=void 0,sr.ONE_HUNDRED=100,sr.ONE_THOUSAND=1e3;var Us={};(function(t){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=t.ONE_MINUTE*5,t.TEN_MINUTES=t.ONE_MINUTE*10,t.THIRTY_MINUTES=t.ONE_MINUTE*30,t.SIXTY_MINUTES=t.ONE_MINUTE*60,t.ONE_HOUR=t.SIXTY_MINUTES,t.THREE_HOURS=t.ONE_HOUR*3,t.SIX_HOURS=t.ONE_HOUR*6,t.TWELVE_HOURS=t.ONE_HOUR*12,t.TWENTY_FOUR_HOURS=t.ONE_HOUR*24,t.ONE_DAY=t.TWENTY_FOUR_HOURS,t.THREE_DAYS=t.ONE_DAY*3,t.FIVE_DAYS=t.ONE_DAY*5,t.SEVEN_DAYS=t.ONE_DAY*7,t.THIRTY_DAYS=t.ONE_DAY*30,t.ONE_WEEK=t.SEVEN_DAYS,t.TWO_WEEKS=t.ONE_WEEK*2,t.THREE_WEEKS=t.ONE_WEEK*3,t.FOUR_WEEKS=t.ONE_WEEK*4,t.ONE_YEAR=t.ONE_DAY*365})(Us),function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(sr,t),r(Us,t)}(qn),Object.defineProperty(ir,"__esModule",{value:!0}),ir.fromMiliseconds=ir.toMiliseconds=void 0;const Ms=qn;function zh(t){return t*Ms.ONE_THOUSAND}ir.toMiliseconds=zh;function Hh(t){return Math.floor(t/Ms.ONE_THOUSAND)}ir.fromMiliseconds=Hh,function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Jr,t),r(ir,t)}(Fs);var Er={};Object.defineProperty(Er,"__esModule",{value:!0}),Er.Watch=void 0;class js{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 r=this.get(e);if(typeof r.elapsed<"u")throw new Error(`Watch already stopped for label: ${e}`);const n=Date.now()-r.started;this.timestamps.set(e,{started:r.started,elapsed:n})}get(e){const r=this.timestamps.get(e);if(typeof r>"u")throw new Error(`No timestamp found for label: ${e}`);return r}elapsed(e){const r=this.get(e);return r.elapsed||Date.now()-r.started}}Er.Watch=js,Er.default=js;var $s={},Xr={};Object.defineProperty(Xr,"__esModule",{value:!0}),Xr.IWatch=void 0;class Kh{}Xr.IWatch=Kh,function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Xr,t)}($s),function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(Fs,t),r(Er,t),r($s,t),r(qn,t)}(Le);var Se={};Object.defineProperty(Se,"__esModule",{value:!0}),Se.getLocalStorage=Se.getLocalStorageOrThrow=Se.getCrypto=Se.getCryptoOrThrow=zs=Se.getLocation=Se.getLocationOrThrow=Vn=Se.getNavigator=Se.getNavigatorOrThrow=Bs=Se.getDocument=Se.getDocumentOrThrow=Se.getFromWindowOrThrow=Se.getFromWindow=void 0;function Wt(t){let e;return typeof window<"u"&&typeof window[t]<"u"&&(e=window[t]),e}Se.getFromWindow=Wt;function or(t){const e=Wt(t);if(!e)throw new Error(`${t} is not defined in Window`);return e}Se.getFromWindowOrThrow=or;function qh(){return or("document")}Se.getDocumentOrThrow=qh;function Vh(){return Wt("document")}var Bs=Se.getDocument=Vh;function Gh(){return or("navigator")}Se.getNavigatorOrThrow=Gh;function Wh(){return Wt("navigator")}var Vn=Se.getNavigator=Wh;function kh(){return or("location")}Se.getLocationOrThrow=kh;function Yh(){return Wt("location")}var zs=Se.getLocation=Yh;function Jh(){return or("crypto")}Se.getCryptoOrThrow=Jh;function Xh(){return Wt("crypto")}Se.getCrypto=Xh;function Zh(){return or("localStorage")}Se.getLocalStorageOrThrow=Zh;function Qh(){return Wt("localStorage")}Se.getLocalStorage=Qh;var Gn={};Object.defineProperty(Gn,"__esModule",{value:!0});var Hs=Gn.getWindowMetadata=void 0;const Ks=Se;function ef(){let t,e;try{t=Ks.getDocumentOrThrow(),e=Ks.getLocationOrThrow()}catch{return null}function r(){const w=t.getElementsByTagName("link"),T=[];for(let E=0;E<w.length;E++){const v=w[E],P=v.getAttribute("rel");if(P&&P.toLowerCase().indexOf("icon")>-1){const C=v.getAttribute("href");if(C)if(C.toLowerCase().indexOf("https:")===-1&&C.toLowerCase().indexOf("http:")===-1&&C.indexOf("//")!==0){let $=e.protocol+"//"+e.host;if(C.indexOf("/")===0)$+=C;else{const x=e.pathname.split("/");x.pop(),$+=x.join("/")+"/"+C}T.push($)}else if(C.indexOf("//")===0){const $=e.protocol+C;T.push($)}else T.push(C)}}return T}function n(...w){const T=t.getElementsByTagName("meta");for(let E=0;E<T.length;E++){const v=T[E],P=["itemprop","property","name"].map(C=>v.getAttribute(C)).filter(C=>C?w.includes(C):!1);if(P.length&&P){const C=v.getAttribute("content");if(C)return C}}return""}function i(){let w=n("name","og:site_name","og:title","twitter:title");return w||(w=t.title),w}function s(){return n("description","og:description","twitter:description","keywords")}const c=i(),u=s(),h=e.origin,f=r();return{description:u,url:h,icons:f,name:c}}Hs=Gn.getWindowMetadata=ef;var Dr={},tf=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),qs="%[a-f0-9]{2}",Vs=new RegExp(qs,"gi"),Gs=new RegExp("("+qs+")+","gi");function Wn(t,e){try{return decodeURIComponent(t.join(""))}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),n=t.slice(e);return Array.prototype.concat.call([],Wn(r),Wn(n))}function rf(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(Vs),r=1;r<e.length;r++)t=Wn(e,r).join(""),e=t.match(Vs);return t}}function nf(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=Gs.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var n=rf(r[0]);n!==r[0]&&(e[r[0]]=n)}r=Gs.exec(t)}e["%C2"]="\uFFFD";for(var i=Object.keys(e),s=0;s<i.length;s++){var c=i[s];t=t.replace(new RegExp(c,"g"),e[c])}return t}var sf=function(t){if(typeof t!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof t+"`");try{return t=t.replace(/\+/g," "),decodeURIComponent(t)}catch{return nf(t)}},of=(t,e)=>{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];const r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]},af=function(t,e){for(var r={},n=Object.keys(t),i=Array.isArray(e),s=0;s<n.length;s++){var c=n[s],u=t[c];(i?e.indexOf(c)!==-1:e(c,u,t))&&(r[c]=u)}return r};(function(t){const e=tf,r=sf,n=of,i=af,s=x=>x==null,c=Symbol("encodeFragmentIdentifier");function u(x){switch(x.arrayFormat){case"index":return A=>(_,D)=>{const m=_.length;return D===void 0||x.skipNull&&D===null||x.skipEmptyString&&D===""?_:D===null?[..._,[g(A,x),"[",m,"]"].join("")]:[..._,[g(A,x),"[",g(m,x),"]=",g(D,x)].join("")]};case"bracket":return A=>(_,D)=>D===void 0||x.skipNull&&D===null||x.skipEmptyString&&D===""?_:D===null?[..._,[g(A,x),"[]"].join("")]:[..._,[g(A,x),"[]=",g(D,x)].join("")];case"colon-list-separator":return A=>(_,D)=>D===void 0||x.skipNull&&D===null||x.skipEmptyString&&D===""?_:D===null?[..._,[g(A,x),":list="].join("")]:[..._,[g(A,x),":list=",g(D,x)].join("")];case"comma":case"separator":case"bracket-separator":{const A=x.arrayFormat==="bracket-separator"?"[]=":"=";return _=>(D,m)=>m===void 0||x.skipNull&&m===null||x.skipEmptyString&&m===""?D:(m=m===null?"":m,D.length===0?[[g(_,x),A,g(m,x)].join("")]:[[D,g(m,x)].join(x.arrayFormatSeparator)])}default:return A=>(_,D)=>D===void 0||x.skipNull&&D===null||x.skipEmptyString&&D===""?_:D===null?[..._,g(A,x)]:[..._,[g(A,x),"=",g(D,x)].join("")]}}function h(x){let A;switch(x.arrayFormat){case"index":return(_,D,m)=>{if(A=/\[(\d*)\]$/.exec(_),_=_.replace(/\[\d*\]$/,""),!A){m[_]=D;return}m[_]===void 0&&(m[_]={}),m[_][A[1]]=D};case"bracket":return(_,D,m)=>{if(A=/(\[\])$/.exec(_),_=_.replace(/\[\]$/,""),!A){m[_]=D;return}if(m[_]===void 0){m[_]=[D];return}m[_]=[].concat(m[_],D)};case"colon-list-separator":return(_,D,m)=>{if(A=/(:list)$/.exec(_),_=_.replace(/:list$/,""),!A){m[_]=D;return}if(m[_]===void 0){m[_]=[D];return}m[_]=[].concat(m[_],D)};case"comma":case"separator":return(_,D,m)=>{const o=typeof D=="string"&&D.includes(x.arrayFormatSeparator),d=typeof D=="string"&&!o&&w(D,x).includes(x.arrayFormatSeparator);D=d?w(D,x):D;const M=o||d?D.split(x.arrayFormatSeparator).map(K=>w(K,x)):D===null?D:w(D,x);m[_]=M};case"bracket-separator":return(_,D,m)=>{const o=/(\[\])$/.test(_);if(_=_.replace(/\[\]$/,""),!o){m[_]=D&&w(D,x);return}const d=D===null?[]:D.split(x.arrayFormatSeparator).map(M=>w(M,x));if(m[_]===void 0){m[_]=d;return}m[_]=[].concat(m[_],d)};default:return(_,D,m)=>{if(m[_]===void 0){m[_]=D;return}m[_]=[].concat(m[_],D)}}}function f(x){if(typeof x!="string"||x.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function g(x,A){return A.encode?A.strict?e(x):encodeURIComponent(x):x}function w(x,A){return A.decode?r(x):x}function T(x){return Array.isArray(x)?x.sort():typeof x=="object"?T(Object.keys(x)).sort((A,_)=>Number(A)-Number(_)).map(A=>x[A]):x}function E(x){const A=x.indexOf("#");return A!==-1&&(x=x.slice(0,A)),x}function v(x){let A="";const _=x.indexOf("#");return _!==-1&&(A=x.slice(_)),A}function P(x){x=E(x);const A=x.indexOf("?");return A===-1?"":x.slice(A+1)}function C(x,A){return A.parseNumbers&&!Number.isNaN(Number(x))&&typeof x=="string"&&x.trim()!==""?x=Number(x):A.parseBooleans&&x!==null&&(x.toLowerCase()==="true"||x.toLowerCase()==="false")&&(x=x.toLowerCase()==="true"),x}function $(x,A){A=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},A),f(A.arrayFormatSeparator);const _=h(A),D=Object.create(null);if(typeof x!="string"||(x=x.trim().replace(/^[?#&]/,""),!x))return D;for(const m of x.split("&")){if(m==="")continue;let[o,d]=n(A.decode?m.replace(/\+/g," "):m,"=");d=d===void 0?null:["comma","separator","bracket-separator"].includes(A.arrayFormat)?d:w(d,A),_(w(o,A),d,D)}for(const m of Object.keys(D)){const o=D[m];if(typeof o=="object"&&o!==null)for(const d of Object.keys(o))o[d]=C(o[d],A);else D[m]=C(o,A)}return A.sort===!1?D:(A.sort===!0?Object.keys(D).sort():Object.keys(D).sort(A.sort)).reduce((m,o)=>{const d=D[o];return Boolean(d)&&typeof d=="object"&&!Array.isArray(d)?m[o]=T(d):m[o]=d,m},Object.create(null))}t.extract=P,t.parse=$,t.stringify=(x,A)=>{if(!x)return"";A=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},A),f(A.arrayFormatSeparator);const _=d=>A.skipNull&&s(x[d])||A.skipEmptyString&&x[d]==="",D=u(A),m={};for(const d of Object.keys(x))_(d)||(m[d]=x[d]);const o=Object.keys(m);return A.sort!==!1&&o.sort(A.sort),o.map(d=>{const M=x[d];return M===void 0?"":M===null?g(d,A):Array.isArray(M)?M.length===0&&A.arrayFormat==="bracket-separator"?g(d,A)+"[]":M.reduce(D(d),[]).join("&"):g(d,A)+"="+g(M,A)}).filter(d=>d.length>0).join("&")},t.parseUrl=(x,A)=>{A=Object.assign({decode:!0},A);const[_,D]=n(x,"#");return Object.assign({url:_.split("?")[0]||"",query:$(P(x),A)},A&&A.parseFragmentIdentifier&&D?{fragmentIdentifier:w(D,A)}:{})},t.stringifyUrl=(x,A)=>{A=Object.assign({encode:!0,strict:!0,[c]:!0},A);const _=E(x.url).split("?")[0]||"",D=t.extract(x.url),m=t.parse(D,{sort:!1}),o=Object.assign(m,x.query);let d=t.stringify(o,A);d&&(d=`?${d}`);let M=v(x.url);return x.fragmentIdentifier&&(M=`#${A[c]?g(x.fragmentIdentifier,A):x.fragmentIdentifier}`),`${_}${d}${M}`},t.pick=(x,A,_)=>{_=Object.assign({parseFragmentIdentifier:!0,[c]:!1},_);const{url:D,query:m,fragmentIdentifier:o}=t.parseUrl(x,_);return t.stringifyUrl({url:D,query:i(m,A),fragmentIdentifier:o},_)},t.exclude=(x,A,_)=>{const D=Array.isArray(A)?m=>!A.includes(m):(m,o)=>!A(m,o);return t.pick(x,D,_)}})(Dr);const cf={waku:{publish:"waku_publish",subscribe:"waku_subscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe"},irn:{publish:"irn_publish",subscribe:"irn_subscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe"},iridium:{publish:"iridium_publish",subscribe:"iridium_subscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe"}},Ws=":";function uf(t){const{namespace:e,reference:r}=t;return[e,r].join(Ws)}function hf(t){const[e,r,n]=t.split(Ws);return{namespace:e,reference:r,address:n}}function ff(t,e){const r=[];return t.forEach(n=>{const i=e(n);r.includes(i)||r.push(i)}),r}function lf(t){const{namespace:e,reference:r}=hf(t);return uf({namespace:e,reference:r})}function df(t){return ff(t,lf)}function kn(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...i.accounts)}),r}function Yn(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...df(i.accounts))}),r}function pf(t,e=[]){const r=[];return Object.keys(t).forEach(n=>{if(e.length&&!e.includes(n))return;const i=t[n];r.push(...i.chains)}),r}const ks="base10",lt="base16",Jn="base64pad",Xn="utf8",Ys=0,xr=1,gf=0,Js=1,Zn=12,Qn=32;function vf(){const t=$n.generateKeyPair();return{privateKey:ft(t.secretKey,lt),publicKey:ft(t.publicKey,lt)}}function ei(){const t=nr.randomBytes(Qn);return ft(t,lt)}function yf(t,e){const r=$n.sharedKey(ht(t,lt),ht(e,lt)),n=new Xc(kr.SHA256,r).expand(Qn);return ft(n,lt)}function _f(t){const e=kr.hash(ht(t,lt));return ft(e,lt)}function Zr(t){const e=kr.hash(ht(t,Xn));return ft(e,lt)}function bf(t){return ht(`${t}`,ks)}function Qr(t){return Number(ft(t,ks))}function mf(t){const e=bf(typeof t.type<"u"?t.type:Ys);if(Qr(e)===xr&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof t.senderPublicKey<"u"?ht(t.senderPublicKey,lt):void 0,n=typeof t.iv<"u"?ht(t.iv,lt):nr.randomBytes(Zn),i=new Ln.ChaCha20Poly1305(ht(t.symKey,lt)).seal(n,ht(t.message,Xn));return Ef({type:e,sealed:i,iv:n,senderPublicKey:r})}function wf(t){const e=new Ln.ChaCha20Poly1305(ht(t.symKey,lt)),{sealed:r,iv:n}=Xs(t.encoded),i=e.open(n,r);if(i===null)throw new Error("Failed to decrypt");return ft(i,Xn)}function Ef(t){if(Qr(t.type)===xr){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return ft(Bn([t.type,t.senderPublicKey,t.iv,t.sealed]),Jn)}return ft(Bn([t.type,t.iv,t.sealed]),Jn)}function Xs(t){const e=ht(t,Jn),r=e.slice(gf,Js),n=Js;if(Qr(r)===xr){const u=n+Qn,h=u+Zn,f=e.slice(n,u),g=e.slice(u,h),w=e.slice(h);return{type:r,sealed:w,iv:g,senderPublicKey:f}}const i=n+Zn,s=e.slice(n,i),c=e.slice(i);return{type:r,sealed:c,iv:s}}function Df(t,e){const r=Xs(t);return Zs({type:Qr(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?ft(r.senderPublicKey,lt):void 0,receiverPublicKey:e?.receiverPublicKey})}function Zs(t){const e=t?.type||Ys;if(e===xr){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function Qs(t){return t.type===xr&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}var xf=Object.defineProperty,eo=Object.getOwnPropertySymbols,Sf=Object.prototype.hasOwnProperty,Of=Object.prototype.propertyIsEnumerable,to=(t,e,r)=>e in t?xf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ro=(t,e)=>{for(var r in e||(e={}))Sf.call(e,r)&&to(t,r,e[r]);if(eo)for(var r of eo(e))Of.call(e,r)&&to(t,r,e[r]);return t};const Af="ReactNative",Sr={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},If="js";function no(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Lf(){return!Bs()&&!!Vn()&&navigator.product===Af}function Tf(){return!no()&&!!Vn()}function Cf(){return Lf()?Sr.reactNative:no()?Sr.node:Tf()?Sr.browser:Sr.unknown}function Nf(t,e){let r=Dr.parse(t);return r=ro(ro({},r),e),t=Dr.stringify(r),t}function Pf(){return Hs()||{name:"",description:"",url:"",icons:[""]}}function Rf(){const t=Fh();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function Ff(){var t;const e=Cf();return e===Sr.browser?[e,((t=zs())==null?void 0:t.host)||"unknown"].join(":"):e}function Uf(t,e,r){const n=Rf(),i=Ff();return[[t,e].join("-"),[If,r].join("-"),n,i].join("/")}function Mf({protocol:t,version:e,relayUrl:r,sdkVersion:n,auth:i,projectId:s}){const c=r.split("?"),u=Uf(t,e,n),h={auth:i,ua:u,projectId:s},f=Nf(c[1]||"",h);return c[0]+"?"+f}function dt(t,e){return t.filter(r=>e.includes(r)).length===t.length}function io(t){return Object.fromEntries(t.entries())}function so(t){return new Map(Object.entries(t))}function ar(t,e){return Le.fromMiliseconds((e||Date.now())+Le.toMiliseconds(t))}function kt(t){return Le.fromMiliseconds(Date.now())>=Le.toMiliseconds(t)}function Yt(){const t=Le.toMiliseconds(Le.FIVE_MINUTES);let e,r,n;return{resolve:i=>{n&&e&&(clearTimeout(n),e(i))},reject:i=>{n&&r&&(clearTimeout(n),r(i))},done:()=>new Promise((i,s)=>{n=setTimeout(s,t),e=i,r=s})}}function oo(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${t}`)}function jf(t){return oo("topic",t)}function $f(t){return oo("id",t)}function Bf(t){const[e,r]=t.split(":"),n={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")n.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))n.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return n}function Fe(t,e){return`${t}${e?`:${e}`:""}`}const zf="irn";function ti(t){return t?.relay||{protocol:zf}}function ri(t){const e=cf[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var Hf=Object.defineProperty,ao=Object.getOwnPropertySymbols,Kf=Object.prototype.hasOwnProperty,qf=Object.prototype.propertyIsEnumerable,co=(t,e,r)=>e in t?Hf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Vf=(t,e)=>{for(var r in e||(e={}))Kf.call(e,r)&&co(t,r,e[r]);if(ao)for(var r of ao(e))qf.call(e,r)&&co(t,r,e[r]);return t};function Gf(t,e="-"){const r={},n="relay"+e;return Object.keys(t).forEach(i=>{if(i.startsWith(n)){const s=i.replace(n,""),c=t[i];r[s]=c}}),r}function Wf(t){const e=t.indexOf(":"),r=t.indexOf("?")!==-1?t.indexOf("?"):void 0,n=t.substring(0,e),i=t.substring(e+1,r).split("@"),s=typeof r<"u"?t.substring(r):"",c=Dr.parse(s);return{protocol:n,topic:i[0],version:parseInt(i[1],10),symKey:c.symKey,relay:Gf(c)}}function kf(t,e="-"){const r="relay",n={};return Object.keys(t).forEach(i=>{const s=r+e+i;t[i]&&(n[s]=t[i])}),n}function Yf(t){return`${t.protocol}:${t.topic}@${t.version}?`+Dr.stringify(Vf({symKey:t.symKey},kf(t.relay)))}function At(t){const e=[];return t.forEach(r=>{const[n,i]=r.split(":");e.push(`${n}:${i}`)}),e}function Jf(t){const e=[];return Object.values(t).forEach(r=>{e.push(...At(r.accounts)),r.extension&&r.extension.forEach(n=>{e.push(...At(n.accounts))})}),e}function Xf(t,e){const r=[];return Object.values(t).forEach(n=>{At(n.accounts).includes(e)&&r.push(...n.methods),n.extension&&n.extension.forEach(i=>{At(i.accounts).includes(e)&&r.push(...i.methods)})}),r}function Zf(t,e){const r=[];return Object.values(t).forEach(n=>{At(n.accounts).includes(e)&&r.push(...n.events),n.extension&&n.extension.forEach(i=>{At(i.accounts).includes(e)&&r.push(...i.events)})}),r}const Qf={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3}},el={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function G(t,e){const{message:r,code:n}=el[t];return{message:e?`${r} ${e}`:r,code:n}}function rt(t,e){const{message:r,code:n}=Qf[t];return{message:e?`${r} ${e}`:r,code:n}}function Or(t,e){return Array.isArray(t)?typeof e<"u"&&t.length?t.every(e):!0:!1}function uo(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function Et(t){return typeof t>"u"}function ot(t,e){return e&&Et(t)?!0:typeof t=="string"&&Boolean(t.trim().length)}function ho(t,e){return e&&Et(t)?!0:typeof t=="number"&&!isNaN(t)}function tl(t,e){const{requiredNamespaces:r}=e,n=Object.keys(t.namespaces),i=Object.keys(r);let s=!0;return dt(i,n)?(n.forEach(c=>{const{accounts:u,methods:h,events:f,extension:g}=t.namespaces[c],w=At(u),T=r[c];(!dt(T.chains,w)||!dt(T.methods,h)||!dt(T.events,f))&&(s=!1),s&&g&&g.forEach(E=>{var v;const{accounts:P,methods:C,events:$}=E,x=At(P);(v=T.extension)!=null&&v.find(A=>dt(A.chains,x)&&dt(A.methods,C)&&dt(A.events,$))||(s=!1)})}),s):!1}function ni(t){return ot(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function rl(t){if(ot(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&ni(r)}}return!1}function nl(t){if(ot(t,!1))try{return typeof new URL(t)<"u"}catch{return!1}return!1}function il(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function sl(t){return t?.topic}function ol(t,e){let r=null;return ot(t?.publicKey,!1)||(r=G("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function ii(t,e){let r=null;return Et(t?.extension)||(!Or(t.extension)||!t.extension.length)&&(r=G("MISSING_OR_INVALID",`${e} extension should be an array of namespaces, or omitted`)),r}function fo(t){let e=!0;return Or(t)?t.length&&(e=t.every(r=>ot(r,!1))):e=!1,e}function lo(t,e,r){let n=null;return Or(e)?e.forEach(i=>{n||(!ni(i)||!i.includes(t))&&(n=rt("UNSUPPORTED_CHAINS",`${r}, chain ${i} should be a string and conform to "namespace:chainId" format`))}):n=rt("UNSUPPORTED_CHAINS",`${r}, chains ${e} should be an array of strings conforming to "namespace:chainId" format`),n}function al(t,e){let r=null;return Object.entries(t).forEach(([n,i])=>{if(r)return;const s=lo(n,i?.chains,`${e} requiredNamespace`),c=ii(i,e);s?r=s:c?r=c:i.extension&&i.extension.forEach(u=>{if(r)return;const h=lo(n,u.chains,`${e} extension`);h&&(r=h)})}),r}function po(t,e){let r=null;return Or(t)?t.forEach(n=>{r||rl(n)||(r=rt("UNSUPPORTED_ACCOUNTS",`${e}, account ${n} should be a string and conform to "namespace:chainId:address" format`))}):r=rt("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function cl(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=po(n?.accounts,`${e} namespace`),s=ii(n,e);i?r=i:s?r=s:n.extension&&n.extension.forEach(c=>{if(r)return;const u=po(c.accounts,`${e} extension`);u&&(r=u)})}),r}function go(t,e){let r=null;return fo(t?.methods)?fo(t?.events)||(r=rt("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=rt("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function vo(t,e){let r=null;return Object.values(t).forEach(n=>{if(r)return;const i=go(n,`${e}, namespace`),s=ii(n,e);i?r=i:s?r=s:n.extension&&n.extension.forEach(c=>{if(r)return;const u=go(c,`${e}, extension`);u&&(r=u)})}),r}function ul(t,e){let r=null;if(t&&uo(t)){const n=vo(t,e);n&&(r=n);const i=al(t,e);i&&(r=i)}else r=G("MISSING_OR_INVALID",`${e}, requiredNamespaces should be an object with data`);return r}function si(t,e){let r=null;if(t&&uo(t)){const n=vo(t,e);n&&(r=n);const i=cl(t,e);i&&(r=i)}else r=G("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function yo(t){return ot(t.protocol,!0)}function hl(t,e){let r=!1;return e&&!t?r=!0:t&&Or(t)&&t.length&&t.forEach(n=>{r=yo(n)}),r}function fl(t){return typeof t=="number"}function yt(t){return typeof t<"u"&&typeof t!==null}function ll(t){return!(!t||typeof t!="object"||!t.code||!ho(t.code,!1)||!t.message||!ot(t.message,!1))}function dl(t){return!(Et(t)||!ot(t.method,!1))}function pl(t){return!(Et(t)||Et(t.result)&&Et(t.error)||!ho(t.id,!1)||!ot(t.jsonrpc,!1))}function gl(t){return!(Et(t)||!ot(t.name,!1))}function _o(t,e){return!(!ni(e)||!Jf(t).includes(e))}function vl(t,e,r){return ot(r,!1)?Xf(t,e).includes(r):!1}function yl(t,e,r){return ot(r,!1)?Zf(t,e).includes(r):!1}function bo(t,e,r){let n=null;const i=Object.keys(t),s=Object.keys(e);return dt(i,s)?i.forEach(c=>{var u;if(n)return;const h=t[c].chains,f=At(e[c].accounts);dt(h,f)?dt(t[c].methods,e[c].methods)?dt(t[c].events,e[c].events)?t[c].extension&&!e[c].extension?n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${c}`):t[c].extension&&e[c].extension&&((u=t[c].extension)==null||u.forEach(({methods:g,events:w,chains:T})=>{var E;n||(E=e[c].extension)!=null&&E.find(v=>{const P=At(v.accounts);return dt(T,P)&&dt(w,v.events)&&dt(g,v.methods)})||(n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces extension doesn't satisfy requiredNamespaces extension for ${c}`))})):n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy requiredNamespaces events for ${c}`):n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy requiredNamespaces methods for ${c}`):n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy requiredNamespaces chains for ${c}`)}):n=G("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces`),n}function _l(t){try{return JSON.stringify(t)}catch{return'"[Circular]"'}}var bl=ml;function ml(t,e,r){var n=r&&r.stringify||_l,i=1;if(typeof t=="object"&&t!==null){var s=e.length+i;if(s===1)return t;var c=new Array(s);c[0]=n(t);for(var u=1;u<s;u++)c[u]=n(e[u]);return c.join(" ")}if(typeof t!="string")return t;var h=e.length;if(h===0)return t;for(var f="",g=1-i,w=-1,T=t&&t.length||0,E=0;E<T;){if(t.charCodeAt(E)===37&&E+1<T){switch(w=w>-1?w:0,t.charCodeAt(E+1)){case 100:case 102:if(g>=h||e[g]==null)break;w<E&&(f+=t.slice(w,E)),f+=Number(e[g]),w=E+2,E++;break;case 105:if(g>=h||e[g]==null)break;w<E&&(f+=t.slice(w,E)),f+=Math.floor(Number(e[g])),w=E+2,E++;break;case 79:case 111:case 106:if(g>=h||e[g]===void 0)break;w<E&&(f+=t.slice(w,E));var v=typeof e[g];if(v==="string"){f+="'"+e[g]+"'",w=E+2,E++;break}if(v==="function"){f+=e[g].name||"<anonymous>",w=E+2,E++;break}f+=n(e[g]),w=E+2,E++;break;case 115:if(g>=h)break;w<E&&(f+=t.slice(w,E)),f+=String(e[g]),w=E+2,E++;break;case 37:w<E&&(f+=t.slice(w,E)),f+="%",w=E+2,E++,g--;break}++g}++E}return w===-1?t:(w<T&&(f+=t.slice(w)),f)}var mo=bl,oi=It,Ar=Ll().console||{},wl={mapHttpRequest:tn,mapHttpResponse:tn,wrapRequestSerializer:ci,wrapResponseSerializer:ci,wrapErrorSerializer:ci,req:tn,res:tn,err:Sl};function It(t){t=t||{},t.browser=t.browser||{};var e=t.browser.transmit;if(e&&typeof e.send!="function")throw Error("pino: transmit option must have a send function");var r=t.browser.write||Ar;t.browser.write&&(t.browser.asObject=!0);var n=t.serializers||{},i=Array.isArray(t.browser.serialize)?t.browser.serialize.filter(function(v){return v!=="!stdSerializers.err"}):t.browser.serialize===!0?Object.keys(n):!1,s=t.browser.serialize;Array.isArray(t.browser.serialize)&&t.browser.serialize.indexOf("!stdSerializers.err")>-1&&(s=!1);var c=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),t.enabled===!1&&(t.level="silent");var u=t.level||"info",h=Object.create(r);h.log||(h.log=Ir),Object.defineProperty(h,"levelVal",{get:g}),Object.defineProperty(h,"level",{get:w,set:T});var f={transmit:e,serialize:i,asObject:t.browser.asObject,levels:c,timestamp:Ol(t)};h.levels=It.levels,h.level=u,h.setMaxListeners=h.getMaxListeners=h.emit=h.addListener=h.on=h.prependListener=h.once=h.prependOnceListener=h.removeListener=h.removeAllListeners=h.listeners=h.listenerCount=h.eventNames=h.write=h.flush=Ir,h.serializers=n,h._serialize=i,h._stdErrSerialize=s,h.child=E,e&&(h._logEvent=ai());function g(){return this.level==="silent"?1/0:this.levels.values[this.level]}function w(){return this._level}function T(v){if(v!=="silent"&&!this.levels.values[v])throw Error("unknown level "+v);this._level=v,cr(f,h,"error","log"),cr(f,h,"fatal","error"),cr(f,h,"warn","error"),cr(f,h,"info","log"),cr(f,h,"debug","log"),cr(f,h,"trace","log")}function E(v){if(!v)throw new Error("missing bindings for child Pino");var P=v.serializers;if(i&&P){var C=Object.assign({},n,P),$=t.browser.serialize===!0?Object.keys(C):i;delete v.serializers,en([v],$,C,this._stdErrSerialize)}function x(A){this._childLevel=(A._childLevel|0)+1,this.error=ur(A,v,"error"),this.fatal=ur(A,v,"fatal"),this.warn=ur(A,v,"warn"),this.info=ur(A,v,"info"),this.debug=ur(A,v,"debug"),this.trace=ur(A,v,"trace"),C&&(this.serializers=C,this._serialize=$),e&&(this._logEvent=ai([].concat(A._logEvent.bindings,v)))}return x.prototype=this,new x(this)}return h}It.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},It.stdSerializers=wl,It.stdTimeFunctions=Object.assign({},{nullTime:wo,epochTime:Eo,unixTime:Al,isoTime:Il});function cr(t,e,r,n){var i=Object.getPrototypeOf(e);e[r]=e.levelVal>e.levels.values[r]?Ir:i[r]?i[r]:Ar[r]||Ar[n]||Ir,El(t,e,r)}function El(t,e,r){!t.transmit&&e[r]===Ir||(e[r]=function(n){return function(){for(var s=t.timestamp(),c=new Array(arguments.length),u=Object.getPrototypeOf&&Object.getPrototypeOf(this)===Ar?Ar:this,h=0;h<c.length;h++)c[h]=arguments[h];if(t.serialize&&!t.asObject&&en(c,this._serialize,this.serializers,this._stdErrSerialize),t.asObject?n.call(u,Dl(this,r,c,s)):n.apply(u,c),t.transmit){var f=t.transmit.level||e.level,g=It.levels.values[f],w=It.levels.values[r];if(w<g)return;xl(this,{ts:s,methodLevel:r,methodValue:w,transmitLevel:f,transmitValue:It.levels.values[t.transmit.level||e.level],send:t.transmit.send,val:e.levelVal},c)}}}(e[r]))}function Dl(t,e,r,n){t._serialize&&en(r,t._serialize,t.serializers,t._stdErrSerialize);var i=r.slice(),s=i[0],c={};n&&(c.time=n),c.level=It.levels.values[e];var u=(t._childLevel|0)+1;if(u<1&&(u=1),s!==null&&typeof s=="object"){for(;u--&&typeof i[0]=="object";)Object.assign(c,i.shift());s=i.length?mo(i.shift(),i):void 0}else typeof s=="string"&&(s=mo(i.shift(),i));return s!==void 0&&(c.msg=s),c}function en(t,e,r,n){for(var i in t)if(n&&t[i]instanceof Error)t[i]=It.stdSerializers.err(t[i]);else if(typeof t[i]=="object"&&!Array.isArray(t[i]))for(var s in t[i])e&&e.indexOf(s)>-1&&s in r&&(t[i][s]=r[s](t[i][s]))}function ur(t,e,r){return function(){var n=new Array(1+arguments.length);n[0]=e;for(var i=1;i<n.length;i++)n[i]=arguments[i-1];return t[r].apply(this,n)}}function xl(t,e,r){var n=e.send,i=e.ts,s=e.methodLevel,c=e.methodValue,u=e.val,h=t._logEvent.bindings;en(r,t._serialize||Object.keys(t.serializers),t.serializers,t._stdErrSerialize===void 0?!0:t._stdErrSerialize),t._logEvent.ts=i,t._logEvent.messages=r.filter(function(f){return h.indexOf(f)===-1}),t._logEvent.level.label=s,t._logEvent.level.value=c,n(s,t._logEvent,u),t._logEvent=ai(h)}function ai(t){return{ts:0,messages:[],bindings:t||[],level:{label:"",value:0}}}function Sl(t){var e={type:t.constructor.name,msg:t.message,stack:t.stack};for(var r in t)e[r]===void 0&&(e[r]=t[r]);return e}function Ol(t){return typeof t.timestamp=="function"?t.timestamp:t.timestamp===!1?wo:Eo}function tn(){return{}}function ci(t){return t}function Ir(){}function wo(){return!1}function Eo(){return Date.now()}function Al(){return Math.round(Date.now()/1e3)}function Il(){return new Date(Date.now()).toISOString()}function Ll(){function t(e){return typeof e<"u"&&e}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return t(self)||t(window)||t(this)||{}}}var rn={},ui=function(t,e){return ui=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(r[i]=n[i])},ui(t,e)};function Tl(t,e){if(typeof e!="function"&&e!==null)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");ui(t,e);function r(){this.constructor=t}t.prototype=e===null?Object.create(e):(r.prototype=e.prototype,new r)}var hi=function(){return hi=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},hi.apply(this,arguments)};function Cl(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function Nl(t,e,r,n){var i=arguments.length,s=i<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,r):n,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(t,e,r,n);else for(var u=t.length-1;u>=0;u--)(c=t[u])&&(s=(i<3?c(s):i>3?c(e,r,s):c(e,r))||s);return i>3&&s&&Object.defineProperty(e,r,s),s}function Pl(t,e){return function(r,n){e(r,n,t)}}function Rl(t,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(t,e)}function Fl(t,e,r,n){function i(s){return s instanceof r?s:new r(function(c){c(s)})}return new(r||(r=Promise))(function(s,c){function u(g){try{f(n.next(g))}catch(w){c(w)}}function h(g){try{f(n.throw(g))}catch(w){c(w)}}function f(g){g.done?s(g.value):i(g.value).then(u,h)}f((n=n.apply(t,e||[])).next())})}function Ul(t,e){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,c;return c={next:u(0),throw:u(1),return:u(2)},typeof Symbol=="function"&&(c[Symbol.iterator]=function(){return this}),c;function u(f){return function(g){return h([f,g])}}function h(f){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=f[0]&2?i.return:f[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,f[1])).done)return s;switch(i=0,s&&(f=[f[0]&2,s.value]),f[0]){case 0:case 1:s=f;break;case 4:return r.label++,{value:f[1],done:!1};case 5:r.label++,i=f[1],f=[0];continue;case 7:f=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(f[0]===6||f[0]===2)){r=0;continue}if(f[0]===3&&(!s||f[1]>s[0]&&f[1]<s[3])){r.label=f[1];break}if(f[0]===6&&r.label<s[1]){r.label=s[1],s=f;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(f);break}s[2]&&r.ops.pop(),r.trys.pop();continue}f=e.call(t,r)}catch(g){f=[6,g],i=0}finally{n=s=0}if(f[0]&5)throw f[1];return{value:f[0]?f[1]:void 0,done:!0}}}var fi=Object.create?function(t,e,r,n){n===void 0&&(n=r);var i=Object.getOwnPropertyDescriptor(e,r);(!i||("get"in i?!e.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,n,i)}:function(t,e,r,n){n===void 0&&(n=r),t[n]=e[r]};function Ml(t,e){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(e,r)&&fi(e,t,r)}function li(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function Do(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],c;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(u){c={error:u}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(c)throw c.error}}return s}function jl(){for(var t=[],e=0;e<arguments.length;e++)t=t.concat(Do(arguments[e]));return t}function $l(){for(var t=0,e=0,r=arguments.length;e<r;e++)t+=arguments[e].length;for(var n=Array(t),i=0,e=0;e<r;e++)for(var s=arguments[e],c=0,u=s.length;c<u;c++,i++)n[i]=s[c];return n}function Bl(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))}function Lr(t){return this instanceof Lr?(this.v=t,this):new Lr(t)}function zl(t,e,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(t,e||[]),i,s=[];return i={},c("next"),c("throw"),c("return"),i[Symbol.asyncIterator]=function(){return this},i;function c(T){n[T]&&(i[T]=function(E){return new Promise(function(v,P){s.push([T,E,v,P])>1||u(T,E)})})}function u(T,E){try{h(n[T](E))}catch(v){w(s[0][3],v)}}function h(T){T.value instanceof Lr?Promise.resolve(T.value.v).then(f,g):w(s[0][2],T)}function f(T){u("next",T)}function g(T){u("throw",T)}function w(T,E){T(E),s.shift(),s.length&&u(s[0][0],s[0][1])}}function Hl(t){var e,r;return e={},n("next"),n("throw",function(i){throw i}),n("return"),e[Symbol.iterator]=function(){return this},e;function n(i,s){e[i]=t[i]?function(c){return(r=!r)?{value:Lr(t[i](c)),done:i==="return"}:s?s(c):c}:s}}function Kl(t){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var e=t[Symbol.asyncIterator],r;return e?e.call(t):(t=typeof li=="function"?li(t):t[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=t[s]&&function(c){return new Promise(function(u,h){c=t[s](c),i(u,h,c.done,c.value)})}}function i(s,c,u,h){Promise.resolve(h).then(function(f){s({value:f,done:u})},c)}}function ql(t,e){return Object.defineProperty?Object.defineProperty(t,"raw",{value:e}):t.raw=e,t}var Vl=Object.create?function(t,e){Object.defineProperty(t,"default",{enumerable:!0,value:e})}:function(t,e){t.default=e};function Gl(t){if(t&&t.__esModule)return t;var e={};if(t!=null)for(var r in t)r!=="default"&&Object.prototype.hasOwnProperty.call(t,r)&&fi(e,t,r);return Vl(e,t),e}function Wl(t){return t&&t.__esModule?t:{default:t}}function kl(t,e,r,n){if(r==="a"&&!n)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return r==="m"?n:r==="a"?n.call(t):n?n.value:e.get(t)}function Yl(t,e,r,n,i){if(n==="m")throw new TypeError("Private method is not writable");if(n==="a"&&!i)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return n==="a"?i.call(t,r):i?i.value=r:e.set(t,r),r}function Jl(t,e){if(e===null||typeof e!="object"&&typeof e!="function")throw new TypeError("Cannot use 'in' operator on non-object");return typeof t=="function"?e===t:t.has(e)}var Xl=Object.freeze({__proto__:null,__extends:Tl,get __assign(){return hi},__rest:Cl,__decorate:Nl,__param:Pl,__metadata:Rl,__awaiter:Fl,__generator:Ul,__createBinding:fi,__exportStar:Ml,__values:li,__read:Do,__spread:jl,__spreadArrays:$l,__spreadArray:Bl,__await:Lr,__asyncGenerator:zl,__asyncDelegator:Hl,__asyncValues:Kl,__makeTemplateObject:ql,__importStar:Gl,__importDefault:Wl,__classPrivateFieldGet:kl,__classPrivateFieldSet:Yl,__classPrivateFieldIn:Jl}),di=wn(Xl),nn={exports:{}},xo;function Zl(){return xo||(xo=1,function(){var t;function e(){}t=e,t.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},t.prototype.setItem=function(r,n){this[r]=String(n)},t.prototype.removeItem=function(r){delete this[r]},t.prototype.clear=function(){var r=this;Object.keys(r).forEach(function(n){r[n]=void 0,delete r[n]})},t.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},t.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),Z.localStorage?nn.exports=localStorage:nn.exports=new e}()),nn.exports}var Tr={},So;function Oo(){if(So)return Tr;So=1,Object.defineProperty(Tr,"__esModule",{value:!0});function t(r){if(typeof r!="string")throw new Error(`Cannot safe json parse value of type ${typeof r}`);try{return JSON.parse(r)}catch{return r}}Tr.safeJsonParse=t;function e(r){return typeof r=="string"?r:JSON.stringify(r,(n,i)=>typeof i>"u"?null:i)}return Tr.safeJsonStringify=e,Tr}var pi={},Cr={},Ao;function Ql(){if(Ao)return Cr;Ao=1,Object.defineProperty(Cr,"__esModule",{value:!0}),Cr.IKeyValueStorage=void 0;class t{}return Cr.IKeyValueStorage=t,Cr}var Nr={},Io;function ed(){if(Io)return Nr;Io=1,Object.defineProperty(Nr,"__esModule",{value:!0}),Nr.parseEntry=void 0;const t=Oo();function e(r){var n;return[r[0],t.safeJsonParse((n=r[1])!==null&&n!==void 0?n:"")]}return Nr.parseEntry=e,Nr}var Lo;function td(){return Lo||(Lo=1,function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=di;e.__exportStar(Ql(),t),e.__exportStar(ed(),t)}(pi)),pi}Object.defineProperty(rn,"__esModule",{value:!0}),rn.KeyValueStorage=void 0;const hr=di,rd=hr.__importDefault(Zl()),To=Oo(),nd=td();class Co{constructor(){this.localStorage=rd.default}getKeys(){return hr.__awaiter(this,void 0,void 0,function*(){return Object.keys(this.localStorage)})}getEntries(){return hr.__awaiter(this,void 0,void 0,function*(){return Object.entries(this.localStorage).map(nd.parseEntry)})}getItem(e){return hr.__awaiter(this,void 0,void 0,function*(){const r=this.localStorage.getItem(e);if(r!==null)return To.safeJsonParse(r)})}setItem(e,r){return hr.__awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(e,To.safeJsonStringify(r))})}removeItem(e){return hr.__awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}}rn.KeyValueStorage=Co;var id=rn.default=Co,Pr={},sn={},gi={},on={};class Jt{}var sd=Object.freeze({__proto__:null,IEvents:Jt}),od=wn(sd);Object.defineProperty(on,"__esModule",{value:!0}),on.IHeartBeat=void 0;const ad=od;class cd extends ad.IEvents{constructor(e){super()}}on.IHeartBeat=cd,function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(on,t)}(gi);var vi={},fr={};Object.defineProperty(fr,"__esModule",{value:!0}),fr.HEARTBEAT_EVENTS=fr.HEARTBEAT_INTERVAL=void 0;const ud=Le;fr.HEARTBEAT_INTERVAL=ud.FIVE_SECONDS,fr.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(fr,t)}(vi);var yi=Z&&Z.__awaiter||function(t,e,r,n){function i(s){return s instanceof r?s:new r(function(c){c(s)})}return new(r||(r=Promise))(function(s,c){function u(g){try{f(n.next(g))}catch(w){c(w)}}function h(g){try{f(n.throw(g))}catch(w){c(w)}}function f(g){g.done?s(g.value):i(g.value).then(u,h)}f((n=n.apply(t,e||[])).next())})};Object.defineProperty(sn,"__esModule",{value:!0}),sn.HeartBeat=void 0;const hd=vr,fd=Le,ld=gi,_i=vi;class bi extends ld.IHeartBeat{constructor(e){super(e),this.events=new hd.EventEmitter,this.interval=_i.HEARTBEAT_INTERVAL,this.interval=e?.interval||_i.HEARTBEAT_INTERVAL}static init(e){return yi(this,void 0,void 0,function*(){const r=new bi(e);return yield r.init(),r})}init(){return yi(this,void 0,void 0,function*(){yield this.initialize()})}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}initialize(){return yi(this,void 0,void 0,function*(){setInterval(()=>this.pulse(),fd.toMiliseconds(this.interval))})}pulse(){this.events.emit(_i.HEARTBEAT_EVENTS.pulse)}}sn.HeartBeat=bi,function(t){var e=Z&&Z.__createBinding||(Object.create?function(n,i,s,c){c===void 0&&(c=s),Object.defineProperty(n,c,{enumerable:!0,get:function(){return i[s]}})}:function(n,i,s,c){c===void 0&&(c=s),n[c]=i[s]}),r=Z&&Z.__exportStar||function(n,i){for(var s in n)s!=="default"&&!i.hasOwnProperty(s)&&e(i,n,s)};Object.defineProperty(t,"__esModule",{value:!0}),r(sn,t),r(gi,t),r(vi,t)}(Pr);var Oe={},Xt={},No;function Po(){return No||(No=1,Object.defineProperty(Xt,"__esModule",{value:!0}),Xt.PINO_CUSTOM_CONTEXT_KEY=Xt.PINO_LOGGER_DEFAULTS=void 0,Xt.PINO_LOGGER_DEFAULTS={level:"info"},Xt.PINO_CUSTOM_CONTEXT_KEY="custom_context"),Xt}var ct={},Ro;function dd(){if(Ro)return ct;Ro=1,Object.defineProperty(ct,"__esModule",{value:!0}),ct.generateChildLogger=ct.formatChildLoggerContext=ct.getLoggerContext=ct.setBrowserLoggerContext=ct.getBrowserLoggerContext=ct.getDefaultLoggerOptions=void 0;const t=Po();function e(u){return Object.assign(Object.assign({},u),{level:u?.level||t.PINO_LOGGER_DEFAULTS.level})}ct.getDefaultLoggerOptions=e;function r(u,h=t.PINO_CUSTOM_CONTEXT_KEY){return u[h]||""}ct.getBrowserLoggerContext=r;function n(u,h,f=t.PINO_CUSTOM_CONTEXT_KEY){return u[f]=h,u}ct.setBrowserLoggerContext=n;function i(u,h=t.PINO_CUSTOM_CONTEXT_KEY){let f="";return typeof u.bindings>"u"?f=r(u,h):f=u.bindings().context||"",f}ct.getLoggerContext=i;function s(u,h,f=t.PINO_CUSTOM_CONTEXT_KEY){const g=i(u,f);return g.trim()?`${g}/${h}`:h}ct.formatChildLoggerContext=s;function c(u,h,f=t.PINO_CUSTOM_CONTEXT_KEY){const g=s(u,h,f),w=u.child({context:g});return n(w,g,f)}return ct.generateChildLogger=c,ct}(function(t){Object.defineProperty(t,"__esModule",{value:!0});const e=di;e.__exportStar(Po(),t),e.__exportStar(dd(),t)})(Oe);class pd extends Jt{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class gd extends Jt{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class vd{constructor(e,r){this.logger=e,this.core=r}}class yd extends Jt{constructor(e,r){super(),this.relayer=e,this.logger=r}}class _d extends Jt{constructor(e){super()}}class bd{constructor(e,r,n,i){this.core=e,this.logger=r,this.name=n}}class md extends Jt{constructor(e,r){super(),this.relayer=e,this.logger=r}}function qe(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var wd=qe;qe.EventEmitter=qe,qe.prototype._events=void 0,qe.prototype._maxListeners=void 0,qe.defaultMaxListeners=10,qe.prototype.setMaxListeners=function(t){if(!Ed(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},qe.prototype.emit=function(t){var e,r,n,i,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Rr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],Fo(r))return!1;if(Rt(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(Rr(r))for(i=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,s=0;s<n;s++)c[s].apply(this,i);return!0},qe.prototype.addListener=function(t,e){var r;if(!Rt(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Rt(e.listener)?e.listener:e),this._events[t]?Rr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Rr(this._events[t])&&!this._events[t].warned&&(Fo(this._maxListeners)?r=qe.defaultMaxListeners:r=this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),typeof console.trace=="function"&&console.trace())),this},qe.prototype.on=qe.prototype.addListener,qe.prototype.once=function(t,e){if(!Rt(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},qe.prototype.removeListener=function(t,e){var r,n,i,s;if(!Rt(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],i=r.length,n=-1,r===e||Rt(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(Rr(r)){for(s=i;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(n<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},qe.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[t]&&delete this._events[t],this;if(arguments.length===0){for(e in this._events)e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],Rt(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},qe.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Rt(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},qe.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Rt(e))return 1;if(e)return e.length}return 0},qe.listenerCount=function(t,e){return t.listenerCount(e)};function Rt(t){return typeof t=="function"}function Ed(t){return typeof t=="number"}function Rr(t){return typeof t=="object"&&t!==null}function Fo(t){return t===void 0}class Dd{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}class Lv extends wd.EventEmitter{constructor(){super()}}class xd{constructor(e){this.client=e}}class Sd extends Jt{constructor(e,r){super(),this.core=e,this.logger=r}}var mi={},Uo={};(function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=re,r=pt;t.DIGEST_LENGTH=64,t.BLOCK_SIZE=128;var n=function(){function u(){this.digestLength=t.DIGEST_LENGTH,this.blockSize=t.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return u.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},u.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},u.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},u.prototype.update=function(h,f){if(f===void 0&&(f=h.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var g=0;if(this._bytesHashed+=f,this._bufferLength>0){for(;this._bufferLength<t.BLOCK_SIZE&&f>0;)this._buffer[this._bufferLength++]=h[g++],f--;this._bufferLength===this.blockSize&&(s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(f>=this.blockSize&&(g=s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,h,g,f),f%=this.blockSize);f>0;)this._buffer[this._bufferLength++]=h[g++],f--;return this},u.prototype.finish=function(h){if(!this._finished){var f=this._bytesHashed,g=this._bufferLength,w=f/536870912|0,T=f<<3,E=f%128<112?128:256;this._buffer[g]=128;for(var v=g+1;v<E-8;v++)this._buffer[v]=0;e.writeUint32BE(w,this._buffer,E-8),e.writeUint32BE(T,this._buffer,E-4),s(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,E),this._finished=!0}for(var v=0;v<this.digestLength/8;v++)e.writeUint32BE(this._stateHi[v],h,v*8),e.writeUint32BE(this._stateLo[v],h,v*8+4);return this},u.prototype.digest=function(){var h=new Uint8Array(this.digestLength);return this.finish(h),h},u.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},u.prototype.restoreState=function(h){return this._stateHi.set(h.stateHi),this._stateLo.set(h.stateLo),this._bufferLength=h.bufferLength,h.buffer&&this._buffer.set(h.buffer),this._bytesHashed=h.bytesHashed,this._finished=!1,this},u.prototype.cleanSavedState=function(h){r.wipe(h.stateHi),r.wipe(h.stateLo),h.buffer&&r.wipe(h.buffer),h.bufferLength=0,h.bytesHashed=0},u}();t.SHA512=n;var i=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function s(u,h,f,g,w,T,E){for(var v=f[0],P=f[1],C=f[2],$=f[3],x=f[4],A=f[5],_=f[6],D=f[7],m=g[0],o=g[1],d=g[2],M=g[3],K=g[4],V=g[5],J=g[6],X=g[7],l,b,U,q,R,N,j,B;E>=128;){for(var Q=0;Q<16;Q++){var H=8*Q+T;u[Q]=e.readUint32BE(w,H),h[Q]=e.readUint32BE(w,H+4)}for(var Q=0;Q<80;Q++){var ee=v,k=P,ae=C,L=$,I=x,S=A,a=_,y=D,z=m,Y=o,fe=d,ye=M,de=K,me=V,Ue=J,Ce=X;if(l=D,b=X,R=b&65535,N=b>>>16,j=l&65535,B=l>>>16,l=(x>>>14|K<<32-14)^(x>>>18|K<<32-18)^(K>>>41-32|x<<32-(41-32)),b=(K>>>14|x<<32-14)^(K>>>18|x<<32-18)^(x>>>41-32|K<<32-(41-32)),R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,l=x&A^~x&_,b=K&V^~K&J,R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,l=i[Q*2],b=i[Q*2+1],R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,l=u[Q%16],b=h[Q%16],R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,N+=R>>>16,j+=N>>>16,B+=j>>>16,U=j&65535|B<<16,q=R&65535|N<<16,l=U,b=q,R=b&65535,N=b>>>16,j=l&65535,B=l>>>16,l=(v>>>28|m<<32-28)^(m>>>34-32|v<<32-(34-32))^(m>>>39-32|v<<32-(39-32)),b=(m>>>28|v<<32-28)^(v>>>34-32|m<<32-(34-32))^(v>>>39-32|m<<32-(39-32)),R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,l=v&P^v&C^P&C,b=m&o^m&d^o&d,R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,N+=R>>>16,j+=N>>>16,B+=j>>>16,y=j&65535|B<<16,Ce=R&65535|N<<16,l=L,b=ye,R=b&65535,N=b>>>16,j=l&65535,B=l>>>16,l=U,b=q,R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,N+=R>>>16,j+=N>>>16,B+=j>>>16,L=j&65535|B<<16,ye=R&65535|N<<16,P=ee,C=k,$=ae,x=L,A=I,_=S,D=a,v=y,o=z,d=Y,M=fe,K=ye,V=de,J=me,X=Ue,m=Ce,Q%16===15)for(var H=0;H<16;H++)l=u[H],b=h[H],R=b&65535,N=b>>>16,j=l&65535,B=l>>>16,l=u[(H+9)%16],b=h[(H+9)%16],R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,U=u[(H+1)%16],q=h[(H+1)%16],l=(U>>>1|q<<32-1)^(U>>>8|q<<32-8)^U>>>7,b=(q>>>1|U<<32-1)^(q>>>8|U<<32-8)^(q>>>7|U<<32-7),R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,U=u[(H+14)%16],q=h[(H+14)%16],l=(U>>>19|q<<32-19)^(q>>>61-32|U<<32-(61-32))^U>>>6,b=(q>>>19|U<<32-19)^(U>>>61-32|q<<32-(61-32))^(q>>>6|U<<32-6),R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,N+=R>>>16,j+=N>>>16,B+=j>>>16,u[H]=j&65535|B<<16,h[H]=R&65535|N<<16}l=v,b=m,R=b&65535,N=b>>>16,j=l&65535,B=l>>>16,l=f[0],b=g[0],R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,N+=R>>>16,j+=N>>>16,B+=j>>>16,f[0]=v=j&65535|B<<16,g[0]=m=R&65535|N<<16,l=P,b=o,R=b&65535,N=b>>>16,j=l&65535,B=l>>>16,l=f[1],b=g[1],R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,N+=R>>>16,j+=N>>>16,B+=j>>>16,f[1]=P=j&65535|B<<16,g[1]=o=R&65535|N<<16,l=C,b=d,R=b&65535,N=b>>>16,j=l&65535,B=l>>>16,l=f[2],b=g[2],R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,N+=R>>>16,j+=N>>>16,B+=j>>>16,f[2]=C=j&65535|B<<16,g[2]=d=R&65535|N<<16,l=$,b=M,R=b&65535,N=b>>>16,j=l&65535,B=l>>>16,l=f[3],b=g[3],R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,N+=R>>>16,j+=N>>>16,B+=j>>>16,f[3]=$=j&65535|B<<16,g[3]=M=R&65535|N<<16,l=x,b=K,R=b&65535,N=b>>>16,j=l&65535,B=l>>>16,l=f[4],b=g[4],R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,N+=R>>>16,j+=N>>>16,B+=j>>>16,f[4]=x=j&65535|B<<16,g[4]=K=R&65535|N<<16,l=A,b=V,R=b&65535,N=b>>>16,j=l&65535,B=l>>>16,l=f[5],b=g[5],R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,N+=R>>>16,j+=N>>>16,B+=j>>>16,f[5]=A=j&65535|B<<16,g[5]=V=R&65535|N<<16,l=_,b=J,R=b&65535,N=b>>>16,j=l&65535,B=l>>>16,l=f[6],b=g[6],R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,N+=R>>>16,j+=N>>>16,B+=j>>>16,f[6]=_=j&65535|B<<16,g[6]=J=R&65535|N<<16,l=D,b=X,R=b&65535,N=b>>>16,j=l&65535,B=l>>>16,l=f[7],b=g[7],R+=b&65535,N+=b>>>16,j+=l&65535,B+=l>>>16,N+=R>>>16,j+=N>>>16,B+=j>>>16,f[7]=D=j&65535|B<<16,g[7]=X=R&65535|N<<16,T+=128,E-=128}return T}function c(u){var h=new n;h.update(u);var f=h.digest();return h.clean(),f}t.hash=c})(Uo),function(t){Object.defineProperty(t,"__esModule",{value:!0});var e=nr,r=Uo,n=pt;t.SIGNATURE_LENGTH=64,t.PUBLIC_KEY_LENGTH=32,t.SECRET_KEY_LENGTH=64,t.SEED_LENGTH=32;function i(L){var I=new Float64Array(16);if(L)for(var S=0;S<L.length;S++)I[S]=L[S];return I}var s=new Uint8Array(32);s[0]=9;var c=i(),u=i([1]),h=i([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),f=i([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),g=i([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),w=i([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),T=i([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function E(L,I){for(var S=0;S<16;S++)L[S]=I[S]|0}function v(L){for(var I=1,S=0;S<16;S++){var a=L[S]+I+65535;I=Math.floor(a/65536),L[S]=a-I*65536}L[0]+=I-1+37*(I-1)}function P(L,I,S){for(var a=~(S-1),y=0;y<16;y++){var z=a&(L[y]^I[y]);L[y]^=z,I[y]^=z}}function C(L,I){for(var S=i(),a=i(),y=0;y<16;y++)a[y]=I[y];v(a),v(a),v(a);for(var z=0;z<2;z++){S[0]=a[0]-65517;for(var y=1;y<15;y++)S[y]=a[y]-65535-(S[y-1]>>16&1),S[y-1]&=65535;S[15]=a[15]-32767-(S[14]>>16&1);var Y=S[15]>>16&1;S[14]&=65535,P(a,S,1-Y)}for(var y=0;y<16;y++)L[2*y]=a[y]&255,L[2*y+1]=a[y]>>8}function $(L,I){for(var S=0,a=0;a<32;a++)S|=L[a]^I[a];return(1&S-1>>>8)-1}function x(L,I){var S=new Uint8Array(32),a=new Uint8Array(32);return C(S,L),C(a,I),$(S,a)}function A(L){var I=new Uint8Array(32);return C(I,L),I[0]&1}function _(L,I){for(var S=0;S<16;S++)L[S]=I[2*S]+(I[2*S+1]<<8);L[15]&=32767}function D(L,I,S){for(var a=0;a<16;a++)L[a]=I[a]+S[a]}function m(L,I,S){for(var a=0;a<16;a++)L[a]=I[a]-S[a]}function o(L,I,S){var a,y,z=0,Y=0,fe=0,ye=0,de=0,me=0,Ue=0,Ce=0,ve=0,pe=0,le=0,ue=0,ce=0,oe=0,se=0,te=0,he=0,ge=0,ne=0,_e=0,be=0,Ee=0,De=0,we=0,xt=0,Ct=0,Kt=0,gt=0,Qt=0,zr=0,pn=0,Me=S[0],Ne=S[1],je=S[2],$e=S[3],Be=S[4],Pe=S[5],We=S[6],ke=S[7],Ye=S[8],Je=S[9],Xe=S[10],He=S[11],ze=S[12],Ie=S[13],Ze=S[14],Qe=S[15];a=I[0],z+=a*Me,Y+=a*Ne,fe+=a*je,ye+=a*$e,de+=a*Be,me+=a*Pe,Ue+=a*We,Ce+=a*ke,ve+=a*Ye,pe+=a*Je,le+=a*Xe,ue+=a*He,ce+=a*ze,oe+=a*Ie,se+=a*Ze,te+=a*Qe,a=I[1],Y+=a*Me,fe+=a*Ne,ye+=a*je,de+=a*$e,me+=a*Be,Ue+=a*Pe,Ce+=a*We,ve+=a*ke,pe+=a*Ye,le+=a*Je,ue+=a*Xe,ce+=a*He,oe+=a*ze,se+=a*Ie,te+=a*Ze,he+=a*Qe,a=I[2],fe+=a*Me,ye+=a*Ne,de+=a*je,me+=a*$e,Ue+=a*Be,Ce+=a*Pe,ve+=a*We,pe+=a*ke,le+=a*Ye,ue+=a*Je,ce+=a*Xe,oe+=a*He,se+=a*ze,te+=a*Ie,he+=a*Ze,ge+=a*Qe,a=I[3],ye+=a*Me,de+=a*Ne,me+=a*je,Ue+=a*$e,Ce+=a*Be,ve+=a*Pe,pe+=a*We,le+=a*ke,ue+=a*Ye,ce+=a*Je,oe+=a*Xe,se+=a*He,te+=a*ze,he+=a*Ie,ge+=a*Ze,ne+=a*Qe,a=I[4],de+=a*Me,me+=a*Ne,Ue+=a*je,Ce+=a*$e,ve+=a*Be,pe+=a*Pe,le+=a*We,ue+=a*ke,ce+=a*Ye,oe+=a*Je,se+=a*Xe,te+=a*He,he+=a*ze,ge+=a*Ie,ne+=a*Ze,_e+=a*Qe,a=I[5],me+=a*Me,Ue+=a*Ne,Ce+=a*je,ve+=a*$e,pe+=a*Be,le+=a*Pe,ue+=a*We,ce+=a*ke,oe+=a*Ye,se+=a*Je,te+=a*Xe,he+=a*He,ge+=a*ze,ne+=a*Ie,_e+=a*Ze,be+=a*Qe,a=I[6],Ue+=a*Me,Ce+=a*Ne,ve+=a*je,pe+=a*$e,le+=a*Be,ue+=a*Pe,ce+=a*We,oe+=a*ke,se+=a*Ye,te+=a*Je,he+=a*Xe,ge+=a*He,ne+=a*ze,_e+=a*Ie,be+=a*Ze,Ee+=a*Qe,a=I[7],Ce+=a*Me,ve+=a*Ne,pe+=a*je,le+=a*$e,ue+=a*Be,ce+=a*Pe,oe+=a*We,se+=a*ke,te+=a*Ye,he+=a*Je,ge+=a*Xe,ne+=a*He,_e+=a*ze,be+=a*Ie,Ee+=a*Ze,De+=a*Qe,a=I[8],ve+=a*Me,pe+=a*Ne,le+=a*je,ue+=a*$e,ce+=a*Be,oe+=a*Pe,se+=a*We,te+=a*ke,he+=a*Ye,ge+=a*Je,ne+=a*Xe,_e+=a*He,be+=a*ze,Ee+=a*Ie,De+=a*Ze,we+=a*Qe,a=I[9],pe+=a*Me,le+=a*Ne,ue+=a*je,ce+=a*$e,oe+=a*Be,se+=a*Pe,te+=a*We,he+=a*ke,ge+=a*Ye,ne+=a*Je,_e+=a*Xe,be+=a*He,Ee+=a*ze,De+=a*Ie,we+=a*Ze,xt+=a*Qe,a=I[10],le+=a*Me,ue+=a*Ne,ce+=a*je,oe+=a*$e,se+=a*Be,te+=a*Pe,he+=a*We,ge+=a*ke,ne+=a*Ye,_e+=a*Je,be+=a*Xe,Ee+=a*He,De+=a*ze,we+=a*Ie,xt+=a*Ze,Ct+=a*Qe,a=I[11],ue+=a*Me,ce+=a*Ne,oe+=a*je,se+=a*$e,te+=a*Be,he+=a*Pe,ge+=a*We,ne+=a*ke,_e+=a*Ye,be+=a*Je,Ee+=a*Xe,De+=a*He,we+=a*ze,xt+=a*Ie,Ct+=a*Ze,Kt+=a*Qe,a=I[12],ce+=a*Me,oe+=a*Ne,se+=a*je,te+=a*$e,he+=a*Be,ge+=a*Pe,ne+=a*We,_e+=a*ke,be+=a*Ye,Ee+=a*Je,De+=a*Xe,we+=a*He,xt+=a*ze,Ct+=a*Ie,Kt+=a*Ze,gt+=a*Qe,a=I[13],oe+=a*Me,se+=a*Ne,te+=a*je,he+=a*$e,ge+=a*Be,ne+=a*Pe,_e+=a*We,be+=a*ke,Ee+=a*Ye,De+=a*Je,we+=a*Xe,xt+=a*He,Ct+=a*ze,Kt+=a*Ie,gt+=a*Ze,Qt+=a*Qe,a=I[14],se+=a*Me,te+=a*Ne,he+=a*je,ge+=a*$e,ne+=a*Be,_e+=a*Pe,be+=a*We,Ee+=a*ke,De+=a*Ye,we+=a*Je,xt+=a*Xe,Ct+=a*He,Kt+=a*ze,gt+=a*Ie,Qt+=a*Ze,zr+=a*Qe,a=I[15],te+=a*Me,he+=a*Ne,ge+=a*je,ne+=a*$e,_e+=a*Be,be+=a*Pe,Ee+=a*We,De+=a*ke,we+=a*Ye,xt+=a*Je,Ct+=a*Xe,Kt+=a*He,gt+=a*ze,Qt+=a*Ie,zr+=a*Ze,pn+=a*Qe,z+=38*he,Y+=38*ge,fe+=38*ne,ye+=38*_e,de+=38*be,me+=38*Ee,Ue+=38*De,Ce+=38*we,ve+=38*xt,pe+=38*Ct,le+=38*Kt,ue+=38*gt,ce+=38*Qt,oe+=38*zr,se+=38*pn,y=1,a=z+y+65535,y=Math.floor(a/65536),z=a-y*65536,a=Y+y+65535,y=Math.floor(a/65536),Y=a-y*65536,a=fe+y+65535,y=Math.floor(a/65536),fe=a-y*65536,a=ye+y+65535,y=Math.floor(a/65536),ye=a-y*65536,a=de+y+65535,y=Math.floor(a/65536),de=a-y*65536,a=me+y+65535,y=Math.floor(a/65536),me=a-y*65536,a=Ue+y+65535,y=Math.floor(a/65536),Ue=a-y*65536,a=Ce+y+65535,y=Math.floor(a/65536),Ce=a-y*65536,a=ve+y+65535,y=Math.floor(a/65536),ve=a-y*65536,a=pe+y+65535,y=Math.floor(a/65536),pe=a-y*65536,a=le+y+65535,y=Math.floor(a/65536),le=a-y*65536,a=ue+y+65535,y=Math.floor(a/65536),ue=a-y*65536,a=ce+y+65535,y=Math.floor(a/65536),ce=a-y*65536,a=oe+y+65535,y=Math.floor(a/65536),oe=a-y*65536,a=se+y+65535,y=Math.floor(a/65536),se=a-y*65536,a=te+y+65535,y=Math.floor(a/65536),te=a-y*65536,z+=y-1+37*(y-1),y=1,a=z+y+65535,y=Math.floor(a/65536),z=a-y*65536,a=Y+y+65535,y=Math.floor(a/65536),Y=a-y*65536,a=fe+y+65535,y=Math.floor(a/65536),fe=a-y*65536,a=ye+y+65535,y=Math.floor(a/65536),ye=a-y*65536,a=de+y+65535,y=Math.floor(a/65536),de=a-y*65536,a=me+y+65535,y=Math.floor(a/65536),me=a-y*65536,a=Ue+y+65535,y=Math.floor(a/65536),Ue=a-y*65536,a=Ce+y+65535,y=Math.floor(a/65536),Ce=a-y*65536,a=ve+y+65535,y=Math.floor(a/65536),ve=a-y*65536,a=pe+y+65535,y=Math.floor(a/65536),pe=a-y*65536,a=le+y+65535,y=Math.floor(a/65536),le=a-y*65536,a=ue+y+65535,y=Math.floor(a/65536),ue=a-y*65536,a=ce+y+65535,y=Math.floor(a/65536),ce=a-y*65536,a=oe+y+65535,y=Math.floor(a/65536),oe=a-y*65536,a=se+y+65535,y=Math.floor(a/65536),se=a-y*65536,a=te+y+65535,y=Math.floor(a/65536),te=a-y*65536,z+=y-1+37*(y-1),L[0]=z,L[1]=Y,L[2]=fe,L[3]=ye,L[4]=de,L[5]=me,L[6]=Ue,L[7]=Ce,L[8]=ve,L[9]=pe,L[10]=le,L[11]=ue,L[12]=ce,L[13]=oe,L[14]=se,L[15]=te}function d(L,I){o(L,I,I)}function M(L,I){var S=i(),a;for(a=0;a<16;a++)S[a]=I[a];for(a=253;a>=0;a--)d(S,S),a!==2&&a!==4&&o(S,S,I);for(a=0;a<16;a++)L[a]=S[a]}function K(L,I){var S=i(),a;for(a=0;a<16;a++)S[a]=I[a];for(a=250;a>=0;a--)d(S,S),a!==1&&o(S,S,I);for(a=0;a<16;a++)L[a]=S[a]}function V(L,I){var S=i(),a=i(),y=i(),z=i(),Y=i(),fe=i(),ye=i(),de=i(),me=i();m(S,L[1],L[0]),m(me,I[1],I[0]),o(S,S,me),D(a,L[0],L[1]),D(me,I[0],I[1]),o(a,a,me),o(y,L[3],I[3]),o(y,y,f),o(z,L[2],I[2]),D(z,z,z),m(Y,a,S),m(fe,z,y),D(ye,z,y),D(de,a,S),o(L[0],Y,fe),o(L[1],de,ye),o(L[2],ye,fe),o(L[3],Y,de)}function J(L,I,S){for(var a=0;a<4;a++)P(L[a],I[a],S)}function X(L,I){var S=i(),a=i(),y=i();M(y,I[2]),o(S,I[0],y),o(a,I[1],y),C(L,a),L[31]^=A(S)<<7}function l(L,I,S){E(L[0],c),E(L[1],u),E(L[2],u),E(L[3],c);for(var a=255;a>=0;--a){var y=S[a/8|0]>>(a&7)&1;J(L,I,y),V(I,L),V(L,L),J(L,I,y)}}function b(L,I){var S=[i(),i(),i(),i()];E(S[0],g),E(S[1],w),E(S[2],u),o(S[3],g,w),l(L,S,I)}function U(L){if(L.length!==t.SEED_LENGTH)throw new Error("ed25519: seed must be "+t.SEED_LENGTH+" bytes");var I=r.hash(L);I[0]&=248,I[31]&=127,I[31]|=64;var S=new Uint8Array(32),a=[i(),i(),i(),i()];b(a,I),X(S,a);var y=new Uint8Array(64);return y.set(L),y.set(S,32),{publicKey:S,secretKey:y}}t.generateKeyPairFromSeed=U;function q(L){var I=e.randomBytes(32,L),S=U(I);return n.wipe(I),S}t.generateKeyPair=q;function R(L){if(L.length!==t.SECRET_KEY_LENGTH)throw new Error("ed25519: secret key must be "+t.SECRET_KEY_LENGTH+" bytes");return new Uint8Array(L.subarray(32))}t.extractPublicKeyFromSecretKey=R;var N=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function j(L,I){var S,a,y,z;for(a=63;a>=32;--a){for(S=0,y=a-32,z=a-12;y<z;++y)I[y]+=S-16*I[a]*N[y-(a-32)],S=Math.floor((I[y]+128)/256),I[y]-=S*256;I[y]+=S,I[a]=0}for(S=0,y=0;y<32;y++)I[y]+=S-(I[31]>>4)*N[y],S=I[y]>>8,I[y]&=255;for(y=0;y<32;y++)I[y]-=S*N[y];for(a=0;a<32;a++)I[a+1]+=I[a]>>8,L[a]=I[a]&255}function B(L){for(var I=new Float64Array(64),S=0;S<64;S++)I[S]=L[S];for(var S=0;S<64;S++)L[S]=0;j(L,I)}function Q(L,I){var S=new Float64Array(64),a=[i(),i(),i(),i()],y=r.hash(L.subarray(0,32));y[0]&=248,y[31]&=127,y[31]|=64;var z=new Uint8Array(64);z.set(y.subarray(32),32);var Y=new r.SHA512;Y.update(z.subarray(32)),Y.update(I);var fe=Y.digest();Y.clean(),B(fe),b(a,fe),X(z,a),Y.reset(),Y.update(z.subarray(0,32)),Y.update(L.subarray(32)),Y.update(I);var ye=Y.digest();B(ye);for(var de=0;de<32;de++)S[de]=fe[de];for(var de=0;de<32;de++)for(var me=0;me<32;me++)S[de+me]+=ye[de]*y[me];return j(z.subarray(32),S),z}t.sign=Q;function H(L,I){var S=i(),a=i(),y=i(),z=i(),Y=i(),fe=i(),ye=i();return E(L[2],u),_(L[1],I),d(y,L[1]),o(z,y,h),m(y,y,L[2]),D(z,L[2],z),d(Y,z),d(fe,Y),o(ye,fe,Y),o(S,ye,y),o(S,S,z),K(S,S),o(S,S,y),o(S,S,z),o(S,S,z),o(L[0],S,z),d(a,L[0]),o(a,a,z),x(a,y)&&o(L[0],L[0],T),d(a,L[0]),o(a,a,z),x(a,y)?-1:(A(L[0])===I[31]>>7&&m(L[0],c,L[0]),o(L[3],L[0],L[1]),0)}function ee(L,I,S){var a=new Uint8Array(32),y=[i(),i(),i(),i()],z=[i(),i(),i(),i()];if(S.length!==t.SIGNATURE_LENGTH)throw new Error("ed25519: signature must be "+t.SIGNATURE_LENGTH+" bytes");if(H(z,L))return!1;var Y=new r.SHA512;Y.update(S.subarray(0,32)),Y.update(L),Y.update(I);var fe=Y.digest();return B(fe),l(y,z,fe),b(z,S.subarray(32)),V(y,z),X(a,y),!$(S,a)}t.verify=ee;function k(L){var I=[i(),i(),i(),i()];if(H(I,L))throw new Error("Ed25519: invalid public key");var S=i(),a=i(),y=I[1];D(S,u,y),m(a,u,y),M(a,a),o(S,S,a);var z=new Uint8Array(32);return C(z,S),z}t.convertPublicKeyToX25519=k;function ae(L){var I=r.hash(L.subarray(0,32));I[0]&=248,I[31]&=127,I[31]|=64;var S=new Uint8Array(I.subarray(0,32));return n.wipe(I),S}t.convertSecretKeyToX25519=ae}(mi);const Od="EdDSA",Ad="JWT",Mo=".",jo="base64url",Id="utf8",Ld="utf8",Td=":",Cd="did",Nd="key",$o="base58btc",Pd="z",Rd="K36",Fd=32;function an(t){return ft(ht(br(t),Id),jo)}function Bo(t){const e=ht(Rd,$o),r=Pd+ft(Bn([e,t]),$o);return[Cd,Nd,r].join(Td)}function Ud(t){return ft(t,jo)}function Md(t){return ht([an(t.header),an(t.payload)].join(Mo),Ld)}function jd(t){return[an(t.header),an(t.payload),Ud(t.signature)].join(Mo)}function zo(t=nr.randomBytes(Fd)){return mi.generateKeyPairFromSeed(t)}async function $d(t,e,r,n,i=Le.fromMiliseconds(Date.now())){const s={alg:Od,typ:Ad},c=Bo(n.publicKey),u=i+r,h={iss:c,sub:t,aud:e,iat:i,exp:u},f=Md({header:s,payload:h}),g=mi.sign(n.secretKey,f);return jd({header:s,payload:h,signature:g})}const Ho=10,Bd=typeof global.WebSocket<"u"?global.WebSocket:require("ws");class zd{constructor(e){if(this.url=e,this.events=new vr.EventEmitter,this.registering=!1,!Gi(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,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){if(typeof this.socket>"u")throw new Error("Connection already closed");this.socket.close(),this.onClose()}async send(e,r){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(br(e))}catch(n){this.onError(e.id,n)}}register(e=this.url){if(!Gi(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return i(new Error("WebSocket connection is missing or invalid"));n(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,n)=>{const i=$i.isReactNative()?void 0:{rejectUnauthorized:!vc(e)},s=new Bd(e,[],i);s.onopen=()=>{this.onOpen(s),r(s)},s.onerror=c=>{const u=this.parseError(c.error);this.events.emit("register_error",u),this.onClose(),n(u)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=()=>this.onClose(),e.onerror=r=>{const n=this.parseError(r.error);this.events.emit("error",n)},this.socket=e,this.registering=!1,this.events.emit("open")}onClose(){this.socket=void 0,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?In(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const n=this.parseError(r),i=n.message||n.toString(),s=qr(e,i);this.events.emit("payload",s)}parseError(e,r=this.url){return ji(e,r,"WS")}resetMaxListeners(){this.events.getMaxListeners()>Ho&&this.events.setMaxListeners(Ho)}}var wi={exports:{}};(function(t,e){var r=200,n="__lodash_hash_undefined__",i=1,s=2,c=9007199254740991,u="[object Arguments]",h="[object Array]",f="[object AsyncFunction]",g="[object Boolean]",w="[object Date]",T="[object Error]",E="[object Function]",v="[object GeneratorFunction]",P="[object Map]",C="[object Number]",$="[object Null]",x="[object Object]",A="[object Promise]",_="[object Proxy]",D="[object RegExp]",m="[object Set]",o="[object String]",d="[object Symbol]",M="[object Undefined]",K="[object WeakMap]",V="[object ArrayBuffer]",J="[object DataView]",X="[object Float32Array]",l="[object Float64Array]",b="[object Int8Array]",U="[object Int16Array]",q="[object Int32Array]",R="[object Uint8Array]",N="[object Uint8ClampedArray]",j="[object Uint16Array]",B="[object Uint32Array]",Q=/[\\^$.*+?()[\]{}|]/g,H=/^\[object .+?Constructor\]$/,ee=/^(?:0|[1-9]\d*)$/,k={};k[X]=k[l]=k[b]=k[U]=k[q]=k[R]=k[N]=k[j]=k[B]=!0,k[u]=k[h]=k[V]=k[g]=k[J]=k[w]=k[T]=k[E]=k[P]=k[C]=k[x]=k[D]=k[m]=k[o]=k[K]=!1;var ae=typeof Z=="object"&&Z&&Z.Object===Object&&Z,L=typeof self=="object"&&self&&self.Object===Object&&self,I=ae||L||Function("return this")(),S=e&&!e.nodeType&&e,a=S&&!0&&t&&!t.nodeType&&t,y=a&&a.exports===S,z=y&&ae.process,Y=function(){try{return z&&z.binding&&z.binding("util")}catch{}}(),fe=Y&&Y.isTypedArray;function ye(p,O){for(var F=-1,W=p==null?0:p.length,Ae=0,ie=[];++F<W;){var Re=p[F];O(Re,F,p)&&(ie[Ae++]=Re)}return ie}function de(p,O){for(var F=-1,W=O.length,Ae=p.length;++F<W;)p[Ae+F]=O[F];return p}function me(p,O){for(var F=-1,W=p==null?0:p.length;++F<W;)if(O(p[F],F,p))return!0;return!1}function Ue(p,O){for(var F=-1,W=Array(p);++F<p;)W[F]=O(F);return W}function Ce(p){return function(O){return p(O)}}function ve(p,O){return p.has(O)}function pe(p,O){return p?.[O]}function le(p){var O=-1,F=Array(p.size);return p.forEach(function(W,Ae){F[++O]=[Ae,W]}),F}function ue(p,O){return function(F){return p(O(F))}}function ce(p){var O=-1,F=Array(p.size);return p.forEach(function(W){F[++O]=W}),F}var oe=Array.prototype,se=Function.prototype,te=Object.prototype,he=I["__core-js_shared__"],ge=se.toString,ne=te.hasOwnProperty,_e=function(){var p=/[^.]+$/.exec(he&&he.keys&&he.keys.IE_PROTO||"");return p?"Symbol(src)_1."+p:""}(),be=te.toString,Ee=RegExp("^"+ge.call(ne).replace(Q,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),De=y?I.Buffer:void 0,we=I.Symbol,xt=I.Uint8Array,Ct=te.propertyIsEnumerable,Kt=oe.splice,gt=we?we.toStringTag:void 0,Qt=Object.getOwnPropertySymbols,zr=De?De.isBuffer:void 0,pn=ue(Object.keys,Object),Me=gr(I,"DataView"),Ne=gr(I,"Map"),je=gr(I,"Promise"),$e=gr(I,"Set"),Be=gr(I,"WeakMap"),Pe=gr(Object,"create"),We=tr(Me),ke=tr(Ne),Ye=tr(je),Je=tr($e),Xe=tr(Be),He=we?we.prototype:void 0,ze=He?He.valueOf:void 0;function Ie(p){var O=-1,F=p==null?0:p.length;for(this.clear();++O<F;){var W=p[O];this.set(W[0],W[1])}}function Ze(){this.__data__=Pe?Pe(null):{},this.size=0}function Qe(p){var O=this.has(p)&&delete this.__data__[p];return this.size-=O?1:0,O}function j0(p){var O=this.__data__;if(Pe){var F=O[p];return F===n?void 0:F}return ne.call(O,p)?O[p]:void 0}function $0(p){var O=this.__data__;return Pe?O[p]!==void 0:ne.call(O,p)}function B0(p,O){var F=this.__data__;return this.size+=this.has(p)?0:1,F[p]=Pe&&O===void 0?n:O,this}Ie.prototype.clear=Ze,Ie.prototype.delete=Qe,Ie.prototype.get=j0,Ie.prototype.has=$0,Ie.prototype.set=B0;function Mt(p){var O=-1,F=p==null?0:p.length;for(this.clear();++O<F;){var W=p[O];this.set(W[0],W[1])}}function z0(){this.__data__=[],this.size=0}function H0(p){var O=this.__data__,F=vn(O,p);if(F<0)return!1;var W=O.length-1;return F==W?O.pop():Kt.call(O,F,1),--this.size,!0}function K0(p){var O=this.__data__,F=vn(O,p);return F<0?void 0:O[F][1]}function q0(p){return vn(this.__data__,p)>-1}function V0(p,O){var F=this.__data__,W=vn(F,p);return W<0?(++this.size,F.push([p,O])):F[W][1]=O,this}Mt.prototype.clear=z0,Mt.prototype.delete=H0,Mt.prototype.get=K0,Mt.prototype.has=q0,Mt.prototype.set=V0;function er(p){var O=-1,F=p==null?0:p.length;for(this.clear();++O<F;){var W=p[O];this.set(W[0],W[1])}}function G0(){this.size=0,this.__data__={hash:new Ie,map:new(Ne||Mt),string:new Ie}}function W0(p){var O=yn(this,p).delete(p);return this.size-=O?1:0,O}function k0(p){return yn(this,p).get(p)}function Y0(p){return yn(this,p).has(p)}function J0(p,O){var F=yn(this,p),W=F.size;return F.set(p,O),this.size+=F.size==W?0:1,this}er.prototype.clear=G0,er.prototype.delete=W0,er.prototype.get=k0,er.prototype.has=Y0,er.prototype.set=J0;function gn(p){var O=-1,F=p==null?0:p.length;for(this.__data__=new er;++O<F;)this.add(p[O])}function X0(p){return this.__data__.set(p,n),this}function Z0(p){return this.__data__.has(p)}gn.prototype.add=gn.prototype.push=X0,gn.prototype.has=Z0;function qt(p){var O=this.__data__=new Mt(p);this.size=O.size}function Q0(){this.__data__=new Mt,this.size=0}function ev(p){var O=this.__data__,F=O.delete(p);return this.size=O.size,F}function tv(p){return this.__data__.get(p)}function rv(p){return this.__data__.has(p)}function nv(p,O){var F=this.__data__;if(F instanceof Mt){var W=F.__data__;if(!Ne||W.length<r-1)return W.push([p,O]),this.size=++F.size,this;F=this.__data__=new er(W)}return F.set(p,O),this.size=F.size,this}qt.prototype.clear=Q0,qt.prototype.delete=ev,qt.prototype.get=tv,qt.prototype.has=rv,qt.prototype.set=nv;function iv(p,O){var F=_n(p),W=!F&&bv(p),Ae=!F&&!W&&Pi(p),ie=!F&&!W&&!Ae&&Ya(p),Re=F||W||Ae||ie,et=Re?Ue(p.length,String):[],it=et.length;for(var Te in p)(O||ne.call(p,Te))&&!(Re&&(Te=="length"||Ae&&(Te=="offset"||Te=="parent")||ie&&(Te=="buffer"||Te=="byteLength"||Te=="byteOffset")||pv(Te,it)))&&et.push(Te);return et}function vn(p,O){for(var F=p.length;F--;)if(Va(p[F][0],O))return F;return-1}function sv(p,O,F){var W=O(p);return _n(p)?W:de(W,F(p))}function Hr(p){return p==null?p===void 0?M:$:gt&&gt in Object(p)?lv(p):_v(p)}function za(p){return Kr(p)&&Hr(p)==u}function Ha(p,O,F,W,Ae){return p===O?!0:p==null||O==null||!Kr(p)&&!Kr(O)?p!==p&&O!==O:ov(p,O,F,W,Ha,Ae)}function ov(p,O,F,W,Ae,ie){var Re=_n(p),et=_n(O),it=Re?h:Vt(p),Te=et?h:Vt(O);it=it==u?x:it,Te=Te==u?x:Te;var vt=it==x,St=Te==x,at=it==Te;if(at&&Pi(p)){if(!Pi(O))return!1;Re=!0,vt=!1}if(at&&!vt)return ie||(ie=new qt),Re||Ya(p)?Ka(p,O,F,W,Ae,ie):hv(p,O,it,F,W,Ae,ie);if(!(F&i)){var _t=vt&&ne.call(p,"__wrapped__"),bt=St&&ne.call(O,"__wrapped__");if(_t||bt){var Gt=_t?p.value():p,jt=bt?O.value():O;return ie||(ie=new qt),Ae(Gt,jt,F,W,ie)}}return at?(ie||(ie=new qt),fv(p,O,F,W,Ae,ie)):!1}function av(p){if(!ka(p)||vv(p))return!1;var O=Ga(p)?Ee:H;return O.test(tr(p))}function cv(p){return Kr(p)&&Wa(p.length)&&!!k[Hr(p)]}function uv(p){if(!yv(p))return pn(p);var O=[];for(var F in Object(p))ne.call(p,F)&&F!="constructor"&&O.push(F);return O}function Ka(p,O,F,W,Ae,ie){var Re=F&i,et=p.length,it=O.length;if(et!=it&&!(Re&&it>et))return!1;var Te=ie.get(p);if(Te&&ie.get(O))return Te==O;var vt=-1,St=!0,at=F&s?new gn:void 0;for(ie.set(p,O),ie.set(O,p);++vt<et;){var _t=p[vt],bt=O[vt];if(W)var Gt=Re?W(bt,_t,vt,O,p,ie):W(_t,bt,vt,p,O,ie);if(Gt!==void 0){if(Gt)continue;St=!1;break}if(at){if(!me(O,function(jt,rr){if(!ve(at,rr)&&(_t===jt||Ae(_t,jt,F,W,ie)))return at.push(rr)})){St=!1;break}}else if(!(_t===bt||Ae(_t,bt,F,W,ie))){St=!1;break}}return ie.delete(p),ie.delete(O),St}function hv(p,O,F,W,Ae,ie,Re){switch(F){case J:if(p.byteLength!=O.byteLength||p.byteOffset!=O.byteOffset)return!1;p=p.buffer,O=O.buffer;case V:return!(p.byteLength!=O.byteLength||!ie(new xt(p),new xt(O)));case g:case w:case C:return Va(+p,+O);case T:return p.name==O.name&&p.message==O.message;case D:case o:return p==O+"";case P:var et=le;case m:var it=W&i;if(et||(et=ce),p.size!=O.size&&!it)return!1;var Te=Re.get(p);if(Te)return Te==O;W|=s,Re.set(p,O);var vt=Ka(et(p),et(O),W,Ae,ie,Re);return Re.delete(p),vt;case d:if(ze)return ze.call(p)==ze.call(O)}return!1}function fv(p,O,F,W,Ae,ie){var Re=F&i,et=qa(p),it=et.length,Te=qa(O),vt=Te.length;if(it!=vt&&!Re)return!1;for(var St=it;St--;){var at=et[St];if(!(Re?at in O:ne.call(O,at)))return!1}var _t=ie.get(p);if(_t&&ie.get(O))return _t==O;var bt=!0;ie.set(p,O),ie.set(O,p);for(var Gt=Re;++St<it;){at=et[St];var jt=p[at],rr=O[at];if(W)var Ja=Re?W(rr,jt,at,O,p,ie):W(jt,rr,at,p,O,ie);if(!(Ja===void 0?jt===rr||Ae(jt,rr,F,W,ie):Ja)){bt=!1;break}Gt||(Gt=at=="constructor")}if(bt&&!Gt){var bn=p.constructor,mn=O.constructor;bn!=mn&&"constructor"in p&&"constructor"in O&&!(typeof bn=="function"&&bn instanceof bn&&typeof mn=="function"&&mn instanceof mn)&&(bt=!1)}return ie.delete(p),ie.delete(O),bt}function qa(p){return sv(p,Ev,dv)}function yn(p,O){var F=p.__data__;return gv(O)?F[typeof O=="string"?"string":"hash"]:F.map}function gr(p,O){var F=pe(p,O);return av(F)?F:void 0}function lv(p){var O=ne.call(p,gt),F=p[gt];try{p[gt]=void 0;var W=!0}catch{}var Ae=be.call(p);return W&&(O?p[gt]=F:delete p[gt]),Ae}var dv=Qt?function(p){return p==null?[]:(p=Object(p),ye(Qt(p),function(O){return Ct.call(p,O)}))}:Dv,Vt=Hr;(Me&&Vt(new Me(new ArrayBuffer(1)))!=J||Ne&&Vt(new Ne)!=P||je&&Vt(je.resolve())!=A||$e&&Vt(new $e)!=m||Be&&Vt(new Be)!=K)&&(Vt=function(p){var O=Hr(p),F=O==x?p.constructor:void 0,W=F?tr(F):"";if(W)switch(W){case We:return J;case ke:return P;case Ye:return A;case Je:return m;case Xe:return K}return O});function pv(p,O){return O=O??c,!!O&&(typeof p=="number"||ee.test(p))&&p>-1&&p%1==0&&p<O}function gv(p){var O=typeof p;return O=="string"||O=="number"||O=="symbol"||O=="boolean"?p!=="__proto__":p===null}function vv(p){return!!_e&&_e in p}function yv(p){var O=p&&p.constructor,F=typeof O=="function"&&O.prototype||te;return p===F}function _v(p){return be.call(p)}function tr(p){if(p!=null){try{return ge.call(p)}catch{}try{return p+""}catch{}}return""}function Va(p,O){return p===O||p!==p&&O!==O}var bv=za(function(){return arguments}())?za:function(p){return Kr(p)&&ne.call(p,"callee")&&!Ct.call(p,"callee")},_n=Array.isArray;function mv(p){return p!=null&&Wa(p.length)&&!Ga(p)}var Pi=zr||xv;function wv(p,O){return Ha(p,O)}function Ga(p){if(!ka(p))return!1;var O=Hr(p);return O==E||O==v||O==f||O==_}function Wa(p){return typeof p=="number"&&p>-1&&p%1==0&&p<=c}function ka(p){var O=typeof p;return p!=null&&(O=="object"||O=="function")}function Kr(p){return p!=null&&typeof p=="object"}var Ya=fe?Ce(fe):cv;function Ev(p){return mv(p)?iv(p):uv(p)}function Dv(){return[]}function xv(){return!1}t.exports=wv})(wi,wi.exports);var Hd=wi.exports,Kd=Object.defineProperty,Ko=Object.getOwnPropertySymbols,qd=Object.prototype.hasOwnProperty,Vd=Object.prototype.propertyIsEnumerable,qo=(t,e,r)=>e in t?Kd(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ut=(t,e)=>{for(var r in e||(e={}))qd.call(e,r)&&qo(t,r,e[r]);if(Ko)for(var r of Ko(e))Vd.call(e,r)&&qo(t,r,e[r]);return t};function Ve(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var cn=Ve;Ve.EventEmitter=Ve,Ve.prototype._events=void 0,Ve.prototype._maxListeners=void 0,Ve.defaultMaxListeners=10,Ve.prototype.setMaxListeners=function(t){if(!Gd(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ve.prototype.emit=function(t){var e,r,n,i,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Fr(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],Vo(r))return!1;if(Ft(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(Fr(r))for(i=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,s=0;s<n;s++)c[s].apply(this,i);return!0},Ve.prototype.addListener=function(t,e){var r;if(!Ft(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Ft(e.listener)?e.listener:e),this._events[t]?Fr(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Fr(this._events[t])&&!this._events[t].warned&&(Vo(this._maxListeners)?r=Ve.defaultMaxListeners:r=this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),typeof console.trace=="function"&&console.trace())),this},Ve.prototype.on=Ve.prototype.addListener,Ve.prototype.once=function(t,e){if(!Ft(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},Ve.prototype.removeListener=function(t,e){var r,n,i,s;if(!Ft(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],i=r.length,n=-1,r===e||Ft(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(Fr(r)){for(s=i;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(n<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},Ve.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[t]&&delete this._events[t],this;if(arguments.length===0){for(e in this._events)e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],Ft(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},Ve.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Ft(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},Ve.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Ft(e))return 1;if(e)return e.length}return 0},Ve.listenerCount=function(t,e){return t.listenerCount(e)};function Ft(t){return typeof t=="function"}function Gd(t){return typeof t=="number"}function Fr(t){return typeof t=="object"&&t!==null}function Vo(t){return t===void 0}function Wd(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<t.length;i++){var s=t.charAt(i),c=s.charCodeAt(0);if(r[c]!==255)throw new TypeError(s+" is ambiguous");r[c]=i}var u=t.length,h=t.charAt(0),f=Math.log(u)/Math.log(256),g=Math.log(256)/Math.log(u);function w(v){if(v instanceof Uint8Array||(ArrayBuffer.isView(v)?v=new Uint8Array(v.buffer,v.byteOffset,v.byteLength):Array.isArray(v)&&(v=Uint8Array.from(v))),!(v instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(v.length===0)return"";for(var P=0,C=0,$=0,x=v.length;$!==x&&v[$]===0;)$++,P++;for(var A=(x-$)*g+1>>>0,_=new Uint8Array(A);$!==x;){for(var D=v[$],m=0,o=A-1;(D!==0||m<C)&&o!==-1;o--,m++)D+=256*_[o]>>>0,_[o]=D%u>>>0,D=D/u>>>0;if(D!==0)throw new Error("Non-zero carry");C=m,$++}for(var d=A-C;d!==A&&_[d]===0;)d++;for(var M=h.repeat(P);d<A;++d)M+=t.charAt(_[d]);return M}function T(v){if(typeof v!="string")throw new TypeError("Expected String");if(v.length===0)return new Uint8Array;var P=0;if(v[P]!==" "){for(var C=0,$=0;v[P]===h;)C++,P++;for(var x=(v.length-P)*f+1>>>0,A=new Uint8Array(x);v[P];){var _=r[v.charCodeAt(P)];if(_===255)return;for(var D=0,m=x-1;(_!==0||D<$)&&m!==-1;m--,D++)_+=u*A[m]>>>0,A[m]=_%256>>>0,_=_/256>>>0;if(_!==0)throw new Error("Non-zero carry");$=D,P++}if(v[P]!==" "){for(var o=x-$;o!==x&&A[o]===0;)o++;for(var d=new Uint8Array(C+(x-o)),M=C;o!==x;)d[M++]=A[o++];return d}}}function E(v){var P=T(v);if(P)return P;throw new Error(`Non-${e} character`)}return{encode:w,decodeUnsafe:T,decode:E}}var kd=Wd,Yd=kd;const Go=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},Jd=t=>new TextEncoder().encode(t),Xd=t=>new TextDecoder().decode(t);class Zd{constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Qd{constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){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))}else throw Error("Can only multibase decode strings")}or(e){return Wo(this,e)}}class ep{constructor(e){this.decoders=e}or(e){return Wo(this,e)}decode(e){const r=e[0],n=this.decoders[r];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Wo=(t,e)=>new ep(ut(ut({},t.decoders||{[t.prefix]:t}),e.decoders||{[e.prefix]:e}));class tp{constructor(e,r,n,i){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Zd(e,r,n),this.decoder=new Qd(e,r,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const un=({name:t,prefix:e,encode:r,decode:n})=>new tp(t,e,r,n),Ur=({prefix:t,name:e,alphabet:r})=>{const{encode:n,decode:i}=Yd(r,e);return un({prefix:t,name:e,encode:n,decode:s=>Go(i(s))})},rp=(t,e,r,n)=>{const i={};for(let g=0;g<e.length;++g)i[e[g]]=g;let s=t.length;for(;t[s-1]==="=";)--s;const c=new Uint8Array(s*r/8|0);let u=0,h=0,f=0;for(let g=0;g<s;++g){const w=i[t[g]];if(w===void 0)throw new SyntaxError(`Non-${n} character`);h=h<<r|w,u+=r,u>=8&&(u-=8,c[f++]=255&h>>u)}if(u>=r||255&h<<8-u)throw new SyntaxError("Unexpected end of data");return c},np=(t,e,r)=>{const n=e[e.length-1]==="=",i=(1<<r)-1;let s="",c=0,u=0;for(let h=0;h<t.length;++h)for(u=u<<8|t[h],c+=8;c>r;)c-=r,s+=e[i&u>>c];if(c&&(s+=e[i&u<<r-c]),n)for(;s.length*r&7;)s+="=";return s},nt=({name:t,prefix:e,bitsPerChar:r,alphabet:n})=>un({prefix:e,name:t,encode(i){return np(i,n,r)},decode(i){return rp(i,n,r,t)}}),ip=un({prefix:"\0",name:"identity",encode:t=>Xd(t),decode:t=>Jd(t)});var sp=Object.freeze({__proto__:null,identity:ip});const op=nt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ap=Object.freeze({__proto__:null,base2:op});const cp=nt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var up=Object.freeze({__proto__:null,base8:cp});const hp=Ur({prefix:"9",name:"base10",alphabet:"0123456789"});var fp=Object.freeze({__proto__:null,base10:hp});const lp=nt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),dp=nt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var pp=Object.freeze({__proto__:null,base16:lp,base16upper:dp});const gp=nt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),vp=nt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),yp=nt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),_p=nt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),bp=nt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),mp=nt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),wp=nt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Ep=nt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Dp=nt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var xp=Object.freeze({__proto__:null,base32:gp,base32upper:vp,base32pad:yp,base32padupper:_p,base32hex:bp,base32hexupper:mp,base32hexpad:wp,base32hexpadupper:Ep,base32z:Dp});const Sp=Ur({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Op=Ur({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Ap=Object.freeze({__proto__:null,base36:Sp,base36upper:Op});const Ip=Ur({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Lp=Ur({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Tp=Object.freeze({__proto__:null,base58btc:Ip,base58flickr:Lp});const Cp=nt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Np=nt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Pp=nt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Rp=nt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Fp=Object.freeze({__proto__:null,base64:Cp,base64pad:Np,base64url:Pp,base64urlpad:Rp});const ko=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),Up=ko.reduce((t,e,r)=>(t[r]=e,t),[]),Mp=ko.reduce((t,e,r)=>(t[e.codePointAt(0)]=r,t),[]);function jp(t){return t.reduce((e,r)=>(e+=Up[r],e),"")}function $p(t){const e=[];for(const r of t){const n=Mp[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(n)}return new Uint8Array(e)}const Bp=un({prefix:"\u{1F680}",name:"base256emoji",encode:jp,decode:$p});var zp=Object.freeze({__proto__:null,base256emoji:Bp}),Hp=Jo,Yo=128,Kp=127,qp=~Kp,Vp=Math.pow(2,31);function Jo(t,e,r){e=e||[],r=r||0;for(var n=r;t>=Vp;)e[r++]=t&255|Yo,t/=128;for(;t&qp;)e[r++]=t&255|Yo,t>>>=7;return e[r]=t|0,Jo.bytes=r-n+1,e}var Gp=Ei,Wp=128,Xo=127;function Ei(t,n){var r=0,n=n||0,i=0,s=n,c,u=t.length;do{if(s>=u)throw Ei.bytes=0,new RangeError("Could not decode varint");c=t[s++],r+=i<28?(c&Xo)<<i:(c&Xo)*Math.pow(2,i),i+=7}while(c>=Wp);return Ei.bytes=s-n,r}var kp=Math.pow(2,7),Yp=Math.pow(2,14),Jp=Math.pow(2,21),Xp=Math.pow(2,28),Zp=Math.pow(2,35),Qp=Math.pow(2,42),eg=Math.pow(2,49),tg=Math.pow(2,56),rg=Math.pow(2,63),ng=function(t){return t<kp?1:t<Yp?2:t<Jp?3:t<Xp?4:t<Zp?5:t<Qp?6:t<eg?7:t<tg?8:t<rg?9:10},ig={encode:Hp,decode:Gp,encodingLength:ng},Zo=ig;const Qo=(t,e,r=0)=>(Zo.encode(t,e,r),e),ea=t=>Zo.encodingLength(t),Di=(t,e)=>{const r=e.byteLength,n=ea(t),i=n+ea(r),s=new Uint8Array(i+r);return Qo(t,s,0),Qo(r,s,n),s.set(e,i),new sg(t,r,e,s)};class sg{constructor(e,r,n,i){this.code=e,this.size=r,this.digest=n,this.bytes=i}}const ta=({name:t,code:e,encode:r})=>new og(t,e,r);class og{constructor(e,r,n){this.name=e,this.code=r,this.encode=n}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?Di(this.code,r):r.then(n=>Di(this.code,n))}else throw Error("Unknown type, must be binary type")}}const ra=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),ag=ta({name:"sha2-256",code:18,encode:ra("SHA-256")}),cg=ta({name:"sha2-512",code:19,encode:ra("SHA-512")});var ug=Object.freeze({__proto__:null,sha256:ag,sha512:cg});const na=0,hg="identity",ia=Go;var fg=Object.freeze({__proto__:null,identity:{code:na,name:hg,encode:ia,digest:t=>Di(na,ia(t))}});new TextEncoder,new TextDecoder;const sa=ut(ut(ut(ut(ut(ut(ut(ut(ut(ut({},sp),ap),up),fp),pp),xp),Ap),Tp),Fp),zp);ut(ut({},ug),fg);function lg(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(t):new Uint8Array(t)}function oa(t,e,r,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:r},decoder:{decode:n}}}const aa=oa("utf8","u",t=>{const e=new TextDecoder("utf8");return"u"+e.decode(t)},t=>new TextEncoder().encode(t.substring(1))),xi=oa("ascii","a",t=>{let e="a";for(let r=0;r<t.length;r++)e+=String.fromCharCode(t[r]);return e},t=>{t=t.substring(1);const e=lg(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return e}),dg=ut({utf8:aa,"utf-8":aa,hex:sa.base16,latin1:xi,ascii:xi,binary:xi},sa);function pg(t,e="utf8"){const r=dg[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t,"utf8"):r.decoder.decode(`${r.prefix}${t}`)}const ca="wc",gg=2,Si="core",Mr=`${ca}@${2}:${Si}:`,vg={name:Si,logger:"error"},yg={database:":memory:"},_g="crypto",ua="client_ed25519_seed",bg=Le.ONE_DAY,mg="keychain",wg="0.3",Eg="messages",Dg="0.3",xg=Le.SIX_HOURS,Sg="publisher",ha="irn",Og="error",Ag="wss://relay.walletconnect.com",Ig="relayer",jr={message:"relayer_message",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error"},Lg="_subscription",lr={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},Tg=Le.ONE_SECOND,Cg="2.0.0-rc.1",Ng="0.3",Zt={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync"},Pg="subscription",Rg="0.3",Fg=Le.FIVE_SECONDS*1e3;class Ug{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=mg,this.version=wg,this.initialized=!1,this.storagePrefix=Mr,this.init=async()=>{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}},this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=async(n,i)=>{this.isInitialized(),this.keychain.set(n,i),await this.persist()},this.get=n=>{this.isInitialized();const i=this.keychain.get(n);if(typeof i>"u"){const{message:s}=G("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(s)}return i},this.del=async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()},this.core=e,this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,io(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?so(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Mg{constructor(e,r,n){this.core=e,this.logger=r,this.name=_g,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=i=>(this.isInitialized(),this.keychain.has(i)),this.getClientId=async()=>{this.isInitialized();const i=await this.getClientSeed(),s=zo(i);return Bo(s.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const i=vf();return this.setPrivateKey(i.publicKey,i.privateKey)},this.signJWT=async i=>{this.isInitialized();const s=await this.getClientSeed(),c=zo(s),u=ei();return await $d(u,i,bg,c)},this.generateSharedKey=(i,s,c)=>{this.isInitialized();const u=this.getPrivateKey(i),h=yf(u,s);return this.setSymKey(h,c)},this.setSymKey=async(i,s)=>{this.isInitialized();const c=s||_f(i);return await this.keychain.set(c,i),c},this.deleteKeyPair=async i=>{this.isInitialized(),await this.keychain.del(i)},this.deleteSymKey=async i=>{this.isInitialized(),await this.keychain.del(i)},this.encode=async(i,s,c)=>{this.isInitialized();const u=Zs(c),h=br(s);if(Qs(u)){const T=u.senderPublicKey,E=u.receiverPublicKey;i=await this.generateSharedKey(T,E)}const f=this.getSymKey(i),{type:g,senderPublicKey:w}=u;return mf({type:g,symKey:f,message:h,senderPublicKey:w})},this.decode=async(i,s,c)=>{this.isInitialized();const u=Df(s,c);if(Qs(u)){const g=u.receiverPublicKey,w=u.senderPublicKey;i=await this.generateSharedKey(g,w)}const h=this.getSymKey(i),f=wf({symKey:h,encoded:s});return In(f)},this.core=e,this.logger=Oe.generateChildLogger(r,this.name),this.keychain=n||new Ug(this.core,this.logger)}get context(){return Oe.getLoggerContext(this.logger)}async setPrivateKey(e,r){return await this.keychain.set(e,r),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(ua)}catch{e=ei(),await this.keychain.set(ua,e)}return pg(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}class jg extends vd{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=Eg,this.version=Dg,this.initialized=!1,this.storagePrefix=Mr,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}},this.set=async(n,i)=>{this.isInitialized();const s=Zr(i);let c=this.messages.get(n);return typeof c>"u"&&(c={}),typeof c[s]<"u"||(c[s]=i,this.messages.set(n,c),await this.persist()),s},this.get=n=>{this.isInitialized();let i=this.messages.get(n);return typeof i>"u"&&(i={}),i},this.has=(n,i)=>{this.isInitialized();const s=this.get(n),c=Zr(i);return typeof s[c]<"u"},this.del=async n=>{this.isInitialized(),this.messages.delete(n),await this.persist()},this.logger=Oe.generateChildLogger(e,this.name),this.core=r}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,io(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?so(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}class $g extends yd{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new cn.EventEmitter,this.name=Sg,this.queue=new Map,this.publish=async(n,i,s)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}});try{const c=s?.ttl||xg,u=ti(s),h=s?.prompt||!1,f=s?.tag||0,g={topic:n,message:i,opts:{ttl:c,relay:u,prompt:h,tag:f}},w=Zr(i);this.queue.set(w,g),await this.rpcPublish(n,i,c,u,h,f),this.onPublish(w,g),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}})}catch(c){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(c),c}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.relayer=e,this.logger=Oe.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return Oe.getLoggerContext(this.logger)}rpcPublish(e,r,n,i,s,c){var u,h,f,g;const w={method:ri(i.protocol).publish,params:{topic:e,message:r,ttl:n,prompt:s,tag:c}};return Et((u=w.params)==null?void 0:u.prompt)&&((h=w.params)==null||delete h.prompt),Et((f=w.params)==null?void 0:f.tag)&&((g=w.params)==null||delete g.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:w}),this.relayer.provider.request(w)}onPublish(e,r){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:r,message:n,opts:{ttl:i,relay:s,prompt:c,tag:u}}=e,h=Zr(n);await this.rpcPublish(r,n,i,s,c,u),this.onPublish(h,e)})}registerEventListeners(){this.relayer.core.heartbeat.on(Pr.HEARTBEAT_EVENTS.pulse,()=>{this.checkQueue()})}}class Bg{constructor(){this.map=new Map,this.set=(e,r)=>{const n=this.get(e);this.exists(e,r)||this.map.set(e,[...n,r])},this.get=e=>this.map.get(e)||[],this.exists=(e,r)=>this.get(e).includes(r),this.delete=(e,r)=>{if(typeof r>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const n=this.get(e);if(!this.exists(e,r))return;const i=n.filter(s=>s!==r);if(!i.length){this.map.delete(e);return}this.map.set(e,i)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var zg=Object.defineProperty,Hg=Object.defineProperties,Kg=Object.getOwnPropertyDescriptors,fa=Object.getOwnPropertySymbols,qg=Object.prototype.hasOwnProperty,Vg=Object.prototype.propertyIsEnumerable,la=(t,e,r)=>e in t?zg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,hn=(t,e)=>{for(var r in e||(e={}))qg.call(e,r)&&la(t,r,e[r]);if(fa)for(var r of fa(e))Vg.call(e,r)&&la(t,r,e[r]);return t},Oi=(t,e)=>Hg(t,Kg(e));class Gg extends md{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new Bg,this.events=new cn.EventEmitter,this.name=Pg,this.version=Rg,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pendingSubInterval=20,this.storagePrefix=Mr,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),await this.reset(),this.registerEventListeners(),this.onEnable())},this.subscribe=async(n,i)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}});try{const s=ti(i),c={topic:n,relay:s};this.pending.set(n,c);const u=await this.rpcSubscribe(n,s);return this.onSubscribe(u,c),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}}),u}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}},this.unsubscribe=async(n,i)=>{this.isInitialized(),typeof i?.id<"u"?await this.unsubscribeById(n,i.id,i):await this.unsubscribeByTopic(n,i)},this.isSubscribed=async n=>this.topics.includes(n)?!0:await new Promise((i,s)=>{const c=new Le.Watch;c.start(this.pendingSubscriptionWatchLabel);const u=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(u),c.stop(this.pendingSubscriptionWatchLabel),i(!0)),c.elapsed(this.pendingSubscriptionWatchLabel)>=Fg&&(clearInterval(u),c.stop(this.pendingSubscriptionWatchLabel),s(!1))},this.pendingSubInterval)}),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.relayer=e,this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,r){let n=!1;try{n=this.getSubscription(e).topic===r}catch{}return n}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear(),this.initialized=!1}async unsubscribeByTopic(e,r){const n=this.topicMap.get(e);await Promise.all(n.map(async i=>await this.unsubscribeById(e,i,r)))}async unsubscribeById(e,r,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:n}});try{const i=ti(n);await this.rpcUnsubscribe(e,r,i);const s=rt("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:n}})}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}}async rpcSubscribe(e,r){const n={method:ri(r.protocol).subscribe,params:{topic:e}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n}),await this.relayer.provider.request(n)}rpcUnsubscribe(e,r,n){const i={method:ri(n.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.provider.request(i)}onSubscribe(e,r){this.setSubscription(e,Oi(hn({},r),{id:e})),this.pending.delete(r.topic)}onResubscribe(e,r){this.addSubscription(e,Oi(hn({},r),{id:e})),this.pending.delete(r.topic)}async onUnsubscribe(e,r,n){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,n),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:r}),this.addSubscription(e,r))}addSubscription(e,r){this.subscriptions.set(e,hn({},r)),this.topicMap.set(r.topic,e),this.events.emit(Zt.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const r=this.subscriptions.get(e);if(!r){const{message:n}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const n=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(n.topic,e),this.events.emit(Zt.deleted,Oi(hn({},n),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Zt.sync)}async reset(){!this.cached.length||await Promise.all(this.cached.map(async e=>await this.resubscribe(e)))}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=G("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async resubscribe(e){if(!this.ids.includes(e.id)){const{topic:r,relay:n}=e,i={topic:r,relay:n};this.pending.set(i.topic,i);const s=await this.rpcSubscribe(i.topic,i.relay);this.onResubscribe(s,i)}}async onConnect(){await this.reset(),this.onEnable()}onDisconnect(){this.onDisable()}checkPending(){this.pending.forEach(async e=>{const r=await this.rpcSubscribe(e.topic,e.relay);this.onSubscribe(r,e)})}registerEventListeners(){this.relayer.core.heartbeat.on(Pr.HEARTBEAT_EVENTS.pulse,()=>{this.checkPending()}),this.relayer.provider.on(lr.connect,async()=>{await this.onConnect()}),this.relayer.provider.on(lr.disconnect,()=>{this.onDisconnect()}),this.events.on(Zt.created,async e=>{const r=Zt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(Zt.deleted,async e=>{const r=Zt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Wg=Object.defineProperty,da=Object.getOwnPropertySymbols,kg=Object.prototype.hasOwnProperty,Yg=Object.prototype.propertyIsEnumerable,pa=(t,e,r)=>e in t?Wg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Jg=(t,e)=>{for(var r in e||(e={}))kg.call(e,r)&&pa(t,r,e[r]);if(da)for(var r of da(e))Yg.call(e,r)&&pa(t,r,e[r]);return t};class Xg extends _d{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new cn.EventEmitter,this.name=Ig,this.initialized=!1,this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Oe.generateChildLogger(e.logger,this.name):oi(Oe.getDefaultLoggerOptions({level:e.logger||Og})),this.messages=new jg(this.logger,e.core),this.subscriber=new Gg(this,this.logger),this.publisher=new $g(this,this.logger),this.relayUrl=e?.relayUrl||Ag,this.projectId=e.projectId,this.provider={}}async init(){this.logger.trace("Initialized");const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=this.createProvider(e),await Promise.all([this.messages.init(),this.provider.connect(),this.subscriber.init()]),this.registerEventListeners(),this.initialized=!0}get context(){return Oe.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,r,n){this.isInitialized(),await this.publisher.publish(e,r,n),await this.recordMessageEvent({topic:e,message:r})}async subscribe(e,r){return this.isInitialized(),await this.subscriber.subscribe(e,r)}async unsubscribe(e,r){this.isInitialized(),await this.subscriber.unsubscribe(e,r)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}createProvider(e){return new On(new zd(Mf({sdkVersion:Cg,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e})))}async recordMessageEvent(e){const{topic:r,message:n}=e;await this.messages.set(r,n)}async shouldIgnoreMessageEvent(e){const{topic:r,message:n}=e;return await this.subscriber.isSubscribed(r)?this.messages.has(r,n):!0}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),ki(e)){if(!e.method.endsWith(Lg))return;const r=e.params,{topic:n,message:i}=r.data,s={topic:n,message:i};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Jg({type:"event",event:r.id},s)),this.events.emit(r.id,s),await this.acknowledgePayload(e),await this.onMessageEvent(s)}}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(jr.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=Sn(e.id,!0);await this.provider.connection.send(r)}registerEventListeners(){this.provider.on(lr.payload,e=>this.onProviderPayload(e)),this.provider.on(lr.connect,()=>{this.events.emit(jr.connect)}),this.provider.on(lr.disconnect,()=>{this.events.emit(jr.disconnect),setTimeout(()=>{this.provider.connect()},Le.toMiliseconds(Tg))}),this.provider.on(lr.error,e=>this.events.emit(jr.error,e))}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Zg=Object.defineProperty,ga=Object.getOwnPropertySymbols,Qg=Object.prototype.hasOwnProperty,e0=Object.prototype.propertyIsEnumerable,va=(t,e,r)=>e in t?Zg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ya=(t,e)=>{for(var r in e||(e={}))Qg.call(e,r)&&va(t,r,e[r]);if(ga)for(var r of ga(e))e0.call(e,r)&&va(t,r,e[r]);return t};class Ai extends bd{constructor(e,r,n,i=Mr){super(e,r,n,i),this.core=e,this.logger=r,this.name=n,this.map=new Map,this.version=Ng,this.cached=[],this.initialized=!1,this.storagePrefix=Mr,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(s=>{il(s)?this.map.set(s.id,s):sl(s)&&this.map.set(s.topic,s)}),this.cached=[],this.initialized=!0)},this.set=async(s,c)=>{this.isInitialized(),this.map.has(s)?await this.update(s,c):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:s,value:c}),this.map.set(s,c),await this.persist())},this.get=s=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:s}),this.getData(s)),this.getAll=s=>s?this.values.filter(c=>Object.keys(s).every(u=>Hd(c[u],s[u]))):this.values,this.update=async(s,c)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:s,update:c});const u=ya(ya({},this.getData(s)),c);this.map.set(s,u),await this.persist()},this.delete=async(s,c)=>{this.isInitialized(),this.map.has(s)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:s,reason:c}),this.map.delete(s),await this.persist())},this.logger=Oe.generateChildLogger(r,this.name),this.storagePrefix=i}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const r=this.map.get(e);if(!r){const{message:n}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:r}=G("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}var t0=Object.defineProperty,_a=Object.getOwnPropertySymbols,r0=Object.prototype.hasOwnProperty,n0=Object.prototype.propertyIsEnumerable,ba=(t,e,r)=>e in t?t0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ma=(t,e)=>{for(var r in e||(e={}))r0.call(e,r)&&ba(t,r,e[r]);if(_a)for(var r of _a(e))n0.call(e,r)&&ba(t,r,e[r]);return t};class Ii extends pd{constructor(e){super(e),this.protocol=ca,this.version=gg,this.name=Si,this.events=new cn.EventEmitter,this.initialized=!1,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.projectId=e?.projectId;const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:oi(Oe.getDefaultLoggerOptions({level:e?.logger||vg.logger}));this.logger=Oe.generateChildLogger(r,this.name),this.heartbeat=new Pr.HeartBeat,this.crypto=new Mg(this,this.logger,e?.keychain),this.storage=e!=null&&e.storage?e.storage:new id(ma(ma({},yg),e?.storageOptions)),this.relayer=new Xg({core:this,logger:this.logger,relayUrl:e?.relayUrl,projectId:this.projectId})}static async init(e){const r=new Ii(e);return await r.initialize(),r}get context(){return Oe.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.relayer.init(),await this.heartbeat.init(),this.initialized=!0,this.logger.info("Core Initilization Success")}catch(e){throw this.logger.info("Core Initilization Failure"),this.logger.error(e.message),e}}}const i0=Ii;var dr={exports:{}},pr=typeof Reflect=="object"?Reflect:null,wa=pr&&typeof pr.apply=="function"?pr.apply:function(e,r,n){return Function.prototype.apply.call(e,r,n)},fn;pr&&typeof pr.ownKeys=="function"?fn=pr.ownKeys:Object.getOwnPropertySymbols?fn=function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:fn=function(e){return Object.getOwnPropertyNames(e)};function s0(t){console&&console.warn&&console.warn(t)}var Ea=Number.isNaN||function(e){return e!==e};function xe(){xe.init.call(this)}dr.exports=xe,dr.exports.once=u0,xe.EventEmitter=xe,xe.prototype._events=void 0,xe.prototype._eventsCount=0,xe.prototype._maxListeners=void 0;var Da=10;function ln(t){if(typeof t!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}Object.defineProperty(xe,"defaultMaxListeners",{enumerable:!0,get:function(){return Da},set:function(t){if(typeof t!="number"||t<0||Ea(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");Da=t}}),xe.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},xe.prototype.setMaxListeners=function(e){if(typeof e!="number"||e<0||Ea(e))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+e+".");return this._maxListeners=e,this};function xa(t){return t._maxListeners===void 0?xe.defaultMaxListeners:t._maxListeners}xe.prototype.getMaxListeners=function(){return xa(this)},xe.prototype.emit=function(e){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=e==="error",s=this._events;if(s!==void 0)i=i&&s.error===void 0;else if(!i)return!1;if(i){var c;if(r.length>0&&(c=r[0]),c instanceof Error)throw c;var u=new Error("Unhandled error."+(c?" ("+c.message+")":""));throw u.context=c,u}var h=s[e];if(h===void 0)return!1;if(typeof h=="function")wa(h,this,r);else for(var f=h.length,g=La(h,f),n=0;n<f;++n)wa(g[n],this,r);return!0};function Sa(t,e,r,n){var i,s,c;if(ln(r),s=t._events,s===void 0?(s=t._events=Object.create(null),t._eventsCount=0):(s.newListener!==void 0&&(t.emit("newListener",e,r.listener?r.listener:r),s=t._events),c=s[e]),c===void 0)c=s[e]=r,++t._eventsCount;else if(typeof c=="function"?c=s[e]=n?[r,c]:[c,r]:n?c.unshift(r):c.push(r),i=xa(t),i>0&&c.length>i&&!c.warned){c.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=t,u.type=e,u.count=c.length,s0(u)}return t}xe.prototype.addListener=function(e,r){return Sa(this,e,r,!1)},xe.prototype.on=xe.prototype.addListener,xe.prototype.prependListener=function(e,r){return Sa(this,e,r,!0)};function o0(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Oa(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=o0.bind(n);return i.listener=r,n.wrapFn=i,i}xe.prototype.once=function(e,r){return ln(r),this.on(e,Oa(this,e,r)),this},xe.prototype.prependOnceListener=function(e,r){return ln(r),this.prependListener(e,Oa(this,e,r)),this},xe.prototype.removeListener=function(e,r){var n,i,s,c,u;if(ln(r),i=this._events,i===void 0)return this;if(n=i[e],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[e],i.removeListener&&this.emit("removeListener",e,n.listener||r));else if(typeof n!="function"){for(s=-1,c=n.length-1;c>=0;c--)if(n[c]===r||n[c].listener===r){u=n[c].listener,s=c;break}if(s<0)return this;s===0?n.shift():a0(n,s),n.length===1&&(i[e]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",e,u||r)}return this},xe.prototype.off=xe.prototype.removeListener,xe.prototype.removeAllListeners=function(e){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[e]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[e]),this;if(arguments.length===0){var s=Object.keys(n),c;for(i=0;i<s.length;++i)c=s[i],c!=="removeListener"&&this.removeAllListeners(c);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[e],typeof r=="function")this.removeListener(e,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(e,r[i]);return this};function Aa(t,e,r){var n=t._events;if(n===void 0)return[];var i=n[e];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?c0(i):La(i,i.length)}xe.prototype.listeners=function(e){return Aa(this,e,!0)},xe.prototype.rawListeners=function(e){return Aa(this,e,!1)},xe.listenerCount=function(t,e){return typeof t.listenerCount=="function"?t.listenerCount(e):Ia.call(t,e)},xe.prototype.listenerCount=Ia;function Ia(t){var e=this._events;if(e!==void 0){var r=e[t];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}xe.prototype.eventNames=function(){return this._eventsCount>0?fn(this._events):[]};function La(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function a0(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}function c0(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}function u0(t,e){return new Promise(function(r,n){function i(c){t.removeListener(e,s),n(c)}function s(){typeof t.removeListener=="function"&&t.removeListener("error",i),r([].slice.call(arguments))}Ta(t,e,s,{once:!0}),e!=="error"&&h0(t,i,{once:!0})})}function h0(t,e,r){typeof t.on=="function"&&Ta(t,"error",e,r)}function Ta(t,e,r,n){if(typeof t.on=="function")n.once?t.once(e,r):t.on(e,r);else if(typeof t.addEventListener=="function")t.addEventListener(e,function i(s){n.once&&t.removeEventListener(e,i),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t)}(function(t){function e(){}function r(h,f){if(h=h===void 0?"utf-8":h,f=f===void 0?{fatal:!1}:f,c.indexOf(h.toLowerCase())===-1)throw new RangeError("Failed to construct 'TextDecoder': The encoding label provided ('"+h+"') is invalid.");if(f.fatal)throw Error("Failed to construct 'TextDecoder': the 'fatal' option is unsupported.")}function n(h){return Buffer.from(h.buffer,h.byteOffset,h.byteLength).toString("utf-8")}function i(h){try{var f=URL.createObjectURL(new Blob([h],{type:"text/plain;charset=UTF-8"})),g=new XMLHttpRequest;return g.open("GET",f,!1),g.send(),g.responseText}catch{return s(h)}finally{f&&URL.revokeObjectURL(f)}}function s(h){for(var f=0,g=Math.min(65536,h.length+1),w=new Uint16Array(g),T=[],E=0;;){var v=f<h.length;if(!v||E>=g-1){if(T.push(String.fromCharCode.apply(null,w.subarray(0,E))),!v)return T.join("");h=h.subarray(f),E=f=0}if(v=h[f++],(v&128)===0)w[E++]=v;else if((v&224)===192){var P=h[f++]&63;w[E++]=(v&31)<<6|P}else if((v&240)===224){P=h[f++]&63;var C=h[f++]&63;w[E++]=(v&31)<<12|P<<6|C}else if((v&248)===240){P=h[f++]&63,C=h[f++]&63;var $=h[f++]&63;v=(v&7)<<18|P<<12|C<<6|$,65535<v&&(v-=65536,w[E++]=v>>>10&1023|55296,v=56320|v&1023),w[E++]=v}}}if(t.TextEncoder&&t.TextDecoder)return!1;var c=["utf-8","utf8","unicode-1-1-utf-8"];Object.defineProperty(e.prototype,"encoding",{value:"utf-8"}),e.prototype.encode=function(h,f){if(f=f===void 0?{stream:!1}:f,f.stream)throw Error("Failed to encode: the 'stream' option is unsupported.");f=0;for(var g=h.length,w=0,T=Math.max(32,g+(g>>>1)+7),E=new Uint8Array(T>>>3<<3);f<g;){var v=h.charCodeAt(f++);if(55296<=v&&56319>=v){if(f<g){var P=h.charCodeAt(f);(P&64512)===56320&&(++f,v=((v&1023)<<10)+(P&1023)+65536)}if(55296<=v&&56319>=v)continue}if(w+4>E.length&&(T+=8,T*=1+f/h.length*2,T=T>>>3<<3,P=new Uint8Array(T),P.set(E),E=P),(v&4294967168)===0)E[w++]=v;else{if((v&4294965248)===0)E[w++]=v>>>6&31|192;else if((v&4294901760)===0)E[w++]=v>>>12&15|224,E[w++]=v>>>6&63|128;else if((v&4292870144)===0)E[w++]=v>>>18&7|240,E[w++]=v>>>12&63|128,E[w++]=v>>>6&63|128;else continue;E[w++]=v&63|128}}return E.slice?E.slice(0,w):E.subarray(0,w)},Object.defineProperty(r.prototype,"encoding",{value:"utf-8"}),Object.defineProperty(r.prototype,"fatal",{value:!1}),Object.defineProperty(r.prototype,"ignoreBOM",{value:!1});var u=s;typeof Buffer=="function"&&Buffer.from?u=n:typeof Blob=="function"&&typeof URL=="function"&&typeof URL.createObjectURL=="function"&&(u=i),r.prototype.decode=function(h,f){if(f=f===void 0?{stream:!1}:f,f.stream)throw Error("Failed to decode: the 'stream' option is unsupported.");return h=h instanceof Uint8Array?h:h.buffer instanceof ArrayBuffer?new Uint8Array(h.buffer):new Uint8Array(h),u(h)},t.TextEncoder=e,t.TextDecoder=r})(typeof window<"u"?window:Z);const Ca="wc",Na=2,Pa="client",$r=`${Ca}@${Na}:${Pa}:`,Li={name:Pa,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},f0="expirer",Dt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},l0="0.3",Lt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},d0="history",p0="0.3",g0="pairing",v0="proposal",Ra=ar(Le.THIRTY_DAYS),y0="session",_0=Le.SEVEN_DAYS,dn=ar(_0),b0="engine",Ti={wc_pairingDelete:{req:{prompt:!1,tag:1e3},res:{prompt:!1,tag:1001}},wc_pairingPing:{req:{prompt:!1,tag:1002},res:{prompt:!1,tag:1003}},wc_sessionPropose:{req:{prompt:!0,tag:1100},res:{prompt:!1,tag:1101}},wc_sessionSettle:{req:{prompt:!1,tag:1102},res:{prompt:!1,tag:1103}},wc_sessionUpdate:{req:{prompt:!1,tag:1104},res:{prompt:!1,tag:1105}},wc_sessionExtend:{req:{prompt:!1,tag:1106},res:{prompt:!1,tag:1107}},wc_sessionRequest:{req:{prompt:!0,tag:1108},res:{prompt:!1,tag:1109}},wc_sessionEvent:{req:{prompt:!0,tag:1110},res:{prompt:!1,tag:1111}},wc_sessionDelete:{req:{prompt:!1,tag:1112},res:{prompt:!1,tag:1113}},wc_sessionPing:{req:{prompt:!1,tag:1114},res:{prompt:!1,tag:1115}}};var m0=Object.defineProperty,w0=Object.defineProperties,E0=Object.getOwnPropertyDescriptors,Fa=Object.getOwnPropertySymbols,D0=Object.prototype.hasOwnProperty,x0=Object.prototype.propertyIsEnumerable,Ua=(t,e,r)=>e in t?m0(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ht=(t,e)=>{for(var r in e||(e={}))D0.call(e,r)&&Ua(t,r,e[r]);if(Fa)for(var r of Fa(e))x0.call(e,r)&&Ua(t,r,e[r]);return t},Ma=(t,e)=>w0(t,E0(e));class S0 extends xd{constructor(e){super(e),this.events=new dr.exports,this.initialized=!1,this.name=b0,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0)},this.connect=async r=>{this.isInitialized(),await this.isValidConnect(r);const{pairingTopic:n,requiredNamespaces:i,relays:s}=r;let c=n,u,h=!1;if(c&&(h=this.client.pairing.get(c).active),!c||!h){const{topic:C,uri:$}=await this.createPairing();c=C,u=$}const f=await this.client.core.crypto.generateKeyPair(),g={requiredNamespaces:i,relays:s??[{protocol:ha}],proposer:{publicKey:f,metadata:this.client.metadata}},{reject:w,resolve:T,done:E}=Yt();if(this.events.once(Fe("session_connect"),async({error:C,session:$})=>{if(C)w(C);else if($){$.self.publicKey=f;const x=Ma(Ht({},$),{requiredNamespaces:i});await this.client.session.set($.topic,x),await this.setExpiry($.topic,$.expiry),c&&await this.client.pairing.update(c,{peerMetadata:$.peer.metadata}),T(x)}}),!c){const{message:C}=G("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(C)}const v=await this.sendRequest(c,"wc_sessionPropose",g),P=ar(Le.FIVE_MINUTES);return await this.setProposal(v,Ht({id:v,expiry:P},g)),{uri:u,approval:E}},this.pair=async r=>{this.isInitialized(),this.isValidPair(r);const{topic:n,symKey:i,relay:s}=Wf(r.uri),c=ar(Le.FIVE_MINUTES),u={topic:n,relay:s,expiry:c,active:!1};return await this.client.pairing.set(n,u),await this.client.core.crypto.setSymKey(i,n),await this.client.core.relayer.subscribe(n,{relay:s}),await this.setExpiry(n,c),u},this.approve=async r=>{this.isInitialized(),await this.isValidApprove(r);const{id:n,relayProtocol:i,namespaces:s}=r,{pairingTopic:c,proposer:u,requiredNamespaces:h}=this.client.proposal.get(n),f=await this.client.core.crypto.generateKeyPair(),g=u.publicKey,w=await this.client.core.crypto.generateSharedKey(f,g),T={relay:{protocol:i??"irn"},namespaces:s,requiredNamespaces:h,controller:{publicKey:f,metadata:this.client.metadata},expiry:dn};await this.client.core.relayer.subscribe(w);const E=await this.sendRequest(w,"wc_sessionSettle",T),{done:v,resolve:P,reject:C}=Yt();this.events.once(Fe("session_approve",E),({error:x})=>{x?C(x):P(this.client.session.get(w))});const $=Ma(Ht({},T),{topic:w,acknowledged:!1,self:T.controller,peer:{publicKey:u.publicKey,metadata:u.metadata},controller:f});return await this.client.session.set(w,$),await this.setExpiry(w,dn),c&&await this.client.pairing.update(c,{peerMetadata:$.peer.metadata}),c&&n&&(await this.sendResult(n,c,{relay:{protocol:i??"irn"},responderPublicKey:f}),await this.client.proposal.delete(n,rt("USER_DISCONNECTED")),await this.activatePairing(c)),{topic:w,acknowledged:v}},this.reject=async r=>{this.isInitialized(),await this.isValidReject(r);const{id:n,reason:i}=r,{pairingTopic:s}=this.client.proposal.get(n);s&&(await this.sendError(n,s,i),await this.client.proposal.delete(n,rt("USER_DISCONNECTED")))},this.update=async r=>{this.isInitialized(),await this.isValidUpdate(r);const{topic:n,namespaces:i}=r,s=await this.sendRequest(n,"wc_sessionUpdate",{namespaces:i}),{done:c,resolve:u,reject:h}=Yt();return this.events.once(Fe("session_update",s),({error:f})=>{f?h(f):u()}),await this.client.session.update(n,{namespaces:i}),{acknowledged:c}},this.extend=async r=>{this.isInitialized(),await this.isValidExtend(r);const{topic:n}=r,i=await this.sendRequest(n,"wc_sessionExtend",{}),{done:s,resolve:c,reject:u}=Yt();return this.events.once(Fe("session_extend",i),({error:h})=>{h?u(h):c()}),await this.setExpiry(n,dn),{acknowledged:s}},this.request=async r=>{this.isInitialized(),await this.isValidRequest(r);const{chainId:n,request:i,topic:s}=r,c=await this.sendRequest(s,"wc_sessionRequest",{request:i,chainId:n}),{done:u,resolve:h,reject:f}=Yt();return this.events.once(Fe("session_request",c),({error:g,result:w})=>{g?f(g):h(w)}),await u()},this.respond=async r=>{this.isInitialized(),await this.isValidRespond(r);const{topic:n,response:i}=r,{id:s}=i;Pt(i)?await this.sendResult(s,n,i.result):wt(i)&&await this.sendError(s,n,i.error)},this.ping=async r=>{this.isInitialized(),await this.isValidPing(r);const{topic:n}=r;if(this.client.session.keys.includes(n)){const i=await this.sendRequest(n,"wc_sessionPing",{}),{done:s,resolve:c,reject:u}=Yt();this.events.once(Fe("session_ping",i),({error:h})=>{h?u(h):c()}),await s()}else if(this.client.pairing.keys.includes(n)){const i=await this.sendRequest(n,"wc_pairingPing",{}),{done:s,resolve:c,reject:u}=Yt();this.events.once(Fe("pairing_ping",i),({error:h})=>{h?u(h):c()}),await s()}},this.emit=async r=>{this.isInitialized(),await this.isValidEmit(r);const{topic:n,event:i,chainId:s}=r;await this.sendRequest(n,"wc_sessionEvent",{event:i,chainId:s})},this.disconnect=async r=>{this.isInitialized(),await this.isValidDisconnect(r);const{topic:n}=r;this.client.session.keys.includes(n)?(await this.sendRequest(n,"wc_sessionDelete",rt("USER_DISCONNECTED")),await this.deleteSession(n)):this.client.pairing.keys.includes(n)&&(await this.sendRequest(n,"wc_pairingDelete",rt("USER_DISCONNECTED")),await this.deletePairing(n))},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(n=>tl(n,r))),this.activatePairing=async r=>{await this.client.pairing.update(r,{active:!0,expiry:Ra}),await this.setExpiry(r,Ra)},this.deleteSession=async r=>{const{self:n}=this.client.session.get(r);await Promise.all([this.client.core.relayer.unsubscribe(r),this.client.session.delete(r,rt("USER_DISCONNECTED")),this.client.core.crypto.deleteKeyPair(n.publicKey),this.client.core.crypto.deleteSymKey(r),this.client.expirer.del(r)])},this.deletePairing=async r=>{await Promise.all([this.client.core.relayer.unsubscribe(r),this.client.pairing.delete(r,rt("USER_DISCONNECTED")),this.client.core.crypto.deleteSymKey(r),this.client.expirer.del(r)])},this.deleteProposal=async r=>{await Promise.all([this.client.proposal.delete(r,rt("USER_DISCONNECTED")),this.client.expirer.del(r)])},this.setExpiry=async(r,n)=>{this.client.pairing.keys.includes(r)?await this.client.pairing.update(r,{expiry:n}):this.client.session.keys.includes(r)&&await this.client.session.update(r,{expiry:n}),this.client.expirer.set(r,n)},this.setProposal=async(r,n)=>{await this.client.proposal.set(r,n),this.client.expirer.set(r,n.expiry)},this.sendRequest=async(r,n,i)=>{const s=xn(n,i),c=await this.client.core.crypto.encode(r,s),u=Ti[n].req;return await this.client.core.relayer.publish(r,c,u),this.client.history.set(r,s),s.id},this.sendResult=async(r,n,i)=>{const s=Sn(r,i),c=await this.client.core.crypto.encode(n,s),u=await this.client.history.get(n,r),h=Ti[u.request.method].res;await this.client.core.relayer.publish(n,c,h),await this.client.history.resolve(s)},this.sendError=async(r,n,i)=>{const s=qr(r,i),c=await this.client.core.crypto.encode(n,s),u=await this.client.history.get(n,r),h=Ti[u.request.method].res;await this.client.core.relayer.publish(n,c,h),await this.client.history.resolve(s)},this.cleanup=async()=>{const r=[],n=[],i=[];this.client.session.getAll().forEach(s=>{kt(s.expiry)&&r.push(s.topic)}),this.client.pairing.getAll().forEach(s=>{kt(s.expiry)&&n.push(s.topic)}),this.client.proposal.getAll().forEach(s=>{kt(s.expiry)&&i.push(s.id)}),await Promise.all([...r.map(this.deleteSession),...n.map(this.deletePairing),...i.map(this.deleteProposal)])},this.onRelayEventRequest=r=>{const{topic:n,payload:i}=r,s=i.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeRequest(n,i);case"wc_sessionSettle":return this.onSessionSettleRequest(n,i);case"wc_sessionUpdate":return this.onSessionUpdateRequest(n,i);case"wc_sessionExtend":return this.onSessionExtendRequest(n,i);case"wc_sessionPing":return this.onSessionPingRequest(n,i);case"wc_pairingPing":return this.onPairingPingRequest(n,i);case"wc_sessionDelete":return this.onSessionDeleteRequest(n,i);case"wc_pairingDelete":return this.onPairingDeleteRequest(n,i);case"wc_sessionRequest":return this.onSessionRequest(n,i);case"wc_sessionEvent":return this.onSessionEventRequest(n,i);default:return this.client.logger.info(`Unsupported request method ${s}`)}},this.onRelayEventResponse=async r=>{const{topic:n,payload:i}=r,s=(await this.client.history.get(n,i.id)).request.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeResponse(n,i);case"wc_sessionSettle":return this.onSessionSettleResponse(n,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(n,i);case"wc_sessionExtend":return this.onSessionExtendResponse(n,i);case"wc_sessionPing":return this.onSessionPingResponse(n,i);case"wc_pairingPing":return this.onPairingPingResponse(n,i);case"wc_sessionRequest":return this.onSessionRequestResponse(n,i);default:return this.client.logger.info(`Unsupported response method ${s}`)}},this.onSessionProposeRequest=async(r,n)=>{const{params:i,id:s}=n;try{this.isValidConnect(Ht({},n.params));const c=ar(Le.FIVE_MINUTES),u=Ht({id:s,pairingTopic:r,expiry:c},i);await this.setProposal(s,u),this.client.events.emit("session_proposal",{id:s,params:u})}catch(c){await this.sendError(s,r,c),this.client.logger.error(c)}},this.onSessionProposeResponse=async(r,n)=>{const{id:i}=n;if(Pt(n)){const{result:s}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:s});const c=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:c});const u=c.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:u});const h=s.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:h});const f=await this.client.core.crypto.generateSharedKey(u,h);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:f});const g=await this.client.core.relayer.subscribe(f);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:g}),await this.activatePairing(r)}else wt(n)&&(await this.client.proposal.delete(i,rt("USER_DISCONNECTED")),this.events.emit(Fe("session_connect"),{error:n.error}))},this.onSessionSettleRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidSessionSettleRequest(s);const{relay:c,controller:u,expiry:h,namespaces:f}=n.params,g={topic:r,relay:c,expiry:h,namespaces:f,acknowledged:!0,controller:u.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:u.publicKey,metadata:u.metadata}};await this.sendResult(n.id,r,!0),this.events.emit(Fe("session_connect"),{session:g})}catch(c){await this.sendError(i,r,c),this.client.logger.error(c)}},this.onSessionSettleResponse=async(r,n)=>{const{id:i}=n;Pt(n)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Fe("session_approve",i),{})):wt(n)&&(await this.client.session.delete(r,rt("USER_DISCONNECTED")),this.events.emit(Fe("session_approve",i),{error:n.error}))},this.onSessionUpdateRequest=async(r,n)=>{const{params:i,id:s}=n;try{this.isValidUpdate(Ht({topic:r},i)),await this.client.session.update(r,{namespaces:i.namespaces}),await this.sendResult(s,r,!0),this.client.events.emit("session_update",{id:s,topic:r,params:i})}catch(c){await this.sendError(s,r,c),this.client.logger.error(c)}},this.onSessionUpdateResponse=(r,n)=>{const{id:i}=n;Pt(n)?this.events.emit(Fe("session_update",i),{}):wt(n)&&this.events.emit(Fe("session_update",i),{error:n.error})},this.onSessionExtendRequest=async(r,n)=>{const{id:i}=n;try{this.isValidExtend({topic:r}),await this.setExpiry(r,dn),await this.sendResult(i,r,!0),this.client.events.emit("session_extend",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionExtendResponse=(r,n)=>{const{id:i}=n;Pt(n)?this.events.emit(Fe("session_extend",i),{}):wt(n)&&this.events.emit(Fe("session_extend",i),{error:n.error})},this.onSessionPingRequest=async(r,n)=>{const{id:i}=n;try{this.isValidPing({topic:r}),await this.sendResult(i,r,!0),this.client.events.emit("session_ping",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionPingResponse=(r,n)=>{const{id:i}=n;Pt(n)?this.events.emit(Fe("session_ping",i),{}):wt(n)&&this.events.emit(Fe("session_ping",i),{error:n.error})},this.onPairingPingRequest=async(r,n)=>{const{id:i}=n;try{this.isValidPing({topic:r}),await this.sendResult(i,r,!0),this.client.events.emit("pairing_ping",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onPairingPingResponse=(r,n)=>{const{id:i}=n;Pt(n)?this.events.emit(Fe("pairing_ping",i),{}):wt(n)&&this.events.emit(Fe("pairing_ping",i),{error:n.error})},this.onSessionDeleteRequest=async(r,n)=>{const{id:i}=n;try{this.isValidDisconnect({topic:r,reason:n.params}),await this.sendResult(i,r,!0),await this.deleteSession(r),this.client.events.emit("session_delete",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onPairingDeleteRequest=async(r,n)=>{const{id:i}=n;try{this.isValidDisconnect({topic:r,reason:n.params}),await this.sendResult(i,r,!0),await this.deletePairing(r),this.client.events.emit("pairing_delete",{id:i,topic:r})}catch(s){await this.sendError(i,r,s),this.client.logger.error(s)}},this.onSessionRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidRequest(Ht({topic:r},s)),this.client.events.emit("session_request",{id:i,topic:r,params:s})}catch(c){await this.sendError(i,r,c),this.client.logger.error(c)}},this.onSessionRequestResponse=(r,n)=>{const{id:i}=n;Pt(n)?this.events.emit(Fe("session_request",i),{result:n.result}):wt(n)&&this.events.emit(Fe("session_request",i),{error:n.error})},this.onSessionEventRequest=async(r,n)=>{const{id:i,params:s}=n;try{this.isValidEmit(Ht({topic:r},s)),this.client.events.emit("session_event",{id:i,topic:r,params:s})}catch(c){await this.sendError(i,r,c),this.client.logger.error(c)}},this.isValidConnect=async r=>{if(!yt(r)){const{message:u}=G("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(u)}const{pairingTopic:n,requiredNamespaces:i,relays:s}=r;Et(n)||await this.isValidPairingTopic(n);const c=ul(i,"connect()");if(c)throw new Error(c.message);if(!hl(s,!0)){const{message:u}=G("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(u)}},this.isValidPair=r=>{if(!yt(r)){const{message:n}=G("MISSING_OR_INVALID",`pair() params: ${r}`);throw new Error(n)}if(!nl(r.uri)){const{message:n}=G("MISSING_OR_INVALID",`pair() uri: ${r.uri}`);throw new Error(n)}},this.isValidApprove=async r=>{if(!yt(r))throw new Error(G("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:n,namespaces:i,relayProtocol:s}=r;await this.isValidProposalId(n);const c=this.client.proposal.get(n),u=si(i,"approve()");if(u)throw new Error(u.message);const h=bo(c.requiredNamespaces,i,"update()");if(h)throw new Error(h.message);if(!ot(s,!0)){const{message:f}=G("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(f)}},this.isValidReject=async r=>{if(!yt(r)){const{message:s}=G("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(s)}const{id:n,reason:i}=r;if(await this.isValidProposalId(n),!ll(i)){const{message:s}=G("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidSessionSettleRequest=r=>{if(!yt(r)){const{message:f}=G("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(f)}const{relay:n,controller:i,namespaces:s,expiry:c}=r;if(!yo(n)){const{message:f}=G("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(f)}const u=ol(i,"onSessionSettleRequest()");if(u)throw new Error(u.message);const h=si(s,"onSessionSettleRequest()");if(h)throw new Error(h.message);if(kt(c)){const{message:f}=G("EXPIRED","onSessionSettleRequest()");throw new Error(f)}},this.isValidUpdate=async r=>{if(!yt(r)){const{message:h}=G("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(h)}const{topic:n,namespaces:i}=r;await this.isValidSessionTopic(n);const s=this.client.session.get(n),c=si(i,"update()");if(c)throw new Error(c.message);const u=bo(s.requiredNamespaces,i,"update()");if(u)throw new Error(u.message)},this.isValidExtend=async r=>{if(!yt(r)){const{message:i}=G("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionTopic(n)},this.isValidRequest=async r=>{if(!yt(r)){const{message:u}=G("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(u)}const{topic:n,request:i,chainId:s}=r;await this.isValidSessionTopic(n);const{namespaces:c}=this.client.session.get(n);if(!_o(c,s)){const{message:u}=G("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(u)}if(!dl(i)){const{message:u}=G("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(u)}if(!vl(c,s,i.method)){const{message:u}=G("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(u)}},this.isValidRespond=async r=>{if(!yt(r)){const{message:s}=G("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(s)}const{topic:n,response:i}=r;if(await this.isValidSessionTopic(n),!pl(i)){const{message:s}=G("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(s)}},this.isValidPing=async r=>{if(!yt(r)){const{message:i}=G("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)},this.isValidEmit=async r=>{if(!yt(r)){const{message:u}=G("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(u)}const{topic:n,event:i,chainId:s}=r;await this.isValidSessionTopic(n);const{namespaces:c}=this.client.session.get(n);if(!_o(c,s)){const{message:u}=G("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(u)}if(!gl(i)){const{message:u}=G("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(u)}if(!yl(c,s,i.name)){const{message:u}=G("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(u)}},this.isValidDisconnect=async r=>{if(!yt(r)){const{message:i}=G("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(i)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)}}async createPairing(){const e=ei(),r=await this.client.core.crypto.setSymKey(e),n=ar(Le.FIVE_MINUTES),i={protocol:ha},s={topic:r,expiry:n,relay:i,active:!1},c=Yf({protocol:this.client.protocol,version:this.client.version,topic:r,symKey:e,relay:i});return await this.client.pairing.set(r,s),await this.client.core.relayer.subscribe(r),await this.setExpiry(r,n),{topic:r,uri:c}}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(jr.message,async e=>{const{topic:r,message:n}=e,i=await this.client.core.crypto.decode(r,n);ki(i)?(this.client.history.set(r,i),this.onRelayEventRequest({topic:r,payload:i})):Yi(i)&&(await this.client.history.resolve(i),this.onRelayEventResponse({topic:r,payload:i}))})}registerExpirerEvents(){this.client.expirer.on(Dt.expired,async e=>{const{topic:r,id:n}=Bf(e.target);r?this.client.session.keys.includes(r)?(await this.deleteSession(r),this.client.events.emit("session_expire",{topic:r})):this.client.pairing.keys.includes(r)&&(await this.deletePairing(r),this.client.events.emit("pairing_expire",{topic:r})):n&&await this.deleteProposal(n)})}async isValidPairingTopic(e){if(!ot(e,!1)){const{message:r}=G("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(r)}if(!this.client.pairing.keys.includes(e)){const{message:r}=G("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(kt(this.client.pairing.get(e).expiry)){await this.deletePairing(e);const{message:r}=G("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!ot(e,!1)){const{message:r}=G("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(!this.client.session.keys.includes(e)){const{message:r}=G("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(kt(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:r}=G("EXPIRED",`session topic: ${e}`);throw new Error(r)}}async isValidSessionOrPairingTopic(e){if(this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.pairing.keys.includes(e))await this.isValidPairingTopic(e);else if(ot(e,!1)){const{message:r}=G("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=G("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!fl(e)){const{message:r}=G("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=G("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(kt(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:r}=G("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class O0 extends Sd{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new dr.exports.EventEmitter,this.name=f0,this.version=l0,this.cached=[],this.initialized=!1,this.storagePrefix=$r,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=n=>{try{const i=this.formatTarget(n);return typeof this.getExpiration(i)<"u"}catch{return!1}},this.set=(n,i)=>{this.isInitialized();const s=this.formatTarget(n),c={target:s,expiry:i};this.expirations.set(s,c),this.checkExpiry(s,c),this.events.emit(Dt.created,{target:s,expiration:c})},this.get=n=>{this.isInitialized();const i=this.formatTarget(n);return this.getExpiration(i)},this.del=n=>{this.isInitialized();const i=this.formatTarget(n);if(this.has(i)){const s=this.getExpiration(i);this.expirations.delete(i),this.events.emit(Dt.deleted,{target:i,expiration:s})}},this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return jf(e);if(typeof e=="number")return $f(e);const{message:r}=G("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(r)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Dt.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=G("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const r=this.expirations.get(e);if(!r){const{message:n}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}return r}checkExpiry(e,r){const{expiry:n}=r;Le.toMiliseconds(n)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(Dt.expired,{target:e,expiration:r})}checkExpirations(){this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(Pr.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(Dt.created,e=>{const r=Dt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Dt.expired,e=>{const r=Dt.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Dt.deleted,e=>{const r=Dt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}class A0 extends gd{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new dr.exports.EventEmitter,this.name=d0,this.version=p0,this.cached=[],this.initialized=!1,this.storagePrefix=$r,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(n,i,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:n,request:i,chainId:s}),this.records.has(i.id))return;const c={id:i.id,topic:n,request:{method:i.method,params:i.params||null},chainId:s};this.records.set(c.id,c),this.events.emit(Lt.created,c)},this.resolve=async n=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:n}),!this.records.has(n.id))return;const i=await this.getRecord(n.id);typeof i.response>"u"&&(i.response=wt(n)?{error:n.error}:{result:n.result},this.records.set(i.id,i),this.events.emit(Lt.updated,i))},this.get=async(n,i)=>{this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:i});const s=await this.getRecord(i);if(s.topic!==n){const{message:c}=G("MISMATCHED_TOPIC",`${this.name}, ${i}`);throw this.logger.error(c),new Error(c)}return s},this.delete=(n,i)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:i}),this.values.forEach(s=>{if(s.topic===n){if(typeof i<"u"&&s.id!==i)return;this.records.delete(s.id),this.events.emit(Lt.deleted,s)}})},this.exists=async(n,i)=>(this.isInitialized(),this.records.has(i)?(await this.getRecord(i)).topic===n:!1),this.on=(n,i)=>{this.events.on(n,i)},this.once=(n,i)=>{this.events.once(n,i)},this.off=(n,i)=>{this.events.off(n,i)},this.removeListener=(n,i)=>{this.events.removeListener(n,i)},this.logger=Oe.generateChildLogger(r,this.name)}get context(){return Oe.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const n={topic:r.topic,request:xn(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(n)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const r=this.records.get(e);if(!r){const{message:n}=G("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Lt.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=G("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(Lt.created,e=>{const r=Lt.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Lt.updated,e=>{const r=Lt.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(Lt.deleted,e=>{const r=Lt.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=G("NOT_INITIALIZED",this.name);throw new Error(e)}}}class I0 extends Ai{constructor(e,r){super(e,r,g0,$r),this.core=e,this.logger=r}}class L0 extends Ai{constructor(e,r){super(e,r,v0,$r),this.core=e,this.logger=r}}class T0 extends Ai{constructor(e,r){super(e,r,y0,$r),this.core=e,this.logger=r}}class Ci extends Dd{constructor(e){super(e),this.protocol=Ca,this.version=Na,this.name=Li.name,this.events=new dr.exports.EventEmitter,this.on=(n,i)=>this.events.on(n,i),this.once=(n,i)=>this.events.once(n,i),this.off=(n,i)=>this.events.off(n,i),this.removeListener=(n,i)=>this.events.removeListener(n,i),this.connect=async n=>{try{return await this.engine.connect(n)}catch(i){throw this.logger.error(i.message),i}},this.pair=async n=>{try{return await this.engine.pair(n)}catch(i){throw this.logger.error(i.message),i}},this.approve=async n=>{try{return await this.engine.approve(n)}catch(i){throw this.logger.error(i.message),i}},this.reject=async n=>{try{return await this.engine.reject(n)}catch(i){throw this.logger.error(i.message),i}},this.update=async n=>{try{return await this.engine.update(n)}catch(i){throw this.logger.error(i.message),i}},this.extend=async n=>{try{return await this.engine.extend(n)}catch(i){throw this.logger.error(i.message),i}},this.request=async n=>{try{return await this.engine.request(n)}catch(i){throw this.logger.error(i.message),i}},this.respond=async n=>{try{return await this.engine.respond(n)}catch(i){throw this.logger.error(i.message),i}},this.ping=async n=>{try{return await this.engine.ping(n)}catch(i){throw this.logger.error(i.message),i}},this.emit=async n=>{try{return await this.engine.emit(n)}catch(i){throw this.logger.error(i.message),i}},this.disconnect=async n=>{try{return await this.engine.disconnect(n)}catch(i){throw this.logger.error(i.message),i}},this.find=n=>{try{return this.engine.find(n)}catch(i){throw this.logger.error(i.message),i}},this.name=e?.name||Li.name,this.metadata=e?.metadata||Pf();const r=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:oi(Oe.getDefaultLoggerOptions({level:e?.logger||Li.logger}));this.core=e?.core||new i0(e),this.logger=Oe.generateChildLogger(r,this.name),this.pairing=new I0(this.core,this.logger),this.session=new T0(this.core,this.logger),this.proposal=new L0(this.core,this.logger),this.history=new A0(this.core,this.logger),this.expirer=new O0(this.core,this.logger),this.engine=new S0(this)}static async init(e){const r=new Ci(e);return await r.initialize(),r}get context(){return Oe.getLoggerContext(this.logger)}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.pairing.init(),await this.session.init(),await this.proposal.init(),await this.history.init(),await this.expirer.init(),await this.engine.init(),this.logger.info("SignClient Initilization Success")}catch(e){throw this.logger.info("SignClient Initilization Failure"),this.logger.error(e.message),e}}}function Ge(){this._events=this._events||{},this._maxListeners=this._maxListeners||void 0}var C0=Ge;Ge.EventEmitter=Ge,Ge.prototype._events=void 0,Ge.prototype._maxListeners=void 0,Ge.defaultMaxListeners=10,Ge.prototype.setMaxListeners=function(t){if(!N0(t)||t<0||isNaN(t))throw TypeError("n must be a positive number");return this._maxListeners=t,this},Ge.prototype.emit=function(t){var e,r,n,i,s,c;if(this._events||(this._events={}),t==="error"&&(!this._events.error||Br(this._events.error)&&!this._events.error.length)){if(e=arguments[1],e instanceof Error)throw e;var u=new Error('Uncaught, unspecified "error" event. ('+e+")");throw u.context=e,u}if(r=this._events[t],ja(r))return!1;if(Ut(r))switch(arguments.length){case 1:r.call(this);break;case 2:r.call(this,arguments[1]);break;case 3:r.call(this,arguments[1],arguments[2]);break;default:i=Array.prototype.slice.call(arguments,1),r.apply(this,i)}else if(Br(r))for(i=Array.prototype.slice.call(arguments,1),c=r.slice(),n=c.length,s=0;s<n;s++)c[s].apply(this,i);return!0},Ge.prototype.addListener=function(t,e){var r;if(!Ut(e))throw TypeError("listener must be a function");return this._events||(this._events={}),this._events.newListener&&this.emit("newListener",t,Ut(e.listener)?e.listener:e),this._events[t]?Br(this._events[t])?this._events[t].push(e):this._events[t]=[this._events[t],e]:this._events[t]=e,Br(this._events[t])&&!this._events[t].warned&&(ja(this._maxListeners)?r=Ge.defaultMaxListeners:r=this._maxListeners,r&&r>0&&this._events[t].length>r&&(this._events[t].warned=!0,console.error("(node) warning: possible EventEmitter memory leak detected. %d listeners added. Use emitter.setMaxListeners() to increase limit.",this._events[t].length),typeof console.trace=="function"&&console.trace())),this},Ge.prototype.on=Ge.prototype.addListener,Ge.prototype.once=function(t,e){if(!Ut(e))throw TypeError("listener must be a function");var r=!1;function n(){this.removeListener(t,n),r||(r=!0,e.apply(this,arguments))}return n.listener=e,this.on(t,n),this},Ge.prototype.removeListener=function(t,e){var r,n,i,s;if(!Ut(e))throw TypeError("listener must be a function");if(!this._events||!this._events[t])return this;if(r=this._events[t],i=r.length,n=-1,r===e||Ut(r.listener)&&r.listener===e)delete this._events[t],this._events.removeListener&&this.emit("removeListener",t,e);else if(Br(r)){for(s=i;s-- >0;)if(r[s]===e||r[s].listener&&r[s].listener===e){n=s;break}if(n<0)return this;r.length===1?(r.length=0,delete this._events[t]):r.splice(n,1),this._events.removeListener&&this.emit("removeListener",t,e)}return this},Ge.prototype.removeAllListeners=function(t){var e,r;if(!this._events)return this;if(!this._events.removeListener)return arguments.length===0?this._events={}:this._events[t]&&delete this._events[t],this;if(arguments.length===0){for(e in this._events)e!=="removeListener"&&this.removeAllListeners(e);return this.removeAllListeners("removeListener"),this._events={},this}if(r=this._events[t],Ut(r))this.removeListener(t,r);else if(r)for(;r.length;)this.removeListener(t,r[r.length-1]);return delete this._events[t],this},Ge.prototype.listeners=function(t){var e;return!this._events||!this._events[t]?e=[]:Ut(this._events[t])?e=[this._events[t]]:e=this._events[t].slice(),e},Ge.prototype.listenerCount=function(t){if(this._events){var e=this._events[t];if(Ut(e))return 1;if(e)return e.length}return 0},Ge.listenerCount=function(t,e){return t.listenerCount(e)};function Ut(t){return typeof t=="function"}function N0(t){return typeof t=="number"}function Br(t){return typeof t=="object"&&t!==null}function ja(t){return t===void 0}function P0(t){return typeof t<"u"&&typeof t.context<"u"}const Tt={init:"signer_init",uri:"signer_uri",created:"signer_created",updated:"signer_updated",deleted:"signer_deleted",event:"signer_event"};class R0 extends hc{constructor(e){super(),this.events=new C0.EventEmitter,this.pending=!1,this.initializing=!1,this.requiredNamespaces=e?.requiredNamespaces||{},this.opts=e?.client}get connected(){return typeof this.session<"u"}get connecting(){return this.pending}get chains(){return this.session?Yn(this.session.namespaces):pf(this.requiredNamespaces)}get accounts(){return this.session?kn(this.session.namespaces):[]}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(){if(this.pending)return new Promise((e,r)=>{this.events.once("open",()=>{if(this.events.once("open_error",n=>{r(n)}),typeof this.client>"u")return r(new Error("Sign Client not initialized"));e()})});try{this.pending=!0;const e=await this.register(),r=e.find({requiredNamespaces:this.requiredNamespaces});if(r.length)return this.onOpen(r[0]);const{uri:n,approval:i}=await e.connect({requiredNamespaces:this.requiredNamespaces});this.events.emit(Tt.uri,{uri:n}),this.session=await i(),this.events.emit(Tt.created,this.session),this.onOpen()}catch(e){throw this.events.emit("open_error",e),e}}async close(){typeof this.session>"u"||(await(await this.register()).disconnect({topic:this.session.topic,reason:rt("USER_DISCONNECTED")}),this.onClose())}async send(e,r){if(typeof this.client>"u"&&(this.client=await this.register(),this.connected||await this.open()),typeof this.session>"u")throw new Error("Signer connection is missing session");this.client.request({topic:this.session.topic,request:e,chainId:r?.chainId}).then(n=>this.events.emit("payload",Sn(e.id,n))).catch(n=>this.events.emit("payload",qr(e.id,n.message)))}async register(e=this.opts){if(typeof this.client<"u")return this.client;if(this.initializing)return new Promise((r,n)=>{this.events.once("register_error",i=>{n(i)}),this.events.once(Tt.init,()=>{if(typeof this.client>"u")return n(new Error("Sign Client not initialized"));r(this.client)})});if(P0(e))return this.client=e,this.registerEventListeners(),this.client;try{return this.initializing=!0,this.client=await Ci.init(e),this.initializing=!1,this.registerEventListeners(),this.events.emit(Tt.init),this.client}catch(r){throw this.events.emit("register_error",r),r}}onOpen(e){this.pending=!1,e&&(this.session=e),this.events.emit("open")}onClose(){this.pending=!1,this.client&&(this.client=void 0),this.events.emit("close")}registerEventListeners(){typeof this.client<"u"&&(this.client.on("session_event",e=>{var r;this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||this.events.emit(Tt.event,e.params)}),this.client.on("session_update",e=>{var r;typeof this.client<"u"&&(this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||(this.session=this.client.session.get(e.topic),this.events.emit(Tt.updated,this.session)))}),this.client.on("session_delete",e=>{var r;!this.session||this.session&&((r=this.session)==null?void 0:r.topic)!==e.topic||(this.onClose(),this.events.emit(Tt.deleted,this.session),this.session=void 0)}))}}const F0=["eth_requestAccounts","eth_accounts","eth_chainId","eth_sendTransaction","eth_signTransaction","eth_sign","eth_signTypedData","personal_sign"],U0=["chainChanged","accountsChanged"];function $a(t){return{chains:t!=null&&t.chainId?[`eip155:${t.chainId}`]:[],methods:t?.methods||[],events:t?.events||[],rpcMap:t?.rpcMap||void 0}}function Ba(t,e){let r;return e.rpcMap&&(r=e.rpcMap[Ni([t])]),r}function Ni(t){return Number(t[0].split(":")[1])}class M0{constructor(e){this.events=new vr.EventEmitter,this.namespace="eip155",this.accounts=[],this.rpc=$a(e),this.signer=this.setSignerProvider(e?.client),this.chainId=Ni(this.rpc.chains),this.http=this.setHttpProvider(this.chainId),this.registerEventListeners()}async request(e){switch(e.method){case"eth_requestAccounts":return await this.connect(),this.accounts;case"eth_accounts":return this.accounts;case"eth_chainId":return this.chainId}if(e.method.startsWith("eth_signTypedData")||this.rpc.methods.includes(e.method))return this.signer.request(e,{chainId:this.formatChainId(this.chainId)});if(typeof this.http>"u")throw new Error(`Cannot request JSON-RPC method (${e.method}) without provided rpc url`);return this.http.request(e)}sendAsync(e,r){this.request(e).then(n=>r(null,n)).catch(n=>r(n,void 0))}get connected(){return this.signer.connection.connected}get connecting(){return this.signer.connection.connecting}async enable(){return await this.request({method:"eth_requestAccounts"})}async connect(){await this.signer.connect()}async disconnect(){await this.signer.disconnect()}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}registerEventListeners(){this.signer.on("connect",()=>{const e=this.signer.connection.chains;e&&e.length&&this.setChainIds(e);const r=this.signer.connection.accounts;r&&r.length&&this.setAccounts(r)}),this.signer.connection.on(Tt.created,e=>{const r=Yn(e.namespaces,[this.namespace]);this.setChainIds(r);const n=kn(e.namespaces,[this.namespace]);this.setAccounts(n)}),this.signer.connection.on(Tt.updated,e=>{const r=Yn(e.namespaces,[this.namespace]);this.setChainIds(r);const n=kn(e.namespaces,[this.namespace]);n!==this.accounts&&this.setAccounts(n)}),this.signer.connection.on(Tt.event,e=>{if(!this.rpc.chains.includes(e.chainId))return;const{event:r}=e;r.name==="accountsChanged"?(this.accounts=r.data,this.events.emit("accountsChanged",this.accounts)):r.name==="chainChanged"?this.setChainId(r.data):this.events.emit(r.name,r.data)}),this.signer.on("disconnect",()=>{this.events.emit("disconnect")}),this.events.on("chainChanged",e=>this.setHttpProvider(e))}setSignerProvider(e){const r=new R0({requiredNamespaces:{[this.namespace]:{chains:this.rpc.chains,methods:this.rpc.methods,events:this.rpc.events}},client:e});return new On(r)}setHttpProvider(e){const r=Ba(`${this.namespace}:${e}`,this.rpc);return typeof r>"u"?void 0:new On(new yc(r))}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const r=e.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n)).filter(n=>n!==this.chainId);r.length&&(this.chainId=r[0],this.events.emit("chainChanged",this.chainId))}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.events.emit("chainChanged",this.chainId)}}parseAccountId(e){const[r,n,i]=e.split(":");return{chainId:`${r}:${n}`,address:i}}setAccounts(e){this.accounts=e.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}}mt.default=M0,mt.getEthereumChainId=Ni,mt.getRpcConfig=$a,mt.getRpcUrl=Ba,mt.signerEvents=U0,mt.signerMethods=F0,Object.defineProperty(mt,"__esModule",{value:!0})});
2
2
  //# sourceMappingURL=index.umd.js.map