1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6851],{16851:function(e,t,i){"use strict";i.r(t),i.d(t,{EthereumProvider:function(){return Qs},OPTIONAL_EVENTS:function(){return Ls},OPTIONAL_METHODS:function(){return Us},REQUIRED_EVENTS:function(){return Ms},REQUIRED_METHODS:function(){return qs},default:function(){return Zs}});var r=i(17187),n=i.n(r),s=i(15501),o=i(512),a=i(31416),c=i(73294),h=i(57664),u=i(37466),l=i(43631),p=i(66736),f=i(62873),d=i(65755),g=i(17563),y=i(60075),v=i(34155);function m(e,t){return e.includes(":")?[e]:t.chains||[]}const w="base10",_="base16",b="base64pad",E="utf8";function I(){const e=(0,a.randomBytes)(32);return(0,u.BB)(e,_)}function P(e){const t=(0,c.vp)((0,u.mL)(e,E));return(0,u.BB)(t,_)}function S(e){return Number((0,u.BB)(e,w))}function O(e){const t=function(e){return(0,u.mL)(`${e}`,w)}(typeof e.type<"u"?e.type:0);if(1===S(t)&&typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const i=typeof e.senderPublicKey<"u"?(0,u.mL)(e.senderPublicKey,_):void 0,r=typeof e.iv<"u"?(0,u.mL)(e.iv,_):(0,a.randomBytes)(12);return function(e){if(1===S(e.type)){if(typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return(0,u.BB)((0,u.zo)([e.type,e.senderPublicKey,e.iv,e.sealed]),b)}return(0,u.BB)((0,u.zo)([e.type,e.iv,e.sealed]),b)}({type:t,sealed:new s.OK((0,u.mL)(e.symKey,_)).seal(r,(0,u.mL)(e.message,E)),iv:r,senderPublicKey:i})}function R(e){const t=(0,u.mL)(e,b),i=t.slice(0,1);if(1===S(i)){const e=33,r=e+12,n=t.slice(1,e),s=t.slice(e,r);return{type:i,sealed:t.slice(r),iv:s,senderPublicKey:n}}const r=t.slice(1,13);return{type:i,sealed:t.slice(13),iv:r}}function N(e){const t=e?.type||0;if(1===t){if(typeof e?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function C(e){return 1===e.type&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}var x=Object.defineProperty,A=Object.getOwnPropertySymbols,T=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable,j=(e,t,i)=>t in e?x(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,$=(e,t)=>{for(var i in t||(t={}))T.call(t,i)&&j(e,i,t[i]);if(A)for(var i of A(t))D.call(t,i)&&j(e,i,t[i]);return e};const q="react-native",U="node",M="browser",L="unknown",z="js";function k(){return typeof v<"u"&&typeof v.versions<"u"&&typeof v.versions.node<"u"}function V(){return!(0,f.getDocument)()&&!!(0,f.getNavigator)()&&"ReactNative"===navigator.product}function K(){return!k()&&!!(0,f.getNavigator)()}function H(){return V()?q:k()?U:K()?M:L}function B(e,t,r){const n=function(){if(typeof(null==i.g?void 0:i.g.Platform)<"u"){const{OS:e,Version:t}=i.g.Platform;return[e,t].join("-")}const e=(0,l.qY)();if(null===e)return"unknown";const t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return"browser"===e.type?[t,e.name,e.version].join("-"):[t,e.version].join("-")}(),s=function(){var e;const t=H();return t===M?[t,(null==(e=(0,f.getLocation)())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),[z,r].join("-"),n,s].join("/")}function W({protocol:e,version:t,relayUrl:i,sdkVersion:r,auth:n,projectId:s,useOnCloseEvent:o}){const a=i.split("?"),c={auth:n,ua:B(e,t,r),projectId:s,useOnCloseEvent:o||void 0},h=function(e,t){let i=g.parse(e);return i=$($({},i),t),g.stringify(i)}(a[1]||"",c);return a[0]+"?"+h}function F(e,t){return e.filter((e=>t.includes(e))).length===e.length}function G(e){return Object.fromEntries(e.entries())}function J(e){return new Map(Object.entries(e))}function Y(e=p.FIVE_MINUTES,t){const i=(0,p.toMiliseconds)(e||p.FIVE_MINUTES);let r,n,s;return{resolve:e=>{s&&r&&(clearTimeout(s),r(e))},reject:e=>{s&&n&&(clearTimeout(s),n(e))},done:()=>new Promise(((e,o)=>{s=setTimeout((()=>{o(new Error(t))}),i),r=e,n=o}))}}function Z(e,t,i){return new Promise((async(r,n)=>{const s=setTimeout((()=>n(new Error(i))),t);try{r(await e)}catch(o){n(o)}clearTimeout(s)}))}function Q(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${e}`)}function X(e){const[t,i]=e.split(":"),r={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof i)r.topic=i;else{if("id"!==t||!Number.isInteger(Number(i)))throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${i}`);r.id=Number(i)}return r}function ee(e,t){return(0,p.fromMiliseconds)((t||Date.now())+(0,p.toMiliseconds)(e))}function te(e){return Date.now()>=(0,p.toMiliseconds)(e)}function ie(e,t){return`${e}${t?`:${t}`:""}`}function re(e=[],t=[]){return[...new Set([...e,...t])]}function ne(e){return e?.relay||{protocol:"irn"}}function se(e){const t=y.RELAY_JSONRPC[e];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${e}`);return t}var oe=Object.defineProperty,ae=Object.getOwnPropertySymbols,ce=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable,ue=(e,t,i)=>t in e?oe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;function le(e,t="-"){const i={},r="relay"+t;return Object.keys(e).forEach((t=>{if(t.startsWith(r)){const n=t.replace(r,""),s=e[t];i[n]=s}})),i}function pe(e){return e.startsWith("//")?e.substring(2):e}function fe(e){return`${e.protocol}
1:${e.topic}@${e.version}?`+g.stringify(((e,t)=>{for(var i in t||(t={}))ce.call(t,i)&&ue(e,i,t[i]);if(ae)for(var i of ae(t))he.call(t,i)&&ue(e,i,t[i]);return e})({symKey:e.symKey},function(e,t="-"){const i={};return Object.keys(e).forEach((r=>{const n="relay"+t+r;e[r]&&(i[n]=e[r])})),i}(e.relay)))}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;function de(e){const t=[];return e.forEach((e=>{const[i,r]=e.split(":");t.push(`${i}:${r}`)})),t}function ge(e){return e.includes(":")}function ye(e){return ge(e)?e.split(":")[0]:e}const ve={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},me={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function we(e,t){const{message:i,code:r}=me[e];return{message:t?`${i} ${t}`:i,code:r}}function _e(e,t){const{message:i,code:r}=ve[e];return{message:t?`${i} ${t}`:i,code:r}}function be(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function Ee(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function Ie(e){return typeof e>"u"}function Pe(e,t){return!(!t||!Ie(e))||"string"==typeof e&&!!e.trim().length}function Se(e,t){return!(!t||!Ie(e))||"number"==typeof e&&!isNaN(e)}function Oe(e){return!(!Pe(e,!1)||!e.includes(":"))&&2===e.split(":").length}function Re(e){let t=!0;return be(e)?e.length&&(t=e.every((e=>Pe(e,!1)))):t=!1,t}function Ne(e,t){let i=null;return Object.entries(e).forEach((([e,r])=>{if(i)return;const n=function(e,t,i){let r=null;return be(t)?t.forEach((t=>{r||(!Oe(t)||!t.includes(e))&&(r=_e("UNSUPPORTED_CHAINS",`${i}, chain ${t} should be a string and conform to "namespace:chainId" format`))})):r=_e("UNSUPPORTED_CHAINS",`${i}, chains ${t} should be an array of strings conforming to "namespace:chainId" format`),r}(e,m(e,r),`${t} requiredNamespace`);n&&(i=n)})),i}function Ce(e,t){let i=null;return be(e)?e.forEach((e=>{i||function(e){if(Pe(e,!1)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&Oe(e)}}return!1}(e)||(i=_e("UNSUPPORTED_ACCOUNTS",`${t}, account ${e} should be a string and conform to "namespace:chainId:address" format`))})):i=_e("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),i}function xe(e,t){let i=null;return Object.values(e).forEach((e=>{if(i)return;const r=function(e,t){let i=null;return Re(e?.methods)?Re(e?.events)||(i=_e("UNSUPPORTED_EVENTS",`${t}
1, events should be an array of strings or empty array for no events`)):i=_e("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),i}(e,`${t}, namespace`);r&&(i=r)})),i}function Ae(e,t){let i=null;if(e&&Ee(e)){const r=xe(e,t);r&&(i=r);const n=function(e,t){let i=null;return Object.values(e).forEach((e=>{if(i)return;const r=Ce(e?.accounts,`${t} namespace`);r&&(i=r)})),i}(e,t);n&&(i=n)}else i=we("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return i}function Te(e){return Pe(e.protocol,!0)}function De(e){return typeof e<"u"&&null!==typeof e}function je(e,t){return!(!Oe(t)||!function(e){const t=[];return Object.values(e).forEach((e=>{t.push(...de(e.accounts))})),t}(e).includes(t))}function $e(e,t,i){return!!Pe(i,!1)&&function(e,t){const i=[];return Object.values(e).forEach((e=>{de(e.accounts).includes(t)&&i.push(...e.methods)})),i}(e,t).includes(i)}function qe(e,t,i){return!!Pe(i,!1)&&function(e,t){const i=[];return Object.values(e).forEach((e=>{de(e.accounts).includes(t)&&i.push(...e.events)})),i}(e,t).includes(i)}function Ue(e,t,i){let r=null;const n=function(e){const t={};return Object.keys(e).forEach((i=>{var r;i.includes(":")?t[i]=e[i]:null==(r=e[i].chains)||r.forEach((r=>{t[r]={methods:e[i].methods,events:e[i].events}}))})),t}(e),s=function(e){const t={};return Object.keys(e).forEach((i=>{if(i.includes(":"))t[i]=e[i];else{de(e[i].accounts)?.forEach((r=>{t[r]={accounts:e[i].accounts.filter((e=>e.includes(`${r}:`))),methods:e[i].methods,events:e[i].events}}))}})),t}(t),o=Object.keys(n),a=Object.keys(s),c=Me(Object.keys(e)),h=Me(Object.keys(t)),u=c.filter((e=>!h.includes(e)));return u.length&&(r=we("NON_CONFORMING_NAMESPACES",`${i} namespaces keys don't satisfy requiredNamespaces.\n Required: ${u.toString()}\n Received: ${Object.keys(t).toString()}`)),F(o,a)||(r=we("NON_CONFORMING_NAMESPACES",`${i} namespaces chains don't satisfy required namespaces.\n Required: ${o.toString()}\n Approved: ${a.toString()}`)),Object.keys(t).forEach((e=>{if(!e.includes(":")||r)return;const n=de(t[e].accounts);n.includes(e)||(r=we("NON_CONFORMING_NAMESPACES",`${i} namespaces accounts don't satisfy namespace accounts for ${e}\n Required: ${e}\n Approved: ${n.toString()}`))})),o.forEach((e=>{r||(F(n[e].methods,s[e].methods)?F(n[e].events,s[e].events)||(r=we("NON_CONFORMING_NAMESPACES",`${i} namespaces events don't satisfy namespace events for ${e}`)):r=we("NON_CONFORMING_NAMESPACES",`${i} namespaces methods don't satisfy namespace methods for ${e}`))})),r}function Me(e){return[...new Set(e.map((e=>e.includes(":")?e.split(":")[0]:e)))]}var Le=i(85150),ze=i(90772),ke=i(9107),Ve=i(38200);class Ke extends Ve.q{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class He extends Ve.q{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}}class Be extends Ve.q{constructor(e,t){super(),this.relayer=e,this.logger=t}}class We extends Ve.q{constructor(e){super()}}class Fe extends Ve.q{constructor(e,t){super(),this.relayer=e,this.logger=t}}class Ge extends Ve.q{constructor(e,t){super(),this.core=e,this.logger=t}}var Je=i(85094),Ye=i(21878);const Ze="INTERNAL_ERROR",Qe="SERVER_ERROR",Xe=[-32700,-32600,-32601,-32602,-32603],et={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"},[Ze]:{code:-32603,message:"Internal error"},[Qe]:{code:-32e3,message:"Server error"}};function tt(e){return Xe.includes(e)}function it(e){return Object.keys(et).includes(e)?et[e]:et.SERVER_ERROR}function rt(e){const t=Object.values(et).find((t=>t.code===e));return t||et.SERVER_ERROR}i(1468);
1function nt(e=3){return Date.now()*Math.pow(10,e)+Math.floor(Math.random()*Math.pow(10,e))}function st(e=6){return BigInt(nt(e))}function ot(e,t,i){return{id:i||nt(),jsonrpc:"2.0",method:e,params:t}}function at(e,t){return{id:e,jsonrpc:"2.0",result:t}}function ct(e,t,i){return{id:e,jsonrpc:"2.0",error:ht(t,i)}}function ht(e,t){return"undefined"===typeof e?it(Ze):("string"===typeof e&&(e=Object.assign(Object.assign({},it(Qe)),{message:e})),"undefined"!==typeof t&&(e.data=t),tt(e.code)&&(e=rt(e.code)),e)}function ut(e){return"object"===typeof e&&"id"in e&&"jsonrpc"in e&&"2.0"===e.jsonrpc}function lt(e){return ut(e)&&"method"in e}function pt(e){return ut(e)&&(ft(e)||dt(e))}function ft(e){return"result"in e}function dt(e){return"error"in e}class gt extends class extends class extends class{}{constructor(){super()}}{constructor(e){super()}}{constructor(e){super(e),this.events=new r.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(ot(e.method,e.params||[],e.id||st().toString()),t)}async requestStrict(e,t){return new Promise((async(i,r)=>{if(!this.connection.connected)try{await this.open()}catch(n){r(n)}this.events.on(`${e.id}`,(e=>{dt(e)?r(e.error):i(e.result)}));try{await this.connection.send(e,t)}catch(n){r(n)}}))}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),pt(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&3e3===e.code&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),"string"===typeof e&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",(e=>this.onPayload(e))),this.connection.on("close",(e=>this.onClose(e))),this.connection.on("error",(e=>this.events.emit("error",e))),this.connection.on("register_error",(e=>this.onClose())),this.hasRegisteredEventListeners=!0)}}var yt=i(12167),vt=i(72307),mt=i.n(vt),wt=i(34155);var _t=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var i=new Uint8Array(256),r=0;r<i.length;r++)i[r]=255;for(var n=0;n<e.length;n++){var s=e.charAt(n),o=s.charCodeAt(0);if(255!==i[o])throw new TypeError(s+" is ambiguous");i[o]=n}var a=e.length,c=e.charAt(0),h=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var r=0,n=0;e[t]===c;)r++,t++;for(var s=(e.length-t)*h+1>>>0,o=new Uint8Array(s);e[t];){var u=i[e.charCodeAt(t)];if(255===u)return;for(var l=0,p=s-1;(0!==u||l<n)&&-1!==p;p--,l++)u+=a*o[p]>>>0,o[p]=u%256>>>0,u=u/256>>>0;if(0!==u)throw new Error("Non-zero carry");n=l,t++}if(" "!==e[t]){for(var f=s-n;f!==s&&0===o[f];)f++;for(var d=new Uint8Array(r+(s-f)),g=r;f!==s;)d[g++]=o[f++];return d}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var i=0,r=0,n=0,s=t.length;n!==s&&0===t[n];)n++,i++;for(var o=(s-n)*u+1>>>0,h=new Uint8Array(o);n!==s;){for(var l=t[n],p=0,f=o-1;(0!==l||p<r)&&-1!==f;f--,p++)l+=256*h[f]>>>0,h[f]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");r=p,n++}for(var d=o-r;d!==o&&0===h[d];)d++;for(var g=c.repeat(i);d<o;++d)g+=e.charAt(h[d]);return g},decodeUnsafe:l,decode:function(e){var i=l(e);if(i)return i;throw new Error(`Non-${t} character`)}}},bt=_t;const Et=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class It{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Pt{constructor(e,t,i){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name}
1 decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return Ot(this,e)}}class St{constructor(e){this.decoders=e}or(e){return Ot(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Ot=(e,t)=>new St({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class Rt{constructor(e,t,i,r){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=r,this.encoder=new It(e,t,i),this.decoder=new Pt(e,t,r)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Nt=({name:e,prefix:t,encode:i,decode:r})=>new Rt(e,t,i,r),Ct=({prefix:e,name:t,alphabet:i})=>{const{encode:r,decode:n}=bt(i,t);return Nt({prefix:e,name:t,encode:r,decode:e=>Et(n(e))})},xt=({name:e,prefix:t,bitsPerChar:i,alphabet:r})=>Nt({prefix:t,name:e,encode:e=>((e,t,i)=>{const r="="===t[t.length-1],n=(1<<i)-1;let s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>i;)o-=i,s+=t[n&a>>o];if(o&&(s+=t[n&a<<i-o]),r)for(;s.length*i&7;)s+="=";return s})(e,r,i),decode:t=>((e,t,i,r)=>{const n={};for(let u=0;u<t.length;++u)n[t[u]]=u;let s=e.length;for(;"="===e[s-1];)--s;const o=new Uint8Array(s*i/8|0);let a=0,c=0,h=0;for(let u=0;u<s;
1++u){const t=n[e[u]];if(void 0===t)throw new SyntaxError(`Non-${r} character`);c=c<<i|t,a+=i,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=i||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,r,i,e)}),At=Nt({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var Tt=Object.freeze({__proto__:null,identity:At});const Dt=xt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var jt=Object.freeze({__proto__:null,base2:Dt});const $t=xt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var qt=Object.freeze({__proto__:null,base8:$t});const Ut=Ct({prefix:"9",name:"base10",alphabet:"0123456789"});var Mt=Object.freeze({__proto__:null,base10:Ut});const Lt=xt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),zt=xt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var kt=Object.freeze({__proto__:null,base16:Lt,base16upper:zt});const Vt=xt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Kt=xt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ht=xt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Bt=xt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Wt=xt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ft=xt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Gt=xt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Jt=xt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Yt=xt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Zt=Object.freeze({__proto__:null,base32:Vt,base32upper:Kt,base32pad:Ht,base32padupper:Bt,base32hex:Wt,base32hexupper:Ft,base32hexpad:Gt,base32hexpadupper:Jt,base32z:Yt});const Qt=Ct({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Xt=Ct({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ei=Object.freeze({__proto__:null,base36:Qt,base36upper:Xt});const ti=Ct({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),ii=Ct({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ri=Object.freeze({__proto__:null,base58btc:ti,base58flickr:ii});const ni=xt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),si=xt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),oi=xt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),ai=xt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var ci=Object.freeze({__proto__:null,base64:ni,base64pad:si,base64url:oi,base64urlpad:ai});const hi=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),ui=hi.reduce(((e,t,i)=>(e[i]=t,e)),[]),li=hi.reduce(((e,t,i)=>(e[t.codePointAt(0)]=i,e)),[]);const pi=Nt({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce(((e,t)=>e+=ui[t]),"")},decode:function(e){const t=[];for(const i of e){const e=li[i.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${i}`);t.push(e)}return new Uint8Array(t)}});
1var fi=Object.freeze({__proto__:null,base256emoji:pi}),di=function e(t,i,r){i=i||[];for(var n=r=r||0;t>=gi;)i[r++]=255&t|128,t/=128;for(;-128&t;)i[r++]=255&t|128,t>>>=7;return i[r]=0|t,e.bytes=r-n+1,i},gi=Math.pow(2,31);var yi=function e(t,i){var r,n=0,s=0,o=i=i||0,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");r=t[o++],n+=s<28?(127&r)<<s:(127&r)*Math.pow(2,s),s+=7}while(r>=128);return e.bytes=o-i,n};var vi=Math.pow(2,7),mi=Math.pow(2,14),wi=Math.pow(2,21),_i=Math.pow(2,28),bi=Math.pow(2,35),Ei=Math.pow(2,42),Ii=Math.pow(2,49),Pi=Math.pow(2,56),Si=Math.pow(2,63),Oi={encode:di,decode:yi,encodingLength:function(e){return e<vi?1:e<mi?2:e<wi?3:e<_i?4:e<bi?5:e<Ei?6:e<Ii?7:e<Pi?8:e<Si?9:10}};const Ri=(e,t,i=0)=>(Oi.encode(e,t,i),t),Ni=e=>Oi.encodingLength(e),Ci=(e,t)=>{const i=t.byteLength,r=Ni(e),n=r+Ni(i),s=new Uint8Array(n+i);return Ri(e,s,0),Ri(i,s,r),s.set(t,n),new xi(e,i,t,s)};class xi{constructor(e,t,i,r){this.code=e,this.size=t,this.digest=i,this.bytes=r}}const Ai=({name:e,code:t,encode:i})=>new Ti(e,t,i);class Ti{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Ci(this.code,t):t.then((e=>Ci(this.code,e)))}throw Error("Unknown type, must be binary type")}}const Di=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),ji=Ai({name:"sha2-256",code:18,encode:Di("SHA-256")}),$i=Ai({name:"sha2-512",code:19,encode:Di("SHA-512")});Object.freeze({__proto__:null,sha256:ji,sha512:$i});const qi=Et,Ui={code:0,name:"identity",encode:qi,digest:e=>Ci(0,qi(e))};Object.freeze({__proto__:null,identity:Ui});new TextEncoder,new TextDecoder;const Mi={...Tt,...jt,...qt,...Mt,...kt,...Zt,...ei,...ri,...ci,...fi};function Li(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function zi(e,t,i,r){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:i},decoder:{decode:r}}}const ki=zi("utf8","u",(e=>"u"+new TextDecoder("utf8").decode(e)),(e=>(new TextEncoder).encode(e.substring(1)))),Vi=zi("ascii","a",(e=>{let t="a";for(let i=0;i<e.length;i++)t+=String.fromCharCode(e[i]);return t}),(e=>{const t=function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?Li(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}((e=e.substring(1)).length);for(let i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t})),Ki={utf8:ki,"utf-8":ki,hex:Mi.base16,latin1:Vi,ascii:Vi,binary:Vi,...Mi};const Hi="core",Bi="wc@2:core:",Wi="error",Fi={database:":memory:"},Gi="client_ed25519_seed",Ji=p.ONE_DAY,Yi=p.SIX_HOURS,Zi="wss://relay.walletconnect.com",Qi="relayer_message",Xi="relayer_message_ack",er="relayer_connect",tr="relayer_disconnect",ir="relayer_error",rr="relayer_connection_stalled",nr="relayer_transport_closed",sr="relayer_publish",or="payload",ar="connect",cr="disconnect",hr="error",ur=p.ONE_SECOND/2,lr="subscription_created",pr="subscription_deleted",fr="subscription_sync",dr="subscription_resubscribed",gr=1e3*p.FIVE_SECONDS,yr={wc_pairingDelete:{req:{ttl:p.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:p.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:p.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:p.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:p.ONE_DAY,prompt:!1,tag:0},res:{ttl:p.ONE_DAY,prompt:!1,tag:0}}},vr="history_created",mr="history_updated",wr="history_deleted",_r="history_sync",br="expirer_created",Er="expirer_deleted",Ir="expirer_expired",Pr="expirer_sync",Sr="verify-api",Or="https://verify.walletconnect.com";class Rr{constructor(e,t){this.core=e,this.logger=t,this.keychain=new Map,this.name="keychain",this.version="0.3",this.initialized=!1,this.storagePrefix=Bi,this.init=async()=>{if(!this.initialized){const e=await this.getKeyChain();typeof e<"u"&&(this.keychain=e),this.initialized=!0}},this.has=e=>(this.isInitialized(),this.keychain.has(e)),this.set=async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()},this.get=e=>{this.isInitialized();const t=this.keychain.get(e);if(typeof t>"u"){const{message:t}=we("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t},this.del=async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()},this.core=e,this.logger=(0,ke.generateChildLogger)(t,this.name)}get context(){return(0,ke.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,G(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?J(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=we("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Nr{constructor(e,t,i){this.core=e,this.logger=t,this.name="crypto",this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=e=>(this.isInitialized(),this.keychain.has(e)),this.getClientId=async()=>{this.isInitialized();const e=await this.getClientSeed(),t=Ye.generateKeyPair(e);return Ye.encodeIss(t.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const e=function(){const e=h.Au();return{privateKey:(0,u.BB)(e.secretKey,_),publicKey:(0,u.BB)(e.publicKey,_)}}();return this.setPrivateKey(e.publicKey,e.privateKey)},this.signJWT=async e=>{this.isInitialized();const t=await this.getClientSeed(),i=Ye.generateKeyPair(t),r=I(),n=Ji;return await Ye.signJWT(r,e,n,i)},this.generateSharedKey=(e,t,i)=>{this.isInitialized();const r=function(e,t){const i=h.gi((0,u.mL)(e,_),(0,u.mL)(t,_)),r=new o.t(c.mE,i).expand(32);return(0,u.BB)(r,_)}(this.getPrivateKey(e),t);return this.setSymKey(r,i)},this.setSymKey=async(e,t)=>{this.isInitialized();const i=t||function(e){const t=(0,c.vp)((0,u.mL)(e,_));return(0,u.BB)(t,_)}(e);return await this.keychain.set(i,e),i},this.deleteKeyPair=async e=>{this.isInitialized(),await this.keychain.del(e)},this.deleteSymKey=async e=>{this.isInitialized(),await this.keychain.del(e)},this.encode=async(e,t,i)=>{this.isInitialized();const r=N(i),n=(0,Je.u)(t);if(C(r)){const t=r.senderPublicKey,i=r.receiverPublicKey;e=await this.generateSharedKey(t,i)}const s=this.getSymKey(e),{type:o,senderPublicKey:a}=r;return O({type:o,symKey:s,message:n,senderPublicKey:a})},this.decode=async(e,t,i)=>{this.isInitialized();const r=function(e,t){const i=R(e);return N({type:S(i.type),senderPublicKey:typeof i.senderPublicKey<"u"?(0,u.BB)(i.senderPublicKey,_):void 0,receiverPublicKey:t?.receiverPublicKey})}(t,i);if(C(r)){const t=r.receiverPublicKey,i=r.senderPublicKey;e=await this.generateSharedKey(t,i)}const n=function(e){const t=new s.OK((0,u.mL)(e.symKey,_)),{sealed:i,iv:r}
1=R(e.encoded),n=t.open(r,i);if(null===n)throw new Error("Failed to decrypt");return(0,u.BB)(n,E)}({symKey:this.getSymKey(e),encoded:t});return(0,Je.D)(n)},this.getPayloadType=e=>S(R(e).type),this.getPayloadSenderPublicKey=e=>{const t=R(e);return t.senderPublicKey?(0,u.BB)(t.senderPublicKey,_):void 0},this.core=e,this.logger=(0,ke.generateChildLogger)(t,this.name),this.keychain=i||new Rr(this.core,this.logger)}get context(){return(0,ke.getLoggerContext)(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(Gi)}catch{e=I(),await this.keychain.set(Gi,e)}return function(e,t="utf8"){const i=Ki[t];if(!i)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?i.decoder.decode(`${i.prefix}${e}`):Li(globalThis.Buffer.from(e,"utf-8"))}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=we("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Cr extends class{constructor(e,t){this.logger=e,this.core=t}}{constructor(e,t){super(e,t),this.logger=e,this.core=t,this.messages=new Map,this.name="messages",this.version="0.3",this.initialized=!1,this.storagePrefix=Bi,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const e=await this.getRelayerMessages();typeof e<"u"&&(this.messages=e),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}},this.set=async(e,t)=>{this.isInitialized();const i=P(t);let r=this.messages.get(e);return typeof r>"u"&&(r={}),typeof r[i]<"u"||(r[i]=t,this.messages.set(e,r),await this.persist()),i},this.get=e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t},this.has=(e,t)=>{this.isInitialized();return typeof this.get(e)[P(t)]<"u"},this.del=async e=>{this.isInitialized(),this.messages.delete(e),await this.persist()},this.logger=(0,ke.generateChildLogger)(e,this.name),this.core=t}get context(){return(0,ke.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,G(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?J(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=we("NOT_INITIALIZED",this.name);throw new Error(e)}}}class xr extends Be{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.events=new r.EventEmitter,this.name="publisher",this.queue=new Map,this.publishTimeout=(0,p.toMiliseconds)(p.TEN_SECONDS),this.queueTimeout=(0,p.toMiliseconds)(p.FIVE_SECONDS),this.needsTransportRestart=!1,this.publish=async(e,t,i)=>{this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:i}});try{const r=i?.ttl||Yi,n=ne(i),s=i?.prompt||!1,o=i?.tag||0,a=i?.id||st().toString(),c={topic:e,message:t,opts:{ttl:r,relay:n,prompt:s,tag:o,id:a}},h=setTimeout((()=>this.queue.set(a,c)),this.queueTimeout);try{await await Z(this.rpcPublish(e,t,r,n,s,o,a),this.publishTimeout),clearTimeout(h),this.relayer.events.emit(sr,c)}catch{return this.logger.debug("Publishing Payload stalled"),void(this.needsTransportRestart=!0)}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:i}})}catch(r){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(r),r}},this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.relayer=e,this.logger=(0,ke.generateChildLogger)(t,this.name),this.registerEventListeners()}get context(){return(0,ke.getLoggerContext)(this.logger)}rpcPublish(e,t,i,r,n,s,o){var a,c,h,u;const l={method:se(r.protocol).publish,params:{topic:e,message:t,ttl:i,prompt:n,tag:s},id:o};return Ie(null==(a=l.params)?void 0:a.prompt)&&(null==(c=l.params)||delete c.prompt),Ie(null==(h=l.params)?void 0:h.tag)&&(null==(u=l.params)||delete u.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:l}),this.relayer.request(l)}onPublish(e){this.queue.delete(e)}checkQueue(){this.queue.forEach((async e=>{const{topic:t,message:i,opts:r}=e;await this.publish(t,i,r)}))}registerEventListeners(){this.relayer.core.heartbeat.on(ze.HEARTBEAT_EVENTS.pulse,(()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(rr);this.checkQueue()})),this.relayer.on(Xi,(e=>{this.onPublish(e.id.toString())}))}}class Ar{constructor(){this.map=new Map,this.set=(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>
1{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const r=i.filter((e=>e!==t));r.length?this.map.set(e,r):this.map.delete(e)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var Tr=Object.defineProperty,Dr=Object.defineProperties,jr=Object.getOwnPropertyDescriptors,$r=Object.getOwnPropertySymbols,qr=Object.prototype.hasOwnProperty,Ur=Object.prototype.propertyIsEnumerable,Mr=(e,t,i)=>t in e?Tr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Lr=(e,t)=>{for(var i in t||(t={}))qr.call(t,i)&&Mr(e,i,t[i]);if($r)for(var i of $r(t))Ur.call(t,i)&&Mr(e,i,t[i]);return e},zr=(e,t)=>Dr(e,jr(t));class kr extends Fe{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new Ar,this.events=new r.EventEmitter,this.name="subscription",this.version="0.3",this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=Bi,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restart(),this.registerEventListeners(),this.onEnable(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(e,t)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const i=ne(t),r={topic:e,relay:i};this.pending.set(e,r);const n=await this.rpcSubscribe(e,i);return this.onSubscribe(n,r),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}}),n}catch(Ke){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(Ke),Ke}},this.unsubscribe=async(e,t)=>{await this.restartToComplete(),this.isInitialized(),typeof t?.id<"u"?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)},this.isSubscribed=async e=>!!this.topics.includes(e)||await new Promise(((t,i)=>{const r=new p.Watch;r.start(this.pendingSubscriptionWatchLabel);const n=setInterval((()=>{!this.pending.has(e)&&this.topics.includes(e)&&(clearInterval(n),r.stop(this.pendingSubscriptionWatchLabel),t(!0)),r.elapsed(this.pendingSubscriptionWatchLabel)>=gr&&(clearInterval(n),r.stop(this.pendingSubscriptionWatchLabel),i(new Error("Subscription resolution timeout")))}),this.pollingInterval)})).catch((()=>!1)),this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=(0,ke.generateChildLogger)(t,this.name),this.clientId=""}get context(){return(0,ke.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map((async i=>await this.unsubscribeById(e,i,t))))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const r=ne(i);await this.rpcUnsubscribe(e,t,r);const n=_e("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(r){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(r),r}}async rpcSubscribe(e,t){const i={method:se(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await Z(this.relayer.request(i),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(rr)}return P(e+this.clientId)}async rpcBatchSubscribe(e){if(!e.length)return;const t={method:se(e[0].relay.protocol).batchSubscribe,params:{topics:e.map((e=>e.topic))}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});try{return await await Z(this.relayer.request(t),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(rr)}}rpcUnsubscribe(e,t,i){const r={method:se(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r}),this.relayer.request(r)}onSubscribe(e,t){this.setSubscription(e,zr(Lr({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach((e=>{this.setSubscription(e.id,Lr({},e)),this.pending.delete(e.topic)}))}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}
1async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t))}addSubscription(e,t){this.subscriptions.set(e,Lr({},t)),this.topicMap.set(t.topic,e),this.events.emit(lr,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:t}=we("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(pr,zr(Lr({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(fr)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let t=0;t<e;t++){const e=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(e)}}this.events.emit(dr)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:e}=we("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;const t=await this.rpcBatchSubscribe(e);be(t)&&this.onBatchSubscribe(t.map(((t,i)=>zr(Lr({},e[i]),{id:t}))))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(this.relayer.transportExplicitlyClosed)return;const e=[];this.pending.forEach((t=>{e.push(t)})),await this.batchSubscribe(e)}registerEventListeners(){this.relayer.core.heartbeat.on(ze.HEARTBEAT_EVENTS.pulse,(async()=>{await this.checkPending()})),this.relayer.on(er,(async()=>{await this.onConnect()})),this.relayer.on(tr,(()=>{this.onDisconnect()})),this.events.on(lr,(async e=>{const t=lr;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})),this.events.on(pr,(async e=>{const t=pr;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=we("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){this.restartInProgress&&await new Promise((e=>{const t=setInterval((()=>{this.restartInProgress||(clearInterval(t),e())}),this.pollingInterval)}))}}var Vr=Object.defineProperty,Kr=Object.getOwnPropertySymbols,Hr=Object.prototype.hasOwnProperty,Br=Object.prototype.propertyIsEnumerable,Wr=(e,t,i)=>t in e?Vr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i;class Fr extends We{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new r.EventEmitter,this.name="relayer",this.transportExplicitlyClosed=!1,this.initialized=!1,this.reconnecting=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.request=async e=>{this.logger.debug("Publishing Request Payload");try{return await this.toEstablishConnection(),await this.provider.request(e)}catch(t){throw this.logger.debug("Failed to Publish Request"),this.logger.error(t),t}},this.core=e.core,this.logger=typeof e.logger<"u"&&"string"!=typeof e.logger?(0,ke.generateChildLogger)(e.logger,this.name):(0,ke.pino)((0,ke.getDefaultLoggerOptions)({level:e.logger||"error"})),this.messages=new Cr(this.logger,e.core),this.subscriber=new kr(this,this.logger),this.publisher=new xr(this,this.logger),this.relayUrl=e?.relayUrl||Zi,this.projectId=e.projectId,this.provider={}}
1async init(){this.logger.trace("Initialized"),await this.createProvider(),await Promise.all([this.messages.init(),this.transportOpen(),this.subscriber.init()]),this.registerEventListeners(),this.initialized=!0,setTimeout((async()=>{0===this.subscriber.topics.length&&(this.logger.info("No topics subscribted to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)}),1e4)}get context(){return(0,ke.getLoggerContext)(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now()})}async subscribe(e,t){var i;this.isInitialized();let r=(null==(i=this.subscriber.topicMap.get(e))?void 0:i[0])||"";return r||(await Promise.all([new Promise((t=>{this.subscriber.once(lr,(i=>{i.topic===e&&t()}))})),new Promise((async i=>{r=await this.subscriber.subscribe(e,t),i()}))]),r)}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportClose(){this.transportExplicitlyClosed=!0,this.connected&&(await this.provider.disconnect(),this.events.emit(nr))}async transportOpen(e){if(this.transportExplicitlyClosed=!1,!this.reconnecting){this.relayUrl=e||this.relayUrl,this.reconnecting=!0;try{await Promise.all([new Promise((e=>{this.initialized||e(),this.subscriber.once(dr,(()=>{e()}))})),await Promise.race([new Promise((async(e,t)=>
1{await Z(this.provider.connect(),5e3,"socket stalled").catch((e=>t(e))).then((()=>e())).finally((()=>this.removeListener(nr,this.rejectTransportOpen)))})),new Promise((e=>this.once(nr,this.rejectTransportOpen)))])])}catch(t){this.logger.error(t);const e=t;if(!this.isConnectionStalled(e.message))throw t;this.events.emit(nr)}finally{this.reconnecting=!1}}}async restartTransport(e){this.transportExplicitlyClosed||this.reconnecting||(this.relayUrl=e||this.relayUrl,this.connected&&await Promise.all([new Promise((e=>{this.provider.once(cr,(()=>{e()}))})),this.transportClose()]),await this.createProvider(),await this.transportOpen())}isConnectionStalled(e){return this.staleConnectionErrors.some((t=>e.includes(t)))}rejectTransportOpen(){throw new Error("Attempt to connect to relay via `transportOpen` has stalled. Retrying...")}async createProvider(){const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new gt(new yt.Z(W({sdkVersion:"2.8.4",protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;return!(await this.subscriber.isSubscribed(t))||this.messages.has(t,i)}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),lt(e)){if(!e.method.endsWith("_subscription"))return;const t=e.params,{topic:i,message:r,publishedAt:n}=t.data,s={topic:i,message:r,publishedAt:n};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(((e,t)=>{for(var i in t||(t={}))Hr.call(t,i)&&Wr(e,i,t[i]);if(Kr)for(var i of Kr(t))Br.call(t,i)&&Wr(e,i,t[i]);return e})({type:"event",event:t.id},s)),this.events.emit(t.id,s),await this.acknowledgePayload(e),await this.onMessageEvent(s)}else pt(e)&&this.events.emit(Xi,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(Qi,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=at(e.id,!0);await this.provider.connection.send(t)}registerProviderListeners(){this.provider.on(or,(e=>this.onProviderPayload(e))),this.provider.on(ar,(()=>{this.events.emit(er)})),this.provider.on(cr,(()=>{this.onProviderDisconnect()})),this.provider.on(hr,(e=>{this.logger.error(e),this.events.emit(ir,e)}))}registerEventListeners(){this.events.on(rr,(async()=>{await this.restartTransport()}))}onProviderDisconnect(){this.events.emit(tr),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||setTimeout((async()=>{await this.restartTransport()}),(0,p.toMiliseconds)(ur))}isInitialized(){if(!this.initialized){const{message:e}=we("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(!this.connected){if(this.connecting)return await new Promise((e=>{const t=setInterval((()=>{this.connected&&(clearInterval(t),e())}),this.connectionStatusPollingInterval)}));await this.restartTransport()}}}var Gr=Object.defineProperty,Jr=Object.getOwnPropertySymbols,Yr=Object.prototype.hasOwnProperty,Zr=Object.prototype.propertyIsEnumerable,Qr=(e,t,i)=>t in e?Gr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Xr=(e,t)=>{for(var i in t||(t={}))Yr.call(t,i)&&Qr(e,i,t[i]);if(Jr)for(var i of Jr(t))Zr.call(t,i)&&Qr(e,i,t[i]);return e};class en extends class{constructor(e,t,i,r){this.core=e,this.logger=t,this.name=i}}{constructor(e,t,i,r=Bi,n){super(e,t,i,r),this.core=e,this.logger=t,this.name=i,this.map=new Map,this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Bi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>{this.getKey&&null!==e&&!Ie(e)?this.map.set(this.getKey(e),e):function(e){var t;return null==(t=e?.proposer)?void 0:t.publicKey}(e)?this.map.set(e.id,e):function(e){return e?.topic}(e)&&this.map.set(e.topic,e)})),this.cached=[],this.initialized=!0)},this.set=async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())},this.get=e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e)),this.getAll=e=>(this.isInitialized(),e?this.values.filter((t=>Object.keys(e).every((i=>mt()(t[i],e[i]))))):this.values),this.update=async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});const i=Xr(Xr({},this.getData(e)),t);this.map.set(e,i),await this.persist()},this.delete=async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",ke
1y:e,reason:t}),this.map.delete(e),await this.persist())},this.logger=(0,ke.generateChildLogger)(t,this.name),this.storagePrefix=r,this.getKey=n}get context(){return(0,ke.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){const{message:t}=we("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:e}=we("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=we("NOT_INITIALIZED",this.name);throw new Error(e)}}}class tn{constructor(e,t){this.core=e,this.logger=t,this.name="pairing",this.version="0.3",this.events=new(n()),this.initialized=!1,this.storagePrefix=Bi,this.ignoredPayloadTypes=[1],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:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]},this.create=async()=>{this.isInitialized();const e=I(),t=await this.core.crypto.setSymKey(e),i=ee(p.FIVE_MINUTES),r={protocol:"irn"},n={topic:t,expiry:i,relay:r,active:!1},s=fe({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:e,relay:r});return await this.pairings.set(t,n),await this.core.relayer.subscribe(t),this.core.expirer.set(t,i),{topic:t,uri:s}},this.pair=async e=>{this.isInitialized(),this.isValidPair(e);const{topic:t,symKey:i,relay:r}=function(e){const t=e.indexOf(":"),i=-1!==e.indexOf("?")?e.indexOf("?"):void 0,r=e.substring(0,t),n=e.substring(t+1,i).split("@"),s=typeof i<"u"?e.substring(i):"",o=g.parse(s);return{protocol:r,topic:pe(n[0]),version:parseInt(n[1],10),symKey:o.symKey,relay:le(o)}}(e.uri);if(this.pairings.keys.includes(t))throw new Error(`Pairing already exists: ${t}`);if(this.core.crypto.hasKeys(t))throw new Error(`Keychain already exists: ${t}`);const n=ee(p.FIVE_MINUTES),s={topic:t,relay:r,expiry:n,active:!1};return await this.pairings.set(t,s),await this.core.crypto.setSymKey(i,t),await this.core.relayer.subscribe(t,{relay:r}),this.core.expirer.set(t,n),e.activatePairing&&await this.activate({topic:t}),s},this.activate=async({topic:e})=>{this.isInitialized();const t=ee(p.THIRTY_DAYS);await this.pairings.update(e,{active:!0,expiry:t}),this.core.expirer.set(e,t)},this.ping=async e=>{this.isInitialized(),await this.isValidPing(e);const{topic:t}=e;if(this.pairings.keys.includes(t)){const e=await this.sendRequest(t,"wc_pairingPing",{}),{done:i,resolve:r,reject:n}=Y();this.events.once(ie("pairing_ping",e),(({error:e})=>{e?n(e):r()})),await i()}},this.updateExpiry=async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})},this.updateMetadata=async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",_e("USER_DISCONNECTED")),await this.deletePairing(t))},this.sendRequest=async(e,t,i)=>{const r=ot(t,i),n=await this.core.crypto.encode(e,r),s=yr[t].req;return this.core.history.set(e,r),this.core.relayer.publish(e,n,s),r.id},this.sendResult=async(e,t,i)=>{const r=at(e,i),n=await this.core.crypto.encode(t,r),s=await this.core.history.get(t,e),o=yr[s.request.method].res;await this.core.relayer.publish(t,n,o),await this.core.history.resolve(r)},this.sendError=async(e,t,i)=>{const r=ct(e,i),n=await this.core.crypto.encode(t,r),s=await this.core.history.get(t,e),o=yr[s.request.method]?yr[s.request.method].res:yr.unregistered_method.res;await this.core.relayer.publish(t,n,o),await this.core.history.resolve(r)},this.deletePairing=async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,_e("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])},this.cleanup=async()=>{const e=this.pairings.getAll().filter((e=>te(e.expiry)));await Promise.all(e.map((e=>this.deletePairing(e.topic))))},this.onRelayEventRequest=e=>{const{topic:t,payload:i}=e,r=i.method;if(this.pairings.keys.includes(t))switch(r){case"wc_pairingPing":return this.onPairingPingRequest(t,i);case"wc_pairingDelete":return this.onPairingDeleteRequest(t,i);default:return this.onUnknownRpcMethodRequest(t,i)}},this.onRelayEventResponse=async e=>{const{topic:t,payload:i}=e,r=(await this.core.history.get(t,i.id)).request.method;if(this.pairings.keys.includes(t)){if("wc_pairingPing"===r)return this.onPairingPingResponse(t,i);return this.onUnknownRpcMethodResponse(r)}},this.onPairingPingRequest=async(e,t)=>{const{id:i}=t;try{this.isValidPing({topic:e}),await this.sendResult(i,e,!0),this.events.emit("pairing_ping",{id:i,topic:e})}catch(r){await this.sendError(i,e,r),this.logger.error(r)}},this.onPairingPingResponse=(e,t)=>{const{id:i}=t;setTimeout((()=>{ft(t)?this.events.emit(ie("pairing_ping",i),{}):dt(t)&&this.events.emit(ie("pairing_ping",i),{error:t.error})}),500)},this.onPairingDeleteRequest=async(e,t)=>{const{id:i}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit("pairing_delete",{id:i,topic:e})}catch(r){await this.sendError(i,e,r),this.logger.error(r)}},this.onUnknownRpcMethodRequest=async(e,t)=>{const{id:i,method:r}=t;try{if(this.registeredMethods.includes(r))return;const t=_e("WC_METHOD_UNSUPPORTED",r);await this.sendError(i,e,t),this.logger.error(t)}catch(n){await this.sendError(i,e,n),this.logger.error(n)}},this.onUnknownRpcMethodResponse=e=>{this.registeredMethods.includes(e)||this.logger.error(_e("WC_METHOD_UNSUPPORTED",e))},this.isValidPair=e=>{if(!De(e)){const{message:t}=we("MISSING_OR_INVALID",`pair() params: ${e}`);throw new Error(t)}if(!function(e){if(Pe(e,!1))try{return typeof new URL(e)<"u"}catch{return!1}return!1}(e.uri)){const{message:t}=we("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw new Error(t)}},this.isValidPing=async e=>{if(!De(e)){const{message:t}=we("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)},this.isValidDisconnect=async e=>{if(!De(e)){const{message:t}=we("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)},this.isValidPairingTopic=async e=>{if(!Pe(e,!1)){const{message:t}=we("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.pairings.keys.includes(e)){const{message:t}=we("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(te(this.pairings.get(e).expiry)){await this.deletePairing(e);const{message:t}=we("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}},this.core=e,this.logger=(0,ke.generateChildLogger)(t,this.name),this.pairings=new en(this.core,this.logger,this.name,this.storagePrefix)}get context(){return(0,ke.getLoggerContext)(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=we("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Qi,(async e=>{const{topic:t,message:i}=e;if(this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const r=await this.core.crypto.decode(t,i);lt(r)?(this.core.history.set(t,r),this.onRelayEventRequest({topic:t,payload:r})):pt(r)&&(await this.core.history.resolve(r),this.onRelayEventResponse({topic:t,payload:r}))}))}registerExpirerEvents(){this.core.expirer.on(Ir,(async e=>{const{topic:t}=X(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit("pairing_expire",{topic:t}))}))}}class rn extends He{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.records=new Map,this.events=new r.EventEmitter,this.name="history",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Bi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(
1),this.cached.forEach((e=>this.records.set(e.id,e))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(e,t,i)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:i}),this.records.has(t.id))return;const r={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:i};this.records.set(r.id,r),this.events.emit(vr,r)},this.resolve=async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;const t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=dt(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.events.emit(mr,t))},this.get=async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t)),this.delete=(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach((i=>{if(i.topic===e){if(typeof t<"u"&&i.id!==t)return;this.records.delete(i.id),this.events.emit(wr,i)}}))},this.exists=async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e),this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.logger=(0,ke.generateChildLogger)(t,this.name)}get context(){return(0,ke.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach((t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:ot(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)})),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:t}=we("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(_r)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:e}=we("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(vr,(e=>{const t=vr;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.events.on(mr,(e=>{const t=mr;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()})),this.events.on(wr,(e=>{const t=wr;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=we("NOT_INITIALIZED",this.name);throw new Error(e)}}}class nn extends Ge{constructor(e,t){super(e,t),this.core=e,this.logger=t,this.expirations=new Map,this.events=new r.EventEmitter,this.name="expirer",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Bi,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach((e=>this.expirations.set(e.target,e))),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=e=>{try{const t=this.formatTarget(e);return typeof this.getExpiration(t)<"u"}catch{return!1}},this.set=(e,t)=>{this.isInitialized();const i=this.formatTarget(e),r={target:i,expiry:t};this.expirations.set(i,r),this.checkExpiry(i,r),this.events.emit(br,{target:i,expiration:r})},this.get=e=>{this.isInitialized();const t=this.formatTarget(e);return this.getExpiration(t)},this.del=e=>{if(this.isInitialized(),this.has(e)){const t=this.formatTarget(e),i=this.getExpiration(t);this.expirations.delete(t),this.events.emit(Er,{target:t,expiration:i})}},this.on=(e,t)=>{this.events.on(e,t)},this.once=(e,t)=>{this.events.once(e,t)},this.off=(e,t)=>{this.events.off(e,t)},this.removeListener=(e,t)=>{this.events.removeListener(e,t)},this.logger=(0,ke.generateChildLogger)(t,this.name)}get context(){return(0,ke.getLoggerContext)(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if("string"==typeof e)return function(e){return Q("topic",e)}(e);if("number"==typeof e)return function(e){return Q("id",e)}(e);const{message:t}=we("UNKNOWN_TYPE","Target type: "+typeof e);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Pr)}
1async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:e}=we("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:t}=we("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}checkExpiry(e,t){const{expiry:i}=t;(0,p.toMiliseconds)(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Ir,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach(((e,t)=>this.checkExpiry(t,e)))}registerEventListeners(){this.core.heartbeat.on(ze.HEARTBEAT_EVENTS.pulse,(()=>this.checkExpirations())),this.events.on(br,(e=>{const t=br;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(Ir,(e=>{const t=Ir;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})),this.events.on(Er,(e=>{const t=Er;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}))}isInitialized(){if(!this.initialized){const{message:e}=we("NOT_INITIALIZED",this.name);throw new Error(e)}}}class sn extends class{constructor(e,t){this.projectId=e,this.logger=t}}{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,this.name=Sr,this.initialized=!1,this.init=async e=>{V()||!K()||(this.verifyUrl=e?.verifyUrl||Or,await this.createIframe())},this.register=async e=>{var t;if(this.initialized||await this.init(),this.iframe)try{null==(t=this.iframe.contentWindow)||t.postMessage(e.attestationId,this.verifyUrl),this.logger.info(`postMessage sent: ${e.attestationId} ${this.verifyUrl}`)}catch{}},this.resolve=async e=>{var t;if(this.isDevEnv)return"";this.logger.info(`resolving attestation: ${e.attestationId}`);const i=this.startAbortTimer(p.FIVE_SECONDS),r=await fetch(`${this.verifyUrl}/attestation/${e.attestationId}`,{signal:this.abortController.signal});return clearTimeout(i),200===r.status?null==(t=await r.json())?void 0:t.origin:""},this.createIframe=async()=>{try{await Promise.race([new Promise(((e,t)=>{if(document.getElementById(Sr))return e();const i=document.createElement("iframe");i.setAttribute("id",Sr),i.setAttribute("src",`${this.verifyUrl}/${this.projectId}`),i.style.display="none",i.addEventListener("load",(()=>{this.initialized=!0,e()})),i.addEventListener("error",(e=>{t(e)})),document.body.append(i),this.iframe=i})),new Promise((e=>{setTimeout((()=>e("iframe load timeout")),(0,p.toMiliseconds)(p.ONE_SECOND/2))}))])}catch(e){this.logger.error(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.error(e)}},this.logger=(0,ke.generateChildLogger)(t,this.name),this.verifyUrl=Or,this.abortController=new AbortController,this.isDevEnv=k()&&wt.env.IS_VITEST}get context(){return(0,ke.getLoggerContext)(this.logger)}startAbortTimer(e){return setTimeout((()=>this.abortController.abort()),(0,p.toMiliseconds)(e))}}var on=Object.defineProperty,an=Object.getOwnPropertySymbols,cn=Object.prototype.hasOwnProperty,hn=Object.prototype.propertyIsEnumerable,un=(e,t,i)=>t in e?on(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,ln=(e,t)=>{for(var i in t||(t={}))cn.call(t,i)&&un(e,i,t[i]);if(an)for(var i of an(t))hn.call(t,i)&&un(e,i,t[i]);return e};class pn extends Ke{constructor(e){super(e),this.protocol="wc",this.version=2,this.name=Hi,this.events=new r.EventEmitter,this.initialized=!1,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Zi;const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,ke.pino)((0,ke.getDefaultLoggerOptions)({level:e?.logger||Wi}));this.logger=(0,ke.generateChildLogger)(t,this.name),this.heartbeat=new ze.HeartBeat,this.crypto=new Nr(this,this.logger,e?.keychain),this.history=new rn(this,this.logger),this.expirer=new nn(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new Le.ZP(ln(ln({},Fi),e?.storageOptions)),this.relayer=new Fr({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new tn(this,this.logger),this.verify=new sn(this.projectId||"",this.logger)}static async init(e){const t=new pn(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",i),t}get context(){return(0,ke.getLoggerContext)(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(
1),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const fn=pn,dn="client",gn="wc@2:client:",yn=dn,vn="error",mn="Proposal expired",wn=p.SEVEN_DAYS,_n={wc_sessionPropose:{req:{ttl:p.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:p.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:p.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:p.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:p.ONE_DAY,prompt:!1,tag:1104},res:{ttl:p.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:p.ONE_DAY,prompt:!1,tag:1106},res:{ttl:p.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:p.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:p.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:p.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:p.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:p.ONE_DAY,prompt:!1,tag:1112},res:{ttl:p.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:p.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:p.THIRTY_SECONDS,prompt:!1,tag:1115}}},bn={min:p.FIVE_MINUTES,max:p.SEVEN_DAYS},En=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var In=Object.defineProperty,Pn=Object.defineProperties,Sn=Object.getOwnPropertyDescriptors,On=Object.getOwnPropertySymbols,Rn=Object.prototype.hasOwnProperty,Nn=Object.prototype.propertyIsEnumerable,Cn=(e,t,i)=>t in e?In(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,xn=(e,t)=>{for(var i in t||(t={}))Rn.call(t,i)&&Cn(e,i,t[i]);if(On)for(var i of On(t))Nn.call(t,i)&&Cn(e,i,t[i]);return e},An=(e,t)=>Pn(e,Sn(t));class Tn extends class{constructor(e){this.client=e}}{constructor(e){super(e),this.name="engine",this.events=new(n()),this.initialized=!1,this.ignoredPayloadTypes=[1],this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.client.core.pairing.register({methods:Object.keys(_n)}),this.initialized=!0)},this.connect=async e=>{this.isInitialized();const t=An(xn({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);const{pairingTopic:i,requiredNamespaces:r,optionalNamespaces:n,sessionProperties:s,relays:o}=t;let a,c=i,h=!1;if(c&&(h=this.client.core.pairing.pairings.get(c).active),!c||!h){const{topic:e,uri:t}=await this.client.core.pairing.create();c=e,a=t}const u=await this.client.core.crypto.generateKeyPair(),l=xn({requiredNamespaces:r,optionalNamespaces:n,relays:o??[{protocol:"irn"}],proposer:{publicKey:u,metadata:this.client.metadata}},s&&{sessionProperties:s}),{reject:f,resolve:d,done:g}=Y(p.FIVE_MINUTES,mn);if(this.events.once(ie("session_connect"),(async({error:e,session:t})=>{if(e)f(e);else if(t){t.self.publicKey=u;const e=An(xn({},t),{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces});await this.client.session.set(t.topic,e),await this.setExpiry(t.topic,t.expiry),c&&await this.client.core.pairing.updateMetadata({topic:c,metadata:t.peer.metadata}),d(e)}})),!c){const{message:e}=we("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(e)}const y=await this.sendRequest(c,"wc_sessionPropose",l),v=ee(p.FIVE_MINUTES);return await this.setProposal(y,xn({id:y,expiry:v},l)),{uri:a,approval:g}},this.pair=async e=>(this.isInitialized(),await this.client.core.pairing.pair(e)),this.approve=async e=>{this.isInitialized(),await this.isValidApprove(e);const{id:t,relayProtocol:i,namespaces:r,sessionProperties:n}=e,s=this.client.proposal.get(t);let{pairingTopic:o,proposer:a,requiredNamespaces:c,optionalNamespaces:h}=s;o=o||"",Ee(c)||(c=function(e,t){const i=Ae(e,t);if(i)throw new Error(i.message);const r={};for(const[n,s]of Object.entries(e))r[n]={methods:s.methods,events:s.events,chains:s.accounts.map((e=>`${e.split(":")[0]}:${e.split(":")[1]}`))};return r}(r,"approve()"));const u=await this.client.core.crypto.generateKeyPair(),l=a.publicKey,p=await this.client.core.crypto.generateSharedKey(u,l);o&&t&&(await this.client.core.pairing.updateMetadata({topic:o,metadata:a.metadata}),await this.sendResult(t,o,{relay:{protocol:i??"irn"},responderPublicKey:u}),await this.client.proposal.delete(t,_e("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:o}));const f=xn({relay:{protocol:i??"irn"},namespaces:r,requiredNamespaces:c,optionalNamespaces:h,pairingTopic:o,controller:{publicKey:u,metadata:this.client.metadata},expiry:ee(wn)},n&&{sessionProperties:n});await this.client.core.relayer.subscribe(p),await this.sendRequest(p,"wc_sessionSettle",f);const d=An(xn({},f),{topic:p,pairingTopic:o,acknowledged:!1,self:f.controller,peer:{publicKey:a.publicKey,metadata:a.metadata},controller:u});return await this.client.session.set(p,d),await this.setExpiry(p,ee(wn)),{topic:p,acknowledged:()=>new Promise((e=>setTimeout((()=>e(this.client.session.get(p))),500)))}},this.reject=async e=>{this.isInitialized(),await this.isValidReject(e);const{id:t,reason:i}=e,{pairingTopic:r}=this.client.proposal.get(t);r&&(await this.sendError(t,r,i),await this.client.proposal.delete(t,_e("USER_DISCONNECTED")))},this.update=async e=>{this.isInitialized(),await this.isValidUpdate(e);const{topic:t,namespaces:i}=e,r=await this.sendRequest(t,"wc_sessionUpdate",{namespaces:i}
1),{done:n,resolve:s,reject:o}=Y();return this.events.once(ie("session_update",r),(({error:e})=>{e?o(e):s()})),await this.client.session.update(t,{namespaces:i}),{acknowledged:n}},this.extend=async e=>{this.isInitialized(),await this.isValidExtend(e);const{topic:t}=e,i=await this.sendRequest(t,"wc_sessionExtend",{}),{done:r,resolve:n,reject:s}=Y();return this.events.once(ie("session_extend",i),(({error:e})=>{e?s(e):n()})),await this.setExpiry(t,ee(wn)),{acknowledged:r}},this.request=async e=>{this.isInitialized(),await this.isValidRequest(e);const{chainId:t,request:r,topic:n,expiry:s}=e,o=await this.sendRequest(n,"wc_sessionRequest",{request:r,chainId:t},s),{done:a,resolve:c,reject:h}=Y(s);this.events.once(ie("session_request",o),(({error:e,result:t})=>{e?h(e):c(t)})),this.client.events.emit("session_request_sent",{topic:n,request:r,chainId:t,id:o});return async function({id:e,topic:t,wcDeepLink:r}){try{if(!r)return;let n=("string"==typeof r?JSON.parse(r):r)?.href;if("string"!=typeof n)return;n.endsWith("/")&&(n=n.slice(0,-1));const s=`${n}/wc?requestId=${e}&sessionTopic=${t}`,o=H();o===M?window.open(s,"_self","noreferrer noopener"):o===q&&typeof(null==i.g?void 0:i.g.Linking)<"u"&&await i.g.Linking.openURL(s)}catch(s){console.error(s)}}({id:o,topic:n,wcDeepLink:await this.client.core.storage.getItem("WALLETCONNECT_DEEPLINK_CHOICE")}),await a()},this.respond=async e=>{this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:i}=e,{id:r}=i;ft(i)?await this.sendResult(r,t,i.result):dt(i)&&await this.sendError(r,t,i.error),this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0})},this.ping=async e=>{this.isInitialized(),await this.isValidPing(e);const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=await this.sendRequest(t,"wc_sessionPing",{}),{done:i,resolve:r,reject:n}=Y();this.events.once(ie("session_ping",e),(({error:e})=>{e?n(e):r()})),await i()}else this.client.core.pairing.pairings.keys.includes(t)&&await this.client.core.pairing.ping({topic:t})},this.emit=async e=>{this.isInitialized(),await this.isValidEmit(e);const{topic:t,event:i,chainId:r}=e;await this.sendRequest(t,"wc_sessionEvent",{event:i,chainId:r})},this.disconnect=async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=st().toString();let i;const r=t=>{t?.id.toString()===e&&(this.client.core.relayer.events.removeListener(Xi,r),i())};await Promise.all([new Promise((e=>{i=e,this.client.core.relayer.on(Xi,r)})),this.sendRequest(t,"wc_sessionDelete",_e("USER_DISCONNECTED"),void 0,e)]),await this.deleteSession(t)}else await this.client.core.pairing.disconnect({topic:t})},this.find=e=>(this.isInitialized(),this.client.session.getAll().filter((t=>function(e,t){const{requiredNamespaces:i}=t,r=Object.keys(e.namespaces),n=Object.keys(i);let s=!0;return!!F(n,r)&&(r.forEach((t=>{const{accounts:r,methods:n,events:o}=e.namespaces[t],a=de(r),c=i[t];(!F(m(t,c),a)||!F(c.methods,n)||!F(c.events,o))&&(s=!1)})),s)}(t,e)))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.pairingTopic),i=this.client.core.pairing.pairings.getAll().filter((i=>{var r,n;return(null==(r=i.peerMetadata)?void 0:r.url)&&(null==(n=i.peerMetadata)?void 0:n.url)===e.peer.metadata.url&&i.topic&&i.topic!==t.topic}));if(0===i.length)return;this.client.logger.info(`Cleaning up ${i.length} duplicate pairing(s)`),await Promise.all(i.map((e=>this.client.core.pairing.disconnect({topic:e.topic})))),this.client.logger.info("Duplicate pairings clean up finished")}catch(t){this.client.logger.error(t)}},this.deleteSession=async(e,t)=>{const{self:i}=this.client.session.get(e);await this.client.core.relayer.unsubscribe(e),this.client.session.delete(e,_e("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(i.publicKey)&&await this.client.core.crypto.deleteKeyPair(i.publicKey),this.client.core.crypto.keychain.has(e)&&await this.client.core.crypto.deleteSymKey(e),t||this.client.core.expirer.del(e)},this.deleteProposal=async(e,t)=>{await Promise.all([this.client.proposal.delete(e,_e("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)])},this.deletePendingSessionRequest=async(e,t,i=!1)=>
1{await Promise.all([this.client.pendingRequest.delete(e,t),i?Promise.resolve():this.client.core.expirer.del(e)])},this.setExpiry=async(e,t)=>{this.client.session.keys.includes(e)&&await this.client.session.update(e,{expiry:t}),this.client.core.expirer.set(e,t)},this.setProposal=async(e,t)=>{await this.client.proposal.set(e,t),this.client.core.expirer.set(e,t.expiry)},this.setPendingSessionRequest=async e=>{const t=_n.wc_sessionRequest.req.ttl,{id:i,topic:r,params:n}=e;await this.client.pendingRequest.set(i,{id:i,topic:r,params:n}),t&&this.client.core.expirer.set(i,ee(t))},this.sendRequest=async(e,t,i,r,n)=>{const s=ot(t,i);if(K()&&En.includes(t)){const e=P(JSON.stringify(s));await this.client.core.verify.register({attestationId:e})}const o=await this.client.core.crypto.encode(e,s),a=_n[t].req;return r&&(a.ttl=r),n&&(a.id=n),this.client.core.history.set(e,s),this.client.core.relayer.publish(e,o,a),s.id},this.sendResult=async(e,t,i)=>{const r=at(e,i),n=await this.client.core.crypto.encode(t,r),s=await this.client.core.history.get(t,e),o=_n[s.request.method].res;this.client.core.relayer.publish(t,n,o),await this.client.core.history.resolve(r)},this.sendError=async(e,t,i)=>{const r=ct(e,i),n=await this.client.core.crypto.encode(t,r),s=await this.client.core.history.get(t,e),o=_n[s.request.method].res;this.client.core.relayer.publish(t,n,o),await this.client.core.history.resolve(r)},this.cleanup=async()=>{const e=[],t=[];this.client.session.getAll().forEach((t=>{te(t.expiry)&&e.push(t.topic)})),this.client.proposal.getAll().forEach((e=>{te(e.expiry)&&t.push(e.id)})),await Promise.all([...e.map((e=>this.deleteSession(e))),...t.map((e=>this.deleteProposal(e)))])},this.onRelayEventRequest=e=>{const{topic:t,payload:i}=e,r=i.method;switch(r){case"wc_sessionPropose":return this.onSessionProposeRequest
1(t,i);case"wc_sessionSettle":return this.onSessionSettleRequest(t,i);case"wc_sessionUpdate":return this.onSessionUpdateRequest(t,i);case"wc_sessionExtend":return this.onSessionExtendRequest(t,i);case"wc_sessionPing":return this.onSessionPingRequest(t,i);case"wc_sessionDelete":return this.onSessionDeleteRequest(t,i);case"wc_sessionRequest":return this.onSessionRequest(t,i);case"wc_sessionEvent":return this.onSessionEventRequest(t,i);default:return this.client.logger.info(`Unsupported request method ${r}`)}},this.onRelayEventResponse=async e=>{const{topic:t,payload:i}=e,r=(await this.client.core.history.get(t,i.id)).request.method;switch(r){case"wc_sessionPropose":return this.onSessionProposeResponse(t,i);case"wc_sessionSettle":return this.onSessionSettleResponse(t,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,i);case"wc_sessionExtend":return this.onSessionExtendResponse(t,i);case"wc_sessionPing":return this.onSessionPingResponse(t,i);case"wc_sessionRequest":return this.onSessionRequestResponse(t,i);default:return this.client.logger.info(`Unsupported response method ${r}`)}},this.onRelayEventUnknownPayload=e=>{const{topic:t}=e,{message:i}=we("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(i)},this.onSessionProposeRequest=async(e,t)=>{const{params:i,id:r}=t;try{this.isValidConnect(xn({},t.params));const n=ee(p.FIVE_MINUTES),s=xn({id:r,pairingTopic:e,expiry:n},i);await this.setProposal(r,s);const o=P(JSON.stringify(t)),a=await this.getVerifyContext(o,s.proposer.metadata);this.client.events.emit("session_proposal",{id:r,params:s,verifyContext:a})}catch(n){await this.sendError(r,e,n),this.client.logger.error(n)}},this.onSessionProposeResponse=async(e,t)=>{const{id:i}=t;if(ft(t)){const{result:r}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:r});const n=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const s=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:s});const o=r.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:o});const a=await this.client.core.crypto.generateSharedKey(s,o);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:a});const c=await this.client.core.relayer.subscribe(a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:c}),await this.client.core.pairing.activate({topic:e})}else dt(t)&&(await this.client.proposal.delete(i,_e("USER_DISCONNECTED")),this.events.emit(ie("session_connect"),{error:t.error}))},this.onSessionSettleRequest=async(e,t)=>{const{id:i,params:r}=t;try{this.isValidSessionSettleRequest(r);const{relay:i,controller:n,expiry:s,namespaces:o,requiredNamespaces:a,optionalNamespaces:c,sessionProperties:h,pairingTopic:u}=t.params,l=xn({topic:e,relay:i,expiry:s,namespaces:o,acknowledged:!0,pairingTopic:u,requiredNamespaces:a,optionalNamespaces:c,controller:n.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:n.publicKey,metadata:n.metadata}},h&&{sessionProperties:h});await this.sendResult(t.id,e,!0),this.events.emit(ie("session_connect"),{session:l}),this.cleanupDuplicatePairings(l)}catch(n){await this.sendError(i,e,n),this.client.logger.error(n)}},this.onSessionSettleResponse=async(e,t)=>{const{id:i}=t;ft(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(ie("session_approve",i),{})):dt(t)&&(await this.client.session.delete(e,_e("USER_DISCONNECTED")),this.events.emit(ie("session_approve",i),{error:t.error}))},this.onSessionUpdateRequest=async(e,t)=>{const{params:i,id:r}=t;try{this.isValidUpdate(xn({topic:e},i)),await this.client.session.update(e,{namespaces:i.namespaces}),await this.sendResult(r,e,!0),this.client.events.emit("session_update",{id:r,topic:e,params:i})}catch(n){await this.sendError(r,e,n),this.client.logger.error(n)}},this.onSessionUpdateResponse=(e,t)=>{const{id:i}=t;ft(t)?this.events.emit(ie("session_update",i),{}):dt(t)&&this.events.emit(ie("session_update",i),{error:t.error})},this.onSessionExtendRequest=async(e,t)=>{const{id:i}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,ee(wn)),await this.sendResult(i,e,!0),this.client.events.emit("session_extend",{id:i,topic:e})}catch(r){await this.sendError(i,e,r),this.client.logger.error(r)}},this.onSessionExtendResponse=(e,t)=>{const{id:i}=t;ft(t)?this.events.emit(ie("session_extend",i),{}):dt(t)&&this.events.emit(ie("session_extend",i),{error:t.error})},this.onSessionPingRequest=async(e,t)=>{const{id:i}=t;try{this.isValidPing({topic:e}),await this.sendResult(i,e,!0),this.client.events.emit("session_ping",{id:i,topic:e})}catch(r){await this.sendError(i,e,r),this.client.logger.error(r)}},this.onSessionPingResponse=(e,t)=>{const{id:i}=t;setTimeout((()=>{ft(t)?this.events.emit(ie("session_ping",i),{}):dt(t)&&this.events.emit(ie("session_ping",i),{error:t.error})}),500)},this.onSessionDeleteRequest=async(e,t)=>{const{id:i}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),await Promise.all([new Promise((t=>{this.client.core.relayer.once(sr,(async()=>{t(await this.deleteSession(e))}))})),this.sendResult(i,e,!0)]),this.client.events.emit("session_delete",{id:i,topic:e})}catch(r){this.client.logger.error(r)}},this.onSessionRequest=async(e,t)=>{const{id:i,params:r}=t;try{this.isValidRequest(xn({topic:e},r)),await this.setPendingSessionRequest({id:i,topic:e,params:r});const n=P(JSON.stringify(t)),s=this.client.session.get(e),o=await this.getVerifyContext(n,s.peer.metadata);this.client.events.emit("session_request",{id:i,topic:e,params:r,verifyContext:o})}catch(n){await this.sendError(i,e,n),this.client.logger.error(n)}},this.onSessionRequestResponse=(e,t)=>{const{id:i}=t;ft(t)?this.events.emit(ie("session_request",i),{result:t.result}):dt(t)&&this.events.emit(ie("session_request",i),{error:t.error})},this.onSessionEventRequest=async(e,t)=>{const{id:i,params:r}=t;try{this.isValidEmit(xn({topic:e},r)),this.client.events.emit("session_event",{id:i,topic:e,params:r})}catch(n){await this.sendError(i,e,n),this.client.logger.error(n)}},this.isValidConnect=async e=>{if(!De(e)){const{message:t}=we("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(t)}const{pairingTopic:t,requiredNamespaces:i,optionalNamespaces:r,sessionProperties:n,relays:s}=e;if(Ie(t)||await this.isValidPairingTopic(t),!function(e,t){let i=!1;return t&&!e?i=!0:e&&be(e)&&e.length&&e.forEach((e=>{i=Te(e)})),i}(s,!0)){const{message:e}=we("MISSING_OR_INVALID",`connect() relays: ${s}`);throw new Error(e)}!Ie(i)&&0!==Ee(i)&&this.validateNamespaces(i,"requiredNamespaces"),!Ie(r)&&0!==Ee(r)&&this.validateNamespaces(r,"optionalNamespaces"),Ie(n)||this.validateSessionProps(n,"sessionProperties")},this.validateNamespaces=(e,t)=>{const i=function(e,t,i){let r=null;if(e&&Ee(e)){const i=xe(e,t);i&&(r=i);const n=Ne(e,t);n&&(r=n)}else r=we("MISSING_OR_INVALID",`${t}, ${i} should be an object with data`);return r}(e,"connect()",t);if(i)throw new Error(i.message)},this.isValidApprove=async e=>{if(!De(e))throw new Error(we("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:t,namespaces:i,relayProtocol:r,sessionProperties:n}=e;await this.isValidProposalId(t);const s=this.client.proposal.get(t),o=Ae(i,"approve()");if(o)throw new Error(o.message);const a=Ue(s.requiredNamespaces,i,"approve()");if(a)throw new Error(a.message);if(!Pe(r,!0)){const{message:e}=we("MISSING_OR_INVALID",`approve() relayProtocol: ${r}`);throw new Error(e)}Ie(n)||this.validateSessionProps(n,"sessionProperties")},this.isValidReject=async e=>{if(!De(e)){const{message:t}=we("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(t)}const{id:t,reason:i}=e;if(await this.isValidProposalId(t),!function(e){return!(!e||"object"!=typeof e||!e.code||!Se(e.code,!1)||
1!e.message||!Pe(e.message,!1))}(i)){const{message:e}=we("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(e)}},this.isValidSessionSettleRequest=e=>{if(!De(e)){const{message:t}=we("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}const{relay:t,controller:i,namespaces:r,expiry:n}=e;if(!Te(t)){const{message:e}=we("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const s=function(e,t){let i=null;return Pe(e?.publicKey,!1)||(i=we("MISSING_OR_INVALID",`${t} controller public key should be a string`)),i}(i,"onSessionSettleRequest()");if(s)throw new Error(s.message);const o=Ae(r,"onSessionSettleRequest()");if(o)throw new Error(o.message);if(te(n)){const{message:e}=we("EXPIRED","onSessionSettleRequest()");throw new Error(e)}},this.isValidUpdate=async e=>{if(!De(e)){const{message:t}=we("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(t)}const{topic:t,namespaces:i}=e;await this.isValidSessionTopic(t);const r=this.client.session.get(t),n=Ae(i,"update()");if(n)throw new Error(n.message);const s=Ue(r.requiredNamespaces,i,"update()");if(s)throw new Error(s.message)},this.isValidExtend=async e=>{if(!De(e)){const{message:t}=we("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionTopic(t)},this.isValidRequest=async e=>{if(!De(e)){const{message:t}=we("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(t)}const{topic:t,request:i,chainId:r,expiry:n}=e;await this.isValidSessionTopic(t);const{namespaces:s}=this.client.session.get(t);if(!je(s,r)){const{message:e}=we("MISSING_OR_INVALID",`request() chainId: ${r}`);throw new Error(e)}if(!function(e){return!(Ie(e)||!Pe(e.method,!1))}(i)){const{message:e}=we("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(e)}if(!$e(s,r,i.method)){const{message:e}=we("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(e)}if(n&&!function(e,t){return Se(e,!1)&&e<=t.max&&e>=t.min}(n,bn)){const{message:e}=we("MISSING_OR_INVALID",`request() expiry: ${n}. Expiry must be a number (in seconds) between ${bn.min} and ${bn.max}`);throw new Error(e)}},this.isValidRespond=async e=>{if(!De(e)){const{message:t}=we("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:t,response:i}=e;if(await this.isValidSessionTopic(t),!function(e){return!(Ie(e)||Ie(e.result)&&Ie(e.error)||!Se(e.id,!1)||!Pe(e.jsonrpc,!1))}(i)){const{message:e}=we("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(e)}},this.isValidPing=async e=>{if(!De(e)){const{message:t}=we("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.isValidEmit=async e=>{if(!De(e)){const{message:t}=we("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(t)}const{topic:t,event:i,chainId:r}=e;await this.isValidSessionTopic(t);const{namespaces:n}=this.client.session.get(t);if(!je(n,r)){const{message:e}=we("MISSING_OR_INVALID",`emit() chainId: ${r}`);throw new Error(e)}if(!function(e){return!(Ie(e)||!Pe(e.name,!1))}(i)){const{message:e}=we("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(e)}if(!qe(n,r,i.name)){const{message:e}=we("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(e)}},this.isValidDisconnect=async e=>{if(!De(e)){const{message:t}=we("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)},this.getVerifyContext=async(e,t)=>{const i={verified:{verifyUrl:t.verifyUrl||"",validation:"UNKNOWN",origin:t.url||""}};try{const r=await this.client.core.verify.resolve({attestationId:e,verifyUrl:t.verifyUrl});r&&(i.verified.origin=r,i.verified.validation=r===t.url?"VALID":"INVALID")}catch(r){this.client.logger.error(r)}return this.client.logger.info(`Verify context: ${JSON.stringify(i)}`),i},this.validateSessionProps=(e,t)=>{Object.values(e).forEach((e=>{if(!Pe(e,!1)){const{message:i}=we("MISSING_OR_INVALID",`${t} must be in Record<string, string> format. Received: ${JSON.stringify(e)}`);throw new Error(i)}}))}}isInitialized(){if(!this.initialized){const{message:e}=we("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.client.core.relayer.on(Qi,(async e=>{const{topic:t,message:i}=e;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(i)))return;const r=await this.client.core.crypto.decode(t,i);lt(r)?(this.client.core.history.set(t,r),this.onRelayEventRequest({topic:t,payload:r})):pt(r)?(await this.client.core.history.resolve(r),this.onRelayEventResponse({topic:t,payload:r})):this.onRelayEventUnknownPayload({topic:t,payload:r})}))}registerExpirerEvents(){this.client.core.expirer.on(Ir,(async e=>
1{const{topic:t,id:i}=X(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,we("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession(t,!0),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))}))}isValidPairingTopic(e){if(!Pe(e,!1)){const{message:t}=we("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=we("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(te(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=we("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!Pe(e,!1)){const{message:t}=we("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(!this.client.session.keys.includes(e)){const{message:t}=we("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(te(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:t}=we("EXPIRED",`session topic: ${e}`);throw new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else{if(!this.client.core.pairing.pairings.keys.includes(e)){if(Pe(e,!1)){const{message:t}=we("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=we("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if("number"!=typeof e){const{message:t}=we("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=we("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(te(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:t}=we("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class Dn extends en{constructor(e,t){super(e,t,"proposal",gn),this.core=e,this.logger=t}}class jn extends en{constructor(e,t){super(e,t,"session",gn),this.core=e,this.logger=t}}class $n extends en{constructor(e,t){super(e,t,"request",gn,(e=>e.id)),this.core=e,this.logger=t}}class qn extends class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}{constructor(e){super(e),this.protocol="wc",this.version=2,this.name=yn,this.events=new r.EventEmitter,this.on=(e,t)=>this.events.on(e,t),this.once=(e,t)=>this.events.once(e,t),this.off=(e,t)=>this.events.off(e,t),this.removeListener=(e,t)=>this.events.removeListener(e,t),this.removeAllListeners=e=>this.events.removeAllListeners(e),this.connect=async e=>{try{return await this.engine.connect(e)}catch(t){throw this.logger.error(t.message),t}},this.pair=async e=>{try{return await this.engine.pair(e)}catch(t){throw this.logger.error(t.message),t}},this.approve=async e=>{try{return await this.engine.approve(e)}catch(t){throw this.logger.error(t.message),t}},this.reject=async e=>{try{return await this.engine.reject(e)}catch(t){throw this.logger.error(t.message),t}},this.update=async e=>{try{return await this.engine.update(e)}catch(t){throw this.logger.error(t.message),t}},this.extend=async e=>{try{return await this.engine.extend(e)}catch(t){throw this.logger.error(t.message),t}},this.request=async e=>{try{return await this.engine.request(e)}catch(t){throw this.logger.error(t.message),t}},this.respond=async e=>{try{return await this.engine.respond(e)}catch(t){throw this.logger.error(t.message),t}},this.ping=async e=>{try{return await this.engine.ping(e)}catch(t){throw this.logger.error(t.message),t}},this.emit=async e=>{try{return await this.engine.emit(e)}catch(t){throw this.logger.error(t.message),t}},this.disconnect=async e=>{try{return await this.engine.disconnect(e)}catch(t){throw this.logger.error(t.message),t}},this.find=e=>{try{return this.engine.find(e)}catch(t){throw this.logger.error(t.message),t}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}},this.name=e?.name||yn,this.metadata=e?.metadata||(0,d.D)()||{name:"",description:"",url:"",icons:[""]};const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,ke.pino)((0,ke.getDefaultLoggerOptions)({level:e?.logger||vn}));this.core=e?.core||new fn(e),this.logger=(0,ke.generateChildLogger)(t,this.name),this.session=new jn(this.core,this.logger),this.proposal=new Dn(this.core,this.logger),this.pendingRequest=new $n(this.core,this.logger),this.engine=new Tn(this)}static async init(e){const t=new qn(e);return await t.initialize(),t}get context(){return(0,ke.getLoggerContext)(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.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(Ke){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(Ke.message),Ke}}}var Un=i(54098),Mn=i.n(Un);const Ln="INTERNAL_ERROR",zn="SERVER_ERROR",kn=[-32700,-32600,-32601,-32602,-32603],Vn={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"},[Ln]:{code:-32603,message:"Internal error"},[zn]:{code:-32e3,message:"Server error"}};function Kn(e){return kn.includes(e)}function Hn(e){return Object.keys(Vn).includes(e)?Vn[e]:Vn.SERVER_ERROR}function Bn(e){const t=Object.values(Vn).find((t=>t.code===e));return t||Vn.SERVER_ERROR}function Wn(e,t){return"undefined"===typeof e?Hn(Ln):("string"===typeof e&&(e=Object.assign(Object.assign({},Hn(zn)),{message:e})),"undefined"!==typeof t&&(e.data=t),Kn(e.code)&&(e=Bn(e.code)),e)}i(47519);function Fn(e,t){const i=function(e){const t=e.match(new RegExp(/^\w+:/,"gi"));if(t&&t.length)return t[0]}(e);return"undefined"!==typeof i&&new RegExp(t).test(i)}function Gn(e){return Fn(e,"^https?:")}const Jn={headers:{Accept:"application/json","Content-Type":"application/json"},method:"POST"};class Yn{constructor(e,t=!1){if(this.url=e,this.disableProviderPing=t,this.events=new r.EventEmitter,this.isAvailable=!1,this.registering=!1,!Gn(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=t}
1get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e,t){this.isAvailable||await this.register();try{const t=(0,Je.u)(e),i=await Mn()(this.url,Object.assign(Object.assign({},Jn),{body:t})),r=await i.json();this.onPayload({data:r})}catch(i){this.onError(e.id,i)}}async register(e=this.url){if(!Gn(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const e=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=e||this.events.listenerCount("open")>=e)&&this.events.setMaxListeners(e+1),new Promise(((e,t)=>{this.events.once("register_error",(e=>{this.resetMaxListeners(),t(e)})),this.events.once("open",(()=>{if(this.resetMaxListeners(),"undefined"===typeof this.isAvailable)return t(new Error("HTTP connection is missing or invalid"));e()}))}))}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const t=(0,Je.u)({id:1,jsonrpc:"2.0",method:"test",params:[]});await Mn()(e,Object.assign(Object.assign({},Jn),{body:t}))}this.onOpen()}catch(t){const e=this.parseError(t);throw this.events.emit("register_error",e),this.onClose(),e}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if("undefined"===typeof e.data)return;const t="string"===typeof e.data?(0,Je.D)(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const i=this.parseError(t),r=function(e,t,i){return{id:e,jsonrpc:"2.0",error:Wn(t,i)}}(e,i.message||i.toString());this.events.emit("payload",r)}parseError(e,t=this.url){return function(e,t,i){return e.message.includes("getaddrinfo ENOTFOUND")||e.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${i} RPC url at ${t}`):e}(e,t,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}}var Zn=Yn;const Qn="error",Xn="wc@2:universal_provider:",es="default_chain_changed";var ts=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof i.g<"u"?i.g:typeof self<"u"?self:{},is={exports:{}};!function(e,t){(function(){var i,r="Expected a function",n="__lodash_hash_undefined__",s="__lodash_placeholder__",o=16,a=32,c=64,h=128,u=256,l=1/0,p=9007199254740991,f=NaN,d=4294967295,g=[["ary",h],["bind",1],["bindKey",2],["curry",8],["curryRight",o],["flip",512],["partial",a],["partialRight",c],["rearg",u]],y="[object Arguments]",v="[object Array]",m="[object Boolean]",w="[object Date]",_="[object Error]",b="[object Function]",E="[object GeneratorFunction]",I="[object Map]",P="[object Number]",S="[object Object]",O="[object Promise]",R="[object RegExp]",N="[object Set]",C="[object String]",x="[object Symbol]",A="[object WeakMap]",T="[object ArrayBuffer]",D="[object DataView]",j="[object Float32Array]",$="[object Float64Array]",q="[object Int8Array]",U="[object Int16Array]",M="[object Int32Array]",L="[object Uint8Array]",z="[object Uint8ClampedArray]",k="[object Uint16Array]",V="[object Uint32Array]",K=/\b__p \+= '';/g,H=/\b(__p \+=) '' \+/g,B=/(__e\(.*?\)|\b__t\)) \+\n'';/g,W=/&(?:amp|lt|gt|quot|#39);/g,F=/[&<>"']/g,G=RegExp(W.source),J=RegExp(F.source),Y=/<%-([\s\S]+?)%>/g,Z=/<%([\s\S]+?)%>/g,Q=/<%=([\s\S]+?)%>/g,X=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ee=/^\w*$/,te=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ie=/[\\^$.*+?()[\]{}|]/g,re=RegExp(ie.source),ne=/^\s+/,se=/\s/,oe=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ae=/\{\n\/\* \[wrapped with (.+)\] \*/,ce=/,? & /,he=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,ue=/[()=,{}\[\]\/\s]/,le=/\\(\\)?/g,pe=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,fe=/\w*$/,de=/^[-+]0x[0-9a-f]+$/i,ge=/^0b[01]+$/i,ye=/^\[object .+?Constructor\]$/,ve=/^0o[0-7]+$/i,me=/^(?:0|[1-9]\d*)$/,we=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u01
vendor: 4,353 bytes, line 1
17f]/g,_e=/($^)/,be=/['\n\r\u2028\u2029\\]/g,Ee="\\ud800-\\udfff",Ie="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",Pe="\\u2700-\\u27bf",Se="a-z\\xdf-\\xf6\\xf8-\\xff",Oe="A-Z\\xc0-\\xd6\\xd8-\\xde",Re="\\ufe0e\\ufe0f",Ne="\\xac\\xb1\\xd7\\xf7\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf\\u2000-\\u206f \\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",Ce="['\u2019]",xe="["+Ee+"]",Ae="["+Ne+"]",Te="["+Ie+"]",De="\\d+",je="["+Pe+"]",$e="["+Se+"]",qe="[^"+Ee+Ne+De+Pe+Se+Oe+"]",Ue="\\ud83c[\\udffb-\\udfff]",Me="[^"+Ee+"]",Le="(?:\\ud83c[\\udde6-\\uddff]){2}",ze="[\\ud800-\\udbff][\\udc00-\\udfff]",ke="["+Oe+"]",Ve="\\u200d",Ke="(?:"+$e+"|"+qe+")",He="(?:"+ke+"|"+qe+")",Be="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",We="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",Fe="(?:"+Te+"|"+Ue+")"+"?",Ge="["+Re+"]?",Je=Ge+Fe+("(?:\\u200d(?:"+[Me,Le,ze].join("|")+")"+Ge+Fe+")*"),Ye="(?:"+[je,Le,ze].join("|")+")"+Je,Ze="(?:"+[Me+Te+"?",Te,Le,ze,xe].join("|")+")",Qe=RegExp(Ce,"g"),Xe=RegExp(Te,"g"),et=RegExp(Ue+"(?="+Ue+")|"+Ze+Je,"g"),tt=RegExp([ke+"?"+$e+"+"+Be+"(?="+[Ae,ke,"$"].join("|")+")",He+"+"+We+"(?="+[Ae,ke+Ke,"$"].join("|")+")",ke+"?"+Ke+"+"+Be,ke+"+"+We,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",De,Ye].join("|"),"g"),it=RegExp("["+Ve+Ee+Ie+Re+"]"),rt=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,nt=["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"],st=-1,ot={};ot[j]=ot[$]=ot[q]=ot[U]=ot[M]=ot[L]=ot[z]=ot[k]=ot[V]=!0,ot[y]=ot[v]=ot[T]=ot[m]=ot[D]=ot[w]=ot[_]=ot[b]=ot[I]=ot[P]=ot[S]=ot[R]=ot[N]=ot[C]=ot[A]=!1;var at={};at[y]=at[v]=at[T]=at[D]=at[m]=at[w]=at[j]=at[$]=at[q]=at[U]=at[M]=at[I]=at[P]=at[S]=at[R]=at[N]=at[C]=at[x]=at[L]=at[z]=at[k]=at[V]=!0,at[_]=at[b]=at[A]=!1;var ct={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},ht=parseFloat,ut=parseInt,lt="object"==typeof ts&&ts&&ts.Object===Object&&ts,pt="object"==typeof self&&self&&self.Object===Object&&self,ft=lt||pt||Function("return this")(),dt=t&&!t.nodeType&&t,gt=dt&&e&&!e.nodeType&&e,yt=gt&>.exports===dt,vt=yt&<.process,mt=function(){try{return gt&>.require&>.require("util").types||vt&&vt.binding&&vt.binding("util")}catch{}}(),wt=mt&&mt.isArrayBuffer,_t=mt&&mt.isDate,bt=mt&&mt.isMap,Et=mt&&mt.isRegExp,It=mt&&mt.isSet,Pt=mt&&mt.isTypedArray;function St(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)}function Ot(e,t,i,r){for(var n=-1,s=null==e?0:e.length;++n<s;){var o=e[n];t(r,o,i(o),e)}return r}function Rt(e,t){for(var i=-1,r=null==e?0:e.length;++i<r&&!1!==t(e[i],i,e););return e}function Nt(e,t){for(var i=null==e?0:e.length;i--&&!1!==t(e[i],i,e););return e}function Ct(e,t){for(var i=-1,r=null==e?0:e.length;++i<r;)if(!t(e[i],i,e))return!1;return!0}function xt(e,t){for(var i=-1,r=null==e?0:e.length,n=0,s=[];++i<r;){var o=e[i];t(o,i,e)&&(s[n++]=o)}return s}function At(e,t){return!!(null==e?0:e.length)&&kt(e,t,0)>-1}function Tt(e,t,i){for(var r=-1,n=null==e?0:e.length;++r<n;)if(i(t,e[r]))return!0;return!1}function Dt(e,t){for(var i=-1,r=null==e?0:e.length,n=Array(r);++i<r;)n[i]=t(e[i],i,e);return n}function jt(e,t){for(var i=-1,r=t.length,n=e.length;++i<r;)e[n+i]=t[i];return e}function $t(e,t,i,r){var n=-1,s=null==e?0:e.length;for(r&&s&&(i=e[++n]);++n<s;)i=t(i,e[n],n,e);return i}function qt(e,t,i,r){var n=null==e?0:e.length;for(r&&n&&(i=e[--n]);n--;)i=t(i,e[n],n,e);return i}function Ut(e,t){for(var i=-1,r=null==e?0:e.length;++i<r;)if(t(e[i],i,e))return!0;return!1}var Mt=Bt("length");function Lt(e,t,i){var r;return i(e,(function(e,i,n){if(t(e,i,n))return r=i,!1})),r}function zt(e,t,i,r){for(var n=e.length,s=i+(r?1:-1);r?s--:++s<n;)if(t(e[s],s,e))return s;return-1}function kt(e,t,i){return t===t?function(e,t,i){for(var r=i-1,n=e.length;++r<n;)if(e[r]===t)return r;return-1}(e,t,i):zt(e,Kt,i)}function Vt(e,t,i,r){for(var n=i-1,s=e.length;++n<s;
vendor: 4,445 bytes, line 1
1)if(r(e[n],t))return n;return-1}function Kt(e){return e!==e}function Ht(e,t){var i=null==e?0:e.length;return i?Gt(e,t)/i:f}function Bt(e){return function(t){return null==t?i:t[e]}}function Wt(e){return function(t){return null==e?i:e[t]}}function Ft(e,t,i,r,n){return n(e,(function(e,n,s){i=r?(r=!1,e):t(i,e,n,s)})),i}function Gt(e,t){for(var r,n=-1,s=e.length;++n<s;){var o=t(e[n]);o!==i&&(r=r===i?o:r+o)}return r}function Jt(e,t){for(var i=-1,r=Array(e);++i<e;)r[i]=t(i);return r}function Yt(e){return e&&e.slice(0,fi(e)+1).replace(ne,"")}function Zt(e){return function(t){return e(t)}}function Qt(e,t){return Dt(t,(function(t){return e[t]}))}function Xt(e,t){return e.has(t)}function ei(e,t){for(var i=-1,r=e.length;++i<r&&kt(t,e[i],0)>-1;);return i}function ti(e,t){for(var i=e.length;i--&&kt(t,e[i],0)>-1;);return i}function ii(e,t){for(var i=e.length,r=0;i--;)e[i]===t&&++r;return r}var ri=Wt({"\xc0":"A","\xc1":"A","\xc2":"A","\xc3":"A","\xc4":"A","\xc5":"A","\xe0":"a","\xe1":"a","\xe2":"a","\xe3":"a","\xe4":"a","\xe5":"a","\xc7":"C","\xe7":"c","\xd0":"D","\xf0":"d","\xc8":"E","\xc9":"E","\xca":"E","\xcb":"E","\xe8":"e","\xe9":"e","\xea":"e","\xeb":"e","\xcc":"I","\xcd":"I","\xce":"I","\xcf":"I","\xec":"i","\xed":"i","\xee":"i","\xef":"i","\xd1":"N","\xf1":"n","\xd2":"O","\xd3":"O","\xd4":"O","\xd5":"O","\xd6":"O","\xd8":"O","\xf2":"o","\xf3":"o","\xf4":"o","\xf5":"o","\xf6":"o","\xf8":"o","\xd9":"U","\xda":"U","\xdb":"U","\xdc":"U","\xf9":"u","\xfa":"u","\xfb":"u","\xfc":"u","\xdd":"Y","\xfd":"y","\xff":"y","\xc6":"Ae","\xe6":"ae","\xde":"Th","\xfe":"th","\xdf":"ss","\u0100":"A","\u0102":"A","\u0104":"A","\u0101":"a","\u0103":"a","\u0105":"a","\u0106":"C","\u0108":"C","\u010a":"C","\u010c":"C","\u0107":"c","\u0109":"c","\u010b":"c","\u010d":"c","\u010e":"D","\u0110":"D","\u010f":"d","\u0111":"d","\u0112":"E","\u0114":"E","\u0116":"E","\u0118":"E","\u011a":"E","\u0113":"e","\u0115":"e","\u0117":"e","\u0119":"e","\u011b":"e","\u011c":"G","\u011e":"G","\u0120":"G","\u0122":"G","\u011d":"g","\u011f":"g","\u0121":"g","\u0123":"g","\u0124":"H","\u0126":"H","\u0125":"h","\u0127":"h","\u0128":"I","\u012a":"I","\u012c":"I","\u012e":"I","\u0130":"I","\u0129":"i","\u012b":"i","\u012d":"i","\u012f":"i","\u0131":"i","\u0134":"J","\u0135":"j","\u0136":"K","\u0137":"k","\u0138":"k","\u0139":"L","\u013b":"L","\u013d":"L","\u013f":"L","\u0141":"L","\u013a":"l","\u013c":"l","\u013e":"l","\u0140":"l","\u0142":"l","\u0143":"N","\u0145":"N","\u0147":"N","\u014a":"N","\u0144":"n","\u0146":"n","\u0148":"n","\u014b":"n","\u014c":"O","\u014e":"O","\u0150":"O","\u014d":"o","\u014f":"o","\u0151":"o","\u0154":"R","\u0156":"R","\u0158":"R","\u0155":"r","\u0157":"r","\u0159":"r","\u015a":"S","\u015c":"S","\u015e":"S","\u0160":"S","\u015b":"s","\u015d":"s","\u015f":"s","\u0161":"s","\u0162":"T","\u0164":"T","\u0166":"T","\u0163":"t","\u0165":"t","\u0167":"t","\u0168":"U","\u016a":"U","\u016c":"U","\u016e":"U","\u0170":"U","\u0172":"U","\u0169":"u","\u016b":"u","\u016d":"u","\u016f":"u","\u0171":"u","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017b":"Z","\u017d":"Z","\u017a":"z","\u017c":"z","\u017e":"z","\u0132":"IJ","\u0133":"ij","\u0152":"Oe","\u0153":"oe","\u0149":"'n","\u017f":"s"}),ni=Wt({"&":"&","<":"<",">":">",'"':""","'":"'"});function si(e){return"\\"+ct[e]}function oi(e){return it.test(e)}function ai(e){var t=-1,i=Array(e.size);return e.forEach((function(e,r){i[++t]=[r,e]})),i}function ci(e,t){return function(i){return e(t(i))}}function hi(e,t){for(var i=-1,r=e.length,n=0,o=[];++i<r;){var a=e[i];(a===t||a===s)&&(e[i]=s,o[n++]=i)}return o}function ui(e){var t=-1,i=Array(e.size);return e.forEach((function(e){i[++t]=e})),i}function li(e){return oi(e)?function(e){for(var t=et.lastIndex=0;et.test(e);)++t;return t}(e):Mt(e)}function pi(e){return oi(e)?function(e){return e.match(et)||[]}(e):function(e){return e.split("")}(e)}function fi(e){for(var t=e.length;t--&&se.test(e.charAt(t)););return t}var di=Wt({"&":"&","<":"<",">":">",""":'"',"'":"'"});var gi=function e(t){var se=(t=null==t?ft:gi.defaults(ft.Object(),t,gi.pick(ft,nt))).Array,Ee=t.Date,Ie=t.Error,Pe=t.Function,Se=t.Math,Oe=t.Object,Re=t.RegExp,Ne=t.String,Ce=t.TypeError,xe=se.prototype,Ae=Pe.prototype,Te=Oe.prototype,De=t["__core-js_shared__"],je=Ae.toString,$e=Te.hasOwnProperty,qe=0,Ue=function(){var e=/[^.]+$/.exec(De&&De.keys&&De.keys.IE_PROTO||"");
vendor: 23,136 bytes, line 1
1return e?"Symbol(src)_1."+e:""}(),Me=Te.toString,Le=je.call(Oe),ze=ft._,ke=Re("^"+je.call($e).replace(ie,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Ve=yt?t.Buffer:i,Ke=t.Symbol,He=t.Uint8Array,Be=Ve?Ve.allocUnsafe:i,We=ci(Oe.getPrototypeOf,Oe),Fe=Oe.create,Ge=Te.propertyIsEnumerable,Je=xe.splice,Ye=Ke?Ke.isConcatSpreadable:i,Ze=Ke?Ke.iterator:i,et=Ke?Ke.toStringTag:i,it=function(){try{var e=ls(Oe,"defineProperty");return e({},"",{}),e}catch{}}(),ct=t.clearTimeout!==ft.clearTimeout&&t.clearTimeout,lt=Ee&&Ee.now!==ft.Date.now&&Ee.now,pt=t.setTimeout!==ft.setTimeout&&t.setTimeout,dt=Se.ceil,gt=Se.floor,vt=Oe.getOwnPropertySymbols,mt=Ve?Ve.isBuffer:i,Mt=t.isFinite,Wt=xe.join,yi=ci(Oe.keys,Oe),vi=Se.max,mi=Se.min,wi=Ee.now,_i=t.parseInt,bi=Se.random,Ei=xe.reverse,Ii=ls(t,"DataView"),Pi=ls(t,"Map"),Si=ls(t,"Promise"),Oi=ls(t,"Set"),Ri=ls(t,"WeakMap"),Ni=ls(Oe,"create"),Ci=Ri&&new Ri,xi={},Ai=Ms(Ii),Ti=Ms(Pi),Di=Ms(Si),ji=Ms(Oi),$i=Ms(Ri),qi=Ke?Ke.prototype:i,Ui=qi?qi.valueOf:i,Mi=qi?qi.toString:i;function Li(e){if(ia(e)&&!Bo(e)&&!(e instanceof Ki)){if(e instanceof Vi)return e;if($e.call(e,"__wrapped__"))return Ls(e)}return new Vi(e)}var zi=function(){function e(){}return function(t){if(!ta(t))return{};if(Fe)return Fe(t);e.prototype=t;var r=new e;return e.prototype=i,r}}();function ki(){}function Vi(e,t){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!t,this.__index__=0,this.__values__=i}function Ki(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=d,this.__views__=[]}function Hi(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}function Bi(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}function Wi(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var r=e[t];this.set(r[0],r[1])}}function Fi(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new Wi;++t<i;)this.add(e[t])}function Gi(e){var t=this.__data__=new Bi(e);this.size=t.size}function Ji(e,t){var i=Bo(e),r=!i&&Ho(e),n=!i&&!r&&Jo(e),s=!i&&!r&&!n&&ua(e),o=i||r||n||s,a=o?Jt(e.length,Ne):[],c=a.length;for(var h in e)(t||$e.call(e,h))&&(!o||!("length"==h||n&&("offset"==h||"parent"==h)||s&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||ms(h,c)))&&a.push(h);return a}function Yi(e){var t=e.length;return t?e[Fr(0,t-1)]:i}function Zi(e,t){return $s(Cn(e),or(t,0,e.length))}function Qi(e){return $s(Cn(e))}function Xi(e,t,r){(r!==i&&!ko(e[t],r)||r===i&&!(t in e))&&nr(e,t,r)}function er(e,t,r){var n=e[t];(!$e.call(e,t)||!ko(n,r)||r===i&&!(t in e))&&nr(e,t,r)}function tr(e,t){for(var i=e.length;i--;)if(ko(e[i][0],t))return i;return-1}function ir(e,t,i,r){return lr(e,(function(e,n,s){t(r,e,i(e),s)})),r}function rr(e,t){return e&&xn(t,Ta(t),e)}function nr(e,t,i){"__proto__"==t&&it?it(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i}function sr(e,t){for(var r=-1,n=t.length,s=se(n),o=null==e;++r<n;)s[r]=o?i:Ra(e,t[r]);return s}function or(e,t,r){return e===e&&(r!==i&&(e=e<=r?e:r),t!==i&&(e=e>=t?e:t)),e}function ar(e,t,r,n,s,o){var a,c=1&t,h=2&t,u=4&t;if(r&&(a=s?r(e,n,s,o):r(e)),a!==i)return a;if(!ta(e))return e;var l=Bo(e);if(l){if(a=function(e){var t=e.length,i=new e.constructor(t);return t&&"string"==typeof e[0]&&$e.call(e,"index")&&(i.index=e.index,i.input=e.input),i}(e),!c)return Cn(e,a)}else{var p=ds(e),f=p==b||p==E;if(Jo(e))return In(e,c);if(p==S||p==y||f&&!s){if(a=h||f?{}:ys(e),!c)return h?function(e,t){return xn(e,fs(e),t)}(e,function(e,t){return e&&xn(t,Da(t),e)}(a,e)):function(e,t){return xn(e,ps(e),t)}(e,rr(a,e))}else{if(!at[p])return s?e:{};a=function(e,t,i){var r=e.constructor;switch(t){case T:return Pn(e);case m:case w:return new r(+e);case D:return function(e,t){var i=t?Pn(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.byteLength)}(e,i);case j:case $:case q:case U:case M:case L:case z:case k:case V:return Sn(e,i);case I:return new r;case P:case C:return new r(e);case R:return function(e){var t=new e.constructor(e.source,fe.exec(e));return t.lastIndex=e.lastIndex,t}(e);case N:return new r;case x:return function(e){return Ui?Oe(Ui.call(e)):{}}(e)}}(e,p,c)}}o||(o=new Gi);var d=o.get(e);if(d)return d;o.set(e,a),aa(e)?e.forEach((function(i){a.add(ar(i,t,r,i,e,o))})):ra(e)&&e.forEach((function(i,n){a.set(n,ar(i,t,r,n,e,o))}));var g=l?i:(u?h?ns:rs:h?Da:Ta)(e);return Rt(g||e,(function(i,n){g&&(i=e[n=i]),er(a,n,ar(i,t,r,n,e,o))})),a}function cr(e,t,r){var n=r.length;if(null==e)return!n;for(e=Oe(e);n--;){var s=r[n],o=t[s],a=e[s];if(a===i&&!(s in e)||!o(a))return!1}return!0}function hr(e,t,n){if("function"!=typeof e)throw new Ce(r);return As((function(){e.apply(i,n)}),t)}function ur(e,t,i,r){var n=-1,s=At,o=!0,a=e.length,c=[],h=t.length;if(!a)return c;i&&(t=Dt(t,Zt(i))),r?(s=Tt,o=!1):t.length>=200&&(s=Xt,o=!1,t=new Fi(t));e:for(;++n<a;){var u=e[n],l=null==i?u:i(u);if(u=r||0!==u?u:0,o&&l===l){for(var p=h;p--;)if(t[p]===l)continue e;c.push(u)}else s(t,l,r)||c.push(u)}return c}Li.templateSettings={escape:Y,evaluate:Z,interpolate:Q,variable:"",imports:{_:Li}},Li.prototype=ki.prototype,Li.prototype.constructor=Li,Vi.prototype=zi(ki.prototype),Vi.prototype.constructor=Vi,Ki.prototype=zi(ki.prototype),Ki.prototype.constructor=Ki,Hi.prototype.clear=function(){this.__data__=Ni?Ni(null):{},this.size=0},Hi.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Hi.prototype.get=function(e){var t=this.__data__;if(Ni){var r=t[e];return r===n?i:r}return $e.call(t,e)?t[e]:i},Hi.prototype.has=function(e){var t=this.__data__;return Ni?t[e]!==i:$e.call(t,e)},Hi.prototype.set=function(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=Ni&&t===i?n:t,this},Bi.prototype.clear=function(){this.__data__=[],this.size=0},Bi.prototype.delete=function(e){var t=this.__data__,i=tr(t,e);return!(i<0)&&(i==t.length-1?t.pop():Je.call(t,i,1),--this.size,!0)},Bi.prototype.get=function(e){var t=this.__data__,r=tr(t,e);return r<0?i:t[r][1]},Bi.prototype.has=function(e){return tr(this.__data__,e)>-1},Bi.prototype.set=function(e,t){var i=this.__data__,r=tr(i,e);return r<0?(++this.size,i.push([e,t])):i[r][1]=t,this},Wi.prototype.clear=function(){this.size=0,this.__data__={hash:new Hi,map:new(Pi||Bi),string:new Hi}},Wi.prototype.delete=function(e){var t=hs(this,e).delete(e);return this.size-=t?1:0,t},Wi.prototype.get=function(e){return hs(this,e).get(e)},Wi.prototype.has=function(e){return hs(this,e).has(e)},Wi.prototype.set=function(e,t){var i=hs(this,e),r=i.size;return i.set(e,t),this.size+=i.size==r?0:1,this},Fi.prototype.add=Fi.prototype.push=function(e){return this.__data__.set(e,n),this},Fi.prototype.has=function(e){return this.__data__.has(e)},Gi.prototype.clear=function(){this.__data__=new Bi,this.size=0},Gi.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},Gi.prototype.get=function(e){return this.__data__.get(e)},Gi.prototype.has=function(e){return this.__data__.has(e)},Gi.prototype.set=function(e,t){var i=this.__data__;if(i instanceof Bi){var r=i.__data__;if(!Pi||r.length<199)return r.push([e,t]),this.size=++i.size,this;i=this.__data__=new Wi(r)}return i.set(e,t),this.size=i.size,this};var lr=Dn(wr),pr=Dn(_r,!0);function fr(e,t){var i=!0;return lr(e,(function(e,r,n){return i=!!t(e,r,n)})),i}function dr(e,t,r){for(var n=-1,s=e.length;++n<s;){var o=e[n],a=t(o);if(null!=a&&(c===i?a===a&&!ha(a):r(a,c)))var c=a,h=o}return h}function gr(e,t){var i=[];return lr(e,(function(e,r,n){t(e,r,n)&&i.push(e)})),i}function yr(e,t,i,r,n){var s=-1,o=e.length;for(i||(i=vs),n||(n=[]);++s<o;){var a=e[s];t>0&&i(a)?t>1?yr(a,t-1,i,r,n):jt(n,a):r||(n[n.length]=a)}return n}var vr=jn(),mr=jn(!0);function wr(e,t){return e&&vr(e,t,Ta)}function _r(e,t){return e&&mr(e,t,Ta)}function br(e,t){return xt(t,(function(t){return Qo(e[t])}))}function Er(e,t){for(var r=0,n=(t=wn(t,e)).length;null!=e&&r<n;)e=e[Us(t[r++])];return r&&r==n?e:i}function Ir(e,t,i){var r=t(e);return Bo(e)?r:jt(r,i(e))}function Pr(e){return null==e?e===i?"[object Undefined]":"[object Null]":et&&et in Oe(e)?function(e){var t=$e.call(e,et),r=e[et];try{e[et]=i;var n=!0}catch{}var s=Me.call(e);return n&&(t?e[et]=r:delete e[et]),s}(e):function(e){return Me.call(e)}(e)}function Sr(e,t){return e>t}function Or(e,t){return null!=e&&$e.call(e,t)}function Rr(e,t){return null!=e&&t in Oe(e)}function Nr(e,t,r){for(var n=r?Tt:At,s=e[0].length,o=e.length,a=o,c=se(o),h=1/0,u=[];a--;){var l=e[a];a&&t&&(l=Dt(l,Zt(t))),h=mi(l.length,h),c[a]=!r&&(t||s>=120&&l.length>=120)?new Fi(a&&l):i}l=e[0];var p=-1,f=c[0];e:for(;++p<s&&u.length<h;){var d=l[p],g=t?t(d):d;if(d=r||0!==d?d:0,!(f?Xt(f,g):n(u,g,r))){for(a=o;--a;){var y=c[a];if(!(y?Xt(y,g):n(e[a],g,r)))continue e}f&&f.push(g),u.push(d)}}return u}function Cr(e,t,r){var n=null==(e=Rs(e,t=wn(t,e)))?e:e[Us(Ys(t))];return null==n?i:St(n,e,r)}function xr(e){return ia(e)&&Pr(e)==y}function Ar(e,t,r,n,s){return e===t||(null==e||null==t||!ia(e)&&!ia(t)?e!==e&&t!==t:function(e,t,r,n,s,o){var a=Bo(e),c=Bo(t),h=a?v:ds(e),u=c?v:ds(t),l=(h=h==y?S:h)==S,p=(u=u==y?S:u)==S,f=h==u;if(f&&Jo(e)){if(!Jo(t))return!1;a=!0,l=!1}if(f&&!l)return o||(o=new Gi),a||ua(e)?ts(e,t,r,n,s,o):function(e,t,i,r,n,s,o){switch(i){case D:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case T:return!(e.byteLength!=t.byteLength||!s(new He(e),new He(t)));case m:case w:case P:return ko(+e,+t);case _:return e.name==t.name&&e.message==t.message;case R:case C:return e==t+"";case I:var a=ai;case N:var c=1&r;if(a||(a=ui),e.size!=t.size&&!c)return!1;var h=o.get(e);if(h)return h==t;r|=2,o.set(e,t);var u=ts(a(e),a(t),r,n,s,o);return o.delete(e),u;case x:if(Ui)return Ui.call(e)==Ui.call(t)}return!1}(e,t,h,r,n,s,o);if(!(1&r)){var d=l&&$e.call(e,"__wrapped__"),g=p&&$e.call(t,"__wrapped__");if(d||g){var b=d?e.value():e,E=g?t.value():t;return o||(o=new Gi),s(b,E,r,n,o)}}return!!f&&(o||(o=new Gi),function(e,t,r,n,s,o){var a=1&r,c=rs(e),h=c.length,u=rs(t).length;if(h!=u&&!a)return!1;for(var l=h;l--;){var p=c[l];if(!(a?p in t:$e.call(t,p)))return!1}var f=o.get(e),d=o.get(t);if(f&&d)return f==t&&d==e;var g=!0;o.set(e,t),o.set(t,e);for(var y=a;++l<h;){var v=e[p=c[l]],m=t[p];if(n)var w=a?n(m,v,p,t,e,o):n(v,m,p,e,t,o);if(!(w===i?v===m||s(v,m,r,n,o):w)){g=!1;break}y||(y="constructor"==p)}if(g&&!y){var _=e.constructor,b=t.constructor;_!=b&&"constructor"in e&&"constructor"in t&&!("function"==typeof _&&_ instanceof _&&"function"==typeof b&&b instanceof b)&&(g=!1)}return o.delete(e),o.delete(t),g}(e,t,r,n,s,o))}(e,t,r,n,Ar,s))}function Tr(e,t,r,n){var s=r.length,o=s,a=!n;if(null==e)return!o;for(e=Oe(e);s--;){var c=r[s];if(a&&c[2]?c[1]!==e[c[0]]:!(c[0]in e))return!1}for(;++s<o;){var h=(c=r[s])[0],u=e[h],l=c[1];if(a&&c[2]){if(u===i&&!(h in e))return!1}else{var p=new Gi;if(n)var f=n(u,l,h,e,t,p);if(!(f===i?Ar(l,u,3,n,p):f))return!1}}return!0}function Dr(e){return!(!ta(e)||function(e){return!!Ue&&Ue in e}(e))&&(Qo(e)?ke:ye).test(Ms(e))}function jr(e){return"function"==typeof e?e:null==e?nc:"object"==typeof e?Bo(e)?zr(e[0],e[1]):Lr(e):fc(e)}function $r(e){if(!Is(e))return yi(e);var t=[];for(var i in Oe(e))$e.call(e,i)&&"constructor"!=i&&t.push(i);return t}function qr(e){if(!ta(e))return function(e){var t=[];if(null!=e)for(var i in Oe(e))t.push(i);return t}(e);var t=Is(e),i=[];for(var r in e)"constructor"==r&&(t||!$e.call(e,r))||i.push(r);return i}function Ur(e,t){return e<t}function Mr(e,t){var i=-1,r=Fo(e)?se(e.length):[];return lr(e,(function(e,n,s){r[++i]=t(e,n,s)})),r}function Lr(e){var t=us(e);return 1==t.length&&t[0][2]?Ss(t[0][0],t[0][1]):function(i){return i===e||Tr(i,e,t)}}function zr(e,t){return _s(e)&&Ps(t)?Ss(Us(e),t):function(r){var n=Ra(r,e);return n===i&&n===t?Na(r,e):Ar(t,n,3)}}function kr(e,t,r,n,s){e!==t&&vr(t,(function(o,a){if(s||(s=new Gi),ta(o))!function(e,t,r,n,s,o,a){var c=Cs(e,r),h=Cs(t,r),u=a.get(h);if(u)return void Xi(e,r,u);var l=o?o(c,h,r+"",e,t,a):i,p=l===i;if(p){var f=Bo(h),d=!f&&Jo(h),g=!f&&!d&&ua(h);l=h,f||d||g?Bo(c)?l=c:Go(c)?l=Cn(c):d?(p=!1,l=In(h,!0)):g?(p=!1,l=Sn(h,!0)):l=[]:sa(h)||Ho(h)?(l=c,Ho(c)?l=ma(c):(!ta(c)||Qo(c))&&(l=ys(h))):p=!1}p&&(a.set(h,l),s(l,h,n,o,a),a.delete(h)),Xi(e,r,l)}(e,t,a,r,kr,n,s);else{var c=n?n(Cs(e,a),o,a+"",e,t,s):i;c===i&&(c=o),Xi(e,a,c)}}),Da)}function Vr(e,t){var r=e.length;if(r)return ms(t+=t<0?r:0,r)?e[t]:i}function Kr(e,t,i){t=t.length?Dt(t,(function(e){return Bo(e)?function(t){return Er(t,1===e.length?e[0]:e)}:e})):[nc];var r=-1;t=Dt(t,Zt(cs()));var n=Mr(e,(function(e,i,n){var s=Dt(t,(function(t){return t(e)}));return{criteria:s,index:++r,value:e}}));return function(e,t){var i=e.length;for(e.sort(t);i--;)e[i]=e[i].value;return e}(n,(function(e,t){return function(e,t,i){for(var r=-1,n=e.criteria,s=t.criteria,o=n.length,a=i.length;++r<o;){var c=On(n[r],s[r]);if(c)return r>=a?c:c*("desc"==i[r]?-1:1)}return e.index-t.index}(e,t,i)}))}function Hr(e,t,i){for(var r=-1,n=t.length,s={};++r<n;){var o=t[r],a=Er(e,o);i(a,o)&&Qr(s,wn(o,e),a)}return s}function Br(e,t,i,r){var n=r?Vt:kt,s=-1,o=t.length,a=e;for(e===t&&(t=Cn(t)),i&&(a=Dt(e,Zt(i)));++s<o;)for(var c=0,h=t[s],u=i?i(h):h;(c=n(a,u,c,r))>-1;)a!==e&&Je.call(a,c,1),Je.call(e,c,1);return e}function Wr(e,t){for(var i=e?t.length:0,r=i-1;i--;){var n=t[i];if(i==r||n!==s){var s=n;ms(n)?Je.call(e,n,1):ln(e,n)}}return e}function Fr(e,t){return e+gt(bi()*(t-e+1))}function Gr(e,t){var i="";if(!e||t<1||t>p)return i;do{t%2&&(i+=e),(t=gt(t/2))&&(e+=e)}while(t);return i}function Jr(e,t){return Ts(Os(e,t,nc),e+"")}function Yr(e){return Yi(ka(e))}function Zr(e,t){var i=ka(e);return $s(i,or(t,0,i.length))}function Qr(e,t,r,n){if(!ta(e))return e;for(var s=-1,o=(t=wn(t,e)).length,a=o-1,c=e;null!=c&&++s<o;){var h=Us(t[s]),u=r;if("__proto__"===h||"constructor"===h||"prototype"===h)return e;if(s!=a){var l=c[h];(u=n?n(l,h,c):i)===i&&(u=ta(l)?l:ms(t[s+1])?[]:{})}er(c,h,u),c=c[h]}return e}var Xr=Ci?function(e,t){return Ci.set(e,t),e}:nc,en=it?function(e,t){return it(e,"toString",{configurable:!0,enumerable:!1,value:tc(t),writable:!0})}:nc;function tn(e){return $s(ka(e))}function rn(e,t,i){var r=-1,n=e.length;t<0&&(t=-t>n?0:n+t),(i=i>n?n:i)<0&&(i+=n),n=t>i?0:i-t>>>0,t>>>=0;for(var s=se(n);++r<n;)s[r]=e[r+t];return s}function nn(e,t){var i;return lr(e,(function(e,r,n){return!(i=t(e,r,n))})),!!i}function sn(e,t,i){var r=0,n=null==e?r:e.length;if("number"==typeof t&&t===t&&n<=2147483647){for(;r<n;){var s=r+n>>>1,o=e[s];null!==o&&!ha(o)&&(i?o<=t:o<t)?r=s+1:n=s}return n}return on(e,t,nc,i)}function on(e,t,r,n){var s=0,o=null==e?0:e.length;if(0===o)return 0;for(var a=(t=r(t))!==t,c=null===t,h=ha(t),u=t===i;s<o;){var l=gt((s+o)/2),p=r(e[l]),f=p!==i,d=null===p,g=p===p,y=ha(p);if(a)var v=n||g;else v=u?g&&(n||f):c?g&&f&&(n||!d):h?g&&f&&!d&&(n||!y):!d&&!y&&(n?p<=t:p<t);v?s=l+1:o=l}return mi(o,4294967294)}function an(e,t){for(var i=-1,r=e.length,n=0,s=[];++i<r;){var o=e[i],a=t?t(o):o;if(!i||!ko(a,c)){var c=a;s[n++]=0===o?0:o}}return s}function cn(e){return"number"==typeof e?e:ha(e)?f:+e}function hn(e){if("string"==typeof e)return e;if(Bo(e))return Dt(e,hn)+"";if(ha(e))return Mi?Mi.call(e):"";var t=e+"";return"0"==t&&1/e==-l?"-0":t}function un(e,t,i){var r=-1,n=At,s=e.length,o=!0,a=[],c=a;if(i)o=!1,n=Tt;else if(s>=200){var h=t?null:Jn(e);if(h)return ui(h);o=!1,n=Xt,c=new Fi}else c=t?[]:a;e:for(;++r<s;){var u=e[r],l=t?t(u):u;if(u=i||0!==u?u:0,o&&l===l){for(var p=c.length;p--;)if(c[p]===l)continue e;t&&c.push(l),a.push(u)}else n(c,l,i)||(c!==a&&c.push(l),a.push(u))}return a}function ln(e,t){return null==(e=Rs(e,t=wn(t,e)))||delete e[Us(Ys(t))]}function pn(e,t,i,r){return Qr(e,t,i(Er(e,t)),r)}function fn(e,t,i,r){for(var n=e.length,s=r?n:-1;(r?s--:++s<n)&&t(e[s],s,e););return i?rn(e,r?0:s,r?s+1:n):rn(e,r?s+1:0,r?n:s)}function dn(e,t){var i=e;return i instanceof Ki&&(i=i.value()),$t(t,(function(e,t){return t.func.apply(t.thisArg,jt([e],t.args))}),i)}function gn(e,t,i){var r=e.length;if(r<2)return r?un(e[0]):[];for(var n=-1,s=se(r);++n<r;)for(var o=e[n],a=-1;++a<r;)a!=n&&(s[n]=ur(s[n]||o,e[a],t,i));return un(yr(s,1),t,i)}function yn(e,t,r){for(var n=-1,s=e.length,o=t.length,a={};++n<s;){var c=n<o?t[n]:i;r(a,e[n],c)}return a}function vn(e){return Go(e)?e:[]}function mn(e){return"function"==typeof e?e:nc}function wn(e,t){return Bo(e)?e:_s(e,t)?[e]:qs(wa(e))}var _n=Jr;function bn(e,t,r){var n=e.length;return r=r===i?n:r,!t&&r>=n?e:rn(e,t,r)}var En=ct||function(e){return ft.clearTimeout(e)};function In(e,t){if(t)return e.slice();var i=e.length,r=Be?Be(i):new e.constructor(i);return e.copy(r),r}function Pn(e){var t=new e.constructor(e.byteLength);return new He(t).set(new He(e)),t}function Sn(e,t){var i=t?Pn(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)}function On(e,t){if(e!==t){var r=e!==i,n=null===e,s=e===e,o=ha(e),a=t!==i,c=null===t,h=t===t,u=ha(t);if(!c&&!u&&!o&&e>t||o&&a&&h&&!c&&!u||n&&a&&h||!r&&h||!s)return 1;if(!n&&!o&&!u&&e<t||u&&r&&s&&!n&&!o||c&&r&&s||!a&&s||!h)return-1}return 0}function Rn(e,t,i,r){for(var n=-1,s=e.length,o=i.length,a=-1,c=t.length,h=vi(s-o,0),u=se(c+h),l=!r;++a<c;)u[a]=t[a];for(;++n<o;)(l||n<s)&&(u[i[n]]=e[n]);for(;h--;)u[a++]=e[n++];return u}function Nn(e,t,i,r){for(var n=-1,s=e.length,o=-1,a=i.length,c=-1,h=t.length,u=vi(s-a,0),l=se(u+h),p=!r;++n<u;)l[n]=e[n];for(var f=n;++c<h;)l[f+c]=t[c];for(;++o<a;)(p||n<s)&&(l[f+i[o]]=e[n++]);return l}function Cn(e,t){var i=-1,r=e.length;for(t||(t=se(r));++i<r;)t[i]=e[i];return t}function xn(e,t,r,n){var s=!r;r||(r={});for(var o=-1,a=t.length;++o<a;){var c=t[o],h=n?n(r[c],e[c],c,r,e):i;h===i&&(h=e[c]),s?nr(r,c,h):er(r,c,h)}return r}function An(e,t){return function(i,r){var n=Bo(i)?Ot:ir,s=t?t():{};return n(i,e,cs(r,2),s)}}function Tn(e){return Jr((function(t,r){var n=-1,s=r.length,o=s>1?r[s-1]:i,a=s>2?r[2]:i;for(o=e.length>3&&"function"==typeof o?(s--,o):i,a&&ws(r[0],r[1],a)&&(o=s<3?i:o,s=1),t=Oe(t);++n<s;){var c=r[n];c&&e(t,c,n,o)}return t}))}function Dn(e,t){return function(i,r){if(null==i)return i;if(!Fo(i))return e(i,r);for(var n=i.length,s=t?n:-1,o=Oe(i);(t?s--:++s<n)&&!1!==r(o[s],s,o););return i}}function jn(e){return function(t,i,r){for(var n=-1,s=Oe(t),o=r(t),a=o.length;a--;){var c=o[e?a:++n];if(!1===i(s[c],c,s))break}return t}}function $n(e){return function(t){var r=oi(t=wa(t))?pi(t):i,n=r?r[0]:t.charAt(0),s=r?bn(r,1).join(""):t.slice(1);return n[e]()+s}}function qn(e){return function(t){return $t(Qa(Ha(t).replace(Qe,"")),e,"")}}function Un(e){return function(){var t=arguments;switch(t.length){case 0:return new e;case 1:return new e(t[0]);case 2:return new e(t[0],t[1]);case 3:return new e(t[0],t[1],t[2]);case 4:return new e(t[0],t[1],t[2],t[3]);case 5:return new e(t[0],t[1],t[2],t[3],t[4]);case 6:return new e(t[0],t[1],t[2],t[3],t[4],t[5]);case 7:return new e(t[0],t[1],t[2],t[3],t[4],t[5],t[6])}var i=zi(e.prototype),r=e.apply(i,t);return ta(r)?r:i}}function Mn(e){return function(t,r,n){var s=Oe(t);if(!Fo(t)){var o=cs(r,3);t=Ta(t),r=function(e){return o(s[e],e,s)}}var a=e(t,r,n);return a>-1?s[o?t[a]:a]:i}}function Ln(e){return is((function(t){var n=t.length,s=n,o=Vi.prototype.thru;for(e&&t.reverse();s--;){var a=t[s];if("function"!=typeof a)throw new Ce(r);if(o&&!c&&"wrapper"==os(a))var c=new Vi([],!0)}for(s=c?s:n;++s<n;){var h=os(a=t[s]),u="wrapper"==h?ss(a):i;c=u&&bs(u[0])&&424==u[1]&&!u[4].length&&1==u[9]?c[os(u[0])].apply(c,u[3]):1==a.length&&bs(a)?c[h]():c.thru(a)}return function(){var e=arguments,i=e[0];if(c&&1==e.length&&Bo(i))return c.plant(i).value();for(var r=0,s=n?t[r].apply(this,e):i;++r<n;)s=t[r].call(this,s);return s}}))}function zn(e,t,r,n,s,o,a,c,u,l){var p=t&h,f=1&t,d=2&t,g=24&t,y=512&t,v=d?i:Un(e);return function i(){for(var h=arguments.length,m=se(h),w=h;w--;)m[w]=arguments[w];if(g)var _=as(i),b=ii(m,_);if(n&&(m=Rn(m,n,s,g)),o&&(m=Nn(m,o,a,g)),h-=b,g&&h<l){var E=hi(m,_);return Fn(e,t,zn,i.placeholder,r,m,E,c,u,l-h)}var I=f?r:this,P=d?I[e]:e;return h=m.length,c?m=Ns(m,c):y&&h>1&&m.reverse(),p&&u<h&&(m.length=u),this&&this!==ft&&this instanceof i&&(P=v||Un(P)),P.apply(I,m)}}function kn(e,t){return function(i,r){return function(e,t,i,r){return wr(e,(function(e,n,s){t(r,i(e),n,s)})),r}(i,e,t(r),{})}}function Vn(e,t){return function(r,n){var s;if(r===i&&n===i)return t;if(r!==i&&(s=r),n!==i){if(s===i)return n;"string"==typeof r||"string"==typeof n?(r=hn(r),n=hn(n)):(r=cn(r),n=cn(n)),s=e(r,n)}return s}}function Kn(e){return is((function(t){return t=Dt(t,Zt(cs())),Jr((function(i){var r=this;return e(t,(function(e){return St(e,r,i)}))}))}))}function Hn(e,t){var r=(t=t===i?" ":hn(t)).length;if(r<2)return r?Gr(t,e):t;var n=Gr(t,dt(e/li(t)));return oi(t)?bn(pi(n),0,e).join(""):n.slice(0,e)}function Bn(e){return function(t,r,n){return n&&"number"!=typeof n&&ws(t,r,n)&&(r=n=i),t=da(t),r===i?(r=t,t=0):r=da(r),function(e,t,i,r){for(var n=-1,s=vi(dt((t-e)/(i||1)),0),o=se(s);s--;)o[r?s:++n]=e,e+=i;return o}(t,r,n=n===i?t<r?1:-1:da(n),e)}}function Wn(e){return function(t,i){return"string"==typeof t&&"string"==typeof i||(t=va(t),i=va(i)),e(t,i)}}function Fn(e,t,r,n,s,o,h,u,l,p){var f=8&t;t|=f?a:c,4&(t&=~(f?c:a))||(t&=-4);var d=[e,t,s,f?o:i,f?h:i,f?i:o,f?i:h,u,l,p],g=r.apply(i,d);return bs(e)&&xs(g,d),g.placeholder=n,Ds(g,e,t)}function Gn(e){var t=Se[e];return function(e,i){if(e=va(e),(i=null==i?0:mi(ga(i),292))&&Mt(e)){var r=(wa(e)+"e").split("e");return+((r=(wa(t(r[0]+"e"+(+r[1]+i)))+"e").split("e"))[0]+"e"+(+r[1]-i))}return t(e)}}var Jn=Oi&&1/ui(new Oi([,-0]))[1]==l?function(e){return new Oi(e)}:hc;function Yn(e){return function(t){var i=ds(t);return i==I?ai(t):i==N?function(e){var t=-1,i=Array(e.size);return e.forEach((function(e){i[++t]=[e,e]})),i}(t):function(e,t){return Dt(t,(function(t){return[t,e[t]]}))}(t,e(t))}}function Zn(e,t,n,l,p,f,d,g){var y=2&t;if(!y&&"function"!=typeof e)throw new Ce(r);var v=l?l.length:0;if(v||(t&=-97,l=p=i),d=d===i?d:vi(ga(d),0),g=g===i?g:ga(g),v-=p?p.length:0,t&c){var m=l,w=p;l=p=i}var _=y?i:ss(e),b=[e,t,n,l,p,m,w,f,d,g];if(_&&function(e,t){var i=e[1],r=t[1],n=i|r,o=n<131,a=r==h&&8==i||r==h&&i==u&&e[7].length<=t[8]||384==r&&t[7].length<=t[8]&&8==i;if(!o&&!a)return e;1&r&&(e[2]=t[2],n|=1&i?0:4);var c=t[3];if(c){var l=e[3];e[3]=l?Rn(l,c,t[4]):c,e[4]=l?hi(e[3],s):t[4]}(c=t[5])&&(l=e[5],e[5]=l?Nn(l,c,t[6]):c,e[6]=l?hi(e[5],s):t[6]),(c=t[7])&&(e[7]=c),r&h&&(e[8]=null==e[8]?t[8]:mi(e[8],t[8])),null==e[9]&&(e[9]=t[9]),e[0]=t[0],e[1]=n}(b,_),e=b[0],t=b[1],n=b[2],l=b[3],p=b[4],!(g=b[9]=b[9]===i?y?0:e.length:vi(b[9]-v,0))&&24&t&&(t&=-25),t&&1!=t)E=8==t||t==o?function(e,t,r){var n=Un(e);return function s(){for(var o=arguments.length,a=se(o),c=o,h=as(s);c--;)a[c]=arguments[c];var u=o<3&&a[0]!==h&&a[o-1]!==h?[]:hi(a,h);return(o-=u.length)<r?Fn(e,t,zn,s.placeholder,i,a,u,i,i,r-o):St(this&&this!==ft&&this instanceof s?n:e,this,a)}}(e,t,g):t!=a&&33!=t||p.length?zn.apply(i,b):function(e,t,i,r){var n=1&t,s=Un(e);return function t(){for(var o=-1,a=arguments.length,c=-1,h=r.length,u=se(h+a),l=this&&this!==ft&&this instanceof t?s:e;++c<h;)u[c]=r[c];for(;a--;)u[c++]=arguments[++o];return St(l,n?i:this,u)}}(e,t,n,l);else var E=function(e,t,i){var r=1&t,n=Un(e);return function t(){return(this&&this!==ft&&this instanceof t?n:e).apply(r?i:this,arguments)}}
vendor: 16,102 bytes, line 1
1(e,t,n);return Ds((_?Xr:xs)(E,b),e,t)}function Qn(e,t,r,n){return e===i||ko(e,Te[r])&&!$e.call(n,r)?t:e}function Xn(e,t,r,n,s,o){return ta(e)&&ta(t)&&(o.set(t,e),kr(e,t,i,Xn,o),o.delete(t)),e}function es(e){return sa(e)?i:e}function ts(e,t,r,n,s,o){var a=1&r,c=e.length,h=t.length;if(c!=h&&!(a&&h>c))return!1;var u=o.get(e),l=o.get(t);if(u&&l)return u==t&&l==e;var p=-1,f=!0,d=2&r?new Fi:i;for(o.set(e,t),o.set(t,e);++p<c;){var g=e[p],y=t[p];if(n)var v=a?n(y,g,p,t,e,o):n(g,y,p,e,t,o);if(v!==i){if(v)continue;f=!1;break}if(d){if(!Ut(t,(function(e,t){if(!Xt(d,t)&&(g===e||s(g,e,r,n,o)))return d.push(t)}))){f=!1;break}}else if(g!==y&&!s(g,y,r,n,o)){f=!1;break}}return o.delete(e),o.delete(t),f}function is(e){return Ts(Os(e,i,Bs),e+"")}function rs(e){return Ir(e,Ta,ps)}function ns(e){return Ir(e,Da,fs)}var ss=Ci?function(e){return Ci.get(e)}:hc;function os(e){for(var t=e.name+"",i=xi[t],r=$e.call(xi,t)?i.length:0;r--;){var n=i[r],s=n.func;if(null==s||s==e)return n.name}return t}function as(e){return($e.call(Li,"placeholder")?Li:e).placeholder}function cs(){var e=Li.iteratee||sc;return e=e===sc?jr:e,arguments.length?e(arguments[0],arguments[1]):e}function hs(e,t){var i=e.__data__;return function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e}(t)?i["string"==typeof t?"string":"hash"]:i.map}function us(e){for(var t=Ta(e),i=t.length;i--;){var r=t[i],n=e[r];t[i]=[r,n,Ps(n)]}return t}function ls(e,t){var r=function(e,t){return null==e?i:e[t]}(e,t);return Dr(r)?r:i}var ps=vt?function(e){return null==e?[]:(e=Oe(e),xt(vt(e),(function(t){return Ge.call(e,t)})))}:yc,fs=vt?function(e){for(var t=[];e;)jt(t,ps(e)),e=We(e);return t}:yc,ds=Pr;function gs(e,t,i){for(var r=-1,n=(t=wn(t,e)).length,s=!1;++r<n;){var o=Us(t[r]);if(!(s=null!=e&&i(e,o)))break;e=e[o]}return s||++r!=n?s:!!(n=null==e?0:e.length)&&ea(n)&&ms(o,n)&&(Bo(e)||Ho(e))}function ys(e){return"function"!=typeof e.constructor||Is(e)?{}:zi(We(e))}function vs(e){return Bo(e)||Ho(e)||!!(Ye&&e&&e[Ye])}function ms(e,t){var i=typeof e;return!!(t=t??p)&&("number"==i||"symbol"!=i&&me.test(e))&&e>-1&&e%1==0&&e<t}function ws(e,t,i){if(!ta(i))return!1;var r=typeof t;return!!("number"==r?Fo(i)&&ms(t,i.length):"string"==r&&t in i)&&ko(i[t],e)}function _s(e,t){if(Bo(e))return!1;var i=typeof e;return!("number"!=i&&"symbol"!=i&&"boolean"!=i&&null!=e&&!ha(e))||(ee.test(e)||!X.test(e)||null!=t&&e in Oe(t))}function bs(e){var t=os(e),i=Li[t];if("function"!=typeof i||!(t in Ki.prototype))return!1;if(e===i)return!0;var r=ss(i);return!!r&&e===r[0]}(Ii&&ds(new Ii(new ArrayBuffer(1)))!=D||Pi&&ds(new Pi)!=I||Si&&ds(Si.resolve())!=O||Oi&&ds(new Oi)!=N||Ri&&ds(new Ri)!=A)&&(ds=function(e){var t=Pr(e),r=t==S?e.constructor:i,n=r?Ms(r):"";if(n)switch(n){case Ai:return D;case Ti:return I;case Di:return O;case ji:return N;case $i:return A}return t});var Es=De?Qo:vc;function Is(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||Te)}function Ps(e){return e===e&&!ta(e)}function Ss(e,t){return function(r){return null!=r&&(r[e]===t&&(t!==i||e in Oe(r)))}}function Os(e,t,r){return t=vi(t===i?e.length-1:t,0),function(){for(var i=arguments,n=-1,s=vi(i.length-t,0),o=se(s);++n<s;)o[n]=i[t+n];n=-1;for(var a=se(t+1);++n<t;)a[n]=i[n];return a[t]=r(o),St(e,this,a)}}function Rs(e,t){return t.length<2?e:Er(e,rn(t,0,-1))}function Ns(e,t){for(var r=e.length,n=mi(t.length,r),s=Cn(e);n--;){var o=t[n];e[n]=ms(o,r)?s[o]:i}return e}function Cs(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]}var xs=js(Xr),As=pt||function(e,t){return ft.setTimeout(e,t)},Ts=js(en);function Ds(e,t,i){var r=t+"";return Ts(e,function(e,t){var i=t.length;if(!i)return e;var r=i-1;return t[r]=(i>1?"& ":"")+t[r],t=t.join(i>2?", ":" "),e.replace(oe,"{\n/* [wrapped with "+t+"] */\n")}(r,function(e,t){return Rt(g,(function(i){var r="_."+i[0];t&i[1]&&!At(e,r)&&e.push(r)})),e.sort()}(function(e){var t=e.match(ae);return t?t[1].split(ce):[]}(r),i)))}function js(e){var t=0,r=0;return function(){var n=wi(),s=16-(n-r);if(r=n,s>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(i,arguments)}}function $s(e,t){var r=-1,n=e.length,s=n-1;for(t=t===i?n:t;++r<t;){var o=Fr(r,s),a=e[o];e[o]=e[r],e[r]=a}return e.length=t,e}var qs=function(e){var t=$o(e,(function(e){return 500===i.size&&i.clear(),e})),i=t.cache;return t}((function(e){var t=[];return 46===e.charCodeAt(0)&&t.push(""),e.replace(te,(function(e,i,r,n){t.push(r?n.replace(le,"$1"):i||e)})),t}));function Us(e){if("string"==typeof e||ha(e))return e;var t=e+"";return"0"==t&&1/e==-l?"-0":t}function Ms(e){if(null!=e){try{return je.call(e)}catch{}try{return e+""}catch{}}return""}function Ls(e){if(e instanceof Ki)return e.clone();var t=new Vi(e.__wrapped__,e.__chain__);return t.__actions__=Cn(e.__actions__),t.__index__=e.__index__,t.__values__=e.__values__,t}var zs=Jr((function(e,t){return Go(e)?ur(e,yr(t,1,Go,!0)):[]})),ks=Jr((function(e,t){var r=Ys(t);return Go(r)&&(r=i),Go(e)?ur(e,yr(t,1,Go,!0),cs(r,2)):[]})),Vs=Jr((function(e,t){var r=Ys(t);return Go(r)&&(r=i),Go(e)?ur(e,yr(t,1,Go,!0),i,r):[]}));function Ks(e,t,i){var r=null==e?0:e.length;if(!r)return-1;var n=null==i?0:ga(i);return n<0&&(n=vi(r+n,0)),zt(e,cs(t,3),n)}function Hs(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var s=n-1;return r!==i&&(s=ga(r),s=r<0?vi(n+s,0):mi(s,n-1)),zt(e,cs(t,3),s,!0)}function Bs(e){return(null==e?0:e.length)?yr(e,1):[]}function Ws(e){return e&&e.length?e[0]:i}var Fs=Jr((function(e){var t=Dt(e,vn);return t.length&&t[0]===e[0]?Nr(t):[]})),Gs=Jr((function(e){var t=Ys(e),r=Dt(e,vn);return t===Ys(r)?t=i:r.pop(),r.length&&r[0]===e[0]?Nr(r,cs(t,2)):[]})),Js=Jr((function(e){var t=Ys(e),r=Dt(e,vn);return(t="function"==typeof t?t:i)&&r.pop(),r.length&&r[0]===e[0]?Nr(r,i,t):[]}));function Ys(e){var t=null==e?0:e.length;return t?e[t-1]:i}var Zs=Jr(Qs);function Qs(e,t){return e&&e.length&&t&&t.length?Br(e,t):e}var Xs=is((function(e,t){var i=null==e?0:e.length,r=sr(e,t);return Wr(e,Dt(t,(function(e){return ms(e,i)?+e:e})).sort(On)),r}));function eo(e){return null==e?e:Ei.call(e)}var to=Jr((function(e){return un(yr(e,1,Go,!0))})),io=Jr((function(e){var t=Ys(e);return Go(t)&&(t=i),un(yr(e,1,Go,!0),cs(t,2))})),ro=Jr((function(e){var t=Ys(e);return t="function"==typeof t?t:i,un(yr(e,1,Go,!0),i,t)}));function no(e){if(!e||!e.length)return[];var t=0;return e=xt(e,(function(e){if(Go(e))return t=vi(e.length,t),!0})),Jt(t,(function(t){return Dt(e,Bt(t))}))}function so(e,t){if(!e||!e.length)return[];var r=no(e);return null==t?r:Dt(r,(function(e){return St(t,i,e)}))}var oo=Jr((function(e,t){return Go(e)?ur(e,t):[]})),ao=Jr((function(e){return gn(xt(e,Go))})),co=Jr((function(e){var t=Ys(e);return Go(t)&&(t=i),gn(xt(e,Go),cs(t,2))})),ho=Jr((function(e){var t=Ys(e);return t="function"==typeof t?t:i,gn(xt(e,Go),i,t)})),uo=Jr(no);var lo=Jr((function(e){var t=e.length,r=t>1?e[t-1]:i;return r="function"==typeof r?(e.pop(),r):i,so(e,r)}));function po(e){var t=Li(e);return t.__chain__=!0,t}function fo(e,t){return t(e)}var go=is((function(e){var t=e.length,r=t?e[0]:0,n=this.__wrapped__,s=function(t){return sr(t,e)};return!(t>1||this.__actions__.length)&&n instanceof Ki&&ms(r)?((n=n.slice(r,+r+(t?1:0))).__actions__.push({func:fo,args:[s],thisArg:i}),new Vi(n,this.__chain__).thru((function(e){return t&&!e.length&&e.push(i),e}))):this.thru(s)}));var yo=An((function(e,t,i){$e.call(e,i)?++e[i]:nr(e,i,1)}));var vo=Mn(Ks),mo=Mn(Hs);function wo(e,t){return(Bo(e)?Rt:lr)(e,cs(t,3))}function _o(e,t){return(Bo(e)?Nt:pr)(e,cs(t,3))}var bo=An((function(e,t,i){$e.call(e,i)?e[i].push(t):nr(e,i,[t])}));var Eo=Jr((function(e,t,i){var r=-1,n="function"==typeof t,s=Fo(e)?se(e.length):[];return lr(e,(function(e){s[++r]=n?St(t,e,i):Cr(e,t,i)})),s})),Io=An((function(e,t,i){nr(e,i,t)}));function Po(e,t){return(Bo(e)?Dt:Mr)(e,cs(t,3))}var So=An((function(e,t,i){e[i?0:1].push(t)}),(function(){return[[],[]]}));var Oo=Jr((function(e,t){if(null==e)return[];var i=t.length;return i>1&&ws(e,t[0],t[1])?t=[]:i>2&&ws(t[0],t[1],t[2])&&(t=[t[0]]),Kr(e,yr(t,1),[])})),Ro=lt||function(){return ft.Date.now()};function No(e,t,r){return t=r?i:t,t=e&&null==t?e.length:t,Zn(e,h,i,i,i,i,t)}function Co(e,t){var n;if("function"!=typeof t)throw new Ce(r);return e=ga(e),function(){return--e>0&&(n=t.apply(this,arguments)),e<=1&&(t=i),n}}var xo=Jr((function(e,t,i){var r=1;if(i.length){var n=hi(i,as(xo));r|=a}return Zn(e,r,t,i,n)})),Ao=Jr((function(e,t,i){var r=3;if(i.length){var n=hi(i,as(Ao));r|=a}return Zn(t,r,e,i,n)}));function To(e,t,n){var s,o,a,c,h,u,l=0,p=!1,f=!1,d=!0;if("function"!=typeof e)throw new Ce(r);function g(t){var r=s,n=o;return s=o=i,l=t,c=e.apply(n,r)}function y(e){return l=e,h=As(m,t),p?g(e):c}function v(e){var r=e-u;return u===i||r>=t||r<0||f&&e-l>=a}function m(){var e=Ro();if(v(e))return w(e);h=As(m,function(e){var i=t-(e-u);return f?mi(i,a-(e-l)):i}(e))}function w(e){return h=i,d&&s?g(e):(s=o=i,c)}function _(){var e=Ro(),r=v(e);if(s=arguments,o=this,u=e,r){if(h===i)return y(u);if(f)return En(h),h=As(m,t),g(u)}return h===i&&(h=As(m,t)),c}return t=va(t)||0,ta(n)&&(p=!!n.leading,a=(f="maxWait"in n)?vi(va(n.maxWait)||0,t):a,d="trailing"in n?!!n.trailing:d),_.cancel=function(){h!==i&&En(h),l=0,s=u=o=h=i},_.flush=function(){return h===i?c:w(Ro())},_}var Do=Jr((function(e,t){return hr(e,1,t)})),jo=Jr((function(e,t,i){return hr(e,va(t)||0,i)}));function $o(e,t){if("function"!=typeof e||null!=t&&"function"!=typeof t)throw new Ce(r);var i=function(){var r=arguments,n=t?t.apply(this,r):r[0],s=i.cache;if(s.has(n))return s.get(n);var o=e.apply(this,r);return i.cache=s.set(n,o)||s,o};return i.cache=new($o.Cache||Wi),i}function qo(e){if("function"!=typeof e)throw new Ce(r);return function(){var t=arguments;switch(t.length){case 0:return!e.call(this);case 1:return!e.call(this,t[0]);case 2:return!e.call(this,t[0],t[1]);case 3:return!e.call(this,t[0],t[1],t[2])}return!e.apply(this,t)}}$o.Cache=Wi;var Uo=_n((function(e,t){var i=(t=1==t.length&&Bo(t[0])?Dt(t[0],Zt(cs())):Dt(yr(t,1),Zt(cs()))).length;return Jr((function(r){for(var n=-1,s=mi(r.length,i);++n<s;)r[n]=t[n].call(this,r[n]);return St(e,this,r)}))})),Mo=Jr((function(e,t){var r=hi(t,as(Mo));return Zn(e,a,i,t,r)})),Lo=Jr((function(e,t){var r=hi(t,as(Lo));return Zn(e,c,i,t,r)})),zo=is((function(e,t){return Zn(e,u,i,i,i,t)}));function ko(e,t){return e===t||e!==e&&t!==t}var Vo=Wn(Sr),Ko=Wn((function(e,t){return e>=t})),Ho=xr(function(){return arguments}())?xr:function(e){return ia(e)&&$e.call(e,"callee")&&!Ge.call(e,"callee")},Bo=se.isArray,Wo=wt?Zt(wt):function(e){return ia(e)&&Pr(e)==T};function Fo(e){return null!=e&&ea(e.length)&&!Qo(e)}function Go(e){return ia(e)&&Fo(e)}var Jo=mt||vc,Yo=_t?Zt(_t):function(e){return ia(e)&&Pr(e)==w};function Zo(e){if(!ia(e))return!1;var t=Pr(e);return t==_||"[object DOMException]"==t||"string"==typeof e.message&&"string"==typeof e.name&&!sa(e)}function Qo(e){if(!ta(e))return!1;var t=Pr(e);return t==b||t==E||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Xo(e){return"number"==typeof e&&e==ga(e)}function ea(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=p}function ta(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function ia(e){return null!=e&&"object"==typeof e}var ra=bt?Zt(bt):function(e){return ia(e)&&ds(e)==I};function na(e){return"number"==typeof e||ia(e)&&Pr(e)==P}function sa(e){if(!ia(e)||Pr(e)!=S)return!1;var t=We(e);if(null===t)return!0;var i=$e.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&je.call(i)==Le}var oa=Et?Zt(Et):function(e){return ia(e)&&Pr(e)==R};var aa=It?Zt(It):function(e){return ia(e)&&ds(e)==N};function ca(e){return"string"==typeof e||!Bo(e)&&ia(e)&&Pr(e)==C}function ha(e){return"symbol"==typeof e||ia(e)&&Pr(e)==x}var ua=Pt?Zt(Pt):function(e){return ia(e)&&ea(e.length)&&!!ot[Pr(e)]};var la=Wn(Ur),pa=Wn((function(e,t){return e<=t}));function fa(e){if(!e)return[];if(Fo(e))return ca(e)?pi(e):Cn(e);if(Ze&&e[Ze])return function(e){for(var t,i=[];!(t=e.next()).done;)i.push(t.value);return i}(e[Ze]());var t=ds(e);return(t==I?ai:t==N?ui:ka)(e)}function da(e){return e?(e=va(e))===l||e===-l?17976931348623157e292*(e<0?-1:1):e===e?e:0:0===e?e:0}function ga(e){var t=da(e),i=t%1;return t===t?i?t-i:t:0}function ya(e){return e?or(ga(e),0,d):0}function va(e){if("number"==typeof e)return e;if(ha(e))return f;if(ta(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=ta(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=Yt(e);var i=ge.test(e);return i||ve.test(e)?ut(e.slice(2),i?2:8):de.test(e)?f:+e}function ma(e){return xn(e,Da(e))}function wa(e){return null==e?"":hn(e)}var _a=Tn((function(e,t){if(Is(t)||Fo(t))xn(t,Ta(t),e);else for(var i in t)$e.call(t,i)&&er(e,i,t[i])})),ba=Tn((function(e,t){xn(t,Da(t),e)})),Ea=Tn((function(e,t,i,r){xn(t,Da(t),e,r)})),Ia=Tn((function(e,t,i,r){xn(t,Ta(t),e,r)})),Pa=is(sr);var Sa=Jr((function(e,t){e=Oe(e);var r=-1,n=t.length,s=n>2?t[2]:i;for(s&&ws(t[0],t[1],s)&&(n=1);++r<n;)for(var o=t[r],a=Da(o),c=-1,h=a.length;++c<h;){var u=a[c],l=e[u];(l===i||ko(l,Te[u])&&!$e.call(e,u))&&(e[u]=o[u])}return e})),Oa=Jr((function(e){return e.push(i,Xn),St($a,i,e)}));function Ra(e,t,r){var n=null==e?i:Er(e,t);return n===i?r:n}function Na(e,t){return null!=e&&gs(e,t,Rr)}var Ca=kn((function(e,t,i){null!=t&&"function"!=typeof t.toString&&(t=Me.call(t)),e[t]=i}),tc(nc)),xa=kn((function(e,t,i){null!=t&&"function"!=typeof t.toString&&(t=Me.call(t)),$e.call(e,t)?e[t].push(i):e[t]=[i]}),cs),Aa=Jr(Cr);function Ta(e){return Fo(e)?Ji(e):$r(e)}function Da(e){return Fo(e)?Ji(e,!0):qr(e)}var ja=Tn((function(e,t,i){kr(e,t,i)})),$a=Tn((function(e,t,i,r){kr(e,t,i,r)})),qa=is((function(e,t){var i={};if(null==e)return i;var r=!1;t=Dt(t,(function(t){return t=wn(t,e),r||(r=t.length>1),t})),xn(e,ns(e),i),r&&(i=ar(i,7,es));for(var n=t.length;n--;)ln(i,t[n]);return i}));var Ua=is((function(e,t){return null==e?{}:function(e,t){return Hr(e,t,(function(t,i){return Na(e,i)}))}(e,t)}));function Ma(e,t){if(null==e)return{};var i=Dt(ns(e),(function(e){return[e]}));return t=cs(t),Hr(e,i,(function(e,i){return t(e,i[0])}))}var La=Yn(Ta),za=Yn(Da);function ka(e){return null==e?[]:Qt(e,Ta(e))}var Va=qn((function(e,t,i){return t=t.toLowerCase(),e+(i?Ka(t):t)}));function Ka(e){return Za(wa(e).toLowerCase())}function Ha(e){return(e=wa(e))&&e.replace(we,ri).replace(Xe,"")}var Ba=qn((function(e,t,i){return e+(i?"-":"")+t.toLowerCase()})),Wa=qn((function(e,t,i){return e+(i?" ":"")+t.toLowerCase()})),Fa=$n("toLowerCase");var Ga=qn((function(e,t,i){return e+(i?"_":"")+t.toLowerCase()}));var Ja=qn((function(e,t,i){return e+(i?" ":"")+Za(t)}));var Ya=qn((function(e,t,i){return e+(i?" ":"")+t.toUpperCase()})),Za=$n("toUpperCase");function Qa(e,t,r){return e=wa(e),(t=r?i:t)===i?function(e){return rt.test(e)}(e)?function(e){return e.match(tt)||[]}(e):function(e){return e.match(he)||[]}(e):e.match(t)||[]}var Xa=Jr((function(e,t){try{return St(e,i,t)}catch(r){return Zo(r)?r:new Ie(r)}})),ec=is((function(e,t){return Rt(t,(function(t){t=Us(t),nr(e,t,xo(e[t],e))})),e}));function tc(e){return function(){return e}}var ic=Ln(),rc=Ln(!0);function nc(e){return e}function sc(e){return jr("function"==typeof e?e:ar(e,1))}var oc=Jr((function(e,t){return function(i){return Cr(i,e,t)}})),ac=Jr((function(e,t){return function(i){return Cr(e,i,t)}}));function cc(e,t,i){var r=Ta(t),n=br(t,r);null==i&&(!ta(t)||!n.length&&r.length)&&(i=t,t=e,e=this,n=br(t,Ta(t)));var s=!(ta(i)&&"chain"in i)||!!i.chain,o=Qo(e);return Rt(n,(function(i){var r=t[i];e[i]=r,o&&(e.prototype[i]=function(){var t=this.__chain__;if(s||t){var i=e(this.__wrapped__),n=i.__actions__=Cn(this.__actions__);return n.push({func:r,args:arguments,thisArg:e}),i.__chain__=t,i}return r.apply(e,jt([this.value()],arguments))})})),e}function hc(){}var uc=Kn(Dt),lc=Kn(Ct),pc=Kn(Ut);function fc(e){return _s(e)?Bt(Us(e)):function(e){return function(t){return Er(t,e)}}(e)}var dc=Bn(),gc=Bn(!0);function yc(){return[]}function vc(){return!1}var mc=Vn((function(e,t){return e+t}),0),wc=Gn("ceil"),_c=Vn((function(e,t){return e/t}),1),bc=Gn("floor");var Ec=Vn((function(e,t){return e*t}),1),Ic=Gn("round"),Pc=Vn((function(e,t){return e-t}
vendor: 4,839 bytes, line 1
1),0);return Li.after=function(e,t){if("function"!=typeof t)throw new Ce(r);return e=ga(e),function(){if(--e<1)return t.apply(this,arguments)}},Li.ary=No,Li.assign=_a,Li.assignIn=ba,Li.assignInWith=Ea,Li.assignWith=Ia,Li.at=Pa,Li.before=Co,Li.bind=xo,Li.bindAll=ec,Li.bindKey=Ao,Li.castArray=function(){if(!arguments.length)return[];var e=arguments[0];return Bo(e)?e:[e]},Li.chain=po,Li.chunk=function(e,t,r){t=(r?ws(e,t,r):t===i)?1:vi(ga(t),0);var n=null==e?0:e.length;if(!n||t<1)return[];for(var s=0,o=0,a=se(dt(n/t));s<n;)a[o++]=rn(e,s,s+=t);return a},Li.compact=function(e){for(var t=-1,i=null==e?0:e.length,r=0,n=[];++t<i;){var s=e[t];s&&(n[r++]=s)}return n},Li.concat=function(){var e=arguments.length;if(!e)return[];for(var t=se(e-1),i=arguments[0],r=e;r--;)t[r-1]=arguments[r];return jt(Bo(i)?Cn(i):[i],yr(t,1))},Li.cond=function(e){var t=null==e?0:e.length,i=cs();return e=t?Dt(e,(function(e){if("function"!=typeof e[1])throw new Ce(r);return[i(e[0]),e[1]]})):[],Jr((function(i){for(var r=-1;++r<t;){var n=e[r];if(St(n[0],this,i))return St(n[1],this,i)}}))},Li.conforms=function(e){return function(e){var t=Ta(e);return function(i){return cr(i,e,t)}}(ar(e,1))},Li.constant=tc,Li.countBy=yo,Li.create=function(e,t){var i=zi(e);return null==t?i:rr(i,t)},Li.curry=function e(t,r,n){var s=Zn(t,8,i,i,i,i,i,r=n?i:r);return s.placeholder=e.placeholder,s},Li.curryRight=function e(t,r,n){var s=Zn(t,o,i,i,i,i,i,r=n?i:r);return s.placeholder=e.placeholder,s},Li.debounce=To,Li.defaults=Sa,Li.defaultsDeep=Oa,Li.defer=Do,Li.delay=jo,Li.difference=zs,Li.differenceBy=ks,Li.differenceWith=Vs,Li.drop=function(e,t,r){var n=null==e?0:e.length;return n?rn(e,(t=r||t===i?1:ga(t))<0?0:t,n):[]},Li.dropRight=function(e,t,r){var n=null==e?0:e.length;return n?rn(e,0,(t=n-(t=r||t===i?1:ga(t)))<0?0:t):[]},Li.dropRightWhile=function(e,t){return e&&e.length?fn(e,cs(t,3),!0,!0):[]},Li.dropWhile=function(e,t){return e&&e.length?fn(e,cs(t,3),!0):[]},Li.fill=function(e,t,r,n){var s=null==e?0:e.length;return s?(r&&"number"!=typeof r&&ws(e,t,r)&&(r=0,n=s),function(e,t,r,n){var s=e.length;for((r=ga(r))<0&&(r=-r>s?0:s+r),(n=n===i||n>s?s:ga(n))<0&&(n+=s),n=r>n?0:ya(n);r<n;)e[r++]=t;return e}(e,t,r,n)):[]},Li.filter=function(e,t){return(Bo(e)?xt:gr)(e,cs(t,3))},Li.flatMap=function(e,t){return yr(Po(e,t),1)},Li.flatMapDeep=function(e,t){return yr(Po(e,t),l)},Li.flatMapDepth=function(e,t,r){return r=r===i?1:ga(r),yr(Po(e,t),r)},Li.flatten=Bs,Li.flattenDeep=function(e){return(null==e?0:e.length)?yr(e,l):[]},Li.flattenDepth=function(e,t){return(null==e?0:e.length)?yr(e,t=t===i?1:ga(t)):[]},Li.flip=function(e){return Zn(e,512)},Li.flow=ic,Li.flowRight=rc,Li.fromPairs=function(e){for(var t=-1,i=null==e?0:e.length,r={};++t<i;){var n=e[t];r[n[0]]=n[1]}return r},Li.functions=function(e){return null==e?[]:br(e,Ta(e))},Li.functionsIn=function(e){return null==e?[]:br(e,Da(e))},Li.groupBy=bo,Li.initial=function(e){return(null==e?0:e.length)?rn(e,0,-1):[]},Li.intersection=Fs,Li.intersectionBy=Gs,Li.intersectionWith=Js,Li.invert=Ca,Li.invertBy=xa,Li.invokeMap=Eo,Li.iteratee=sc,Li.keyBy=Io,Li.keys=Ta,Li.keysIn=Da,Li.map=Po,Li.mapKeys=function(e,t){var i={};return t=cs(t,3),wr(e,(function(e,r,n){nr(i,t(e,r,n),e)})),i},Li.mapValues=function(e,t){var i={};return t=cs(t,3),wr(e,(function(e,r,n){nr(i,r,t(e,r,n))})),i},Li.matches=function(e){return Lr(ar(e,1))},Li.matchesProperty=function(e,t){return zr(e,ar(t,1))},Li.memoize=$o,Li.merge=ja,Li.mergeWith=$a,Li.method=oc,Li.methodOf=ac,Li.mixin=cc,Li.negate=qo,Li.nthArg=function(e){return e=ga(e),Jr((function(t){return Vr(t,e)}))},Li.omit=qa,Li.omitBy=function(e,t){return Ma(e,qo(cs(t)))},Li.once=function(e){return Co(2,e)},Li.orderBy=function(e,t,r,n){return null==e?[]:(Bo(t)||(t=null==t?[]:[t]),Bo(r=n?i:r)||(r=null==r?[]:[r]),Kr(e,t,r))},Li.over=uc,Li.overArgs=Uo,Li.overEvery=lc,Li.overSome=pc,Li.partial=Mo,Li.partialRight=Lo,Li.partition=So,Li.pick=Ua,Li.pickBy=Ma,Li.property=fc,Li.propertyOf=function(e){return function(t){return null==e?i:Er(e,t)}},Li.pull=Zs,Li.pullAll=Qs,Li.pullAllBy=function(e,t,i){return e&&e.length&&t&&t.length?Br(e,t,cs(i,2)):e},Li.pullAllWith=function(e,t,r){return e&&e.length&&t&&t.length?Br(e,t,i,r):e},Li.pullAt=Xs,Li.range=dc,Li.rangeRight=gc,Li.rearg=zo,Li.reject=function(e,t){return(Bo(e)?xt:gr)(e,qo(cs(t,3)))},Li.remove=function(e,t){var i=[];if(!e||!e.length)return i;var r=-1,n=[],s=e.length;for(t=cs(t,3);++r<s;){var o=e[r];t(o,r,e)&&(i.push(o),n.push(r))}return Wr(e,n),i},Li.rest=function(e,t){if("function"!=typeof e)throw new Ce(r);return Jr(e,t=t===i?t:ga(t))},Li.reverse=eo,Li.sampleSize=function(e,t,r){return t=(r?ws(e,t,r):t===i)?1:ga(t),(Bo(e)?Zi:Zr)(e,t)},Li.set=function(e,t,i){return null==e?e:Qr(e,t,i)},Li.setWith=function(e,t,r,n){return n="function"==typeof n?n:i,null==e?e:Qr(e,t,r,n)},Li.shuffle=function(e){return(Bo(e)?Qi:tn)(e)}
vendor: 4,693 bytes, line 1
1,Li.slice=function(e,t,r){var n=null==e?0:e.length;return n?(r&&"number"!=typeof r&&ws(e,t,r)?(t=0,r=n):(t=null==t?0:ga(t),r=r===i?n:ga(r)),rn(e,t,r)):[]},Li.sortBy=Oo,Li.sortedUniq=function(e){return e&&e.length?an(e):[]},Li.sortedUniqBy=function(e,t){return e&&e.length?an(e,cs(t,2)):[]},Li.split=function(e,t,r){return r&&"number"!=typeof r&&ws(e,t,r)&&(t=r=i),(r=r===i?d:r>>>0)?(e=wa(e))&&("string"==typeof t||null!=t&&!oa(t))&&(!(t=hn(t))&&oi(e))?bn(pi(e),0,r):e.split(t,r):[]},Li.spread=function(e,t){if("function"!=typeof e)throw new Ce(r);return t=null==t?0:vi(ga(t),0),Jr((function(i){var r=i[t],n=bn(i,0,t);return r&&jt(n,r),St(e,this,n)}))},Li.tail=function(e){var t=null==e?0:e.length;return t?rn(e,1,t):[]},Li.take=function(e,t,r){return e&&e.length?rn(e,0,(t=r||t===i?1:ga(t))<0?0:t):[]},Li.takeRight=function(e,t,r){var n=null==e?0:e.length;return n?rn(e,(t=n-(t=r||t===i?1:ga(t)))<0?0:t,n):[]},Li.takeRightWhile=function(e,t){return e&&e.length?fn(e,cs(t,3),!1,!0):[]},Li.takeWhile=function(e,t){return e&&e.length?fn(e,cs(t,3)):[]},Li.tap=function(e,t){return t(e),e},Li.throttle=function(e,t,i){var n=!0,s=!0;if("function"!=typeof e)throw new Ce(r);return ta(i)&&(n="leading"in i?!!i.leading:n,s="trailing"in i?!!i.trailing:s),To(e,t,{leading:n,maxWait:t,trailing:s})},Li.thru=fo,Li.toArray=fa,Li.toPairs=La,Li.toPairsIn=za,Li.toPath=function(e){return Bo(e)?Dt(e,Us):ha(e)?[e]:Cn(qs(wa(e)))},Li.toPlainObject=ma,Li.transform=function(e,t,i){var r=Bo(e),n=r||Jo(e)||ua(e);if(t=cs(t,4),null==i){var s=e&&e.constructor;i=n?r?new s:[]:ta(e)&&Qo(s)?zi(We(e)):{}}return(n?Rt:wr)(e,(function(e,r,n){return t(i,e,r,n)})),i},Li.unary=function(e){return No(e,1)},Li.union=to,Li.unionBy=io,Li.unionWith=ro,Li.uniq=function(e){return e&&e.length?un(e):[]},Li.uniqBy=function(e,t){return e&&e.length?un(e,cs(t,2)):[]},Li.uniqWith=function(e,t){return t="function"==typeof t?t:i,e&&e.length?un(e,i,t):[]},Li.unset=function(e,t){return null==e||ln(e,t)},Li.unzip=no,Li.unzipWith=so,Li.update=function(e,t,i){return null==e?e:pn(e,t,mn(i))},Li.updateWith=function(e,t,r,n){return n="function"==typeof n?n:i,null==e?e:pn(e,t,mn(r),n)},Li.values=ka,Li.valuesIn=function(e){return null==e?[]:Qt(e,Da(e))},Li.without=oo,Li.words=Qa,Li.wrap=function(e,t){return Mo(mn(t),e)},Li.xor=ao,Li.xorBy=co,Li.xorWith=ho,Li.zip=uo,Li.zipObject=function(e,t){return yn(e||[],t||[],er)},Li.zipObjectDeep=function(e,t){return yn(e||[],t||[],Qr)},Li.zipWith=lo,Li.entries=La,Li.entriesIn=za,Li.extend=ba,Li.extendWith=Ea,cc(Li,Li),Li.add=mc,Li.attempt=Xa,Li.camelCase=Va,Li.capitalize=Ka,Li.ceil=wc,Li.clamp=function(e,t,r){return r===i&&(r=t,t=i),r!==i&&(r=(r=va(r))===r?r:0),t!==i&&(t=(t=va(t))===t?t:0),or(va(e),t,r)},Li.clone=function(e){return ar(e,4)},Li.cloneDeep=function(e){return ar(e,5)},Li.cloneDeepWith=function(e,t){return ar(e,5,t="function"==typeof t?t:i)},Li.cloneWith=function(e,t){return ar(e,4,t="function"==typeof t?t:i)},Li.conformsTo=function(e,t){return null==t||cr(e,t,Ta(t))},Li.deburr=Ha,Li.defaultTo=function(e,t){return null==e||e!==e?t:e},Li.divide=_c,Li.endsWith=function(e,t,r){e=wa(e),t=hn(t);var n=e.length,s=r=r===i?n:or(ga(r),0,n);return(r-=t.length)>=0&&e.slice(r,s)==t},Li.eq=ko,Li.escape=function(e){return(e=wa(e))&&J.test(e)?e.replace(F,ni):e},Li.escapeRegExp=function(e){return(e=wa(e))&&re.test(e)?e.replace(ie,"\\$&"):e},Li.every=function(e,t,r){var n=Bo(e)?Ct:fr;return r&&ws(e,t,r)&&(t=i),n(e,cs(t,3))},Li.find=vo,Li.findIndex=Ks,Li.findKey=function(e,t){return Lt(e,cs(t,3),wr)},Li.findLast=mo,Li.findLastIndex=Hs,Li.findLastKey=function(e,t){return Lt(e,cs(t,3),_r)},Li.floor=bc,Li.forEach=wo,Li.forEachRight=_o,Li.forIn=function(e,t){return null==e?e:vr(e,cs(t,3),Da)},Li.forInRight=function(e,t){return null==e?e:mr(e,cs(t,3),Da)},Li.forOwn=function(e,t){return e&&wr(e,cs(t,3))},Li.forOwnRight=function(e,t){return e&&_r(e,cs(t,3))},Li.get=Ra,Li.gt=Vo,Li.gte=Ko,Li.has=function(e,t){return null!=e&&gs(e,t,Or)},Li.hasIn=Na,Li.head=Ws,Li.identity=nc,Li.includes=function(e,t,i,r){e=Fo(e)?e:ka(e),i=i&&!r?ga(i):0;var n=e.length;return i<0&&(i=vi(n+i,0)),ca(e)?i<=n&&e.indexOf(t,i)>-1:!!n&&kt(e,t,i)>-1},Li.indexOf=function(e,t,i){var r=null==e?0:e.length;if(!r)return-1;var n=null==i?0:ga(i);return n<0&&(n=vi(r+n,0)),kt(e,t,n)},Li.inRange=function(e,t,r){return t=da(t),r===i?(r=t,t=0):r=da(r),function(e,t,i){return e>=mi(t,i)&&e<vi(t,i)}(e=va(e),t,r)},Li.invoke=Aa,Li.isArguments=Ho,Li.isArray=Bo,Li.isArrayBuffer=Wo,Li.isArrayLike=Fo,Li.isArrayLikeObject=Go,Li.isBoolean=function(e){return!0===e||!1===e||ia(e)&&Pr(e)==m},Li.isBuffer=Jo,Li.isDate=Yo,Li.isElement=function(e){return ia(e)&&1===e.nodeType&&!sa(e)},Li.isEmpty=function(e){if(null==e)return!0;
vendor: 5,485 bytes, line 1
1if(Fo(e)&&(Bo(e)||"string"==typeof e||"function"==typeof e.splice||Jo(e)||ua(e)||Ho(e)))return!e.length;var t=ds(e);if(t==I||t==N)return!e.size;if(Is(e))return!$r(e).length;for(var i in e)if($e.call(e,i))return!1;return!0},Li.isEqual=function(e,t){return Ar(e,t)},Li.isEqualWith=function(e,t,r){var n=(r="function"==typeof r?r:i)?r(e,t):i;return n===i?Ar(e,t,i,r):!!n},Li.isError=Zo,Li.isFinite=function(e){return"number"==typeof e&&Mt(e)},Li.isFunction=Qo,Li.isInteger=Xo,Li.isLength=ea,Li.isMap=ra,Li.isMatch=function(e,t){return e===t||Tr(e,t,us(t))},Li.isMatchWith=function(e,t,r){return r="function"==typeof r?r:i,Tr(e,t,us(t),r)},Li.isNaN=function(e){return na(e)&&e!=+e},Li.isNative=function(e){if(Es(e))throw new Ie("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return Dr(e)},Li.isNil=function(e){return null==e},Li.isNull=function(e){return null===e},Li.isNumber=na,Li.isObject=ta,Li.isObjectLike=ia,Li.isPlainObject=sa,Li.isRegExp=oa,Li.isSafeInteger=function(e){return Xo(e)&&e>=-p&&e<=p},Li.isSet=aa,Li.isString=ca,Li.isSymbol=ha,Li.isTypedArray=ua,Li.isUndefined=function(e){return e===i},Li.isWeakMap=function(e){return ia(e)&&ds(e)==A},Li.isWeakSet=function(e){return ia(e)&&"[object WeakSet]"==Pr(e)},Li.join=function(e,t){return null==e?"":Wt.call(e,t)},Li.kebabCase=Ba,Li.last=Ys,Li.lastIndexOf=function(e,t,r){var n=null==e?0:e.length;if(!n)return-1;var s=n;return r!==i&&(s=(s=ga(r))<0?vi(n+s,0):mi(s,n-1)),t===t?function(e,t,i){for(var r=i+1;r--;)if(e[r]===t)return r;return r}(e,t,s):zt(e,Kt,s,!0)},Li.lowerCase=Wa,Li.lowerFirst=Fa,Li.lt=la,Li.lte=pa,Li.max=function(e){return e&&e.length?dr(e,nc,Sr):i},Li.maxBy=function(e,t){return e&&e.length?dr(e,cs(t,2),Sr):i},Li.mean=function(e){return Ht(e,nc)},Li.meanBy=function(e,t){return Ht(e,cs(t,2))},Li.min=function(e){return e&&e.length?dr(e,nc,Ur):i},Li.minBy=function(e,t){return e&&e.length?dr(e,cs(t,2),Ur):i},Li.stubArray=yc,Li.stubFalse=vc,Li.stubObject=function(){return{}},Li.stubString=function(){return""},Li.stubTrue=function(){return!0},Li.multiply=Ec,Li.nth=function(e,t){return e&&e.length?Vr(e,ga(t)):i},Li.noConflict=function(){return ft._===this&&(ft._=ze),this},Li.noop=hc,Li.now=Ro,Li.pad=function(e,t,i){e=wa(e);var r=(t=ga(t))?li(e):0;if(!t||r>=t)return e;var n=(t-r)/2;return Hn(gt(n),i)+e+Hn(dt(n),i)},Li.padEnd=function(e,t,i){e=wa(e);var r=(t=ga(t))?li(e):0;return t&&r<t?e+Hn(t-r,i):e},Li.padStart=function(e,t,i){e=wa(e);var r=(t=ga(t))?li(e):0;return t&&r<t?Hn(t-r,i)+e:e},Li.parseInt=function(e,t,i){return i||null==t?t=0:t&&(t=+t),_i(wa(e).replace(ne,""),t||0)},Li.random=function(e,t,r){if(r&&"boolean"!=typeof r&&ws(e,t,r)&&(t=r=i),r===i&&("boolean"==typeof t?(r=t,t=i):"boolean"==typeof e&&(r=e,e=i)),e===i&&t===i?(e=0,t=1):(e=da(e),t===i?(t=e,e=0):t=da(t)),e>t){var n=e;e=t,t=n}if(r||e%1||t%1){var s=bi();return mi(e+s*(t-e+ht("1e-"+((s+"").length-1))),t)}return Fr(e,t)},Li.reduce=function(e,t,i){var r=Bo(e)?$t:Ft,n=arguments.length<3;return r(e,cs(t,4),i,n,lr)},Li.reduceRight=function(e,t,i){var r=Bo(e)?qt:Ft,n=arguments.length<3;return r(e,cs(t,4),i,n,pr)},Li.repeat=function(e,t,r){return t=(r?ws(e,t,r):t===i)?1:ga(t),Gr(wa(e),t)},Li.replace=function(){var e=arguments,t=wa(e[0]);return e.length<3?t:t.replace(e[1],e[2])},Li.result=function(e,t,r){var n=-1,s=(t=wn(t,e)).length;for(s||(s=1,e=i);++n<s;){var o=null==e?i:e[Us(t[n])];o===i&&(n=s,o=r),e=Qo(o)?o.call(e):o}return e},Li.round=Ic,Li.runInContext=e,Li.sample=function(e){return(Bo(e)?Yi:Yr)(e)},Li.size=function(e){if(null==e)return 0;if(Fo(e))return ca(e)?li(e):e.length;var t=ds(e);return t==I||t==N?e.size:$r(e).length},Li.snakeCase=Ga,Li.some=function(e,t,r){var n=Bo(e)?Ut:nn;return r&&ws(e,t,r)&&(t=i),n(e,cs(t,3))},Li.sortedIndex=function(e,t){return sn(e,t)},Li.sortedIndexBy=function(e,t,i){return on(e,t,cs(i,2))},Li.sortedIndexOf=function(e,t){var i=null==e?0:e.length;if(i){var r=sn(e,t);if(r<i&&ko(e[r],t))return r}return-1},Li.sortedLastIndex=function(e,t){return sn(e,t,!0)},Li.sortedLastIndexBy=function(e,t,i){return on(e,t,cs(i,2),!0)},Li.sortedLastIndexOf=function(e,t){if(null==e?0:e.length){var i=sn(e,t,!0)-1;if(ko(e[i],t))return i}return-1},Li.startCase=Ja,Li.startsWith=function(e,t,i){return e=wa(e),i=null==i?0:or(ga(i),0,e.length),t=hn(t),e.slice(i,i+t.length)==t},Li.subtract=Pc,Li.sum=function(e){return e&&e.length?Gt(e,nc):0},Li.sumBy=function(e,t){return e&&e.length?Gt(e,cs(t,2)):0},Li.template=function(e,t,r){var n=Li.templateSettings;r&&ws(e,t,r)&&(t=i),e=wa(e),t=Ea({},t,n,Qn);var s,o,a=Ea({},t.imports,n.imports,Qn),c=Ta(a),h=Qt(a,c),u=0,l=t.interpolate||_e,p="__p += '",f=Re((t.escape||_e).source+"|"+l.source+"|"+(l===Q?pe:_e).source+"|"+(t.evaluate||_e).source+"|$","g"),d="//# sourceURL="+($e.call(t,"sourceURL")?(t.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++st+"]")+"\n";e.replace(f,(function(t,i,r,n,a,c){return r||(r=n),p+=e.slice(u,c).replace(be,si),i&&(s=!0,p+="' +\n__e("+i+") +\n'"),a&&(o=!0,p+="';\n"+a+";\n__p += '"),r&&(p+="' +\n((__t = ("+r+")) == null ? '' : __t) +\n'"),u=c+t.length,t})),p+="';\n";var g=$e.call(t,"variable")&&t.variable;if(g){if(ue.test(g))throw new Ie("Invalid `variable` option passed into `_.template`")}else p="with (obj) {\n"+p+"\n}\n";p=(o?p.replace(K,""):p).replace(H,"$1").replace(B,"$1;"),p="function("+(g||"obj")+") {\n"+(g?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(s?", __e = _.escape":"")+(o?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";
1\n")+p+"return __p\n}";var y=Xa((function(){return Pe(c,d+"return "+p).apply(i,h)}));if(y.source=p,Zo(y))throw y;return y},Li.times=function(e,t){if((e=ga(e))<1||e>p)return[];var i=d,r=mi(e,d);t=cs(t),e-=d;for(var n=Jt(r,t);++i<e;)t(i);return n},Li.toFinite=da,Li.toInteger=ga,Li.toLength=ya,Li.toLower=function(e){return wa(e).toLowerCase()},Li.toNumber=va,Li.toSafeInteger=function(e){return e?or(ga(e),-p,p):0===e?e:0},Li.toString=wa,Li.toUpper=function(e){return wa(e).toUpperCase()},Li.trim=function(e,t,r){if((e=wa(e))&&(r||t===i))return Yt(e);if(!e||!(t=hn(t)))return e;var n=pi(e),s=pi(t);return bn(n,ei(n,s),ti(n,s)+1).join("")},Li.trimEnd=function(e,t,r){if((e=wa(e))&&(r||t===i))return e.slice(0,fi(e)+1);if(!e||!(t=hn(t)))return e;var n=pi(e);return bn(n,0,ti(n,pi(t))+1).join("")},Li.trimStart=function(e,t,r){if((e=wa(e))&&(r||t===i))return e.replace(ne,"");if(!e||!(t=hn(t)))return e;var n=pi(e);return bn(n,ei(n,pi(t))).join("")},Li.truncate=function(e,t){var r=30,n="...";if(ta(t)){var s="separator"in t?t.separator:s;r="length"in t?ga(t.length):r,n="omission"in t?hn(t.omission):n}var o=(e=wa(e)).length;if(oi(e)){var a=pi(e);o=a.length}if(r>=o)return e;var c=r-li(n);if(c<1)return n;var h=a?bn(a,0,c).join(""):e.slice(0,c);if(s===i)return h+n;if(a&&(c+=h.length-c),oa(s)){if(e.slice(c).search(s)){var u,l=h;for(s.global||(s=Re(s.source,wa(fe.exec(s))+"g")),s.lastIndex=0;u=s.exec(l);)var p=u.index;h=h.slice(0,p===i?c:p)}}else if(e.indexOf(hn(s),c)!=c){var f=h.lastIndexOf(s);f>-1&&(h=h.slice(0,f))}return h+n},Li.unescape=function(e){return(e=wa(e))&&G.test(e)?e.replace(W,di):e},Li.uniqueId=function(e){var t=++qe;return wa(e)+t},Li.upperCase=Ya,Li.upperFirst=Za,Li.each=wo,Li.eachRight=_o,Li.first=Ws,cc(Li,function(){var e={};return wr(Li,(function(t,i){$e.call(Li.prototype,i)||(e[i]=t)})),e}(),{chain:!1}),Li.VERSION="4.17.21",Rt(["bind","bindKey","curry","curryRight","partial","partialRight"],(function(e){Li[e].placeholder=Li})),Rt(["drop","take"],(function(e,t){Ki.prototype[e]=function(r){r=r===i?1:vi(ga(r),0);var n=this.__filtered__&&!t?new Ki(this):this.clone();return n.__filtered__?n.__takeCount__=mi(r,n.__takeCount__):n.__views__.push({size:mi(r,d),type:e+(n.__dir__<0?"Right":"")}),n},Ki.prototype[e+"Right"]=function(t){return this.reverse()[e](t).reverse()}})),Rt(["filter","map","takeWhile"],(function(e,t){var i=t+1,r=1==i||3==i;Ki.prototype[e]=function(e){var t=this.clone();return t.__iteratees__.push({iteratee:cs(e,3),type:i}),t.__filtered__=t.__filtered__||r,t}})),Rt(["head","last"],(function(e,t){var i="take"+(t?"Right":"");Ki.prototype[e]=function(){return this[i](1).value()[0]}})),Rt(["initial","tail"],(function(e,t){var i="drop"+(t?"":"Right");Ki.prototype[e]=function(){return this.__filtered__?new Ki(this):this[i](1)}})),Ki.prototype.compact=function(){return this.filter(nc)},Ki.prototype.find=function(e){return this.filter(e).head()},Ki.prototype.findLast=function(e){return this.reverse().find(e)},Ki.prototype.invokeMap=Jr((function(e,t){return"function"==typeof e?new Ki(this):this.map((function(i){return Cr(i,e,t)}))})),Ki.prototype.reject=function(e){return this.filter(qo(cs(e)))},Ki.prototype.slice=function(e,t){e=ga(e);var r=this;return r.__filtered__&&(e>0||t<0)?new Ki(r):(e<0?r=r.takeRight(-e):e&&(r=r.drop(e)),t!==i&&(r=(t=ga(t))<0?r.dropRight(-t):r.take(t-e)),r)},Ki.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},Ki.prototype.toArray=function(){return this.take(d)},wr(Ki.prototype,(function(e,t){var r=/^(?:filter|find|map|reject)|While$/.test(t),n=/^(?:head|last)$/.test(t),s=Li[n?"take"+("last"==t?"Right":""):t],o=n||/^find/.test(t);s&&(Li.prototype[t]=function(){var t=this.__wrapped__,a=n?[1]:arguments,c=t instanceof Ki,h=a[0],u=c||Bo(t),l=function(e){var t=s.apply(Li,jt([e],a));return n&&p?t[0]:t};u&&r&&"function"==typeof h&&1!=h.length&&(c=u=!1);var p=this.__chain__,f=!!this.__actions__.length,d=o&&!p,g=c&&!f;if(!o&&u){t=g?t:new Ki(this);var y=e.apply(t,a);return y.__actions__.push({func:fo,args:[l],thisArg:i}),new Vi(y,p)}
vendor: 2,662 bytes, line 1
1return d&&g?e.apply(this,a):(y=this.thru(l),d?n?y.value()[0]:y.value():y)})})),Rt(["pop","push","shift","sort","splice","unshift"],(function(e){var t=xe[e],i=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",r=/^(?:pop|shift)$/.test(e);Li.prototype[e]=function(){var e=arguments;if(r&&!this.__chain__){var n=this.value();return t.apply(Bo(n)?n:[],e)}return this[i]((function(i){return t.apply(Bo(i)?i:[],e)}))}})),wr(Ki.prototype,(function(e,t){var i=Li[t];if(i){var r=i.name+"";$e.call(xi,r)||(xi[r]=[]),xi[r].push({name:t,func:i})}})),xi[zn(i,2).name]=[{name:"wrapper",func:i}],Ki.prototype.clone=function(){var e=new Ki(this.__wrapped__);return e.__actions__=Cn(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=Cn(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=Cn(this.__views__),e},Ki.prototype.reverse=function(){if(this.__filtered__){var e=new Ki(this);e.__dir__=-1,e.__filtered__=!0}else(e=this.clone()).__dir__*=-1;return e},Ki.prototype.value=function(){var e=this.__wrapped__.value(),t=this.__dir__,i=Bo(e),r=t<0,n=i?e.length:0,s=function(e,t,i){for(var r=-1,n=i.length;++r<n;){var s=i[r],o=s.size;switch(s.type){case"drop":e+=o;break;case"dropRight":t-=o;break;case"take":t=mi(t,e+o);break;case"takeRight":e=vi(e,t-o)}}return{start:e,end:t}}(0,n,this.__views__),o=s.start,a=s.end,c=a-o,h=r?a:o-1,u=this.__iteratees__,l=u.length,p=0,f=mi(c,this.__takeCount__);if(!i||!r&&n==c&&f==c)return dn(e,this.__actions__);var d=[];e:for(;c--&&p<f;){for(var g=-1,y=e[h+=t];++g<l;){var v=u[g],m=v.iteratee,w=v.type,_=m(y);if(2==w)y=_;else if(!_){if(1==w)continue e;break e}}d[p++]=y}return d},Li.prototype.at=go,Li.prototype.chain=function(){return po(this)},Li.prototype.commit=function(){return new Vi(this.value(),this.__chain__)},Li.prototype.next=function(){this.__values__===i&&(this.__values__=fa(this.value()));var e=this.__index__>=this.__values__.length;return{done:e,value:e?i:this.__values__[this.__index__++]}},Li.prototype.plant=function(e){for(var t,r=this;r instanceof ki;){var n=Ls(r);n.__index__=0,n.__values__=i,t?s.__wrapped__=n:t=n;var s=n;r=r.__wrapped__}return s.__wrapped__=e,t},Li.prototype.reverse=function(){var e=this.__wrapped__;if(e instanceof Ki){var t=e;return this.__actions__.length&&(t=new Ki(this)),(t=t.reverse()).__actions__.push({func:fo,args:[eo],thisArg:i}),new Vi(t,this.__chain__)}return this.thru(eo)},Li.prototype.toJSON=Li.prototype.valueOf=Li.prototype.value=function(){return dn(this.__wrapped__,this.__actions__)},Li.prototype.first=Li.prototype.head,Ze&&(Li.prototype[Ze]=function(){return this}),Li}();gt?((gt.exports=gi)._=gi,dt._=gi):ft._=gi}).call(ts)}
1(is,is.exports);var rs=Object.defineProperty,ns=Object.defineProperties,ss=Object.getOwnPropertyDescriptors,os=Object.getOwnPropertySymbols,as=Object.prototype.hasOwnProperty,cs=Object.prototype.propertyIsEnumerable,hs=(e,t,i)=>t in e?rs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,us=(e,t)=>{for(var i in t||(t={}))as.call(t,i)&&hs(e,i,t[i]);if(os)for(var i of os(t))cs.call(t,i)&&hs(e,i,t[i]);return e},ls=(e,t)=>ns(e,ss(t));function ps(e,t,i){let r;const n=fs(e);return t.rpcMap&&(r=t.rpcMap[n]),r||(r=`https://rpc.walletconnect.com/v1?chainId=eip155:${n}&projectId=${i}`),r}function fs(e){return e.includes("eip155")?Number(e.split(":")[1]):Number(e)}function ds(e){var t,i,r,n;const s={};if(!Ee(e))return s;for(const[o,a]of Object.entries(e)){const e=ge(o)?[o]:a.chains,c=a.methods||[],h=a.events||[],u=a.rpcMap||{},l=ye(o);s[l]=ls(us(us({},s[l]),a),{chains:re(e,null==(t=s[l])?void 0:t.chains),methods:re(c,null==(i=s[l])?void 0:i.methods),events:re(h,null==(r=s[l])?void 0:r.events),rpcMap:us(us({},u),null==(n=s[l])?void 0:n.rpcMap)})}return s}const gs={},ys=e=>gs[e],vs=(e,t)=>{gs[e]=t};class ms{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=ys("events"),this.client=ys("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||ps(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(es,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2]))||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var i;e[t]=this.createHttpProvider(t,null==(i=this.namespace.rpcMap)?void 0:i[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||ps(e,this.namespace);return typeof i>"u"?void 0:new gt(new Zn(i,ys("disableProviderPing")))}}class ws{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=ys("events"),this.client=ys("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){const i=fs(e);if(!this.httpProviders[i]){const e=t||ps(`${this.name}:${i}`,this.namespace,this.client.core.projectId);if(!e)throw new Error(`No RPC url provided for chainId: ${i}`);this.setHttpProvider(i,e)}this.chainId=i,this.events.emit(es,`${this.name}:${i}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const i=t||ps(`${this.name}:${e}`,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new gt(new Yn(i,ys("disableProviderPing")))}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var i;const r=fs(t);e[r]=this.createHttpProvider(r,null==(i=this.namespace.rpcMap)?void 0:i[t])})),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t;let i=e.request.params?null==(t=e.request.params[0])?void 0:t.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const r=parseInt(i,16);if(this.isChainApproved(r))this.setDefaultChain(`${r}`);else{if(!this.namespace.methods.includes("wallet_switchEthereumChain"))throw new Error(`Failed to switch to chain 'eip155:${r}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:e.chainId}),this.setDefaultChain(`${r}`)}return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}}class _s{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=ys("events"),this.client=ys("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const i=t||ps(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(es,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var i;e[t]=this.createHttpProvider(t,null==(i=this.namespace.rpcMap)?void 0:i[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||ps(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new gt(new Zn(i,ys("disableProviderPing")))}}class bs{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=ys("events"),this.client=ys("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||ps(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(es,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var i;e[t]=this.createHttpProvider(t,null==(i=this.namespace.rpcMap)?void 0:i[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||ps(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new gt(new Zn(i,ys("disableProviderPing")))}}class Es{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=ys("events"),this.client=ys("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||this.getCardanoRPCUrl(e);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(es,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{const i=this.getCardanoRPCUrl(t);e[t]=this.createHttpProvider(t,i)})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||this.getCardanoRPCUrl(e);return typeof i>"u"?void 0:new gt(new Zn(i,ys("disableProviderPing")))}}class Is{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=ys("events"),this.client=ys("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const i=t||ps(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(es,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var i;e[t]=this.createHttpProvider(t,null==(i=this.namespace.rpcMap)?void 0:i[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||ps(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new gt(new Zn(i,ys("disableProviderPing")))}}class Ps{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=ys("events"),this.client=ys("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const i=t||ps(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(es,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter((e=>e.split(":")[1]===this.chainId.toString())).map((e=>e.split(":")[2])))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach((t=>{var i;e[t]=this.createHttpProvider(t,null==(i=this.namespace.rpcMap)?void 0:i[t])})),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||ps(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new gt(new Zn(i,ys("disableProviderPing")))}}var Ss=Object.defineProperty,Os=Object.defineProperties,Rs=Object.getOwnPropertyDescriptors,Ns=Object.getOwnPropertySymbols,Cs=Object.prototype.hasOwnProperty,xs=Object.prototype.propertyIsEnumerable,As=(e,t,i)=>t in e?Ss(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Ts=(e,t)=>{for(var i in t||(t={}))Cs.call(t,i)&&As(e,i,t[i]);if(Ns)for(var i of Ns(t))xs.call(t,i)&&As(e,i,t[i]);return e},Ds=(e,t)=>Os(e,Rs(t));
1class js{constructor(e){this.events=new(n()),this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,ke.pino)((0,ke.getDefaultLoggerOptions)({level:e?.logger||Qn})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const t=new js(e);return await t.initialize(),t}async request(e,t){const[i,r]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:Ts({},e),chainId:`${i}:${r}`,topic:this.session.topic})}sendAsync(e,t,i){this.request(e,i).then((e=>t(null,e))).catch((e=>t(e,void 0)))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:null==(e=this.session)?void 0:e.topic,reason:_e("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){this.shouldAbortPairingAttempt=!1;let t=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(t>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:i,approval:r}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});i&&(this.uri=i,this.events.emit("display_uri",i)),await r().then((e=>{this.session=e})).catch((e=>{if(e.message!==mn)throw e;t++}))}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,t){try{const[i,r]=this.validateChain(e);this.getProvider(i).setDefaultChain(r,t)}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if(be(t)){for(const i of t)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await qn.init({logger:this.providerOpts.logger||Qn,relayUrl:this.providerOpts.relayUrl||"wss://relay.walletconnect.com",projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map((e=>ye(e))))];vs("client",this.client),vs("events",this.events),vs("disableProviderPing",this.disableProviderPing),e.forEach((e=>{if(!this.session)return;const t=function(e,t){const i=Object.keys(t.namespaces).filter((t=>t.includes(e)));if(!i.length)return[];const r=[];return i.forEach((e=>{const i=t.namespaces[e].accounts;
1r.push(...i)})),r}(e,this.session),i=function(e){return e.map((e=>`${e.split(":")[0]}:${e.split(":")[1]}`))}(t),r=function(e,t={}){const i=ds(e),r=ds(t);return is.exports.merge(i,r)}(this.namespaces,this.optionalNamespaces),n=Ds(Ts({},r[e]),{accounts:t,chains:i});switch(e){case"eip155":this.rpcProviders[e]=new ws({namespace:n});break;case"solana":this.rpcProviders[e]=new _s({namespace:n});break;case"cosmos":this.rpcProviders[e]=new bs({namespace:n});break;case"polkadot":this.rpcProviders[e]=new ms({namespace:n});break;case"cip34":this.rpcProviders[e]=new Es({namespace:n});break;case"elrond":this.rpcProviders[e]=new Is({namespace:n});break;case"multiversx":this.rpcProviders[e]=new Ps({namespace:n})}}))}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",(e=>{this.events.emit("session_ping",e)})),this.client.on("session_event",(e=>{const{params:t}=e,{event:i}=t;"accountsChanged"===i.name?this.events.emit("accountsChanged",i.data):"chainChanged"===i.name?this.onChainChanged(t.chainId):this.events.emit(i.name,i.data),this.events.emit("session_event",e)})),this.client.on("session_update",(({topic:e,params:t})=>{var i;const{namespaces:r}=t,n=null==(i=this.client)?void 0:i.session.get(e);this.session=Ds(Ts({},n),{namespaces:r}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})})),this.client.on("session_delete",(async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Ds(Ts({},_e("USER_DISCONNECTED")),{data:e.topic}))})),this.on(es,(e=>{this.onChainChanged(e,!0)}))}getProvider(e){if(!this.rpcProviders[e])throw new Error(`Provider not found: ${e}`);return this.rpcProviders[e]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach((e=>{var t;this.getProvider(e).updateNamespace(null==(t=this.session)?void 0:t.namespaces[e])}))}setNamespaces(e){const{namespaces:t,optionalNamespaces:i,sessionProperties:r}=e;if(!t||!Object.keys(t).length)throw new Error("Namespaces must be not empty");this.namespaces=t,this.optionalNamespaces=i,this.sessionProperties=r,this.persist("namespaces",t),this.persist("optionalNamespaces",i)}validateChain(e){const[t,i]=e?.split(":")||["",""];if(t&&!Object.keys(this.namespaces).map((e=>ye(e))).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&i)return[t,i];const r=ye(Object.keys(this.namespaces)[0]);return[r,this.rpcProviders[r].getDefaultChain()]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){var i;const[r,n]=this.validateChain(e);t||this.getProvider(r).setDefaultChain(n),(null!=(i=this.namespaces[r])?i:this.namespaces[`${r}:${n}`]).defaultChain=n,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",n)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${Xn}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${Xn}/${e}`)}}const $s=js,qs=["eth_sendTransaction","personal_sign"],Us=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],Ms=["chainChanged","accountsChanged"],Ls=["message","disconnect","connect"];var zs=Object.defineProperty,ks=Object.defineProperties,Vs=Object.getOwnPropertyDescriptors,Ks=Object.getOwnPropertySymbols,Hs=Object.prototype.hasOwnProperty,Bs=Object.prototype.propertyIsEnumerable,Ws=(e,t,i)=>t in e?zs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Fs=(e,t)=>{for(var i in t||(t={}))Hs.call(t,i)&&Ws(e,i,t[i]);if(Ks)for(var i of Ks(t))Bs.call(t,i)&&Ws(e,i,t[i]);return e},Gs=(e,t)=>ks(e,Vs(t));function Js(e){return Number(e[0].split(":")[1])}function Ys(e){return`0x${e.toString(16)}`}class Zs{constructor(){this.events=new r.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY="wc@2:ethereum_provider:",this.on=(e,t)=>(this.events.on(e,t),this),this.once=(e,t)=>(this.events.once(e,t),this),this.removeListener=(e,t)=>(this.events.removeListener(e,t),this),this.off=(e,t)=>(this.events.off(e,t),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const t=new Zs;return await t.initialize(e),t}async request(e){return await this.signer.request(e,this.formatChainId(this.chainId))}sendAsync(e,t){this.signer.sendAsync(e,t,this.formatChainId(this.chainId))}get connected(){return!!this.signer.client&&this.signer.client.core.relayer.connected}get connecting(){return!!this.signer.client&&this.signer.client.core.relayer.connecting}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(e){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:t,optional:i}=function(e){const{chains:t,optionalChains:i,methods:r,optionalMethods:n,events:s,optionalEvents:o,rpcMap:a}=e;if(!be(t))throw new Error("Invalid chains");const c=t,h=r||qs,u=s||Ms,l={chains:c,methods:h,events:u,rpcMap:{[Js(c)]:a[Js(c)]}},p=s?.filter((e=>!Ms.includes(e))),f=r?.filter((e=>!qs.includes(e)));return i||o||n||null!=p&&p.length||null!=f&&f.length?{required:l,optional:{chains:[...new Set(p?.length&&f?.length||!i?c.concat(i||[]):i)],methods:[...new Set(h.concat(n||[]))],events:[...new Set(u.concat(o||[]))],rpcMap:a}}:{required:l}}(this.rpc);try{const r=await new Promise((async(r,n)=>{var s;this.rpc.showQrModal&&(null==(s=this.modal)||s.subscribeModal((e=>{!e.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),n(new Error("Connection request reset. Please try again.")))}))),await this.signer.connect(Gs(Fs({namespaces:{[this.namespace]:t}},i&&{optionalNamespaces:{[this.namespace]:i}}),{pairingTopic:e?.pairingTopic})).then((e=>{r(e)})).catch((e=>{n(new Error(e.message))}))}));if(!r)return;this.setChainIds(this.rpc.chains);const n=function(e,t=[]){const i=[];return Object.keys(e).forEach((r=>{if(t.length&&!t.includes(r))return;const n=e[r];i.push(...n.accounts)})),i}(r.namespaces,[this.namespace]);this.setAccounts(n),this.events.emit("connect",{chainId:Ys(this.chainId)})}catch(Ke){throw this.signer.logger.error(Ke),Ke}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",(e=>{const{params:t}=e,{event:i}=t;"accountsChanged"===i.name?(this.accounts=this.parseAccounts(i.data),this.events.emit("accountsChanged",this.accounts)):"chainChanged"===i.name?this.setChainId(this.formatChainId(i.data)):this.events.emit(i.name,i.data),this.events.emit("session_event",e)})),this.signer.on("chainChanged",(e=>{const t=parseInt(e);this.chainId=t,this.events.emit("chainChanged",Ys(this.chainId)),this.persist()})),this.signer.on("session_update",(e=>{this.events.emit("session_update",e)})),this.signer.on("session_delete",(e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",Gs(Fs({},_e("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))})),this.signer.on("display_uri",(e=>{var t,i;this.rpc.showQrModal&&(null==(t=this.modal)||t.closeModal(),null==(i=this.modal)||i.openModal({uri:e})),this.events.emit("display_uri",e)}))}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return"string"==typeof e&&e.startsWith(`${this.namespace}:`)}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const t=e.filter((e=>this.isCompatibleChainId(e))).map((e=>this.parseChainId(e)));t.length&&(this.chainId=t[0],this.events.emit("chainChanged",Ys(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const t=this.parseChainId(e);this.chainId=t,this.switchEthereumChain(t)}}parseAccountId(e){const[t,i,r]=e.split(":");return{chainId:`${t}:${i}`,address:r}}setAccounts(e){this.accounts=e.filter((e=>this.parseChainId(this.parseAccountId(e).chainId)===this.chainId)).map((e=>this.parseAccountId(e).address)),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var t,i;return{chains:(null==(t=e.chains)?void 0:t.map((e=>this.formatChainId(e))))||[`${this.namespace}:1`],optionalChains:e.optionalChains?e.optionalChains.map((e=>this.formatChainId(e))):void 0,methods:e?.methods||qs,events:e?.events||Ms,optionalMethods:e?.optionalMethods||[],optionalEvents:e?.optionalEvents||[],rpcMap:e?.rpcMap||this.buildRpcMap(e.chains.concat(e.optionalChains||[]),e.projectId),showQrModal:!(null==e||!e.showQrModal),qrModalOptions:null!=(i=e?.qrModalOptions)?i:void 0,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,t){const i={};return e.forEach((e=>{i[e]=this.getRpcUrl(e,t)})),i}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=Js(this.rpc.chains),this.signer=await $s.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storageOptions:e.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let e;
1try{const{WalletConnectModal:t}=await i.e(9343).then(i.bind(i,59343));e=t}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(e)try{this.modal=new e(Fs({walletConnectVersion:2,projectId:this.rpc.projectId,standaloneChains:this.rpc.chains},this.rpc.qrModalOptions))}catch(t){throw this.signer.logger.error(t),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:t,optionalChains:i,rpcMap:r}=e;t&&be(t)&&(this.rpc.chains=t.map((e=>this.formatChainId(e))),t.forEach((e=>{this.rpc.rpcMap[e]=r?.[e]||this.getRpcUrl(e)}))),i&&be(i)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=i?.map((e=>this.formatChainId(e))),i.forEach((e=>{this.rpc.rpcMap[e]=r?.[e]||this.getRpcUrl(e)})))}getRpcUrl(e,t){var i;return(null==(i=this.rpc.rpcMap)?void 0:i[e])||`https://rpc.walletconnect.com/v1/?chainId=eip155:${e}&projectId=${t||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),t=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]:t?.accounts),this.setAccounts(t?.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(e){return"string"==typeof e||e instanceof String?[this.parseAccount(e)]:e.map((e=>this.parseAccount(e)))}}const Qs=Zs},47519:function(e,t,i){"use strict";var r=i(64528);i.o(r,"isHttpUrl")&&i.d(t,{isHttpUrl:function(){return r.isHttpUrl}});var n=i(56662);i.o(n,"isHttpUrl")&&i.d(t,{isHttpUrl:function(){return n.isHttpUrl}})},64528:function(){},56662:function(){}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.