Reading from NEAR testnet…
Reading from NEAR testnet…
9dwNuMTrfdueX2A68ZUEop8SpAHWgJRwLdY7Ps9KLWuv
web4.nearbuilders.testnet to web4.nearbuilders.testnet · failed
fs_store()
length===0&&await Ao()}},async unwatch(){Fn.watchListeners=[],await Ao()},mount(Ho,zo){if(Ho=normalizeBaseKey(Ho),Ho&&Fn.mounts[Ho])throw new Error(`already mounted at ${Ho}`);return Ho&&(Fn.mountpoints.push(Ho),Fn.mountpoints.sort((Go,Vo)=>Vo.length-Go.length)),Fn.mounts[Ho]=zo,Fn.watching&&Promise.resolve(watch(zo,$o,Ho)).then(Go=>{Fn.unwatch[Ho]=Go}).catch(console.error),Lo},async unmount(Ho,zo=!0){Ho=normalizeBaseKey(Ho),!(!Ho||!Fn.mounts[Ho])&&(Fn.watching&&Ho in Fn.unwatch&&(Fn.unwatch[Ho](),delete Fn.unwatch[Ho]),zo&&await dispose(Fn.mounts[Ho]),Fn.mountpoints=Fn.mountpoints.filter(Go=>Go!==Ho),delete Fn.mounts[Ho])},getMount(Ho=""){Ho=normalizeKey(Ho)+":";const zo=io(Ho);return{driver:zo.driver,base:zo.base}},getMounts(Ho="",zo={}){return Ho=normalizeKey(Ho),fo(Ho,zo.parents).map(Vo=>({driver:Vo.driver,base:Vo.mountpoint}))},keys:(Ho,zo={})=>Lo.getKeys(Ho,zo),get:(Ho,zo={})=>Lo.getItem(Ho,zo),set:(Ho,zo,Go={})=>Lo.setItem(Ho,zo,Go),has:(Ho,zo={})=>Lo.hasItem(Ho,zo),del:(Ho,zo={})=>Lo.removeItem(Ho,zo),remove:(Ho,zo={})=>Lo.removeItem(Ho,zo)};return Lo}function watch(Mn,Fn,io){return Mn.watch?Mn.watch((fo,$o)=>Fn(fo,io+$o)):()=>{}}async function dispose(Mn){typeof Mn.dispose=="function"&&await asyncCall(Mn.dispose)}function promisifyRequest(Mn){return new Promise((Fn,io)=>{Mn.oncomplete=Mn.onsuccess=()=>Fn(Mn.result),Mn.onabort=Mn.onerror=()=>io(Mn.error)})}function createStore$1(Mn,Fn){const io=indexedDB.open(Mn);io.onupgradeneeded=()=>io.result.createObjectStore(Fn);const fo=promisifyRequest(io);return($o,mo)=>fo.then(Ao=>mo(Ao.transaction(Fn,$o).objectStore(Fn)))}let defaultGetStoreFunc;function defaultGetStore(){return defaultGetStoreFunc||(defaultGetStoreFunc=createStore$1("keyval-store","keyval")),defaultGetStoreFunc}function get$e(Mn,Fn=defaultGetStore()){return Fn("readonly",io=>promisifyRequest(io.get(Mn)))}function set$e(Mn,Fn,io=defaultGetStore()){return io("readwrite",fo=>(fo.put(Fn,Mn),promisifyRequest(fo.transaction)))}function del(Mn,Fn=defaultGetStore()){return Fn("readwrite",io=>(io.delete(Mn),promisifyRequest(io.transaction)))}function clear$7(Mn=defaultGetStore()){return Mn("readwrite",Fn=>(Fn.clear(),promisifyRequest(Fn.transaction)))}function eachCursor(Mn,Fn){return Mn.openCursor().onsuccess=function(){this.result&&(Fn(this.result),this.result.continue())},promisifyRequest(Mn.transaction)}function keys$d(Mn=defaultGetStore()){return Mn("readonly",Fn=>{if(Fn.getAllKeys)return promisifyRequest(Fn.getAllKeys());const io=[];return eachCursor(Fn,fo=>io.push(fo.key)).then(()=>io)})}const x$4="idb-keyval";var z$5=(Mn={})=>{const Fn=Mn.base&&Mn.base.length>0?`${Mn.base}:`:"",io=$o=>Fn+$o;let fo;return Mn.dbName&&Mn.storeName&&(fo=createStore$1(Mn.dbName,Mn.storeName)),{name:x$4,options:Mn,async hasItem($o){return!(typeof await get$e(io($o),fo)>"u")},async getItem($o){return await get$e(io($o),fo)??null},setItem($o,mo){return set$e(io($o),mo,fo)},removeItem($o){return del(io($o),fo)},getKeys(){return keys$d(fo)},clear(){return clear$7(fo)}}};const D$4="WALLET_CONNECT_V2_INDEXED_DB",E$4="keyvaluestorage";let _$1=class{constructor(){this.indexedDb=createStorage({driver:z$5({dbName:D$4,storeName:E$4})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(Fn=>[Fn.key,Fn.value])}async getItem(Fn){const io=await this.indexedDb.getItem(Fn);if(io!==null)return io}async setItem(Fn,io){await this.indexedDb.setItem(Fn,safeJsonStringify(io))}async removeItem(Fn){await this.indexedDb.removeItem(Fn)}};var l$3=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global$o<"u"?global$o:typeof self<"u"?self:{},c$1={exports:{}};(function(){let Mn;function Fn(){}Mn=Fn,Mn.prototype.getItem=function(io){return this.hasOwnProperty(io)?String(this[io]):null},Mn.prototype.setItem=function(io,fo){this[io]=String(fo)},Mn.prototype.removeItem=function(io){delete this[io]},Mn.prototype.clear=function(){const io=this;Object.keys(io).forEach(function(fo){io[fo]=void 0,delete io[fo]})},Mn.prototype.key=function(io){return io=io||0,Object.keys(this)[io]},Mn.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof l$3<"u"&&l$3.localStorage?c$1.exports=l$3.localStorage:typeof window<"u"&&window.localStorage?c$1.exports=window.localStorage:c$1.exports=new Fn})();function k$1(Mn){var Fn;return[Mn[0],safeJsonParse((Fn=Mn[1])!=null?Fn:"")]}let K$3=class{constructor(){this.localStorage=c$1.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(k$1)}async getItem(Fn){const io=this.localStorage.getItem(Fn);if(io!==null)return safeJsonParse(io)}async setItem(Fn,io){this.localStorage.setItem(Fn,safeJsonStringify(io))}async removeItem(Fn){this.localStorage.removeItem(Fn)}};const N$3="wc_storage_version",y$4=1,O$5=async(Mn,Fn,io)=>{const fo=N$3,$o=await Fn.getItem(fo);if($o&&$o>=y$4){io(Fn);return}const mo=await Mn.getKeys();if(!mo.length){io(Fn);return}const Ao=[];for(;mo.length;){const jo=mo.shift();if(!jo)continue;const Lo=jo.toLowerCase();if(Lo.includes("wc@")||Lo.includes("walletconnect")||Lo.includes("wc_")||Lo.includes("wallet_connect")){const Ho=await Mn.getItem(jo);await Fn.setItem(jo,Ho),Ao.push(jo)}}await Fn.setItem(fo,y$4),io(Fn),j$7(Mn,Ao)},j$7=async(Mn,Fn)=>{Fn.length&&Fn.forEach(async io=>{await Mn.removeItem(io)})};let h$2=class{constructor(){this.initialized=!1,this.setInitialized=io=>{this.storage=io,this.initialized=!0};const Fn=new K$3;this.storage=Fn;try{const io=new _$1;O$5(Fn,io,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(Fn){return await this.initialize(),this.storage.getItem(Fn)}async setItem(Fn,io){return await this.initialize(),this.storage.setItem(Fn,io)}async removeItem(Fn){return await this.initialize(),this.storage.removeItem(Fn)}async initialize(){this.initialized||await new Promise(Fn=>{const io=setInterval(()=>{this.initialized&&(clearInterval(io),Fn())},20)})}},n$3=class extends IEvents{constructor(Fn){super(),this.opts=Fn,this.protocol="wc",this.version=2}},h$1=class extends IEvents{constructor(Fn,io){super(),this.core=Fn,this.logger=io,this.records=new Map}},a$1=class{constructor(Fn,io){this.logger=Fn,this.core=io}},g$2=class extends IEvents{constructor(Fn,io){super(),this.relayer=Fn,this.logger=io}},u$2=class extends IEvents{constructor(Fn){super()}},p$5=class{constructor(Fn,io,fo,$o){this.core=Fn,this.logger=io,this.name=fo}},d$1=class extends IEvents{constructor(Fn,io){super(),this.relayer=Fn,this.logger=io}},x$3=class extends IEvents{constructor(Fn,io){super(),this.core=Fn,this.logger=io}},y$3=class{constructor(Fn,io,fo){this.core=Fn,this.logger=io,this.store=fo}},v$5=class{constructor(Fn,io){this.projectId=Fn,this.logger=io}},C$3=class{constructor(Fn,io,fo){this.core=Fn,this.logger=io,this.telemetryEnabled=fo}},S$3=class{constructor(Fn){this.opts=Fn,this.protocol="wc",this.version=2}},M$4=class{constructor(Fn){this.client=Fn}};const PARSE_ERROR="PARSE_ERROR",INVALID_REQUEST="INVALID_REQUEST",METHOD_NOT_FOUND="METHOD_NOT_FOUND",INVALID_PARAMS="INVALID_PARAMS",INTERNAL_ERROR="INTERNAL_ERROR",SERVER_ERROR="SERVER_ERROR",RESERVED_ERROR_CODES=[-32700,-32600,-32601,-32602,-32603],STANDARD_ERROR_MAP={[PARSE_ERROR]:{code:-32700,message:"Parse error"},[INVALID_REQUEST]:{code:-32600,message:"Invalid Request"},[METHOD_NOT_FOUND]:{code:-32601,message:"Method not found"},[INVALID_PARAMS]:{code:-32602,message:"Invalid params"},[INTERNAL_ERROR]:{code:-32603,message:"Internal error"},[SERVER_ERROR]:{code:-32e3,message:"Server error"}},DEFAULT_ERROR=SERVER_ERROR;function isReservedErrorCode(Mn){return RESERVED_ERROR_CODES.includes(Mn)}function getError(Mn){return Object.keys(STANDARD_ERROR_MAP).includes(Mn)?STANDARD_ERROR_MAP[Mn]:STANDARD_ERROR_MAP[DEFAULT_ERROR]}function getErrorByCode(Mn){const Fn=Object.values(STANDARD_ERROR_MAP).find(io=>io.code===Mn);return Fn||STANDARD_ERROR_MAP[DEFAULT_ERROR]}function parseConnectionError(Mn,Fn,io){return Mn.message.includes("getaddrinfo ENOTFOUND")||Mn.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${io} RPC url at ${Fn}`):Mn}var cjs$1={},crypto$2={},hasRequiredCrypto;function requireCrypto(){if(hasRequiredCrypto)return crypto$2;hasRequiredCrypto=1,Object.defineProperty(crypto$2,"__esModule",{value:!0}),crypto$2.isBrowserCryptoAvailable=crypto$2.getSubtleCrypto=crypto$2.getBrowerCrypto=void 0;function Mn(){return(commonjsGlobal$c==null?void 0:commonjsGlobal$c.crypto)||(commonjsGlobal$c==null?void 0:commonjsGlobal$c.msCrypto)||{}}crypto$2.getBrowerCrypto=Mn;function Fn(){const fo=Mn();return fo.subtle||fo.webkitSubtle}crypto$2.getSubtleCrypto=Fn;function io(){return!!Mn()&&!!Fn()}return crypto$2.isBrowserCryptoAvailable=io,crypto$2}var env={},hasRequiredEnv;function requireEnv(){if(hasRequiredEnv)return env;hasRequiredEnv=1,Object.defineProperty(env,"__esModule",{value:!0}),env.isBrowser=env.isNode=env.isReactNative=void 0;function Mn(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}env.isReactNative=Mn;function Fn(){return typeof process$1$7<"u"&&typeof process$1$7.versions<"u"&&typeof process$1$7.versions.node<"u"}env.isNode=Fn;function io(){return!Mn()&&!Fn()}return env.isBrowser=io,env}(function(Mn){Object.defineProperty(Mn,"__esModule",{value:!0});const Fn=require$$0$9;Fn.__exportStar(requireCrypto(),Mn),Fn.__exportStar(requireEnv(),Mn)})(cjs$1);function payloadId(Mn=3){const Fn=Date.now()*Math.pow(10,Mn),io=Math.floor(Math.random()*Math.pow(10,Mn));return Fn+io}function getBigIntRpcId(Mn=6){return BigInt(payloadId(Mn))}function formatJsonRpcRequest(Mn,Fn,io){return{id:io||payloadId(),jsonrpc:"2.0",method:Mn,params:Fn}}function formatJsonRpcResult(Mn,Fn){return{id:Mn,jsonrpc:"2.0",result:Fn}}function formatJsonRpcError(Mn,Fn,io){return{id:Mn,jsonrpc:"2.0",error:formatErrorMessage(Fn)}}function formatErrorMessage(Mn,Fn){return typeof Mn>"u"?getError(INTERNAL_ERROR):(typeof Mn=="string"&&(Mn=Object.assign(Object.assign({},getError(SERVER_ERROR)),{message:Mn})),isReservedErrorCode(Mn.code)&&(Mn=getErrorByCode(Mn.code)),Mn)}class e{}let n$2=class extends e{constructor(){super()}},r$1=class extends n$2{constructor(Fn){super()}};const HTTP_REGEX="^https?:",WS_REGEX="^wss?:";function getUrlProtocol(Mn){const Fn=Mn.match(new RegExp(/^\w+:/,"gi"));if(!(!Fn||!Fn.length))return Fn[0]}function matchRegexProtocol(Mn,Fn){const io=getUrlProtocol(Mn);return typeof io>"u"?!1:new RegExp(Fn).test(io)}function isHttpUrl(Mn){return matchRegexProtocol(Mn,HTTP_REGEX)}function isWsUrl(Mn){return matchRegexProtocol(Mn,WS_REGEX)}function isLocalhostUrl(Mn){return new RegExp("wss?://localhost(:d{2,5})?").test(Mn)}function isJsonRpcPayload(Mn){return typeof Mn=="object"&&"id"in Mn&&"jsonrpc"in Mn&&Mn.jsonrpc==="2.0"}function isJsonRpcRequest(Mn){return isJsonRpcPayload(Mn)&&"method"in Mn}function isJsonRpcResponse(Mn){return isJsonRpcPayload(Mn)&&(isJsonRpcResult(Mn)||isJsonRpcError(Mn))}function isJsonRpcResult(Mn){return"result"in Mn}function isJsonRpcError(Mn){return"error"in Mn}let o$1=class extends r$1{constructor(Fn){super(Fn),this.events=new eventsExports.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(Fn),this.connection.connected&&this.registerEventListeners()}async connect(Fn=this.connection){await this.open(Fn)}async disconnect(){await this.close()}on(Fn,io){this.events.on(Fn,io)}once(Fn,io){this.events.once(Fn,io)}off(Fn,io){this.events.off(Fn,io)}removeListener(Fn,io){this.events.removeListener(Fn,io)}async request(Fn,io){return this.requestStrict(formatJsonRpcRequest(Fn.method,Fn.params||[],Fn.id||getBigIntRpcId().toString()),io)}async requestStrict(Fn,io){return new Promise(async(fo,$o)=>{if(!this.connection.connected)try{await this.open()}catch(mo){$o(mo)}this.events.on(`${Fn.id}`,mo=>{isJsonRpcError(mo)?$o(mo.error):fo(mo.result)});try{await this.connection.send(Fn,io)}catch(mo){$o(mo)}})}setConnection(Fn=this.connection){return Fn}onPayload(Fn){this.events.emit("payload",Fn),isJsonRpcResponse(Fn)?this.events.emit(`${Fn.id}`,Fn):this.events.emit("message",{type:Fn.method,data:Fn.params})}onClose(Fn){Fn&&Fn.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${Fn.code} ${Fn.reason?`(${Fn.reason})`:""}`)),this.events.emit("disconnect")}async open(Fn=this.connection){this.connection===Fn&&this.connection.connected||(this.connection.connected&&this.close(),typeof Fn=="string"&&(await this.connection.open(Fn),Fn=this.connection),this.connection=this.setConnection(Fn),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",Fn=>this.onPayload(Fn)),this.connection.on("close",Fn=>this.onClose(Fn)),this.connection.on("error",Fn=>this.events.emit("error",Fn)),this.connection.on("register_error",Fn=>this.onClose()),this.hasRegisteredEventListeners=!0)}};const w$3=()=>typeof WebSocket<"u"?WebSocket:typeof global$o<"u"&&typeof global$o.WebSocket<"u"?global$o.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),b$1=()=>typeof WebSocket<"u"||typeof global$o<"u"&&typeof global$o.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",a=Mn=>Mn.split("?")[0],h=10,S$2=w$3();let f$2=class{constructor(Fn){if(this.url=Fn,this.events=new eventsExports.EventEmitter,this.registering=!1,!isWsUrl(Fn))throw new Error(`Provided URL is not compatible with WebSocket connection: ${Fn}`);this.url=Fn}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(Fn,io){this.events.on(Fn,io)}once(Fn,io){this.events.once(Fn,io)}off(Fn,io){this.events.off(Fn,io)}removeListener(Fn,io){this.events.removeListener(Fn,io)}async open(Fn=this.url){await this.register(Fn)}async close(){return new Promise((Fn,io)=>{if(typeof this.socket>"u"){io(new Error("Connection already closed"));return}this.socket.onclose=fo=>{this.onClose(fo),Fn()},this.socket.close()})}async send(Fn){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(safeJsonStringify(Fn))}catch(io){this.onError(Fn.id,io)}}register(Fn=this.url){if(!isWsUrl(Fn))throw new Error(`Provided URL is not compatible with WebSocket connection: ${Fn}`);if(this.registering){const io=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=io||this.events.listenerCount("open")>=io)&&this.events.setMaxListeners(io+1),new Promise((fo,$o)=>{this.events.once("register_error",mo=>{this.resetMaxListeners(),$o(mo)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return $o(new Error("WebSocket connection is missing or invalid"));fo(this.socket)})})}return this.url=Fn,this.registering=!0,new Promise((io,fo)=>{const $o=new URLSearchParams(Fn).get("origin"),mo=cjs$1.isReactNative()?{headers:{origin:$o}}:{rejectUnauthorized:!isLocalhostUrl(Fn)},Ao=new S$2(Fn,[],mo);b$1()?Ao.onerror=jo=>{const Lo=jo;fo(this.emitError(Lo.error))}:Ao.on("error",jo=>{fo(this.emitError(jo))}),Ao.onopen=()=>{this.onOpen(Ao),io(Ao)}})}onOpen(Fn){Fn.onmessage=io=>this.onPayload(io),Fn.onclose=io=>this.onClose(io),this.socket=Fn,this.registering=!1,this.events.emit("open")}onClose(Fn){this.socket=void 0,this.registering=!1,this.events.emit("close",Fn)}onPayload(Fn){if(typeof Fn.data>"u")return;const io=typeof Fn.data=="string"?safeJsonParse(Fn.data):Fn.data;this.events.emit("payload",io)}onError(Fn,io){const fo=this.parseError(io),$o=fo.message||fo.toString(),mo=formatJsonRpcError(Fn,$o);this.events.emit("payload",mo)}parseError(Fn,io=this.url){return parseConnectionError(Fn,a(io),"WS")}resetMaxListeners(){this.events.getMaxListeners()>h&&this.events.setMaxListeners(h)}emitError(Fn){const io=this.parseError(new Error((Fn==null?void 0:Fn.message)||`WebSocket connection failed for host: ${a(this.url)}`));return this.events.emit("register_error",io),io}};var lodash_isequal={exports:{}};lodash_isequal.exports;(function(Mn,Fn){var io=200,fo="__lodash_hash_undefined__",$o=1,mo=2,Ao=9007199254740991,jo="[object Arguments]",Lo="[object Array]",Ho="[object AsyncFunction]",zo="[object Boolean]",Go="[object Date]",Vo="[object Error]",Yo="[object Function]",Xo="[object GeneratorFunction]",is="[object Map]",yl="[object Number]",us="[object Null]",hs="[object Object]",_l="[object Promise]",xl="[object Proxy]",Il="[object RegExp]",Ol="[object Set]",Tl="[object String]",Cl="[object Symbol]",Nl="[object Undefined]",Wl="[object WeakMap]",Dl="[object ArrayBuffer]",Rl="[object DataView]",Qo="[object Float32Array]",Jo="[object Float64Array]",rs="[object Int8Array]",ps="[object Int16Array]",_c="[object Int32Array]",$l="[object Uint8Array]",El="[object Uint8ClampedArray]",ds="[object Uint16Array]",os="[object Uint32Array]",Al=/[\\^$.*+?()[\]{}|]/g,Ul=/^\[object .+?Constructor\]$/,Zl=/^(?:0|[1-9]\d*)$/,Pl={};Pl[Qo]=Pl[Jo]=Pl[rs]=Pl[ps]=Pl[_c]=Pl[$l]=Pl[El]=Pl[ds]=Pl[os]=!0,Pl[jo]=Pl[Lo]=Pl[Dl]=Pl[zo]=Pl[Rl]=Pl[Go]=Pl[Vo]=Pl[Yo]=Pl[is]=Pl[yl]=Pl[hs]=Pl[Il]=Pl[Ol]=Pl[Tl]=Pl[Wl]=!1;var Hl=typeof commonjsGlobal$c=="object"&&commonjsGlobal$c&&commonjsGlobal$c.Object===Object&&commonjsGlobal$c,Ml=typeof self=="object"&&self&&self.Object===Object&&self,Fl=Hl||Ml||Function("return this")(),Yl=Fn&&!Fn.nodeType&&Fn,Bl=Yl&&!0&&Mn&&!Mn.nodeType&&Mn,Kl=Bl&&Bl.exports===Yl,Gl=Kl&&Hl.process,fu=function(){try{return Gl&&Gl.binding&&Gl.binding("util")}catch{}}(),bu=fu&&fu.isTypedArray;function rp(np,fp){for(var Np=-1,o1=np==null?0:np.length,U1=0,p1=[];++Np<o1;){var W1=np[Np];fp(W1,Np,np)&&(p1[U1++]=W1)}return p1}function tp(np,fp){for(var Np=-1,o1=fp.length,U1=np.length;++Np<o1;)np[U1+Np]=fp[Np];return np}function op(np,fp){for(var Np=-1,o1=np==null?0:np.length;++Np<o1;)if(fp(np[Np],Np,np))return!0;return!1}function vp(np,fp){for(var Np=-1,o1=Array(np);++Np<np;)o1[Np]=fp(Np);return o1}function ip(np){return function(fp){return np(fp)}}function up(np,fp){return np.has(fp)}function $p(np,fp){return np==null?void 0:np[fp]}function gp(np){var fp=-1,Np=Array(np.size);return np.forEach(function(o1,U1){Np[++fp]=[U1,o1]}),Np}function yp(np,fp){return function(Np){return np(fp(Np))}}function _p(np){var fp=-1,Np=Array(np.size);return np.forEach(function(o1){Np[++fp]=o1}),Np}var mp=Array.prototype,wp=Function.prototype,Sp=Object.prototype,bp=Fl["__core-js_shared__"],Ap=wp.toString,Xl=Sp.hasOwnProperty,Vl=function(){var np=/[^.]+$/.exec(bp&&bp.keys&&bp.keys.IE_PROTO||"");return np?"Symbol(src)_1."+np:""}(),Jl=Sp.toString,wu=RegExp("^"+Ap.call(Xl).replace(Al,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ep=Kl?Fl.Buffer:void 0,sp=Fl.Symbol,dp=Fl.Uint8Array,xp=Sp.propertyIsEnumerable,Op=mp.splice,Lp=sp?sp.toStringTag:void 0,Mp=Object.getOwnPropertySymbols,Pp=ep?ep.isBuffer:void 0,a1=yp(Object.keys,Object),Up=N$(Fl,"DataView"),Dp=N$(Fl,"Map"),Jp=N$(Fl,"Promise"),Kp=N$(Fl,"Set"),Bp=N$(Fl,"WeakMap"),Zp=N$(Object,"create"),Hp=fm(Up),Gp=fm(Dp),Qp=fm(Jp),Vp=fm(Kp),Wp=fm(Bp),Xp=sp?sp.prototype:void 0,zp=Xp?Xp.valueOf:void 0;function jp(np){var fp=-1,Np=np==null?0:np.length;for(this.clear();++fp<Np;){var o1=np[fp];this.set(o1[0],o1[1])}}function r1(){this.__data__=Zp?Zp(null):{},this.size=0}function qp(np){var fp=this.has(np)&&delete this.__data__[np];return this.size-=fp?1:0,fp}function e1(np){var fp=this.__data__;if(Zp){var Np=fp[np];return Np===fo?void 0:Np}return Xl.call(fp,np)?fp[np]:void 0}function s1(np){var fp=this.__data__;return Zp?fp[np]!==void 0:Xl.call(fp,np)}function t1(np,fp){var Np=this.__data__;return this.size+=this.has(np)?0:1,Np[np]=Zp&&fp===void 0?fo:fp,this}jp.prototype.clear=r1,jp.prototype.delete=qp,jp.prototype.get=e1,jp.prototype.has=s1,jp.prototype.set=t1;function Yp(np){var fp=-1,Np=np==null?0:np.length;for(this.clear();++fp<Np;){var o1=np[fp];this.set(o1[0],o1[1])}}function f1(){this.__data__=[],this.size=0}function R1(np){var fp=this.__data__,Np=Km(fp,np);if(Np<0)return!1;var o1=fp.length-1;return Np==o1?fp.pop():Op.call(fp,Np,1),--this.size,!0}function O1(np){var fp=this.__data__,Np=Km(fp,np);return Np<0?void 0:fp[Np][1]}function M1(np){return Km(this.__data__,np)>-1}function N1(np,fp){var Np=this.__data__,o1=Km(Np,np);return o1<0?(++this.size,Np.push([np,fp])):Np[o1][1]=fp,this}Yp.prototype.clear=f1,Yp.prototype.delete=R1,Yp.prototype.get=O1,Yp.prototype.has=M1,Yp.prototype.set=N1;function E1(np){var fp=-1,Np=np==null?0:np.length;for(this.clear();++fp<Np;){var o1=np[fp];this.set(o1[0],o1[1])}}function q1(){this.size=0,this.__data__={hash:new jp,map:new(Dp||Yp),string:new jp}}function i$(np){var fp=Am(this,np).delete(np);return this.size-=fp?1:0,fp}function Y1(np){return Am(this,np).get(np)}function a$(np){return Am(this,np).has(np)}function s$(np,fp){var Np=Am(this,np),o1=Np.size;return Np.set(np,fp),this.size+=Np.size==o1?0:1,this}E1.prototype.clear=q1,E1.prototype.delete=i$,E1.prototype.get=Y1,E1.prototype.has=a$,E1.prototype.set=s$;function Z1(np){var fp=-1,Np=np==null?0:np.length;for(this.__data__=new E1;++fp<Np;)this.add(np[fp])}function t$(np){return this.__data__.set(np,fo),this}function r$(np){return this.__data__.has(np)}Z1.prototype.add=Z1.prototype.push=t$,Z1.prototype.has=r$;function D1(np){var fp=this.__data__=new Yp(np);this.size=fp.size}function c$(){this.__data__=new Yp,this.size=0}function l$(np){var fp=this.__data__,Np=fp.delete(np);return this.size=fp.size,Np}function u$(np){return this.__data__.get(np)}function E$(np){return this.__data__.has(np)}function _m(np,fp){var Np=this.__data__;if(Np instanceof Yp){var o1=Np.__data__;if(!Dp||o1.length<io-1)return o1.push([np,fp]),this.size=++Np.size,this;Np=this.__data__=new E1(o1)}return Np.set(np,fp),this.size=Np.size,this}D1.prototype.clear=c$,D1.prototype.delete=l$,D1.prototype.get=u$,D1.prototype.has=E$,D1.prototype.set=_m;function Xy(np,fp){var Np=cy(np),o1=!Np&&Dv(np),U1=!Np&&!o1&&Ny(np),p1=!Np&&!o1&&!U1&&Uv(np),W1=Np||o1||U1||p1,n$=W1?vp(np.length,String):[],A1=n$.length;for(var F1 in np)Xl.call(np,F1)&&!(W1&&(F1=="length"||U1&&(F1=="offset"||F1=="parent")||p1&&(F1=="buffer"||F1=="byteLength"||F1=="byteOffset")||Ov(F1,A1)))&&n$.push(F1);return n$}function Km(np,fp){for(var Np=np.length;Np--;)if(jv(np[Np][0],fp))return Np;return-1}function Oy(np,fp,Np){var o1=fp(np);return cy(np)?o1:tp(o1,Np(np))}function Wm(np){return np==null?np===void 0?Nl:us:Lp&&Lp in Object(np)?Tv(np):Tw(np)}function My(np){return Hm(np)&&Wm(np)==jo}function zm(np,fp,Np,o1,U1){return np===fp?!0:np==null||fp==null||!Hm(np)&&!Hm(fp)?np!==np&&fp!==fp:$v(np,fp,Np,o1,zm,U1)}function $v(np,fp,Np,o1,U1,p1){var W1=cy(np),n$=cy(fp),A1=W1?Lo:nm(np),F1=n$?Lo:nm(fp);A1=A1==jo?hs:A1,F1=F1==jo?hs:F1;var X1=A1==hs,T$=F1==hs,o$=A1==F1;if(o$&&Ny(np)){if(!Ny(fp))return!1;W1=!0,X1=!1}if(o$&&!X1)return p1||(p1=new D1),W1||Uv(np)?ay(np,fp,Np,o1,U1,p1):Iw(np,fp,A1,Np,o1,U1,p1);if(!(Np&$o)){var z1=X1&&Xl.call(np,"__wrapped__"),_$=T$&&Xl.call(fp,"__wrapped__");if(z1||_$){var Z$=z1?np.value():np,F$=_$?fp.value():fp;return p1||(p1=new D1),U1(Z$,F$,Np,o1,p1)}}return o$?(p1||(p1=new D1),Sv(np,fp,Np,o1,U1,p1)):!1}function Cw(np){if(!Lv(np)||Nv(np))return!1;var fp=ly(np)?wu:Ul;return fp.test(fm(np))}function yv(np){return Hm(np)&&Bv(np.length)&&!!Pl[Wm(np)]}function bv(np){if(!kv(np))return a1(np);var fp=[];for(var Np in Object(np))Xl.call(np,Np)&&Np!="constructor"&&fp.push(Np);return fp}function ay(np,fp,Np,o1,U1,p1){var W1=Np&$o,n$=np.length,A1=fp.length;if(n$!=A1&&!(W1&&A1>n$))return!1;var F1=p1.get(np);if(F1&&p1.get(fp))return F1==fp;var X1=-1,T$=!0,o$=Np&mo?new Z1:void 0;for(p1.set(np,fp),p1.set(fp,np);++X1<n$;){var z1=np[X1],_$=fp[X1];if(o1)var Z$=W1?o1(_$,z1,X1,fp,np,p1):o1(z1,_$,X1,np,fp,p1);if(Z$!==void 0){if(Z$)continue;T$=!1;break}if(o$){if(!op(fp,function(F$,om){if(!up(o$,om)&&(z1===F$||U1(z1,F$,Np,o1,p1)))return o$.push(om)})){T$=!1;break}}else if(!(z1===_$||U1(z1,_$,Np,o1,p1))){T$=!1;break}}return p1.delete(np),p1.delete(fp),T$}function Iw(np,fp,Np,o1,U1,p1,W1){switch(Np){case Rl:if(np.byteLength!=fp.byteLength||np.byteOffset!=fp.byteOffset)return!1;np=np.buffer,fp=fp.buffer;case Dl:return!(np.byteLength!=fp.byteLength||!p1(new dp(np),new dp(fp)));case zo:case Go:case yl:return jv(+np,+fp);case Vo:return np.name==fp.name&&np.message==fp.message;case Il:case Tl:return np==fp+"";case is:var n$=gp;case Ol:var A1=o1&$o;if(n$||(n$=_p),np.size!=fp.size&&!A1)return!1;var F1=W1.get(np);if(F1)return F1==fp;o1|=mo,W1.set(np,fp);var X1=ay(n$(np),n$(fp),o1,U1,p1,W1);return W1.delete(np),X1;case Cl:if(zp)return zp.call(np)==zp.call(fp)}return!1}function Sv(np,fp,Np,o1,U1,p1){var W1=Np&$o,n$=sy(np),A1=n$.length,F1=sy(fp),X1=F1.length;if(A1!=X1&&!W1)return!1;for(var T$=A1;T$--;){var o$=n$[T$];if(!(W1?o$ in fp:Xl.call(fp,o$)))return!1}var z1=p1.get(np);if(z1&&p1.get(fp))return z1==fp;var _$=!0;p1.set(np,fp),p1.set(fp,np);for(var Z$=W1;++T$<A1;){o$=n$[T$];var F$=np[o$],om=fp[o$];if(o1)var ky=W1?o1(om,F$,o$,fp,np,p1):o1(F$,om,o$,np,fp,p1);if(!(ky===void 0?F$===om||U1(F$,om,Np,o1,p1):ky)){_$=!1;break}Z$||(Z$=o$=="constructor")}if(_$&&!Z$){var Gm=np.constructor,$$=fp.constructor;Gm!=$$&&"constructor"in np&&"constructor"in fp&&!(typeof Gm=="function"&&Gm instanceof Gm&&typeof $$=="function"&&$$ instanceof $$)&&(_$=!1)}return p1.delete(np),p1.delete(fp),_$}function sy(np){return Oy(np,Ow,Rv)}function Am(np,fp){var Np=np.__data__;return Mv(fp)?Np[typeof fp=="string"?"string":"hash"]:Np.map}function N$(np,fp){var Np=$p(np,fp);return Cw(Np)?Np:void 0}function Tv(np){var fp=Xl.call(np,Lp),Np=np[Lp];try{np[Lp]=void 0;var o1=!0}catch{}var U1=Jl.call(np);return o1&&(fp?np[Lp]=Np:delete np[Lp]),U1}var Rv=Mp?function(np){return np==null?[]:(np=Object(np),rp(Mp(np),function(fp){return xp.call(np,fp)}))}:B1,nm=Wm;(Up&&nm(new Up(new ArrayBuffer(1)))!=Rl||Dp&&nm(new Dp)!=is||Jp&&nm(Jp.resolve())!=_l||Kp&&nm(new Kp)!=Ol||Bp&&nm(new Bp)!=Wl)&&(nm=function(np){var fp=Wm(np),Np=fp==hs?np.constructor:void 0,o1=Np?fm(Np):"";if(o1)switch(o1){case Hp:return Rl;case Gp:return is;case Qp:return _l;case Vp:return Ol;case Wp:return Wl}return fp});function Ov(np,fp){return fp=fp??Ao,!!fp&&(typeof np=="number"||Zl.test(np))&&np>-1&&np%1==0&&np<fp}function Mv(np){var fp=typeof np;return fp=="string"||fp=="number"||fp=="symbol"||fp=="boolean"?np!=="__proto__":np===null}function Nv(np){return!!Vl&&Vl in np}function kv(np){var fp=np&&np.constructor,Np=typeof fp=="function"&&fp.prototype||Sp;return np===Np}function Tw(np){return Jl.call(np)}function fm(np){if(np!=null){try{return Ap.call(np)}catch{}try{return np+""}catch{}}return""}function jv(np,fp){return np===fp||np!==np&&fp!==fp}var Dv=My(function(){return arguments}())?My:function(np){return Hm(np)&&Xl.call(np,"callee")&&!xp.call(np,"callee")},cy=Array.isArray;function Pw(np){return np!=null&&Bv(np.length)&&!ly(np)}var Ny=Pp||j1;function Rw(np,fp){return zm(np,fp)}function ly(np){if(!Lv(np))return!1;var fp=Wm(np);return fp==Yo||fp==Xo||fp==Ho||fp==xl}function Bv(np){return typeof np=="number"&&np>-1&&np%1==0&&np<=Ao}function Lv(np){var fp=typeof np;return np!=null&&(fp=="object"||fp=="function")}function Hm(np){return np!=null&&typeof np=="object"}var Uv=bu?ip(bu):yv;function Ow(np){return Pw(np)?Xy(np):bv(np)}function B1(){return[]}function j1(){return!1}Mn.exports=Rw})(lodash_isequal,lodash_isequal.exports);var lodash_isequalExports=lodash_isequal.exports;const bs=getDefaultExportFromCjs$1(lodash_isequalExports),be$3="wc",fe$2=2,ne$2="core",O$4=`${be$3}@2:${ne$2}:`,Xe$2={name:ne$2,logger:"error"},Ze$2={database:":memory:"},Qe$1="crypto",_e$1="client_ed25519_seed",et=cjs$4.ONE_DAY,tt="keychain",it$1="0.3",st$1="messages",rt$1="0.3",nt$1=cjs$4.SIX_HOURS,ot$1="publisher",at$1="irn",ct$1="error",Ee$1="wss://relay.walletconnect.org",ht$1="relayer",w$2={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},lt$5="_subscription",T$4={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},ut$2=.1,oe$3="2.17.0",F$2={link_mode:"link_mode",relay:"relay"},dt$1="0.3",gt$6="WALLETCONNECT_CLIENT_ID",ve$1="WALLETCONNECT_LINK_MODE_APPS",A$2={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},pt$1="subscription",yt$1="0.3",Dt$1=cjs$4.FIVE_SECONDS*1e3,mt="pairing",bt="0.3",j$6={wc_pairingDelete:{req:{ttl:cjs$4.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:cjs$4.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:cjs$4.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:cjs$4.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:cjs$4.ONE_DAY,prompt:!1,tag:0},res:{ttl:cjs$4.ONE_DAY,prompt:!1,tag:0}}},q$3={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},P$3={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},ft="history",_t="0.3",Et="expirer",R$3={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},vt="0.3",wt="verify-api",Is$2="https://verify.walletconnect.com",It="https://verify.walletconnect.org",Z$1=It,Tt$2=`${Z$1}/v3`,Ct=[Is$2,It],St="echo",Pt="https://echo.walletconnect.com",z$4={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},M$3={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},Cs={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Ss$1={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Ps$1={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Rs$1={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},Rt=.1,xt="event-client",Ot$1=86400,At="https://pulse.walletconnect.org/batch";function xs(Mn,Fn){if(Mn.length>=255)throw new TypeError("Alphabet too long");for(var io=new Uint8Array(256),fo=0;fo<io.length;fo++)io[fo]=255;for(var $o=0;$o<Mn.length;$o++){var mo=Mn.charAt($o),Ao=mo.charCodeAt(0);if(io[Ao]!==255)throw new TypeError(mo+" is ambiguous");io[Ao]=$o}var jo=Mn.length,Lo=Mn.charAt(0),Ho=Math.log(jo)/Math.log(256),zo=Math.log(256)/Math.log(jo);function Go(Xo){if(Xo instanceof Uint8Array||(ArrayBuffer.isView(Xo)?Xo=new Uint8Array(Xo.buffer,Xo.byteOffset,Xo.byteLength):Array.isArray(Xo)&&(Xo=Uint8Array.from(Xo))),!(Xo instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(Xo.length===0)return"";for(var is=0,yl=0,us=0,hs=Xo.length;us!==hs&&Xo[us]===0;)us++,is++;for(var _l=(hs-us)*zo+1>>>0,xl=new Uint8Array(_l);us!==hs;){for(var Il=Xo[us],Ol=0,Tl=_l-1;(Il!==0||Ol<yl)&&Tl!==-1;Tl--,Ol++)Il+=256*xl[Tl]>>>0,xl[Tl]=Il%jo>>>0,Il=Il/jo>>>0;if(Il!==0)throw new Error("Non-zero carry");yl=Ol,us++}for(var Cl=_l-yl;Cl!==_l&&xl[Cl]===0;)Cl++;for(var Nl=Lo.repeat(is);Cl<_l;++Cl)Nl+=Mn.charAt(xl[Cl]);return Nl}function Vo(Xo){if(typeof Xo!="string")throw new TypeError("Expected String");if(Xo.length===0)return new Uint8Array;var is=0;if(Xo[is]!==" "){for(var yl=0,us=0;Xo[is]===Lo;)yl++,is++;for(var hs=(Xo.length-is)*Ho+1>>>0,_l=new Uint8Array(hs);Xo[is];){var xl=io[Xo.charCodeAt(is)];if(xl===255)return;for(var Il=0,Ol=hs-1;(xl!==0||Il<us)&&Ol!==-1;Ol--,Il++)xl+=jo*_l[Ol]>>>0,_l[Ol]=xl%256>>>0,xl=xl/256>>>0;if(xl!==0)throw new Error("Non-zero carry");us=Il,is++}if(Xo[is]!==" "){for(var Tl=hs-us;Tl!==hs&&_l[Tl]===0;)Tl++;for(var Cl=new Uint8Array(yl+(hs-Tl)),Nl=yl;Tl!==hs;)Cl[Nl++]=_l[Tl++];return Cl}}}function Yo(Xo){var is=Vo(Xo);if(is)return is;throw new Error(`Non-${Fn} character`)}return{encode:Go,decodeUnsafe:Vo,decode:Yo}}var Os=xs,As=Os;const Nt=Mn=>{if(Mn instanceof Uint8Array&&Mn.constructor.name==="Uint8Array")return Mn;if(Mn instanceof ArrayBuffer)return new Uint8Array(Mn);if(ArrayBuffer.isView(Mn))return new Uint8Array(Mn.buffer,Mn.byteOffset,Mn.byteLength);throw new Error("Unknown type, must be binary type")},Ns$1=Mn=>new TextEncoder().encode(Mn),Ls$1=Mn=>new TextDecoder().decode(Mn);let zs$1=class{constructor(Fn,io,fo){this.name=Fn,this.prefix=io,this.baseEncode=fo}encode(Fn){if(Fn instanceof Uint8Array)return`${this.prefix}${this.baseEncode(Fn)}`;throw Error("Unknown type, must be binary type")}},ks$1=class{constructor(Fn,io,fo){if(this.name=Fn,this.prefix=io,io.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=io.codePointAt(0),this.baseDecode=fo}decode(Fn){if(typeof Fn=="string"){if(Fn.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(Fn)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(Fn.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(Fn){return Lt$1(this,Fn)}};class Ms{constructor(Fn){this.decoders=Fn}or(Fn){return Lt$1(this,Fn)}decode(Fn){const io=Fn[0],fo=this.decoders[io];if(fo)return fo.decode(Fn);throw RangeError(`Unable to decode multibase string ${JSON.stringify(Fn)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Lt$1=(Mn,Fn)=>new Ms({...Mn.decoders||{[Mn.prefix]:Mn},...Fn.decoders||{[Fn.prefix]:Fn}});let $s$1=class{constructor(Fn,io,fo,$o){this.name=Fn,this.prefix=io,this.baseEncode=fo,this.baseDecode=$o,this.encoder=new zs$1(Fn,io,fo),this.decoder=new ks$1(Fn,io,$o)}encode(Fn){return this.encoder.encode(Fn)}decode(Fn){return this.decoder.decode(Fn)}};const ae$3=({name:Mn,prefix:Fn,encode:io,decode:fo})=>new $s$1(Mn,Fn,io,fo),Q$4=({prefix:Mn,name:Fn,alphabet:io})=>{const{encode:fo,decode:$o}=As(io,Fn);return ae$3({prefix:Mn,name:Fn,encode:fo,decode:mo=>Nt($o(mo))})},Fs$1=(Mn,Fn,io,fo)=>{const $o={};for(let zo=0;zo<Fn.length;++zo)$o[Fn[zo]]=zo;let mo=Mn.length;for(;Mn[mo-1]==="=";)--mo;const Ao=new Uint8Array(mo*io/8|0);let jo=0,Lo=0,Ho=0;for(let zo=0;zo<mo;++zo){const Go=$o[Mn[zo]];if(Go===void 0)throw new SyntaxError(`Non-${fo} character`);Lo=Lo<<io|Go,jo+=io,jo>=8&&(jo-=8,Ao[Ho++]=255&Lo>>jo)}if(jo>=io||255&Lo<<8-jo)throw new SyntaxError("Unexpected end of data");return Ao},Us=(Mn,Fn,io)=>{const fo=Fn[Fn.length-1]==="=",$o=(1<<io)-1;let mo="",Ao=0,jo=0;for(let Lo=0;Lo<Mn.length;++Lo)for(jo=jo<<8|Mn[Lo],Ao+=8;Ao>io;)Ao-=io,mo+=Fn[$o&jo>>Ao];if(Ao&&(mo+=Fn[$o&jo<<io-Ao]),fo)for(;mo.length*io&7;)mo+="=";return mo},_=({name:Mn,prefix:Fn,bitsPerChar:io,alphabet:fo})=>ae$3({prefix:Fn,name:Mn,encode($o){return Us($o,fo,io)},decode($o){return Fs$1($o,fo,io,Mn)}}),Ks=ae$3({prefix:"\0",name:"identity",encode:Mn=>Ls$1(Mn),decode:Mn=>Ns$1(Mn)});var Bs=Object.freeze({__proto__:null,identity:Ks});const Vs$1=_({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var js$1=Object.freeze({__proto__:null,base2:Vs$1});const qs$1=_({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Gs$1=Object.freeze({__proto__:null,base8:qs$1});const Hs=Q$4({prefix:"9",name:"base10",alphabet:"0123456789"});var Ys$1=Object.freeze({__proto__:null,base10:Hs});const Js$1=_({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ws$1=_({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Xs$1=Object.freeze({__proto__:null,base16:Js$1,base16upper:Ws$1});const Zs$1=_({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Qs$1=_({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),er=_({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),tr=_({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),ir$1=_({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),sr$2=_({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),rr=_({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),nr$1=_({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),or$1=_({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ar$2=Object.freeze({__proto__:null,base32:Zs$1,base32upper:Qs$1,base32pad:er,base32padupper:tr,base32hex:ir$1,base32hexupper:sr$2,base32hexpad:rr,base32hexpadupper:nr$1,base32z:or$1});const cr$1=Q$4({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),hr$2=Q$4({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var lr$2=Object.freeze({__proto__:null,base36:cr$1,base36upper:hr$2});const ur$1=Q$4({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),dr$1=Q$4({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var gr=Object.freeze({__proto__:null,base58btc:ur$1,base58flickr:dr$1});const pr$1=_({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),yr=_({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Dr$1=_({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mr$1=_({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var br$1=Object.freeze({__proto__:null,base64:pr$1,base64pad:yr,base64url:Dr$1,base64urlpad:mr$1});const zt$1=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),fr$1=zt$1.reduce((Mn,Fn,io)=>(Mn[io]=Fn,Mn),[]),_r=zt$1.reduce((Mn,Fn,io)=>(Mn[Fn.codePointAt(0)]=io,Mn),[]);function Er$1(Mn){return Mn.reduce((Fn,io)=>(Fn+=fr$1[io],Fn),"")}function vr$1(Mn){const Fn=[];for(const io of Mn){const fo=_r[io.codePointAt(0)];if(fo===void 0)throw new Error(`Non-base256emoji character: ${io}`);Fn.push(fo)}return new Uint8Array(Fn)}const wr=ae$3({prefix:"🚀",name:"base256emoji",encode:Er$1,decode:vr$1});var Ir=Object.freeze({__proto__:null,base256emoji:wr}),Tr$1=Mt,kt$1=128,Cr=127,Sr=~Cr,Pr=Math.pow(2,31);function Mt(Mn,Fn,io){Fn=Fn||[],io=io||0;for(var fo=io;Mn>=Pr;)Fn[io++]=Mn&255|kt$1,Mn/=128;for(;Mn&Sr;)Fn[io++]=Mn&255|kt$1,Mn>>>=7;return Fn[io]=Mn|0,Mt.bytes=io-fo+1,Fn}var Rr$1=we$3,xr$1=128,$t$1=127;function we$3(Mn,fo){var io=0,fo=fo||0,$o=0,mo=fo,Ao,jo=Mn.length;do{if(mo>=jo)throw we$3.bytes=0,new RangeError("Could not decode varint");Ao=Mn[mo++],io+=$o<28?(Ao&$t$1)<<$o:(Ao&$t$1)*Math.pow(2,$o),$o+=7}while(Ao>=xr$1);return we$3.bytes=mo-fo,io}var Or=Math.pow(2,7),Ar$1=Math.pow(2,14),Nr=Math.pow(2,21),Lr$1=Math.pow(2,28),zr$1=Math.pow(2,35),kr$1=Math.pow(2,42),Mr$1=Math.pow(2,49),$r=Math.pow(2,56),Fr$1=Math.pow(2,63),Ur$1=function(Mn){return Mn<Or?1:Mn<Ar$1?2:Mn<Nr?3:Mn<Lr$1?4:Mn<zr$1?5:Mn<kr$1?6:Mn<Mr$1?7:Mn<$r?8:Mn<Fr$1?9:10},Kr$1={encode:Tr$1,decode:Rr$1,encodingLength:Ur$1},Ft$1=Kr$1;const Ut$1=(Mn,Fn,io=0)=>(Ft$1.encode(Mn,Fn,io),Fn),Kt$1=Mn=>Ft$1.encodingLength(Mn),Ie$1=(Mn,Fn)=>{const io=Fn.byteLength,fo=Kt$1(Mn),$o=fo+Kt$1(io),mo=new Uint8Array($o+io);return Ut$1(Mn,mo,0),Ut$1(io,mo,fo),mo.set(Fn,$o),new Br(Mn,io,Fn,mo)};class Br{constructor(Fn,io,fo,$o){this.code=Fn,this.size=io,this.digest=fo,this.bytes=$o}}const Bt=({name:Mn,code:Fn,encode:io})=>new Vr(Mn,Fn,io);class Vr{constructor(Fn,io,fo){this.name=Fn,this.code=io,this.encode=fo}digest(Fn){if(Fn instanceof Uint8Array){const io=this.encode(Fn);return io instanceof Uint8Array?Ie$1(this.code,io):io.then(fo=>Ie$1(this.code,fo))}else throw Error("Unknown type, must be binary type")}}const Vt=Mn=>async Fn=>new Uint8Array(await crypto.subtle.digest(Mn,Fn)),jr$1=Bt({name:"sha2-256",code:18,encode:Vt("SHA-256")}),qr$1=Bt({name:"sha2-512",code:19,encode:Vt("SHA-512")});var Gr$1=Object.freeze({__proto__:null,sha256:jr$1,sha512:qr$1});const jt$1=0,Hr$1="identity",qt=Nt,Yr=Mn=>Ie$1(jt$1,qt(Mn)),Jr$1={code:jt$1,name:Hr$1,encode:qt,digest:Yr};var Wr=Object.freeze({__proto__:null,identity:Jr$1});new TextEncoder,new TextDecoder;const Gt$1={...Bs,...js$1,...Gs$1,...Ys$1,...Xs$1,...ar$2,...lr$2,...gr,...br$1,...Ir};({...Gr$1,...Wr});function Xr(Mn=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(Mn):new Uint8Array(Mn)}function Ht$1(Mn,Fn,io,fo){return{name:Mn,prefix:Fn,encoder:{name:Mn,prefix:Fn,encode:io},decoder:{decode:fo}}}const Yt=Ht$1("utf8","u",Mn=>"u"+new TextDecoder("utf8").decode(Mn),Mn=>new TextEncoder().encode(Mn.substring(1))),Te$1=Ht$1("ascii","a",Mn=>{let Fn="a";for(let io=0;io<Mn.length;io++)Fn+=String.fromCharCode(Mn[io]);return Fn},Mn=>{Mn=Mn.substring(1);const Fn=Xr(Mn.length);for(let io=0;io<Mn.length;io++)Fn[io]=Mn.charCodeAt(io);return Fn}),Zr={utf8:Yt,"utf-8":Yt,hex:Gt$1.base16,latin1:Te$1,ascii:Te$1,binary:Te$1,...Gt$1};function Qr$1(Mn,Fn="utf8"){const io=Zr[Fn];if(!io)throw new Error(`Unsupported encoding "${Fn}"`);return(Fn==="utf8"||Fn==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(Mn,"utf8"):io.decoder.decode(`${io.prefix}${Mn}`)}let Jt$1=class{constructor(Fn,io){this.core=Fn,this.logger=io,this.keychain=new Map,this.name=tt,this.version=it$1,this.initialized=!1,this.storagePrefix=O$4,this.init=async()=>{if(!this.initialized){const fo=await this.getKeyChain();typeof fo<"u"&&(this.keychain=fo),this.initialized=!0}},this.has=fo=>(this.isInitialized(),this.keychain.has(fo)),this.set=async(fo,$o)=>{this.isInitialized(),this.keychain.set(fo,$o),await this.persist()},this.get=fo=>{this.isInitialized();const $o=this.keychain.get(fo);if(typeof $o>"u"){const{message:mo}=xe$2("NO_MATCHING_KEY",`${this.name}: ${fo}`);throw new Error(mo)}return $o},this.del=async fo=>{this.isInitialized(),this.keychain.delete(fo),await this.persist()},this.core=Fn,this.logger=E$6(io,this.name)}get context(){return y$7(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(Fn){await this.core.storage.setItem(this.storageKey,cs(Fn))}async getKeyChain(){const Fn=await this.core.storage.getItem(this.storageKey);return typeof Fn<"u"?ls(Fn):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:Fn}=xe$2("NOT_INITIALIZED",this.name);throw new Error(Fn)}}};class Wt{constructor(Fn,io,fo){this.core=Fn,this.logger=io,this.name=Qe$1,this.randomSessionIdentifier=Bu(),this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=$o=>(this.isInitialized(),this.keychain.has($o)),this.getClientId=async()=>{this.isInitialized();const $o=await this.getClientSeed(),mo=generateKeyPair($o);return encodeIss(mo.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const $o=_u();return this.setPrivateKey($o.publicKey,$o.privateKey)},this.signJWT=async $o=>{this.isInitialized();const mo=await this.getClientSeed(),Ao=generateKeyPair(mo),jo=this.randomSessionIdentifier;return await signJWT(jo,$o,et,Ao)},this.generateSharedKey=($o,mo,Ao)=>{this.isInitialized();const jo=this.getPrivateKey($o),Lo=Cu(jo,mo);return this.setSymKey(Lo,Ao)},this.setSymKey=async($o,mo)=>{this.isInitialized();const Ao=mo||Ru($o);return await this.keychain.set(Ao,$o),Ao},this.deleteKeyPair=async $o=>{this.isInitialized(),await this.keychain.del($o)},this.deleteSymKey=async $o=>{this.isInitialized(),await this.keychain.del($o)},this.encode=async($o,mo,Ao)=>{this.isInitialized();const jo=so(Ao),Lo=safeJsonStringify(mo);if(qu(jo))return Tu(Lo,Ao==null?void 0:Ao.encoding);if(ku(jo)){const Vo=jo.senderPublicKey,Yo=jo.receiverPublicKey;$o=await this.generateSharedKey(Vo,Yo)}const Ho=this.getSymKey($o),{type:zo,senderPublicKey:Go}=jo;return Pu({type:zo,symKey:Ho,message:Lo,senderPublicKey:Go,encoding:Ao==null?void 0:Ao.encoding})},this.decode=async($o,mo,Ao)=>{this.isInitialized();const jo=Uu(mo,Ao);if(qu(jo)){const Lo=Fu(mo,Ao==null?void 0:Ao.encoding);return safeJsonParse(Lo)}if(ku(jo)){const Lo=jo.receiverPublicKey,Ho=jo.senderPublicKey;$o=await this.generateSharedKey(Lo,Ho)}try{const Lo=this.getSymKey($o),Ho=Du({symKey:Lo,encoded:mo,encoding:Ao==null?void 0:Ao.encoding});return safeJsonParse(Ho)}catch(Lo){this.logger.error(`Failed to decode message from topic: '${$o}', clientId: '${await this.getClientId()}'`),this.logger.error(Lo)}},this.getPayloadType=($o,mo=tn$1)=>{const Ao=Wr$1({encoded:$o,encoding:mo});return Ze$3(Ao.type)},this.getPayloadSenderPublicKey=($o,mo=tn$1)=>{const Ao=Wr$1({encoded:$o,encoding:mo});return Ao.senderPublicKey?toString$b(Ao.senderPublicKey,Lt$2):void 0},this.core=Fn,this.logger=E$6(io,this.name),this.keychain=fo||new Jt$1(this.core,this.logger)}get context(){return y$7(this.logger)}async setPrivateKey(Fn,io){return await this.keychain.set(Fn,io),Fn}getPrivateKey(Fn){return this.keychain.get(Fn)}async getClientSeed(){let Fn="";try{Fn=this.keychain.get(_e$1)}catch{Fn=Bu(),await this.keychain.set(_e$1,Fn)}return Qr$1(Fn,"base16")}getSymKey(Fn){return this.keychain.get(Fn)}isInitialized(){if(!this.initialized){const{message:Fn}=xe$2("NOT_INITIALIZED",this.name);throw new Error(Fn)}}}class Xt extends a$1{constructor(Fn,io){super(Fn,io),this.logger=Fn,this.core=io,this.messages=new Map,this.name=st$1,this.version=rt$1,this.initialized=!1,this.storagePrefix=O$4,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const fo=await this.getRelayerMessages();typeof fo<"u"&&(this.messages=fo),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(fo){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(fo)}finally{this.initialized=!0}}},this.set=async(fo,$o)=>{this.isInitialized();const mo=Ou($o);let Ao=this.messages.get(fo);return typeof Ao>"u"&&(Ao={}),typeof Ao[mo]<"u"||(Ao[mo]=$o,this.messages.set(fo,Ao),await this.persist()),mo},this.get=fo=>{this.isInitialized();let $o=this.messages.get(fo);return typeof $o>"u"&&($o={}),$o},this.has=(fo,$o)=>{this.isInitialized();const mo=this.get(fo),Ao=Ou($o);return typeof mo[Ao]<"u"},this.del=async fo=>{this.isInitialized(),this.messages.delete(fo),await this.persist()},this.logger=E$6(Fn,this.name),this.core=io}get context(){return y$7(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(Fn){await this.core.storage.setItem(this.storageKey,cs(Fn))}async getRelayerMessages(){const Fn=await this.core.storage.getItem(this.storageKey);return typeof Fn<"u"?ls(Fn):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:Fn}=xe$2("NOT_INITIALIZED",this.name);throw new Error(Fn)}}}let en$1=class extends g$2{constructor(Fn,io){super(Fn,io),this.relayer=Fn,this.logger=io,this.events=new eventsExports.EventEmitter,this.name=ot$1,this.queue=new Map,this.publishTimeout=cjs$4.toMiliseconds(cjs$4.ONE_MINUTE),this.failedPublishTimeout=cjs$4.toMiliseconds(cjs$4.ONE_SECOND),this.needsTransportRestart=!1,this.publish=async(fo,$o,mo)=>{var Ao;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:fo,message:$o,opts:mo}});const jo=(mo==null?void 0:mo.ttl)||nt$1,Lo=zu(mo),Ho=(mo==null?void 0:mo.prompt)||!1,zo=(mo==null?void 0:mo.tag)||0,Go=(mo==null?void 0:mo.id)||getBigIntRpcId().toString(),Vo={topic:fo,message:$o,opts:{ttl:jo,relay:Lo,prompt:Ho,tag:zo,id:Go,attestation:mo==null?void 0:mo.attestation}},Yo=`Failed to publish payload, please try again. id:${Go} tag:${zo}`,Xo=Date.now();let is,yl=1;try{for(;is===void 0;){if(Date.now()-Xo>this.publishTimeout)throw new Error(Yo);this.logger.trace({id:Go,attempts:yl},`publisher.publish - attempt ${yl}`),is=await await ms$1(this.rpcPublish(fo,$o,jo,Lo,Ho,zo,Go,mo==null?void 0:mo.attestation).catch(us=>this.logger.warn(us)),this.publishTimeout,Yo),yl++,is||await new Promise(us=>setTimeout(us,this.failedPublishTimeout))}this.relayer.events.emit(w$2.publish,Vo),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:Go,topic:fo,message:$o,opts:mo}})}catch(us){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(us),(Ao=mo==null?void 0:mo.internal)!=null&&Ao.throwOnFailedPublish)throw us;this.queue.set(Go,Vo)}},this.on=(fo,$o)=>{this.events.on(fo,$o)},this.once=(fo,$o)=>{this.events.once(fo,$o)},this.off=(fo,$o)=>{this.events.off(fo,$o)},this.removeListener=(fo,$o)=>{this.events.removeListener(fo,$o)},this.relayer=Fn,this.logger=E$6(io,this.name),this.registerEventListeners()}get context(){return y$7(this.logger)}rpcPublish(Fn,io,fo,$o,mo,Ao,jo,Lo){var Ho,zo,Go,Vo;const Yo={method:ju($o.protocol).publish,params:{topic:Fn,message:io,ttl:fo,prompt:mo,tag:Ao,attestation:Lo},id:jo};return Pe$1((Ho=Yo.params)==null?void 0:Ho.prompt)&&((zo=Yo.params)==null||delete zo.prompt),Pe$1((Go=Yo.params)==null?void 0:Go.tag)&&((Vo=Yo.params)==null||delete Vo.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:Yo}),this.relayer.request(Yo)}removeRequestFromQueue(Fn){this.queue.delete(Fn)}checkQueue(){this.queue.forEach(async Fn=>{const{topic:io,message:fo,opts:$o}=Fn;await this.publish(io,fo,$o)})}registerEventListeners(){this.relayer.core.heartbeat.on(r$2.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(w$2.connection_stalled);return}this.checkQueue()}),this.relayer.on(w$2.message_ack,Fn=>{this.removeRequestFromQueue(Fn.id.toString())})}};class tn{constructor(){this.map=new Map,this.set=(Fn,io)=>{const fo=this.get(Fn);this.exists(Fn,io)||this.map.set(Fn,[...fo,io])},this.get=Fn=>this.map.get(Fn)||[],this.exists=(Fn,io)=>this.get(Fn).includes(io),this.delete=(Fn,io)=>{if(typeof io>"u"){this.map.delete(Fn);return}if(!this.map.has(Fn))return;const fo=this.get(Fn);if(!this.exists(Fn,io))return;const $o=fo.filter(mo=>mo!==io);if(!$o.length){this.map.delete(Fn);return}this.map.set(Fn,$o)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var sn=Object.defineProperty,rn=Object.defineProperties,nn=Object.getOwnPropertyDescriptors,Zt$1=Object.getOwnPropertySymbols,on=Object.prototype.hasOwnProperty,an=Object.prototype.propertyIsEnumerable,Qt=(Mn,Fn,io)=>Fn in Mn?sn(Mn,Fn,{enumerable:!0,configurable:!0,writable:!0,value:io}):Mn[Fn]=io,ee$2=(Mn,Fn)=>{for(var io in Fn||(Fn={}))on.call(Fn,io)&&Qt(Mn,io,Fn[io]);if(Zt$1)for(var io of Zt$1(Fn))an.call(Fn,io)&&Qt(Mn,io,Fn[io]);return Mn},Ce$3=(Mn,Fn)=>rn(Mn,nn(Fn));let ei$1=class extends d$1{constructor(Fn,io){super(Fn,io),this.relayer=Fn,this.logger=io,this.subscriptions=new Map,this.topicMap=new tn,this.events=new eventsExports.EventEmitter,this.name=pt$1,this.version=yt$1,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=O$4,this.subscribeTimeout=cjs$4.toMiliseconds(cjs$4.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId(),await this.restore()),this.initialized=!0},this.subscribe=async(fo,$o)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:fo,opts:$o}});try{const mo=zu($o),Ao={topic:fo,relay:mo,transportType:$o==null?void 0:$o.transportType};this.pending.set(fo,Ao);const jo=await this.rpcSubscribe(fo,mo,$o==null?void 0:$o.transportType);return typeof jo=="string"&&(this.onSubscribe(jo,Ao),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:fo,opts:$o}})),jo}catch(mo){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(mo),mo}},this.unsubscribe=async(fo,$o)=>{await this.restartToComplete(),this.isInitialized(),typeof($o==null?void 0:$o.id)<"u"?await this.unsubscribeById(fo,$o.id,$o):await this.unsubscribeByTopic(fo,$o)},this.isSubscribed=async fo=>{if(this.topics.includes(fo))return!0;const $o=`${this.pendingSubscriptionWatchLabel}_${fo}`;return await new Promise((mo,Ao)=>{const jo=new cjs$4.Watch;jo.start($o);const Lo=setInterval(()=>{!this.pending.has(fo)&&this.topics.includes(fo)&&(clearInterval(Lo),jo.stop($o),mo(!0)),jo.elapsed($o)>=Dt$1&&(clearInterval(Lo),jo.stop($o),Ao(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)},this.on=(fo,$o)=>{this.events.on(fo,$o)},this.once=(fo,$o)=>{this.events.once(fo,$o)},this.off=(fo,$o)=>{this.events.off(fo,$o)},this.removeListener=(fo,$o)=>{this.events.removeListener(fo,$o)},this.start=async()=>{await this.onConnect()},this.stop=async()=>{await this.onDisconnect()},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=Fn,this.logger=E$6(io,this.name),this.clientId=""}get context(){return y$7(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(Fn,io){let fo=!1;try{fo=this.getSubscription(Fn).topic===io}catch{}return fo}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(Fn,io){const fo=this.topicMap.get(Fn);await Promise.all(fo.map(async $o=>await this.unsubscribeById(Fn,$o,io)))}async unsubscribeById(Fn,io,fo){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:Fn,id:io,opts:fo}});try{const $o=zu(fo);await this.rpcUnsubscribe(Fn,io,$o);const mo=er$1("USER_DISCONNECTED",`${this.name}, ${Fn}`);await this.onUnsubscribe(Fn,io,mo),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:Fn,id:io,opts:fo}})}catch($o){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error($o),$o}}async rpcSubscribe(Fn,io,fo=F$2.relay){fo===F$2.relay&&await this.restartToComplete();const $o={method:ju(io.protocol).subscribe,params:{topic:Fn}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:$o});try{const mo=Ou(Fn+this.clientId);return fo===F$2.link_mode?(setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request($o).catch(Ao=>this.logger.warn(Ao))},cjs$4.toMiliseconds(cjs$4.ONE_SECOND)),mo):await await ms$1(this.relayer.request($o).catch(Ao=>this.logger.warn(Ao)),this.subscribeTimeout)?mo:null}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(w$2.connection_stalled)}return null}async rpcBatchSubscribe(Fn){if(!Fn.length)return;const io=Fn[0].relay,fo={method:ju(io.protocol).batchSubscribe,params:{topics:Fn.map($o=>$o.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:fo});try{return await await ms$1(this.relayer.request(fo).catch($o=>this.logger.warn($o)),this.subscribeTimeout)}catch{this.relayer.events.emit(w$2.connection_stalled)}}async rpcBatchFetchMessages(Fn){if(!Fn.length)return;const io=Fn[0].relay,fo={method:ju(io.protocol).batchFetchMessages,params:{topics:Fn.map(mo=>mo.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:fo});let $o;try{$o=await await ms$1(this.relayer.request(fo).catch(mo=>this.logger.warn(mo)),this.subscribeTimeout)}catch{this.relayer.events.emit(w$2.connection_stalled)}return $o}rpcUnsubscribe(Fn,io,fo){const $o={method:ju(fo.protocol).unsubscribe,params:{topic:Fn,id:io}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:$o}),this.relayer.request($o)}onSubscribe(Fn,io){this.setSubscription(Fn,Ce$3(ee$2({},io),{id:Fn})),this.pending.delete(io.topic)}onBatchSubscribe(Fn){Fn.length&&Fn.forEach(io=>{this.setSubscription(io.id,ee$2({},io)),this.pending.delete(io.topic)})}async onUnsubscribe(Fn,io,fo){this.events.removeAllListeners(io),this.hasSubscription(io,Fn)&&this.deleteSubscription(io,fo),await this.relayer.messages.del(Fn)}async setRelayerSubscriptions(Fn){await this.relayer.core.storage.setItem(this.storageKey,Fn)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(Fn,io){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:Fn,subscription:io}),this.addSubscription(Fn,io)}addSubscription(Fn,io){this.subscriptions.set(Fn,ee$2({},io)),this.topicMap.set(io.topic,Fn),this.events.emit(A$2.created,io)}getSubscription(Fn){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:Fn});const io=this.subscriptions.get(Fn);if(!io){const{message:fo}=xe$2("NO_MATCHING_KEY",`${this.name}: ${Fn}`);throw new Error(fo)}return io}deleteSubscription(Fn,io){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:Fn,reason:io});const fo=this.getSubscription(Fn);this.subscriptions.delete(Fn),this.topicMap.delete(fo.topic,Fn),this.events.emit(A$2.deleted,Ce$3(ee$2({},fo),{reason:io}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(A$2.sync)}async reset(){if(this.cached.length){const Fn=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let io=0;io<Fn;io++){const fo=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchFetchMessages(fo),await this.batchSubscribe(fo)}}this.events.emit(A$2.resubscribed)}async restore(){try{const Fn=await this.getRelayerSubscriptions();if(typeof Fn>"u"||!Fn.length)return;if(this.subscriptions.size){const{message:io}=xe$2("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(io),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(io)}this.cached=Fn,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(Fn){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(Fn)}}async batchSubscribe(Fn){if(!Fn.length)return;const io=await this.rpcBatchSubscribe(Fn);Nr$1(io)&&this.onBatchSubscribe(io.map((fo,$o)=>Ce$3(ee$2({},Fn[$o]),{id:fo})))}async batchFetchMessages(Fn){if(!Fn.length)return;this.logger.trace(`Fetching batch messages for ${Fn.length} subscriptions`);const io=await this.rpcBatchFetchMessages(Fn);io&&io.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(io.messages))}async onConnect(){await this.restart(),this.onEnable()}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||!this.relayer.connected)return;const Fn=[];this.pending.forEach(io=>{Fn.push(io)}),await this.batchSubscribe(Fn),this.pendingBatchMessages.length&&(await this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[])}registerEventListeners(){this.relayer.core.heartbeat.on(r$2.pulse,async()=>{await this.checkPending()}),this.events.on(A$2.created,async Fn=>{const io=A$2.created;this.logger.info(`Emitting ${io}`),this.logger.debug({type:"event",event:io,data:Fn}),await this.persist()}),this.events.on(A$2.deleted,async Fn=>{const io=A$2.deleted;this.logger.info(`Emitting ${io}`),this.logger.debug({type:"event",event:io,data:Fn}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:Fn}=xe$2("NOT_INITIALIZED",this.name);throw new Error(Fn)}}async restartToComplete(){!this.relayer.connected&&!this.relayer.connecting&&await this.relayer.transportOpen(),this.restartInProgress&&await new Promise(Fn=>{const io=setInterval(()=>{this.restartInProgress||(clearInterval(io),Fn())},this.pollingInterval)})}};var cn=Object.defineProperty,ti$1=Object.getOwnPropertySymbols,hn=Object.prototype.hasOwnProperty,ln=Object.prototype.propertyIsEnumerable,ii$1=(Mn,Fn,io)=>Fn in Mn?cn(Mn,Fn,{enumerable:!0,configurable:!0,writable:!0,value:io}):Mn[Fn]=io,un=(Mn,Fn)=>{for(var io in Fn||(Fn={}))hn.call(Fn,io)&&ii$1(Mn,io,Fn[io]);if(ti$1)for(var io of ti$1(Fn))ln.call(Fn,io)&&ii$1(Mn,io,Fn[io]);return Mn};let si$1=class extends u$2{constructor(Fn){super(Fn),this.protocol="wc",this.version=2,this.events=new eventsExports.EventEmitter,this.name=ht$1,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=cjs$4.toMiliseconds(cjs$4.THIRTY_SECONDS+cjs$4.ONE_SECOND),this.request=async io=>{var fo,$o;this.logger.debug("Publishing Request Payload");const mo=io.id||getBigIntRpcId().toString();await this.toEstablishConnection();try{const Ao=this.provider.request(io);this.requestsInFlight.set(mo,{promise:Ao,request:io}),this.logger.trace({id:mo,method:io.method,topic:(fo=io.params)==null?void 0:fo.topic},"relayer.request - attempt to publish...");const jo=await new Promise(async(Lo,Ho)=>{const zo=()=>{Ho(new Error(`relayer.request - publish interrupted, id: ${mo}`))};this.provider.on(T$4.disconnect,zo);const Go=await Ao;this.provider.off(T$4.disconnect,zo),Lo(Go)});return this.logger.trace({id:mo,method:io.method,topic:($o=io.params)==null?void 0:$o.topic},"relayer.request - published"),jo}catch(Ao){throw this.logger.debug(`Failed to Publish Request: ${mo}`),Ao}finally{this.requestsInFlight.delete(mo)}},this.resetPingTimeout=()=>{if(bi$2())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var io,fo,$o;($o=(fo=(io=this.provider)==null?void 0:io.connection)==null?void 0:fo.socket)==null||$o.terminate()},this.heartBeatTimeout)}catch(io){this.logger.warn(io)}},this.onPayloadHandler=io=>{this.onProviderPayload(io),this.resetPingTimeout()},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(w$2.connect)},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect()},this.onProviderErrorHandler=io=>{this.logger.error(io),this.events.emit(w$2.error,io),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(T$4.payload,this.onPayloadHandler),this.provider.on(T$4.connect,this.onConnectHandler),this.provider.on(T$4.disconnect,this.onDisconnectHandler),this.provider.on(T$4.error,this.onProviderErrorHandler)},this.core=Fn.core,this.logger=typeof Fn.logger<"u"&&typeof Fn.logger!="string"?E$6(Fn.logger,this.name):Mg$1(k$3({level:Fn.logger||ct$1})),this.messages=new Xt(this.logger,Fn.core),this.subscriber=new ei$1(this,this.logger),this.publisher=new en$1(this,this.logger),this.relayUrl=(Fn==null?void 0:Fn.relayUrl)||Ee$1,this.projectId=Fn.projectId,this.bundleId=ns(),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{await this.transportOpen()}catch(Fn){this.logger.warn(Fn)}}get context(){return y$7(this.logger)}get connected(){var Fn,io,fo;return((fo=(io=(Fn=this.provider)==null?void 0:Fn.connection)==null?void 0:io.socket)==null?void 0:fo.readyState)===1}get connecting(){var Fn,io,fo;return((fo=(io=(Fn=this.provider)==null?void 0:Fn.connection)==null?void 0:io.socket)==null?void 0:fo.readyState)===0}async publish(Fn,io,fo){this.isInitialized(),await this.publisher.publish(Fn,io,fo),await this.recordMessageEvent({topic:Fn,message:io,publishedAt:Date.now(),transportType:F$2.relay})}async subscribe(Fn,io){var fo;this.isInitialized(),(io==null?void 0:io.transportType)==="relay"&&await this.toEstablishConnection();let $o=((fo=this.subscriber.topicMap.get(Fn))==null?void 0:fo[0])||"",mo;const Ao=jo=>{jo.topic===Fn&&(this.subscriber.off(A$2.created,Ao),mo())};return await Promise.all([new Promise(jo=>{mo=jo,this.subscriber.on(A$2.created,Ao)}),new Promise(async jo=>{$o=await this.subscriber.subscribe(Fn,io)||$o,jo()})]),$o}async unsubscribe(Fn,io){this.isInitialized(),await this.subscriber.unsubscribe(Fn,io)}on(Fn,io){this.events.on(Fn,io)}once(Fn,io){this.events.once(Fn,io)}off(Fn,io){this.events.off(Fn,io)}removeListener(Fn,io){this.events.removeListener(Fn,io)}async transportDisconnect(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{await Promise.all(Array.from(this.requestsInFlight.values()).map(Fn=>Fn.promise))}catch(Fn){this.logger.warn(Fn)}this.hasExperiencedNetworkDisruption||this.connected?await ms$1(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(Fn){await this.confirmOnlineStateOrThrow(),Fn&&Fn!==this.relayUrl&&(this.relayUrl=Fn,await this.transportDisconnect()),await this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{await new Promise(async(io,fo)=>{const $o=()=>{this.provider.off(T$4.disconnect,$o),fo(new Error("Connection interrupted while trying to subscribe"))};this.provider.on(T$4.disconnect,$o),await ms$1(this.provider.connect(),cjs$4.toMiliseconds(cjs$4.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(mo=>{fo(mo)}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0}),this.subscriber.start().catch(mo=>{this.logger.error(mo),this.onDisconnectHandler()}),this.hasExperiencedNetworkDisruption=!1,io()})}catch(io){this.logger.error(io);const fo=io;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(fo.message))throw io}finally{this.connectionAttemptInProgress=!1}}async restartTransport(Fn){this.connectionAttemptInProgress||(this.relayUrl=Fn||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Bh$1())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(Fn){if((Fn==null?void 0:Fn.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const io=Fn.sort((fo,$o)=>fo.publishedAt-$o.publishedAt);this.logger.trace(`Batch of ${io.length} message events sorted`);for(const fo of io)try{await this.onMessageEvent(fo)}catch($o){this.logger.warn($o)}this.logger.trace(`Batch of ${io.length} message events processed`)}async onLinkMessageEvent(Fn,io){const{topic:fo}=Fn;if(!io.sessionExists){const $o=ws$1(cjs$4.FIVE_MINUTES),mo={topic:fo,expiry:$o,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(fo,mo)}this.events.emit(w$2.message,Fn),await this.recordMessageEvent(Fn)}startPingTimeout(){var Fn,io,fo,$o,mo;if(bi$2())try{(io=(Fn=this.provider)==null?void 0:Fn.connection)!=null&&io.socket&&((mo=($o=(fo=this.provider)==null?void 0:fo.connection)==null?void 0:$o.socket)==null||mo.once("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(Ao){this.logger.warn(Ao)}}isConnectionStalled(Fn){return this.staleConnectionErrors.some(io=>Fn.includes(io))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const Fn=await this.core.crypto.signJWT(this.relayUrl);this.provider=new o$1(new f$2(ss({sdkVersion:oe$3,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:Fn,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(Fn){const{topic:io,message:fo}=Fn;await this.messages.set(io,fo)}async shouldIgnoreMessageEvent(Fn){const{topic:io,message:fo}=Fn;if(!fo||fo.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${fo}`),!0;if(!await this.subscriber.isSubscribed(io))return this.logger.debug(`Ignoring message for non-subscribed topic ${io}`),!0;const $o=this.messages.has(io,fo);return $o&&this.logger.debug(`Ignoring duplicate message: ${fo}`),$o}async onProviderPayload(Fn){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:Fn}),isJsonRpcRequest(Fn)){if(!Fn.method.endsWith(lt$5))return;const io=Fn.params,{topic:fo,message:$o,publishedAt:mo,attestation:Ao}=io.data,jo={topic:fo,message:$o,publishedAt:mo,transportType:F$2.relay,attestation:Ao};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(un({type:"event",event:io.id},jo)),this.events.emit(io.id,jo),await this.acknowledgePayload(Fn),await this.onMessageEvent(jo)}else isJsonRpcResponse(Fn)&&this.events.emit(w$2.message_ack,Fn)}async onMessageEvent(Fn){await this.shouldIgnoreMessageEvent(Fn)||(this.events.emit(w$2.message,Fn),await this.recordMessageEvent(Fn))}async acknowledgePayload(Fn){const io=formatJsonRpcResult(Fn.id,!0);await this.provider.connection.send(io)}unregisterProviderListeners(){this.provider.off(T$4.payload,this.onPayloadHandler),this.provider.off(T$4.connect,this.onConnectHandler),this.provider.off(T$4.disconnect,this.onDisconnectHandler),this.provider.off(T$4.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let Fn=await Bh$1();Ch$1(async io=>{Fn!==io&&(Fn=io,io?await this.restartTransport().catch(fo=>this.logger.error(fo)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){await this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(w$2.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(Fn=>this.logger.error(Fn))},cjs$4.toMiliseconds(ut$2))))}isInitialized(){if(!this.initialized){const{message:Fn}=xe$2("NOT_INITIALIZED",this.name);throw new Error(Fn)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&await new Promise(Fn=>{const io=setInterval(()=>{this.connected&&(clearInterval(io),Fn())},this.connectionStatusPollingInterval)}),await this.transportOpen())}};var dn=Object.defineProperty,ri$1=Object.getOwnPropertySymbols,gn=Object.prototype.hasOwnProperty,pn=Object.prototype.propertyIsEnumerable,ni$1=(Mn,Fn,io)=>Fn in Mn?dn(Mn,Fn,{enumerable:!0,configurable:!0,writable:!0,value:io}):Mn[Fn]=io,oi$1=(Mn,Fn)=>{for(var io in Fn||(Fn={}))gn.call(Fn,io)&&ni$1(Mn,io,Fn[io]);if(ri$1)for(var io of ri$1(Fn))pn.call(Fn,io)&&ni$1(Mn,io,Fn[io]);return Mn};let ai$1=class extends p$5{constructor(Fn,io,fo,$o=O$4,mo=void 0){super(Fn,io,fo,$o),this.core=Fn,this.logger=io,this.name=fo,this.map=new Map,this.version=dt$1,this.cached=[],this.initialized=!1,this.storagePrefix=O$4,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(Ao=>{this.getKey&&Ao!==null&&!Pe$1(Ao)?this.map.set(this.getKey(Ao),Ao):lh$1(Ao)?this.map.set(Ao.id,Ao):dh$1(Ao)&&this.map.set(Ao.topic,Ao)}),this.cached=[],this.initialized=!0)},this.set=async(Ao,jo)=>{this.isInitialized(),this.map.has(Ao)?await this.update(Ao,jo):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:Ao,value:jo}),this.map.set(Ao,jo),await this.persist())},this.get=Ao=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:Ao}),this.getData(Ao)),this.getAll=Ao=>(this.isInitialized(),Ao?this.values.filter(jo=>Object.keys(Ao).every(Lo=>bs(jo[Lo],Ao[Lo]))):this.values),this.update=async(Ao,jo)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:Ao,update:jo});const Lo=oi$1(oi$1({},this.getData(Ao)),jo);this.map.set(Ao,Lo),await this.persist()},this.delete=async(Ao,jo)=>{this.isInitialized(),this.map.has(Ao)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:Ao,reason:jo}),this.map.delete(Ao),this.addToRecentlyDeleted(Ao),await this.persist())},this.logger=E$6(io,this.name),this.storagePrefix=$o,this.getKey=mo}get context(){return y$7(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(Fn){this.recentlyDeleted.push(Fn),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(Fn){await this.core.storage.setItem(this.storageKey,Fn)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(Fn){const io=this.map.get(Fn);if(!io){if(this.recentlyDeleted.includes(Fn)){const{message:$o}=xe$2("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${Fn}`);throw this.logger.error($o),new Error($o)}const{message:fo}=xe$2("NO_MATCHING_KEY",`${this.name}: ${Fn}`);throw this.logger.error(fo),new Error(fo)}return io}async persist(){await this.setDataStore(this.values)}async restore(){try{const Fn=await this.getDataStore();if(typeof Fn>"u"||!Fn.length)return;if(this.map.size){const{message:io}=xe$2("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(io),new Error(io)}this.cached=Fn,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(Fn){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(Fn)}}isInitialized(){if(!this.initialized){const{message:Fn}=xe$2("NOT_INITIALIZED",this.name);throw new Error(Fn)}}},ci$1=class{constructor(Fn,io){this.core=Fn,this.logger=io,this.name=mt,this.version=bt,this.events=new EventEmitter$3,this.initialized=!1,this.storagePrefix=O$4,this.ignoredPayloadTypes=[pr$2],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:fo})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...fo])]},this.create=async fo=>{this.isInitialized();const $o=Bu(),mo=await this.core.crypto.setSymKey($o),Ao=ws$1(cjs$4.FIVE_MINUTES),jo={protocol:at$1},Lo={topic:mo,expiry:Ao,relay:jo,active:!1,methods:fo==null?void 0:fo.methods},Ho=$u({protocol:this.core.protocol,version:this.core.version,topic:mo,symKey:$o,relay:jo,expiryTimestamp:Ao,methods:fo==null?void 0:fo.methods});return this.events.emit(q$3.create,Lo),this.core.expirer.set(mo,Ao),await this.pairings.set(mo,Lo),await this.core.relayer.subscribe(mo,{transportType:fo==null?void 0:fo.transportType}),{topic:mo,uri:Ho}},this.pair=async fo=>{this.isInitialized();const $o=this.core.eventClient.createEvent({properties:{topic:fo==null?void 0:fo.uri,trace:[z$4.pairing_started]}});this.isValidPair(fo,$o);const{topic:mo,symKey:Ao,relay:jo,expiryTimestamp:Lo,methods:Ho}=Xu(fo.uri);$o.props.properties.topic=mo,$o.addTrace(z$4.pairing_uri_validation_success),$o.addTrace(z$4.pairing_uri_not_expired);let zo;if(this.pairings.keys.includes(mo)){if(zo=this.pairings.get(mo),$o.addTrace(z$4.existing_pairing),zo.active)throw $o.setError(M$3.active_pairing_already_exists),new Error(`Pairing already exists: ${mo}. Please try again with a new connection URI.`);$o.addTrace(z$4.pairing_not_expired)}const Go=Lo||ws$1(cjs$4.FIVE_MINUTES),Vo={topic:mo,relay:jo,expiry:Go,active:!1,methods:Ho};this.core.expirer.set(mo,Go),await this.pairings.set(mo,Vo),$o.addTrace(z$4.store_new_pairing),fo.activatePairing&&await this.activate({topic:mo}),this.events.emit(q$3.create,Vo),$o.addTrace(z$4.emit_inactive_pairing),this.core.crypto.keychain.has(mo)||await this.core.crypto.setSymKey(Ao,mo),$o.addTrace(z$4.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{$o.setError(M$3.no_internet_connection)}try{await this.core.relayer.subscribe(mo,{relay:jo})}catch(Yo){throw $o.setError(M$3.subscribe_pairing_topic_failure),Yo}return $o.addTrace(z$4.subscribe_pairing_topic_success),Vo},this.activate=async({topic:fo})=>{this.isInitialized();const $o=ws$1(cjs$4.THIRTY_DAYS);this.core.expirer.set(fo,$o),await this.pairings.update(fo,{active:!0,expiry:$o})},this.ping=async fo=>{this.isInitialized(),await this.isValidPing(fo);const{topic:$o}=fo;if(this.pairings.keys.includes($o)){const mo=await this.sendRequest($o,"wc_pairingPing",{}),{done:Ao,resolve:jo,reject:Lo}=gs();this.events.once(Ms$1("pairing_ping",mo),({error:Ho})=>{Ho?Lo(Ho):jo()}),await Ao()}},this.updateExpiry=async({topic:fo,expiry:$o})=>{this.isInitialized(),await this.pairings.update(fo,{expiry:$o})},this.updateMetadata=async({topic:fo,metadata:$o})=>{this.isInitialized(),await this.pairings.update(fo,{peerMetadata:$o})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async fo=>{this.isInitialized(),await this.isValidDisconnect(fo);const{topic:$o}=fo;this.pairings.keys.includes($o)&&(await this.sendRequest($o,"wc_pairingDelete",er$1("USER_DISCONNECTED")),await this.deletePairing($o))},this.formatUriFromPairing=fo=>{this.isInitialized();const{topic:$o,relay:mo,expiry:Ao,methods:jo}=fo,Lo=this.core.crypto.keychain.get($o);return $u({protocol:this.core.protocol,version:this.core.version,topic:$o,symKey:Lo,relay:mo,expiryTimestamp:Ao,methods:jo})},this.sendRequest=async(fo,$o,mo)=>{const Ao=formatJsonRpcRequest($o,mo),jo=await this.core.crypto.encode(fo,Ao),Lo=j$6[$o].req;return this.core.history.set(fo,Ao),this.core.relayer.publish(fo,jo,Lo),Ao.id},this.sendResult=async(fo,$o,mo)=>{const Ao=formatJsonRpcResult(fo,mo),jo=await this.core.crypto.encode($o,Ao),Lo=await this.core.history.get($o,fo),Ho=j$6[Lo.request.method].res;await this.core.relayer.publish($o,jo,Ho),await this.core.history.resolve(Ao)},this.sendError=async(fo,$o,mo)=>{const Ao=formatJsonRpcError(fo,mo),jo=await this.core.crypto.encode($o,Ao),Lo=await this.core.history.get($o,fo),Ho=j$6[Lo.request.method]?j$6[Lo.request.method].res:j$6.unregistered_method.res;await this.core.relayer.publish($o,jo,Ho),await this.core.history.resolve(Ao)},this.deletePairing=async(fo,$o)=>{await this.core.relayer.unsubscribe(fo),await Promise.all([this.pairings.delete(fo,er$1("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(fo),$o?Promise.resolve():this.core.expirer.del(fo)])},this.cleanup=async()=>{const fo=this.pairings.getAll().filter($o=>xs$1($o.expiry));await Promise.all(fo.map($o=>this.deletePairing($o.topic)))},this.onRelayEventRequest=fo=>{const{topic:$o,payload:mo}=fo;switch(mo.method){case"wc_pairingPing":return this.onPairingPingRequest($o,mo);case"wc_pairingDelete":return this.onPairingDeleteRequest($o,mo);default:return this.onUnknownRpcMethodRequest($o,mo)}},this.onRelayEventResponse=async fo=>{const{topic:$o,payload:mo}=fo,Ao=(await this.core.history.get($o,mo.id)).request.method;switch(Ao){case"wc_pairingPing":return this.onPairingPingResponse($o,mo);default:return this.onUnknownRpcMethodResponse(Ao)}},this.onPairingPingRequest=async(fo,$o)=>{const{id:mo}=$o;try{this.isValidPing({topic:fo}),await this.sendResult(mo,fo,!0),this.events.emit(q$3.ping,{id:mo,topic:fo})}catch(Ao){await this.sendError(mo,fo,Ao),this.logger.error(Ao)}},this.onPairingPingResponse=(fo,$o)=>{const{id:mo}=$o;setTimeout(()=>{isJsonRpcResult($o)?this.events.emit(Ms$1("pairing_ping",mo),{}):isJsonRpcError($o)&&this.events.emit(Ms$1("pairing_ping",mo),{error:$o.error})},500)},this.onPairingDeleteRequest=async(fo,$o)=>{const{id:mo}=$o;try{this.isValidDisconnect({topic:fo}),await this.deletePairing(fo),this.events.emit(q$3.delete,{id:mo,topic:fo})}catch(Ao){await this.sendError(mo,fo,Ao),this.logger.error(Ao)}},this.onUnknownRpcMethodRequest=async(fo,$o)=>{const{id:mo,method:Ao}=$o;try{if(this.registeredMethods.includes(Ao))return;const jo=er$1("WC_METHOD_UNSUPPORTED",Ao);await this.sendError(mo,fo,jo),this.logger.error(jo)}catch(jo){await this.sendError(mo,fo,jo),this.logger.error(jo)}},this.onUnknownRpcMethodResponse=fo=>{this.registeredMethods.includes(fo)||this.logger.error(er$1("WC_METHOD_UNSUPPORTED",fo))},this.isValidPair=(fo,$o)=>{var mo;if(!Ah$1(fo)){const{message:jo}=xe$2("MISSING_OR_INVALID",`pair() params: ${fo}`);throw $o.setError(M$3.malformed_pairing_uri),new Error(jo)}if(!ch$1(fo.uri)){const{message:jo}=xe$2("MISSING_OR_INVALID",`pair() uri: ${fo.uri}`);throw $o.setError(M$3.malformed_pairing_uri),new Error(jo)}const Ao=Xu(fo==null?void 0:fo.uri);if(!((mo=Ao==null?void 0:Ao.relay)!=null&&mo.protocol)){const{message:jo}=xe$2("MISSING_OR_INVALID","pair() uri#relay-protocol");throw $o.setError(M$3.malformed_pairing_uri),new Error(jo)}if(!(Ao!=null&&Ao.symKey)){const{message:jo}=xe$2("MISSING_OR_INVALID","pair() uri#symKey");throw $o.setError(M$3.malformed_pairing_uri),new Error(jo)}if(Ao!=null&&Ao.expiryTimestamp&&cjs$4.toMiliseconds(Ao==null?void 0:Ao.expiryTimestamp)<Date.now()){$o.setError(M$3.pairing_expired);const{message:jo}=xe$2("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(jo)}},this.isValidPing=async fo=>{if(!Ah$1(fo)){const{message:mo}=xe$2("MISSING_OR_INVALID",`ping() params: ${fo}`);throw new Error(mo)}const{topic:$o}=fo;await this.isValidPairingTopic($o)},this.isValidDisconnect=async fo=>{if(!Ah$1(fo)){const{message:mo}=xe$2("MISSING_OR_INVALID",`disconnect() params: ${fo}`);throw new Error(mo)}const{topic:$o}=fo;await this.isValidPairingTopic($o)},this.isValidPairingTopic=async fo=>{if(!Yt$1(fo,!1)){const{message:$o}=xe$2("MISSING_OR_INVALID",`pairing topic should be a string: ${fo}`);throw new Error($o)}if(!this.pairings.keys.includes(fo)){const{message:$o}=xe$2("NO_MATCHING_KEY",`pairing topic doesn't exist: ${fo}`);throw new Error($o)}if(xs$1(this.pairings.get(fo).expiry)){await this.deletePairing(fo);const{message:$o}=xe$2("EXPIRED",`pairing topic: ${fo}`);throw new Error($o)}},this.core=Fn,this.logger=E$6(io,this.name),this.pairings=new ai$1(this.core,this.logger,this.name,this.storagePrefix)}get context(){return y$7(this.logger)}isInitialized(){if(!this.initialized){const{message:Fn}=xe$2("NOT_INITIALIZED",this.name);throw new Error(Fn)}}registerRelayerEvents(){this.core.relayer.on(w$2.message,async Fn=>{const{topic:io,message:fo,transportType:$o}=Fn;if(!this.pairings.keys.includes(io)||$o===F$2.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(fo)))return;const mo=await this.core.crypto.decode(io,fo);try{isJsonRpcRequest(mo)?(this.core.history.set(io,mo),this.onRelayEventRequest({topic:io,payload:mo})):isJsonRpcResponse(mo)&&(await this.core.history.resolve(mo),await this.onRelayEventResponse({topic:io,payload:mo}),this.core.history.delete(io,mo.id))}catch(Ao){this.logger.error(Ao)}})}registerExpirerEvents(){this.core.expirer.on(R$3.expired,async Fn=>{const{topic:io}=ys$1(Fn.target);io&&this.pairings.keys.includes(io)&&(await this.deletePairing(io,!0),this.events.emit(q$3.expire,{topic:io}))})}},hi$2=class extends h$1{constructor(Fn,io){super(Fn,io),this.core=Fn,this.logger=io,this.records=new Map,this.events=new eventsExports.EventEmitter,this.name=ft,this.version=_t,this.cached=[],this.initialized=!1,this.storagePrefix=O$4,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(fo=>this.records.set(fo.id,fo)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(fo,$o,mo)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:fo,request:$o,chainId:mo}),this.records.has($o.id))return;const Ao={id:$o.id,topic:fo,request:{method:$o.method,params:$o.params||null},chainId:mo,expiry:ws$1(cjs$4.THIRTY_DAYS)};this.records.set(Ao.id,Ao),this.persist(),this.events.emit(P$3.created,Ao)},this.resolve=async fo=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:fo}),!this.records.has(fo.id))return;const $o=await this.getRecord(fo.id);typeof $o.response>"u"&&($o.response=isJsonRpcError(fo)?{error:fo.error}:{result:fo.result},this.records.set($o.id,$o),this.persist(),this.events.emit(P$3.updated,$o))},this.get=async(fo,$o)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:fo,id:$o}),await this.getRecord($o)),this.delete=(fo,$o)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:$o}),this.values.forEach(mo=>{if(mo.topic===fo){if(typeof $o<"u"&&mo.id!==$o)return;this.records.delete(mo.id),this.events.emit(P$3.deleted,mo)}}),this.persist()},this.exists=async(fo,$o)=>(this.isInitialized(),this.records.has($o)?(await this.getRecord($o)).topic===fo:!1),this.on=(fo,$o)=>{this.events.on(fo,$o)},this.once=(fo,$o)=>{this.events.once(fo,$o)},this.off=(fo,$o)=>{this.events.off(fo,$o)},this.removeListener=(fo,$o)=>{this.events.removeListener(fo,$o)},this.logger=E$6(io,this.name)}get context(){return y$7(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const Fn=[];return this.values.forEach(io=>{if(typeof io.response<"u")return;const fo={topic:io.topic,request:formatJsonRpcRequest(io.request.method,io.request.params,io.id),chainId:io.chainId};return Fn.push(fo)}),Fn}async setJsonRpcRecords(Fn){await this.core.storage.setItem(this.storageKey,Fn)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(Fn){this.isInitialized();const io=this.records.get(Fn);if(!io){const{message:fo}=xe$2("NO_MATCHING_KEY",`${this.name}: ${Fn}`);throw new Error(fo)}return io}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(P$3.sync)}async restore(){try{const Fn=await this.getJsonRpcRecords();if(typeof Fn>"u"||!Fn.length)return;if(this.records.size){const{message:io}=xe$2("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(io),new Error(io)}this.cached=Fn,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(Fn){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(Fn)}}registerEventListeners(){this.events.on(P$3.created,Fn=>{const io=P$3.created;this.logger.info(`Emitting ${io}`),this.logger.debug({type:"event",event:io,record:Fn})}),this.events.on(P$3.updated,Fn=>{const io=P$3.updated;this.logger.info(`Emitting ${io}`),this.logger.debug({type:"event",event:io,record:Fn})}),this.events.on(P$3.deleted,Fn=>{const io=P$3.deleted;this.logger.info(`Emitting ${io}`),this.logger.debug({type:"event",event:io,record:Fn})}),this.core.heartbeat.on(r$2.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let Fn=!1;this.records.forEach(io=>{cjs$4.toMiliseconds(io.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${io.id}`),this.records.delete(io.id),this.events.emit(P$3.deleted,io,!1),Fn=!0)}),Fn&&this.persist()}catch(Fn){this.logger.warn(Fn)}}isInitialized(){if(!this.initialized){const{message:Fn}=xe$2("NOT_INITIALIZED",this.name);throw new Error(Fn)}}},li$1=class extends x$3{constructor(Fn,io){super(Fn,io),this.core=Fn,this.logger=io,this.expirations=new Map,this.events=new eventsExports.EventEmitter,this.name=Et,this.version=vt,this.cached=[],this.initialized=!1,this.storagePrefix=O$4,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(fo=>this.expirations.set(fo.target,fo)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=fo=>{try{const $o=this.formatTarget(fo);return typeof this.getExpiration($o)<"u"}catch{return!1}},this.set=(fo,$o)=>{this.isInitialized();const mo=this.formatTarget(fo),Ao={target:mo,expiry:$o};this.expirations.set(mo,Ao),this.checkExpiry(mo,Ao),this.events.emit(R$3.created,{target:mo,expiration:Ao})},this.get=fo=>{this.isInitialized();const $o=this.formatTarget(fo);return this.getExpiration($o)},this.del=fo=>{if(this.isInitialized(),this.has(fo)){const $o=this.formatTarget(fo),mo=this.getExpiration($o);this.expirations.delete($o),this.events.emit(R$3.deleted,{target:$o,expiration:mo})}},this.on=(fo,$o)=>{this.events.on(fo,$o)},this.once=(fo,$o)=>{this.events.once(fo,$o)},this.off=(fo,$o)=>{this.events.off(fo,$o)},this.removeListener=(fo,$o)=>{this.events.removeListener(fo,$o)},this.logger=E$6(io,this.name)}get context(){return y$7(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(Fn){if(typeof Fn=="string")return As$1(Fn);if(typeof Fn=="number")return bs$1(Fn);const{message:io}=xe$2("UNKNOWN_TYPE",`Target type: ${typeof Fn}`);throw new Error(io)}async setExpirations(Fn){await this.core.storage.setItem(this.storageKey,Fn)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(R$3.sync)}async restore(){try{const Fn=await this.getExpirations();if(typeof Fn>"u"||!Fn.length)return;if(this.expirations.size){const{message:io}=xe$2("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(io),new Error(io)}this.cached=Fn,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(Fn){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(Fn)}}getExpiration(Fn){const io=this.expirations.get(Fn);if(!io){const{message:fo}=xe$2("NO_MATCHING_KEY",`${this.name}: ${Fn}`);throw this.logger.warn(fo),new Error(fo)}return io}checkExpiry(Fn,io){const{expiry:fo}=io;cjs$4.toMiliseconds(fo)-Date.now()<=0&&this.expire(Fn,io)}expire(Fn,io){this.expirations.delete(Fn),this.events.emit(R$3.expired,{target:Fn,expiration:io})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((Fn,io)=>this.checkExpiry(io,Fn))}registerEventListeners(){this.core.heartbeat.on(r$2.pulse,()=>this.checkExpirations()),this.events.on(R$3.created,Fn=>{const io=R$3.created;this.logger.info(`Emitting ${io}`),this.logger.debug({type:"event",event:io,data:Fn}),this.persist()}),this.events.on(R$3.expired,Fn=>{const io=R$3.expired;this.logger.info(`Emitting ${io}`),this.logger.debug({type:"event",event:io,data:Fn}),this.persist()}),this.events.on(R$3.deleted,Fn=>{const io=R$3.deleted;this.logger.info(`Emitting ${io}`),this.logger.debug({type:"event",event:io,data:Fn}),this.persist()})}isInitialized(){if(!this.initialized){const{message:Fn}=xe$2("NOT_INITIALIZED",this.name);throw new Error(Fn)}}};var y$2={};Object.defineProperty(y$2,"__esModule",{value:!0}),y$2.getLocalStorage=y$2.getLocalStorageOrThrow=y$2.getCrypto=y$2.getCryptoOrThrow=y$2.getLocation=y$2.getLocationOrThrow=y$2.getNavigator=y$2.getNavigatorOrThrow=ui$1=y$2.getDocument=y$2.getDocumentOrThrow=y$2.getFromWindowOrThrow=y$2.getFromWindow=void 0;function U$3(Mn){let Fn;return typeof window<"u"&&typeof window[Mn]<"u"&&(Fn=window[Mn]),Fn}y$2.getFromWindow=U$3;function G$2(Mn){const Fn=U$3(Mn);if(!Fn)throw new Error(`${Mn} is not defined in Window`);return Fn}y$2.getFromWindowOrThrow=G$2;function yn(){return G$2("document")}y$2.getDocumentOrThrow=yn;function Dn(){return U$3("document")}var ui$1=y$2.getDocument=Dn;function mn(){return G$2("navigator")}y$2.getNavigatorOrThrow=mn;function bn(){return U$3("navigator")}y$2.getNavigator=bn;function fn(){return G$2("location")}y$2.getLocationOrThrow=fn;function _n$1(){return U$3("location")}y$2.getLocation=_n$1;function En(){return G$2("crypto")}y$2.getCryptoOrThrow=En;function vn(){return U$3("crypto")}y$2.getCrypto=vn;function wn$1(){return G$2("localStorage")}y$2.getLocalStorageOrThrow=wn$1;function In(){return U$3("localStorage")}y$2.getLocalStorage=In;let di$1=class extends y$3{constructor(Fn,io,fo){super(Fn,io,fo),this.core=Fn,this.logger=io,this.store=fo,this.name=wt,this.verifyUrlV3=Tt$2,this.storagePrefix=O$4,this.version=fe$2,this.init=async()=>{var $o;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&cjs$4.toMiliseconds(($o=this.publicKey)==null?void 0:$o.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))},this.register=async $o=>{if(!gr$1()||this.isDevEnv)return;const mo=window.location.origin,{id:Ao,decryptedId:jo}=$o,Lo=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${mo}&id=${Ao}&decryptedId=${jo}`;try{const Ho=ui$1(),zo=this.startAbortTimer(cjs$4.ONE_SECOND*5),Go=await new Promise((Vo,Yo)=>{const Xo=()=>{window.removeEventListener("message",yl),Ho.body.removeChild(is),Yo("attestation aborted")};this.abortController.signal.addEventListener("abort",Xo);const is=Ho.createElement("iframe");is.src=Lo,is.style.display="none",is.addEventListener("error",Xo,{signal:this.abortController.signal});const yl=us=>{if(us.data&&typeof us.data=="string")try{const hs=JSON.parse(us.data);if(hs.type==="verify_attestation"){if(decodeJWT(hs.attestation).payload.id!==Ao)return;clearInterval(zo),Ho.body.removeChild(is),this.abortController.signal.removeEventListener("abort",Xo),window.removeEventListener("message",yl),Vo(hs.attestation===null?"":hs.attestation)}}catch(hs){this.logger.warn(hs)}};Ho.body.appendChild(is),window.addEventListener("message",yl,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",Go),Go}catch(Ho){this.logger.warn(Ho)}return""},this.resolve=async $o=>{if(this.isDevEnv)return"";const{attestationId:mo,hash:Ao,encryptedId:jo}=$o;if(mo===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(mo){if(decodeJWT(mo).payload.id!==jo)return;const Ho=await this.isValidJwtAttestation(mo);if(Ho){if(!Ho.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return Ho}}if(!Ao)return;const Lo=this.getVerifyUrl($o==null?void 0:$o.verifyUrl);return this.fetchAttestation(Ao,Lo)},this.fetchAttestation=async($o,mo)=>{this.logger.debug(`resolving attestation: ${$o} from url: ${mo}`);const Ao=this.startAbortTimer(cjs$4.ONE_SECOND*5),jo=await fetch(`${mo}/attestation/${$o}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(Ao),jo.status===200?await jo.json():void 0},this.getVerifyUrl=$o=>{let mo=$o||Z$1;return Ct.includes(mo)||(this.logger.info(`verify url: ${mo}, not included in trusted list, assigning default: ${Z$1}`),mo=Z$1),mo},this.fetchPublicKey=async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const $o=this.startAbortTimer(cjs$4.FIVE_SECONDS),mo=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout($o),await mo.json()}catch($o){this.logger.warn($o)}},this.persistPublicKey=async $o=>{this.logger.debug("persisting public key to local storage",$o),await this.store.setItem(this.storeKey,$o),this.publicKey=$o},this.removePublicKey=async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0},this.isValidJwtAttestation=async $o=>{const mo=await this.getPublicKey();try{if(mo)return this.validateAttestation($o,mo)}catch(jo){this.logger.error(jo),this.logger.warn("error validating attestation")}const Ao=await this.fetchAndPersistPublicKey();try{if(Ao)return this.validateAttestation($o,Ao)}catch(jo){this.logger.error(jo),this.logger.warn("error validating attestation")}},this.getPublicKey=async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey(),this.fetchAndPersistPublicKey=async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async mo=>{const Ao=await this.fetchPublicKey();Ao&&(await this.persistPublicKey(Ao),mo(Ao))});const $o=await this.fetchPromise;return this.fetchPromise=void 0,$o},this.validateAttestation=($o,mo)=>{const Ao=Lu($o,mo.publicKey),jo={hasExpired:cjs$4.toMiliseconds(Ao.exp)<Date.now(),payload:Ao};if(jo.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:jo.payload.origin,isScam:jo.payload.isScam,isVerified:jo.payload.isVerified}},this.logger=E$6(io,this.name),this.abortController=new AbortController,this.isDevEnv=_s$2(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return y$7(this.logger)}startAbortTimer(Fn){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),cjs$4.toMiliseconds(Fn))}},gi$2=class extends v$5{constructor(Fn,io){super(Fn,io),this.projectId=Fn,this.logger=io,this.context=St,this.registerDeviceToken=async fo=>{const{clientId:$o,token:mo,notificationType:Ao,enableEncrypted:jo=!1}=fo,Lo=`${Pt}/${this.projectId}/clients`;await fetch(Lo,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:$o,type:Ao,token:mo,always_raw:jo})})},this.logger=E$6(io,this.context)}};var Tn$1=Object.defineProperty,pi$1=Object.getOwnPropertySymbols,Cn=Object.prototype.hasOwnProperty,Sn=Object.prototype.propertyIsEnumerable,yi$1=(Mn,Fn,io)=>Fn in Mn?Tn$1(Mn,Fn,{enumerable:!0,configurable:!0,writable:!0,value:io}):Mn[Fn]=io,te$2=(Mn,Fn)=>{for(var io in Fn||(Fn={}))Cn.call(Fn,io)&&yi$1(Mn,io,Fn[io]);if(pi$1)for(var io of pi$1(Fn))Sn.call(Fn,io)&&yi$1(Mn,io,Fn[io]);return Mn};let Di$2=class extends C$3{constructor(Fn,io,fo=!0){super(Fn,io,fo),this.core=Fn,this.logger=io,this.context=xt,this.storagePrefix=O$4,this.storageVersion=Rt,this.events=new Map,this.shouldPersist=!1,this.init=async()=>{if(!_s$2())try{const $o={eventId:Ns$2(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:Pn$1(this.core.relayer.protocol,this.core.relayer.version,oe$3)}}};await this.sendEvent([$o])}catch($o){this.logger.warn($o)}},this.createEvent=$o=>{const{event:mo="ERROR",type:Ao="",properties:{topic:jo,trace:Lo}}=$o,Ho=Ns$2(),zo=this.core.projectId||"",Go=Date.now(),Vo=te$2({eventId:Ho,timestamp:Go,props:{event:mo,type:Ao,properties:{topic:jo,trace:Lo}},bundleId:zo,domain:this.getAppDomain()},this.setMethods(Ho));return this.telemetryEnabled&&(this.events.set(Ho,Vo),this.shouldPersist=!0),Vo},this.getEvent=$o=>{const{eventId:mo,topic:Ao}=$o;if(mo)return this.events.get(mo);const jo=Array.from(this.events.values()).find(Lo=>Lo.props.properties.topic===Ao);if(jo)return te$2(te$2({},jo),this.setMethods(jo.eventId))},this.deleteEvent=$o=>{const{eventId:mo}=$o;this.events.delete(mo),this.shouldPersist=!0},this.setEventListeners=()=>{this.core.heartbeat.on(r$2.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach($o=>{cjs$4.fromMiliseconds(Date.now())-cjs$4.fromMiliseconds($o.timestamp)>Ot$1&&(this.events.delete($o.eventId),this.shouldPersist=!0)})})},this.setMethods=$o=>({addTrace:mo=>this.addTrace($o,mo),setError:mo=>this.setError($o,mo)}),this.addTrace=($o,mo)=>{const Ao=this.events.get($o);Ao&&(Ao.props.properties.trace.push(mo),this.events.set($o,Ao),this.shouldPersist=!0)},this.setError=($o,mo)=>{const Ao=this.events.get($o);Ao&&(Ao.props.type=mo,Ao.timestamp=Date.now(),this.events.set($o,Ao),this.shouldPersist=!0)},this.persist=async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1},this.restore=async()=>{try{const $o=await this.core.storage.getItem(this.storageKey)||[];if(!$o.length)return;$o.forEach(mo=>{this.events.set(mo.eventId,te$2(te$2({},mo),this.setMethods(mo.eventId)))})}catch($o){this.logger.warn($o)}},this.submit=async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const $o=[];for(const[mo,Ao]of this.events)Ao.props.type&&$o.push(Ao);if($o.length!==0)try{if((await this.sendEvent($o)).ok)for(const mo of $o)this.events.delete(mo.eventId),this.shouldPersist=!0}catch(mo){this.logger.warn(mo)}},this.sendEvent=async $o=>{const mo=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${At}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${oe$3}${mo}`,{method:"POST",body:JSON.stringify($o)})},this.getAppDomain=()=>fs$1().url,this.logger=E$6(io,this.context),this.telemetryEnabled=fo,fo?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}};var Pn=Object.defineProperty,mi$2=Object.getOwnPropertySymbols,Rn=Object.prototype.hasOwnProperty,xn$1=Object.prototype.propertyIsEnumerable,bi$1=(Mn,Fn,io)=>Fn in Mn?Pn(Mn,Fn,{enumerable:!0,configurable:!0,writable:!0,value:io}):Mn[Fn]=io,fi$1=(Mn,Fn)=>{for(var io in Fn||(Fn={}))Rn.call(Fn,io)&&bi$1(Mn,io,Fn[io]);if(mi$2)for(var io of mi$2(Fn))xn$1.call(Fn,io)&&bi$1(Mn,io,Fn[io]);return Mn};let ce$2=class d_ extends n$3{constructor(Fn){var io;super(Fn),this.protocol=be$3,this.version=fe$2,this.name=ne$2,this.events=new eventsExports.EventEmitter,this.initialized=!1,this.on=(Ao,jo)=>this.events.on(Ao,jo),this.once=(Ao,jo)=>this.events.once(Ao,jo),this.off=(Ao,jo)=>this.events.off(Ao,jo),this.removeListener=(Ao,jo)=>this.events.removeListener(Ao,jo),this.dispatchEnvelope=({topic:Ao,message:jo,sessionExists:Lo})=>{if(!Ao||!jo)return;const Ho={topic:Ao,message:jo,publishedAt:Date.now(),transportType:F$2.link_mode};this.relayer.onLinkMessageEvent(Ho,{sessionExists:Lo})},this.projectId=Fn==null?void 0:Fn.projectId,this.relayUrl=(Fn==null?void 0:Fn.relayUrl)||Ee$1,this.customStoragePrefix=Fn!=null&&Fn.customStoragePrefix?`:${Fn.customStoragePrefix}`:"";const fo=k$3({level:typeof(Fn==null?void 0:Fn.logger)=="string"&&Fn.logger?Fn.logger:Xe$2.logger}),{logger:$o,chunkLoggerController:mo}=A$4({opts:fo,maxSizeInBytes:Fn==null?void 0:Fn.maxLogBlobSizeInBytes,loggerOverride:Fn==null?void 0:Fn.logger});this.logChunkController=mo,(io=this.logChunkController)!=null&&io.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var Ao,jo;(Ao=this.logChunkController)!=null&&Ao.downloadLogsBlobInBrowser&&((jo=this.logChunkController)==null||jo.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=E$6($o,this.name),this.heartbeat=new i$1,this.crypto=new Wt(this,this.logger,Fn==null?void 0:Fn.keychain),this.history=new hi$2(this,this.logger),this.expirer=new li$1(this,this.logger),this.storage=Fn!=null&&Fn.storage?Fn.storage:new h$2(fi$1(fi$1({},Ze$2),Fn==null?void 0:Fn.storageOptions)),this.relayer=new si$1({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new ci$1(this,this.logger),this.verify=new di$1(this,this.logger,this.storage),this.echoClient=new gi$2(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new Di$2(this,this.logger,Fn==null?void 0:Fn.telemetryEnabled)}static async init(Fn){const io=new d_(Fn);await io.initialize();const fo=await io.crypto.getClientId();return await io.storage.setItem(gt$6,fo),io}get context(){return y$7(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var Fn;return(Fn=this.logChunkController)==null?void 0:Fn.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(Fn){this.linkModeSupportedApps.includes(Fn)||(this.linkModeSupportedApps.push(Fn),await this.storage.setItem(ve$1,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=await this.storage.getItem(ve$1)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(Fn){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,Fn),this.logger.error(Fn.message),Fn}}};const On=ce$2,be$2="wc",Ce$2=2,Le$1="client",ye$2=`${be$2}@${Ce$2}:${Le$1}:`,we$2={name:Le$1,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.org"},xe$1="WALLETCONNECT_DEEPLINK_CHOICE",st="proposal",it="Proposal expired",rt="session",z$3=cjs$4.SEVEN_DAYS,nt="engine",v$4={wc_sessionPropose:{req:{ttl:cjs$4.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:cjs$4.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:cjs$4.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:cjs$4.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:cjs$4.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:cjs$4.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:cjs$4.ONE_DAY,prompt:!1,tag:1104},res:{ttl:cjs$4.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:cjs$4.ONE_DAY,prompt:!1,tag:1106},res:{ttl:cjs$4.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:cjs$4.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:cjs$4.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:cjs$4.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:cjs$4.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:cjs$4.ONE_DAY,prompt:!1,tag:1112},res:{ttl:cjs$4.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:cjs$4.ONE_DAY,prompt:!1,tag:1114},res:{ttl:cjs$4.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:cjs$4.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:cjs$4.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:cjs$4.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:cjs$4.FIVE_MINUTES,prompt:!1,tag:1119}}},me$1={min:cjs$4.FIVE_MINUTES,max:cjs$4.SEVEN_DAYS},x$2={idle:"IDLE",active:"ACTIVE"},ot="request",at=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],ct="wc",lt$4="auth",pt="authKeys",ht="pairingTopics",dt="requests",oe$2=`${ct}@${1.5}:${lt$4}:`,ae$2=`${oe$2}:PUB_KEY`;var ys=Object.defineProperty,ws=Object.defineProperties,ms=Object.getOwnPropertyDescriptors,ut$1=Object.getOwnPropertySymbols,_s$1=Object.prototype.hasOwnProperty,Es$1=Object.prototype.propertyIsEnumerable,gt$5=(Mn,Fn,io)=>Fn in Mn?ys(Mn,Fn,{enumerable:!0,configurable:!0,writable:!0,value:io}):Mn[Fn]=io,I$2=(Mn,Fn)=>{for(var io in Fn||(Fn={}))_s$1.call(Fn,io)&>$5(Mn,io,Fn[io]);if(ut$1)for(var io of ut$1(Fn))Es$1.call(Fn,io)&>$5(Mn,io,Fn[io]);return Mn},D$3=(Mn,Fn)=>ws(Mn,ms(Fn));class Rs extends M$4{constructor(Fn){super(Fn),this.name=nt,this.events=new EventEmitter$3,this.initialized=!1,this.requestQueue={state:x$2.idle,queue:[]},this.sessionRequestQueue={state:x$2.idle,queue:[]},this.requestQueueDelay=cjs$4.ONE_SECOND,this.expectedPairingMethodMap=new Map,this.recentlyDeletedMap=new Map,this.recentlyDeletedLimit=200,this.relayMessageCache=[],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(v$4)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},cjs$4.toMiliseconds(this.requestQueueDelay)))},this.connect=async io=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const fo=D$3(I$2({},io),{requiredNamespaces:io.requiredNamespaces||{},optionalNamespaces:io.optionalNamespaces||{}});await this.isValidConnect(fo);const{pairingTopic:$o,requiredNamespaces:mo,optionalNamespaces:Ao,sessionProperties:jo,relays:Lo}=fo;let Ho=$o,zo,Go=!1;try{Ho&&(Go=this.client.core.pairing.pairings.get(Ho).active)}catch(xl){throw this.client.logger.error(`connect() -> pairing.get(${Ho}) failed`),xl}if(!Ho||!Go){const{topic:xl,uri:Il}=await this.client.core.pairing.create();Ho=xl,zo=Il}if(!Ho){const{message:xl}=xe$2("NO_MATCHING_KEY",`connect() pairing topic: ${Ho}`);throw new Error(xl)}const Vo=await this.client.core.crypto.generateKeyPair(),Yo=v$4.wc_sessionPropose.req.ttl||cjs$4.FIVE_MINUTES,Xo=ws$1(Yo),is=I$2({requiredNamespaces:mo,optionalNamespaces:Ao,relays:Lo??[{protocol:at$1}],proposer:{publicKey:Vo,metadata:this.client.metadata},expiryTimestamp:Xo,pairingTopic:Ho},jo&&{sessionProperties:jo}),{reject:yl,resolve:us,done:hs}=gs(Yo,it);this.events.once(Ms$1("session_connect"),async({error:xl,session:Il})=>{if(xl)yl(xl);else if(Il){Il.self.publicKey=Vo;const Ol=D$3(I$2({},Il),{pairingTopic:is.pairingTopic,requiredNamespaces:is.requiredNamespaces,optionalNamespaces:is.optionalNamespaces,transportType:F$2.relay});await this.client.session.set(Il.topic,Ol),await this.setExpiry(Il.topic,Il.expiry),Ho&&await this.client.core.pairing.updateMetadata({topic:Ho,metadata:Il.peer.metadata}),this.cleanupDuplicatePairings(Ol),us(Ol)}});const _l=await this.sendRequest({topic:Ho,method:"wc_sessionPropose",params:is,throwOnFailedPublish:!0});return await this.setProposal(_l,I$2({id:_l},is)),{uri:zo,approval:hs}},this.pair=async io=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(io)}catch(fo){throw this.client.logger.error("pair() failed"),fo}},this.approve=async io=>{var fo,$o,mo;const Ao=this.client.core.eventClient.createEvent({properties:{topic:(fo=io==null?void 0:io.id)==null?void 0:fo.toString(),trace:[Cs.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(Cl){throw Ao.setError(Ss$1.no_internet_connection),Cl}try{await this.isValidProposalId(io==null?void 0:io.id)}catch(Cl){throw this.client.logger.error(`approve() -> proposal.get(${io==null?void 0:io.id}) failed`),Ao.setError(Ss$1.proposal_not_found),Cl}try{await this.isValidApprove(io)}catch(Cl){throw this.client.logger.error("approve() -> isValidApprove() failed"),Ao.setError(Ss$1.session_approve_namespace_validation_failure),Cl}const{id:jo,relayProtocol:Lo,namespaces:Ho,sessionProperties:zo,sessionConfig:Go}=io,Vo=this.client.proposal.get(jo);this.client.core.eventClient.deleteEvent({eventId:Ao.eventId});const{pairingTopic:Yo,proposer:Xo,requiredNamespaces:is,optionalNamespaces:yl}=Vo;let us=($o=this.client.core.eventClient)==null?void 0:$o.getEvent({topic:Yo});us||(us=(mo=this.client.core.eventClient)==null?void 0:mo.createEvent({type:Cs.session_approve_started,properties:{topic:Yo,trace:[Cs.session_approve_started,Cs.session_namespaces_validation_success]}}));const hs=await this.client.core.crypto.generateKeyPair(),_l=Xo.publicKey,xl=await this.client.core.crypto.generateSharedKey(hs,_l),Il=I$2(I$2({relay:{protocol:Lo??"irn"},namespaces:Ho,controller:{publicKey:hs,metadata:this.client.metadata},expiry:ws$1(z$3)},zo&&{sessionProperties:zo}),Go&&{sessionConfig:Go}),Ol=F$2.relay;us.addTrace(Cs.subscribing_session_topic);try{await this.client.core.relayer.subscribe(xl,{transportType:Ol})}catch(Cl){throw us.setError(Ss$1.subscribe_session_topic_failure),Cl}us.addTrace(Cs.subscribe_session_topic_success);const Tl=D$3(I$2({},Il),{topic:xl,requiredNamespaces:is,optionalNamespaces:yl,pairingTopic:Yo,acknowledged:!1,self:Il.controller,peer:{publicKey:Xo.publicKey,metadata:Xo.metadata},controller:hs,transportType:F$2.relay});await this.client.session.set(xl,Tl),us.addTrace(Cs.store_session);try{us.addTrace(Cs.publishing_session_settle),await this.sendRequest({topic:xl,method:"wc_sessionSettle",params:Il,throwOnFailedPublish:!0}).catch(Cl=>{throw us==null||us.setError(Ss$1.session_settle_publish_failure),Cl}),us.addTrace(Cs.session_settle_publish_success),us.addTrace(Cs.publishing_session_approve),await this.sendResult({id:jo,topic:Yo,result:{relay:{protocol:Lo??"irn"},responderPublicKey:hs},throwOnFailedPublish:!0}).catch(Cl=>{throw us==null||us.setError(Ss$1.session_approve_publish_failure),Cl}),us.addTrace(Cs.session_approve_publish_success)}catch(Cl){throw this.client.logger.error(Cl),this.client.session.delete(xl,er$1("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(xl),Cl}return this.client.core.eventClient.deleteEvent({eventId:us.eventId}),await this.client.core.pairing.updateMetadata({topic:Yo,metadata:Xo.metadata}),await this.client.proposal.delete(jo,er$1("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:Yo}),await this.setExpiry(xl,ws$1(z$3)),{topic:xl,acknowledged:()=>Promise.resolve(this.client.session.get(xl))}},this.reject=async io=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(io)}catch(Ao){throw this.client.logger.error("reject() -> isValidReject() failed"),Ao}const{id:fo,reason:$o}=io;let mo;try{mo=this.client.proposal.get(fo).pairingTopic}catch(Ao){throw this.client.logger.error(`reject() -> proposal.get(${fo}) failed`),Ao}mo&&(await this.sendError({id:fo,topic:mo,error:$o,rpcOpts:v$4.wc_sessionPropose.reject}),await this.client.proposal.delete(fo,er$1("USER_DISCONNECTED")))},this.update=async io=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(io)}catch(Go){throw this.client.logger.error("update() -> isValidUpdate() failed"),Go}const{topic:fo,namespaces:$o}=io,{done:mo,resolve:Ao,reject:jo}=gs(),Lo=payloadId(),Ho=getBigIntRpcId().toString(),zo=this.client.session.get(fo).namespaces;return this.events.once(Ms$1("session_update",Lo),({error:Go})=>{Go?jo(Go):Ao()}),await this.client.session.update(fo,{namespaces:$o}),await this.sendRequest({topic:fo,method:"wc_sessionUpdate",params:{namespaces:$o},throwOnFailedPublish:!0,clientRpcId:Lo,relayRpcId:Ho}).catch(Go=>{this.client.logger.error(Go),this.client.session.update(fo,{namespaces:zo}),jo(Go)}),{acknowledged:mo}},this.extend=async io=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(io)}catch(Lo){throw this.client.logger.error("extend() -> isValidExtend() failed"),Lo}const{topic:fo}=io,$o=payloadId(),{done:mo,resolve:Ao,reject:jo}=gs();return this.events.once(Ms$1("session_extend",$o),({error:Lo})=>{Lo?jo(Lo):Ao()}),await this.setExpiry(fo,ws$1(z$3)),this.sendRequest({topic:fo,method:"wc_sessionExtend",params:{},clientRpcId:$o,throwOnFailedPublish:!0}).catch(Lo=>{jo(Lo)}),{acknowledged:mo}},this.request=async io=>{this.isInitialized();try{await this.isValidRequest(io)}catch(Xo){throw this.client.logger.error("request() -> isValidRequest() failed"),Xo}const{chainId:fo,request:$o,topic:mo,expiry:Ao=v$4.wc_sessionRequest.req.ttl}=io,jo=this.client.session.get(mo);(jo==null?void 0:jo.transportType)===F$2.relay&&await this.confirmOnlineStateOrThrow();const Lo=payloadId(),Ho=getBigIntRpcId().toString(),{done:zo,resolve:Go,reject:Vo}=gs(Ao,"Request expired. Please try again.");this.events.once(Ms$1("session_request",Lo),({error:Xo,result:is})=>{Xo?Vo(Xo):Go(is)});const Yo=this.getAppLinkIfEnabled(jo.peer.metadata,jo.transportType);return Yo?(await this.sendRequest({clientRpcId:Lo,relayRpcId:Ho,topic:mo,method:"wc_sessionRequest",params:{request:D$3(I$2({},$o),{expiryTimestamp:ws$1(Ao)}),chainId:fo},expiry:Ao,throwOnFailedPublish:!0,appLink:Yo}).catch(Xo=>Vo(Xo)),this.client.events.emit("session_request_sent",{topic:mo,request:$o,chainId:fo,id:Lo}),await zo()):await Promise.all([new Promise(async Xo=>{await this.sendRequest({clientRpcId:Lo,relayRpcId:Ho,topic:mo,method:"wc_sessionRequest",params:{request:D$3(I$2({},$o),{expiryTimestamp:ws$1(Ao)}),chainId:fo},expiry:Ao,throwOnFailedPublish:!0}).catch(is=>Vo(is)),this.client.events.emit("session_request_sent",{topic:mo,request:$o,chainId:fo,id:Lo}),Xo()}),new Promise(async Xo=>{var is;if(!((is=jo.sessionConfig)!=null&&is.disableDeepLink)){const yl=await Ss$2(this.client.core.storage,xe$1);await Es$2({id:Lo,topic:mo,wcDeepLink:yl})}Xo()}),zo()]).then(Xo=>Xo[2])},this.respond=async io=>{this.isInitialized(),await this.isValidRespond(io);const{topic:fo,response:$o}=io,{id:mo}=$o,Ao=this.client.session.get(fo);Ao.transportType===F$2.relay&&await this.confirmOnlineStateOrThrow();const jo=this.getAppLinkIfEnabled(Ao.peer.metadata,Ao.transportType);isJsonRpcResult($o)?await this.sendResult({id:mo,topic:fo,result:$o.result,throwOnFailedPublish:!0,appLink:jo}):isJsonRpcError($o)&&await this.sendError({id:mo,topic:fo,error:$o.error,appLink:jo}),this.cleanupAfterResponse(io)},this.ping=async io=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(io)}catch($o){throw this.client.logger.error("ping() -> isValidPing() failed"),$o}const{topic:fo}=io;if(this.client.session.keys.includes(fo)){const $o=payloadId(),mo=getBigIntRpcId().toString(),{done:Ao,resolve:jo,reject:Lo}=gs();this.events.once(Ms$1("session_ping",$o),({error:Ho})=>{Ho?Lo(Ho):jo()}),await Promise.all([this.sendRequest({topic:fo,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:$o,relayRpcId:mo}),Ao()])}else this.client.core.pairing.pairings.keys.includes(fo)&&await this.client.core.pairing.ping({topic:fo})},this.emit=async io=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(io);const{topic:fo,event:$o,chainId:mo}=io,Ao=getBigIntRpcId().toString();await this.sendRequest({topic:fo,method:"wc_sessionEvent",params:{event:$o,chainId:mo},throwOnFailedPublish:!0,relayRpcId:Ao})},this.disconnect=async io=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(io);const{topic:fo}=io;if(this.client.session.keys.includes(fo))await this.sendRequest({topic:fo,method:"wc_sessionDelete",params:er$1("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:fo,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(fo))await this.client.core.pairing.disconnect({topic:fo});else{const{message:$o}=xe$2("MISMATCHED_TOPIC",`Session or pairing topic not found: ${fo}`);throw new Error($o)}},this.find=io=>(this.isInitialized(),this.client.session.getAll().filter(fo=>hh$1(fo,io))),this.getPendingSessionRequests=()=>this.client.pendingRequest.getAll(),this.authenticate=async(io,fo)=>{var $o;this.isInitialized(),this.isValidAuthenticate(io);const mo=fo&&this.client.core.linkModeSupportedApps.includes(fo)&&(($o=this.client.metadata.redirect)==null?void 0:$o.linkMode),Ao=mo?F$2.link_mode:F$2.relay;Ao===F$2.relay&&await this.confirmOnlineStateOrThrow();const{chains:jo,statement:Lo="",uri:Ho,domain:zo,nonce:Go,type:Vo,exp:Yo,nbf:Xo,methods:is=[],expiry:yl}=io,us=[...io.resources||[]],{topic:hs,uri:_l}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:Ao});this.client.logger.info({message:"Generated new pairing",pairing:{topic:hs,uri:_l}});const xl=await this.client.core.crypto.generateKeyPair(),Il=Ru(xl);if(await Promise.all([this.client.auth.authKeys.set(ae$2,{responseTopic:Il,publicKey:xl}),this.client.auth.pairingTopics.set(Il,{topic:Il,pairingTopic:hs})]),await this.client.core.relayer.subscribe(Il,{transportType:Ao}),this.client.logger.info(`sending request to new pairing topic: ${hs}`),is.length>0){const{namespace:$l}=An$1(jo[0]);let El=xu($l,"request",is);Vr$1(us)&&(El=Mu(El,us.pop())),us.push(El)}const Ol=yl&&yl>v$4.wc_sessionAuthenticate.req.ttl?yl:v$4.wc_sessionAuthenticate.req.ttl,Tl={authPayload:{type:Vo??"caip122",chains:jo,statement:Lo,aud:Ho,domain:zo,version:"1",nonce:Go,iat:new Date().toISOString(),exp:Yo,nbf:Xo,resources:us},requester:{publicKey:xl,metadata:this.client.metadata},expiryTimestamp:ws$1(Ol)},Cl={eip155:{chains:jo,methods:[...new Set(["personal_sign",...is])],events:["chainChanged","accountsChanged"]}},Nl={requiredNamespaces:{},optionalNamespaces:Cl,relays:[{protocol:"irn"}],pairingTopic:hs,proposer:{publicKey:xl,metadata:this.client.metadata},expiryTimestamp:ws$1(v$4.wc_sessionPropose.req.ttl)},{done:Wl,resolve:Dl,reject:Rl}=gs(Ol,"Request expired"),Qo=async({error:$l,session:El})=>{if(this.events.off(Ms$1("session_request",rs),Jo),$l)Rl($l);else if(El){El.self.publicKey=xl,await this.client.session.set(El.topic,El),await this.setExpiry(El.topic,El.expiry),hs&&await this.client.core.pairing.updateMetadata({topic:hs,metadata:El.peer.metadata});const ds=this.client.session.get(El.topic);await this.deleteProposal(ps),Dl({session:ds})}},Jo=async $l=>{var El,ds,os;if(await this.deletePendingAuthRequest(rs,{message:"fulfilled",code:0}),$l.error){const Fl=er$1("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return $l.error.code===Fl.code?void 0:(this.events.off(Ms$1("session_connect"),Qo),Rl($l.error.message))}await this.deleteProposal(ps),this.events.off(Ms$1("session_connect"),Qo);const{cacaos:Al,responder:Ul}=$l.result,Zl=[],Pl=[];for(const Fl of Al){await mu({cacao:Fl,projectId:this.client.core.projectId})||(this.client.logger.error(Fl,"Signature verification failed"),Rl(er$1("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:Yl}=Fl,Bl=Vr$1(Yl.resources),Kl=[gu(Yl.iss)],Gl=Vi$1(Yl.iss);if(Bl){const fu=Eu(Bl),bu=Su(Bl);Zl.push(...fu),Kl.push(...bu)}for(const fu of Kl)Pl.push(`${fu}:${Gl}`)}const Hl=await this.client.core.crypto.generateSharedKey(xl,Ul.publicKey);let Ml;Zl.length>0&&(Ml={topic:Hl,acknowledged:!0,self:{publicKey:xl,metadata:this.client.metadata},peer:Ul,controller:Ul.publicKey,expiry:ws$1(z$3),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:hs,namespaces:uh$1([...new Set(Zl)],[...new Set(Pl)]),transportType:Ao},await this.client.core.relayer.subscribe(Hl,{transportType:Ao}),await this.client.session.set(Hl,Ml),hs&&await this.client.core.pairing.updateMetadata({topic:hs,metadata:Ul.metadata}),Ml=this.client.session.get(Hl)),(El=this.client.metadata.redirect)!=null&&El.linkMode&&(ds=Ul.metadata.redirect)!=null&&ds.linkMode&&(os=Ul.metadata.redirect)!=null&&os.universal&&fo&&(this.client.core.addLinkModeSupportedApp(Ul.metadata.redirect.universal),this.client.session.update(Hl,{transportType:F$2.link_mode})),Dl({auths:Al,session:Ml})},rs=payloadId(),ps=payloadId();this.events.once(Ms$1("session_connect"),Qo),this.events.once(Ms$1("session_request",rs),Jo);let _c;try{if(mo){const $l=formatJsonRpcRequest("wc_sessionAuthenticate",Tl,rs);this.client.core.history.set(hs,$l);const El=await this.client.core.crypto.encode("",$l,{type:Sr$1,encoding:Iu});_c=Zu(fo,hs,El)}else await Promise.all([this.sendRequest({topic:hs,method:"wc_sessionAuthenticate",params:Tl,expiry:io.expiry,throwOnFailedPublish:!0,clientRpcId:rs}),this.sendRequest({topic:hs,method:"wc_sessionPropose",params:Nl,expiry:v$4.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:ps})])}catch($l){throw this.events.off(Ms$1("session_connect"),Qo),this.events.off(Ms$1("session_request",rs),Jo),$l}return await this.setProposal(ps,I$2({id:ps},Nl)),await this.setAuthRequest(rs,{request:D$3(I$2({},Tl),{verifyContext:{}}),pairingTopic:hs,transportType:Ao}),{uri:_c??_l,response:Wl}},this.approveSessionAuthenticate=async io=>{const{id:fo,auths:$o}=io,mo=this.client.core.eventClient.createEvent({properties:{topic:fo.toString(),trace:[Ps$1.authenticated_session_approve_started]}});try{this.isInitialized()}catch(yl){throw mo.setError(Rs$1.no_internet_connection),yl}const Ao=this.getPendingAuthRequest(fo);if(!Ao)throw mo.setError(Rs$1.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${fo}`);const jo=Ao.transportType||F$2.relay;jo===F$2.relay&&await this.confirmOnlineStateOrThrow();const Lo=Ao.requester.publicKey,Ho=await this.client.core.crypto.generateKeyPair(),zo=Ru(Lo),Go={type:pr$2,receiverPublicKey:Lo,senderPublicKey:Ho},Vo=[],Yo=[];for(const yl of $o){if(!await mu({cacao:yl,projectId:this.client.core.projectId})){mo.setError(Rs$1.invalid_cacao);const Il=er$1("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:fo,topic:zo,error:Il,encodeOpts:Go}),new Error(Il.message)}mo.addTrace(Ps$1.cacaos_verified);const{p:us}=yl,hs=Vr$1(us.resources),_l=[gu(us.iss)],xl=Vi$1(us.iss);if(hs){const Il=Eu(hs),Ol=Su(hs);Vo.push(...Il),_l.push(...Ol)}for(const Il of _l)Yo.push(`${Il}:${xl}`)}const Xo=await this.client.core.crypto.generateSharedKey(Ho,Lo);mo.addTrace(Ps$1.create_authenticated_session_topic);let is;if((Vo==null?void 0:Vo.length)>0){is={topic:Xo,acknowledged:!0,self:{publicKey:Ho,metadata:this.client.metadata},peer:{publicKey:Lo,metadata:Ao.requester.metadata},controller:Lo,expiry:ws$1(z$3),authentication:$o,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:Ao.pairingTopic,namespaces:uh$1([...new Set(Vo)],[...new Set(Yo)]),transportType:jo},mo.addTrace(Ps$1.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(Xo,{transportType:jo})}catch(yl){throw mo.setError(Rs$1.subscribe_authenticated_session_topic_failure),yl}mo.addTrace(Ps$1.subscribe_authenticated_session_topic_success),await this.client.session.set(Xo,is),mo.addTrace(Ps$1.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:Ao.pairingTopic,metadata:Ao.requester.metadata})}mo.addTrace(Ps$1.publishing_authenticated_session_approve);try{await this.sendResult({topic:zo,id:fo,result:{cacaos:$o,responder:{publicKey:Ho,metadata:this.client.metadata}},encodeOpts:Go,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(Ao.requester.metadata,jo)})}catch(yl){throw mo.setError(Rs$1.authenticated_session_approve_publish_failure),yl}return await this.client.auth.requests.delete(fo,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:Ao.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:mo.eventId}),{session:is}},this.rejectSessionAuthenticate=async io=>{this.isInitialized();const{id:fo,reason:$o}=io,mo=this.getPendingAuthRequest(fo);if(!mo)throw new Error(`Could not find pending auth request with id ${fo}`);mo.transportType===F$2.relay&&await this.confirmOnlineStateOrThrow();const Ao=mo.requester.publicKey,jo=await this.client.core.crypto.generateKeyPair(),Lo=Ru(Ao),Ho={type:pr$2,receiverPublicKey:Ao,senderPublicKey:jo};await this.sendError({id:fo,topic:Lo,error:$o,encodeOpts:Ho,rpcOpts:v$4.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(mo.requester.metadata,mo.transportType)}),await this.client.auth.requests.delete(fo,{message:"rejected",code:0}),await this.client.proposal.delete(fo,er$1("USER_DISCONNECTED"))},this.formatAuthMessage=io=>{this.isInitialized();const{request:fo,iss:$o}=io;return Wf$1(fo,$o)},this.processRelayMessageCache=()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const io=this.relayMessageCache.shift();io&&await this.onRelayMessage(io)}catch(io){this.client.logger.error(io)}},50)},this.cleanupDuplicatePairings=async io=>{if(io.pairingTopic)try{const fo=this.client.core.pairing.pairings.get(io.pairingTopic),$o=this.client.core.pairing.pairings.getAll().filter(mo=>{var Ao,jo;return((Ao=mo.peerMetadata)==null?void 0:Ao.url)&&((jo=mo.peerMetadata)==null?void 0:jo.url)===io.peer.metadata.url&&mo.topic&&mo.topic!==fo.topic});if($o.length===0)return;this.client.logger.info(`Cleaning up ${$o.length} duplicate pairing(s)`),await Promise.all($o.map(mo=>this.client.core.pairing.disconnect({topic:mo.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(fo){this.client.logger.error(fo)}},this.deleteSession=async io=>{var fo;const{topic:$o,expirerHasDeleted:mo=!1,emitEvent:Ao=!0,id:jo=0}=io,{self:Lo}=this.client.session.get($o);await this.client.core.relayer.unsubscribe($o),await this.client.session.delete($o,er$1("USER_DISCONNECTED")),this.addToRecentlyDeleted($o,"session"),this.client.core.crypto.keychain.has(Lo.publicKey)&&await this.client.core.crypto.deleteKeyPair(Lo.publicKey),this.client.core.crypto.keychain.has($o)&&await this.client.core.crypto.deleteSymKey($o),mo||this.client.core.expirer.del($o),this.client.core.storage.removeItem(xe$1).catch(Ho=>this.client.logger.warn(Ho)),this.getPendingSessionRequests().forEach(Ho=>{Ho.topic===$o&&this.deletePendingSessionRequest(Ho.id,er$1("USER_DISCONNECTED"))}),$o===((fo=this.sessionRequestQueue.queue[0])==null?void 0:fo.topic)&&(this.sessionRequestQueue.state=x$2.idle),Ao&&this.client.events.emit("session_delete",{id:jo,topic:$o})},this.deleteProposal=async(io,fo)=>{if(fo)try{const $o=this.client.proposal.get(io),mo=this.client.core.eventClient.getEvent({topic:$o.pairingTopic});mo==null||mo.setError(Ss$1.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(io,er$1("USER_DISCONNECTED")),fo?Promise.resolve():this.client.core.expirer.del(io)]),this.addToRecentlyDeleted(io,"proposal")},this.deletePendingSessionRequest=async(io,fo,$o=!1)=>{await Promise.all([this.client.pendingRequest.delete(io,fo),$o?Promise.resolve():this.client.core.expirer.del(io)]),this.addToRecentlyDeleted(io,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(mo=>mo.id!==io),$o&&(this.sessionRequestQueue.state=x$2.idle,this.client.events.emit("session_request_expire",{id:io}))},this.deletePendingAuthRequest=async(io,fo,$o=!1)=>{await Promise.all([this.client.auth.requests.delete(io,fo),$o?Promise.resolve():this.client.core.expirer.del(io)])},this.setExpiry=async(io,fo)=>{this.client.session.keys.includes(io)&&(this.client.core.expirer.set(io,fo),await this.client.session.update(io,{expiry:fo}))},this.setProposal=async(io,fo)=>{this.client.core.expirer.set(io,ws$1(v$4.wc_sessionPropose.req.ttl)),await this.client.proposal.set(io,fo)},this.setAuthRequest=async(io,fo)=>{const{request:$o,pairingTopic:mo,transportType:Ao=F$2.relay}=fo;this.client.core.expirer.set(io,$o.expiryTimestamp),await this.client.auth.requests.set(io,{authPayload:$o.authPayload,requester:$o.requester,expiryTimestamp:$o.expiryTimestamp,id:io,pairingTopic:mo,verifyContext:$o.verifyContext,transportType:Ao})},this.setPendingSessionRequest=async io=>{const{id:fo,topic:$o,params:mo,verifyContext:Ao}=io,jo=mo.request.expiryTimestamp||ws$1(v$4.wc_sessionRequest.req.ttl);this.client.core.expirer.set(fo,jo),await this.client.pendingRequest.set(fo,{id:fo,topic:$o,params:mo,verifyContext:Ao})},this.sendRequest=async io=>{const{topic:fo,method:$o,params:mo,expiry:Ao,relayRpcId:jo,clientRpcId:Lo,throwOnFailedPublish:Ho,appLink:zo}=io,Go=formatJsonRpcRequest($o,mo,Lo);let Vo;const Yo=!!zo;try{const yl=Yo?Iu:tn$1;Vo=await this.client.core.crypto.encode(fo,Go,{encoding:yl})}catch(yl){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${fo} failed`),yl}let Xo;if(at.includes($o)){const yl=Ou(JSON.stringify(Go)),us=Ou(Vo);Xo=await this.client.core.verify.register({id:us,decryptedId:yl})}const is=v$4[$o].req;if(is.attestation=Xo,Ao&&(is.ttl=Ao),jo&&(is.id=jo),this.client.core.history.set(fo,Go),Yo){const yl=Zu(zo,fo,Vo);await global$o.Linking.openURL(yl,this.client.name)}else{const yl=v$4[$o].req;Ao&&(yl.ttl=Ao),jo&&(yl.id=jo),Ho?(yl.internal=D$3(I$2({},yl.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(fo,Vo,yl)):this.client.core.relayer.publish(fo,Vo,yl).catch(us=>this.client.logger.error(us))}return Go.id},this.sendResult=async io=>{const{id:fo,topic:$o,result:mo,throwOnFailedPublish:Ao,encodeOpts:jo,appLink:Lo}=io,Ho=formatJsonRpcResult(fo,mo);let zo;const Go=Lo&&typeof(global$o==null?void 0:global$o.Linking)<"u";try{const Yo=Go?Iu:tn$1;zo=await this.client.core.crypto.encode($o,Ho,D$3(I$2({},jo||{}),{encoding:Yo}))}catch(Yo){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${$o} failed`),Yo}let Vo;try{Vo=await this.client.core.history.get($o,fo)}catch(Yo){throw this.client.logger.error(`sendResult() -> history.get(${$o}, ${fo}) failed`),Yo}if(Go){const Yo=Zu(Lo,$o,zo);await global$o.Linking.openURL(Yo,this.client.name)}else{const Yo=v$4[Vo.request.method].res;Ao?(Yo.internal=D$3(I$2({},Yo.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish($o,zo,Yo)):this.client.core.relayer.publish($o,zo,Yo).catch(Xo=>this.client.logger.error(Xo))}await this.client.core.history.resolve(Ho)},this.sendError=async io=>{const{id:fo,topic:$o,error:mo,encodeOpts:Ao,rpcOpts:jo,appLink:Lo}=io,Ho=formatJsonRpcError(fo,mo);let zo;const Go=Lo&&typeof(global$o==null?void 0:global$o.Linking)<"u";try{const Yo=Go?Iu:tn$1;zo=await this.client.core.crypto.encode($o,Ho,D$3(I$2({},Ao||{}),{encoding:Yo}))}catch(Yo){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${$o} failed`),Yo}let Vo;try{Vo=await this.client.core.history.get($o,fo)}catch(Yo){throw this.client.logger.error(`sendError() -> history.get(${$o}, ${fo}) failed`),Yo}if(Go){const Yo=Zu(Lo,$o,zo);await global$o.Linking.openURL(Yo,this.client.name)}else{const Yo=jo||v$4[Vo.request.method].res;this.client.core.relayer.publish($o,zo,Yo)}await this.client.core.history.resolve(Ho)},this.cleanup=async()=>{const io=[],fo=[];this.client.session.getAll().forEach($o=>{let mo=!1;xs$1($o.expiry)&&(mo=!0),this.client.core.crypto.keychain.has($o.topic)||(mo=!0),mo&&io.push($o.topic)}),this.client.proposal.getAll().forEach($o=>{xs$1($o.expiryTimestamp)&&fo.push($o.id)}),await Promise.all([...io.map($o=>this.deleteSession({topic:$o})),...fo.map($o=>this.deleteProposal($o))])},this.onRelayEventRequest=async io=>{this.requestQueue.queue.push(io),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===x$2.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=x$2.active;const io=this.requestQueue.queue.shift();if(io)try{await this.processRequest(io)}catch(fo){this.client.logger.warn(fo)}}this.requestQueue.state=x$2.idle},this.processRequest=async io=>{const{topic:fo,payload:$o,attestation:mo,transportType:Ao,encryptedId:jo}=io,Lo=$o.method;if(!this.shouldIgnorePairingRequest({topic:fo,requestMethod:Lo}))switch(Lo){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:fo,payload:$o,attestation:mo,encryptedId:jo});case"wc_sessionSettle":return await this.onSessionSettleRequest(fo,$o);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(fo,$o);case"wc_sessionExtend":return await this.onSessionExtendRequest(fo,$o);case"wc_sessionPing":return await this.onSessionPingRequest(fo,$o);case"wc_sessionDelete":return await this.onSessionDeleteRequest(fo,$o);case"wc_sessionRequest":return await this.onSessionRequest({topic:fo,payload:$o,attestation:mo,encryptedId:jo,transportType:Ao});case"wc_sessionEvent":return await this.onSessionEventRequest(fo,$o);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:fo,payload:$o,attestation:mo,encryptedId:jo,transportType:Ao});default:return this.client.logger.info(`Unsupported request method ${Lo}`)}},this.onRelayEventResponse=async io=>{const{topic:fo,payload:$o,transportType:mo}=io,Ao=(await this.client.core.history.get(fo,$o.id)).request.method;switch(Ao){case"wc_sessionPropose":return this.onSessionProposeResponse(fo,$o,mo);case"wc_sessionSettle":return this.onSessionSettleResponse(fo,$o);case"wc_sessionUpdate":return this.onSessionUpdateResponse(fo,$o);case"wc_sessionExtend":return this.onSessionExtendResponse(fo,$o);case"wc_sessionPing":return this.onSessionPingResponse(fo,$o);case"wc_sessionRequest":return this.onSessionRequestResponse(fo,$o);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(fo,$o);default:return this.client.logger.info(`Unsupported response method ${Ao}`)}},this.onRelayEventUnknownPayload=io=>{const{topic:fo}=io,{message:$o}=xe$2("MISSING_OR_INVALID",`Decoded payload on topic ${fo} is not identifiable as a JSON-RPC request or a response.`);throw new Error($o)},this.shouldIgnorePairingRequest=io=>{const{topic:fo,requestMethod:$o}=io,mo=this.expectedPairingMethodMap.get(fo);return!mo||mo.includes($o)?!1:!!(mo.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)},this.onSessionProposeRequest=async io=>{const{topic:fo,payload:$o,attestation:mo,encryptedId:Ao}=io,{params:jo,id:Lo}=$o;try{const Ho=this.client.core.eventClient.getEvent({topic:fo});this.isValidConnect(I$2({},$o.params));const zo=jo.expiryTimestamp||ws$1(v$4.wc_sessionPropose.req.ttl),Go=I$2({id:Lo,pairingTopic:fo,expiryTimestamp:zo},jo);await this.setProposal(Lo,Go);const Vo=await this.getVerifyContext({attestationId:mo,hash:Ou(JSON.stringify($o)),encryptedId:Ao,metadata:Go.proposer.metadata});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),Ho==null||Ho.setError(M$3.proposal_listener_not_found)),Ho==null||Ho.addTrace(z$4.emit_session_proposal),this.client.events.emit("session_proposal",{id:Lo,params:Go,verifyContext:Vo})}catch(Ho){await this.sendError({id:Lo,topic:fo,error:Ho,rpcOpts:v$4.wc_sessionPropose.autoReject}),this.client.logger.error(Ho)}},this.onSessionProposeResponse=async(io,fo,$o)=>{const{id:mo}=fo;if(isJsonRpcResult(fo)){const{result:Ao}=fo;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:Ao});const jo=this.client.proposal.get(mo);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:jo});const Lo=jo.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:Lo});const Ho=Ao.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:Ho});const zo=await this.client.core.crypto.generateSharedKey(Lo,Ho);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:zo});const Go=await this.client.core.relayer.subscribe(zo,{transportType:$o});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:Go}),await this.client.core.pairing.activate({topic:io})}else if(isJsonRpcError(fo)){await this.client.proposal.delete(mo,er$1("USER_DISCONNECTED"));const Ao=Ms$1("session_connect");if(this.events.listenerCount(Ao)===0)throw new Error(`emitting ${Ao} without any listeners, 954`);this.events.emit(Ms$1("session_connect"),{error:fo.error})}},this.onSessionSettleRequest=async(io,fo)=>{const{id:$o,params:mo}=fo;try{this.isValidSessionSettleRequest(mo);const{relay:Ao,controller:jo,expiry:Lo,namespaces:Ho,sessionProperties:zo,sessionConfig:Go}=fo.params,Vo=D$3(I$2(I$2({topic:io,relay:Ao,expiry:Lo,namespaces:Ho,acknowledged:!0,pairingTopic:"",requiredNamespaces:{},optionalNamespaces:{},controller:jo.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:jo.publicKey,metadata:jo.metadata}},zo&&{sessionProperties:zo}),Go&&{sessionConfig:Go}),{transportType:F$2.relay}),Yo=Ms$1("session_connect");if(this.events.listenerCount(Yo)===0)throw new Error(`emitting ${Yo} without any listeners 997`);this.events.emit(Ms$1("session_connect"),{session:Vo}),await this.sendResult({id:fo.id,topic:io,result:!0,throwOnFailedPublish:!0})}catch(Ao){await this.sendError({id:$o,topic:io,error:Ao}),this.client.logger.error(Ao)}},this.onSessionSettleResponse=async(io,fo)=>{const{id:$o}=fo;isJsonRpcResult(fo)?(await this.client.session.update(io,{acknowledged:!0}),this.events.emit(Ms$1("session_approve",$o),{})):isJsonRpcError(fo)&&(await this.client.session.delete(io,er$1("USER_DISCONNECTED")),this.events.emit(Ms$1("session_approve",$o),{error:fo.error}))},this.onSessionUpdateRequest=async(io,fo)=>{const{params:$o,id:mo}=fo;try{const Ao=`${io}_session_update`,jo=Rh$1.get(Ao);if(jo&&this.isRequestOutOfSync(jo,mo)){this.client.logger.info(`Discarding out of sync request - ${mo}`),this.sendError({id:mo,topic:io,error:er$1("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(I$2({topic:io},$o));try{Rh$1.set(Ao,mo),await this.client.session.update(io,{namespaces:$o.namespaces}),await this.sendResult({id:mo,topic:io,result:!0,throwOnFailedPublish:!0})}catch(Lo){throw Rh$1.delete(Ao),Lo}this.client.events.emit("session_update",{id:mo,topic:io,params:$o})}catch(Ao){await this.sendError({id:mo,topic:io,error:Ao}),this.client.logger.error(Ao)}},this.isRequestOutOfSync=(io,fo)=>parseInt(fo.toString().slice(0,-3))<=parseInt(io.toString().slice(0,-3)),this.onSessionUpdateResponse=(io,fo)=>{const{id:$o}=fo,mo=Ms$1("session_update",$o);if(this.events.listenerCount(mo)===0)throw new Error(`emitting ${mo} without any listeners`);isJsonRpcResult(fo)?this.events.emit(Ms$1("session_update",$o),{}):isJsonRpcError(fo)&&this.events.emit(Ms$1("session_update",$o),{error:fo.error})},this.onSessionExtendRequest=async(io,fo)=>{const{id:$o}=fo;try{this.isValidExtend({topic:io}),await this.setExpiry(io,ws$1(z$3)),await this.sendResult({id:$o,topic:io,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:$o,topic:io})}catch(mo){await this.sendError({id:$o,topic:io,error:mo}),this.client.logger.error(mo)}},this.onSessionExtendResponse=(io,fo)=>{const{id:$o}=fo,mo=Ms$1("session_extend",$o);if(this.events.listenerCount(mo)===0)throw new Error(`emitting ${mo} without any listeners`);isJsonRpcResult(fo)?this.events.emit(Ms$1("session_extend",$o),{}):isJsonRpcError(fo)&&this.events.emit(Ms$1("session_extend",$o),{error:fo.error})},this.onSessionPingRequest=async(io,fo)=>{const{id:$o}=fo;try{this.isValidPing({topic:io}),await this.sendResult({id:$o,topic:io,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:$o,topic:io})}catch(mo){await this.sendError({id:$o,topic:io,error:mo}),this.client.logger.error(mo)}},this.onSessionPingResponse=(io,fo)=>{const{id:$o}=fo,mo=Ms$1("session_ping",$o);if(this.events.listenerCount(mo)===0)throw new Error(`emitting ${mo} without any listeners`);setTimeout(()=>{isJsonRpcResult(fo)?this.events.emit(Ms$1("session_ping",$o),{}):isJsonRpcError(fo)&&this.events.emit(Ms$1("session_ping",$o),{error:fo.error})},500)},this.onSessionDeleteRequest=async(io,fo)=>{const{id:$o}=fo;try{this.isValidDisconnect({topic:io,reason:fo.params}),Promise.all([new Promise(mo=>{this.client.core.relayer.once(w$2.publish,async()=>{mo(await this.deleteSession({topic:io,id:$o}))})}),this.sendResult({id:$o,topic:io,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:io,error:er$1("USER_DISCONNECTED")})]).catch(mo=>this.client.logger.error(mo))}catch(mo){this.client.logger.error(mo)}},this.onSessionRequest=async io=>{var fo,$o,mo;const{topic:Ao,payload:jo,attestation:Lo,encryptedId:Ho,transportType:zo}=io,{id:Go,params:Vo}=jo;try{await this.isValidRequest(I$2({topic:Ao},Vo));const Yo=this.client.session.get(Ao),Xo=await this.getVerifyContext({attestationId:Lo,hash:Ou(JSON.stringify(formatJsonRpcRequest("wc_sessionRequest",Vo,Go))),encryptedId:Ho,metadata:Yo.peer.metadata,transportType:zo}),is={id:Go,topic:Ao,params:Vo,verifyContext:Xo};await this.setPendingSessionRequest(is),zo===F$2.link_mode&&(fo=Yo.peer.metadata.redirect)!=null&&fo.universal&&this.client.core.addLinkModeSupportedApp(($o=Yo.peer.metadata.redirect)==null?void 0:$o.universal),(mo=this.client.signConfig)!=null&&mo.disableRequestQueue?this.emitSessionRequest(is):(this.addSessionRequestToSessionRequestQueue(is),this.processSessionRequestQueue())}catch(Yo){await this.sendError({id:Go,topic:Ao,error:Yo}),this.client.logger.error(Yo)}},this.onSessionRequestResponse=(io,fo)=>{const{id:$o}=fo,mo=Ms$1("session_request",$o);if(this.events.listenerCount(mo)===0)throw new Error(`emitting ${mo} without any listeners`);isJsonRpcResult(fo)?this.events.emit(Ms$1("session_request",$o),{result:fo.result}):isJsonRpcError(fo)&&this.events.emit(Ms$1("session_request",$o),{error:fo.error})},this.onSessionEventRequest=async(io,fo)=>{const{id:$o,params:mo}=fo;try{const Ao=`${io}_session_event_${mo.event.name}`,jo=Rh$1.get(Ao);if(jo&&this.isRequestOutOfSync(jo,$o)){this.client.logger.info(`Discarding out of sync request - ${$o}`);return}this.isValidEmit(I$2({topic:io},mo)),this.client.events.emit("session_event",{id:$o,topic:io,params:mo}),Rh$1.set(Ao,$o)}catch(Ao){await this.sendError({id:$o,topic:io,error:Ao}),this.client.logger.error(Ao)}},this.onSessionAuthenticateResponse=(io,fo)=>{const{id:$o}=fo;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:io,payload:fo}),isJsonRpcResult(fo)?this.events.emit(Ms$1("session_request",$o),{result:fo.result}):isJsonRpcError(fo)&&this.events.emit(Ms$1("session_request",$o),{error:fo.error})},this.onSessionAuthenticateRequest=async io=>{var fo;const{topic:$o,payload:mo,attestation:Ao,encryptedId:jo,transportType:Lo}=io;try{const{requester:Ho,authPayload:zo,expiryTimestamp:Go}=mo.params,Vo=await this.getVerifyContext({attestationId:Ao,hash:Ou(JSON.stringify(mo)),encryptedId:jo,metadata:Ho.metadata,transportType:Lo}),Yo={requester:Ho,pairingTopic:$o,id:mo.id,authPayload:zo,verifyContext:Vo,expiryTimestamp:Go};await this.setAuthRequest(mo.id,{request:Yo,pairingTopic:$o,transportType:Lo}),Lo===F$2.link_mode&&(fo=Ho.metadata.redirect)!=null&&fo.universal&&this.client.core.addLinkModeSupportedApp(Ho.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:$o,params:mo.params,id:mo.id,verifyContext:Vo})}catch(Ho){this.client.logger.error(Ho);const zo=mo.params.requester.publicKey,Go=await this.client.core.crypto.generateKeyPair(),Vo=this.getAppLinkIfEnabled(mo.params.requester.metadata,Lo),Yo={type:pr$2,receiverPublicKey:zo,senderPublicKey:Go};await this.sendError({id:mo.id,topic:$o,error:Ho,encodeOpts:Yo,rpcOpts:v$4.wc_sessionAuthenticate.autoReject,appLink:Vo})}},this.addSessionRequestToSessionRequestQueue=io=>{this.sessionRequestQueue.queue.push(io)},this.cleanupAfterResponse=io=>{this.deletePendingSessionRequest(io.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=x$2.idle,this.processSessionRequestQueue()},cjs$4.toMiliseconds(this.requestQueueDelay))},this.cleanupPendingSentRequestsForTopic=({topic:io,error:fo})=>{const $o=this.client.core.history.pending;$o.length>0&&$o.filter(mo=>mo.topic===io&&mo.request.method==="wc_sessionRequest").forEach(mo=>{const Ao=mo.request.id,jo=Ms$1("session_request",Ao);if(this.events.listenerCount(jo)===0)throw new Error(`emitting ${jo} without any listeners`);this.events.emit(Ms$1("session_request",mo.request.id),{error:fo})})},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===x$2.active){this.client.logger.info("session request queue is already active.");return}const io=this.sessionRequestQueue.queue[0];if(!io){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=x$2.active,this.emitSessionRequest(io)}catch(fo){this.client.logger.error(fo)}},this.emitSessionRequest=io=>{this.client.events.emit("session_request",io)},this.onPairingCreated=io=>{if(io.methods&&this.expectedPairingMethodMap.set(io.topic,io.methods),io.active)return;const fo=this.client.proposal.getAll().find($o=>$o.pairingTopic===io.topic);fo&&this.onSessionProposeRequest({topic:io.topic,payload:formatJsonRpcRequest("wc_sessionPropose",{requiredNamespaces:fo.requiredNamespaces,optionalNamespaces:fo.optionalNamespaces,relays:fo.relays,proposer:fo.proposer,sessionProperties:fo.sessionProperties},fo.id)})},this.isValidConnect=async io=>{if(!Ah$1(io)){const{message:Lo}=xe$2("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(io)}`);throw new Error(Lo)}const{pairingTopic:fo,requiredNamespaces:$o,optionalNamespaces:mo,sessionProperties:Ao,relays:jo}=io;if(Pe$1(fo)||await this.isValidPairingTopic(fo),!gh$1(jo)){const{message:Lo}=xe$2("MISSING_OR_INVALID",`connect() relays: ${jo}`);throw new Error(Lo)}!Pe$1($o)&&Xr$1($o)!==0&&this.validateNamespaces($o,"requiredNamespaces"),!Pe$1(mo)&&Xr$1(mo)!==0&&this.validateNamespaces(mo,"optionalNamespaces"),Pe$1(Ao)||this.validateSessionProps(Ao,"sessionProperties")},this.validateNamespaces=(io,fo)=>{const $o=vh$2(io,"connect()",fo);if($o)throw new Error($o.message)},this.isValidApprove=async io=>{if(!Ah$1(io))throw new Error(xe$2("MISSING_OR_INVALID",`approve() params: ${io}`).message);const{id:fo,namespaces:$o,relayProtocol:mo,sessionProperties:Ao}=io;this.checkRecentlyDeleted(fo),await this.isValidProposalId(fo);const jo=this.client.proposal.get(fo),Lo=Oo($o,"approve()");if(Lo)throw new Error(Lo.message);const Ho=To(jo.requiredNamespaces,$o,"approve()");if(Ho)throw new Error(Ho.message);if(!Yt$1(mo,!0)){const{message:zo}=xe$2("MISSING_OR_INVALID",`approve() relayProtocol: ${mo}`);throw new Error(zo)}Pe$1(Ao)||this.validateSessionProps(Ao,"sessionProperties")},this.isValidReject=async io=>{if(!Ah$1(io)){const{message:mo}=xe$2("MISSING_OR_INVALID",`reject() params: ${io}`);throw new Error(mo)}const{id:fo,reason:$o}=io;if(this.checkRecentlyDeleted(fo),await this.isValidProposalId(fo),!bh$1($o)){const{message:mo}=xe$2("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify($o)}`);throw new Error(mo)}},this.isValidSessionSettleRequest=io=>{if(!Ah$1(io)){const{message:Ho}=xe$2("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${io}`);throw new Error(Ho)}const{relay:fo,controller:$o,namespaces:mo,expiry:Ao}=io;if(!Po(fo)){const{message:Ho}=xe$2("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(Ho)}const jo=ph$1($o,"onSessionSettleRequest()");if(jo)throw new Error(jo.message);const Lo=Oo(mo,"onSessionSettleRequest()");if(Lo)throw new Error(Lo.message);if(xs$1(Ao)){const{message:Ho}=xe$2("EXPIRED","onSessionSettleRequest()");throw new Error(Ho)}},this.isValidUpdate=async io=>{if(!Ah$1(io)){const{message:Lo}=xe$2("MISSING_OR_INVALID",`update() params: ${io}`);throw new Error(Lo)}const{topic:fo,namespaces:$o}=io;this.checkRecentlyDeleted(fo),await this.isValidSessionTopic(fo);const mo=this.client.session.get(fo),Ao=Oo($o,"update()");if(Ao)throw new Error(Ao.message);const jo=To(mo.requiredNamespaces,$o,"update()");if(jo)throw new Error(jo.message)},this.isValidExtend=async io=>{if(!Ah$1(io)){const{message:$o}=xe$2("MISSING_OR_INVALID",`extend() params: ${io}`);throw new Error($o)}const{topic:fo}=io;this.checkRecentlyDeleted(fo),await this.isValidSessionTopic(fo)},this.isValidRequest=async io=>{if(!Ah$1(io)){const{message:Lo}=xe$2("MISSING_OR_INVALID",`request() params: ${io}`);throw new Error(Lo)}const{topic:fo,request:$o,chainId:mo,expiry:Ao}=io;this.checkRecentlyDeleted(fo),await this.isValidSessionTopic(fo);const{namespaces:jo}=this.client.session.get(fo);if(!Mh$1(jo,mo)){const{message:Lo}=xe$2("MISSING_OR_INVALID",`request() chainId: ${mo}`);throw new Error(Lo)}if(!yh$1($o)){const{message:Lo}=xe$2("MISSING_OR_INVALID",`request() ${JSON.stringify($o)}`);throw new Error(Lo)}if(!Eh$1(jo,mo,$o.method)){const{message:Lo}=xe$2("MISSING_OR_INVALID",`request() method: ${$o.method}`);throw new Error(Lo)}if(Ao&&!_h(Ao,me$1)){const{message:Lo}=xe$2("MISSING_OR_INVALID",`request() expiry: ${Ao}. Expiry must be a number (in seconds) between ${me$1.min} and ${me$1.max}`);throw new Error(Lo)}},this.isValidRespond=async io=>{var fo;if(!Ah$1(io)){const{message:Ao}=xe$2("MISSING_OR_INVALID",`respond() params: ${io}`);throw new Error(Ao)}const{topic:$o,response:mo}=io;try{await this.isValidSessionTopic($o)}catch(Ao){throw(fo=io==null?void 0:io.response)!=null&&fo.id&&this.cleanupAfterResponse(io),Ao}if(!wh$1(mo)){const{message:Ao}=xe$2("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(mo)}`);throw new Error(Ao)}},this.isValidPing=async io=>{if(!Ah$1(io)){const{message:$o}=xe$2("MISSING_OR_INVALID",`ping() params: ${io}`);throw new Error($o)}const{topic:fo}=io;await this.isValidSessionOrPairingTopic(fo)},this.isValidEmit=async io=>{if(!Ah$1(io)){const{message:jo}=xe$2("MISSING_OR_INVALID",`emit() params: ${io}`);throw new Error(jo)}const{topic:fo,event:$o,chainId:mo}=io;await this.isValidSessionTopic(fo);const{namespaces:Ao}=this.client.session.get(fo);if(!Mh$1(Ao,mo)){const{message:jo}=xe$2("MISSING_OR_INVALID",`emit() chainId: ${mo}`);throw new Error(jo)}if(!xh$1($o)){const{message:jo}=xe$2("MISSING_OR_INVALID",`emit() event: ${JSON.stringify($o)}`);throw new Error(jo)}if(!Sh$1(Ao,mo,$o.name)){const{message:jo}=xe$2("MISSING_OR_INVALID",`emit() event: ${JSON.stringify($o)}`);throw new Error(jo)}},this.isValidDisconnect=async io=>{if(!Ah$1(io)){const{message:$o}=xe$2("MISSING_OR_INVALID",`disconnect() params: ${io}`);throw new Error($o)}const{topic:fo}=io;await this.isValidSessionOrPairingTopic(fo)},this.isValidAuthenticate=io=>{const{chains:fo,uri:$o,domain:mo,nonce:Ao}=io;if(!Array.isArray(fo)||fo.length===0)throw new Error("chains is required and must be a non-empty array");if(!Yt$1($o,!1))throw new Error("uri is required parameter");if(!Yt$1(mo,!1))throw new Error("domain is required parameter");if(!Yt$1(Ao,!1))throw new Error("nonce is required parameter");if([...new Set(fo.map(Lo=>An$1(Lo).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:jo}=An$1(fo[0]);if(jo!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")},this.getVerifyContext=async io=>{const{attestationId:fo,hash:$o,encryptedId:mo,metadata:Ao,transportType:jo}=io,Lo={verified:{verifyUrl:Ao.verifyUrl||Z$1,validation:"UNKNOWN",origin:Ao.url||""}};try{if(jo===F$2.link_mode){const zo=this.getAppLinkIfEnabled(Ao,jo);return Lo.verified.validation=zo&&new URL(zo).origin===new URL(Ao.url).origin?"VALID":"INVALID",Lo}const Ho=await this.client.core.verify.resolve({attestationId:fo,hash:$o,encryptedId:mo,verifyUrl:Ao.verifyUrl});Ho&&(Lo.verified.origin=Ho.origin,Lo.verified.isScam=Ho.isScam,Lo.verified.validation=Ho.origin===new URL(Ao.url).origin?"VALID":"INVALID")}catch(Ho){this.client.logger.warn(Ho)}return this.client.logger.debug(`Verify context: ${JSON.stringify(Lo)}`),Lo},this.validateSessionProps=(io,fo)=>{Object.values(io).forEach($o=>{if(!Yt$1($o,!1)){const{message:mo}=xe$2("MISSING_OR_INVALID",`${fo} must be in Record<string, string> format. Received: ${JSON.stringify($o)}`);throw new Error(mo)}})},this.getPendingAuthRequest=io=>{const fo=this.client.auth.requests.get(io);return typeof fo=="object"?fo:void 0},this.addToRecentlyDeleted=(io,fo)=>{if(this.recentlyDeletedMap.set(io,fo),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let $o=0;const mo=this.recentlyDeletedLimit/2;for(const Ao of this.recentlyDeletedMap.keys()){if($o++>=mo)break;this.recentlyDeletedMap.delete(Ao)}}},this.checkRecentlyDeleted=io=>{const fo=this.recentlyDeletedMap.get(io);if(fo){const{message:$o}=xe$2("MISSING_OR_INVALID",`Record was recently deleted - ${fo}: ${io}`);throw new Error($o)}},this.isLinkModeEnabled=(io,fo)=>{var $o,mo,Ao,jo,Lo,Ho,zo,Go,Vo;return!io||fo!==F$2.link_mode?!1:((mo=($o=this.client.metadata)==null?void 0:$o.redirect)==null?void 0:mo.linkMode)===!0&&((jo=(Ao=this.client.metadata)==null?void 0:Ao.redirect)==null?void 0:jo.universal)!==void 0&&((Ho=(Lo=this.client.metadata)==null?void 0:Lo.redirect)==null?void 0:Ho.universal)!==""&&((zo=io==null?void 0:io.redirect)==null?void 0:zo.universal)!==void 0&&((Go=io==null?void 0:io.redirect)==null?void 0:Go.universal)!==""&&((Vo=io==null?void 0:io.redirect)==null?void 0:Vo.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(io.redirect.universal)&&typeof(global$o==null?void 0:global$o.Linking)<"u"},this.getAppLinkIfEnabled=(io,fo)=>{var $o;return this.isLinkModeEnabled(io,fo)?($o=io==null?void 0:io.redirect)==null?void 0:$o.universal:void 0},this.handleLinkModeMessage=({url:io})=>{if(!io||!io.includes("wc_ev")||!io.includes("topic"))return;const fo=Is$3(io,"topic")||"",$o=decodeURIComponent(Is$3(io,"wc_ev")||""),mo=this.client.session.keys.includes(fo);mo&&this.client.session.update(fo,{transportType:F$2.link_mode}),this.client.core.dispatchEnvelope({topic:fo,message:$o,sessionExists:mo})},this.registerLinkModeListeners=async()=>{var io;if(_s$2()||rr$1()&&(io=this.client.metadata.redirect)!=null&&io.linkMode){const fo=global$o==null?void 0:global$o.Linking;if(typeof fo<"u"){fo.addEventListener("url",this.handleLinkModeMessage,this.client.name);const $o=await fo.getInitialURL();$o&&setTimeout(()=>{this.handleLinkModeMessage({url:$o})},50)}}}}isInitialized(){if(!this.initialized){const{message:Fn}=xe$2("NOT_INITIALIZED",this.name);throw new Error(Fn)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(w$2.message,Fn=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(Fn):this.onRelayMessage(Fn)})}async onRelayMessage(Fn){const{topic:io,message:fo,attestation:$o,transportType:mo}=Fn,{publicKey:Ao}=this.client.auth.authKeys.keys.includes(ae$2)?this.client.auth.authKeys.get(ae$2):{responseTopic:void 0,publicKey:void 0},jo=await this.client.core.crypto.decode(io,fo,{receiverPublicKey:Ao,encoding:mo===F$2.link_mode?Iu:tn$1});try{isJsonRpcRequest(jo)?(this.client.core.history.set(io,jo),this.onRelayEventRequest({topic:io,payload:jo,attestation:$o,transportType:mo,encryptedId:Ou(fo)})):isJsonRpcResponse(jo)?(await this.client.core.history.resolve(jo),await this.onRelayEventResponse({topic:io,payload:jo,transportType:mo}),this.client.core.history.delete(io,jo.id)):this.onRelayEventUnknownPayload({topic:io,payload:jo,transportType:mo})}catch(Lo){this.client.logger.error(Lo)}}registerExpirerEvents(){this.client.core.expirer.on(R$3.expired,async Fn=>{const{topic:io,id:fo}=ys$1(Fn.target);if(fo&&this.client.pendingRequest.keys.includes(fo))return await this.deletePendingSessionRequest(fo,xe$2("EXPIRED"),!0);if(fo&&this.client.auth.requests.keys.includes(fo))return await this.deletePendingAuthRequest(fo,xe$2("EXPIRED"),!0);io?this.client.session.keys.includes(io)&&(await this.deleteSession({topic:io,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:io})):fo&&(await this.deleteProposal(fo,!0),this.client.events.emit("proposal_expire",{id:fo}))})}registerPairingEvents(){this.client.core.pairing.events.on(q$3.create,Fn=>this.onPairingCreated(Fn)),this.client.core.pairing.events.on(q$3.delete,Fn=>{this.addToRecentlyDeleted(Fn.topic,"pairing")})}isValidPairingTopic(Fn){if(!Yt$1(Fn,!1)){const{message:io}=xe$2("MISSING_OR_INVALID",`pairing topic should be a string: ${Fn}`);throw new Error(io)}if(!this.client.core.pairing.pairings.keys.includes(Fn)){const{message:io}=xe$2("NO_MATCHING_KEY",`pairing topic doesn't exist: ${Fn}`);throw new Error(io)}if(xs$1(this.client.core.pairing.pairings.get(Fn).expiry)){const{message:io}=xe$2("EXPIRED",`pairing topic: ${Fn}`);throw new Error(io)}}async isValidSessionTopic(Fn){if(!Yt$1(Fn,!1)){const{message:io}=xe$2("MISSING_OR_INVALID",`session topic should be a string: ${Fn}`);throw new Error(io)}if(this.checkRecentlyDeleted(Fn),!this.client.session.keys.includes(Fn)){const{message:io}=xe$2("NO_MATCHING_KEY",`session topic doesn't exist: ${Fn}`);throw new Error(io)}if(xs$1(this.client.session.get(Fn).expiry)){await this.deleteSession({topic:Fn});const{message:io}=xe$2("EXPIRED",`session topic: ${Fn}`);throw new Error(io)}if(!this.client.core.crypto.keychain.has(Fn)){const{message:io}=xe$2("MISSING_OR_INVALID",`session topic does not exist in keychain: ${Fn}`);throw await this.deleteSession({topic:Fn}),new Error(io)}}async isValidSessionOrPairingTopic(Fn){if(this.checkRecentlyDeleted(Fn),this.client.session.keys.includes(Fn))await this.isValidSessionTopic(Fn);else if(this.client.core.pairing.pairings.keys.includes(Fn))this.isValidPairingTopic(Fn);else if(Yt$1(Fn,!1)){const{message:io}=xe$2("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${Fn}`);throw new Error(io)}else{const{message:io}=xe$2("MISSING_OR_INVALID",`session or pairing topic should be a string: ${Fn}`);throw new Error(io)}}async isValidProposalId(Fn){if(!mh$1(Fn)){const{message:io}=xe$2("MISSING_OR_INVALID",`proposal id should be a number: ${Fn}`);throw new Error(io)}if(!this.client.proposal.keys.includes(Fn)){const{message:io}=xe$2("NO_MATCHING_KEY",`proposal id doesn't exist: ${Fn}`);throw new Error(io)}if(xs$1(this.client.proposal.get(Fn).expiryTimestamp)){await this.deleteProposal(Fn);const{message:io}=xe$2("EXPIRED",`proposal id: ${Fn}`);throw new Error(io)}}}class Ss extends ai$1{constructor(Fn,io){super(Fn,io,st,ye$2),this.core=Fn,this.logger=io}}class yt extends ai$1{constructor(Fn,io){super(Fn,io,rt,ye$2),this.core=Fn,this.logger=io}}let Is$1=class extends ai$1{constructor(Fn,io){super(Fn,io,ot,ye$2,fo=>fo.id),this.core=Fn,this.logger=io}};class fs extends ai$1{constructor(Fn,io){super(Fn,io,pt,oe$2,()=>ae$2),this.core=Fn,this.logger=io}}class vs extends ai$1{constructor(Fn,io){super(Fn,io,ht,oe$2),this.core=Fn,this.logger=io}}class qs extends ai$1{constructor(Fn,io){super(Fn,io,dt,oe$2,fo=>fo.id),this.core=Fn,this.logger=io}}let Ts$1=class{constructor(Fn,io){this.core=Fn,this.logger=io,this.authKeys=new fs(this.core,this.logger),this.pairingTopics=new vs(this.core,this.logger),this.requests=new qs(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}};class _e extends S$3{constructor(Fn){super(Fn),this.protocol=be$2,this.version=Ce$2,this.name=we$2.name,this.events=new eventsExports.EventEmitter,this.on=(fo,$o)=>this.events.on(fo,$o),this.once=(fo,$o)=>this.events.once(fo,$o),this.off=(fo,$o)=>this.events.off(fo,$o),this.removeListener=(fo,$o)=>this.events.removeListener(fo,$o),this.removeAllListeners=fo=>this.events.removeAllListeners(fo),this.connect=async fo=>{try{return await this.engine.connect(fo)}catch($o){throw this.logger.error($o.message),$o}},this.pair=async fo=>{try{return await this.engine.pair(fo)}catch($o){throw this.logger.error($o.message),$o}},this.approve=async fo=>{try{return await this.engine.approve(fo)}catch($o){throw this.logger.error($o.message),$o}},this.reject=async fo=>{try{return await this.engine.reject(fo)}catch($o){throw this.logger.error($o.message),$o}},this.update=async fo=>{try{return await this.engine.update(fo)}catch($o){throw this.logger.error($o.message),$o}},this.extend=async fo=>{try{return await this.engine.extend(fo)}catch($o){throw this.logger.error($o.message),$o}},this.request=async fo=>{try{return await this.engine.request(fo)}catch($o){throw this.logger.error($o.message),$o}},this.respond=async fo=>{try{return await this.engine.respond(fo)}catch($o){throw this.logger.error($o.message),$o}},this.ping=async fo=>{try{return await this.engine.ping(fo)}catch($o){throw this.logger.error($o.message),$o}},this.emit=async fo=>{try{return await this.engine.emit(fo)}catch($o){throw this.logger.error($o.message),$o}},this.disconnect=async fo=>{try{return await this.engine.disconnect(fo)}catch($o){throw this.logger.error($o.message),$o}},this.find=fo=>{try{return this.engine.find(fo)}catch($o){throw this.logger.error($o.message),$o}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(fo){throw this.logger.error(fo.message),fo}},this.authenticate=async(fo,$o)=>{try{return await this.engine.authenticate(fo,$o)}catch(mo){throw this.logger.error(mo.message),mo}},this.formatAuthMessage=fo=>{try{return this.engine.formatAuthMessage(fo)}catch($o){throw this.logger.error($o.message),$o}},this.approveSessionAuthenticate=async fo=>{try{return await this.engine.approveSessionAuthenticate(fo)}catch($o){throw this.logger.error($o.message),$o}},this.rejectSessionAuthenticate=async fo=>{try{return await this.engine.rejectSessionAuthenticate(fo)}catch($o){throw this.logger.error($o.message),$o}},this.name=(Fn==null?void 0:Fn.name)||we$2.name,this.metadata=(Fn==null?void 0:Fn.metadata)||fs$1(),this.signConfig=Fn==null?void 0:Fn.signConfig;const io=typeof(Fn==null?void 0:Fn.logger)<"u"&&typeof(Fn==null?void 0:Fn.logger)!="string"?Fn.logger:Mg$1(k$3({level:(Fn==null?void 0:Fn.logger)||we$2.logger}));this.core=(Fn==null?void 0:Fn.core)||new On(Fn),this.logger=E$6(io,this.name),this.session=new yt(this.core,this.logger),this.proposal=new Ss(this.core,this.logger),this.pendingRequest=new Is$1(this.core,this.logger),this.engine=new Rs(this),this.auth=new Ts$1(this.core,this.logger)}static async init(Fn){const io=new _e(Fn);return await io.initialize(),io}get context(){return y$7(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),this.engine.processRelayMessageCache()}catch(Fn){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(Fn.message),Fn}}}var browserPonyfill={exports:{}};(function(Mn,Fn){var io=typeof self<"u"?self:commonjsGlobal$c,fo=function(){function mo(){this.fetch=!1,this.DOMException=io.DOMException}return mo.prototype=io,new mo}();(function(mo){(function(Ao){var jo={searchParams:"URLSearchParams"in mo,iterable:"Symbol"in mo&&"iterator"in Symbol,blob:"FileReader"in mo&&"Blob"in mo&&function(){try{return new Blob,!0}catch{return!1}}(),formData:"FormData"in mo,arrayBuffer:"ArrayBuffer"in mo};function Lo(Jo){return Jo&&DataView.prototype.isPrototypeOf(Jo)}if(jo.arrayBuffer)var Ho=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],zo=ArrayBuffer.isView||function(Jo){return Jo&&Ho.indexOf(Object.prototype.toString.call(Jo))>-1};function Go(Jo){if(typeof Jo!="string"&&(Jo=String(Jo)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(Jo))throw new TypeError("Invalid character in header field name");return Jo.toLowerCase()}function Vo(Jo){return typeof Jo!="string"&&(Jo=String(Jo)),Jo}function Yo(Jo){var rs={next:function(){var ps=Jo.shift();return{done:ps===void 0,value:ps}}};return jo.iterable&&(rs[Symbol.iterator]=function(){return rs}),rs}function Xo(Jo){this.map={},Jo instanceof Xo?Jo.forEach(function(rs,ps){this.append(ps,rs)},this):Array.isArray(Jo)?Jo.forEach(function(rs){this.append(rs[0],rs[1])},this):Jo&&Object.getOwnPropertyNames(Jo).forEach(function(rs){this.append(rs,Jo[rs])},this)}Xo.prototype.append=function(Jo,rs){Jo=Go(Jo),rs=Vo(rs);var ps=this.map[Jo];this.map[Jo]=ps?ps+", "+rs:rs},Xo.prototype.delete=function(Jo){delete this.map[Go(Jo)]},Xo.prototype.get=function(Jo){return Jo=Go(Jo),this.has(Jo)?this.map[Jo]:null},Xo.prototype.has=function(Jo){return this.map.hasOwnProperty(Go(Jo))},Xo.prototype.set=function(Jo,rs){this.map[Go(Jo)]=Vo(rs)},Xo.prototype.forEach=function(Jo,rs){for(var ps in this.map)this.map.hasOwnProperty(ps)&&Jo.call(rs,this.map[ps],ps,this)},Xo.prototype.keys=function(){var Jo=[];return this.forEach(function(rs,ps){Jo.push(ps)}),Yo(Jo)},Xo.prototype.values=function(){var Jo=[];return this.forEach(function(rs){Jo.push(rs)}),Yo(Jo)},Xo.prototype.entries=function(){var Jo=[];return this.forEach(function(rs,ps){Jo.push([ps,rs])}),Yo(Jo)},jo.iterable&&(Xo.prototype[Symbol.iterator]=Xo.prototype.entries);function is(Jo){if(Jo.bodyUsed)return Promise.reject(new TypeError("Already read"));Jo.bodyUsed=!0}function yl(Jo){return new Promise(function(rs,ps){Jo.onload=function(){rs(Jo.result)},Jo.onerror=function(){ps(Jo.error)}})}function us(Jo){var rs=new FileReader,ps=yl(rs);return rs.readAsArrayBuffer(Jo),ps}function hs(Jo){var rs=new FileReader,ps=yl(rs);return rs.readAsText(Jo),ps}function _l(Jo){for(var rs=new Uint8Array(Jo),ps=new Array(rs.length),_c=0;_c<rs.length;_c++)ps[_c]=String.fromCharCode(rs[_c]);return ps.join("")}function xl(Jo){if(Jo.slice)return Jo.slice(0);var rs=new Uint8Array(Jo.byteLength);return rs.set(new Uint8Array(Jo)),rs.buffer}function Il(){return this.bodyUsed=!1,this._initBody=function(Jo){this._bodyInit=Jo,Jo?typeof Jo=="string"?this._bodyText=Jo:jo.blob&&Blob.prototype.isPrototypeOf(Jo)?this._bodyBlob=Jo:jo.formData&&FormData.prototype.isPrototypeOf(Jo)?this._bodyFormData=Jo:jo.searchParams&&URLSearchParams.prototype.isPrototypeOf(Jo)?this._bodyText=Jo.toString():jo.arrayBuffer&&jo.blob&&Lo(Jo)?(this._bodyArrayBuffer=xl(Jo.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):jo.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(Jo)||zo(Jo))?this._bodyArrayBuffer=xl(Jo):this._bodyText=Jo=Object.prototype.toString.call(Jo):this._bodyText="",this.headers.get("content-type")||(typeof Jo=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):jo.searchParams&&URLSearchParams.prototype.isPrototypeOf(Jo)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},jo.blob&&(this.blob=function(){var Jo=is(this);if(Jo)return Jo;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?is(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(us)}),this.text=function(){var Jo=is(this);if(Jo)return Jo;if(this._bodyBlob)return hs(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)},jo.formData&&(this.formData=function(){return this.text().then(Nl)}),this.json=function(){return this.text().then(JSON.parse)},this}var Ol=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function Tl(Jo){var rs=Jo.toUpperCase();return Ol.indexOf(rs)>-1?rs:Jo}function Cl(Jo,rs){rs=rs||{};var ps=rs.body;if(Jo instanceof Cl){if(Jo.bodyUsed)throw new TypeError("Already read");this.url=Jo.url,this.credentials=Jo.credentials,rs.headers||(this.headers=new Xo(Jo.headers)),this.method=Jo.method,this.mode=Jo.mode,this.signal=Jo.signal,!ps&&Jo._bodyInit!=null&&(ps=Jo._bodyInit,Jo.bodyUsed=!0)}else this.url=String(Jo);if(this.credentials=rs.credentials||this.credentials||"same-origin",(rs.headers||!this.headers)&&(this.headers=new Xo(rs.headers)),this.method=Tl(rs.method||this.method||"GET"),this.mode=rs.mode||this.mode||null,this.signal=rs.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&ps)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(ps)}Cl.prototype.clone=function(){return new Cl(this,{body:this._bodyInit})};function Nl(Jo){var rs=new FormData;return Jo.trim().split("&").forEach(function(ps){if(ps){var _c=ps.split("="),$l=_c.shift().replace(/\+/g," "),El=_c.join("=").replace(/\+/g," ");rs.append(decodeURIComponent($l),decodeURIComponent(El))}}),rs}function Wl(Jo){var rs=new Xo,ps=Jo.replace(/\r?\n[\t ]+/g," ");return ps.split(/\r?\n/).forEach(function(_c){var $l=_c.split(":"),El=$l.shift().trim();if(El){var ds=$l.join(":").trim();rs.append(El,ds)}}),rs}Il.call(Cl.prototype);function Dl(Jo,rs){rs||(rs={}),this.type="default",this.status=rs.status===void 0?200:rs.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in rs?rs.statusText:"OK",this.headers=new Xo(rs.headers),this.url=rs.url||"",this._initBody(Jo)}Il.call(Dl.prototype),Dl.prototype.clone=function(){return new Dl(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new Xo(this.headers),url:this.url})},Dl.error=function(){var Jo=new Dl(null,{status:0,statusText:""});return Jo.type="error",Jo};var Rl=[301,302,303,307,308];Dl.redirect=function(Jo,rs){if(Rl.indexOf(rs)===-1)throw new RangeError("Invalid status code");return new Dl(null,{status:rs,headers:{location:Jo}})},Ao.DOMException=mo.DOMException;try{new Ao.DOMException}catch{Ao.DOMException=function(rs,ps){this.message=rs,this.name=ps;var _c=Error(rs);this.stack=_c.stack},Ao.DOMException.prototype=Object.create(Error.prototype),Ao.DOMException.prototype.constructor=Ao.DOMException}function Qo(Jo,rs){return new Promise(function(ps,_c){var $l=new Cl(Jo,rs);if($l.signal&&$l.signal.aborted)return _c(new Ao.DOMException("Aborted","AbortError"));var El=new XMLHttpRequest;function ds(){El.abort()}El.onload=function(){var os={status:El.status,statusText:El.statusText,headers:Wl(El.getAllResponseHeaders()||"")};os.url="responseURL"in El?El.responseURL:os.headers.get("X-Request-URL");var Al="response"in El?El.response:El.responseText;ps(new Dl(Al,os))},El.onerror=function(){_c(new TypeError("Network request failed"))},El.ontimeout=function(){_c(new TypeError("Network request failed"))},El.onabort=function(){_c(new Ao.DOMException("Aborted","AbortError"))},El.open($l.method,$l.url,!0),$l.credentials==="include"?El.withCredentials=!0:$l.credentials==="omit"&&(El.withCredentials=!1),"responseType"in El&&jo.blob&&(El.responseType="blob"),$l.headers.forEach(function(os,Al){El.setRequestHeader(Al,os)}),$l.signal&&($l.signal.addEventListener("abort",ds),El.onreadystatechange=function(){El.readyState===4&&$l.signal.removeEventListener("abort",ds)}),El.send(typeof $l._bodyInit>"u"?null:$l._bodyInit)})}return Qo.polyfill=!0,mo.fetch||(mo.fetch=Qo,mo.Headers=Xo,mo.Request=Cl,mo.Response=Dl),Ao.Headers=Xo,Ao.Request=Cl,Ao.Response=Dl,Ao.fetch=Qo,Object.defineProperty(Ao,"__esModule",{value:!0}),Ao})({})})(fo),fo.fetch.ponyfill=!0,delete fo.fetch.polyfill;var $o=fo;Fn=$o.fetch,Fn.default=$o.fetch,Fn.fetch=$o.fetch,Fn.Headers=$o.Headers,Fn.Request=$o.Request,Fn.Response=$o.Response,Mn.exports=Fn})(browserPonyfill,browserPonyfill.exports);var browserPonyfillExports=browserPonyfill.exports;const o=getDefaultExportFromCjs$1(browserPonyfillExports);var P$2=Object.defineProperty,w$1=Object.defineProperties,E$3=Object.getOwnPropertyDescriptors,c=Object.getOwnPropertySymbols,L$3=Object.prototype.hasOwnProperty,O$3=Object.prototype.propertyIsEnumerable,l$2=(Mn,Fn,io)=>Fn in Mn?P$2(Mn,Fn,{enumerable:!0,configurable:!0,writable:!0,value:io}):Mn[Fn]=io,p$4=(Mn,Fn)=>{for(var io in Fn||(Fn={}))L$3.call(Fn,io)&&l$2(Mn,io,Fn[io]);if(c)for(var io of c(Fn))O$3.call(Fn,io)&&l$2(Mn,io,Fn[io]);return Mn},v$3=(Mn,Fn)=>w$1(Mn,E$3(Fn));const j$5={Accept:"application/json","Content-Type":"application/json"},T$3="POST",d={headers:j$5,method:T$3},g$1=10;let f$1=class{constructor(Fn,io=!1){if(this.url=Fn,this.disableProviderPing=io,this.events=new eventsExports.EventEmitter,this.isAvailable=!1,this.registering=!1,!isHttpUrl(Fn))throw new Error(`Provided URL is not compatible with HTTP connection: ${Fn}`);this.url=Fn,this.disableProviderPing=io}get connected(){return this.isAvailable}get connecting(){return this.registering}on(Fn,io){this.events.on(Fn,io)}once(Fn,io){this.events.once(Fn,io)}off(Fn,io){this.events.off(Fn,io)}removeListener(Fn,io){this.events.removeListener(Fn,io)}async open(Fn=this.url){await this.register(Fn)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(Fn){this.isAvailable||await this.register();try{const io=safeJsonStringify(Fn),fo=await(await o(this.url,v$3(p$4({},d),{body:io}))).json();this.onPayload({data:fo})}catch(io){this.onError(Fn.id,io)}}async register(Fn=this.url){if(!isHttpUrl(Fn))throw new Error(`Provided URL is not compatible with HTTP connection: ${Fn}`);if(this.registering){const io=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=io||this.events.listenerCount("open")>=io)&&this.events.setMaxListeners(io+1),new Promise((fo,$o)=>{this.events.once("register_error",mo=>{this.resetMaxListeners(),$o(mo)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return $o(new Error("HTTP connection is missing or invalid"));fo()})})}this.url=Fn,this.registering=!0;try{if(!this.disableProviderPing){const io=safeJsonStringify({id:1,jsonrpc:"2.0",method:"test",params:[]});await o(Fn,v$3(p$4({},d),{body:io}))}this.onOpen()}catch(io){const fo=this.parseError(io);throw this.events.emit("register_error",fo),this.onClose(),fo}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(Fn){if(typeof Fn.data>"u")return;const io=typeof Fn.data=="string"?safeJsonParse(Fn.data):Fn.data;this.events.emit("payload",io)}onError(Fn,io){const fo=this.parseError(io),$o=fo.message||fo.toString(),mo=formatJsonRpcError(Fn,$o);this.events.emit("payload",mo)}parseError(Fn,io=this.url){return parseConnectionError(Fn,io,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>g$1&&this.events.setMaxListeners(g$1)}};const ya$2="error",Yg$1="wss://relay.walletconnect.org",Zg$1="wc",Xg$1="universal_provider",Sa$2=`${Zg$1}@2:${Xg$1}:`,Oa$2="https://rpc.walletconnect.org/v1/",ze$1="generic",Qg$1=`${Oa$2}bundler`,Tt$1={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var _n=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global$o<"u"?global$o:typeof self<"u"?self:{},qi$2={exports:{}};/**
* @license
* Lodash <https://lodash.com/>
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
* Released under MIT license <https://lodash.com/license>
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
*/(function(Mn,Fn){(function(){var io,fo="4.17.21",$o=200,mo="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",Ao="Expected a function",jo="Invalid `variable` option passed into `_.template`",Lo="__lodash_hash_undefined__",Ho=500,zo="__lodash_placeholder__",Go=1,Vo=2,Yo=4,Xo=1,is=2,yl=1,us=2,hs=4,_l=8,xl=16,Il=32,Ol=64,Tl=128,Cl=256,Nl=512,Wl=30,Dl="...",Rl=800,Qo=16,Jo=1,rs=2,ps=3,_c=1/0,$l=9007199254740991,El=17976931348623157e292,ds=NaN,os=4294967295,Al=os-1,Ul=os>>>1,Zl=[["ary",Tl],["bind",yl],["bindKey",us],["curry",_l],["curryRight",xl],["flip",Nl],["partial",Il],["partialRight",Ol],["rearg",Cl]],Pl="[object Arguments]",Hl="[object Array]",Ml="[object AsyncFunction]",Fl="[object Boolean]",Yl="[object Date]",Bl="[object DOMException]",Kl="[object Error]",Gl="[object Function]",fu="[object GeneratorFunction]",bu="[object Map]",rp="[object Number]",tp="[object Null]",op="[object Object]",vp="[object Promise]",ip="[object Proxy]",up="[object RegExp]",$p="[object Set]",gp="[object String]",yp="[object Symbol]",_p="[object Undefined]",mp="[object WeakMap]",wp="[object WeakSet]",Sp="[object ArrayBuffer]",bp="[object DataView]",Ap="[object Float32Array]",Xl="[object Float64Array]",Vl="[object Int8Array]",Jl="[object Int16Array]",wu="[object Int32Array]",ep="[object Uint8Array]",sp="[object Uint8ClampedArray]",dp="[object Uint16Array]",xp="[object Uint32Array]",Op=/\b__p \+= '';/g,Lp=/\b(__p \+=) '' \+/g,Mp=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Pp=/&(?:amp|lt|gt|quot|#39);/g,a1=/[&<>"']/g,Up=RegExp(Pp.source),Dp=RegExp(a1.source),Jp=/<%-([\s\S]+?)%>/g,Kp=/<%([\s\S]+?)%>/g,Bp=/<%=([\s\S]+?)%>/g,Zp=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Hp=/^\w*$/,Gp=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Qp=/[\\^$.*+?()[\]{}|]/g,Vp=RegExp(Qp.source),Wp=/^\s+/,Xp=/\s/,zp=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,jp=/\{\n\/\* \[wrapped with (.+)\] \*/,r1=/,? & /,qp=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,e1=/[()=,{}\[\]\/\s]/,s1=/\\(\\)?/g,t1=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Yp=/\w*$/,f1=/^[-+]0x[0-9a-f]+$/i,R1=/^0b[01]+$/i,O1=/^\[object .+?Constructor\]$/,M1=/^0o[0-7]+$/i,N1=/^(?:0|[1-9]\d*)$/,E1=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,q1=/($^)/,i$=/['\n\r\u2028\u2029\\]/g,Y1="\\ud800-\\udfff",a$="\\u0300-\\u036f",s$="\\ufe20-\\ufe2f",Z1="\\u20d0-\\u20ff",t$=a$+s$+Z1,r$="\\u2700-\\u27bf",D1="a-z\\xdf-\\xf6\\xf8-\\xff",c$="\\xac\\xb1\\xd7\\xf7",l$="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",u$="\\u2000-\\u206f",E$=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",_m="A-Z\\xc0-\\xd6\\xd8-\\xde",Xy="\\ufe0e\\ufe0f",Km=c$+l$+u$+E$,Oy="['’]",Wm="["+Y1+"]",My="["+Km+"]",zm="["+t$+"]",$v="\\d+",Cw="["+r$+"]",yv="["+D1+"]",bv="[^"+Y1+Km+$v+r$+D1+_m+"]",ay="\\ud83c[\\udffb-\\udfff]",Iw="(?:"+zm+"|"+ay+")",Sv="[^"+Y1+"]",sy="(?:\\ud83c[\\udde6-\\uddff]){2}",Am="[\\ud800-\\udbff][\\udc00-\\udfff]",N$="["+_m+"]",Tv="\\u200d",Rv="(?:"+yv+"|"+bv+")",nm="(?:"+N$+"|"+bv+")",Ov="(?:"+Oy+"(?:d|ll|m|re|s|t|ve))?",Mv="(?:"+Oy+"(?:D|LL|M|RE|S|T|VE))?",Nv=Iw+"?",kv="["+Xy+"]?",Tw="(?:"+Tv+"(?:"+[Sv,sy,Am].join("|")+")"+kv+Nv+")*",fm="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",jv="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Dv=kv+Nv+Tw,cy="(?:"+[Cw,sy,Am].join("|")+")"+Dv,Pw="(?:"+[Sv+zm+"?",zm,sy,Am,Wm].join("|")+")",Ny=RegExp(Oy,"g"),Rw=RegExp(zm,"g"),ly=RegExp(ay+"(?="+ay+")|"+Pw+Dv,"g"),Bv=RegExp([N$+"?"+yv+"+"+Ov+"(?="+[My,N$,"$"].join("|")+")",nm+"+"+Mv+"(?="+[My,N$+Rv,"$"].join("|")+")",N$+"?"+Rv+"+"+Ov,N$+"+"+Mv,jv,fm,$v,cy].join("|"),"g"),Lv=RegExp("["+Tv+Y1+t$+Xy+"]"),Hm=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Uv=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],Ow=-1,B1={};B1[Ap]=B1[Xl]=B1[Vl]=B1[Jl]=B1[wu]=B1[ep]=B1[sp]=B1[dp]=B1[xp]=!0,B1[Pl]=B1[Hl]=B1[Sp]=B1[Fl]=B1[bp]=B1[Yl]=B1[Kl]=B1[Gl]=B1[bu]=B1[rp]=B1[op]=B1[up]=B1[$p]=B1[gp]=B1[mp]=!1;var j1={};j1[Pl]=j1[Hl]=j1[Sp]=j1[bp]=j1[Fl]=j1[Yl]=j1[Ap]=j1[Xl]=j1[Vl]=j1[Jl]=j1[wu]=j1[bu]=j1[rp]=j1[op]=j1[up]=j1[$p]=j1[gp]=j1[yp]=j1[ep]=j1[sp]=j1[dp]=j1[xp]=!0,j1[Kl]=j1[Gl]=j1[mp]=!1;var np={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},fp={"&":"&","<":"<",">":">",'"':""","'":"'"},Np={"&":"&","<":"<",">":">",""":'"',"'":"'"},o1={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},U1=parseFloat,p1=parseInt,W1=typeof _n=="object"&&_n&&_n.Object===Object&&_n,n$=typeof self=="object"&&self&&self.Object===Object&&self,A1=W1||n$||Function("return this")(),F1=Fn&&!Fn.nodeType&&Fn,X1=F1&&!0&&Mn&&!Mn.nodeType&&Mn,T$=X1&&X1.exports===F1,o$=T$&&W1.process,z1=function(){try{var hp=X1&&X1.require&&X1.require("util").types;return hp||o$&&o$.binding&&o$.binding("util")}catch{}}(),_$=z1&&z1.isArrayBuffer,Z$=z1&&z1.isDate,F$=z1&&z1.isMap,om=z1&&z1.isRegExp,ky=z1&&z1.isSet,Gm=z1&&z1.isTypedArray;function $$(hp,Cp,Ep){switch(Ep.length){case 0:return hp.call(Cp);case 1:return hp.call(Cp,Ep[0]);case 2:return hp.call(Cp,Ep[0],Ep[1]);case 3:return hp.call(Cp,Ep[0],Ep[1],Ep[2])}return hp.apply(Cp,Ep)}function E_(hp,Cp,Ep,i1){for(var h1=-1,C1=hp==null?0:hp.length;++h1<C1;){var d$=hp[h1];Cp(i1,d$,Ep(d$),hp)}return i1}function K$(hp,Cp){for(var Ep=-1,i1=hp==null?0:hp.length;++Ep<i1&&Cp(hp[Ep],Ep,hp)!==!1;);return hp}function __(hp,Cp){for(var Ep=hp==null?0:hp.length;Ep--&&Cp(hp[Ep],Ep,hp)!==!1;);return hp}function H2(hp,Cp){for(var Ep=-1,i1=hp==null?0:hp.length;++Ep<i1;)if(!Cp(hp[Ep],Ep,hp))return!1;return!0}function Sm(hp,Cp){for(var Ep=-1,i1=hp==null?0:hp.length,h1=0,C1=[];++Ep<i1;){var d$=hp[Ep];Cp(d$,Ep,hp)&&(C1[h1++]=d$)}return C1}function Fv(hp,Cp){var Ep=hp==null?0:hp.length;return!!Ep&&uy(hp,Cp,0)>-1}function Mw(hp,Cp,Ep){for(var i1=-1,h1=hp==null?0:hp.length;++i1<h1;)if(Ep(Cp,hp[i1]))return!0;return!1}function H1(hp,Cp){for(var Ep=-1,i1=hp==null?0:hp.length,h1=Array(i1);++Ep<i1;)h1[Ep]=Cp(hp[Ep],Ep,hp);return h1}function xm(hp,Cp){for(var Ep=-1,i1=Cp.length,h1=hp.length;++Ep<i1;)hp[h1+Ep]=Cp[Ep];return hp}function Nw(hp,Cp,Ep,i1){var h1=-1,C1=hp==null?0:hp.length;for(i1&&C1&&(Ep=hp[++h1]);++h1<C1;)Ep=Cp(Ep,hp[h1],h1,hp);return Ep}function A_(hp,Cp,Ep,i1){var h1=hp==null?0:hp.length;for(i1&&h1&&(Ep=hp[--h1]);h1--;)Ep=Cp(Ep,hp[h1],h1,hp);return Ep}function kw(hp,Cp){for(var Ep=-1,i1=hp==null?0:hp.length;++Ep<i1;)if(Cp(hp[Ep],Ep,hp))return!0;return!1}var S_=jw("length");function x_(hp){return hp.split("")}function C_(hp){return hp.match(qp)||[]}function G2(hp,Cp,Ep){var i1;return Ep(hp,function(h1,C1,d$){if(Cp(h1,C1,d$))return i1=C1,!1}),i1}function Kv(hp,Cp,Ep,i1){for(var h1=hp.length,C1=Ep+(i1?1:-1);i1?C1--:++C1<h1;)if(Cp(hp[C1],C1,hp))return C1;return-1}function uy(hp,Cp,Ep){return Cp===Cp?L_(hp,Cp,Ep):Kv(hp,V2,Ep)}function I_(hp,Cp,Ep,i1){for(var h1=Ep-1,C1=hp.length;++h1<C1;)if(i1(hp[h1],Cp))return h1;return-1}function V2(hp){return hp!==hp}function q2(hp,Cp){var Ep=hp==null?0:hp.length;return Ep?Bw(hp,Cp)/Ep:ds}function jw(hp){return function(Cp){return Cp==null?io:Cp[hp]}}function Dw(hp){return function(Cp){return hp==null?io:hp[Cp]}}function Y2(hp,Cp,Ep,i1,h1){return h1(hp,function(C1,d$,K1){Ep=i1?(i1=!1,C1):Cp(Ep,C1,d$,K1)}),Ep}function T_(hp,Cp){var Ep=hp.length;for(hp.sort(Cp);Ep--;)hp[Ep]=hp[Ep].value;return hp}function Bw(hp,Cp){for(var Ep,i1=-1,h1=hp.length;++i1<h1;){var C1=Cp(hp[i1]);C1!==io&&(Ep=Ep===io?C1:Ep+C1)}return Ep}function Lw(hp,Cp){for(var Ep=-1,i1=Array(hp);++Ep<hp;)i1[Ep]=Cp(Ep);return i1}function P_(hp,Cp){return H1(Cp,function(Ep){return[Ep,hp[Ep]]})}function Z2(hp){return hp&&hp.slice(0,e3(hp)+1).replace(Wp,"")}function k$(hp){return function(Cp){return hp(Cp)}}function Uw(hp,Cp){return H1(Cp,function(Ep){return hp[Ep]})}function jy(hp,Cp){return hp.has(Cp)}function J2(hp,Cp){for(var Ep=-1,i1=hp.length;++Ep<i1&&uy(Cp,hp[Ep],0)>-1;);return Ep}function Q2(hp,Cp){for(var Ep=hp.length;Ep--&&uy(Cp,hp[Ep],0)>-1;);return Ep}function R_(hp,Cp){for(var Ep=hp.length,i1=0;Ep--;)hp[Ep]===Cp&&++i1;return i1}var O_=Dw(np),M_=Dw(fp);function N_(hp){return"\\"+o1[hp]}function k_(hp,Cp){return hp==null?io:hp[Cp]}function dy(hp){return Lv.test(hp)}function j_(hp){return Hm.test(hp)}function D_(hp){for(var Cp,Ep=[];!(Cp=hp.next()).done;)Ep.push(Cp.value);return Ep}function Fw(hp){var Cp=-1,Ep=Array(hp.size);return hp.forEach(function(i1,h1){Ep[++Cp]=[h1,i1]}),Ep}function X2(hp,Cp){return function(Ep){return hp(Cp(Ep))}}function Cm(hp,Cp){for(var Ep=-1,i1=hp.length,h1=0,C1=[];++Ep<i1;){var d$=hp[Ep];(d$===Cp||d$===zo)&&(hp[Ep]=zo,C1[h1++]=Ep)}return C1}function Wv(hp){var Cp=-1,Ep=Array(hp.size);return hp.forEach(function(i1){Ep[++Cp]=i1}),Ep}function B_(hp){var Cp=-1,Ep=Array(hp.size);return hp.forEach(function(i1){Ep[++Cp]=[i1,i1]}),Ep}function L_(hp,Cp,Ep){for(var i1=Ep-1,h1=hp.length;++i1<h1;)if(hp[i1]===Cp)return i1;return-1}function U_(hp,Cp,Ep){for(var i1=Ep+1;i1--;)if(hp[i1]===Cp)return i1;return i1}function fy(hp){return dy(hp)?K_(hp):S_(hp)}function J$(hp){return dy(hp)?W_(hp):x_(hp)}function e3(hp){for(var Cp=hp.length;Cp--&&Xp.test(hp.charAt(Cp)););return Cp}var F_=Dw(Np);function K_(hp){for(var Cp=ly.lastIndex=0;ly.test(hp);)++Cp;return Cp}function W_(hp){return hp.match(ly)||[]}function z_(hp){return hp.match(Bv)||[]}var H_=function hp(Cp){Cp=Cp==null?A1:hy.defaults(A1.Object(),Cp,hy.pick(A1,Uv));var Ep=Cp.Array,i1=Cp.Date,h1=Cp.Error,C1=Cp.Function,d$=Cp.Math,K1=Cp.Object,Kw=Cp.RegExp,G_=Cp.String,W$=Cp.TypeError,zv=Ep.prototype,V_=C1.prototype,py=K1.prototype,Hv=Cp["__core-js_shared__"],Gv=V_.toString,k1=py.hasOwnProperty,q_=0,t3=function(){var as=/[^.]+$/.exec(Hv&&Hv.keys&&Hv.keys.IE_PROTO||"");return as?"Symbol(src)_1."+as:""}(),Vv=py.toString,Y_=Gv.call(K1),Z_=A1._,J_=Kw("^"+Gv.call(k1).replace(Qp,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),qv=T$?Cp.Buffer:io,Im=Cp.Symbol,Yv=Cp.Uint8Array,r3=qv?qv.allocUnsafe:io,Zv=X2(K1.getPrototypeOf,K1),n3=K1.create,o3=py.propertyIsEnumerable,Jv=zv.splice,i3=Im?Im.isConcatSpreadable:io,Dy=Im?Im.iterator:io,Vm=Im?Im.toStringTag:io,Qv=function(){try{var as=Qm(K1,"defineProperty");return as({},"",{}),as}catch{}}(),Q_=Cp.clearTimeout!==A1.clearTimeout&&Cp.clearTimeout,X_=i1&&i1.now!==A1.Date.now&&i1.now,eA=Cp.setTimeout!==A1.setTimeout&&Cp.setTimeout,Xv=d$.ceil,_b=d$.floor,Ww=K1.getOwnPropertySymbols,tA=qv?qv.isBuffer:io,a3=Cp.isFinite,rA=zv.join,nA=X2(K1.keys,K1),f$=d$.max,y$=d$.min,oA=i1.now,iA=Cp.parseInt,s3=d$.random,aA=zv.reverse,zw=Qm(Cp,"DataView"),By=Qm(Cp,"Map"),Hw=Qm(Cp,"Promise"),$y=Qm(Cp,"Set"),Ly=Qm(Cp,"WeakMap"),Uy=Qm(K1,"create"),ew=Ly&&new Ly,gy={},sA=Xm(zw),cA=Xm(By),lA=Xm(Hw),uA=Xm($y),dA=Xm(Ly),tw=Im?Im.prototype:io,Fy=tw?tw.valueOf:io,c3=tw?tw.toString:io;function Au(as){if(J1(as)&&!$1(as)&&!(as instanceof w1)){if(as instanceof z$)return as;if(k1.call(as,"__wrapped__"))return lE(as)}return new z$(as)}var my=function(){function as(){}return function(Sl){if(!G1(Sl))return{};if(n3)return n3(Sl);as.prototype=Sl;var Ll=new as;return as.prototype=io,Ll}}();function rw(){}function z$(as,Sl){this.__wrapped__=as,this.__actions__=[],this.__chain__=!!Sl,this.__index__=0,this.__values__=io}Au.templateSettings={escape:Jp,evaluate:Kp,interpolate:Bp,variable:"",imports:{_:Au}},Au.prototype=rw.prototype,Au.prototype.constructor=Au,z$.prototype=my(rw.prototype),z$.prototype.constructor=z$;function w1(as){this.__wrapped__=as,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=os,this.__views__=[]}function fA(){var as=new w1(this.__wrapped__);return as.__actions__=P$(this.__actions__),as.__dir__=this.__dir__,as.__filtered__=this.__filtered__,as.__iteratees__=P$(this.__iteratees__),as.__takeCount__=this.__takeCount__,as.__views__=P$(this.__views__),as}function hA(){if(this.__filtered__){var as=new w1(this);as.__dir__=-1,as.__filtered__=!0}else as=this.clone(),as.__dir__*=-1;return as}function pA(){var as=this.__wrapped__.value(),Sl=this.__dir__,Ll=$1(as),Ql=Sl<0,yu=Ll?as.length:0,_d=xS(0,yu,this.__views__),cp=_d.start,lp=_d.end,pp=lp-cp,Ip=Ql?lp:cp-1,Tp=this.__iteratees__,kp=Tp.length,n1=0,c1=y$(pp,this.__takeCount__);if(!Ll||!Ql&&yu==pp&&c1==pp)return O3(as,this.__actions__);var u1=[];e:for(;pp--&&n1<c1;){Ip+=Sl;for(var m1=-1,d1=as[Ip];++m1<kp;){var b1=Tp[m1],x1=b1.iteratee,B$=b1.type,x$=x1(d1);if(B$==rs)d1=x$;else if(!x$){if(B$==Jo)continue e;break e}}u1[n1++]=d1}return u1}w1.prototype=my(rw.prototype),w1.prototype.constructor=w1;function qm(as){var Sl=-1,Ll=as==null?0:as.length;for(this.clear();++Sl<Ll;){var Ql=as[Sl];this.set(Ql[0],Ql[1])}}function $A(){this.__data__=Uy?Uy(null):{},this.size=0}function gA(as){var Sl=this.has(as)&&delete this.__data__[as];return this.size-=Sl?1:0,Sl}function mA(as){var Sl=this.__data__;if(Uy){var Ll=Sl[as];return Ll===Lo?io:Ll}return k1.call(Sl,as)?Sl[as]:io}function yA(as){var Sl=this.__data__;return Uy?Sl[as]!==io:k1.call(Sl,as)}function vA(as,Sl){var Ll=this.__data__;return this.size+=this.has(as)?0:1,Ll[as]=Uy&&Sl===io?Lo:Sl,this}qm.prototype.clear=$A,qm.prototype.delete=gA,qm.prototype.get=mA,qm.prototype.has=yA,qm.prototype.set=vA;function hm(as){var Sl=-1,Ll=as==null?0:as.length;for(this.clear();++Sl<Ll;){var Ql=as[Sl];this.set(Ql[0],Ql[1])}}function bA(){this.__data__=[],this.size=0}function wA(as){var Sl=this.__data__,Ll=nw(Sl,as);if(Ll<0)return!1;var Ql=Sl.length-1;return Ll==Ql?Sl.pop():Jv.call(Sl,Ll,1),--this.size,!0}function EA(as){var Sl=this.__data__,Ll=nw(Sl,as);return Ll<0?io:Sl[Ll][1]}function _A(as){return nw(this.__data__,as)>-1}function AA(as,Sl){var Ll=this.__data__,Ql=nw(Ll,as);return Ql<0?(++this.size,Ll.push([as,Sl])):Ll[Ql][1]=Sl,this}hm.prototype.clear=bA,hm.prototype.delete=wA,hm.prototype.get=EA,hm.prototype.has=_A,hm.prototype.set=AA;function pm(as){var Sl=-1,Ll=as==null?0:as.length;for(this.clear();++Sl<Ll;){var Ql=as[Sl];this.set(Ql[0],Ql[1])}}function SA(){this.size=0,this.__data__={hash:new qm,map:new(By||hm),string:new qm}}function xA(as){var Sl=$w(this,as).delete(as);return this.size-=Sl?1:0,Sl}function CA(as){return $w(this,as).get(as)}function IA(as){return $w(this,as).has(as)}function TA(as,Sl){var Ll=$w(this,as),Ql=Ll.size;return Ll.set(as,Sl),this.size+=Ll.size==Ql?0:1,this}pm.prototype.clear=SA,pm.prototype.delete=xA,pm.prototype.get=CA,pm.prototype.has=IA,pm.prototype.set=TA;function Ym(as){var Sl=-1,Ll=as==null?0:as.length;for(this.__data__=new pm;++Sl<Ll;)this.add(as[Sl])}function PA(as){return this.__data__.set(as,Lo),this}function RA(as){return this.__data__.has(as)}Ym.prototype.add=Ym.prototype.push=PA,Ym.prototype.has=RA;function Q$(as){var Sl=this.__data__=new hm(as);this.size=Sl.size}function OA(){this.__data__=new hm,this.size=0}function MA(as){var Sl=this.__data__,Ll=Sl.delete(as);return this.size=Sl.size,Ll}function NA(as){return this.__data__.get(as)}function kA(as){return this.__data__.has(as)}function jA(as,Sl){var Ll=this.__data__;if(Ll instanceof hm){var Ql=Ll.__data__;if(!By||Ql.length<$o-1)return Ql.push([as,Sl]),this.size=++Ll.size,this;Ll=this.__data__=new pm(Ql)}return Ll.set(as,Sl),this.size=Ll.size,this}Q$.prototype.clear=OA,Q$.prototype.delete=MA,Q$.prototype.get=NA,Q$.prototype.has=kA,Q$.prototype.set=jA;function l3(as,Sl){var Ll=$1(as),Ql=!Ll&&ey(as),yu=!Ll&&!Ql&&Mm(as),_d=!Ll&&!Ql&&!yu&&wy(as),cp=Ll||Ql||yu||_d,lp=cp?Lw(as.length,G_):[],pp=lp.length;for(var Ip in as)(Sl||k1.call(as,Ip))&&!(cp&&(Ip=="length"||yu&&(Ip=="offset"||Ip=="parent")||_d&&(Ip=="buffer"||Ip=="byteLength"||Ip=="byteOffset")||ym(Ip,pp)))&&lp.push(Ip);return lp}function u3(as){var Sl=as.length;return Sl?as[r2(0,Sl-1)]:io}function DA(as,Sl){return gw(P$(as),Zm(Sl,0,as.length))}function BA(as){return gw(P$(as))}function Gw(as,Sl,Ll){(Ll!==io&&!X$(as[Sl],Ll)||Ll===io&&!(Sl in as))&&$m(as,Sl,Ll)}function Ky(as,Sl,Ll){var Ql=as[Sl];(!(k1.call(as,Sl)&&X$(Ql,Ll))||Ll===io&&!(Sl in as))&&$m(as,Sl,Ll)}function nw(as,Sl){for(var Ll=as.length;Ll--;)if(X$(as[Ll][0],Sl))return Ll;return-1}function LA(as,Sl,Ll,Ql){return Tm(as,function(yu,_d,cp){Sl(Ql,yu,Ll(yu),cp)}),Ql}function d3(as,Sl){return as&&am(Sl,g$(Sl),as)}function UA(as,Sl){return as&&am(Sl,O$(Sl),as)}function $m(as,Sl,Ll){Sl=="__proto__"&&Qv?Qv(as,Sl,{configurable:!0,enumerable:!0,value:Ll,writable:!0}):as[Sl]=Ll}function Vw(as,Sl){for(var Ll=-1,Ql=Sl.length,yu=Ep(Ql),_d=as==null;++Ll<Ql;)yu[Ll]=_d?io:C2(as,Sl[Ll]);return yu}function Zm(as,Sl,Ll){return as===as&&(Ll!==io&&(as=as<=Ll?as:Ll),Sl!==io&&(as=as>=Sl?as:Sl)),as}function H$(as,Sl,Ll,Ql,yu,_d){var cp,lp=Sl&Go,pp=Sl&Vo,Ip=Sl&Yo;if(Ll&&(cp=yu?Ll(as,Ql,yu,_d):Ll(as)),cp!==io)return cp;if(!G1(as))return as;var Tp=$1(as);if(Tp){if(cp=IS(as),!lp)return P$(as,cp)}else{var kp=v$(as),n1=kp==Gl||kp==fu;if(Mm(as))return k3(as,lp);if(kp==op||kp==Pl||n1&&!yu){if(cp=pp||n1?{}:eE(as),!lp)return pp?mS(as,UA(cp,as)):gS(as,d3(cp,as))}else{if(!j1[kp])return yu?as:{};cp=TS(as,kp,lp)}}_d||(_d=new Q$);var c1=_d.get(as);if(c1)return c1;_d.set(as,cp),PE(as)?as.forEach(function(d1){cp.add(H$(d1,Sl,Ll,d1,as,_d))}):IE(as)&&as.forEach(function(d1,b1){cp.set(b1,H$(d1,Sl,Ll,b1,as,_d))});var u1=Ip?pp?h2:f2:pp?O$:g$,m1=Tp?io:u1(as);return K$(m1||as,function(d1,b1){m1&&(b1=d1,d1=as[b1]),Ky(cp,b1,H$(d1,Sl,Ll,b1,as,_d))}),cp}function FA(as){var Sl=g$(as);return function(Ll){return f3(Ll,as,Sl)}}function f3(as,Sl,Ll){var Ql=Ll.length;if(as==null)return!Ql;for(as=K1(as);Ql--;){var yu=Ll[Ql],_d=Sl[yu],cp=as[yu];if(cp===io&&!(yu in as)||!_d(cp))return!1}return!0}function h3(as,Sl,Ll){if(typeof as!="function")throw new W$(Ao);return Yy(function(){as.apply(io,Ll)},Sl)}function Wy(as,Sl,Ll,Ql){var yu=-1,_d=Fv,cp=!0,lp=as.length,pp=[],Ip=Sl.length;if(!lp)return pp;Ll&&(Sl=H1(Sl,k$(Ll))),Ql?(_d=Mw,cp=!1):Sl.length>=$o&&(_d=jy,cp=!1,Sl=new Ym(Sl));e:for(;++yu<lp;){var Tp=as[yu],kp=Ll==null?Tp:Ll(Tp);if(Tp=Ql||Tp!==0?Tp:0,cp&&kp===kp){for(var n1=Ip;n1--;)if(Sl[n1]===kp)continue e;pp.push(Tp)}else _d(Sl,kp,Ql)||pp.push(Tp)}return pp}var Tm=U3(im),p3=U3(Yw,!0);function KA(as,Sl){var Ll=!0;return Tm(as,function(Ql,yu,_d){return Ll=!!Sl(Ql,yu,_d),Ll}),Ll}function ow(as,Sl,Ll){for(var Ql=-1,yu=as.length;++Ql<yu;){var _d=as[Ql],cp=Sl(_d);if(cp!=null&&(lp===io?cp===cp&&!D$(cp):Ll(cp,lp)))var lp=cp,pp=_d}return pp}function WA(as,Sl,Ll,Ql){var yu=as.length;for(Ll=g1(Ll),Ll<0&&(Ll=-Ll>yu?0:yu+Ll),Ql=Ql===io||Ql>yu?yu:g1(Ql),Ql<0&&(Ql+=yu),Ql=Ll>Ql?0:ME(Ql);Ll<Ql;)as[Ll++]=Sl;return as}function $3(as,Sl){var Ll=[];return Tm(as,function(Ql,yu,_d){Sl(Ql,yu,_d)&&Ll.push(Ql)}),Ll}function m$(as,Sl,Ll,Ql,yu){var _d=-1,cp=as.length;for(Ll||(Ll=RS),yu||(yu=[]);++_d<cp;){var lp=as[_d];Sl>0&&Ll(lp)?Sl>1?m$(lp,Sl-1,Ll,Ql,yu):xm(yu,lp):Ql||(yu[yu.length]=lp)}return yu}var qw=F3(),g3=F3(!0);function im(as,Sl){return as&&qw(as,Sl,g$)}function Yw(as,Sl){return as&&g3(as,Sl,g$)}function iw(as,Sl){return Sm(Sl,function(Ll){return vm(as[Ll])})}function Jm(as,Sl){Sl=Rm(Sl,as);for(var Ll=0,Ql=Sl.length;as!=null&&Ll<Ql;)as=as[sm(Sl[Ll++])];return Ll&&Ll==Ql?as:io}function m3(as,Sl,Ll){var Ql=Sl(as);return $1(as)?Ql:xm(Ql,Ll(as))}function A$(as){return as==null?as===io?_p:tp:Vm&&Vm in K1(as)?SS(as):BS(as)}function Zw(as,Sl){return as>Sl}function zA(as,Sl){return as!=null&&k1.call(as,Sl)}function HA(as,Sl){return as!=null&&Sl in K1(as)}function GA(as,Sl,Ll){return as>=y$(Sl,Ll)&&as<f$(Sl,Ll)}function Jw(as,Sl,Ll){for(var Ql=Ll?Mw:Fv,yu=as[0].length,_d=as.length,cp=_d,lp=Ep(_d),pp=1/0,Ip=[];cp--;){var Tp=as[cp];cp&&Sl&&(Tp=H1(Tp,k$(Sl))),pp=y$(Tp.length,pp),lp[cp]=!Ll&&(Sl||yu>=120&&Tp.length>=120)?new Ym(cp&&Tp):io}Tp=as[0];var kp=-1,n1=lp[0];e:for(;++kp<yu&&Ip.length<pp;){var c1=Tp[kp],u1=Sl?Sl(c1):c1;if(c1=Ll||c1!==0?c1:0,!(n1?jy(n1,u1):Ql(Ip,u1,Ll))){for(cp=_d;--cp;){var m1=lp[cp];if(!(m1?jy(m1,u1):Ql(as[cp],u1,Ll)))continue e}n1&&n1.push(u1),Ip.push(c1)}}return Ip}function VA(as,Sl,Ll,Ql){return im(as,function(yu,_d,cp){Sl(Ql,Ll(yu),_d,cp)}),Ql}function zy(as,Sl,Ll){Sl=Rm(Sl,as),as=oE(as,Sl);var Ql=as==null?as:as[sm(V$(Sl))];return Ql==null?io:$$(Ql,as,Ll)}function y3(as){return J1(as)&&A$(as)==Pl}function qA(as){return J1(as)&&A$(as)==Sp}function YA(as){return J1(as)&&A$(as)==Yl}function Hy(as,Sl,Ll,Ql,yu){return as===Sl?!0:as==null||Sl==null||!J1(as)&&!J1(Sl)?as!==as&&Sl!==Sl:ZA(as,Sl,Ll,Ql,Hy,yu)}function ZA(as,Sl,Ll,Ql,yu,_d){var cp=$1(as),lp=$1(Sl),pp=cp?Hl:v$(as),Ip=lp?Hl:v$(Sl);pp=pp==Pl?op:pp,Ip=Ip==Pl?op:Ip;var Tp=pp==op,kp=Ip==op,n1=pp==Ip;if(n1&&Mm(as)){if(!Mm(Sl))return!1;cp=!0,Tp=!1}if(n1&&!Tp)return _d||(_d=new Q$),cp||wy(as)?J3(as,Sl,Ll,Ql,yu,_d):_S(as,Sl,pp,Ll,Ql,yu,_d);if(!(Ll&Xo)){var c1=Tp&&k1.call(as,"__wrapped__"),u1=kp&&k1.call(Sl,"__wrapped__");if(c1||u1){var m1=c1?as.value():as,d1=u1?Sl.value():Sl;return _d||(_d=new Q$),yu(m1,d1,Ll,Ql,_d)}}return n1?(_d||(_d=new Q$),AS(as,Sl,Ll,Ql,yu,_d)):!1}function JA(as){return J1(as)&&v$(as)==bu}function Qw(as,Sl,Ll,Ql){var yu=Ll.length,_d=yu,cp=!Ql;if(as==null)return!_d;for(as=K1(as);yu--;){var lp=Ll[yu];if(cp&&lp[2]?lp[1]!==as[lp[0]]:!(lp[0]in as))return!1}for(;++yu<_d;){lp=Ll[yu];var pp=lp[0],Ip=as[pp],Tp=lp[1];if(cp&&lp[2]){if(Ip===io&&!(pp in as))return!1}else{var kp=new Q$;if(Ql)var n1=Ql(Ip,Tp,pp,as,Sl,kp);if(!(n1===io?Hy(Tp,Ip,Xo|is,Ql,kp):n1))return!1}}return!0}function v3(as){if(!G1(as)||MS(as))return!1;var Sl=vm(as)?J_:O1;return Sl.test(Xm(as))}function QA(as){return J1(as)&&A$(as)==up}function XA(as){return J1(as)&&v$(as)==$p}function eS(as){return J1(as)&&_w(as.length)&&!!B1[A$(as)]}function b3(as){return typeof as=="function"?as:as==null?M$:typeof as=="object"?$1(as)?_3(as[0],as[1]):E3(as):zE(as)}function Xw(as){if(!qy(as))return nA(as);var Sl=[];for(var Ll in K1(as))k1.call(as,Ll)&&Ll!="constructor"&&Sl.push(Ll);return Sl}function tS(as){if(!G1(as))return DS(as);var Sl=qy(as),Ll=[];for(var Ql in as)Ql=="constructor"&&(Sl||!k1.call(as,Ql))||Ll.push(Ql);return Ll}function e2(as,Sl){return as<Sl}function w3(as,Sl){var Ll=-1,Ql=R$(as)?Ep(as.length):[];return Tm(as,function(yu,_d,cp){Ql[++Ll]=Sl(yu,_d,cp)}),Ql}function E3(as){var Sl=$2(as);return Sl.length==1&&Sl[0][2]?rE(Sl[0][0],Sl[0][1]):function(Ll){return Ll===as||Qw(Ll,as,Sl)}}function _3(as,Sl){return m2(as)&&tE(Sl)?rE(sm(as),Sl):function(Ll){var Ql=C2(Ll,as);return Ql===io&&Ql===Sl?I2(Ll,as):Hy(Sl,Ql,Xo|is)}}function aw(as,Sl,Ll,Ql,yu){as!==Sl&&qw(Sl,function(_d,cp){if(yu||(yu=new Q$),G1(_d))rS(as,Sl,cp,Ll,aw,Ql,yu);else{var lp=Ql?Ql(v2(as,cp),_d,cp+"",as,Sl,yu):io;lp===io&&(lp=_d),Gw(as,cp,lp)}},O$)}function rS(as,Sl,Ll,Ql,yu,_d,cp){var lp=v2(as,Ll),pp=v2(Sl,Ll),Ip=cp.get(pp);if(Ip){Gw(as,Ll,Ip);return}var Tp=_d?_d(lp,pp,Ll+"",as,Sl,cp):io,kp=Tp===io;if(kp){var n1=$1(pp),c1=!n1&&Mm(pp),u1=!n1&&!c1&&wy(pp);Tp=pp,n1||c1||u1?$1(lp)?Tp=lp:h0(lp)?Tp=P$(lp):c1?(kp=!1,Tp=k3(pp,!0)):u1?(kp=!1,Tp=j3(pp,!0)):Tp=[]:Zy(pp)||ey(pp)?(Tp=lp,ey(lp)?Tp=NE(lp):(!G1(lp)||vm(lp))&&(Tp=eE(pp))):kp=!1}kp&&(cp.set(pp,Tp),yu(Tp,pp,Ql,_d,cp),cp.delete(pp)),Gw(as,Ll,Tp)}function A3(as,Sl){var Ll=as.length;if(Ll)return Sl+=Sl<0?Ll:0,ym(Sl,Ll)?as[Sl]:io}function S3(as,Sl,Ll){Sl.length?Sl=H1(Sl,function(_d){return $1(_d)?function(cp){return Jm(cp,_d.length===1?_d[0]:_d)}:_d}):Sl=[M$];var Ql=-1;Sl=H1(Sl,k$(l1()));var yu=w3(as,function(_d,cp,lp){var pp=H1(Sl,function(Ip){return Ip(_d)});return{criteria:pp,index:++Ql,value:_d}});return T_(yu,function(_d,cp){return $S(_d,cp,Ll)})}function nS(as,Sl){return x3(as,Sl,function(Ll,Ql){return I2(as,Ql)})}function x3(as,Sl,Ll){for(var Ql=-1,yu=Sl.length,_d={};++Ql<yu;){var cp=Sl[Ql],lp=Jm(as,cp);Ll(lp,cp)&&Gy(_d,Rm(cp,as),lp)}return _d}function oS(as){return function(Sl){return Jm(Sl,as)}}function t2(as,Sl,Ll,Ql){var yu=Ql?I_:uy,_d=-1,cp=Sl.length,lp=as;for(as===Sl&&(Sl=P$(Sl)),Ll&&(lp=H1(as,k$(Ll)));++_d<cp;)for(var pp=0,Ip=Sl[_d],Tp=Ll?Ll(Ip):Ip;(pp=yu(lp,Tp,pp,Ql))>-1;)lp!==as&&Jv.call(lp,pp,1),Jv.call(as,pp,1);return as}function C3(as,Sl){for(var Ll=as?Sl.length:0,Ql=Ll-1;Ll--;){var yu=Sl[Ll];if(Ll==Ql||yu!==_d){var _d=yu;ym(yu)?Jv.call(as,yu,1):i2(as,yu)}}return as}function r2(as,Sl){return as+_b(s3()*(Sl-as+1))}function iS(as,Sl,Ll,Ql){for(var yu=-1,_d=f$(Xv((Sl-as)/(Ll||1)),0),cp=Ep(_d);_d--;)cp[Ql?_d:++yu]=as,as+=Ll;return cp}function n2(as,Sl){var Ll="";if(!as||Sl<1||Sl>$l)return Ll;do Sl%2&&(Ll+=as),Sl=_b(Sl/2),Sl&&(as+=as);while(Sl);return Ll}function v1(as,Sl){return b2(nE(as,Sl,M$),as+"")}function aS(as){return u3(Ey(as))}function sS(as,Sl){var Ll=Ey(as);return gw(Ll,Zm(Sl,0,Ll.length))}function Gy(as,Sl,Ll,Ql){if(!G1(as))return as;Sl=Rm(Sl,as);for(var yu=-1,_d=Sl.length,cp=_d-1,lp=as;lp!=null&&++yu<_d;){var pp=sm(Sl[yu]),Ip=Ll;if(pp==="__proto__"||pp==="constructor"||pp==="prototype")return as;if(yu!=cp){var Tp=lp[pp];Ip=Ql?Ql(Tp,pp,lp):io,Ip===io&&(Ip=G1(Tp)?Tp:ym(Sl[yu+1])?[]:{})}Ky(lp,pp,Ip),lp=lp[pp]}return as}var I3=ew?function(as,Sl){return ew.set(as,Sl),as}:M$,cS=Qv?function(as,Sl){return Qv(as,"toString",{configurable:!0,enumerable:!1,value:P2(Sl),writable:!0})}:M$;function lS(as){return gw(Ey(as))}function G$(as,Sl,Ll){var Ql=-1,yu=as.length;Sl<0&&(Sl=-Sl>yu?0:yu+Sl),Ll=Ll>yu?yu:Ll,Ll<0&&(Ll+=yu),yu=Sl>Ll?0:Ll-Sl>>>0,Sl>>>=0;for(var _d=Ep(yu);++Ql<yu;)_d[Ql]=as[Ql+Sl];return _d}function uS(as,Sl){var Ll;return Tm(as,function(Ql,yu,_d){return Ll=Sl(Ql,yu,_d),!Ll}),!!Ll}function sw(as,Sl,Ll){var Ql=0,yu=as==null?Ql:as.length;if(typeof Sl=="number"&&Sl===Sl&&yu<=Ul){for(;Ql<yu;){var _d=Ql+yu>>>1,cp=as[_d];cp!==null&&!D$(cp)&&(Ll?cp<=Sl:cp<Sl)?Ql=_d+1:yu=_d}return yu}return o2(as,Sl,M$,Ll)}function o2(as,Sl,Ll,Ql){var yu=0,_d=as==null?0:as.length;if(_d===0)return 0;Sl=Ll(Sl);for(var cp=Sl!==Sl,lp=Sl===null,pp=D$(Sl),Ip=Sl===io;yu<_d;){var Tp=_b((yu+_d)/2),kp=Ll(as[Tp]),n1=kp!==io,c1=kp===null,u1=kp===kp,m1=D$(kp);if(cp)var d1=Ql||u1;else Ip?d1=u1&&(Ql||n1):lp?d1=u1&&n1&&(Ql||!c1):pp?d1=u1&&n1&&!c1&&(Ql||!m1):c1||m1?d1=!1:d1=Ql?kp<=Sl:kp<Sl;d1?yu=Tp+1:_d=Tp}return y$(_d,Al)}function T3(as,Sl){for(var Ll=-1,Ql=as.length,yu=0,_d=[];++Ll<Ql;){var cp=as[Ll],lp=Sl?Sl(cp):cp;if(!Ll||!X$(lp,pp)){var pp=lp;_d[yu++]=cp===0?0:cp}}return _d}function P3(as){return typeof as=="number"?as:D$(as)?ds:+as}function j$(as){if(typeof as=="string")return as;if($1(as))return H1(as,j$)+"";if(D$(as))return c3?c3.call(as):"";var Sl=as+"";return Sl=="0"&&1/as==-_c?"-0":Sl}function Pm(as,Sl,Ll){var Ql=-1,yu=Fv,_d=as.length,cp=!0,lp=[],pp=lp;if(Ll)cp=!1,yu=Mw;else if(_d>=$o){var Ip=Sl?null:wS(as);if(Ip)return Wv(Ip);cp=!1,yu=jy,pp=new Ym}else pp=Sl?[]:lp;e:for(;++Ql<_d;){var Tp=as[Ql],kp=Sl?Sl(Tp):Tp;if(Tp=Ll||Tp!==0?Tp:0,cp&&kp===kp){for(var n1=pp.length;n1--;)if(pp[n1]===kp)continue e;Sl&&pp.push(kp),lp.push(Tp)}else yu(pp,kp,Ll)||(pp!==lp&&pp.push(kp),lp.push(Tp))}return lp}function i2(as,Sl){return Sl=Rm(Sl,as),as=oE(as,Sl),as==null||delete as[sm(V$(Sl))]}function R3(as,Sl,Ll,Ql){return Gy(as,Sl,Ll(Jm(as,Sl)),Ql)}function cw(as,Sl,Ll,Ql){for(var yu=as.length,_d=Ql?yu:-1;(Ql?_d--:++_d<yu)&&Sl(as[_d],_d,as););return Ll?G$(as,Ql?0:_d,Ql?_d+1:yu):G$(as,Ql?_d+1:0,Ql?yu:_d)}function O3(as,Sl){var Ll=as;return Ll instanceof w1&&(Ll=Ll.value()),Nw(Sl,function(Ql,yu){return yu.func.apply(yu.thisArg,xm([Ql],yu.args))},Ll)}function a2(as,Sl,Ll){var Ql=as.length;if(Ql<2)return Ql?Pm(as[0]):[];for(var yu=-1,_d=Ep(Ql);++yu<Ql;)for(var cp=as[yu],lp=-1;++lp<Ql;)lp!=yu&&(_d[yu]=Wy(_d[yu]||cp,as[lp],Sl,Ll));return Pm(m$(_d,1),Sl,Ll)}function M3(as,Sl,Ll){for(var Ql=-1,yu=as.length,_d=Sl.length,cp={};++Ql<yu;){var lp=Ql<_d?Sl[Ql]:io;Ll(cp,as[Ql],lp)}return cp}function s2(as){return h0(as)?as:[]}function c2(as){return typeof as=="function"?as:M$}function Rm(as,Sl){return $1(as)?as:m2(as,Sl)?[as]:cE(I1(as))}var dS=v1;function Om(as,Sl,Ll){var Ql=as.length;return Ll=Ll===io?Ql:Ll,!Sl&&Ll>=Ql?as:G$(as,Sl,Ll)}var N3=Q_||function(as){return A1.clearTimeout(as)};function k3(as,Sl){if(Sl)return as.slice();var Ll=as.length,Ql=r3?r3(Ll):new as.constructor(Ll);return as.copy(Ql),Ql}function l2(as){var Sl=new as.constructor(as.byteLength);return new Yv(Sl).set(new Yv(as)),Sl}function fS(as,Sl){var Ll=Sl?l2(as.buffer):as.buffer;return new as.constructor(Ll,as.byteOffset,as.byteLength)}function hS(as){var Sl=new as.constructor(as.source,Yp.exec(as));return Sl.lastIndex=as.lastIndex,Sl}function pS(as){return Fy?K1(Fy.call(as)):{}}function j3(as,Sl){var Ll=Sl?l2(as.buffer):as.buffer;return new as.constructor(Ll,as.byteOffset,as.length)}function D3(as,Sl){if(as!==Sl){var Ll=as!==io,Ql=as===null,yu=as===as,_d=D$(as),cp=Sl!==io,lp=Sl===null,pp=Sl===Sl,Ip=D$(Sl);if(!lp&&!Ip&&!_d&&as>Sl||_d&&cp&&pp&&!lp&&!Ip||Ql&&cp&&pp||!Ll&&pp||!yu)return 1;if(!Ql&&!_d&&!Ip&&as<Sl||Ip&&Ll&&yu&&!Ql&&!_d||lp&&Ll&&yu||!cp&&yu||!pp)return-1}return 0}function $S(as,Sl,Ll){for(var Ql=-1,yu=as.criteria,_d=Sl.criteria,cp=yu.length,lp=Ll.length;++Ql<cp;){var pp=D3(yu[Ql],_d[Ql]);if(pp){if(Ql>=lp)return pp;var Ip=Ll[Ql];return pp*(Ip=="desc"?-1:1)}}return as.index-Sl.index}function B3(as,Sl,Ll,Ql){for(var yu=-1,_d=as.length,cp=Ll.length,lp=-1,pp=Sl.length,Ip=f$(_d-cp,0),Tp=Ep(pp+Ip),kp=!Ql;++lp<pp;)Tp[lp]=Sl[lp];for(;++yu<cp;)(kp||yu<_d)&&(Tp[Ll[yu]]=as[yu]);for(;Ip--;)Tp[lp++]=as[yu++];return Tp}function L3(as,Sl,Ll,Ql){for(var yu=-1,_d=as.length,cp=-1,lp=Ll.length,pp=-1,Ip=Sl.length,Tp=f$(_d-lp,0),kp=Ep(Tp+Ip),n1=!Ql;++yu<Tp;)kp[yu]=as[yu];for(var c1=yu;++pp<Ip;)kp[c1+pp]=Sl[pp];for(;++cp<lp;)(n1||yu<_d)&&(kp[c1+Ll[cp]]=as[yu++]);return kp}function P$(as,Sl){var Ll=-1,Ql=as.length;for(Sl||(Sl=Ep(Ql));++Ll<Ql;)Sl[Ll]=as[Ll];return Sl}function am(as,Sl,Ll,Ql){var yu=!Ll;Ll||(Ll={});for(var _d=-1,cp=Sl.length;++_d<cp;){var lp=Sl[_d],pp=Ql?Ql(Ll[lp],as[lp],lp,Ll,as):io;pp===io&&(pp=as[lp]),yu?$m(Ll,lp,pp):Ky(Ll,lp,pp)}return Ll}function gS(as,Sl){return am(as,g2(as),Sl)}function mS(as,Sl){return am(as,Q3(as),Sl)}function lw(as,Sl){return function(Ll,Ql){var yu=$1(Ll)?E_:LA,_d=Sl?Sl():{};return yu(Ll,as,l1(Ql,2),_d)}}function yy(as){return v1(function(Sl,Ll){var Ql=-1,yu=Ll.length,_d=yu>1?Ll[yu-1]:io,cp=yu>2?Ll[2]:io;for(_d=as.length>3&&typeof _d=="function"?(yu--,_d):io,cp&&S$(Ll[0],Ll[1],cp)&&(_d=yu<3?io:_d,yu=1),Sl=K1(Sl);++Ql<yu;){var lp=Ll[Ql];lp&&as(Sl,lp,Ql,_d)}return Sl})}function U3(as,Sl){return function(Ll,Ql){if(Ll==null)return Ll;if(!R$(Ll))return as(Ll,Ql);for(var yu=Ll.length,_d=Sl?yu:-1,cp=K1(Ll);(Sl?_d--:++_d<yu)&&Ql(cp[_d],_d,cp)!==!1;);return Ll}}function F3(as){return function(Sl,Ll,Ql){for(var yu=-1,_d=K1(Sl),cp=Ql(Sl),lp=cp.length;lp--;){var pp=cp[as?lp:++yu];if(Ll(_d[pp],pp,_d)===!1)break}return Sl}}function yS(as,Sl,Ll){var Ql=Sl&yl,yu=Vy(as);function _d(){var cp=this&&this!==A1&&this instanceof _d?yu:as;return cp.apply(Ql?Ll:this,arguments)}return _d}function K3(as){return function(Sl){Sl=I1(Sl);var Ll=dy(Sl)?J$(Sl):io,Ql=Ll?Ll[0]:Sl.charAt(0),yu=Ll?Om(Ll,1).join(""):Sl.slice(1);return Ql[as]()+yu}}function vy(as){return function(Sl){return Nw(KE(FE(Sl).replace(Ny,"")),as,"")}}function Vy(as){return function(){var Sl=arguments;switch(Sl.length){case 0:return new as;case 1:return new as(Sl[0]);case 2:return new as(Sl[0],Sl[1]);case 3:return new as(Sl[0],Sl[1],Sl[2]);case 4:return new as(Sl[0],Sl[1],Sl[2],Sl[3]);case 5:return new as(Sl[0],Sl[1],Sl[2],Sl[3],Sl[4]);case 6:return new as(Sl[0],Sl[1],Sl[2],Sl[3],Sl[4],Sl[5]);case 7:return new as(Sl[0],Sl[1],Sl[2],Sl[3],Sl[4],Sl[5],Sl[6])}var Ll=my(as.prototype),Ql=as.apply(Ll,Sl);return G1(Ql)?Ql:Ll}}function vS(as,Sl,Ll){var Ql=Vy(as);function yu(){for(var _d=arguments.length,cp=Ep(_d),lp=_d,pp=by(yu);lp--;)cp[lp]=arguments[lp];var Ip=_d<3&&cp[0]!==pp&&cp[_d-1]!==pp?[]:Cm(cp,pp);if(_d-=Ip.length,_d<Ll)return V3(as,Sl,uw,yu.placeholder,io,cp,Ip,io,io,Ll-_d);var Tp=this&&this!==A1&&this instanceof yu?Ql:as;return $$(Tp,this,cp)}return yu}function W3(as){return function(Sl,Ll,Ql){var yu=K1(Sl);if(!R$(Sl)){var _d=l1(Ll,3);Sl=g$(Sl),Ll=function(lp){return _d(yu[lp],lp,yu)}}var cp=as(Sl,Ll,Ql);return cp>-1?yu[_d?Sl[cp]:cp]:io}}function z3(as){return mm(function(Sl){var Ll=Sl.length,Ql=Ll,yu=z$.prototype.thru;for(as&&Sl.reverse();Ql--;){var _d=Sl[Ql];if(typeof _d!="function")throw new W$(Ao);if(yu&&!cp&&pw(_d)=="wrapper")var cp=new z$([],!0)}for(Ql=cp?Ql:Ll;++Ql<Ll;){_d=Sl[Ql];var lp=pw(_d),pp=lp=="wrapper"?p2(_d):io;pp&&y2(pp[0])&&pp[1]==(Tl|_l|Il|Cl)&&!pp[4].length&&pp[9]==1?cp=cp[pw(pp[0])].apply(cp,pp[3]):cp=_d.length==1&&y2(_d)?cp[lp]():cp.thru(_d)}return function(){var Ip=arguments,Tp=Ip[0];if(cp&&Ip.length==1&&$1(Tp))return cp.plant(Tp).value();for(var kp=0,n1=Ll?Sl[kp].apply(this,Ip):Tp;++kp<Ll;)n1=Sl[kp].call(this,n1);return n1}})}function uw(as,Sl,Ll,Ql,yu,_d,cp,lp,pp,Ip){var Tp=Sl&Tl,kp=Sl&yl,n1=Sl&us,c1=Sl&(_l|xl),u1=Sl&Nl,m1=n1?io:Vy(as);function d1(){for(var b1=arguments.length,x1=Ep(b1),B$=b1;B$--;)x1[B$]=arguments[B$];if(c1)var x$=by(d1),L$=R_(x1,x$);if(Ql&&(x1=B3(x1,Ql,yu,c1)),_d&&(x1=L3(x1,_d,cp,c1)),b1-=L$,c1&&b1<Ip){var e$=Cm(x1,x$);return V3(as,Sl,uw,d1.placeholder,Ll,x1,e$,lp,pp,Ip-b1)}var _g=kp?Ll:this,wm=n1?_g[as]:as;return b1=x1.length,lp?x1=LS(x1,lp):u1&&b1>1&&x1.reverse(),Tp&&pp<b1&&(x1.length=pp),this&&this!==A1&&this instanceof d1&&(wm=m1||Vy(wm)),wm.apply(_g,x1)}return d1}function H3(as,Sl){return function(Ll,Ql){return VA(Ll,as,Sl(Ql),{})}}function dw(as,Sl){return function(Ll,Ql){var yu;if(Ll===io&&Ql===io)return Sl;if(Ll!==io&&(yu=Ll),Ql!==io){if(yu===io)return Ql;typeof Ll=="string"||typeof Ql=="string"?(Ll=j$(Ll),Ql=j$(Ql)):(Ll=P3(Ll),Ql=P3(Ql)),yu=as(Ll,Ql)}return yu}}function u2(as){return mm(function(Sl){return Sl=H1(Sl,k$(l1())),v1(function(Ll){var Ql=this;return as(Sl,function(yu){return $$(yu,Ql,Ll)})})})}function fw(as,Sl){Sl=Sl===io?" ":j$(Sl);var Ll=Sl.length;if(Ll<2)return Ll?n2(Sl,as):Sl;var Ql=n2(Sl,Xv(as/fy(Sl)));return dy(Sl)?Om(J$(Ql),0,as).join(""):Ql.slice(0,as)}function bS(as,Sl,Ll,Ql){var yu=Sl&yl,_d=Vy(as);function cp(){for(var lp=-1,pp=arguments.length,Ip=-1,Tp=Ql.length,kp=Ep(Tp+pp),n1=this&&this!==A1&&this instanceof cp?_d:as;++Ip<Tp;)kp[Ip]=Ql[Ip];for(;pp--;)kp[Ip++]=arguments[++lp];return $$(n1,yu?Ll:this,kp)}return cp}function G3(as){return function(Sl,Ll,Ql){return Ql&&typeof Ql!="number"&&S$(Sl,Ll,Ql)&&(Ll=Ql=io),Sl=bm(Sl),Ll===io?(Ll=Sl,Sl=0):Ll=bm(Ll),Ql=Ql===io?Sl<Ll?1:-1:bm(Ql),iS(Sl,Ll,Ql,as)}}function hw(as){return function(Sl,Ll){return typeof Sl=="string"&&typeof Ll=="string"||(Sl=q$(Sl),Ll=q$(Ll)),as(Sl,Ll)}}function V3(as,Sl,Ll,Ql,yu,_d,cp,lp,pp,Ip){var Tp=Sl&_l,kp=Tp?cp:io,n1=Tp?io:cp,c1=Tp?_d:io,u1=Tp?io:_d;Sl|=Tp?Il:Ol,Sl&=~(Tp?Ol:Il),Sl&hs||(Sl&=~(yl|us));var m1=[as,Sl,yu,c1,kp,u1,n1,lp,pp,Ip],d1=Ll.apply(io,m1);return y2(as)&&iE(d1,m1),d1.placeholder=Ql,aE(d1,as,Sl)}function d2(as){var Sl=d$[as];return function(Ll,Ql){if(Ll=q$(Ll),Ql=Ql==null?0:y$(g1(Ql),292),Ql&&a3(Ll)){var yu=(I1(Ll)+"e").split("e"),_d=Sl(yu[0]+"e"+(+yu[1]+Ql));return yu=(I1(_d)+"e").split("e"),+(yu[0]+"e"+(+yu[1]-Ql))}return Sl(Ll)}}var wS=$y&&1/Wv(new $y([,-0]))[1]==_c?function(as){return new $y(as)}:M2;function q3(as){return function(Sl){var Ll=v$(Sl);return Ll==bu?Fw(Sl):Ll==$p?B_(Sl):P_(Sl,as(Sl))}}function gm(as,Sl,Ll,Ql,yu,_d,cp,lp){var pp=Sl&us;if(!pp&&typeof as!="function")throw new W$(Ao);var Ip=Ql?Ql.length:0;if(Ip||(Sl&=~(Il|Ol),Ql=yu=io),cp=cp===io?cp:f$(g1(cp),0),lp=lp===io?lp:g1(lp),Ip-=yu?yu.length:0,Sl&Ol){var Tp=Ql,kp=yu;Ql=yu=io}var n1=pp?io:p2(as),c1=[as,Sl,Ll,Ql,yu,Tp,kp,_d,cp,lp];if(n1&&jS(c1,n1),as=c1[0],Sl=c1[1],Ll=c1[2],Ql=c1[3],yu=c1[4],lp=c1[9]=c1[9]===io?pp?0:as.length:f$(c1[9]-Ip,0),!lp&&Sl&(_l|xl)&&(Sl&=~(_l|xl)),!Sl||Sl==yl)var u1=yS(as,Sl,Ll);else Sl==_l||Sl==xl?u1=vS(as,Sl,lp):(Sl==Il||Sl==(yl|Il))&&!yu.length?u1=bS(as,Sl,Ll,Ql):u1=uw.apply(io,c1);var m1=n1?I3:iE;return aE(m1(u1,c1),as,Sl)}function Y3(as,Sl,Ll,Ql){return as===io||X$(as,py[Ll])&&!k1.call(Ql,Ll)?Sl:as}function Z3(as,Sl,Ll,Ql,yu,_d){return G1(as)&&G1(Sl)&&(_d.set(Sl,as),aw(as,Sl,io,Z3,_d),_d.delete(Sl)),as}function ES(as){return Zy(as)?io:as}function J3(as,Sl,Ll,Ql,yu,_d){var cp=Ll&Xo,lp=as.length,pp=Sl.length;if(lp!=pp&&!(cp&&pp>lp))return!1;var Ip=_d.get(as),Tp=_d.get(Sl);if(Ip&&Tp)return Ip==Sl&&Tp==as;var kp=-1,n1=!0,c1=Ll&is?new Ym:io;for(_d.set(as,Sl),_d.set(Sl,as);++kp<lp;){var u1=as[kp],m1=Sl[kp];if(Ql)var d1=cp?Ql(m1,u1,kp,Sl,as,_d):Ql(u1,m1,kp,as,Sl,_d);if(d1!==io){if(d1)continue;n1=!1;break}if(c1){if(!kw(Sl,function(b1,x1){if(!jy(c1,x1)&&(u1===b1||yu(u1,b1,Ll,Ql,_d)))return c1.push(x1)})){n1=!1;break}}else if(!(u1===m1||yu(u1,m1,Ll,Ql,_d))){n1=!1;break}}return _d.delete(as),_d.delete(Sl),n1}function _S(as,Sl,Ll,Ql,yu,_d,cp){switch(Ll){case bp:if(as.byteLength!=Sl.byteLength||as.byteOffset!=Sl.byteOffset)return!1;as=as.buffer,Sl=Sl.buffer;case Sp:return!(as.byteLength!=Sl.byteLength||!_d(new Yv(as),new Yv(Sl)));case Fl:case Yl:case rp:return X$(+as,+Sl);case Kl:return as.name==Sl.name&&as.message==Sl.message;case up:case gp:return as==Sl+"";case bu:var lp=Fw;case $p:var pp=Ql&Xo;if(lp||(lp=Wv),as.size!=Sl.size&&!pp)return!1;var Ip=cp.get(as);if(Ip)return Ip==Sl;Ql|=is,cp.set(as,Sl);var Tp=J3(lp(as),lp(Sl),Ql,yu,_d,cp);return cp.delete(as),Tp;case yp:if(Fy)return Fy.call(as)==Fy.call(Sl)}return!1}function AS(as,Sl,Ll,Ql,yu,_d){var cp=Ll&Xo,lp=f2(as),pp=lp.length,Ip=f2(Sl),Tp=Ip.length;if(pp!=Tp&&!cp)return!1;for(var kp=pp;kp--;){var n1=lp[kp];if(!(cp?n1 in Sl:k1.call(Sl,n1)))return!1}var c1=_d.get(as),u1=_d.get(Sl);if(c1&&u1)return c1==Sl&&u1==as;var m1=!0;_d.set(as,Sl),_d.set(Sl,as);for(var d1=cp;++kp<pp;){n1=lp[kp];var b1=as[n1],x1=Sl[n1];if(Ql)var B$=cp?Ql(x1,b1,n1,Sl,as,_d):Ql(b1,x1,n1,as,Sl,_d);if(!(B$===io?b1===x1||yu(b1,x1,Ll,Ql,_d):B$)){m1=!1;break}d1||(d1=n1=="constructor")}if(m1&&!d1){var x$=as.constructor,L$=Sl.constructor;x$!=L$&&"constructor"in as&&"constructor"in Sl&&!(typeof x$=="function"&&x$ instanceof x$&&typeof L$=="function"&&L$ instanceof L$)&&(m1=!1)}return _d.delete(as),_d.delete(Sl),m1}function mm(as){return b2(nE(as,io,fE),as+"")}function f2(as){return m3(as,g$,g2)}function h2(as){return m3(as,O$,Q3)}var p2=ew?function(as){return ew.get(as)}:M2;function pw(as){for(var Sl=as.name+"",Ll=gy[Sl],Ql=k1.call(gy,Sl)?Ll.length:0;Ql--;){var yu=Ll[Ql],_d=yu.func;if(_d==null||_d==as)return yu.name}return Sl}function by(as){var Sl=k1.call(Au,"placeholder")?Au:as;return Sl.placeholder}function l1(){var as=Au.iteratee||R2;return as=as===R2?b3:as,arguments.length?as(arguments[0],arguments[1]):as}function $w(as,Sl){var Ll=as.__data__;return OS(Sl)?Ll[typeof Sl=="string"?"string":"hash"]:Ll.map}function $2(as){for(var Sl=g$(as),Ll=Sl.length;Ll--;){var Ql=Sl[Ll],yu=as[Ql];Sl[Ll]=[Ql,yu,tE(yu)]}return Sl}function Qm(as,Sl){var Ll=k_(as,Sl);return v3(Ll)?Ll:io}function SS(as){var Sl=k1.call(as,Vm),Ll=as[Vm];try{as[Vm]=io;var Ql=!0}catch{}var yu=Vv.call(as);return Ql&&(Sl?as[Vm]=Ll:delete as[Vm]),yu}var g2=Ww?function(as){return as==null?[]:(as=K1(as),Sm(Ww(as),function(Sl){return o3.call(as,Sl)}))}:N2,Q3=Ww?function(as){for(var Sl=[];as;)xm(Sl,g2(as)),as=Zv(as);return Sl}:N2,v$=A$;(zw&&v$(new zw(new ArrayBuffer(1)))!=bp||By&&v$(new By)!=bu||Hw&&v$(Hw.resolve())!=vp||$y&&v$(new $y)!=$p||Ly&&v$(new Ly)!=mp)&&(v$=function(as){var Sl=A$(as),Ll=Sl==op?as.constructor:io,Ql=Ll?Xm(Ll):"";if(Ql)switch(Ql){case sA:return bp;case cA:return bu;case lA:return vp;case uA:return $p;case dA:return mp}return Sl});function xS(as,Sl,Ll){for(var Ql=-1,yu=Ll.length;++Ql<yu;){var _d=Ll[Ql],cp=_d.size;switch(_d.type){case"drop":as+=cp;break;case"dropRight":Sl-=cp;break;case"take":Sl=y$(Sl,as+cp);break;case"takeRight":as=f$(as,Sl-cp);break}}return{start:as,end:Sl}}function CS(as){var Sl=as.match(jp);return Sl?Sl[1].split(r1):[]}function X3(as,Sl,Ll){Sl=Rm(Sl,as);for(var Ql=-1,yu=Sl.length,_d=!1;++Ql<yu;){var cp=sm(Sl[Ql]);if(!(_d=as!=null&&Ll(as,cp)))break;as=as[cp]}return _d||++Ql!=yu?_d:(yu=as==null?0:as.length,!!yu&&_w(yu)&&ym(cp,yu)&&($1(as)||ey(as)))}function IS(as){var Sl=as.length,Ll=new as.constructor(Sl);return Sl&&typeof as[0]=="string"&&k1.call(as,"index")&&(Ll.index=as.index,Ll.input=as.input),Ll}function eE(as){return typeof as.constructor=="function"&&!qy(as)?my(Zv(as)):{}}function TS(as,Sl,Ll){var Ql=as.constructor;switch(Sl){case Sp:return l2(as);case Fl:case Yl:return new Ql(+as);case bp:return fS(as,Ll);case Ap:case Xl:case Vl:case Jl:case wu:case ep:case sp:case dp:case xp:return j3(as,Ll);case bu:return new Ql;case rp:case gp:return new Ql(as);case up:return hS(as);case $p:return new Ql;case yp:return pS(as)}}function PS(as,Sl){var Ll=Sl.length;if(!Ll)return as;var Ql=Ll-1;return Sl[Ql]=(Ll>1?"& ":"")+Sl[Ql],Sl=Sl.join(Ll>2?", ":" "),as.replace(zp,`{
/* [wrapped with `+Sl+`] */
`)}function RS(as){return $1(as)||ey(as)||!!(i3&&as&&as[i3])}function ym(as,Sl){var Ll=typeof as;return Sl=Sl??$l,!!Sl&&(Ll=="number"||Ll!="symbol"&&N1.test(as))&&as>-1&&as%1==0&&as<Sl}function S$(as,Sl,Ll){if(!G1(Ll))return!1;var Ql=typeof Sl;return(Ql=="number"?R$(Ll)&&ym(Sl,Ll.length):Ql=="string"&&Sl in Ll)?X$(Ll[Sl],as):!1}function m2(as,Sl){if($1(as))return!1;var Ll=typeof as;return Ll=="number"||Ll=="symbol"||Ll=="boolean"||as==null||D$(as)?!0:Hp.test(as)||!Zp.test(as)||Sl!=null&&as in K1(Sl)}function OS(as){var Sl=typeof as;return Sl=="string"||Sl=="number"||Sl=="symbol"||Sl=="boolean"?as!=="__proto__":as===null}function y2(as){var Sl=pw(as),Ll=Au[Sl];if(typeof Ll!="function"||!(Sl in w1.prototype))return!1;if(as===Ll)return!0;var Ql=p2(Ll);return!!Ql&&as===Ql[0]}function MS(as){return!!t3&&t3 in as}var NS=Hv?vm:k2;function qy(as){var Sl=as&&as.constructor,Ll=typeof Sl=="function"&&Sl.prototype||py;return as===Ll}function tE(as){return as===as&&!G1(as)}function rE(as,Sl){return function(Ll){return Ll==null?!1:Ll[as]===Sl&&(Sl!==io||as in K1(Ll))}}function kS(as){var Sl=ww(as,function(Ql){return Ll.size===Ho&&Ll.clear(),Ql}),Ll=Sl.cache;return Sl}function jS(as,Sl){var Ll=as[1],Ql=Sl[1],yu=Ll|Ql,_d=yu<(yl|us|Tl),cp=Ql==Tl&&Ll==_l||Ql==Tl&&Ll==Cl&&as[7].length<=Sl[8]||Ql==(Tl|Cl)&&Sl[7].length<=Sl[8]&&Ll==_l;if(!(_d||cp))return as;Ql&yl&&(as[2]=Sl[2],yu|=Ll&yl?0:hs);var lp=Sl[3];if(lp){var pp=as[3];as[3]=pp?B3(pp,lp,Sl[4]):lp,as[4]=pp?Cm(as[3],zo):Sl[4]}return lp=Sl[5],lp&&(pp=as[5],as[5]=pp?L3(pp,lp,Sl[6]):lp,as[6]=pp?Cm(as[5],zo):Sl[6]),lp=Sl[7],lp&&(as[7]=lp),Ql&Tl&&(as[8]=as[8]==null?Sl[8]:y$(as[8],Sl[8])),as[9]==null&&(as[9]=Sl[9]),as[0]=Sl[0],as[1]=yu,as}function DS(as){var Sl=[];if(as!=null)for(var Ll in K1(as))Sl.push(Ll);return Sl}function BS(as){return Vv.call(as)}function nE(as,Sl,Ll){return Sl=f$(Sl===io?as.length-1:Sl,0),function(){for(var Ql=arguments,yu=-1,_d=f$(Ql.length-Sl,0),cp=Ep(_d);++yu<_d;)cp[yu]=Ql[Sl+yu];yu=-1;for(var lp=Ep(Sl+1);++yu<Sl;)lp[yu]=Ql[yu];return lp[Sl]=Ll(cp),$$(as,this,lp)}}function oE(as,Sl){return Sl.length<2?as:Jm(as,G$(Sl,0,-1))}function LS(as,Sl){for(var Ll=as.length,Ql=y$(Sl.length,Ll),yu=P$(as);Ql--;){var _d=Sl[Ql];as[Ql]=ym(_d,Ll)?yu[_d]:io}return as}function v2(as,Sl){if(!(Sl==="constructor"&&typeof as[Sl]=="function")&&Sl!="__proto__")return as[Sl]}var iE=sE(I3),Yy=eA||function(as,Sl){return A1.setTimeout(as,Sl)},b2=sE(cS);function aE(as,Sl,Ll){var Ql=Sl+"";return b2(as,PS(Ql,US(CS(Ql),Ll)))}function sE(as){var Sl=0,Ll=0;return function(){var Ql=oA(),yu=Qo-(Ql-Ll);if(Ll=Ql,yu>0){if(++Sl>=Rl)return arguments[0]}else Sl=0;return as.apply(io,arguments)}}function gw(as,Sl){var Ll=-1,Ql=as.length,yu=Ql-1;for(Sl=Sl===io?Ql:Sl;++Ll<Sl;){var _d=r2(Ll,yu),cp=as[_d];as[_d]=as[Ll],as[Ll]=cp}return as.length=Sl,as}var cE=kS(function(as){var Sl=[];return as.charCodeAt(0)===46&&Sl.push(""),as.replace(Gp,function(Ll,Ql,yu,_d){Sl.push(yu?_d.replace(s1,"$1"):Ql||Ll)}),Sl});function sm(as){if(typeof as=="string"||D$(as))return as;var Sl=as+"";return Sl=="0"&&1/as==-_c?"-0":Sl}function Xm(as){if(as!=null){try{return Gv.call(as)}catch{}try{return as+""}catch{}}return""}function US(as,Sl){return K$(Zl,function(Ll){var Ql="_."+Ll[0];Sl&Ll[1]&&!Fv(as,Ql)&&as.push(Ql)}),as.sort()}function lE(as){if(as instanceof w1)return as.clone();var Sl=new z$(as.__wrapped__,as.__chain__);return Sl.__actions__=P$(as.__actions__),Sl.__index__=as.__index__,Sl.__values__=as.__values__,Sl}function FS(as,Sl,Ll){(Ll?S$(as,Sl,Ll):Sl===io)?Sl=1:Sl=f$(g1(Sl),0);var Ql=as==null?0:as.length;if(!Ql||Sl<1)return[];for(var yu=0,_d=0,cp=Ep(Xv(Ql/Sl));yu<Ql;)cp[_d++]=G$(as,yu,yu+=Sl);return cp}function KS(as){for(var Sl=-1,Ll=as==null?0:as.length,Ql=0,yu=[];++Sl<Ll;){var _d=as[Sl];_d&&(yu[Ql++]=_d)}return yu}function WS(){var as=arguments.length;if(!as)return[];for(var Sl=Ep(as-1),Ll=arguments[0],Ql=as;Ql--;)Sl[Ql-1]=arguments[Ql];return xm($1(Ll)?P$(Ll):[Ll],m$(Sl,1))}var zS=v1(function(as,Sl){return h0(as)?Wy(as,m$(Sl,1,h0,!0)):[]}),HS=v1(function(as,Sl){var Ll=V$(Sl);return h0(Ll)&&(Ll=io),h0(as)?Wy(as,m$(Sl,1,h0,!0),l1(Ll,2)):[]}),GS=v1(function(as,Sl){var Ll=V$(Sl);return h0(Ll)&&(Ll=io),h0(as)?Wy(as,m$(Sl,1,h0,!0),io,Ll):[]});function VS(as,Sl,Ll){var Ql=as==null?0:as.length;return Ql?(Sl=Ll||Sl===io?1:g1(Sl),G$(as,Sl<0?0:Sl,Ql)):[]}function qS(as,Sl,Ll){var Ql=as==null?0:as.length;return Ql?(Sl=Ll||Sl===io?1:g1(Sl),Sl=Ql-Sl,G$(as,0,Sl<0?0:Sl)):[]}function YS(as,Sl){return as&&as.length?cw(as,l1(Sl,3),!0,!0):[]}function ZS(as,Sl){return as&&as.length?cw(as,l1(Sl,3),!0):[]}function JS(as,Sl,Ll,Ql){var yu=as==null?0:as.length;return yu?(Ll&&typeof Ll!="number"&&S$(as,Sl,Ll)&&(Ll=0,Ql=yu),WA(as,Sl,Ll,Ql)):[]}function uE(as,Sl,Ll){var Ql=as==null?0:as.length;if(!Ql)return-1;var yu=Ll==null?0:g1(Ll);return yu<0&&(yu=f$(Ql+yu,0)),Kv(as,l1(Sl,3),yu)}function dE(as,Sl,Ll){var Ql=as==null?0:as.length;if(!Ql)return-1;var yu=Ql-1;return Ll!==io&&(yu=g1(Ll),yu=Ll<0?f$(Ql+yu,0):y$(yu,Ql-1)),Kv(as,l1(Sl,3),yu,!0)}function fE(as){var Sl=as==null?0:as.length;return Sl?m$(as,1):[]}function QS(as){var Sl=as==null?0:as.length;return Sl?m$(as,_c):[]}function XS(as,Sl){var Ll=as==null?0:as.length;return Ll?(Sl=Sl===io?1:g1(Sl),m$(as,Sl)):[]}function e5(as){for(var Sl=-1,Ll=as==null?0:as.length,Ql={};++Sl<Ll;){var yu=as[Sl];Ql[yu[0]]=yu[1]}return Ql}function hE(as){return as&&as.length?as[0]:io}function t5(as,Sl,Ll){var Ql=as==null?0:as.length;if(!Ql)return-1;var yu=Ll==null?0:g1(Ll);return yu<0&&(yu=f$(Ql+yu,0)),uy(as,Sl,yu)}function r5(as){var Sl=as==null?0:as.length;return Sl?G$(as,0,-1):[]}var n5=v1(function(as){var Sl=H1(as,s2);return Sl.length&&Sl[0]===as[0]?Jw(Sl):[]}),o5=v1(function(as){var Sl=V$(as),Ll=H1(as,s2);return Sl===V$(Ll)?Sl=io:Ll.pop(),Ll.length&&Ll[0]===as[0]?Jw(Ll,l1(Sl,2)):[]}),i5=v1(function(as){var Sl=V$(as),Ll=H1(as,s2);return Sl=typeof Sl=="function"?Sl:io,Sl&&Ll.pop(),Ll.length&&Ll[0]===as[0]?Jw(Ll,io,Sl):[]});function a5(as,Sl){return as==null?"":rA.call(as,Sl)}function V$(as){var Sl=as==null?0:as.length;return Sl?as[Sl-1]:io}function s5(as,Sl,Ll){var Ql=as==null?0:as.length;if(!Ql)return-1;var yu=Ql;return Ll!==io&&(yu=g1(Ll),yu=yu<0?f$(Ql+yu,0):y$(yu,Ql-1)),Sl===Sl?U_(as,Sl,yu):Kv(as,V2,yu,!0)}function c5(as,Sl){return as&&as.length?A3(as,g1(Sl)):io}var l5=v1(pE);function pE(as,Sl){return as&&as.length&&Sl&&Sl.length?t2(as,Sl):as}function u5(as,Sl,Ll){return as&&as.length&&Sl&&Sl.length?t2(as,Sl,l1(Ll,2)):as}function d5(as,Sl,Ll){return as&&as.length&&Sl&&Sl.length?t2(as,Sl,io,Ll):as}var f5=mm(function(as,Sl){var Ll=as==null?0:as.length,Ql=Vw(as,Sl);return C3(as,H1(Sl,function(yu){return ym(yu,Ll)?+yu:yu}).sort(D3)),Ql});function h5(as,Sl){var Ll=[];if(!(as&&as.length))return Ll;var Ql=-1,yu=[],_d=as.length;for(Sl=l1(Sl,3);++Ql<_d;){var cp=as[Ql];Sl(cp,Ql,as)&&(Ll.push(cp),yu.push(Ql))}return C3(as,yu),Ll}function w2(as){return as==null?as:aA.call(as)}function p5(as,Sl,Ll){var Ql=as==null?0:as.length;return Ql?(Ll&&typeof Ll!="number"&&S$(as,Sl,Ll)?(Sl=0,Ll=Ql):(Sl=Sl==null?0:g1(Sl),Ll=Ll===io?Ql:g1(Ll)),G$(as,Sl,Ll)):[]}function $5(as,Sl){return sw(as,Sl)}function g5(as,Sl,Ll){return o2(as,Sl,l1(Ll,2))}function m5(as,Sl){var Ll=as==null?0:as.length;if(Ll){var Ql=sw(as,Sl);if(Ql<Ll&&X$(as[Ql],Sl))return Ql}return-1}function y5(as,Sl){return sw(as,Sl,!0)}function v5(as,Sl,Ll){return o2(as,Sl,l1(Ll,2),!0)}function b5(as,Sl){var Ll=as==null?0:as.length;if(Ll){var Ql=sw(as,Sl,!0)-1;if(X$(as[Ql],Sl))return Ql}return-1}function w5(as){return as&&as.length?T3(as):[]}function E5(as,Sl){return as&&as.length?T3(as,l1(Sl,2)):[]}function _5(as){var Sl=as==null?0:as.length;return Sl?G$(as,1,Sl):[]}function A5(as,Sl,Ll){return as&&as.length?(Sl=Ll||Sl===io?1:g1(Sl),G$(as,0,Sl<0?0:Sl)):[]}function S5(as,Sl,Ll){var Ql=as==null?0:as.length;return Ql?(Sl=Ll||Sl===io?1:g1(Sl),Sl=Ql-Sl,G$(as,Sl<0?0:Sl,Ql)):[]}function x5(as,Sl){return as&&as.length?cw(as,l1(Sl,3),!1,!0):[]}function C5(as,Sl){return as&&as.length?cw(as,l1(Sl,3)):[]}var I5=v1(function(as){return Pm(m$(as,1,h0,!0))}),T5=v1(function(as){var Sl=V$(as);return h0(Sl)&&(Sl=io),Pm(m$(as,1,h0,!0),l1(Sl,2))}),P5=v1(function(as){var Sl=V$(as);return Sl=typeof Sl=="function"?Sl:io,Pm(m$(as,1,h0,!0),io,Sl)});function R5(as){return as&&as.length?Pm(as):[]}function O5(as,Sl){return as&&as.length?Pm(as,l1(Sl,2)):[]}function M5(as,Sl){return Sl=typeof Sl=="function"?Sl:io,as&&as.length?Pm(as,io,Sl):[]}function E2(as){if(!(as&&as.length))return[];var Sl=0;return as=Sm(as,function(Ll){if(h0(Ll))return Sl=f$(Ll.length,Sl),!0}),Lw(Sl,function(Ll){return H1(as,jw(Ll))})}function $E(as,Sl){if(!(as&&as.length))return[];var Ll=E2(as);return Sl==null?Ll:H1(Ll,function(Ql){return $$(Sl,io,Ql)})}var N5=v1(function(as,Sl){return h0(as)?Wy(as,Sl):[]}),k5=v1(function(as){return a2(Sm(as,h0))}),j5=v1(function(as){var Sl=V$(as);return h0(Sl)&&(Sl=io),a2(Sm(as,h0),l1(Sl,2))}),D5=v1(function(as){var Sl=V$(as);return Sl=typeof Sl=="function"?Sl:io,a2(Sm(as,h0),io,Sl)}),B5=v1(E2);function L5(as,Sl){return M3(as||[],Sl||[],Ky)}function U5(as,Sl){return M3(as||[],Sl||[],Gy)}var F5=v1(function(as){var Sl=as.length,Ll=Sl>1?as[Sl-1]:io;return Ll=typeof Ll=="function"?(as.pop(),Ll):io,$E(as,Ll)});function gE(as){var Sl=Au(as);return Sl.__chain__=!0,Sl}function K5(as,Sl){return Sl(as),as}function mw(as,Sl){return Sl(as)}var W5=mm(function(as){var Sl=as.length,Ll=Sl?as[0]:0,Ql=this.__wrapped__,yu=function(_d){return Vw(_d,as)};return Sl>1||this.__actions__.length||!(Ql instanceof w1)||!ym(Ll)?this.thru(yu):(Ql=Ql.slice(Ll,+Ll+(Sl?1:0)),Ql.__actions__.push({func:mw,args:[yu],thisArg:io}),new z$(Ql,this.__chain__).thru(function(_d){return Sl&&!_d.length&&_d.push(io),_d}))});function z5(){return gE(this)}function H5(){return new z$(this.value(),this.__chain__)}function G5(){this.__values__===io&&(this.__values__=OE(this.value()));var as=this.__index__>=this.__values__.length,Sl=as?io:this.__values__[this.__index__++];return{done:as,value:Sl}}function V5(){return this}function q5(as){for(var Sl,Ll=this;Ll instanceof rw;){var Ql=lE(Ll);Ql.__index__=0,Ql.__values__=io,Sl?yu.__wrapped__=Ql:Sl=Ql;var yu=Ql;Ll=Ll.__wrapped__}return yu.__wrapped__=as,Sl}function Y5(){var as=this.__wrapped__;if(as instanceof w1){var Sl=as;return this.__actions__.length&&(Sl=new w1(this)),Sl=Sl.reverse(),Sl.__actions__.push({func:mw,args:[w2],thisArg:io}),new z$(Sl,this.__chain__)}return this.thru(w2)}function Z5(){return O3(this.__wrapped__,this.__actions__)}var J5=lw(function(as,Sl,Ll){k1.call(as,Ll)?++as[Ll]:$m(as,Ll,1)});function Q5(as,Sl,Ll){var Ql=$1(as)?H2:KA;return Ll&&S$(as,Sl,Ll)&&(Sl=io),Ql(as,l1(Sl,3))}function X5(as,Sl){var Ll=$1(as)?Sm:$3;return Ll(as,l1(Sl,3))}var ex=W3(uE),tx=W3(dE);function rx(as,Sl){return m$(yw(as,Sl),1)}function nx(as,Sl){return m$(yw(as,Sl),_c)}function ox(as,Sl,Ll){return Ll=Ll===io?1:g1(Ll),m$(yw(as,Sl),Ll)}function mE(as,Sl){var Ll=$1(as)?K$:Tm;return Ll(as,l1(Sl,3))}function yE(as,Sl){var Ll=$1(as)?__:p3;return Ll(as,l1(Sl,3))}var ix=lw(function(as,Sl,Ll){k1.call(as,Ll)?as[Ll].push(Sl):$m(as,Ll,[Sl])});function ax(as,Sl,Ll,Ql){as=R$(as)?as:Ey(as),Ll=Ll&&!Ql?g1(Ll):0;var yu=as.length;return Ll<0&&(Ll=f$(yu+Ll,0)),Aw(as)?Ll<=yu&&as.indexOf(Sl,Ll)>-1:!!yu&&uy(as,Sl,Ll)>-1}var sx=v1(function(as,Sl,Ll){var Ql=-1,yu=typeof Sl=="function",_d=R$(as)?Ep(as.length):[];return Tm(as,function(cp){_d[++Ql]=yu?$$(Sl,cp,Ll):zy(cp,Sl,Ll)}),_d}),lx=lw(function(as,Sl,Ll){$m(as,Ll,Sl)});function yw(as,Sl){var Ll=$1(as)?H1:w3;return Ll(as,l1(Sl,3))}function ux(as,Sl,Ll,Ql){return as==null?[]:($1(Sl)||(Sl=Sl==null?[]:[Sl]),Ll=Ql?io:Ll,$1(Ll)||(Ll=Ll==null?[]:[Ll]),S3(as,Sl,Ll))}var dx=lw(function(as,Sl,Ll){as[Ll?0:1].push(Sl)},function(){return[[],[]]});function fx(as,Sl,Ll){var Ql=$1(as)?Nw:Y2,yu=arguments.length<3;return Ql(as,l1(Sl,4),Ll,yu,Tm)}function hx(as,Sl,Ll){var Ql=$1(as)?A_:Y2,yu=arguments.length<3;return Ql(as,l1(Sl,4),Ll,yu,p3)}function $x(as,Sl){var Ll=$1(as)?Sm:$3;return Ll(as,Ew(l1(Sl,3)))}function gx(as){var Sl=$1(as)?u3:aS;return Sl(as)}function mx(as,Sl,Ll){(Ll?S$(as,Sl,Ll):Sl===io)?Sl=1:Sl=g1(Sl);var Ql=$1(as)?DA:sS;return Ql(as,Sl)}function yx(as){var Sl=$1(as)?BA:lS;return Sl(as)}function vx(as){if(as==null)return 0;if(R$(as))return Aw(as)?fy(as):as.length;var Sl=v$(as);return Sl==bu||Sl==$p?as.size:Xw(as).length}function bx(as,Sl,Ll){var Ql=$1(as)?kw:uS;return Ll&&S$(as,Sl,Ll)&&(Sl=io),Ql(as,l1(Sl,3))}var wx=v1(function(as,Sl){if(as==null)return[];var Ll=Sl.length;return Ll>1&&S$(as,Sl[0],Sl[1])?Sl=[]:Ll>2&&S$(Sl[0],Sl[1],Sl[2])&&(Sl=[Sl[0]]),S3(as,m$(Sl,1),[])}),bw=X_||function(){return A1.Date.now()};function Ex(as,Sl){if(typeof Sl!="function")throw new W$(Ao);return as=g1(as),function(){if(--as<1)return Sl.apply(this,arguments)}}function vE(as,Sl,Ll){return Sl=Ll?io:Sl,Sl=as&&Sl==null?as.length:Sl,gm(as,Tl,io,io,io,io,Sl)}function bE(as,Sl){var Ll;if(typeof Sl!="function")throw new W$(Ao);return as=g1(as),function(){return--as>0&&(Ll=Sl.apply(this,arguments)),as<=1&&(Sl=io),Ll}}var _2=v1(function(as,Sl,Ll){var Ql=yl;if(Ll.length){var yu=Cm(Ll,by(_2));Ql|=Il}return gm(as,Ql,Sl,Ll,yu)}),wE=v1(function(as,Sl,Ll){var Ql=yl|us;if(Ll.length){var yu=Cm(Ll,by(wE));Ql|=Il}return gm(Sl,Ql,as,Ll,yu)});function _E(as,Sl,Ll){Sl=Ll?io:Sl;var Ql=gm(as,_l,io,io,io,io,io,Sl);return Ql.placeholder=_E.placeholder,Ql}function AE(as,Sl,Ll){Sl=Ll?io:Sl;var Ql=gm(as,xl,io,io,io,io,io,Sl);return Ql.placeholder=AE.placeholder,Ql}function SE(as,Sl,Ll){var Ql,yu,_d,cp,lp,pp,Ip=0,Tp=!1,kp=!1,n1=!0;if(typeof as!="function")throw new W$(Ao);Sl=q$(Sl)||0,G1(Ll)&&(Tp=!!Ll.leading,kp="maxWait"in Ll,_d=kp?f$(q$(Ll.maxWait)||0,Sl):_d,n1="trailing"in Ll?!!Ll.trailing:n1);function c1(e$){var _g=Ql,wm=yu;return Ql=yu=io,Ip=e$,cp=as.apply(wm,_g),cp}function u1(e$){return Ip=e$,lp=Yy(b1,Sl),Tp?c1(e$):cp}function m1(e$){var _g=e$-pp,wm=e$-Ip,HE=Sl-_g;return kp?y$(HE,_d-wm):HE}function d1(e$){var _g=e$-pp,wm=e$-Ip;return pp===io||_g>=Sl||_g<0||kp&&wm>=_d}function b1(){var e$=bw();if(d1(e$))return x1(e$);lp=Yy(b1,m1(e$))}function x1(e$){return lp=io,n1&&Ql?c1(e$):(Ql=yu=io,cp)}function B$(){lp!==io&&N3(lp),Ip=0,Ql=pp=yu=lp=io}function x$(){return lp===io?cp:x1(bw())}function L$(){var e$=bw(),_g=d1(e$);if(Ql=arguments,yu=this,pp=e$,_g){if(lp===io)return u1(pp);if(kp)return N3(lp),lp=Yy(b1,Sl),c1(pp)}return lp===io&&(lp=Yy(b1,Sl)),cp}return L$.cancel=B$,L$.flush=x$,L$}var _x=v1(function(as,Sl){return h3(as,1,Sl)}),Ax=v1(function(as,Sl,Ll){return h3(as,q$(Sl)||0,Ll)});function Sx(as){return gm(as,Nl)}function ww(as,Sl){if(typeof as!="function"||Sl!=null&&typeof Sl!="function")throw new W$(Ao);var Ll=function(){var Ql=arguments,yu=Sl?Sl.apply(this,Ql):Ql[0],_d=Ll.cache;if(_d.has(yu))return _d.get(yu);var cp=as.apply(this,Ql);return Ll.cache=_d.set(yu,cp)||_d,cp};return Ll.cache=new(ww.Cache||pm),Ll}ww.Cache=pm;function Ew(as){if(typeof as!="function")throw new W$(Ao);return function(){var Sl=arguments;switch(Sl.length){case 0:return!as.call(this);case 1:return!as.call(this,Sl[0]);case 2:return!as.call(this,Sl[0],Sl[1]);case 3:return!as.call(this,Sl[0],Sl[1],Sl[2])}return!as.apply(this,Sl)}}function xx(as){return bE(2,as)}var Cx=dS(function(as,Sl){Sl=Sl.length==1&&$1(Sl[0])?H1(Sl[0],k$(l1())):H1(m$(Sl,1),k$(l1()));var Ll=Sl.length;return v1(function(Ql){for(var yu=-1,_d=y$(Ql.length,Ll);++yu<_d;)Ql[yu]=Sl[yu].call(this,Ql[yu]);return $$(as,this,Ql)})}),A2=v1(function(as,Sl){var Ll=Cm(Sl,by(A2));return gm(as,Il,io,Sl,Ll)}),xE=v1(function(as,Sl){var Ll=Cm(Sl,by(xE));return gm(as,Ol,io,Sl,Ll)}),Ix=mm(function(as,Sl){return gm(as,Cl,io,io,io,Sl)});function Tx(as,Sl){if(typeof as!="function")throw new W$(Ao);return Sl=Sl===io?Sl:g1(Sl),v1(as,Sl)}function Px(as,Sl){if(typeof as!="function")throw new W$(Ao);return Sl=Sl==null?0:f$(g1(Sl),0),v1(function(Ll){var Ql=Ll[Sl],yu=Om(Ll,0,Sl);return Ql&&xm(yu,Ql),$$(as,this,yu)})}function Rx(as,Sl,Ll){var Ql=!0,yu=!0;if(typeof as!="function")throw new W$(Ao);return G1(Ll)&&(Ql="leading"in Ll?!!Ll.leading:Ql,yu="trailing"in Ll?!!Ll.trailing:yu),SE(as,Sl,{leading:Ql,maxWait:Sl,trailing:yu})}function Ox(as){return vE(as,1)}function Mx(as,Sl){return A2(c2(Sl),as)}function Nx(){if(!arguments.length)return[];var as=arguments[0];return $1(as)?as:[as]}function kx(as){return H$(as,Yo)}function jx(as,Sl){return Sl=typeof Sl=="function"?Sl:io,H$(as,Yo,Sl)}function Dx(as){return H$(as,Go|Yo)}function Bx(as,Sl){return Sl=typeof Sl=="function"?Sl:io,H$(as,Go|Yo,Sl)}function Lx(as,Sl){return Sl==null||f3(as,Sl,g$(Sl))}function X$(as,Sl){return as===Sl||as!==as&&Sl!==Sl}var Ux=hw(Zw),Fx=hw(function(as,Sl){return as>=Sl}),ey=y3(function(){return arguments}())?y3:function(as){return J1(as)&&k1.call(as,"callee")&&!o3.call(as,"callee")},$1=Ep.isArray,Kx=_$?k$(_$):qA;function R$(as){return as!=null&&_w(as.length)&&!vm(as)}function h0(as){return J1(as)&&R$(as)}function Wx(as){return as===!0||as===!1||J1(as)&&A$(as)==Fl}var Mm=tA||k2,zx=Z$?k$(Z$):YA;function Hx(as){return J1(as)&&as.nodeType===1&&!Zy(as)}function Gx(as){if(as==null)return!0;if(R$(as)&&($1(as)||typeof as=="string"||typeof as.splice=="function"||Mm(as)||wy(as)||ey(as)))return!as.length;var Sl=v$(as);if(Sl==bu||Sl==$p)return!as.size;if(qy(as))return!Xw(as).length;for(var Ll in as)if(k1.call(as,Ll))return!1;return!0}function Vx(as,Sl){return Hy(as,Sl)}function qx(as,Sl,Ll){Ll=typeof Ll=="function"?Ll:io;var Ql=Ll?Ll(as,Sl):io;return Ql===io?Hy(as,Sl,io,Ll):!!Ql}function S2(as){if(!J1(as))return!1;var Sl=A$(as);return Sl==Kl||Sl==Bl||typeof as.message=="string"&&typeof as.name=="string"&&!Zy(as)}function Yx(as){return typeof as=="number"&&a3(as)}function vm(as){if(!G1(as))return!1;var Sl=A$(as);return Sl==Gl||Sl==fu||Sl==Ml||Sl==ip}function CE(as){return typeof as=="number"&&as==g1(as)}function _w(as){return typeof as=="number"&&as>-1&&as%1==0&&as<=$l}function G1(as){var Sl=typeof as;return as!=null&&(Sl=="object"||Sl=="function")}function J1(as){return as!=null&&typeof as=="object"}var IE=F$?k$(F$):JA;function Zx(as,Sl){return as===Sl||Qw(as,Sl,$2(Sl))}function Jx(as,Sl,Ll){return Ll=typeof Ll=="function"?Ll:io,Qw(as,Sl,$2(Sl),Ll)}function Qx(as){return TE(as)&&as!=+as}function Xx(as){if(NS(as))throw new h1(mo);return v3(as)}function e4(as){return as===null}function t4(as){return as==null}function TE(as){return typeof as=="number"||J1(as)&&A$(as)==rp}function Zy(as){if(!J1(as)||A$(as)!=op)return!1;var Sl=Zv(as);if(Sl===null)return!0;var Ll=k1.call(Sl,"constructor")&&Sl.constructor;return typeof Ll=="function"&&Ll instanceof Ll&&Gv.call(Ll)==Y_}var x2=om?k$(om):QA;function r4(as){return CE(as)&&as>=-$l&&as<=$l}var PE=ky?k$(ky):XA;function Aw(as){return typeof as=="string"||!$1(as)&&J1(as)&&A$(as)==gp}function D$(as){return typeof as=="symbol"||J1(as)&&A$(as)==yp}var wy=Gm?k$(Gm):eS;function n4(as){return as===io}function o4(as){return J1(as)&&v$(as)==mp}function i4(as){return J1(as)&&A$(as)==wp}var a4=hw(e2),s4=hw(function(as,Sl){return as<=Sl});function OE(as){if(!as)return[];if(R$(as))return Aw(as)?J$(as):P$(as);if(Dy&&as[Dy])return D_(as[Dy]());var Sl=v$(as),Ll=Sl==bu?Fw:Sl==$p?Wv:Ey;return Ll(as)}function bm(as){if(!as)return as===0?as:0;if(as=q$(as),as===_c||as===-_c){var Sl=as<0?-1:1;return Sl*El}return as===as?as:0}function g1(as){var Sl=bm(as),Ll=Sl%1;return Sl===Sl?Ll?Sl-Ll:Sl:0}function ME(as){return as?Zm(g1(as),0,os):0}function q$(as){if(typeof as=="number")return as;if(D$(as))return ds;if(G1(as)){var Sl=typeof as.valueOf=="function"?as.valueOf():as;as=G1(Sl)?Sl+"":Sl}if(typeof as!="string")return as===0?as:+as;as=Z2(as);var Ll=R1.test(as);return Ll||M1.test(as)?p1(as.slice(2),Ll?2:8):f1.test(as)?ds:+as}function NE(as){return am(as,O$(as))}function c4(as){return as?Zm(g1(as),-$l,$l):as===0?as:0}function I1(as){return as==null?"":j$(as)}var l4=yy(function(as,Sl){if(qy(Sl)||R$(Sl)){am(Sl,g$(Sl),as);return}for(var Ll in Sl)k1.call(Sl,Ll)&&Ky(as,Ll,Sl[Ll])}),kE=yy(function(as,Sl){am(Sl,O$(Sl),as)}),Sw=yy(function(as,Sl,Ll,Ql){am(Sl,O$(Sl),as,Ql)}),u4=yy(function(as,Sl,Ll,Ql){am(Sl,g$(Sl),as,Ql)}),d4=mm(Vw);function f4(as,Sl){var Ll=my(as);return Sl==null?Ll:d3(Ll,Sl)}var h4=v1(function(as,Sl){as=K1(as);var Ll=-1,Ql=Sl.length,yu=Ql>2?Sl[2]:io;for(yu&&S$(Sl[0],Sl[1],yu)&&(Ql=1);++Ll<Ql;)for(var _d=Sl[Ll],cp=O$(_d),lp=-1,pp=cp.length;++lp<pp;){var Ip=cp[lp],Tp=as[Ip];(Tp===io||X$(Tp,py[Ip])&&!k1.call(as,Ip))&&(as[Ip]=_d[Ip])}return as}),p4=v1(function(as){return as.push(io,Z3),$$(jE,io,as)});function $4(as,Sl){return G2(as,l1(Sl,3),im)}function g4(as,Sl){return G2(as,l1(Sl,3),Yw)}function m4(as,Sl){return as==null?as:qw(as,l1(Sl,3),O$)}function y4(as,Sl){return as==null?as:g3(as,l1(Sl,3),O$)}function v4(as,Sl){return as&&im(as,l1(Sl,3))}function b4(as,Sl){return as&&Yw(as,l1(Sl,3))}function w4(as){return as==null?[]:iw(as,g$(as))}function E4(as){return as==null?[]:iw(as,O$(as))}function C2(as,Sl,Ll){var Ql=as==null?io:Jm(as,Sl);return Ql===io?Ll:Ql}function _4(as,Sl){return as!=null&&X3(as,Sl,zA)}function I2(as,Sl){return as!=null&&X3(as,Sl,HA)}var A4=H3(function(as,Sl,Ll){Sl!=null&&typeof Sl.toString!="function"&&(Sl=Vv.call(Sl)),as[Sl]=Ll},P2(M$)),S4=H3(function(as,Sl,Ll){Sl!=null&&typeof Sl.toString!="function"&&(Sl=Vv.call(Sl)),k1.call(as,Sl)?as[Sl].push(Ll):as[Sl]=[Ll]},l1),x4=v1(zy);function g$(as){return R$(as)?l3(as):Xw(as)}function O$(as){return R$(as)?l3(as,!0):tS(as)}function C4(as,Sl){var Ll={};return Sl=l1(Sl,3),im(as,function(Ql,yu,_d){$m(Ll,Sl(Ql,yu,_d),Ql)}),Ll}function I4(as,Sl){var Ll={};return Sl=l1(Sl,3),im(as,function(Ql,yu,_d){$m(Ll,yu,Sl(Ql,yu,_d))}),Ll}var T4=yy(function(as,Sl,Ll){aw(as,Sl,Ll)}),jE=yy(function(as,Sl,Ll,Ql){aw(as,Sl,Ll,Ql)}),P4=mm(function(as,Sl){var Ll={};if(as==null)return Ll;var Ql=!1;Sl=H1(Sl,function(_d){return _d=Rm(_d,as),Ql||(Ql=_d.length>1),_d}),am(as,h2(as),Ll),Ql&&(Ll=H$(Ll,Go|Vo|Yo,ES));for(var yu=Sl.length;yu--;)i2(Ll,Sl[yu]);return Ll});function R4(as,Sl){return DE(as,Ew(l1(Sl)))}var O4=mm(function(as,Sl){return as==null?{}:nS(as,Sl)});function DE(as,Sl){if(as==null)return{};var Ll=H1(h2(as),function(Ql){return[Ql]});return Sl=l1(Sl),x3(as,Ll,function(Ql,yu){return Sl(Ql,yu[0])})}function M4(as,Sl,Ll){Sl=Rm(Sl,as);var Ql=-1,yu=Sl.length;for(yu||(yu=1,as=io);++Ql<yu;){var _d=as==null?io:as[sm(Sl[Ql])];_d===io&&(Ql=yu,_d=Ll),as=vm(_d)?_d.call(as):_d}return as}function N4(as,Sl,Ll){return as==null?as:Gy(as,Sl,Ll)}function k4(as,Sl,Ll,Ql){return Ql=typeof Ql=="function"?Ql:io,as==null?as:Gy(as,Sl,Ll,Ql)}var BE=q3(g$),LE=q3(O$);function j4(as,Sl,Ll){var Ql=$1(as),yu=Ql||Mm(as)||wy(as);if(Sl=l1(Sl,4),Ll==null){var _d=as&&as.constructor;yu?Ll=Ql?new _d:[]:G1(as)?Ll=vm(_d)?my(Zv(as)):{}:Ll={}}return(yu?K$:im)(as,function(cp,lp,pp){return Sl(Ll,cp,lp,pp)}),Ll}function D4(as,Sl){return as==null?!0:i2(as,Sl)}function B4(as,Sl,Ll){return as==null?as:R3(as,Sl,c2(Ll))}function L4(as,Sl,Ll,Ql){return Ql=typeof Ql=="function"?Ql:io,as==null?as:R3(as,Sl,c2(Ll),Ql)}function Ey(as){return as==null?[]:Uw(as,g$(as))}function U4(as){return as==null?[]:Uw(as,O$(as))}function F4(as,Sl,Ll){return Ll===io&&(Ll=Sl,Sl=io),Ll!==io&&(Ll=q$(Ll),Ll=Ll===Ll?Ll:0),Sl!==io&&(Sl=q$(Sl),Sl=Sl===Sl?Sl:0),Zm(q$(as),Sl,Ll)}function K4(as,Sl,Ll){return Sl=bm(Sl),Ll===io?(Ll=Sl,Sl=0):Ll=bm(Ll),as=q$(as),GA(as,Sl,Ll)}function W4(as,Sl,Ll){if(Ll&&typeof Ll!="boolean"&&S$(as,Sl,Ll)&&(Sl=Ll=io),Ll===io&&(typeof Sl=="boolean"?(Ll=Sl,Sl=io):typeof as=="boolean"&&(Ll=as,as=io)),as===io&&Sl===io?(as=0,Sl=1):(as=bm(as),Sl===io?(Sl=as,as=0):Sl=bm(Sl)),as>Sl){var Ql=as;as=Sl,Sl=Ql}if(Ll||as%1||Sl%1){var yu=s3();return y$(as+yu*(Sl-as+U1("1e-"+((yu+"").length-1))),Sl)}return r2(as,Sl)}var z4=vy(function(as,Sl,Ll){return Sl=Sl.toLowerCase(),as+(Ll?UE(Sl):Sl)});function UE(as){return T2(I1(as).toLowerCase())}function FE(as){return as=I1(as),as&&as.replace(E1,O_).replace(Rw,"")}function H4(as,Sl,Ll){as=I1(as),Sl=j$(Sl);var Ql=as.length;Ll=Ll===io?Ql:Zm(g1(Ll),0,Ql);var yu=Ll;return Ll-=Sl.length,Ll>=0&&as.slice(Ll,yu)==Sl}function G4(as){return as=I1(as),as&&Dp.test(as)?as.replace(a1,M_):as}function V4(as){return as=I1(as),as&&Vp.test(as)?as.replace(Qp,"\\$&"):as}var q4=vy(function(as,Sl,Ll){return as+(Ll?"-":"")+Sl.toLowerCase()}),Y4=vy(function(as,Sl,Ll){return as+(Ll?" ":"")+Sl.toLowerCase()}),Z4=K3("toLowerCase");function J4(as,Sl,Ll){as=I1(as),Sl=g1(Sl);var Ql=Sl?fy(as):0;if(!Sl||Ql>=Sl)return as;var yu=(Sl-Ql)/2;return fw(_b(yu),Ll)+as+fw(Xv(yu),Ll)}function Q4(as,Sl,Ll){as=I1(as),Sl=g1(Sl);var Ql=Sl?fy(as):0;return Sl&&Ql<Sl?as+fw(Sl-Ql,Ll):as}function X4(as,Sl,Ll){as=I1(as),Sl=g1(Sl);var Ql=Sl?fy(as):0;return Sl&&Ql<Sl?fw(Sl-Ql,Ll)+as:as}function e6(as,Sl,Ll){return Ll||Sl==null?Sl=0:Sl&&(Sl=+Sl),iA(I1(as).replace(Wp,""),Sl||0)}function t6(as,Sl,Ll){return(Ll?S$(as,Sl,Ll):Sl===io)?Sl=1:Sl=g1(Sl),n2(I1(as),Sl)}function r6(){var as=arguments,Sl=I1(as[0]);return as.length<3?Sl:Sl.replace(as[1],as[2])}var n6=vy(function(as,Sl,Ll){return as+(Ll?"_":"")+Sl.toLowerCase()});function o6(as,Sl,Ll){return Ll&&typeof Ll!="number"&&S$(as,Sl,Ll)&&(Sl=Ll=io),Ll=Ll===io?os:Ll>>>0,Ll?(as=I1(as),as&&(typeof Sl=="string"||Sl!=null&&!x2(Sl))&&(Sl=j$(Sl),!Sl&&dy(as))?Om(J$(as),0,Ll):as.split(Sl,Ll)):[]}var i6=vy(function(as,Sl,Ll){return as+(Ll?" ":"")+T2(Sl)});function a6(as,Sl,Ll){return as=I1(as),Ll=Ll==null?0:Zm(g1(Ll),0,as.length),Sl=j$(Sl),as.slice(Ll,Ll+Sl.length)==Sl}function s6(as,Sl,Ll){var Ql=Au.templateSettings;Ll&&S$(as,Sl,Ll)&&(Sl=io),as=I1(as),Sl=Sw({},Sl,Ql,Y3);var yu=Sw({},Sl.imports,Ql.imports,Y3),_d=g$(yu),cp=Uw(yu,_d),lp,pp,Ip=0,Tp=Sl.interpolate||q1,kp="__p += '",n1=Kw((Sl.escape||q1).source+"|"+Tp.source+"|"+(Tp===Bp?t1:q1).source+"|"+(Sl.evaluate||q1).source+"|$","g"),c1="//# sourceURL="+(k1.call(Sl,"sourceURL")?(Sl.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Ow+"]")+`
`;as.replace(n1,function(d1,b1,x1,B$,x$,L$){return x1||(x1=B$),kp+=as.slice(Ip,L$).replace(i$,N_),b1&&(lp=!0,kp+=`' +
__e(`+b1+`) +
'`),x$&&(pp=!0,kp+=`';
`+x$+`;
__p += '`),x1&&(kp+=`' +
((__t = (`+x1+`)) == null ? '' : __t) +
'`),Ip=L$+d1.length,d1}),kp+=`';
`;var u1=k1.call(Sl,"variable")&&Sl.variable;if(!u1)kp=`with (obj) {
`+kp+`
}
`;else if(e1.test(u1))throw new h1(jo);kp=(pp?kp.replace(Op,""):kp).replace(Lp,"$1").replace(Mp,"$1;"),kp="function("+(u1||"obj")+`) {
`+(u1?"":`obj || (obj = {});
`)+"var __t, __p = ''"+(lp?", __e = _.escape":"")+(pp?`, __j = Array.prototype.join;
function print() { __p += __j.call(arguments, '') }
`:`;
`)+kp+`return __p
}`;var m1=WE(function(){return C1(_d,c1+"return "+kp).apply(io,cp)});if(m1.source=kp,S2(m1))throw m1;return m1}function c6(as){return I1(as).toLowerCase()}function l6(as){return I1(as).toUpperCase()}function u6(as,Sl,Ll){if(as=I1(as),as&&(Ll||Sl===io))return Z2(as);if(!as||!(Sl=j$(Sl)))return as;var Ql=J$(as),yu=J$(Sl),_d=J2(Ql,yu),cp=Q2(Ql,yu)+1;return Om(Ql,_d,cp).join("")}function d6(as,Sl,Ll){if(as=I1(as),as&&(Ll||Sl===io))return as.slice(0,e3(as)+1);if(!as||!(Sl=j$(Sl)))return as;var Ql=J$(as),yu=Q2(Ql,J$(Sl))+1;return Om(Ql,0,yu).join("")}function f6(as,Sl,Ll){if(as=I1(as),as&&(Ll||Sl===io))return as.replace(Wp,"");if(!as||!(Sl=j$(Sl)))return as;var Ql=J$(as),yu=J2(Ql,J$(Sl));return Om(Ql,yu).join("")}function h6(as,Sl){var Ll=Wl,Ql=Dl;if(G1(Sl)){var yu="separator"in Sl?Sl.separator:yu;Ll="length"in Sl?g1(Sl.length):Ll,Ql="omission"in Sl?j$(Sl.omission):Ql}as=I1(as);var _d=as.length;if(dy(as)){var cp=J$(as);_d=cp.length}if(Ll>=_d)return as;var lp=Ll-fy(Ql);if(lp<1)return Ql;var pp=cp?Om(cp,0,lp).join(""):as.slice(0,lp);if(yu===io)return pp+Ql;if(cp&&(lp+=pp.length-lp),x2(yu)){if(as.slice(lp).search(yu)){var Ip,Tp=pp;for(yu.global||(yu=Kw(yu.source,I1(Yp.exec(yu))+"g")),yu.lastIndex=0;Ip=yu.exec(Tp);)var kp=Ip.index;pp=pp.slice(0,kp===io?lp:kp)}}else if(as.indexOf(j$(yu),lp)!=lp){var n1=pp.lastIndexOf(yu);n1>-1&&(pp=pp.slice(0,n1))}return pp+Ql}function p6(as){return as=I1(as),as&&Up.test(as)?as.replace(Pp,F_):as}var $6=vy(function(as,Sl,Ll){return as+(Ll?" ":"")+Sl.toUpperCase()}),T2=K3("toUpperCase");function KE(as,Sl,Ll){return as=I1(as),Sl=Ll?io:Sl,Sl===io?j_(as)?z_(as):C_(as):as.match(Sl)||[]}var WE=v1(function(as,Sl){try{return $$(as,io,Sl)}catch(Ll){return S2(Ll)?Ll:new h1(Ll)}}),g6=mm(function(as,Sl){return K$(Sl,function(Ll){Ll=sm(Ll),$m(as,Ll,_2(as[Ll],as))}),as});function m6(as){var Sl=as==null?0:as.length,Ll=l1();return as=Sl?H1(as,function(Ql){if(typeof Ql[1]!="function")throw new W$(Ao);return[Ll(Ql[0]),Ql[1]]}):[],v1(function(Ql){for(var yu=-1;++yu<Sl;){var _d=as[yu];if($$(_d[0],this,Ql))return $$(_d[1],this,Ql)}})}function y6(as){return FA(H$(as,Go))}function P2(as){return function(){return as}}function v6(as,Sl){return as==null||as!==as?Sl:as}var b6=z3(),w6=z3(!0);function M$(as){return as}function R2(as){return b3(typeof as=="function"?as:H$(as,Go))}function E6(as){return E3(H$(as,Go))}function _6(as,Sl){return _3(as,H$(Sl,Go))}var A6=v1(function(as,Sl){return function(Ll){return zy(Ll,as,Sl)}}),S6=v1(function(as,Sl){return function(Ll){return zy(as,Ll,Sl)}});function O2(as,Sl,Ll){var Ql=g$(Sl),yu=iw(Sl,Ql);Ll==null&&!(G1(Sl)&&(yu.length||!Ql.length))&&(Ll=Sl,Sl=as,as=this,yu=iw(Sl,g$(Sl)));var _d=!(G1(Ll)&&"chain"in Ll)||!!Ll.chain,cp=vm(as);return K$(yu,function(lp){var pp=Sl[lp];as[lp]=pp,cp&&(as.prototype[lp]=function(){var Ip=this.__chain__;if(_d||Ip){var Tp=as(this.__wrapped__),kp=Tp.__actions__=P$(this.__actions__);return kp.push({func:pp,args:arguments,thisArg:as}),Tp.__chain__=Ip,Tp}return pp.apply(as,xm([this.value()],arguments))})}),as}function x6(){return A1._===this&&(A1._=Z_),this}function M2(){}function C6(as){return as=g1(as),v1(function(Sl){return A3(Sl,as)})}var I6=u2(H1),T6=u2(H2),P6=u2(kw);function zE(as){return m2(as)?jw(sm(as)):oS(as)}function R6(as){return function(Sl){return as==null?io:Jm(as,Sl)}}var O6=G3(),M6=G3(!0);function N2(){return[]}function k2(){return!1}function N6(){return{}}function k6(){return""}function j6(){return!0}function D6(as,Sl){if(as=g1(as),as<1||as>$l)return[];var Ll=os,Ql=y$(as,os);Sl=l1(Sl),as-=os;for(var yu=Lw(Ql,Sl);++Ll<as;)Sl(Ll);return yu}function B6(as){return $1(as)?H1(as,sm):D$(as)?[as]:P$(cE(I1(as)))}function L6(as){var Sl=++q_;return I1(as)+Sl}var U6=dw(function(as,Sl){return as+Sl},0),F6=d2("ceil"),K6=dw(function(as,Sl){return as/Sl},1),W6=d2("floor");function z6(as){return as&&as.length?ow(as,M$,Zw):io}function H6(as,Sl){return as&&as.length?ow(as,l1(Sl,2),Zw):io}function G6(as){return q2(as,M$)}function V6(as,Sl){return q2(as,l1(Sl,2))}function q6(as){return as&&as.length?ow(as,M$,e2):io}function Y6(as,Sl){return as&&as.length?ow(as,l1(Sl,2),e2):io}var Z6=dw(function(as,Sl){return as*Sl},1),J6=d2("round"),Q6=dw(function(as,Sl){return as-Sl},0);function X6(as){return as&&as.length?Bw(as,M$):0}function eC(as,Sl){return as&&as.length?Bw(as,l1(Sl,2)):0}return Au.after=Ex,Au.ary=vE,Au.assign=l4,Au.assignIn=kE,Au.assignInWith=Sw,Au.assignWith=u4,Au.at=d4,Au.before=bE,Au.bind=_2,Au.bindAll=g6,Au.bindKey=wE,Au.castArray=Nx,Au.chain=gE,Au.chunk=FS,Au.compact=KS,Au.concat=WS,Au.cond=m6,Au.conforms=y6,Au.constant=P2,Au.countBy=J5,Au.create=f4,Au.curry=_E,Au.curryRight=AE,Au.debounce=SE,Au.defaults=h4,Au.defaultsDeep=p4,Au.defer=_x,Au.delay=Ax,Au.difference=zS,Au.differenceBy=HS,Au.differenceWith=GS,Au.drop=VS,Au.dropRight=qS,Au.dropRightWhile=YS,Au.dropWhile=ZS,Au.fill=JS,Au.filter=X5,Au.flatMap=rx,Au.flatMapDeep=nx,Au.flatMapDepth=ox,Au.flatten=fE,Au.flattenDeep=QS,Au.flattenDepth=XS,Au.flip=Sx,Au.flow=b6,Au.flowRight=w6,Au.fromPairs=e5,Au.functions=w4,Au.functionsIn=E4,Au.groupBy=ix,Au.initial=r5,Au.intersection=n5,Au.intersectionBy=o5,Au.intersectionWith=i5,Au.invert=A4,Au.invertBy=S4,Au.invokeMap=sx,Au.iteratee=R2,Au.keyBy=lx,Au.keys=g$,Au.keysIn=O$,Au.map=yw,Au.mapKeys=C4,Au.mapValues=I4,Au.matches=E6,Au.matchesProperty=_6,Au.memoize=ww,Au.merge=T4,Au.mergeWith=jE,Au.method=A6,Au.methodOf=S6,Au.mixin=O2,Au.negate=Ew,Au.nthArg=C6,Au.omit=P4,Au.omitBy=R4,Au.once=xx,Au.orderBy=ux,Au.over=I6,Au.overArgs=Cx,Au.overEvery=T6,Au.overSome=P6,Au.partial=A2,Au.partialRight=xE,Au.partition=dx,Au.pick=O4,Au.pickBy=DE,Au.property=zE,Au.propertyOf=R6,Au.pull=l5,Au.pullAll=pE,Au.pullAllBy=u5,Au.pullAllWith=d5,Au.pullAt=f5,Au.range=O6,Au.rangeRight=M6,Au.rearg=Ix,Au.reject=$x,Au.remove=h5,Au.rest=Tx,Au.reverse=w2,Au.sampleSize=mx,Au.set=N4,Au.setWith=k4,Au.shuffle=yx,Au.slice=p5,Au.sortBy=wx,Au.sortedUniq=w5,Au.sortedUniqBy=E5,Au.split=o6,Au.spread=Px,Au.tail=_5,Au.take=A5,Au.takeRight=S5,Au.takeRightWhile=x5,Au.takeWhile=C5,Au.tap=K5,Au.throttle=Rx,Au.thru=mw,Au.toArray=OE,Au.toPairs=BE,Au.toPairsIn=LE,Au.toPath=B6,Au.toPlainObject=NE,Au.transform=j4,Au.unary=Ox,Au.union=I5,Au.unionBy=T5,Au.unionWith=P5,Au.uniq=R5,Au.uniqBy=O5,Au.uniqWith=M5,Au.unset=D4,Au.unzip=E2,Au.unzipWith=$E,Au.update=B4,Au.updateWith=L4,Au.values=Ey,Au.valuesIn=U4,Au.without=N5,Au.words=KE,Au.wrap=Mx,Au.xor=k5,Au.xorBy=j5,Au.xorWith=D5,Au.zip=B5,Au.zipObject=L5,Au.zipObjectDeep=U5,Au.zipWith=F5,Au.entries=BE,Au.entriesIn=LE,Au.extend=kE,Au.extendWith=Sw,O2(Au,Au),Au.add=U6,Au.attempt=WE,Au.camelCase=z4,Au.capitalize=UE,Au.ceil=F6,Au.clamp=F4,Au.clone=kx,Au.cloneDeep=Dx,Au.cloneDeepWith=Bx,Au.cloneWith=jx,Au.conformsTo=Lx,Au.deburr=FE,Au.defaultTo=v6,Au.divide=K6,Au.endsWith=H4,Au.eq=X$,Au.escape=G4,Au.escapeRegExp=V4,Au.every=Q5,Au.find=ex,Au.findIndex=uE,Au.findKey=$4,Au.findLast=tx,Au.findLastIndex=dE,Au.findLastKey=g4,Au.floor=W6,Au.forEach=mE,Au.forEachRight=yE,Au.forIn=m4,Au.forInRight=y4,Au.forOwn=v4,Au.forOwnRight=b4,Au.get=C2,Au.gt=Ux,Au.gte=Fx,Au.has=_4,Au.hasIn=I2,Au.head=hE,Au.identity=M$,Au.includes=ax,Au.indexOf=t5,Au.inRange=K4,Au.invoke=x4,Au.isArguments=ey,Au.isArray=$1,Au.isArrayBuffer=Kx,Au.isArrayLike=R$,Au.isArrayLikeObject=h0,Au.isBoolean=Wx,Au.isBuffer=Mm,Au.isDate=zx,Au.isElement=Hx,Au.isEmpty=Gx,Au.isEqual=Vx,Au.isEqualWith=qx,Au.isError=S2,Au.isFinite=Yx,Au.isFunction=vm,Au.isInteger=CE,Au.isLength=_w,Au.isMap=IE,Au.isMatch=Zx,Au.isMatchWith=Jx,Au.isNaN=Qx,Au.isNative=Xx,Au.isNil=t4,Au.isNull=e4,Au.isNumber=TE,Au.isObject=G1,Au.isObjectLike=J1,Au.isPlainObject=Zy,Au.isRegExp=x2,Au.isSafeInteger=r4,Au.isSet=PE,Au.isString=Aw,Au.isSymbol=D$,Au.isTypedArray=wy,Au.isUndefined=n4,Au.isWeakMap=o4,Au.isWeakSet=i4,Au.join=a5,Au.kebabCase=q4,Au.last=V$,Au.lastIndexOf=s5,Au.lowerCase=Y4,Au.lowerFirst=Z4,Au.lt=a4,Au.lte=s4,Au.max=z6,Au.maxBy=H6,Au.mean=G6,Au.meanBy=V6,Au.min=q6,Au.minBy=Y6,Au.stubArray=N2,Au.stubFalse=k2,Au.stubObject=N6,Au.stubString=k6,Au.stubTrue=j6,Au.multiply=Z6,Au.nth=c5,Au.noConflict=x6,Au.noop=M2,Au.now=bw,Au.pad=J4,Au.padEnd=Q4,Au.padStart=X4,Au.parseInt=e6,Au.random=W4,Au.reduce=fx,Au.reduceRight=hx,Au.repeat=t6,Au.replace=r6,Au.result=M4,Au.round=J6,Au.runInContext=hp,Au.sample=gx,Au.size=vx,Au.snakeCase=n6,Au.some=bx,Au.sortedIndex=$5,Au.sortedIndexBy=g5,Au.sortedIndexOf=m5,Au.sortedLastIndex=y5,Au.sortedLastIndexBy=v5,Au.sortedLastIndexOf=b5,Au.startCase=i6,Au.startsWith=a6,Au.subtract=Q6,Au.sum=X6,Au.sumBy=eC,Au.template=s6,Au.times=D6,Au.toFinite=bm,Au.toInteger=g1,Au.toLength=ME,Au.toLower=c6,Au.toNumber=q$,Au.toSafeInteger=c4,Au.toString=I1,Au.toUpper=l6,Au.trim=u6,Au.trimEnd=d6,Au.trimStart=f6,Au.truncate=h6,Au.unescape=p6,Au.uniqueId=L6,Au.upperCase=$6,Au.upperFirst=T2,Au.each=mE,Au.eachRight=yE,Au.first=hE,O2(Au,function(){var as={};return im(Au,function(Sl,Ll){k1.call(Au.prototype,Ll)||(as[Ll]=Sl)}),as}(),{chain:!1}),Au.VERSION=fo,K$(["bind","bindKey","curry","curryRight","partial","partialRight"],function(as){Au[as].placeholder=Au}),K$(["drop","take"],function(as,Sl){w1.prototype[as]=function(Ll){Ll=Ll===io?1:f$(g1(Ll),0);var Ql=this.__filtered__&&!Sl?new w1(this):this.clone();return Ql.__filtered__?Ql.__takeCount__=y$(Ll,Ql.__takeCount__):Ql.__views__.push({size:y$(Ll,os),type:as+(Ql.__dir__<0?"Right":"")}),Ql},w1.prototype[as+"Right"]=function(Ll){return this.reverse()[as](Ll).reverse()}}),K$(["filter","map","takeWhile"],function(as,Sl){var Ll=Sl+1,Ql=Ll==Jo||Ll==ps;w1.prototype[as]=function(yu){var _d=this.clone();return _d.__iteratees__.push({iteratee:l1(yu,3),type:Ll}),_d.__filtered__=_d.__filtered__||Ql,_d}}),K$(["head","last"],function(as,Sl){var Ll="take"+(Sl?"Right":"");w1.prototype[as]=function(){return this[Ll](1).value()[0]}}),K$(["initial","tail"],function(as,Sl){var Ll="drop"+(Sl?"":"Right");w1.prototype[as]=function(){return this.__filtered__?new w1(this):this[Ll](1)}}),w1.prototype.compact=function(){return this.filter(M$)},w1.prototype.find=function(as){return this.filter(as).head()},w1.prototype.findLast=function(as){return this.reverse().find(as)},w1.prototype.invokeMap=v1(function(as,Sl){return typeof as=="function"?new w1(this):this.map(function(Ll){return zy(Ll,as,Sl)})}),w1.prototype.reject=function(as){return this.filter(Ew(l1(as)))},w1.prototype.slice=function(as,Sl){as=g1(as);var Ll=this;return Ll.__filtered__&&(as>0||Sl<0)?new w1(Ll):(as<0?Ll=Ll.takeRight(-as):as&&(Ll=Ll.drop(as)),Sl!==io&&(Sl=g1(Sl),Ll=Sl<0?Ll.dropRight(-Sl):Ll.take(Sl-as)),Ll)},w1.prototype.takeRightWhile=function(as){return this.reverse().takeWhile(as).reverse()},w1.prototype.toArray=function(){return this.take(os)},im(w1.prototype,function(as,Sl){var Ll=/^(?:filter|find|map|reject)|While$/.test(Sl),Ql=/^(?:head|last)$/.test(Sl),yu=Au[Ql?"take"+(Sl=="last"?"Right":""):Sl],_d=Ql||/^find/.test(Sl);yu&&(Au.prototype[Sl]=function(){var cp=this.__wrapped__,lp=Ql?[1]:arguments,pp=cp instanceof w1,Ip=lp[0],Tp=pp||$1(cp),kp=function(b1){var x1=yu.apply(Au,xm([b1],lp));return Ql&&n1?x1[0]:x1};Tp&&Ll&&typeof Ip=="function"&&Ip.length!=1&&(pp=Tp=!1);var n1=this.__chain__,c1=!!this.__actions__.length,u1=_d&&!n1,m1=pp&&!c1;if(!_d&&Tp){cp=m1?cp:new w1(this);var d1=as.apply(cp,lp);return d1.__actions__.push({func:mw,args:[kp],thisArg:io}),new z$(d1,n1)}return u1&&m1?as.apply(this,lp):(d1=this.thru(kp),u1?Ql?d1.value()[0]:d1.value():d1)})}),K$(["pop","push","shift","sort","splice","unshift"],function(as){var Sl=zv[as],Ll=/^(?:push|sort|unshift)$/.test(as)?"tap":"thru",Ql=/^(?:pop|shift)$/.test(as);Au.prototype[as]=function(){var yu=arguments;if(Ql&&!this.__chain__){var _d=this.value();return Sl.apply($1(_d)?_d:[],yu)}return this[Ll](function(cp){return Sl.apply($1(cp)?cp:[],yu)})}}),im(w1.prototype,function(as,Sl){var Ll=Au[{"ActionError":{"index":0,"kind":{"FunctionCallError":{"CompilationError":{"CodeDoesNotExist":{"account_id":"web4.nearbuilders.testnet"}}}}}}
1 automatic refund step from the network not shown.
This page reads FastNEAR's public transaction index and stores nothing. This command asks a NEAR archival node for the same transaction and needs no keys.
curl -s https://archival-rpc.testnet.fastnear.com -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":1,"method":"tx","params":{"tx_hash":"9dwNuMTrfdueX2A68ZUEop8SpAHWgJRwLdY7Ps9KLWuv","sender_account_id":"web4.nearbuilders.testnet","wait_until":"FINAL"}}'Vouch has its own page because testnet.nearblocks.io stopped indexing on 27 Sep 2026, so it can't show newer transactions.