-
Notifications
You must be signed in to change notification settings - Fork 0
/
73.6392bdd5930a720822ff.js
1 lines (1 loc) · 241 KB
/
73.6392bdd5930a720822ff.js
1
"use strict";(self.webpackChunktimeless_frontend=self.webpackChunktimeless_frontend||[]).push([[73],{30073:(Qt,k,H)=>{H.r(k),H.d(k,{EthereumProvider:()=>Zb,OPTIONAL_EVENTS:()=>Kl,OPTIONAL_METHODS:()=>Vl,REQUIRED_EVENTS:()=>ss,REQUIRED_METHODS:()=>is,default:()=>cs});var N=H(34553),Le=H(93105),Je=H.n(Le),Ve=H(91573),Te=H(37651),We=H(52632),Ye=H(41027),ot=H(72180),ye=H(81361),L=H(14611),or=(H(63581),H(38541),H(32257),H(9964));const pp={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}};function Gr(n,e){return!!Array.isArray(n)&&(!(typeof e<"u"&&n.length)||n.every(e))}var Np=H(83639),Bn=H(38960),Pp=H(22694),Ti=H.n(Pp);const Wn="custom_context";Symbol;var jp=Object.defineProperty,$p=Object.defineProperties,Dp=Object.getOwnPropertyDescriptors,Va=Object.getOwnPropertySymbols,Fp=Object.prototype.hasOwnProperty,Up=Object.prototype.propertyIsEnumerable,Ka=(n,e,t)=>e in n?jp(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;function ho(n){return((n,e)=>$p(n,Dp(e)))(((n,e)=>{for(var t in e||(e={}))Fp.call(e,t)&&Ka(n,t,e[t]);if(Va)for(var t of Va(e))Up.call(e,t)&&Ka(n,t,e[t]);return n})({},n),{level:n?.level||"info"})}function St(n,e=Wn){let t="";return t=typeof n.bindings>"u"?function(n,e=Wn){return n[e]||""}(n,e):n.bindings().context||"",t}function Tt(n,e,t=Wn){const a=function(n,e,t=Wn){const a=St(n,t);return a.trim()?`${a}/${e}`:e}(n,e,t);return function(n,e,t=Wn){return n[t]=e,n}(n.child({context:a}),a,t)}var wn=H(52399);class Zp extends wn.q{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class Vp extends wn.q{constructor(e,t){super(),this.core=e,this.logger=t,this.records=new Map}}class Bp extends wn.q{constructor(e,t){super(),this.relayer=e,this.logger=t}}class Wp extends wn.q{constructor(e){super()}}class Gp extends wn.q{constructor(e,t){super(),this.relayer=e,this.logger=t}}class Jp extends wn.q{constructor(e,t){super(),this.core=e,this.logger=t}}var Di=H(62757),Ba=function(n,e,t){if(t||2===arguments.length)for(var d,a=0,l=e.length;a<l;a++)(d||!(a in e))&&(d||(d=Array.prototype.slice.call(e,0,a)),d[a]=e[a]);return n.concat(d||Array.prototype.slice.call(e))},ig=function(e,t,a){this.name=e,this.version=t,this.os=a,this.type="browser"},sg=function(e){this.version=e,this.type="node",this.name="node",this.os=process.platform},og=function(e,t,a,l){this.name=e,this.version=t,this.os=a,this.bot=l,this.type="bot-device"},cg=function(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null},ag=function(){this.type="react-native",this.name="react-native",this.version=null,this.os=null},lg=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,fg=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/]],Ha=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function Ja(n){var e=function(n){return""!==n&&fg.reduce(function(e,t){var a=t[0];if(e)return e;var d=t[1].exec(n);return!!d&&[a,d]},!1)}(n);if(!e)return null;var t=e[0],a=e[1];if("searchbot"===t)return new cg;var l=a[1]&&a[1].split(".").join("_").split("_").slice(0,3);l?l.length<3&&(l=Ba(Ba([],l,!0),function(n){for(var e=[],t=0;t<n;t++)e.push("0");return e}(3-l.length),!0)):l=[];var d=l.join("."),p=function(n){for(var e=0,t=Ha.length;e<t;e++){var a=Ha[e],l=a[0];if(a[1].exec(n))return l}return null}(n),m=lg.exec(n);return m&&m[1]?new og(t,d,p,m[1]):new ig(t,d,p)}var Fi=H(45418),_g=H(31846),Ui=H(34955);function po(n,e){return n.includes(":")?[n]:e.chains||[]}const vt="base16",_o="base64pad",yo="utf8";function bo(){const n=(0,We.randomBytes)(32);return(0,ye.BB)(n,vt)}function In(n){const e=(0,Ye.vp)((0,ye.mL)(n,yo));return(0,ye.BB)(e,vt)}function Hn(n){return Number((0,ye.BB)(n,"base10"))}function ki(n){const e=(0,ye.mL)(n,_o),t=e.slice(0,1);if(1===Hn(t)){const m=33,P=m+12,S=e.slice(1,m),T=e.slice(m,P);return{type:t,sealed:e.slice(P),iv:T,senderPublicKey:S}}const d=e.slice(1,13);return{type:t,sealed:e.slice(13),iv:d}}function ru(n){const e=n?.type||0;if(1===e){if(typeof n?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof n?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:n?.senderPublicKey,receiverPublicKey:n?.receiverPublicKey}}function nu(n){return 1===n.type&&"string"==typeof n.senderPublicKey&&"string"==typeof n.receiverPublicKey}var $g=Object.defineProperty,iu=Object.getOwnPropertySymbols,Dg=Object.prototype.hasOwnProperty,Fg=Object.prototype.propertyIsEnumerable,su=(n,e,t)=>e in n?$g(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ou=(n,e)=>{for(var t in e||(e={}))Dg.call(e,t)&&su(n,t,e[t]);if(iu)for(var t of iu(e))Fg.call(e,t)&&su(n,t,e[t]);return n};const kg="js";function Eo(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function au(){return!(0,Fi.getDocument)()&&!!(0,Fi.getNavigator)()&&"ReactNative"===navigator.product}function Io(){return!Eo()&&!!(0,Fi.getNavigator)()}function Mi(){return au()?"react-native":Eo()?"node":Io()?"browser":"unknown"}function Vg(n,e,t){const a=function(){if("react-native"===Mi()&&typeof global<"u"&&typeof(null==global?void 0:global.Platform)<"u"){const{OS:t,Version:a}=global.Platform;return[t,a].join("-")}const n=function(n){return n?Ja(n):"undefined"==typeof document&&"undefined"!=typeof navigator&&"ReactNative"===navigator.product?new ag:"undefined"!=typeof navigator?Ja(navigator.userAgent):"undefined"!=typeof process&&process.version?new sg(process.version.slice(1)):null}();if(null===n)return"unknown";const e=n.os?n.os.replace(" ","").toLowerCase():"unknown";return"browser"===n.type?[e,n.name,n.version].join("-"):[e,n.version].join("-")}(),l=function(){var n;const e=Mi();return"browser"===e?[e,(null==(n=(0,Fi.getLocation)())?void 0:n.host)||"unknown"].join(":"):e}();return[[n,e].join("-"),[kg,t].join("-"),a,l].join("/")}function Qr(n,e){return n.filter(t=>e.includes(t)).length===n.length}function uu(n){return Object.fromEntries(n.entries())}function lu(n){return new Map(Object.entries(n))}function On(n=L.FIVE_MINUTES,e){const t=(0,L.toMiliseconds)(n||L.FIVE_MINUTES);let a,l,d;return{resolve:p=>{d&&a&&(clearTimeout(d),a(p))},reject:p=>{d&&l&&(clearTimeout(d),l(p))},done:()=>new Promise((p,m)=>{d=setTimeout(()=>{m(new Error(e))},t),a=p,l=m})}}function qi(n,e,t){return new Promise(function(){var a=(0,N.Z)(function*(l,d){const p=setTimeout(()=>d(new Error(t)),e);try{l(yield n)}catch(m){d(m)}clearTimeout(p)});return function(l,d){return a.apply(this,arguments)}}())}function fu(n,e){if("string"==typeof e&&e.startsWith(`${n}:`))return e;if("topic"===n.toLowerCase()){if("string"!=typeof e)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}if("id"===n.toLowerCase()){if("number"!=typeof e)throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${n}`)}function du(n){const[e,t]=n.split(":"),a={id:void 0,topic:void 0};if("topic"===e&&"string"==typeof t)a.topic=t;else{if("id"!==e||!Number.isInteger(Number(t)))throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);a.id=Number(t)}return a}function Xt(n,e){return(0,L.fromMiliseconds)((e||Date.now())+(0,L.toMiliseconds)(n))}function Nr(n){return Date.now()>=(0,L.toMiliseconds)(n)}function ct(n,e){return`${n}${e?`:${e}`:""}`}function Oo(){return(Oo=(0,N.Z)(function*({id:n,topic:e,wcDeepLink:t}){try{if(!t)return;let l=("string"==typeof t?JSON.parse(t):t)?.href;if("string"!=typeof l)return;l.endsWith("/")&&(l=l.slice(0,-1));const d=`${l}/wc?requestId=${n}&sessionTopic=${e}`,p=Mi();"browser"===p?d.startsWith("https://")?window.open(d,"_blank","noreferrer noopener"):window.open(d,"_self","noreferrer noopener"):"react-native"===p&&typeof(null==global?void 0:global.Linking)<"u"&&(yield global.Linking.openURL(d))}catch(a){console.error(a)}})).apply(this,arguments)}function So(n){return n?.relay||{protocol:"irn"}}function zi(n){const e=or.RELAY_JSONRPC[n];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${n}`);return e}var Xg=Object.defineProperty,hu=Object.getOwnPropertySymbols,e_=Object.prototype.hasOwnProperty,t_=Object.prototype.propertyIsEnumerable,pu=(n,e,t)=>e in n?Xg(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;function n_(n,e="-"){const t={},a="relay"+e;return Object.keys(n).forEach(l=>{if(l.startsWith(a)){const d=l.replace(a,"");t[d]=n[l]}}),t}function s_(n){return n.startsWith("//")?n.substring(2):n}function Sn(n){const e=[];return n.forEach(t=>{const[a,l]=t.split(":");e.push(`${a}:${l}`)}),e}const b_={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}},w_={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 ee(n,e){const{message:t,code:a}=w_[n];return{message:e?`${t} ${e}`:t,code:a}}function lt(n,e){const{message:t,code:a}=b_[n];return{message:e?`${t} ${e}`:t,code:a}}function Gn(n,e){return!!Array.isArray(n)&&(!(typeof e<"u"&&n.length)||n.every(e))}function xn(n){return Object.getPrototypeOf(n)===Object.prototype&&Object.keys(n).length}function bt(n){return typeof n>"u"}function ft(n,e){return!(!e||!bt(n))||"string"==typeof n&&!!n.trim().length}function xo(n,e){return!(!e||!bt(n))||"number"==typeof n&&!isNaN(n)}function Zi(n){return!(!ft(n,!1)||!n.includes(":"))&&2===n.split(":").length}function vu(n){let e=!0;return Gn(n)?n.length&&(e=n.every(t=>ft(t,!1))):e=!1,e}function bu(n,e){let t=null;return Object.values(n).forEach(a=>{if(t)return;const l=function(n,e){let t=null;return vu(n?.methods)?vu(n?.events)||(t=lt("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=lt("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}(a,`${e}, namespace`);l&&(t=l)}),t}function Vi(n,e){let t=null;if(n&&xn(n)){const a=bu(n,e);a&&(t=a);const l=function(n,e){let t=null;return Object.values(n).forEach(a=>{if(t)return;const l=function(n,e){let t=null;return Gn(n)?n.forEach(a=>{t||function(n){if(ft(n,!1)&&n.includes(":")){const e=n.split(":");if(3===e.length){const t=e[0]+":"+e[1];return!!e[2]&&Zi(t)}}return!1}(a)||(t=lt("UNSUPPORTED_ACCOUNTS",`${e}, account ${a} should be a string and conform to "namespace:chainId:address" format`))}):t=lt("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}(a?.accounts,`${e} namespace`);l&&(t=l)}),t}(n,e);l&&(t=l)}else t=ee("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function wu(n){return ft(n.protocol,!0)}function xt(n){return typeof n<"u"&&null!==typeof n}function Eu(n,e){return!(!Zi(e)||!function(n){const e=[];return Object.values(n).forEach(t=>{e.push(...Sn(t.accounts))}),e}(n).includes(e))}function No(n,e,t){let a=null;const l=function(n){const e={};return Object.keys(n).forEach(t=>{var a;t.includes(":")?e[t]=n[t]:null==(a=n[t].chains)||a.forEach(l=>{e[l]={methods:n[t].methods,events:n[t].events}})}),e}(n),d=function(n){const e={};return Object.keys(n).forEach(t=>{t.includes(":")?e[t]=n[t]:Sn(n[t].accounts)?.forEach(l=>{e[l]={accounts:n[t].accounts.filter(d=>d.includes(`${l}:`)),methods:n[t].methods,events:n[t].events}})}),e}(e),p=Object.keys(l),m=Object.keys(d),P=Iu(Object.keys(n)),S=Iu(Object.keys(e)),T=P.filter(D=>!S.includes(D));return T.length&&(a=ee("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces.\n Required: ${T.toString()}\n Received: ${Object.keys(e).toString()}`)),Qr(p,m)||(a=ee("NON_CONFORMING_NAMESPACES",`${t} namespaces chains don't satisfy required namespaces.\n Required: ${p.toString()}\n Approved: ${m.toString()}`)),Object.keys(e).forEach(D=>{if(!D.includes(":")||a)return;const Q=Sn(e[D].accounts);Q.includes(D)||(a=ee("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${D}\n Required: ${D}\n Approved: ${Q.toString()}`))}),p.forEach(D=>{a||(Qr(l[D].methods,d[D].methods)?Qr(l[D].events,d[D].events)||(a=ee("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${D}`)):a=ee("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${D}`))}),a}function Iu(n){return[...new Set(n.map(e=>e.includes(":")?e.split(":")[0]:e))]}var Pr=H(10321),xe=H(22339);const Ou=n=>n.split("?")[0],Y_="undefined"!=typeof WebSocket?WebSocket:"undefined"!=typeof global&&void 0!==global.WebSocket?global.WebSocket:"undefined"!=typeof window&&void 0!==window.WebSocket?window.WebSocket:"undefined"!=typeof self&&void 0!==self.WebSocket?self.WebSocket:H(98164);var ey=H(6856),ty=H.n(ey),iy=function(n,e){if(n.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),a=0;a<t.length;a++)t[a]=255;for(var l=0;l<n.length;l++){var d=n.charAt(l),p=d.charCodeAt(0);if(255!==t[p])throw new TypeError(d+" is ambiguous");t[p]=l}var m=n.length,P=n.charAt(0),S=Math.log(m)/Math.log(256),T=Math.log(256)/Math.log(m);function Q(B){if("string"!=typeof B)throw new TypeError("Expected String");if(0===B.length)return new Uint8Array;var Y=0;if(" "!==B[Y]){for(var te=0,Me=0;B[Y]===P;)te++,Y++;for(var Xe=(B.length-Y)*S+1>>>0,Ue=new Uint8Array(Xe);B[Y];){var ve=t[B.charCodeAt(Y)];if(255===ve)return;for(var oe=0,Ne=Xe-1;(0!==ve||oe<Me)&&-1!==Ne;Ne--,oe++)Ue[Ne]=(ve+=m*Ue[Ne]>>>0)%256>>>0,ve=ve/256>>>0;if(0!==ve)throw new Error("Non-zero carry");Me=oe,Y++}if(" "!==B[Y]){for(var qe=Xe-Me;qe!==Xe&&0===Ue[qe];)qe++;for(var dt=new Uint8Array(te+(Xe-qe)),$r=te;qe!==Xe;)dt[$r++]=Ue[qe++];return dt}}}return{encode:function(B){if(B instanceof Uint8Array||(ArrayBuffer.isView(B)?B=new Uint8Array(B.buffer,B.byteOffset,B.byteLength):Array.isArray(B)&&(B=Uint8Array.from(B))),!(B instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===B.length)return"";for(var Y=0,te=0,Me=0,Xe=B.length;Me!==Xe&&0===B[Me];)Me++,Y++;for(var Ue=(Xe-Me)*T+1>>>0,ve=new Uint8Array(Ue);Me!==Xe;){for(var oe=B[Me],Ne=0,qe=Ue-1;(0!==oe||Ne<te)&&-1!==qe;qe--,Ne++)ve[qe]=(oe+=256*ve[qe]>>>0)%m>>>0,oe=oe/m>>>0;if(0!==oe)throw new Error("Non-zero carry");te=Ne,Me++}for(var dt=Ue-te;dt!==Ue&&0===ve[dt];)dt++;for(var $r=P.repeat(Y);dt<Ue;++dt)$r+=n.charAt(ve[dt]);return $r},decodeUnsafe:Q,decode:function(B){var Y=Q(B);if(Y)return Y;throw new Error(`Non-${e} character`)}}};const xu=n=>{if(n instanceof Uint8Array&&"Uint8Array"===n.constructor.name)return n;if(n instanceof ArrayBuffer)return new Uint8Array(n);if(ArrayBuffer.isView(n))return new Uint8Array(n.buffer,n.byteOffset,n.byteLength);throw new Error("Unknown type, must be binary type")};class cy{constructor(e,t,a){this.name=e,this.prefix=t,this.baseEncode=a}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class ay{constructor(e,t,a){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=a}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return Nu(this,e)}}class uy{constructor(e){this.decoders=e}or(e){return Nu(this,e)}decode(e){const a=this.decoders[e[0]];if(a)return a.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Nu=(n,e)=>new uy({...n.decoders||{[n.prefix]:n},...e.decoders||{[e.prefix]:e}});class ly{constructor(e,t,a,l){this.name=e,this.prefix=t,this.baseEncode=a,this.baseDecode=l,this.encoder=new cy(e,t,a),this.decoder=new ay(e,t,l)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Ki=({name:n,prefix:e,encode:t,decode:a})=>new ly(n,e,t,a),Jn=({prefix:n,name:e,alphabet:t})=>{const{encode:a,decode:l}=iy(t,e);return Ki({prefix:n,name:e,encode:a,decode:d=>xu(l(d))})},pt=({name:n,prefix:e,bitsPerChar:t,alphabet:a})=>Ki({prefix:e,name:n,encode:l=>((n,e,t)=>{const a="="===e[e.length-1],l=(1<<t)-1;let d="",p=0,m=0;for(let P=0;P<n.length;++P)for(m=m<<8|n[P],p+=8;p>t;)p-=t,d+=e[l&m>>p];if(p&&(d+=e[l&m<<t-p]),a)for(;d.length*t&7;)d+="=";return d})(l,a,t),decode:l=>((n,e,t,a)=>{const l={};for(let T=0;T<e.length;++T)l[e[T]]=T;let d=n.length;for(;"="===n[d-1];)--d;const p=new Uint8Array(d*t/8|0);let m=0,P=0,S=0;for(let T=0;T<d;++T){const D=l[n[T]];if(void 0===D)throw new SyntaxError(`Non-${a} character`);P=P<<t|D,m+=t,m>=8&&(m-=8,p[S++]=255&P>>m)}if(m>=t||255&P<<8-m)throw new SyntaxError("Unexpected end of data");return p})(l,a,t,n)}),hy=Ki({prefix:"\0",name:"identity",encode:n=>(n=>(new TextDecoder).decode(n))(n),decode:n=>(n=>(new TextEncoder).encode(n))(n)});var py=Object.freeze({__proto__:null,identity:hy});const gy=pt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var _y=Object.freeze({__proto__:null,base2:gy});const yy=pt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var my=Object.freeze({__proto__:null,base8:yy});const vy=Jn({prefix:"9",name:"base10",alphabet:"0123456789"});var by=Object.freeze({__proto__:null,base10:vy});const wy=pt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Ey=pt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Iy=Object.freeze({__proto__:null,base16:wy,base16upper:Ey});const Oy=pt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Sy=pt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),xy=pt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ny=pt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Py=pt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ry=pt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ay=pt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Cy=pt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ty=pt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var jy=Object.freeze({__proto__:null,base32:Oy,base32upper:Sy,base32pad:xy,base32padupper:Ny,base32hex:Py,base32hexupper:Ry,base32hexpad:Ay,base32hexpadupper:Cy,base32z:Ty});const $y=Jn({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Dy=Jn({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Fy=Object.freeze({__proto__:null,base36:$y,base36upper:Dy});const Uy=Jn({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ly=Jn({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ky=Object.freeze({__proto__:null,base58btc:Uy,base58flickr:Ly});const My=pt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qy=pt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),zy=pt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Zy=pt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Vy=Object.freeze({__proto__:null,base64:My,base64pad:qy,base64url:zy,base64urlpad:Zy});const Pu=Array.from("\u{1f680}\u{1fa90}\u2604\u{1f6f0}\u{1f30c}\u{1f311}\u{1f312}\u{1f313}\u{1f314}\u{1f315}\u{1f316}\u{1f317}\u{1f318}\u{1f30d}\u{1f30f}\u{1f30e}\u{1f409}\u2600\u{1f4bb}\u{1f5a5}\u{1f4be}\u{1f4bf}\u{1f602}\u2764\u{1f60d}\u{1f923}\u{1f60a}\u{1f64f}\u{1f495}\u{1f62d}\u{1f618}\u{1f44d}\u{1f605}\u{1f44f}\u{1f601}\u{1f525}\u{1f970}\u{1f494}\u{1f496}\u{1f499}\u{1f622}\u{1f914}\u{1f606}\u{1f644}\u{1f4aa}\u{1f609}\u263a\u{1f44c}\u{1f917}\u{1f49c}\u{1f614}\u{1f60e}\u{1f607}\u{1f339}\u{1f926}\u{1f389}\u{1f49e}\u270c\u2728\u{1f937}\u{1f631}\u{1f60c}\u{1f338}\u{1f64c}\u{1f60b}\u{1f497}\u{1f49a}\u{1f60f}\u{1f49b}\u{1f642}\u{1f493}\u{1f929}\u{1f604}\u{1f600}\u{1f5a4}\u{1f603}\u{1f4af}\u{1f648}\u{1f447}\u{1f3b6}\u{1f612}\u{1f92d}\u2763\u{1f61c}\u{1f48b}\u{1f440}\u{1f62a}\u{1f611}\u{1f4a5}\u{1f64b}\u{1f61e}\u{1f629}\u{1f621}\u{1f92a}\u{1f44a}\u{1f973}\u{1f625}\u{1f924}\u{1f449}\u{1f483}\u{1f633}\u270b\u{1f61a}\u{1f61d}\u{1f634}\u{1f31f}\u{1f62c}\u{1f643}\u{1f340}\u{1f337}\u{1f63b}\u{1f613}\u2b50\u2705\u{1f97a}\u{1f308}\u{1f608}\u{1f918}\u{1f4a6}\u2714\u{1f623}\u{1f3c3}\u{1f490}\u2639\u{1f38a}\u{1f498}\u{1f620}\u261d\u{1f615}\u{1f33a}\u{1f382}\u{1f33b}\u{1f610}\u{1f595}\u{1f49d}\u{1f64a}\u{1f639}\u{1f5e3}\u{1f4ab}\u{1f480}\u{1f451}\u{1f3b5}\u{1f91e}\u{1f61b}\u{1f534}\u{1f624}\u{1f33c}\u{1f62b}\u26bd\u{1f919}\u2615\u{1f3c6}\u{1f92b}\u{1f448}\u{1f62e}\u{1f646}\u{1f37b}\u{1f343}\u{1f436}\u{1f481}\u{1f632}\u{1f33f}\u{1f9e1}\u{1f381}\u26a1\u{1f31e}\u{1f388}\u274c\u270a\u{1f44b}\u{1f630}\u{1f928}\u{1f636}\u{1f91d}\u{1f6b6}\u{1f4b0}\u{1f353}\u{1f4a2}\u{1f91f}\u{1f641}\u{1f6a8}\u{1f4a8}\u{1f92c}\u2708\u{1f380}\u{1f37a}\u{1f913}\u{1f619}\u{1f49f}\u{1f331}\u{1f616}\u{1f476}\u{1f974}\u25b6\u27a1\u2753\u{1f48e}\u{1f4b8}\u2b07\u{1f628}\u{1f31a}\u{1f98b}\u{1f637}\u{1f57a}\u26a0\u{1f645}\u{1f61f}\u{1f635}\u{1f44e}\u{1f932}\u{1f920}\u{1f927}\u{1f4cc}\u{1f535}\u{1f485}\u{1f9d0}\u{1f43e}\u{1f352}\u{1f617}\u{1f911}\u{1f30a}\u{1f92f}\u{1f437}\u260e\u{1f4a7}\u{1f62f}\u{1f486}\u{1f446}\u{1f3a4}\u{1f647}\u{1f351}\u2744\u{1f334}\u{1f4a3}\u{1f438}\u{1f48c}\u{1f4cd}\u{1f940}\u{1f922}\u{1f445}\u{1f4a1}\u{1f4a9}\u{1f450}\u{1f4f8}\u{1f47b}\u{1f910}\u{1f92e}\u{1f3bc}\u{1f975}\u{1f6a9}\u{1f34e}\u{1f34a}\u{1f47c}\u{1f48d}\u{1f4e3}\u{1f942}"),Ky=Pu.reduce((n,e,t)=>(n[t]=e,n),[]),By=Pu.reduce((n,e,t)=>(n[e.codePointAt(0)]=t,n),[]),Gy=Ki({prefix:"\u{1f680}",name:"base256emoji",encode:function(n){return n.reduce((e,t)=>e+Ky[t],"")},decode:function(n){const e=[];for(const t of n){const a=By[t.codePointAt(0)];if(void 0===a)throw new Error(`Non-base256emoji character: ${t}`);e.push(a)}return new Uint8Array(e)}});var Jy=Object.freeze({__proto__:null,base256emoji:Gy}),em=Math.pow(2,31),nm=Math.pow(2,7),im=Math.pow(2,14),sm=Math.pow(2,21),om=Math.pow(2,28),cm=Math.pow(2,35),am=Math.pow(2,42),um=Math.pow(2,49),lm=Math.pow(2,56),fm=Math.pow(2,63),hm={encode:function Au(n,e,t){e=e||[];for(var a=t=t||0;n>=em;)e[t++]=255&n|128,n/=128;for(;-128&n;)e[t++]=255&n|128,n>>>=7;return e[t]=0|n,Au.bytes=t-a+1,e},decode:function Po(n,e){var d,t=0,a=0,l=e=e||0,p=n.length;do{if(l>=p)throw Po.bytes=0,new RangeError("Could not decode varint");d=n[l++],t+=a<28?(127&d)<<a:(127&d)*Math.pow(2,a),a+=7}while(d>=128);return Po.bytes=l-e,t},encodingLength:function(n){return n<nm?1:n<im?2:n<sm?3:n<om?4:n<cm?5:n<am?6:n<um?7:n<lm?8:n<fm?9:10}},Tu=hm;const ju=(n,e,t=0)=>(Tu.encode(n,e,t),e),$u=n=>Tu.encodingLength(n),Ro=(n,e)=>{const t=e.byteLength,a=$u(n),l=a+$u(t),d=new Uint8Array(l+t);return ju(n,d,0),ju(t,d,a),d.set(e,l),new pm(n,t,e,d)};class pm{constructor(e,t,a,l){this.code=e,this.size=t,this.digest=a,this.bytes=l}}const Du=({name:n,code:e,encode:t})=>new gm(n,e,t);class gm{constructor(e,t,a){this.name=e,this.code=t,this.encode=a}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Ro(this.code,t):t.then(a=>Ro(this.code,a))}throw Error("Unknown type, must be binary type")}}const Fu=n=>function(){var e=(0,N.Z)(function*(t){return new Uint8Array(yield crypto.subtle.digest(n,t))});return function(t){return e.apply(this,arguments)}}(),_m=Du({name:"sha2-256",code:18,encode:Fu("SHA-256")}),ym=Du({name:"sha2-512",code:19,encode:Fu("SHA-512")});Object.freeze({__proto__:null,sha256:_m,sha512:ym});const Lu=xu;Object.freeze({__proto__:null,identity:{code:0,name:"identity",encode:Lu,digest:n=>Ro(0,Lu(n))}}),new TextEncoder,new TextDecoder;const ku={...py,..._y,...my,...by,...Iy,...jy,...Fy,...ky,...Vy,...Jy};function Mu(n){return null!=globalThis.Buffer?new Uint8Array(n.buffer,n.byteOffset,n.byteLength):n}function qu(n,e,t,a){return{name:n,prefix:e,encoder:{name:n,prefix:e,encode:t},decoder:{decode:a}}}const zu=qu("utf8","u",n=>"u"+new TextDecoder("utf8").decode(n),n=>(new TextEncoder).encode(n.substring(1))),Ao=qu("ascii","a",n=>{let e="a";for(let t=0;t<n.length;t++)e+=String.fromCharCode(n[t]);return e},n=>{const e=function(n=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?Mu(globalThis.Buffer.allocUnsafe(n)):new Uint8Array(n)}((n=n.substring(1)).length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return e}),Em={utf8:zu,"utf-8":zu,hex:ku.base16,latin1:Ao,ascii:Ao,binary:Ao,...ku},Rr="wc@2:core:",xm={database:":memory:"},Vu="client_ed25519_seed",Pm=L.ONE_DAY,jm=L.SIX_HOURS,Bu="wss://relay.walletconnect.com",Wu="wss://relay.walletconnect.org",Lm=L.ONE_SECOND/2,cr_created="subscription_created",cr_deleted="subscription_deleted",Km=1e3*L.FIVE_SECONDS,Qn={wc_pairingDelete:{req:{ttl:L.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:L.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:L.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:L.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:L.ONE_DAY,prompt:!1,tag:0},res:{ttl:L.ONE_DAY,prompt:!1,tag:0}}},Mt_expired="expirer_expired",To="verify-api",Hu="https://verify.walletconnect.com";class Qm{constructor(e,t){var a=this;this.core=e,this.logger=t,this.keychain=new Map,this.name="keychain",this.version="0.3",this.initialized=!1,this.storagePrefix=Rr,this.init=(0,N.Z)(function*(){if(!a.initialized){const l=yield a.getKeyChain();typeof l<"u"&&(a.keychain=l),a.initialized=!0}}),this.has=l=>(this.isInitialized(),this.keychain.has(l)),this.set=function(){var l=(0,N.Z)(function*(d,p){a.isInitialized(),a.keychain.set(d,p),yield a.persist()});return function(d,p){return l.apply(this,arguments)}}(),this.get=l=>{this.isInitialized();const d=this.keychain.get(l);if(typeof d>"u"){const{message:p}=ee("NO_MATCHING_KEY",`${this.name}: ${l}`);throw new Error(p)}return d},this.del=function(){var l=(0,N.Z)(function*(d){a.isInitialized(),a.keychain.delete(d),yield a.persist()});return function(d){return l.apply(this,arguments)}}(),this.core=e,this.logger=Tt(t,this.name)}get context(){return St(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}setKeyChain(e){var t=this;return(0,N.Z)(function*(){yield t.core.storage.setItem(t.storageKey,uu(e))})()}getKeyChain(){var e=this;return(0,N.Z)(function*(){const t=yield e.core.storage.getItem(e.storageKey);return typeof t<"u"?lu(t):void 0})()}persist(){var e=this;return(0,N.Z)(function*(){yield e.setKeyChain(e.keychain)})()}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}}class Xm{constructor(e,t,a){var l=this;this.core=e,this.logger=t,this.name="crypto",this.initialized=!1,this.init=(0,N.Z)(function*(){l.initialized||(yield l.keychain.init(),l.initialized=!0)}),this.hasKeys=d=>(this.isInitialized(),this.keychain.has(d)),this.getClientId=(0,N.Z)(function*(){l.isInitialized();const d=yield l.getClientSeed(),p=Di.generateKeyPair(d);return Di.encodeIss(p.publicKey)}),this.generateKeyPair=()=>{this.isInitialized();const d=function(){const n=ot.Au();return{privateKey:(0,ye.BB)(n.secretKey,vt),publicKey:(0,ye.BB)(n.publicKey,vt)}}();return this.setPrivateKey(d.publicKey,d.privateKey)},this.signJWT=function(){var d=(0,N.Z)(function*(p){l.isInitialized();const m=yield l.getClientSeed(),P=Di.generateKeyPair(m),S=bo(),T=Pm;return yield Di.signJWT(S,p,T,P)});return function(p){return d.apply(this,arguments)}}(),this.generateSharedKey=(d,p,m)=>{this.isInitialized();const S=function(n,e){const t=ot.gi((0,ye.mL)(n,vt),(0,ye.mL)(e,vt)),a=new Te.t(Ye.mE,t).expand(32);return(0,ye.BB)(a,vt)}(this.getPrivateKey(d),p);return this.setSymKey(S,m)},this.setSymKey=function(){var d=(0,N.Z)(function*(p,m){l.isInitialized();const P=m||function(n){const e=(0,Ye.vp)((0,ye.mL)(n,vt));return(0,ye.BB)(e,vt)}(p);return yield l.keychain.set(P,p),P});return function(p,m){return d.apply(this,arguments)}}(),this.deleteKeyPair=function(){var d=(0,N.Z)(function*(p){l.isInitialized(),yield l.keychain.del(p)});return function(p){return d.apply(this,arguments)}}(),this.deleteSymKey=function(){var d=(0,N.Z)(function*(p){l.isInitialized(),yield l.keychain.del(p)});return function(p){return d.apply(this,arguments)}}(),this.encode=function(){var d=(0,N.Z)(function*(p,m,P){l.isInitialized();const S=ru(P),T=function(n){return"string"==typeof n?n:(n=>JSON.stringify(n,(e,t)=>"bigint"==typeof t?t.toString()+"n":t))(n)||""}(m);if(nu(S)){const B=S.senderPublicKey,Y=S.receiverPublicKey;p=yield l.generateSharedKey(B,Y)}const D=l.getSymKey(p),{type:Q,senderPublicKey:se}=S;return function(n){const e=function(n){return(0,ye.mL)(`${n}`,"base10")}(typeof n.type<"u"?n.type:0);if(1===Hn(e)&&typeof n.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const t=typeof n.senderPublicKey<"u"?(0,ye.mL)(n.senderPublicKey,vt):void 0,a=typeof n.iv<"u"?(0,ye.mL)(n.iv,vt):(0,We.randomBytes)(12);return function(n){if(1===Hn(n.type)){if(typeof n.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return(0,ye.BB)((0,ye.zo)([n.type,n.senderPublicKey,n.iv,n.sealed]),_o)}return(0,ye.BB)((0,ye.zo)([n.type,n.iv,n.sealed]),_o)}({type:e,sealed:new Ve.OK((0,ye.mL)(n.symKey,vt)).seal(a,(0,ye.mL)(n.message,yo)),iv:a,senderPublicKey:t})}({type:Q,symKey:D,message:T,senderPublicKey:se})});return function(p,m,P){return d.apply(this,arguments)}}(),this.decode=function(){var d=(0,N.Z)(function*(p,m,P){l.isInitialized();const S=function(n,e){const t=ki(n);return ru({type:Hn(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?(0,ye.BB)(t.senderPublicKey,vt):void 0,receiverPublicKey:e?.receiverPublicKey})}(m,P);if(nu(S)){const T=S.receiverPublicKey,D=S.senderPublicKey;p=yield l.generateSharedKey(T,D)}try{const D=function(n){const e=new Ve.OK((0,ye.mL)(n.symKey,vt)),{sealed:t,iv:a}=ki(n.encoded),l=e.open(a,t);if(null===l)throw new Error("Failed to decrypt");return(0,ye.BB)(l,yo)}({symKey:l.getSymKey(p),encoded:m});return function(n){if("string"!=typeof n)throw new Error("Cannot safe json parse value of type "+typeof n);try{return(n=>{const t=n.replace(/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,'$1"$2n"$3');return JSON.parse(t,(a,l)=>"string"==typeof l&&l.match(/^\d+n$/)?BigInt(l.substring(0,l.length-1)):l)})(n)}catch{return n}}(D)}catch(T){l.logger.error(`Failed to decode message from topic: '${p}', clientId: '${yield l.getClientId()}'`),l.logger.error(T)}});return function(p,m,P){return d.apply(this,arguments)}}(),this.getPayloadType=d=>Hn(ki(d).type),this.getPayloadSenderPublicKey=d=>{const p=ki(d);return p.senderPublicKey?(0,ye.BB)(p.senderPublicKey,vt):void 0},this.core=e,this.logger=Tt(t,this.name),this.keychain=a||new Qm(this.core,this.logger)}get context(){return St(this.logger)}setPrivateKey(e,t){var a=this;return(0,N.Z)(function*(){return yield a.keychain.set(e,t),e})()}getPrivateKey(e){return this.keychain.get(e)}getClientSeed(){var e=this;return(0,N.Z)(function*(){let t="";try{t=e.keychain.get(Vu)}catch{t=bo(),yield e.keychain.set(Vu,t)}return function(n,e="utf8"){const t=Em[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return"utf8"!==e&&"utf-8"!==e||null==globalThis.Buffer||null==globalThis.Buffer.from?t.decoder.decode(`${t.prefix}${n}`):Mu(globalThis.Buffer.from(n,"utf-8"))}(t,"base16")})()}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}}class ev extends class{constructor(e,t){this.logger=e,this.core=t}}{constructor(e,t){var a;super(e,t),a=this,this.logger=e,this.core=t,this.messages=new Map,this.name="messages",this.version="0.3",this.initialized=!1,this.storagePrefix=Rr,this.init=(0,N.Z)(function*(){if(!a.initialized){a.logger.trace("Initialized");try{const l=yield a.getRelayerMessages();typeof l<"u"&&(a.messages=l),a.logger.debug(`Successfully Restored records for ${a.name}`),a.logger.trace({type:"method",method:"restore",size:a.messages.size})}catch(l){a.logger.debug(`Failed to Restore records for ${a.name}`),a.logger.error(l)}finally{a.initialized=!0}}}),this.set=function(){var l=(0,N.Z)(function*(d,p){a.isInitialized();const m=In(p);let P=a.messages.get(d);return typeof P>"u"&&(P={}),typeof P[m]<"u"||(P[m]=p,a.messages.set(d,P),yield a.persist()),m});return function(d,p){return l.apply(this,arguments)}}(),this.get=l=>{this.isInitialized();let d=this.messages.get(l);return typeof d>"u"&&(d={}),d},this.has=(l,d)=>(this.isInitialized(),typeof this.get(l)[In(d)]<"u"),this.del=function(){var l=(0,N.Z)(function*(d){a.isInitialized(),a.messages.delete(d),yield a.persist()});return function(d){return l.apply(this,arguments)}}(),this.logger=Tt(e,this.name),this.core=t}get context(){return St(this.logger)}get storageKey(){return this.storagePrefix+this.version+"//"+this.name}setRelayerMessages(e){var t=this;return(0,N.Z)(function*(){yield t.core.storage.setItem(t.storageKey,uu(e))})()}getRelayerMessages(){var e=this;return(0,N.Z)(function*(){const t=yield e.core.storage.getItem(e.storageKey);return typeof t<"u"?lu(t):void 0})()}persist(){var e=this;return(0,N.Z)(function*(){yield e.setRelayerMessages(e.messages)})()}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}}class tv extends Bp{constructor(e,t){var a;super(e,t),a=this,this.relayer=e,this.logger=t,this.events=new Le.EventEmitter,this.name="publisher",this.queue=new Map,this.publishTimeout=(0,L.toMiliseconds)(L.TEN_SECONDS),this.queueTimeout=(0,L.toMiliseconds)(L.FIVE_SECONDS),this.needsTransportRestart=!1,this.publish=function(){var l=(0,N.Z)(function*(d,p,m){a.logger.debug("Publishing Payload"),a.logger.trace({type:"method",method:"publish",params:{topic:d,message:p,opts:m}});try{const P=m?.ttl||jm,S=So(m),T=m?.prompt||!1,D=m?.tag||0,Q=m?.id||(0,xe.getBigIntRpcId)().toString(),se={topic:d,message:p,opts:{ttl:P,relay:S,prompt:T,tag:D,id:Q}},B=setTimeout(()=>a.queue.set(Q,se),a.queueTimeout);try{yield yield qi(a.rpcPublish(d,p,P,S,T,D,Q),a.publishTimeout),clearTimeout(B),a.relayer.events.emit("relayer_publish",se)}catch{return a.logger.debug("Publishing Payload stalled"),void(a.needsTransportRestart=!0)}a.logger.debug("Successfully Published Payload"),a.logger.trace({type:"method",method:"publish",params:{topic:d,message:p,opts:m}})}catch(P){throw a.logger.debug("Failed to Publish Payload"),a.logger.error(P),P}});return function(d,p,m){return l.apply(this,arguments)}}(),this.on=(l,d)=>{this.events.on(l,d)},this.once=(l,d)=>{this.events.once(l,d)},this.off=(l,d)=>{this.events.off(l,d)},this.removeListener=(l,d)=>{this.events.removeListener(l,d)},this.relayer=e,this.logger=Tt(t,this.name),this.registerEventListeners()}get context(){return St(this.logger)}rpcPublish(e,t,a,l,d,p,m){var P,S,T,D;const Q={method:zi(l.protocol).publish,params:{topic:e,message:t,ttl:a,prompt:d,tag:p},id:m};return bt(null==(P=Q.params)?void 0:P.prompt)&&(null==(S=Q.params)||delete S.prompt),bt(null==(T=Q.params)?void 0:T.tag)&&(null==(D=Q.params)||delete D.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:Q}),this.relayer.request(Q)}onPublish(e){this.queue.delete(e)}checkQueue(){var e=this;this.queue.forEach(function(){var t=(0,N.Z)(function*(a){const{topic:l,message:d,opts:p}=a;yield e.publish(l,d,p)});return function(a){return t.apply(this,arguments)}}())}registerEventListeners(){this.relayer.core.heartbeat.on(Bn.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit("relayer_connection_stalled");this.checkQueue()}),this.relayer.on("relayer_message_ack",e=>{this.onPublish(e.id.toString())})}}class rv{constructor(){this.map=new Map,this.set=(e,t)=>{const a=this.get(e);this.exists(e,t)||this.map.set(e,[...a,t])},this.get=e=>this.map.get(e)||[],this.exists=(e,t)=>this.get(e).includes(t),this.delete=(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const a=this.get(e);if(!this.exists(e,t))return;const l=a.filter(d=>d!==t);l.length?this.map.set(e,l):this.map.delete(e)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var nv=Object.defineProperty,iv=Object.defineProperties,sv=Object.getOwnPropertyDescriptors,Gu=Object.getOwnPropertySymbols,ov=Object.prototype.hasOwnProperty,cv=Object.prototype.propertyIsEnumerable,Ju=(n,e,t)=>e in n?nv(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,Xn=(n,e)=>{for(var t in e||(e={}))ov.call(e,t)&&Ju(n,t,e[t]);if(Gu)for(var t of Gu(e))cv.call(e,t)&&Ju(n,t,e[t]);return n},jo=(n,e)=>iv(n,sv(e));class av extends Gp{constructor(e,t){var a;super(e,t),a=this,this.relayer=e,this.logger=t,this.subscriptions=new Map,this.topicMap=new rv,this.events=new Le.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=Rr,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=(0,N.Z)(function*(){a.initialized||(a.logger.trace("Initialized"),yield a.restart(),a.registerEventListeners(),a.onEnable(),a.clientId=yield a.relayer.core.crypto.getClientId())}),this.subscribe=function(){var l=(0,N.Z)(function*(d,p){yield a.restartToComplete(),a.isInitialized(),a.logger.debug("Subscribing Topic"),a.logger.trace({type:"method",method:"subscribe",params:{topic:d,opts:p}});try{const m=So(p),P={topic:d,relay:m};a.pending.set(d,P);const S=yield a.rpcSubscribe(d,m);return a.onSubscribe(S,P),a.logger.debug("Successfully Subscribed Topic"),a.logger.trace({type:"method",method:"subscribe",params:{topic:d,opts:p}}),S}catch(m){throw a.logger.debug("Failed to Subscribe Topic"),a.logger.error(m),m}});return function(d,p){return l.apply(this,arguments)}}(),this.unsubscribe=function(){var l=(0,N.Z)(function*(d,p){yield a.restartToComplete(),a.isInitialized(),typeof p?.id<"u"?yield a.unsubscribeById(d,p.id,p):yield a.unsubscribeByTopic(d,p)});return function(d,p){return l.apply(this,arguments)}}(),this.isSubscribed=function(){var l=(0,N.Z)(function*(d){return!!a.topics.includes(d)||(yield new Promise((p,m)=>{const P=new L.Watch;P.start(a.pendingSubscriptionWatchLabel);const S=setInterval(()=>{!a.pending.has(d)&&a.topics.includes(d)&&(clearInterval(S),P.stop(a.pendingSubscriptionWatchLabel),p(!0)),P.elapsed(a.pendingSubscriptionWatchLabel)>=Km&&(clearInterval(S),P.stop(a.pendingSubscriptionWatchLabel),m(new Error("Subscription resolution timeout")))},a.pollingInterval)}).catch(()=>!1))});return function(d){return l.apply(this,arguments)}}(),this.on=(l,d)=>{this.events.on(l,d)},this.once=(l,d)=>{this.events.once(l,d)},this.off=(l,d)=>{this.events.off(l,d)},this.removeListener=(l,d)=>{this.events.removeListener(l,d)},this.restart=(0,N.Z)(function*(){a.restartInProgress=!0,yield a.restore(),yield a.reset(),a.restartInProgress=!1}),this.relayer=e,this.logger=Tt(t,this.name),this.clientId=""}get context(){return St(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 a=!1;try{a=this.getSubscription(e).topic===t}catch{}return a}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}unsubscribeByTopic(e,t){var a=this;return(0,N.Z)(function*(){const l=a.topicMap.get(e);yield Promise.all(l.map(function(){var d=(0,N.Z)(function*(p){return yield a.unsubscribeById(e,p,t)});return function(p){return d.apply(this,arguments)}}()))})()}unsubscribeById(e,t,a){var l=this;return(0,N.Z)(function*(){l.logger.debug("Unsubscribing Topic"),l.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:a}});try{const d=So(a);yield l.rpcUnsubscribe(e,t,d);const p=lt("USER_DISCONNECTED",`${l.name}, ${e}`);yield l.onUnsubscribe(e,t,p),l.logger.debug("Successfully Unsubscribed Topic"),l.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:a}})}catch(d){throw l.logger.debug("Failed to Unsubscribe Topic"),l.logger.error(d),d}})()}rpcSubscribe(e,t){var a=this;return(0,N.Z)(function*(){const l={method:zi(t.protocol).subscribe,params:{topic:e}};a.logger.debug("Outgoing Relay Payload"),a.logger.trace({type:"payload",direction:"outgoing",request:l});try{yield yield qi(a.relayer.request(l),a.subscribeTimeout)}catch{a.logger.debug("Outgoing Relay Subscribe Payload stalled"),a.relayer.events.emit("relayer_connection_stalled")}return In(e+a.clientId)})()}rpcBatchSubscribe(e){var t=this;return(0,N.Z)(function*(){if(!e.length)return;const l={method:zi(e[0].relay.protocol).batchSubscribe,params:{topics:e.map(d=>d.topic)}};t.logger.debug("Outgoing Relay Payload"),t.logger.trace({type:"payload",direction:"outgoing",request:l});try{return yield yield qi(t.relayer.request(l),t.subscribeTimeout)}catch{t.logger.debug("Outgoing Relay Payload stalled"),t.relayer.events.emit("relayer_connection_stalled")}})()}rpcUnsubscribe(e,t,a){const l={method:zi(a.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:l}),this.relayer.request(l)}onSubscribe(e,t){this.setSubscription(e,jo(Xn({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,Xn({},t)),this.pending.delete(t.topic)})}onUnsubscribe(e,t,a){var l=this;return(0,N.Z)(function*(){l.events.removeAllListeners(t),l.hasSubscription(t,e)&&l.deleteSubscription(t,a),yield l.relayer.messages.del(e)})()}setRelayerSubscriptions(e){var t=this;return(0,N.Z)(function*(){yield t.relayer.core.storage.setItem(t.storageKey,e)})()}getRelayerSubscriptions(){var e=this;return(0,N.Z)(function*(){return yield e.relayer.core.storage.getItem(e.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,Xn({},t)),this.topicMap.set(t.topic,e),this.events.emit(cr_created,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:a}=ee("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(a)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const a=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(a.topic,e),this.events.emit(cr_deleted,jo(Xn({},a),{reason:t}))}persist(){var e=this;return(0,N.Z)(function*(){yield e.setRelayerSubscriptions(e.values),e.events.emit("subscription_sync")})()}reset(){var e=this;return(0,N.Z)(function*(){if(e.cached.length){const t=Math.ceil(e.cached.length/e.batchSubscribeTopicsLimit);for(let a=0;a<t;a++){const l=e.cached.splice(0,e.batchSubscribeTopicsLimit);yield e.batchSubscribe(l)}}e.events.emit("subscription_resubscribed")})()}restore(){var e=this;return(0,N.Z)(function*(){try{const t=yield e.getRelayerSubscriptions();if(typeof t>"u"||!t.length)return;if(e.subscriptions.size){const{message:a}=ee("RESTORE_WILL_OVERRIDE",e.name);throw e.logger.error(a),e.logger.error(`${e.name}: ${JSON.stringify(e.values)}`),new Error(a)}e.cached=t,e.logger.debug(`Successfully Restored subscriptions for ${e.name}`),e.logger.trace({type:"method",method:"restore",subscriptions:e.values})}catch(t){e.logger.debug(`Failed to Restore subscriptions for ${e.name}`),e.logger.error(t)}})()}batchSubscribe(e){var t=this;return(0,N.Z)(function*(){if(!e.length)return;const a=yield t.rpcBatchSubscribe(e);Gn(a)&&t.onBatchSubscribe(a.map((l,d)=>jo(Xn({},e[d]),{id:l})))})()}onConnect(){var e=this;return(0,N.Z)(function*(){e.restartInProgress||(yield e.restart(),e.onEnable())})()}onDisconnect(){this.onDisable()}checkPending(){var e=this;return(0,N.Z)(function*(){if(e.relayer.transportExplicitlyClosed)return;const t=[];e.pending.forEach(a=>{t.push(a)}),yield e.batchSubscribe(t)})()}registerEventListeners(){var e=this;this.relayer.core.heartbeat.on(Bn.HEARTBEAT_EVENTS.pulse,(0,N.Z)(function*(){yield e.checkPending()})),this.relayer.on("relayer_connect",(0,N.Z)(function*(){yield e.onConnect()})),this.relayer.on("relayer_disconnect",()=>{this.onDisconnect()}),this.events.on(cr_created,function(){var t=(0,N.Z)(function*(a){const l=cr_created;e.logger.info(`Emitting ${l}`),e.logger.debug({type:"event",event:l,data:a}),yield e.persist()});return function(a){return t.apply(this,arguments)}}()),this.events.on(cr_deleted,function(){var t=(0,N.Z)(function*(a){const l=cr_deleted;e.logger.info(`Emitting ${l}`),e.logger.debug({type:"event",event:l,data:a}),yield e.persist()});return function(a){return t.apply(this,arguments)}}())}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}restartToComplete(){var e=this;return(0,N.Z)(function*(){e.restartInProgress&&(yield new Promise(t=>{const a=setInterval(()=>{e.restartInProgress||(clearInterval(a),t())},e.pollingInterval)}))})()}}var uv=Object.defineProperty,Yu=Object.getOwnPropertySymbols,lv=Object.prototype.hasOwnProperty,fv=Object.prototype.propertyIsEnumerable,Qu=(n,e,t)=>e in n?uv(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;class hv extends Wp{constructor(e){var t;super(e),t=this,this.protocol="wc",this.version=2,this.events=new Le.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=function(){var a=(0,N.Z)(function*(l){t.logger.debug("Publishing Request Payload");try{return yield t.toEstablishConnection(),yield t.provider.request(l)}catch(d){throw t.logger.debug("Failed to Publish Request"),t.logger.error(d),d}});return function(l){return a.apply(this,arguments)}}(),this.core=e.core,this.logger=typeof e.logger<"u"&&"string"!=typeof e.logger?Tt(e.logger,this.name):Ti()(ho({level:e.logger||"error"})),this.messages=new ev(this.logger,e.core),this.subscriber=new av(this,this.logger),this.publisher=new tv(this,this.logger),this.relayUrl=e?.relayUrl||Bu,this.projectId=e.projectId,this.provider={}}init(){var e=this;return(0,N.Z)(function*(){e.logger.trace("Initialized"),yield e.createProvider(),yield Promise.all([e.messages.init(),e.subscriber.init()]);try{yield e.transportOpen()}catch{e.logger.warn(`Connection via ${e.relayUrl} failed, attempting to connect via failover domain ${Wu}...`),yield e.restartTransport(Wu)}e.registerEventListeners(),e.initialized=!0,setTimeout((0,N.Z)(function*(){0===e.subscriber.topics.length&&(e.logger.info("No topics subscribed to after init, closing transport"),yield e.transportClose(),e.transportExplicitlyClosed=!1)}),1e4)})()}get context(){return St(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}publish(e,t,a){var l=this;return(0,N.Z)(function*(){l.isInitialized(),yield l.publisher.publish(e,t,a),yield l.recordMessageEvent({topic:e,message:t,publishedAt:Date.now()})})()}subscribe(e,t){var a=this;return(0,N.Z)(function*(){var l;a.isInitialized();let d=(null==(l=a.subscriber.topicMap.get(e))?void 0:l[0])||"";return d||(yield Promise.all([new Promise(p=>{a.subscriber.once(cr_created,m=>{m.topic===e&&p()})}),new Promise(function(){var p=(0,N.Z)(function*(m){d=yield a.subscriber.subscribe(e,t),m()});return function(m){return p.apply(this,arguments)}}())]),d)})()}unsubscribe(e,t){var a=this;return(0,N.Z)(function*(){a.isInitialized(),yield a.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)}transportClose(){var e=this;return(0,N.Z)(function*(){e.transportExplicitlyClosed=!0,e.connected&&(yield e.provider.disconnect(),e.events.emit("relayer_transport_closed"))})()}transportOpen(e){var t=this;return(0,N.Z)(function*(){if(t.transportExplicitlyClosed=!1,!t.reconnecting){t.relayUrl=e||t.relayUrl,t.reconnecting=!0;try{yield Promise.all([new Promise(a=>{t.initialized||a(),t.subscriber.once("subscription_resubscribed",()=>{a()})}),yield Promise.race([new Promise(function(){var a=(0,N.Z)(function*(l,d){yield qi(t.provider.connect(),1e4,`Socket stalled when trying to connect to ${t.relayUrl}`).catch(p=>d(p)).then(()=>l()).finally(()=>t.removeListener("relayer_transport_closed",t.rejectTransportOpen))});return function(l,d){return a.apply(this,arguments)}}()),new Promise(a=>t.once("relayer_transport_closed",t.rejectTransportOpen))])])}catch(a){if(t.logger.error(a),!t.isConnectionStalled(a.message))throw a;t.events.emit("relayer_transport_closed")}finally{t.reconnecting=!1}}})()}restartTransport(e){var t=this;return(0,N.Z)(function*(){t.transportExplicitlyClosed||t.reconnecting||(t.relayUrl=e||t.relayUrl,t.connected&&(yield Promise.all([new Promise(a=>{t.provider.once("disconnect",()=>{a()})}),t.transportClose()])),yield t.createProvider(),yield t.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...")}createProvider(){var e=this;return(0,N.Z)(function*(){const t=yield e.core.crypto.signJWT(e.relayUrl);e.provider=new Pr.r(new class{constructor(e){if(this.url=e,this.events=new Le.EventEmitter,this.registering=!1,!(0,xe.isWsUrl)(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return void 0!==this.socket}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}open(e=this.url){var t=this;return(0,N.Z)(function*(){yield t.register(e)})()}close(){var e=this;return(0,N.Z)(function*(){return new Promise((t,a)=>{void 0!==e.socket?(e.socket.onclose=l=>{e.onClose(l),t()},e.socket.close()):a(new Error("Connection already closed"))})})()}send(e,t){var a=this;return(0,N.Z)(function*(){void 0===a.socket&&(a.socket=yield a.register());try{a.socket.send(function(n){return"string"==typeof n?n:(n=>JSON.stringify(n,(e,t)=>"bigint"==typeof t?t.toString()+"n":t))(n)||""}(e))}catch(l){a.onError(e.id,l)}})()}register(e=this.url){if(!(0,xe.isWsUrl)(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((a,l)=>{this.events.once("register_error",d=>{this.resetMaxListeners(),l(d)}),this.events.once("open",()=>{if(this.resetMaxListeners(),void 0===this.socket)return l(new Error("WebSocket connection is missing or invalid"));a(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,a)=>{const l=(0,xe.isReactNative)()?void 0:{rejectUnauthorized:!(0,xe.isLocalhostUrl)(e)},d=new Y_(e,[],l);"undefined"!=typeof WebSocket||"undefined"!=typeof global&&void 0!==global.WebSocket||"undefined"!=typeof window&&void 0!==window.WebSocket||"undefined"!=typeof self&&void 0!==self.WebSocket?d.onerror=p=>{a(this.emitError(p.error))}:d.on("error",p=>{a(this.emitError(p))}),d.onopen=()=>{this.onOpen(d),t(d)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(void 0===e.data)return;const t="string"==typeof e.data?function(n){if("string"!=typeof n)throw new Error("Cannot safe json parse value of type "+typeof n);try{return(n=>{const t=n.replace(/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,'$1"$2n"$3');return JSON.parse(t,(a,l)=>"string"==typeof l&&l.match(/^\d+n$/)?BigInt(l.substring(0,l.length-1)):l)})(n)}catch{return n}}(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const a=this.parseError(t),l=a.message||a.toString(),d=(0,xe.formatJsonRpcError)(e,l);this.events.emit("payload",d)}parseError(e,t=this.url){return(0,xe.CX)(e,Ou(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>10&&this.events.setMaxListeners(10)}emitError(e){const t=this.parseError(new Error((null==e?void 0:e.message)||`WebSocket connection failed for host: ${Ou(this.url)}`));return this.events.emit("register_error",t),t}}(function({protocol:n,version:e,relayUrl:t,sdkVersion:a,auth:l,projectId:d,useOnCloseEvent:p}){const m=t.split("?"),P=Vg(n,e,a),T=function(n,e){let t=Ui.parse(n);return t=ou(ou({},t),e),Ui.stringify(t)}(m[1]||"",{auth:l,ua:P,projectId:d,useOnCloseEvent:p||void 0});return m[0]+"?"+T}({sdkVersion:"2.9.1",protocol:e.protocol,version:e.version,relayUrl:e.relayUrl,projectId:e.projectId,auth:t,useOnCloseEvent:!0}))),e.registerProviderListeners()})()}recordMessageEvent(e){var t=this;return(0,N.Z)(function*(){const{topic:a,message:l}=e;yield t.messages.set(a,l)})()}shouldIgnoreMessageEvent(e){var t=this;return(0,N.Z)(function*(){const{topic:a,message:l}=e;if(!l||0===l.length)return t.logger.debug(`Ignoring invalid/empty message: ${l}`),!0;if(!(yield t.subscriber.isSubscribed(a)))return t.logger.debug(`Ignoring message for non-subscribed topic ${a}`),!0;const d=t.messages.has(a,l);return d&&t.logger.debug(`Ignoring duplicate message: ${l}`),d})()}onProviderPayload(e){var t=this;return(0,N.Z)(function*(){if(t.logger.debug("Incoming Relay Payload"),t.logger.trace({type:"payload",direction:"incoming",payload:e}),(0,xe.isJsonRpcRequest)(e)){if(!e.method.endsWith("_subscription"))return;const a=e.params,{topic:l,message:d,publishedAt:p}=a.data,m={topic:l,message:d,publishedAt:p};t.logger.debug("Emitting Relayer Payload"),t.logger.trace(((n,e)=>{for(var t in e||(e={}))lv.call(e,t)&&Qu(n,t,e[t]);if(Yu)for(var t of Yu(e))fv.call(e,t)&&Qu(n,t,e[t]);return n})({type:"event",event:a.id},m)),t.events.emit(a.id,m),yield t.acknowledgePayload(e),yield t.onMessageEvent(m)}else(0,xe.isJsonRpcResponse)(e)&&t.events.emit("relayer_message_ack",e)})()}onMessageEvent(e){var t=this;return(0,N.Z)(function*(){(yield t.shouldIgnoreMessageEvent(e))||(t.events.emit("relayer_message",e),yield t.recordMessageEvent(e))})()}acknowledgePayload(e){var t=this;return(0,N.Z)(function*(){const a=(0,xe.formatJsonRpcResult)(e.id,!0);yield t.provider.connection.send(a)})()}registerProviderListeners(){this.provider.on("payload",e=>this.onProviderPayload(e)),this.provider.on("connect",()=>{this.events.emit("relayer_connect")}),this.provider.on("disconnect",()=>{this.onProviderDisconnect()}),this.provider.on("error",e=>{this.logger.error(e),this.events.emit("relayer_error",e)})}registerEventListeners(){var e=this;this.events.on("relayer_connection_stalled",(0,N.Z)(function*(){yield e.restartTransport()}))}onProviderDisconnect(){this.events.emit("relayer_disconnect"),this.attemptToReconnect()}attemptToReconnect(){var e=this;this.transportExplicitlyClosed||setTimeout((0,N.Z)(function*(){yield e.restartTransport()}),(0,L.toMiliseconds)(Lm))}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}toEstablishConnection(){var e=this;return(0,N.Z)(function*(){if(!e.connected){if(e.connecting)return yield new Promise(t=>{const a=setInterval(()=>{e.connected&&(clearInterval(a),t())},e.connectionStatusPollingInterval)});yield e.restartTransport()}})()}}var pv=Object.defineProperty,Xu=Object.getOwnPropertySymbols,gv=Object.prototype.hasOwnProperty,_v=Object.prototype.propertyIsEnumerable,el=(n,e,t)=>e in n?pv(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,tl=(n,e)=>{for(var t in e||(e={}))gv.call(e,t)&&el(n,t,e[t]);if(Xu)for(var t of Xu(e))_v.call(e,t)&&el(n,t,e[t]);return n};class Bi extends class{constructor(e,t,a,l){this.core=e,this.logger=t,this.name=a}}{constructor(e,t,a,l=Rr,d){var p;super(e,t,a,l),p=this,this.core=e,this.logger=t,this.name=a,this.map=new Map,this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Rr,this.init=(0,N.Z)(function*(){p.initialized||(p.logger.trace("Initialized"),yield p.restore(),p.cached.forEach(m=>{p.getKey&&null!==m&&!bt(m)?p.map.set(p.getKey(m),m):function(n){var e;return null==(e=n?.proposer)?void 0:e.publicKey}(m)?p.map.set(m.id,m):m?.topic&&p.map.set(m.topic,m)}),p.cached=[],p.initialized=!0)}),this.set=function(){var m=(0,N.Z)(function*(P,S){p.isInitialized(),p.map.has(P)?yield p.update(P,S):(p.logger.debug("Setting value"),p.logger.trace({type:"method",method:"set",key:P,value:S}),p.map.set(P,S),yield p.persist())});return function(P,S){return m.apply(this,arguments)}}(),this.get=m=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:m}),this.getData(m)),this.getAll=m=>(this.isInitialized(),m?this.values.filter(P=>Object.keys(m).every(S=>ty()(P[S],m[S]))):this.values),this.update=function(){var m=(0,N.Z)(function*(P,S){p.isInitialized(),p.logger.debug("Updating value"),p.logger.trace({type:"method",method:"update",key:P,update:S});const T=tl(tl({},p.getData(P)),S);p.map.set(P,T),yield p.persist()});return function(P,S){return m.apply(this,arguments)}}(),this.delete=function(){var m=(0,N.Z)(function*(P,S){p.isInitialized(),p.map.has(P)&&(p.logger.debug("Deleting value"),p.logger.trace({type:"method",method:"delete",key:P,reason:S}),p.map.delete(P),yield p.persist())});return function(P,S){return m.apply(this,arguments)}}(),this.logger=Tt(t,this.name),this.storagePrefix=l,this.getKey=d}get context(){return St(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())}setDataStore(e){var t=this;return(0,N.Z)(function*(){yield t.core.storage.setItem(t.storageKey,e)})()}getDataStore(){var e=this;return(0,N.Z)(function*(){return yield e.core.storage.getItem(e.storageKey)})()}getData(e){const t=this.map.get(e);if(!t){const{message:a}=ee("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(a),new Error(a)}return t}persist(){var e=this;return(0,N.Z)(function*(){yield e.setDataStore(e.values)})()}restore(){var e=this;return(0,N.Z)(function*(){try{const t=yield e.getDataStore();if(typeof t>"u"||!t.length)return;if(e.map.size){const{message:a}=ee("RESTORE_WILL_OVERRIDE",e.name);throw e.logger.error(a),new Error(a)}e.cached=t,e.logger.debug(`Successfully Restored value for ${e.name}`),e.logger.trace({type:"method",method:"restore",value:e.values})}catch(t){e.logger.debug(`Failed to Restore value for ${e.name}`),e.logger.error(t)}})()}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}}class yv{constructor(e,t){var a=this;this.core=e,this.logger=t,this.name="pairing",this.version="0.3",this.events=new(Je()),this.initialized=!1,this.storagePrefix=Rr,this.ignoredPayloadTypes=[1],this.registeredMethods=[],this.init=(0,N.Z)(function*(){a.initialized||(yield a.pairings.init(),yield a.cleanup(),a.registerRelayerEvents(),a.registerExpirerEvents(),a.initialized=!0,a.logger.trace("Initialized"))}),this.register=({methods:l})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...l])]},this.create=(0,N.Z)(function*(){a.isInitialized();const l=bo(),d=yield a.core.crypto.setSymKey(l),p=Xt(L.FIVE_MINUTES),m={protocol:"irn"},P={topic:d,expiry:p,relay:m,active:!1},S=function(n){return`${n.protocol}:${n.topic}@${n.version}?`+Ui.stringify(((n,e)=>{for(var t in e||(e={}))e_.call(e,t)&&pu(n,t,e[t]);if(hu)for(var t of hu(e))t_.call(e,t)&&pu(n,t,e[t]);return n})({symKey:n.symKey},function(n,e="-"){const a={};return Object.keys(n).forEach(l=>{n[l]&&(a["relay"+e+l]=n[l])}),a}(n.relay)))}({protocol:a.core.protocol,version:a.core.version,topic:d,symKey:l,relay:m});return yield a.pairings.set(d,P),yield a.core.relayer.subscribe(d),a.core.expirer.set(d,p),{topic:d,uri:S}}),this.pair=function(){var l=(0,N.Z)(function*(d){a.isInitialized(),a.isValidPair(d);const{topic:p,symKey:m,relay:P}=function(n){const e=n.indexOf(":"),t=-1!==n.indexOf("?")?n.indexOf("?"):void 0,a=n.substring(0,e),l=n.substring(e+1,t).split("@"),d=typeof t<"u"?n.substring(t):"",p=Ui.parse(d);return{protocol:a,topic:s_(l[0]),version:parseInt(l[1],10),symKey:p.symKey,relay:n_(p)}}(d.uri);if(a.pairings.keys.includes(p))throw new Error(`Pairing already exists: ${p}`);if(a.core.crypto.hasKeys(p))throw new Error(`Keychain already exists: ${p}`);const S=Xt(L.FIVE_MINUTES),T={topic:p,relay:P,expiry:S,active:!1};return yield a.pairings.set(p,T),yield a.core.crypto.setSymKey(m,p),yield a.core.relayer.subscribe(p,{relay:P}),a.core.expirer.set(p,S),d.activatePairing&&(yield a.activate({topic:p})),T});return function(d){return l.apply(this,arguments)}}(),this.activate=function(){var l=(0,N.Z)(function*({topic:d}){a.isInitialized();const p=Xt(L.THIRTY_DAYS);yield a.pairings.update(d,{active:!0,expiry:p}),a.core.expirer.set(d,p)});return function(d){return l.apply(this,arguments)}}(),this.ping=function(){var l=(0,N.Z)(function*(d){a.isInitialized(),yield a.isValidPing(d);const{topic:p}=d;if(a.pairings.keys.includes(p)){const m=yield a.sendRequest(p,"wc_pairingPing",{}),{done:P,resolve:S,reject:T}=On();a.events.once(ct("pairing_ping",m),({error:D})=>{D?T(D):S()}),yield P()}});return function(d){return l.apply(this,arguments)}}(),this.updateExpiry=function(){var l=(0,N.Z)(function*({topic:d,expiry:p}){a.isInitialized(),yield a.pairings.update(d,{expiry:p})});return function(d){return l.apply(this,arguments)}}(),this.updateMetadata=function(){var l=(0,N.Z)(function*({topic:d,metadata:p}){a.isInitialized(),yield a.pairings.update(d,{peerMetadata:p})});return function(d){return l.apply(this,arguments)}}(),this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=function(){var l=(0,N.Z)(function*(d){a.isInitialized(),yield a.isValidDisconnect(d);const{topic:p}=d;a.pairings.keys.includes(p)&&(yield a.sendRequest(p,"wc_pairingDelete",lt("USER_DISCONNECTED")),yield a.deletePairing(p))});return function(d){return l.apply(this,arguments)}}(),this.sendRequest=function(){var l=(0,N.Z)(function*(d,p,m){const P=(0,xe.formatJsonRpcRequest)(p,m),S=yield a.core.crypto.encode(d,P),T=Qn[p].req;return a.core.history.set(d,P),a.core.relayer.publish(d,S,T),P.id});return function(d,p,m){return l.apply(this,arguments)}}(),this.sendResult=function(){var l=(0,N.Z)(function*(d,p,m){const P=(0,xe.formatJsonRpcResult)(d,m),S=yield a.core.crypto.encode(p,P),T=yield a.core.history.get(p,d),D=Qn[T.request.method].res;yield a.core.relayer.publish(p,S,D),yield a.core.history.resolve(P)});return function(d,p,m){return l.apply(this,arguments)}}(),this.sendError=function(){var l=(0,N.Z)(function*(d,p,m){const P=(0,xe.formatJsonRpcError)(d,m),S=yield a.core.crypto.encode(p,P),T=yield a.core.history.get(p,d),D=Qn[T.request.method]?Qn[T.request.method].res:Qn.unregistered_method.res;yield a.core.relayer.publish(p,S,D),yield a.core.history.resolve(P)});return function(d,p,m){return l.apply(this,arguments)}}(),this.deletePairing=function(){var l=(0,N.Z)(function*(d,p){yield a.core.relayer.unsubscribe(d),yield Promise.all([a.pairings.delete(d,lt("USER_DISCONNECTED")),a.core.crypto.deleteSymKey(d),p?Promise.resolve():a.core.expirer.del(d)])});return function(d,p){return l.apply(this,arguments)}}(),this.cleanup=(0,N.Z)(function*(){const l=a.pairings.getAll().filter(d=>Nr(d.expiry));yield Promise.all(l.map(d=>a.deletePairing(d.topic)))}),this.onRelayEventRequest=l=>{const{topic:d,payload:p}=l;switch(p.method){case"wc_pairingPing":return this.onPairingPingRequest(d,p);case"wc_pairingDelete":return this.onPairingDeleteRequest(d,p);default:return this.onUnknownRpcMethodRequest(d,p)}},this.onRelayEventResponse=function(){var l=(0,N.Z)(function*(d){const{topic:p,payload:m}=d,P=(yield a.core.history.get(p,m.id)).request.method;return"wc_pairingPing"===P?a.onPairingPingResponse(p,m):a.onUnknownRpcMethodResponse(P)});return function(d){return l.apply(this,arguments)}}(),this.onPairingPingRequest=function(){var l=(0,N.Z)(function*(d,p){const{id:m}=p;try{a.isValidPing({topic:d}),yield a.sendResult(m,d,!0),a.events.emit("pairing_ping",{id:m,topic:d})}catch(P){yield a.sendError(m,d,P),a.logger.error(P)}});return function(d,p){return l.apply(this,arguments)}}(),this.onPairingPingResponse=(l,d)=>{const{id:p}=d;setTimeout(()=>{(0,xe.isJsonRpcResult)(d)?this.events.emit(ct("pairing_ping",p),{}):(0,xe.isJsonRpcError)(d)&&this.events.emit(ct("pairing_ping",p),{error:d.error})},500)},this.onPairingDeleteRequest=function(){var l=(0,N.Z)(function*(d,p){const{id:m}=p;try{a.isValidDisconnect({topic:d}),yield a.deletePairing(d),a.events.emit("pairing_delete",{id:m,topic:d})}catch(P){yield a.sendError(m,d,P),a.logger.error(P)}});return function(d,p){return l.apply(this,arguments)}}(),this.onUnknownRpcMethodRequest=function(){var l=(0,N.Z)(function*(d,p){const{id:m,method:P}=p;try{if(a.registeredMethods.includes(P))return;const S=lt("WC_METHOD_UNSUPPORTED",P);yield a.sendError(m,d,S),a.logger.error(S)}catch(S){yield a.sendError(m,d,S),a.logger.error(S)}});return function(d,p){return l.apply(this,arguments)}}(),this.onUnknownRpcMethodResponse=l=>{this.registeredMethods.includes(l)||this.logger.error(lt("WC_METHOD_UNSUPPORTED",l))},this.isValidPair=l=>{if(!xt(l)){const{message:d}=ee("MISSING_OR_INVALID",`pair() params: ${l}`);throw new Error(d)}if(!function(n){if(ft(n,!1))try{return typeof new URL(n)<"u"}catch{return!1}return!1}(l.uri)){const{message:d}=ee("MISSING_OR_INVALID",`pair() uri: ${l.uri}`);throw new Error(d)}},this.isValidPing=function(){var l=(0,N.Z)(function*(d){if(!xt(d)){const{message:m}=ee("MISSING_OR_INVALID",`ping() params: ${d}`);throw new Error(m)}const{topic:p}=d;yield a.isValidPairingTopic(p)});return function(d){return l.apply(this,arguments)}}(),this.isValidDisconnect=function(){var l=(0,N.Z)(function*(d){if(!xt(d)){const{message:m}=ee("MISSING_OR_INVALID",`disconnect() params: ${d}`);throw new Error(m)}const{topic:p}=d;yield a.isValidPairingTopic(p)});return function(d){return l.apply(this,arguments)}}(),this.isValidPairingTopic=function(){var l=(0,N.Z)(function*(d){if(!ft(d,!1)){const{message:p}=ee("MISSING_OR_INVALID",`pairing topic should be a string: ${d}`);throw new Error(p)}if(!a.pairings.keys.includes(d)){const{message:p}=ee("NO_MATCHING_KEY",`pairing topic doesn't exist: ${d}`);throw new Error(p)}if(Nr(a.pairings.get(d).expiry)){yield a.deletePairing(d);const{message:p}=ee("EXPIRED",`pairing topic: ${d}`);throw new Error(p)}});return function(d){return l.apply(this,arguments)}}(),this.core=e,this.logger=Tt(t,this.name),this.pairings=new Bi(this.core,this.logger,this.name,this.storagePrefix)}get context(){return St(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){var e=this;this.core.relayer.on("relayer_message",function(){var t=(0,N.Z)(function*(a){const{topic:l,message:d}=a;if(!e.pairings.keys.includes(l)||e.ignoredPayloadTypes.includes(e.core.crypto.getPayloadType(d)))return;const p=yield e.core.crypto.decode(l,d);(0,xe.isJsonRpcRequest)(p)?(e.core.history.set(l,p),e.onRelayEventRequest({topic:l,payload:p})):(0,xe.isJsonRpcResponse)(p)&&(yield e.core.history.resolve(p),yield e.onRelayEventResponse({topic:l,payload:p}),e.core.history.delete(l,p.id))});return function(a){return t.apply(this,arguments)}}())}registerExpirerEvents(){var e=this;this.core.expirer.on(Mt_expired,function(){var t=(0,N.Z)(function*(a){const{topic:l}=du(a.target);l&&e.pairings.keys.includes(l)&&(yield e.deletePairing(l,!0),e.events.emit("pairing_expire",{topic:l}))});return function(a){return t.apply(this,arguments)}}())}}class mv extends Vp{constructor(e,t){var a;super(e,t),a=this,this.core=e,this.logger=t,this.records=new Map,this.events=new Le.EventEmitter,this.name="history",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Rr,this.init=(0,N.Z)(function*(){a.initialized||(a.logger.trace("Initialized"),yield a.restore(),a.cached.forEach(l=>a.records.set(l.id,l)),a.cached=[],a.registerEventListeners(),a.initialized=!0)}),this.set=(l,d,p)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:l,request:d,chainId:p}),this.records.has(d.id))return;const m={id:d.id,topic:l,request:{method:d.method,params:d.params||null},chainId:p,expiry:Xt(L.THIRTY_DAYS)};this.records.set(m.id,m),this.events.emit("history_created",m)},this.resolve=function(){var l=(0,N.Z)(function*(d){if(a.isInitialized(),a.logger.debug("Updating JSON-RPC response history record"),a.logger.trace({type:"method",method:"update",response:d}),!a.records.has(d.id))return;const p=yield a.getRecord(d.id);typeof p.response>"u"&&(p.response=(0,xe.isJsonRpcError)(d)?{error:d.error}:{result:d.result},a.records.set(p.id,p),a.events.emit("history_updated",p))});return function(d){return l.apply(this,arguments)}}(),this.get=function(){var l=(0,N.Z)(function*(d,p){return a.isInitialized(),a.logger.debug("Getting record"),a.logger.trace({type:"method",method:"get",topic:d,id:p}),yield a.getRecord(p)});return function(d,p){return l.apply(this,arguments)}}(),this.delete=(l,d)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:d}),this.values.forEach(p=>{if(p.topic===l){if(typeof d<"u"&&p.id!==d)return;this.records.delete(p.id),this.events.emit("history_deleted",p)}})},this.exists=function(){var l=(0,N.Z)(function*(d,p){return a.isInitialized(),!!a.records.has(p)&&(yield a.getRecord(p)).topic===d});return function(d,p){return l.apply(this,arguments)}}(),this.on=(l,d)=>{this.events.on(l,d)},this.once=(l,d)=>{this.events.once(l,d)},this.off=(l,d)=>{this.events.off(l,d)},this.removeListener=(l,d)=>{this.events.removeListener(l,d)},this.logger=Tt(t,this.name)}get context(){return St(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 a={topic:t.topic,request:(0,xe.formatJsonRpcRequest)(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(a)}),e}setJsonRpcRecords(e){var t=this;return(0,N.Z)(function*(){yield t.core.storage.setItem(t.storageKey,e)})()}getJsonRpcRecords(){var e=this;return(0,N.Z)(function*(){return yield e.core.storage.getItem(e.storageKey)})()}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:a}=ee("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(a)}return t}persist(){var e=this;return(0,N.Z)(function*(){yield e.setJsonRpcRecords(e.values),e.events.emit("history_sync")})()}restore(){var e=this;return(0,N.Z)(function*(){try{const t=yield e.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(e.records.size){const{message:a}=ee("RESTORE_WILL_OVERRIDE",e.name);throw e.logger.error(a),new Error(a)}e.cached=t,e.logger.debug(`Successfully Restored records for ${e.name}`),e.logger.trace({type:"method",method:"restore",records:e.values})}catch(t){e.logger.debug(`Failed to Restore records for ${e.name}`),e.logger.error(t)}})()}registerEventListeners(){this.events.on("history_created",e=>{const t="history_created";this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()}),this.events.on("history_updated",e=>{const t="history_updated";this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()}),this.events.on("history_deleted",e=>{const t="history_deleted";this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e}),this.persist()}),this.core.heartbeat.on(Bn.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup()})}cleanup(){try{this.records.forEach(e=>{(0,L.toMiliseconds)(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.delete(e.topic,e.id))})}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}}class vv extends Jp{constructor(e,t){var a;super(e,t),a=this,this.core=e,this.logger=t,this.expirations=new Map,this.events=new Le.EventEmitter,this.name="expirer",this.version="0.3",this.cached=[],this.initialized=!1,this.storagePrefix=Rr,this.init=(0,N.Z)(function*(){a.initialized||(a.logger.trace("Initialized"),yield a.restore(),a.cached.forEach(l=>a.expirations.set(l.target,l)),a.cached=[],a.registerEventListeners(),a.initialized=!0)}),this.has=l=>{try{const d=this.formatTarget(l);return typeof this.getExpiration(d)<"u"}catch{return!1}},this.set=(l,d)=>{this.isInitialized();const p=this.formatTarget(l),m={target:p,expiry:d};this.expirations.set(p,m),this.checkExpiry(p,m),this.events.emit("expirer_created",{target:p,expiration:m})},this.get=l=>{this.isInitialized();const d=this.formatTarget(l);return this.getExpiration(d)},this.del=l=>{if(this.isInitialized(),this.has(l)){const d=this.formatTarget(l),p=this.getExpiration(d);this.expirations.delete(d),this.events.emit("expirer_deleted",{target:d,expiration:p})}},this.on=(l,d)=>{this.events.on(l,d)},this.once=(l,d)=>{this.events.once(l,d)},this.off=(l,d)=>{this.events.off(l,d)},this.removeListener=(l,d)=>{this.events.removeListener(l,d)},this.logger=Tt(t,this.name)}get context(){return St(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 fu("topic",e);if("number"==typeof e)return function(n){return fu("id",n)}(e);const{message:t}=ee("UNKNOWN_TYPE","Target type: "+typeof e);throw new Error(t)}setExpirations(e){var t=this;return(0,N.Z)(function*(){yield t.core.storage.setItem(t.storageKey,e)})()}getExpirations(){var e=this;return(0,N.Z)(function*(){return yield e.core.storage.getItem(e.storageKey)})()}persist(){var e=this;return(0,N.Z)(function*(){yield e.setExpirations(e.values),e.events.emit("expirer_sync")})()}restore(){var e=this;return(0,N.Z)(function*(){try{const t=yield e.getExpirations();if(typeof t>"u"||!t.length)return;if(e.expirations.size){const{message:a}=ee("RESTORE_WILL_OVERRIDE",e.name);throw e.logger.error(a),new Error(a)}e.cached=t,e.logger.debug(`Successfully Restored expirations for ${e.name}`),e.logger.trace({type:"method",method:"restore",expirations:e.values})}catch(t){e.logger.debug(`Failed to Restore expirations for ${e.name}`),e.logger.error(t)}})()}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:a}=ee("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(a),new Error(a)}return t}checkExpiry(e,t){const{expiry:a}=t;(0,L.toMiliseconds)(a)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(Mt_expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(Bn.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on("expirer_created",e=>{const t="expirer_created";this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(Mt_expired,e=>{const t=Mt_expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on("expirer_deleted",e=>{const t="expirer_deleted";this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}}class bv extends class{constructor(e,t){this.projectId=e,this.logger=t}}{constructor(e,t){var a;super(e,t),a=this,this.projectId=e,this.logger=t,this.name=To,this.initialized=!1,this.init=function(){var l=(0,N.Z)(function*(d){au()||!Io()||(a.verifyUrl=d?.verifyUrl||Hu,yield a.createIframe())});return function(d){return l.apply(this,arguments)}}(),this.register=function(){var l=(0,N.Z)(function*(d){var p;if(a.initialized||(yield a.init()),a.iframe)try{null==(p=a.iframe.contentWindow)||p.postMessage(d.attestationId,a.verifyUrl),a.logger.info(`postMessage sent: ${d.attestationId} ${a.verifyUrl}`)}catch{}});return function(d){return l.apply(this,arguments)}}(),this.resolve=function(){var l=(0,N.Z)(function*(d){var p;if(a.isDevEnv)return"";a.logger.info(`resolving attestation: ${d.attestationId}`);const m=a.startAbortTimer(L.FIVE_SECONDS),P=yield fetch(`${a.verifyUrl}/attestation/${d.attestationId}`,{signal:a.abortController.signal});return clearTimeout(m),200===P.status?null==(p=yield P.json())?void 0:p.origin:""});return function(d){return l.apply(this,arguments)}}(),this.createIframe=(0,N.Z)(function*(){try{yield Promise.race([new Promise((l,d)=>{if(document.getElementById(To))return l();const p=document.createElement("iframe");p.setAttribute("id",To),p.setAttribute("src",`${a.verifyUrl}/${a.projectId}`),p.style.display="none",p.addEventListener("load",()=>{a.initialized=!0,l()}),p.addEventListener("error",m=>{d(m)}),document.body.append(p),a.iframe=p}),new Promise(l=>{setTimeout(()=>l("iframe load timeout"),(0,L.toMiliseconds)(L.ONE_SECOND/2))})])}catch(l){a.logger.error(`Verify iframe failed to load: ${a.verifyUrl}`),a.logger.error(l)}}),this.logger=Tt(t,this.name),this.verifyUrl=Hu,this.abortController=new AbortController,this.isDevEnv=Eo()&&process.env.IS_VITEST}get context(){return St(this.logger)}startAbortTimer(e){return setTimeout(()=>this.abortController.abort(),(0,L.toMiliseconds)(e))}}var wv=Object.defineProperty,rl=Object.getOwnPropertySymbols,Ev=Object.prototype.hasOwnProperty,Iv=Object.prototype.propertyIsEnumerable,nl=(n,e,t)=>e in n?wv(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,il=(n,e)=>{for(var t in e||(e={}))Ev.call(e,t)&&nl(n,t,e[t]);if(rl)for(var t of rl(e))Iv.call(e,t)&&nl(n,t,e[t]);return n};class $o extends Zp{constructor(e){super(e),this.protocol="wc",this.version=2,this.name="core",this.events=new Le.EventEmitter,this.initialized=!1,this.on=(a,l)=>this.events.on(a,l),this.once=(a,l)=>this.events.once(a,l),this.off=(a,l)=>this.events.off(a,l),this.removeListener=(a,l)=>this.events.removeListener(a,l),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||Bu;const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:Ti()(ho({level:e?.logger||"error"}));this.logger=Tt(t,this.name),this.heartbeat=new Bn.HeartBeat,this.crypto=new Xm(this,this.logger,e?.keychain),this.history=new mv(this,this.logger),this.expirer=new vv(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new Np.Z(il(il({},xm),e?.storageOptions)),this.relayer=new hv({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new yv(this,this.logger),this.verify=new bv(this.projectId||"",this.logger)}static init(e){return(0,N.Z)(function*(){const t=new $o(e);yield t.initialize();const a=yield t.crypto.getClientId();return yield t.storage.setItem("WALLETCONNECT_CLIENT_ID",a),t})()}get context(){return St(this.logger)}start(){var e=this;return(0,N.Z)(function*(){e.initialized||(yield e.initialize())})()}initialize(){var e=this;return(0,N.Z)(function*(){e.logger.trace("Initialized");try{yield e.crypto.init(),yield e.history.init(),yield e.expirer.init(),yield e.relayer.init(),yield e.heartbeat.init(),yield e.pairing.init(),e.initialized=!0,e.logger.info("Core Initialization Success")}catch(t){throw e.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,t),e.logger.error(t.message),t}})()}}const Ov=$o,Do="wc@2:client:",al="Proposal expired",Wi=L.SEVEN_DAYS,ei={wc_sessionPropose:{req:{ttl:L.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:L.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:L.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:L.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:L.ONE_DAY,prompt:!1,tag:1104},res:{ttl:L.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:L.ONE_DAY,prompt:!1,tag:1106},res:{ttl:L.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:L.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:L.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:L.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:L.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:L.ONE_DAY,prompt:!1,tag:1112},res:{ttl:L.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:L.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:L.THIRTY_SECONDS,prompt:!1,tag:1115}}},Uo={min:L.FIVE_MINUTES,max:L.SEVEN_DAYS},Av=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var Cv=Object.defineProperty,Tv=Object.defineProperties,jv=Object.getOwnPropertyDescriptors,ul=Object.getOwnPropertySymbols,$v=Object.prototype.hasOwnProperty,Dv=Object.prototype.propertyIsEnumerable,ll=(n,e,t)=>e in n?Cv(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,qt=(n,e)=>{for(var t in e||(e={}))$v.call(e,t)&&ll(n,t,e[t]);if(ul)for(var t of ul(e))Dv.call(e,t)&&ll(n,t,e[t]);return n},Lo=(n,e)=>Tv(n,jv(e));class Fv extends class{constructor(e){this.client=e}}{constructor(e){var t;super(e),t=this,this.name="engine",this.events=new(Je()),this.initialized=!1,this.ignoredPayloadTypes=[1],this.requestQueue={state:"idle",requests:[]},this.requestQueueDelay=L.ONE_SECOND,this.init=(0,N.Z)(function*(){t.initialized||(yield t.cleanup(),t.registerRelayerEvents(),t.registerExpirerEvents(),t.client.core.pairing.register({methods:Object.keys(ei)}),t.initialized=!0,setTimeout(()=>{t.requestQueue.requests=t.getPendingSessionRequests(),t.processRequestQueue()},(0,L.toMiliseconds)(t.requestQueueDelay)))}),this.connect=function(){var a=(0,N.Z)(function*(l){t.isInitialized();const d=Lo(qt({},l),{requiredNamespaces:l.requiredNamespaces||{},optionalNamespaces:l.optionalNamespaces||{}});yield t.isValidConnect(d);const{pairingTopic:p,requiredNamespaces:m,optionalNamespaces:P,sessionProperties:S,relays:T}=d;let Q,D=p,se=!1;if(D&&(se=t.client.core.pairing.pairings.get(D).active),!D||!se){const{topic:oe,uri:Ne}=yield t.client.core.pairing.create();D=oe,Q=Ne}const B=yield t.client.core.crypto.generateKeyPair(),Y=qt({requiredNamespaces:m,optionalNamespaces:P,relays:T??[{protocol:"irn"}],proposer:{publicKey:B,metadata:t.client.metadata}},S&&{sessionProperties:S}),{reject:te,resolve:Me,done:Xe}=On(L.FIVE_MINUTES,al);if(t.events.once(ct("session_connect"),function(){var oe=(0,N.Z)(function*({error:Ne,session:qe}){if(Ne)te(Ne);else if(qe){qe.self.publicKey=B;const dt=Lo(qt({},qe),{requiredNamespaces:qe.requiredNamespaces,optionalNamespaces:qe.optionalNamespaces});yield t.client.session.set(qe.topic,dt),yield t.setExpiry(qe.topic,qe.expiry),D&&(yield t.client.core.pairing.updateMetadata({topic:D,metadata:qe.peer.metadata})),Me(dt)}});return function(Ne){return oe.apply(this,arguments)}}()),!D){const{message:oe}=ee("NO_MATCHING_KEY",`connect() pairing topic: ${D}`);throw new Error(oe)}const Ue=yield t.sendRequest(D,"wc_sessionPropose",Y),ve=Xt(L.FIVE_MINUTES);return yield t.setProposal(Ue,qt({id:Ue,expiry:ve},Y)),{uri:Q,approval:Xe}});return function(l){return a.apply(this,arguments)}}(),this.pair=function(){var a=(0,N.Z)(function*(l){return t.isInitialized(),yield t.client.core.pairing.pair(l)});return function(l){return a.apply(this,arguments)}}(),this.approve=function(){var a=(0,N.Z)(function*(l){t.isInitialized(),yield t.isValidApprove(l);const{id:d,relayProtocol:p,namespaces:m,sessionProperties:P}=l,S=t.client.proposal.get(d);let{pairingTopic:T,proposer:D,requiredNamespaces:Q,optionalNamespaces:se}=S;T=T||"",xn(Q)||(Q=function(n,e){const t=Vi(n,"approve()");if(t)throw new Error(t.message);const a={};for(const[l,d]of Object.entries(n))a[l]={methods:d.methods,events:d.events,chains:d.accounts.map(p=>`${p.split(":")[0]}:${p.split(":")[1]}`)};return a}(m));const B=yield t.client.core.crypto.generateKeyPair(),Y=D.publicKey,te=yield t.client.core.crypto.generateSharedKey(B,Y);T&&d&&(yield t.client.core.pairing.updateMetadata({topic:T,metadata:D.metadata}),yield t.sendResult(d,T,{relay:{protocol:p??"irn"},responderPublicKey:B}),yield t.client.proposal.delete(d,lt("USER_DISCONNECTED")),yield t.client.core.pairing.activate({topic:T}));const Me=qt({relay:{protocol:p??"irn"},namespaces:m,requiredNamespaces:Q,optionalNamespaces:se,pairingTopic:T,controller:{publicKey:B,metadata:t.client.metadata},expiry:Xt(Wi)},P&&{sessionProperties:P});yield t.client.core.relayer.subscribe(te),yield t.sendRequest(te,"wc_sessionSettle",Me);const Xe=Lo(qt({},Me),{topic:te,pairingTopic:T,acknowledged:!1,self:Me.controller,peer:{publicKey:D.publicKey,metadata:D.metadata},controller:B});return yield t.client.session.set(te,Xe),yield t.setExpiry(te,Xt(Wi)),{topic:te,acknowledged:()=>new Promise(Ue=>setTimeout(()=>Ue(t.client.session.get(te)),500))}});return function(l){return a.apply(this,arguments)}}(),this.reject=function(){var a=(0,N.Z)(function*(l){t.isInitialized(),yield t.isValidReject(l);const{id:d,reason:p}=l,{pairingTopic:m}=t.client.proposal.get(d);m&&(yield t.sendError(d,m,p),yield t.client.proposal.delete(d,lt("USER_DISCONNECTED")))});return function(l){return a.apply(this,arguments)}}(),this.update=function(){var a=(0,N.Z)(function*(l){t.isInitialized(),yield t.isValidUpdate(l);const{topic:d,namespaces:p}=l,m=yield t.sendRequest(d,"wc_sessionUpdate",{namespaces:p}),{done:P,resolve:S,reject:T}=On();return t.events.once(ct("session_update",m),({error:D})=>{D?T(D):S()}),yield t.client.session.update(d,{namespaces:p}),{acknowledged:P}});return function(l){return a.apply(this,arguments)}}(),this.extend=function(){var a=(0,N.Z)(function*(l){t.isInitialized(),yield t.isValidExtend(l);const{topic:d}=l,p=yield t.sendRequest(d,"wc_sessionExtend",{}),{done:m,resolve:P,reject:S}=On();return t.events.once(ct("session_extend",p),({error:T})=>{T?S(T):P()}),yield t.setExpiry(d,Xt(Wi)),{acknowledged:m}});return function(l){return a.apply(this,arguments)}}(),this.request=function(){var a=(0,N.Z)(function*(l){t.isInitialized(),yield t.isValidRequest(l);const{chainId:d,request:p,topic:m,expiry:P}=l,S=yield t.sendRequest(m,"wc_sessionRequest",{request:p,chainId:d},P),{done:T,resolve:D,reject:Q}=On(P);return t.events.once(ct("session_request",S),({error:B,result:Y})=>{B?Q(B):D(Y)}),t.client.events.emit("session_request_sent",{topic:m,request:p,chainId:d,id:S}),function(n){Oo.apply(this,arguments)}({id:S,topic:m,wcDeepLink:yield t.client.core.storage.getItem("WALLETCONNECT_DEEPLINK_CHOICE")}),yield T()});return function(l){return a.apply(this,arguments)}}(),this.respond=function(){var a=(0,N.Z)(function*(l){t.isInitialized(),yield t.isValidRespond(l);const{topic:d,response:p}=l,{id:m}=p;(0,xe.isJsonRpcResult)(p)?yield t.sendResult(m,d,p.result):(0,xe.isJsonRpcError)(p)&&(yield t.sendError(m,d,p.error)),t.cleanupAfterResponse(l)});return function(l){return a.apply(this,arguments)}}(),this.ping=function(){var a=(0,N.Z)(function*(l){t.isInitialized(),yield t.isValidPing(l);const{topic:d}=l;if(t.client.session.keys.includes(d)){const p=yield t.sendRequest(d,"wc_sessionPing",{}),{done:m,resolve:P,reject:S}=On();t.events.once(ct("session_ping",p),({error:T})=>{T?S(T):P()}),yield m()}else t.client.core.pairing.pairings.keys.includes(d)&&(yield t.client.core.pairing.ping({topic:d}))});return function(l){return a.apply(this,arguments)}}(),this.emit=function(){var a=(0,N.Z)(function*(l){t.isInitialized(),yield t.isValidEmit(l);const{topic:d,event:p,chainId:m}=l;yield t.sendRequest(d,"wc_sessionEvent",{event:p,chainId:m})});return function(l){return a.apply(this,arguments)}}(),this.disconnect=function(){var a=(0,N.Z)(function*(l){t.isInitialized(),yield t.isValidDisconnect(l);const{topic:d}=l;if(t.client.session.keys.includes(d)){const p=(0,xe.getBigIntRpcId)().toString();let m;const P=S=>{S?.id.toString()===p&&(t.client.core.relayer.events.removeListener("relayer_message_ack",P),m())};yield Promise.all([new Promise(S=>{m=S,t.client.core.relayer.on("relayer_message_ack",P)}),t.sendRequest(d,"wc_sessionDelete",lt("USER_DISCONNECTED"),void 0,p)]),yield t.deleteSession(d)}else yield t.client.core.pairing.disconnect({topic:d})});return function(l){return a.apply(this,arguments)}}(),this.find=a=>(this.isInitialized(),this.client.session.getAll().filter(l=>function(n,e){const{requiredNamespaces:t}=e,a=Object.keys(n.namespaces),l=Object.keys(t);let d=!0;return!!Qr(l,a)&&(a.forEach(p=>{const{accounts:m,methods:P,events:S}=n.namespaces[p],T=Sn(m),D=t[p];Qr(po(p,D),T)&&Qr(D.methods,P)&&Qr(D.events,S)||(d=!1)}),d)}(l,a))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=function(){var a=(0,N.Z)(function*(l){if(l.pairingTopic)try{const d=t.client.core.pairing.pairings.get(l.pairingTopic),p=t.client.core.pairing.pairings.getAll().filter(m=>{var P,S;return(null==(P=m.peerMetadata)?void 0:P.url)&&(null==(S=m.peerMetadata)?void 0:S.url)===l.peer.metadata.url&&m.topic&&m.topic!==d.topic});if(0===p.length)return;t.client.logger.info(`Cleaning up ${p.length} duplicate pairing(s)`),yield Promise.all(p.map(m=>t.client.core.pairing.disconnect({topic:m.topic}))),t.client.logger.info("Duplicate pairings clean up finished")}catch(d){t.client.logger.error(d)}});return function(l){return a.apply(this,arguments)}}(),this.deleteSession=function(){var a=(0,N.Z)(function*(l,d){const{self:p}=t.client.session.get(l);yield t.client.core.relayer.unsubscribe(l),t.client.session.delete(l,lt("USER_DISCONNECTED")),t.client.core.crypto.keychain.has(p.publicKey)&&(yield t.client.core.crypto.deleteKeyPair(p.publicKey)),t.client.core.crypto.keychain.has(l)&&(yield t.client.core.crypto.deleteSymKey(l)),d||t.client.core.expirer.del(l)});return function(l,d){return a.apply(this,arguments)}}(),this.deleteProposal=function(){var a=(0,N.Z)(function*(l,d){yield Promise.all([t.client.proposal.delete(l,lt("USER_DISCONNECTED")),d?Promise.resolve():t.client.core.expirer.del(l)])});return function(l,d){return a.apply(this,arguments)}}(),this.deletePendingSessionRequest=function(){var a=(0,N.Z)(function*(l,d,p=!1){yield Promise.all([t.client.pendingRequest.delete(l,d),p?Promise.resolve():t.client.core.expirer.del(l)]),t.requestQueue.requests=t.requestQueue.requests.filter(m=>m.id!==l),p&&(t.requestQueue.state="idle")});return function(l,d){return a.apply(this,arguments)}}(),this.setExpiry=function(){var a=(0,N.Z)(function*(l,d){t.client.session.keys.includes(l)&&(yield t.client.session.update(l,{expiry:d})),t.client.core.expirer.set(l,d)});return function(l,d){return a.apply(this,arguments)}}(),this.setProposal=function(){var a=(0,N.Z)(function*(l,d){yield t.client.proposal.set(l,d),t.client.core.expirer.set(l,d.expiry)});return function(l,d){return a.apply(this,arguments)}}(),this.setPendingSessionRequest=function(){var a=(0,N.Z)(function*(l){const d=ei.wc_sessionRequest.req.ttl,{id:p,topic:m,params:P}=l;yield t.client.pendingRequest.set(p,{id:p,topic:m,params:P}),d&&t.client.core.expirer.set(p,Xt(d))});return function(l){return a.apply(this,arguments)}}(),this.sendRequest=function(){var a=(0,N.Z)(function*(l,d,p,m,P){const S=(0,xe.formatJsonRpcRequest)(d,p);if(Io()&&Av.includes(d)){const Q=In(JSON.stringify(S));yield t.client.core.verify.register({attestationId:Q})}const T=yield t.client.core.crypto.encode(l,S),D=ei[d].req;return m&&(D.ttl=m),P&&(D.id=P),t.client.core.history.set(l,S),t.client.core.relayer.publish(l,T,D),S.id});return function(l,d,p,m,P){return a.apply(this,arguments)}}(),this.sendResult=function(){var a=(0,N.Z)(function*(l,d,p){const m=(0,xe.formatJsonRpcResult)(l,p),P=yield t.client.core.crypto.encode(d,m),S=yield t.client.core.history.get(d,l);t.client.core.relayer.publish(d,P,ei[S.request.method].res),yield t.client.core.history.resolve(m)});return function(l,d,p){return a.apply(this,arguments)}}(),this.sendError=function(){var a=(0,N.Z)(function*(l,d,p){const m=(0,xe.formatJsonRpcError)(l,p),P=yield t.client.core.crypto.encode(d,m),S=yield t.client.core.history.get(d,l);t.client.core.relayer.publish(d,P,ei[S.request.method].res),yield t.client.core.history.resolve(m)});return function(l,d,p){return a.apply(this,arguments)}}(),this.cleanup=(0,N.Z)(function*(){const a=[],l=[];t.client.session.getAll().forEach(d=>{Nr(d.expiry)&&a.push(d.topic)}),t.client.proposal.getAll().forEach(d=>{Nr(d.expiry)&&l.push(d.id)}),yield Promise.all([...a.map(d=>t.deleteSession(d)),...l.map(d=>t.deleteProposal(d))])}),this.onRelayEventRequest=a=>{const{topic:l,payload:d}=a,p=d.method;switch(p){case"wc_sessionPropose":return this.onSessionProposeRequest(l,d);case"wc_sessionSettle":return this.onSessionSettleRequest(l,d);case"wc_sessionUpdate":return this.onSessionUpdateRequest(l,d);case"wc_sessionExtend":return this.onSessionExtendRequest(l,d);case"wc_sessionPing":return this.onSessionPingRequest(l,d);case"wc_sessionDelete":return this.onSessionDeleteRequest(l,d);case"wc_sessionRequest":return this.onSessionRequest(l,d);case"wc_sessionEvent":return this.onSessionEventRequest(l,d);default:return this.client.logger.info(`Unsupported request method ${p}`)}},this.onRelayEventResponse=function(){var a=(0,N.Z)(function*(l){const{topic:d,payload:p}=l,m=(yield t.client.core.history.get(d,p.id)).request.method;switch(m){case"wc_sessionPropose":return t.onSessionProposeResponse(d,p);case"wc_sessionSettle":return t.onSessionSettleResponse(d,p);case"wc_sessionUpdate":return t.onSessionUpdateResponse(d,p);case"wc_sessionExtend":return t.onSessionExtendResponse(d,p);case"wc_sessionPing":return t.onSessionPingResponse(d,p);case"wc_sessionRequest":return t.onSessionRequestResponse(d,p);default:return t.client.logger.info(`Unsupported response method ${m}`)}});return function(l){return a.apply(this,arguments)}}(),this.onRelayEventUnknownPayload=a=>{const{topic:l}=a,{message:d}=ee("MISSING_OR_INVALID",`Decoded payload on topic ${l} is not identifiable as a JSON-RPC request or a response.`);throw new Error(d)},this.onSessionProposeRequest=function(){var a=(0,N.Z)(function*(l,d){const{params:p,id:m}=d;try{t.isValidConnect(qt({},d.params));const P=Xt(L.FIVE_MINUTES),S=qt({id:m,pairingTopic:l,expiry:P},p);yield t.setProposal(m,S);const T=In(JSON.stringify(d)),D=yield t.getVerifyContext(T,S.proposer.metadata);t.client.events.emit("session_proposal",{id:m,params:S,verifyContext:D})}catch(P){yield t.sendError(m,l,P),t.client.logger.error(P)}});return function(l,d){return a.apply(this,arguments)}}(),this.onSessionProposeResponse=function(){var a=(0,N.Z)(function*(l,d){const{id:p}=d;if((0,xe.isJsonRpcResult)(d)){const{result:m}=d;t.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:m});const P=t.client.proposal.get(p);t.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:P});const S=P.proposer.publicKey;t.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:S});const T=m.responderPublicKey;t.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:T});const D=yield t.client.core.crypto.generateSharedKey(S,T);t.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:D});const Q=yield t.client.core.relayer.subscribe(D);t.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:Q}),yield t.client.core.pairing.activate({topic:l})}else(0,xe.isJsonRpcError)(d)&&(yield t.client.proposal.delete(p,lt("USER_DISCONNECTED")),t.events.emit(ct("session_connect"),{error:d.error}))});return function(l,d){return a.apply(this,arguments)}}(),this.onSessionSettleRequest=function(){var a=(0,N.Z)(function*(l,d){const{id:p,params:m}=d;try{t.isValidSessionSettleRequest(m);const{relay:P,controller:S,expiry:T,namespaces:D,requiredNamespaces:Q,optionalNamespaces:se,sessionProperties:B,pairingTopic:Y}=d.params,te=qt({topic:l,relay:P,expiry:T,namespaces:D,acknowledged:!0,pairingTopic:Y,requiredNamespaces:Q,optionalNamespaces:se,controller:S.publicKey,self:{publicKey:"",metadata:t.client.metadata},peer:{publicKey:S.publicKey,metadata:S.metadata}},B&&{sessionProperties:B});yield t.sendResult(d.id,l,!0),t.events.emit(ct("session_connect"),{session:te}),t.cleanupDuplicatePairings(te)}catch(P){yield t.sendError(p,l,P),t.client.logger.error(P)}});return function(l,d){return a.apply(this,arguments)}}(),this.onSessionSettleResponse=function(){var a=(0,N.Z)(function*(l,d){const{id:p}=d;(0,xe.isJsonRpcResult)(d)?(yield t.client.session.update(l,{acknowledged:!0}),t.events.emit(ct("session_approve",p),{})):(0,xe.isJsonRpcError)(d)&&(yield t.client.session.delete(l,lt("USER_DISCONNECTED")),t.events.emit(ct("session_approve",p),{error:d.error}))});return function(l,d){return a.apply(this,arguments)}}(),this.onSessionUpdateRequest=function(){var a=(0,N.Z)(function*(l,d){const{params:p,id:m}=d;try{t.isValidUpdate(qt({topic:l},p)),yield t.client.session.update(l,{namespaces:p.namespaces}),yield t.sendResult(m,l,!0),t.client.events.emit("session_update",{id:m,topic:l,params:p})}catch(P){yield t.sendError(m,l,P),t.client.logger.error(P)}});return function(l,d){return a.apply(this,arguments)}}(),this.onSessionUpdateResponse=(a,l)=>{const{id:d}=l;(0,xe.isJsonRpcResult)(l)?this.events.emit(ct("session_update",d),{}):(0,xe.isJsonRpcError)(l)&&this.events.emit(ct("session_update",d),{error:l.error})},this.onSessionExtendRequest=function(){var a=(0,N.Z)(function*(l,d){const{id:p}=d;try{t.isValidExtend({topic:l}),yield t.setExpiry(l,Xt(Wi)),yield t.sendResult(p,l,!0),t.client.events.emit("session_extend",{id:p,topic:l})}catch(m){yield t.sendError(p,l,m),t.client.logger.error(m)}});return function(l,d){return a.apply(this,arguments)}}(),this.onSessionExtendResponse=(a,l)=>{const{id:d}=l;(0,xe.isJsonRpcResult)(l)?this.events.emit(ct("session_extend",d),{}):(0,xe.isJsonRpcError)(l)&&this.events.emit(ct("session_extend",d),{error:l.error})},this.onSessionPingRequest=function(){var a=(0,N.Z)(function*(l,d){const{id:p}=d;try{t.isValidPing({topic:l}),yield t.sendResult(p,l,!0),t.client.events.emit("session_ping",{id:p,topic:l})}catch(m){yield t.sendError(p,l,m),t.client.logger.error(m)}});return function(l,d){return a.apply(this,arguments)}}(),this.onSessionPingResponse=(a,l)=>{const{id:d}=l;setTimeout(()=>{(0,xe.isJsonRpcResult)(l)?this.events.emit(ct("session_ping",d),{}):(0,xe.isJsonRpcError)(l)&&this.events.emit(ct("session_ping",d),{error:l.error})},500)},this.onSessionDeleteRequest=function(){var a=(0,N.Z)(function*(l,d){const{id:p}=d;try{t.isValidDisconnect({topic:l,reason:d.params}),yield Promise.all([new Promise(m=>{t.client.core.relayer.once("relayer_publish",(0,N.Z)(function*(){m(yield t.deleteSession(l))}))}),t.sendResult(p,l,!0)]),t.client.events.emit("session_delete",{id:p,topic:l})}catch(m){t.client.logger.error(m)}});return function(l,d){return a.apply(this,arguments)}}(),this.onSessionRequest=function(){var a=(0,N.Z)(function*(l,d){const{id:p,params:m}=d;try{t.isValidRequest(qt({topic:l},m)),yield t.setPendingSessionRequest({id:p,topic:l,params:m}),t.addRequestToQueue({id:p,topic:l,params:m}),yield t.processRequestQueue()}catch(P){yield t.sendError(p,l,P),t.client.logger.error(P)}});return function(l,d){return a.apply(this,arguments)}}(),this.onSessionRequestResponse=(a,l)=>{const{id:d}=l;(0,xe.isJsonRpcResult)(l)?this.events.emit(ct("session_request",d),{result:l.result}):(0,xe.isJsonRpcError)(l)&&this.events.emit(ct("session_request",d),{error:l.error})},this.onSessionEventRequest=function(){var a=(0,N.Z)(function*(l,d){const{id:p,params:m}=d;try{t.isValidEmit(qt({topic:l},m)),t.client.events.emit("session_event",{id:p,topic:l,params:m})}catch(P){yield t.sendError(p,l,P),t.client.logger.error(P)}});return function(l,d){return a.apply(this,arguments)}}(),this.addRequestToQueue=a=>{this.requestQueue.requests.push(a)},this.cleanupAfterResponse=a=>{this.deletePendingSessionRequest(a.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.requestQueue.state="idle",this.processRequestQueue()},(0,L.toMiliseconds)(this.requestQueueDelay))},this.processRequestQueue=(0,N.Z)(function*(){if("active"===t.requestQueue.state)return void t.client.logger.info("session request queue is already active.");const a=t.requestQueue.requests[0];if(a)try{const{id:l,topic:d,params:p}=a,m=In(JSON.stringify({id:l,params:p})),P=t.client.session.get(d),S=yield t.getVerifyContext(m,P.peer.metadata);t.requestQueue.state="active",t.client.events.emit("session_request",{id:l,topic:d,params:p,verifyContext:S})}catch(l){t.client.logger.error(l)}else t.client.logger.info("session request queue is empty.")}),this.isValidConnect=function(){var a=(0,N.Z)(function*(l){if(!xt(l)){const{message:T}=ee("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(l)}`);throw new Error(T)}const{pairingTopic:d,requiredNamespaces:p,optionalNamespaces:m,sessionProperties:P,relays:S}=l;if(bt(d)||(yield t.isValidPairingTopic(d)),!function(n,e){let t=!1;return n?n&&Gn(n)&&n.length&&n.forEach(a=>{t=wu(a)}):t=!0,t}(S)){const{message:T}=ee("MISSING_OR_INVALID",`connect() relays: ${S}`);throw new Error(T)}!bt(p)&&0!==xn(p)&&t.validateNamespaces(p,"requiredNamespaces"),!bt(m)&&0!==xn(m)&&t.validateNamespaces(m,"optionalNamespaces"),bt(P)||t.validateSessionProps(P,"sessionProperties")});return function(l){return a.apply(this,arguments)}}(),this.validateNamespaces=(a,l)=>{const d=function(n,e,t){let a=null;if(n&&xn(n)){const l=bu(n,e);l&&(a=l);const d=function(n,e,t){let a=null;return Object.entries(n).forEach(([l,d])=>{if(a)return;const p=function(n,e,t){let a=null;return Gn(e)&&e.length?e.forEach(l=>{a||Zi(l)||(a=lt("UNSUPPORTED_CHAINS",`${t}, chain ${l} should be a string and conform to "namespace:chainId" format`))}):Zi(n)||(a=lt("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),a}(l,po(l,d),`${e} ${t}`);p&&(a=p)}),a}(n,e,t);d&&(a=d)}else a=ee("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return a}(a,"connect()",l);if(d)throw new Error(d.message)},this.isValidApprove=function(){var a=(0,N.Z)(function*(l){if(!xt(l))throw new Error(ee("MISSING_OR_INVALID",`approve() params: ${l}`).message);const{id:d,namespaces:p,relayProtocol:m,sessionProperties:P}=l;yield t.isValidProposalId(d);const S=t.client.proposal.get(d),T=Vi(p,"approve()");if(T)throw new Error(T.message);const D=No(S.requiredNamespaces,p,"approve()");if(D)throw new Error(D.message);if(!ft(m,!0)){const{message:Q}=ee("MISSING_OR_INVALID",`approve() relayProtocol: ${m}`);throw new Error(Q)}bt(P)||t.validateSessionProps(P,"sessionProperties")});return function(l){return a.apply(this,arguments)}}(),this.isValidReject=function(){var a=(0,N.Z)(function*(l){if(!xt(l)){const{message:m}=ee("MISSING_OR_INVALID",`reject() params: ${l}`);throw new Error(m)}const{id:d,reason:p}=l;if(yield t.isValidProposalId(d),!((n=p)&&"object"==typeof n&&n.code&&xo(n.code,!1)&&n.message&&ft(n.message,!1))){const{message:m}=ee("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(p)}`);throw new Error(m)}var n});return function(l){return a.apply(this,arguments)}}(),this.isValidSessionSettleRequest=a=>{if(!xt(a)){const{message:T}=ee("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${a}`);throw new Error(T)}const{relay:l,controller:d,namespaces:p,expiry:m}=a;if(!wu(l)){const{message:T}=ee("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(T)}const P=function(n,e){let t=null;return ft(n?.publicKey,!1)||(t=ee("MISSING_OR_INVALID","onSessionSettleRequest() controller public key should be a string")),t}(d);if(P)throw new Error(P.message);const S=Vi(p,"onSessionSettleRequest()");if(S)throw new Error(S.message);if(Nr(m)){const{message:T}=ee("EXPIRED","onSessionSettleRequest()");throw new Error(T)}},this.isValidUpdate=function(){var a=(0,N.Z)(function*(l){if(!xt(l)){const{message:T}=ee("MISSING_OR_INVALID",`update() params: ${l}`);throw new Error(T)}const{topic:d,namespaces:p}=l;yield t.isValidSessionTopic(d);const m=t.client.session.get(d),P=Vi(p,"update()");if(P)throw new Error(P.message);const S=No(m.requiredNamespaces,p,"update()");if(S)throw new Error(S.message)});return function(l){return a.apply(this,arguments)}}(),this.isValidExtend=function(){var a=(0,N.Z)(function*(l){if(!xt(l)){const{message:p}=ee("MISSING_OR_INVALID",`extend() params: ${l}`);throw new Error(p)}const{topic:d}=l;yield t.isValidSessionTopic(d)});return function(l){return a.apply(this,arguments)}}(),this.isValidRequest=function(){var a=(0,N.Z)(function*(l){if(!xt(l)){const{message:T}=ee("MISSING_OR_INVALID",`request() params: ${l}`);throw new Error(T)}const{topic:d,request:p,chainId:m,expiry:P}=l;yield t.isValidSessionTopic(d);const{namespaces:S}=t.client.session.get(d);if(!Eu(S,m)){const{message:T}=ee("MISSING_OR_INVALID",`request() chainId: ${m}`);throw new Error(T)}if(bt(n=p)||!ft(n.method,!1)){const{message:T}=ee("MISSING_OR_INVALID",`request() ${JSON.stringify(p)}`);throw new Error(T)}var n;if(!function(n,e,t){return!!ft(t,!1)&&function(n,e){const t=[];return Object.values(n).forEach(a=>{Sn(a.accounts).includes(e)&&t.push(...a.methods)}),t}(n,e).includes(t)}(S,m,p.method)){const{message:T}=ee("MISSING_OR_INVALID",`request() method: ${p.method}`);throw new Error(T)}if(P&&!function(n,e){return xo(n,!1)&&n<=e.max&&n>=e.min}(P,Uo)){const{message:T}=ee("MISSING_OR_INVALID",`request() expiry: ${P}. Expiry must be a number (in seconds) between ${Uo.min} and ${Uo.max}`);throw new Error(T)}});return function(l){return a.apply(this,arguments)}}(),this.isValidRespond=function(){var a=(0,N.Z)(function*(l){if(!xt(l)){const{message:m}=ee("MISSING_OR_INVALID",`respond() params: ${l}`);throw new Error(m)}const{topic:d,response:p}=l;if(yield t.isValidSessionTopic(d),bt(n=p)||bt(n.result)&&bt(n.error)||!xo(n.id,!1)||!ft(n.jsonrpc,!1)){const{message:m}=ee("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(p)}`);throw new Error(m)}var n});return function(l){return a.apply(this,arguments)}}(),this.isValidPing=function(){var a=(0,N.Z)(function*(l){if(!xt(l)){const{message:p}=ee("MISSING_OR_INVALID",`ping() params: ${l}`);throw new Error(p)}const{topic:d}=l;yield t.isValidSessionOrPairingTopic(d)});return function(l){return a.apply(this,arguments)}}(),this.isValidEmit=function(){var a=(0,N.Z)(function*(l){if(!xt(l)){const{message:S}=ee("MISSING_OR_INVALID",`emit() params: ${l}`);throw new Error(S)}const{topic:d,event:p,chainId:m}=l;yield t.isValidSessionTopic(d);const{namespaces:P}=t.client.session.get(d);if(!Eu(P,m)){const{message:S}=ee("MISSING_OR_INVALID",`emit() chainId: ${m}`);throw new Error(S)}if(bt(n=p)||!ft(n.name,!1)){const{message:S}=ee("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(p)}`);throw new Error(S)}var n;if(!function(n,e,t){return!!ft(t,!1)&&function(n,e){const t=[];return Object.values(n).forEach(a=>{Sn(a.accounts).includes(e)&&t.push(...a.events)}),t}(n,e).includes(t)}(P,m,p.name)){const{message:S}=ee("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(p)}`);throw new Error(S)}});return function(l){return a.apply(this,arguments)}}(),this.isValidDisconnect=function(){var a=(0,N.Z)(function*(l){if(!xt(l)){const{message:p}=ee("MISSING_OR_INVALID",`disconnect() params: ${l}`);throw new Error(p)}const{topic:d}=l;yield t.isValidSessionOrPairingTopic(d)});return function(l){return a.apply(this,arguments)}}(),this.getVerifyContext=function(){var a=(0,N.Z)(function*(l,d){const p={verified:{verifyUrl:d.verifyUrl||"",validation:"UNKNOWN",origin:d.url||""}};try{const m=yield t.client.core.verify.resolve({attestationId:l,verifyUrl:d.verifyUrl});m&&(p.verified.origin=m,p.verified.validation=m===d.url?"VALID":"INVALID")}catch(m){t.client.logger.error(m)}return t.client.logger.info(`Verify context: ${JSON.stringify(p)}`),p});return function(l,d){return a.apply(this,arguments)}}(),this.validateSessionProps=(a,l)=>{Object.values(a).forEach(d=>{if(!ft(d,!1)){const{message:p}=ee("MISSING_OR_INVALID",`${l} must be in Record<string, string> format. Received: ${JSON.stringify(d)}`);throw new Error(p)}})}}isInitialized(){if(!this.initialized){const{message:e}=ee("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){var e=this;this.client.core.relayer.on("relayer_message",function(){var t=(0,N.Z)(function*(a){const{topic:l,message:d}=a;if(e.ignoredPayloadTypes.includes(e.client.core.crypto.getPayloadType(d)))return;const p=yield e.client.core.crypto.decode(l,d);(0,xe.isJsonRpcRequest)(p)?(e.client.core.history.set(l,p),e.onRelayEventRequest({topic:l,payload:p})):(0,xe.isJsonRpcResponse)(p)?(yield e.client.core.history.resolve(p),yield e.onRelayEventResponse({topic:l,payload:p}),e.client.core.history.delete(l,p.id)):e.onRelayEventUnknownPayload({topic:l,payload:p})});return function(a){return t.apply(this,arguments)}}())}registerExpirerEvents(){var e=this;this.client.core.expirer.on(Mt_expired,function(){var t=(0,N.Z)(function*(a){const{topic:l,id:d}=du(a.target);if(d&&e.client.pendingRequest.keys.includes(d))return yield e.deletePendingSessionRequest(d,ee("EXPIRED"),!0);l?e.client.session.keys.includes(l)&&(yield e.deleteSession(l,!0),e.client.events.emit("session_expire",{topic:l})):d&&(yield e.deleteProposal(d,!0),e.client.events.emit("proposal_expire",{id:d}))});return function(a){return t.apply(this,arguments)}}())}isValidPairingTopic(e){if(!ft(e,!1)){const{message:t}=ee("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}=ee("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(Nr(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=ee("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}isValidSessionTopic(e){var t=this;return(0,N.Z)(function*(){if(!ft(e,!1)){const{message:a}=ee("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(a)}if(!t.client.session.keys.includes(e)){const{message:a}=ee("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(a)}if(Nr(t.client.session.get(e).expiry)){yield t.deleteSession(e);const{message:a}=ee("EXPIRED",`session topic: ${e}`);throw new Error(a)}})()}isValidSessionOrPairingTopic(e){var t=this;return(0,N.Z)(function*(){if(t.client.session.keys.includes(e))yield t.isValidSessionTopic(e);else{if(!t.client.core.pairing.pairings.keys.includes(e)){if(ft(e,!1)){const{message:a}=ee("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(a)}{const{message:a}=ee("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(a)}}t.isValidPairingTopic(e)}})()}isValidProposalId(e){var t=this;return(0,N.Z)(function*(){if("number"!=typeof e){const{message:a}=ee("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(a)}if(!t.client.proposal.keys.includes(e)){const{message:a}=ee("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(a)}if(Nr(t.client.proposal.get(e).expiry)){yield t.deleteProposal(e);const{message:a}=ee("EXPIRED",`proposal id: ${e}`);throw new Error(a)}})()}}class Uv extends Bi{constructor(e,t){super(e,t,"proposal",Do),this.core=e,this.logger=t}}class Lv extends Bi{constructor(e,t){super(e,t,"session",Do),this.core=e,this.logger=t}}class kv extends Bi{constructor(e,t){super(e,t,"request",Do,a=>a.id),this.core=e,this.logger=t}}class ko extends class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}}{constructor(e){var t;super(e),t=this,this.protocol="wc",this.version=2,this.name="client",this.events=new Le.EventEmitter,this.on=(l,d)=>this.events.on(l,d),this.once=(l,d)=>this.events.once(l,d),this.off=(l,d)=>this.events.off(l,d),this.removeListener=(l,d)=>this.events.removeListener(l,d),this.removeAllListeners=l=>this.events.removeAllListeners(l),this.connect=function(){var l=(0,N.Z)(function*(d){try{return yield t.engine.connect(d)}catch(p){throw t.logger.error(p.message),p}});return function(d){return l.apply(this,arguments)}}(),this.pair=function(){var l=(0,N.Z)(function*(d){try{return yield t.engine.pair(d)}catch(p){throw t.logger.error(p.message),p}});return function(d){return l.apply(this,arguments)}}(),this.approve=function(){var l=(0,N.Z)(function*(d){try{return yield t.engine.approve(d)}catch(p){throw t.logger.error(p.message),p}});return function(d){return l.apply(this,arguments)}}(),this.reject=function(){var l=(0,N.Z)(function*(d){try{return yield t.engine.reject(d)}catch(p){throw t.logger.error(p.message),p}});return function(d){return l.apply(this,arguments)}}(),this.update=function(){var l=(0,N.Z)(function*(d){try{return yield t.engine.update(d)}catch(p){throw t.logger.error(p.message),p}});return function(d){return l.apply(this,arguments)}}(),this.extend=function(){var l=(0,N.Z)(function*(d){try{return yield t.engine.extend(d)}catch(p){throw t.logger.error(p.message),p}});return function(d){return l.apply(this,arguments)}}(),this.request=function(){var l=(0,N.Z)(function*(d){try{return yield t.engine.request(d)}catch(p){throw t.logger.error(p.message),p}});return function(d){return l.apply(this,arguments)}}(),this.respond=function(){var l=(0,N.Z)(function*(d){try{return yield t.engine.respond(d)}catch(p){throw t.logger.error(p.message),p}});return function(d){return l.apply(this,arguments)}}(),this.ping=function(){var l=(0,N.Z)(function*(d){try{return yield t.engine.ping(d)}catch(p){throw t.logger.error(p.message),p}});return function(d){return l.apply(this,arguments)}}(),this.emit=function(){var l=(0,N.Z)(function*(d){try{return yield t.engine.emit(d)}catch(p){throw t.logger.error(p.message),p}});return function(d){return l.apply(this,arguments)}}(),this.disconnect=function(){var l=(0,N.Z)(function*(d){try{return yield t.engine.disconnect(d)}catch(p){throw t.logger.error(p.message),p}});return function(d){return l.apply(this,arguments)}}(),this.find=l=>{try{return this.engine.find(l)}catch(d){throw this.logger.error(d.message),d}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(l){throw this.logger.error(l.message),l}},this.name=e?.name||"client",this.metadata=e?.metadata||(0,_g.D)()||{name:"",description:"",url:"",icons:[""]};const a=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:Ti()(ho({level:e?.logger||"error"}));this.core=e?.core||new Ov(e),this.logger=Tt(a,this.name),this.session=new Lv(this.core,this.logger),this.proposal=new Uv(this.core,this.logger),this.pendingRequest=new kv(this.core,this.logger),this.engine=new Fv(this)}static init(e){return(0,N.Z)(function*(){const t=new ko(e);return yield t.initialize(),t})()}get context(){return St(this.logger)}get pairing(){return this.core.pairing.pairings}initialize(){var e=this;return(0,N.Z)(function*(){e.logger.trace("Initialized");try{yield e.core.start(),yield e.session.init(),yield e.proposal.init(),yield e.pendingRequest.init(),yield e.engine.init(),e.core.verify.init({verifyUrl:e.metadata.verifyUrl}),e.logger.info("SignClient Initialization Success")}catch(t){throw e.logger.info("SignClient Initialization Failure"),e.logger.error(t.message),t}})()}}function ur(n=[],e=[]){return[...new Set([...n,...e])]}function Yi(n){return n.includes(":")}function ni(n){return Yi(n)?n.split(":")[0]:n}H(7092),H(47274),H(49290);const C0={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}};function Tr(n,e){const{message:t,code:a}=C0[n];return{message:e?`${t} ${e}`:t,code:a}}function Pn(n,e){return!!Array.isArray(n)&&(!(typeof e<"u"&&n.length)||n.every(e))}Symbol;var H0=Object.defineProperty,G0=Object.defineProperties,J0=Object.getOwnPropertyDescriptors,jl=Object.getOwnPropertySymbols,Y0=Object.prototype.hasOwnProperty,Q0=Object.prototype.propertyIsEnumerable,$l=(n,e,t)=>e in n?H0(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,rn=H(6930);const Fl="wc@2:universal_provider:";var n,e,si=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Jo={exports:{}};n=Jo,e=Jo.exports,function(){var t,p="Expected a function",P="__lodash_hash_undefined__",T="__lodash_placeholder__",nn=1/0,Dr=9007199254740991,lr=4294967295,Xb=[["ary",128],["bind",1],["bindKey",2],["curry",8],["curryRight",16],["flip",512],["partial",32],["partialRight",64],["rearg",256]],Rn="[object Arguments]",us="[object Array]",ci="[object Boolean]",ai="[object Date]",ls="[object Error]",fs="[object Function]",Jl="[object GeneratorFunction]",er="[object Map]",ui="[object Number]",pr="[object Object]",Yl="[object Promise]",li="[object RegExp]",tr="[object Set]",fi="[object String]",ds="[object Symbol]",di="[object WeakMap]",hi="[object ArrayBuffer]",An="[object DataView]",rc="[object Float32Array]",nc="[object Float64Array]",ic="[object Int8Array]",sc="[object Int16Array]",oc="[object Int32Array]",cc="[object Uint8Array]",ac="[object Uint8ClampedArray]",uc="[object Uint16Array]",lc="[object Uint32Array]",ow=/\b__p \+= '';/g,cw=/\b(__p \+=) '' \+/g,aw=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ql=/&(?:amp|lt|gt|quot|#39);/g,Xl=/[&<>"']/g,uw=RegExp(Ql.source),lw=RegExp(Xl.source),fw=/<%-([\s\S]+?)%>/g,dw=/<%([\s\S]+?)%>/g,ef=/<%=([\s\S]+?)%>/g,hw=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,pw=/^\w*$/,gw=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,fc=/[\\^$.*+?()[\]{}|]/g,_w=RegExp(fc.source),dc=/^\s+/,yw=/\s/,mw=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,vw=/\{\n\/\* \[wrapped with (.+)\] \*/,bw=/,? & /,ww=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Ew=/[()=,{}\[\]\/\s]/,Iw=/\\(\\)?/g,Ow=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,tf=/\w*$/,Sw=/^[-+]0x[0-9a-f]+$/i,xw=/^0b[01]+$/i,Nw=/^\[object .+?Constructor\]$/,Pw=/^0o[0-7]+$/i,Rw=/^(?:0|[1-9]\d*)$/,Aw=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,hs=/($^)/,Cw=/['\n\r\u2028\u2029\\]/g,ps="\\ud800-\\udfff",rf="\\u0300-\\u036f\\ufe20-\\ufe2f\\u20d0-\\u20ff",nf="\\u2700-\\u27bf",sf="a-z\\xdf-\\xf6\\xf8-\\xff",of="A-Z\\xc0-\\xd6\\xd8-\\xde",cf="\\ufe0e\\ufe0f",af="\\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",kw="["+ps+"]",uf="["+af+"]",gs="["+rf+"]",lf="\\d+",Mw="["+nf+"]",ff="["+sf+"]",df="[^"+ps+af+lf+nf+sf+of+"]",pc="\\ud83c[\\udffb-\\udfff]",hf="[^"+ps+"]",gc="(?:\\ud83c[\\udde6-\\uddff]){2}",_c="[\\ud800-\\udbff][\\udc00-\\udfff]",Cn="["+of+"]",gf="(?:"+ff+"|"+df+")",zw="(?:"+Cn+"|"+df+")",_f="(?:['\u2019](?:d|ll|m|re|s|t|ve))?",yf="(?:['\u2019](?:D|LL|M|RE|S|T|VE))?",mf="(?:"+gs+"|"+pc+")?",vf="["+cf+"]?",bf=vf+mf+"(?:\\u200d(?:"+[hf,gc,_c].join("|")+")"+vf+mf+")*",Bw="(?:"+[Mw,gc,_c].join("|")+")"+bf,Ww="(?:"+[hf+gs+"?",gs,gc,_c,kw].join("|")+")",Hw=RegExp("['\u2019]","g"),Gw=RegExp(gs,"g"),yc=RegExp(pc+"(?="+pc+")|"+Ww+bf,"g"),Jw=RegExp([Cn+"?"+ff+"+"+_f+"(?="+[uf,Cn,"$"].join("|")+")",zw+"+"+yf+"(?="+[uf,Cn+gf,"$"].join("|")+")",Cn+"?"+gf+"+"+_f,Cn+"+"+yf,"\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])","\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",lf,Bw].join("|"),"g"),Yw=RegExp("[\\u200d"+ps+rf+cf+"]"),Qw=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,Xw=["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"],e1=-1,Ge={};Ge[rc]=Ge[nc]=Ge[ic]=Ge[sc]=Ge[oc]=Ge[cc]=Ge[ac]=Ge[uc]=Ge[lc]=!0,Ge[Rn]=Ge[us]=Ge[hi]=Ge[ci]=Ge[An]=Ge[ai]=Ge[ls]=Ge[fs]=Ge[er]=Ge[ui]=Ge[pr]=Ge[li]=Ge[tr]=Ge[fi]=Ge[di]=!1;var He={};He[Rn]=He[us]=He[hi]=He[An]=He[ci]=He[ai]=He[rc]=He[nc]=He[ic]=He[sc]=He[oc]=He[er]=He[ui]=He[pr]=He[li]=He[tr]=He[fi]=He[ds]=He[cc]=He[ac]=He[uc]=He[lc]=!0,He[ls]=He[fs]=He[di]=!1;var i1={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},s1=parseFloat,o1=parseInt,wf="object"==typeof si&&si&&si.Object===Object&&si,c1="object"==typeof self&&self&&self.Object===Object&&self,gt=wf||c1||Function("return this")(),mc=e&&!e.nodeType&&e,sn=mc&&n&&!n.nodeType&&n,Ef=sn&&sn.exports===mc,vc=Ef&&wf.process,Vt=function(){try{return sn&&sn.require&&sn.require("util").types||vc&&vc.binding&&vc.binding("util")}catch{}}(),If=Vt&&Vt.isArrayBuffer,Of=Vt&&Vt.isDate,Sf=Vt&&Vt.isMap,xf=Vt&&Vt.isRegExp,Nf=Vt&&Vt.isSet,Pf=Vt&&Vt.isTypedArray;function jt(j,q,F){switch(F.length){case 0:return j.call(q);case 1:return j.call(q,F[0]);case 2:return j.call(q,F[0],F[1]);case 3:return j.call(q,F[0],F[1],F[2])}return j.apply(q,F)}function a1(j,q,F,re){for(var be=-1,ze=null==j?0:j.length;++be<ze;){var at=j[be];q(re,at,F(at),j)}return re}function Kt(j,q){for(var F=-1,re=null==j?0:j.length;++F<re&&!1!==q(j[F],F,j););return j}function u1(j,q){for(var F=null==j?0:j.length;F--&&!1!==q(j[F],F,j););return j}function Rf(j,q){for(var F=-1,re=null==j?0:j.length;++F<re;)if(!q(j[F],F,j))return!1;return!0}function Fr(j,q){for(var F=-1,re=null==j?0:j.length,be=0,ze=[];++F<re;){var at=j[F];q(at,F,j)&&(ze[be++]=at)}return ze}function _s(j,q){return!(null==j||!j.length)&&Tn(j,q,0)>-1}function bc(j,q,F){for(var re=-1,be=null==j?0:j.length;++re<be;)if(F(q,j[re]))return!0;return!1}function Qe(j,q){for(var F=-1,re=null==j?0:j.length,be=Array(re);++F<re;)be[F]=q(j[F],F,j);return be}function Ur(j,q){for(var F=-1,re=q.length,be=j.length;++F<re;)j[be+F]=q[F];return j}function wc(j,q,F,re){var be=-1,ze=null==j?0:j.length;for(re&&ze&&(F=j[++be]);++be<ze;)F=q(F,j[be],be,j);return F}function l1(j,q,F,re){var be=null==j?0:j.length;for(re&&be&&(F=j[--be]);be--;)F=q(F,j[be],be,j);return F}function Ec(j,q){for(var F=-1,re=null==j?0:j.length;++F<re;)if(q(j[F],F,j))return!0;return!1}var f1=Ic("length");function Af(j,q,F){var re;return F(j,function(be,ze,at){if(q(be,ze,at))return re=ze,!1}),re}function ys(j,q,F,re){for(var be=j.length,ze=F+(re?1:-1);re?ze--:++ze<be;)if(q(j[ze],ze,j))return ze;return-1}function Tn(j,q,F){return q==q?function(j,q,F){for(var re=F-1,be=j.length;++re<be;)if(j[re]===q)return re;return-1}(j,q,F):ys(j,Cf,F)}function p1(j,q,F,re){for(var be=F-1,ze=j.length;++be<ze;)if(re(j[be],q))return be;return-1}function Cf(j){return j!=j}function Tf(j,q){var F=null==j?0:j.length;return F?Sc(j,q)/F:NaN}function Ic(j){return function(q){return null==q?t:q[j]}}function Oc(j){return function(q){return null==j?t:j[q]}}function jf(j,q,F,re,be){return be(j,function(ze,at,Be){F=re?(re=!1,ze):q(F,ze,at,Be)}),F}function Sc(j,q){for(var F,re=-1,be=j.length;++re<be;){var ze=q(j[re]);ze!==t&&(F=F===t?ze:F+ze)}return F}function xc(j,q){for(var F=-1,re=Array(j);++F<j;)re[F]=q(F);return re}function $f(j){return j&&j.slice(0,Lf(j)+1).replace(dc,"")}function $t(j){return function(q){return j(q)}}function Nc(j,q){return Qe(q,function(F){return j[F]})}function pi(j,q){return j.has(q)}function Df(j,q){for(var F=-1,re=j.length;++F<re&&Tn(q,j[F],0)>-1;);return F}function Ff(j,q){for(var F=j.length;F--&&Tn(q,j[F],0)>-1;);return F}function y1(j,q){for(var F=j.length,re=0;F--;)j[F]===q&&++re;return re}var m1=Oc({\u00c0:"A",\u00c1:"A",\u00c2:"A",\u00c3:"A",\u00c4:"A",\u00c5:"A",\u00e0:"a",\u00e1:"a",\u00e2:"a",\u00e3:"a",\u00e4:"a",\u00e5:"a",\u00c7:"C",\u00e7:"c",\u00d0:"D",\u00f0:"d",\u00c8:"E",\u00c9:"E",\u00ca:"E",\u00cb:"E",\u00e8:"e",\u00e9:"e",\u00ea:"e",\u00eb:"e",\u00cc:"I",\u00cd:"I",\u00ce:"I",\u00cf:"I",\u00ec:"i",\u00ed:"i",\u00ee:"i",\u00ef:"i",\u00d1:"N",\u00f1:"n",\u00d2:"O",\u00d3:"O",\u00d4:"O",\u00d5:"O",\u00d6:"O",\u00d8:"O",\u00f2:"o",\u00f3:"o",\u00f4:"o",\u00f5:"o",\u00f6:"o",\u00f8:"o",\u00d9:"U",\u00da:"U",\u00db:"U",\u00dc:"U",\u00f9:"u",\u00fa:"u",\u00fb:"u",\u00fc:"u",\u00dd:"Y",\u00fd:"y",\u00ff:"y",\u00c6:"Ae",\u00e6:"ae",\u00de:"Th",\u00fe:"th",\u00df:"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"}),v1=Oc({"&":"&","<":"<",">":">",'"':""","'":"'"});function b1(j){return"\\"+i1[j]}function jn(j){return Yw.test(j)}function Pc(j){var q=-1,F=Array(j.size);return j.forEach(function(re,be){F[++q]=[be,re]}),F}function Uf(j,q){return function(F){return j(q(F))}}function Lr(j,q){for(var F=-1,re=j.length,be=0,ze=[];++F<re;){var at=j[F];(at===q||at===T)&&(j[F]=T,ze[be++]=F)}return ze}function ms(j){var q=-1,F=Array(j.size);return j.forEach(function(re){F[++q]=re}),F}function $n(j){return jn(j)?function(j){for(var q=yc.lastIndex=0;yc.test(j);)++q;return q}(j):f1(j)}function rr(j){return jn(j)?function(j){return j.match(yc)||[]}(j):function(j){return j.split("")}(j)}function Lf(j){for(var q=j.length;q--&&yw.test(j.charAt(q)););return q}var N1=Oc({"&":"&","<":"<",">":">",""":'"',"'":"'"}),Dn=function j(q){var r,F=(q=null==q?gt:Dn.defaults(gt.Object(),q,Dn.pick(gt,Xw))).Array,re=q.Date,be=q.Error,ze=q.Function,at=q.Math,Be=q.Object,Rc=q.RegExp,T1=q.String,Bt=q.TypeError,vs=F.prototype,Fn=Be.prototype,bs=q["__core-js_shared__"],ws=ze.prototype.toString,Ke=Fn.hasOwnProperty,$1=0,kf=(r=/[^.]+$/.exec(bs&&bs.keys&&bs.keys.IE_PROTO||""))?"Symbol(src)_1."+r:"",Es=Fn.toString,D1=ws.call(Be),F1=gt._,U1=Rc("^"+ws.call(Ke).replace(fc,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Is=Ef?q.Buffer:t,kr=q.Symbol,Os=q.Uint8Array,Mf=Is?Is.allocUnsafe:t,Ss=Uf(Be.getPrototypeOf,Be),qf=Be.create,zf=Fn.propertyIsEnumerable,xs=vs.splice,Zf=kr?kr.isConcatSpreadable:t,gi=kr?kr.iterator:t,on=kr?kr.toStringTag:t,Ns=function(){try{var r=fn(Be,"defineProperty");return r({},"",{}),r}catch{}}(),L1=q.clearTimeout!==gt.clearTimeout&&q.clearTimeout,k1=re&&re.now!==gt.Date.now&&re.now,M1=q.setTimeout!==gt.setTimeout&&q.setTimeout,Ps=at.ceil,Rs=at.floor,Ac=Be.getOwnPropertySymbols,q1=Is?Is.isBuffer:t,Vf=q.isFinite,z1=vs.join,Z1=Uf(Be.keys,Be),ut=at.max,yt=at.min,V1=re.now,K1=q.parseInt,Kf=at.random,B1=vs.reverse,Cc=fn(q,"DataView"),_i=fn(q,"Map"),Tc=fn(q,"Promise"),Un=fn(q,"Set"),yi=fn(q,"WeakMap"),mi=fn(Be,"create"),As=yi&&new yi,Ln={},W1=dn(Cc),H1=dn(_i),G1=dn(Tc),J1=dn(Un),Y1=dn(yi),Cs=kr?kr.prototype:t,vi=Cs?Cs.valueOf:t,Bf=Cs?Cs.toString:t;function b(r){if(rt(r)&&!Ee(r)&&!(r instanceof Ae)){if(r instanceof Wt)return r;if(Ke.call(r,"__wrapped__"))return Wd(r)}return new Wt(r)}var kn=function(){function r(){}return function(o){if(!et(o))return{};if(qf)return qf(o);r.prototype=o;var f=new r;return r.prototype=t,f}}();function Ts(){}function Wt(r,o){this.__wrapped__=r,this.__actions__=[],this.__chain__=!!o,this.__index__=0,this.__values__=t}function Ae(r){this.__wrapped__=r,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=lr,this.__views__=[]}function cn(r){var o=-1,f=null==r?0:r.length;for(this.clear();++o<f;){var g=r[o];this.set(g[0],g[1])}}function gr(r){var o=-1,f=null==r?0:r.length;for(this.clear();++o<f;){var g=r[o];this.set(g[0],g[1])}}function _r(r){var o=-1,f=null==r?0:r.length;for(this.clear();++o<f;){var g=r[o];this.set(g[0],g[1])}}function an(r){var o=-1,f=null==r?0:r.length;for(this.__data__=new _r;++o<f;)this.add(r[o])}function nr(r){var o=this.__data__=new gr(r);this.size=o.size}function Wf(r,o){var f=Ee(r),g=!f&&_n(r),_=!f&&!g&&Vr(r),w=!f&&!g&&!_&&Zn(r),R=f||g||_||w,A=R?xc(r.length,T1):[],$=A.length;for(var z in r)(o||Ke.call(r,z))&&(!R||!("length"==z||_&&("offset"==z||"parent"==z)||w&&("buffer"==z||"byteLength"==z||"byteOffset"==z)||br(z,$)))&&A.push(z);return A}function Hf(r){var o=r.length;return o?r[Zc(0,o-1)]:t}function IE(r,o){return Bs(Pt(r),un(o,0,r.length))}function OE(r){return Bs(Pt(r))}function jc(r,o,f){(f!==t&&!ir(r[o],f)||f===t&&!(o in r))&&yr(r,o,f)}function bi(r,o,f){var g=r[o];(!Ke.call(r,o)||!ir(g,f)||f===t&&!(o in r))&&yr(r,o,f)}function js(r,o){for(var f=r.length;f--;)if(ir(r[f][0],o))return f;return-1}function SE(r,o,f,g){return Mr(r,function(_,w,R){o(g,_,f(_),R)}),g}function Gf(r,o){return r&&dr(o,ht(o),r)}function yr(r,o,f){"__proto__"==o&&Ns?Ns(r,o,{configurable:!0,enumerable:!0,value:f,writable:!0}):r[o]=f}function $c(r,o){for(var f=-1,g=o.length,_=F(g),w=null==r;++f<g;)_[f]=w?t:pa(r,o[f]);return _}function un(r,o,f){return r==r&&(f!==t&&(r=r<=f?r:f),o!==t&&(r=r>=o?r:o)),r}function Ht(r,o,f,g,_,w){var R,A=1&o,$=2&o,z=4&o;if(f&&(R=_?f(r,g,_,w):f(r)),R!==t)return R;if(!et(r))return r;var Z=Ee(r);if(Z){if(R=function(r){var o=r.length,f=new r.constructor(o);return o&&"string"==typeof r[0]&&Ke.call(r,"index")&&(f.index=r.index,f.input=r.input),f}(r),!A)return Pt(r,R)}else{var K=mt(r),X=K==fs||K==Jl;if(Vr(r))return vd(r,A);if(K==pr||K==Rn||X&&!_){if(R=$||X?{}:Ld(r),!A)return $?function(r,o){return dr(r,Fd(r),o)}(r,function(r,o){return r&&dr(o,At(o),r)}(R,r)):function(r,o){return dr(r,na(r),o)}(r,Gf(R,r))}else{if(!He[K])return _?r:{};R=function(r,o,f){var g=r.constructor;switch(o){case hi:return Jc(r);case ci:case ai:return new g(+r);case An:return function(r,o){var f=o?Jc(r.buffer):r.buffer;return new r.constructor(f,r.byteOffset,r.byteLength)}(r,f);case rc:case nc:case ic:case sc:case oc:case cc:case ac:case uc:case lc:return bd(r,f);case er:return new g;case ui:case fi:return new g(r);case li:return function(r){var o=new r.constructor(r.source,tf.exec(r));return o.lastIndex=r.lastIndex,o}(r);case tr:return new g;case ds:return function(r){return vi?Be(vi.call(r)):{}}(r)}}(r,K,A)}}w||(w=new nr);var ne=w.get(r);if(ne)return ne;w.set(r,R),hh(r)?r.forEach(function(_e){R.add(Ht(_e,o,f,_e,r,w))}):fh(r)&&r.forEach(function(_e,Re){R.set(Re,Ht(_e,o,f,Re,r,w))});var Se=Z?t:(z?$?ea:Xc:$?At:ht)(r);return Kt(Se||r,function(_e,Re){Se&&(_e=r[Re=_e]),bi(R,Re,Ht(_e,o,f,Re,r,w))}),R}function Jf(r,o,f){var g=f.length;if(null==r)return!g;for(r=Be(r);g--;){var _=f[g],R=r[_];if(R===t&&!(_ in r)||!(0,o[_])(R))return!1}return!0}function Yf(r,o,f){if("function"!=typeof r)throw new Bt(p);return Ni(function(){r.apply(t,f)},o)}function wi(r,o,f,g){var _=-1,w=_s,R=!0,A=r.length,$=[],z=o.length;if(!A)return $;f&&(o=Qe(o,$t(f))),g?(w=bc,R=!1):o.length>=200&&(w=pi,R=!1,o=new an(o));e:for(;++_<A;){var Z=r[_],K=null==f?Z:f(Z);if(Z=g||0!==Z?Z:0,R&&K==K){for(var X=z;X--;)if(o[X]===K)continue e;$.push(Z)}else w(o,K,g)||$.push(Z)}return $}b.templateSettings={escape:fw,evaluate:dw,interpolate:ef,variable:"",imports:{_:b}},(b.prototype=Ts.prototype).constructor=b,(Wt.prototype=kn(Ts.prototype)).constructor=Wt,(Ae.prototype=kn(Ts.prototype)).constructor=Ae,cn.prototype.clear=function(){this.__data__=mi?mi(null):{},this.size=0},cn.prototype.delete=function(r){var o=this.has(r)&&delete this.__data__[r];return this.size-=o?1:0,o},cn.prototype.get=function(r){var o=this.__data__;if(mi){var f=o[r];return f===P?t:f}return Ke.call(o,r)?o[r]:t},cn.prototype.has=function(r){var o=this.__data__;return mi?o[r]!==t:Ke.call(o,r)},cn.prototype.set=function(r,o){var f=this.__data__;return this.size+=this.has(r)?0:1,f[r]=mi&&o===t?P:o,this},gr.prototype.clear=function(){this.__data__=[],this.size=0},gr.prototype.delete=function(r){var o=this.__data__,f=js(o,r);return!(f<0||(f==o.length-1?o.pop():xs.call(o,f,1),--this.size,0))},gr.prototype.get=function(r){var o=this.__data__,f=js(o,r);return f<0?t:o[f][1]},gr.prototype.has=function(r){return js(this.__data__,r)>-1},gr.prototype.set=function(r,o){var f=this.__data__,g=js(f,r);return g<0?(++this.size,f.push([r,o])):f[g][1]=o,this},_r.prototype.clear=function(){this.size=0,this.__data__={hash:new cn,map:new(_i||gr),string:new cn}},_r.prototype.delete=function(r){var o=Ks(this,r).delete(r);return this.size-=o?1:0,o},_r.prototype.get=function(r){return Ks(this,r).get(r)},_r.prototype.has=function(r){return Ks(this,r).has(r)},_r.prototype.set=function(r,o){var f=Ks(this,r),g=f.size;return f.set(r,o),this.size+=f.size==g?0:1,this},an.prototype.add=an.prototype.push=function(r){return this.__data__.set(r,P),this},an.prototype.has=function(r){return this.__data__.has(r)},nr.prototype.clear=function(){this.__data__=new gr,this.size=0},nr.prototype.delete=function(r){var o=this.__data__,f=o.delete(r);return this.size=o.size,f},nr.prototype.get=function(r){return this.__data__.get(r)},nr.prototype.has=function(r){return this.__data__.has(r)},nr.prototype.set=function(r,o){var f=this.__data__;if(f instanceof gr){var g=f.__data__;if(!_i||g.length<199)return g.push([r,o]),this.size=++f.size,this;f=this.__data__=new _r(g)}return f.set(r,o),this.size=f.size,this};var Mr=Od(fr),Qf=Od(Fc,!0);function PE(r,o){var f=!0;return Mr(r,function(g,_,w){return f=!!o(g,_,w)}),f}function $s(r,o,f){for(var g=-1,_=r.length;++g<_;){var w=r[g],R=o(w);if(null!=R&&(A===t?R==R&&!Ft(R):f(R,A)))var A=R,$=w}return $}function Xf(r,o){var f=[];return Mr(r,function(g,_,w){o(g,_,w)&&f.push(g)}),f}function _t(r,o,f,g,_){var w=-1,R=r.length;for(f||(f=yI),_||(_=[]);++w<R;){var A=r[w];o>0&&f(A)?o>1?_t(A,o-1,f,g,_):Ur(_,A):g||(_[_.length]=A)}return _}var Dc=Sd(),ed=Sd(!0);function fr(r,o){return r&&Dc(r,o,ht)}function Fc(r,o){return r&&ed(r,o,ht)}function Ds(r,o){return Fr(o,function(f){return wr(r[f])})}function ln(r,o){for(var f=0,g=(o=zr(o,r)).length;null!=r&&f<g;)r=r[hr(o[f++])];return f&&f==g?r:t}function td(r,o,f){var g=o(r);return Ee(r)?g:Ur(g,f(r))}function wt(r){return null==r?r===t?"[object Undefined]":"[object Null]":on&&on in Be(r)?function(r){var o=Ke.call(r,on),f=r[on];try{r[on]=t;var g=!0}catch{}var _=Es.call(r);return g&&(o?r[on]=f:delete r[on]),_}(r):function(r){return Es.call(r)}(r)}function Uc(r,o){return r>o}function AE(r,o){return null!=r&&Ke.call(r,o)}function CE(r,o){return null!=r&&o in Be(r)}function Lc(r,o,f){for(var g=f?bc:_s,_=r[0].length,w=r.length,R=w,A=F(w),$=1/0,z=[];R--;){var Z=r[R];R&&o&&(Z=Qe(Z,$t(o))),$=yt(Z.length,$),A[R]=!f&&(o||_>=120&&Z.length>=120)?new an(R&&Z):t}Z=r[0];var K=-1,X=A[0];e:for(;++K<_&&z.length<$;){var ne=Z[K],ge=o?o(ne):ne;if(ne=f||0!==ne?ne:0,!(X?pi(X,ge):g(z,ge,f))){for(R=w;--R;){var Se=A[R];if(!(Se?pi(Se,ge):g(r[R],ge,f)))continue e}X&&X.push(ge),z.push(ne)}}return z}function Ei(r,o,f){var g=null==(r=zd(r,o=zr(o,r)))?r:r[hr(Jt(o))];return null==g?t:jt(g,r,f)}function rd(r){return rt(r)&&wt(r)==Rn}function Ii(r,o,f,g,_){return r===o||(null==r||null==o||!rt(r)&&!rt(o)?r!=r&&o!=o:function(r,o,f,g,_,w){var R=Ee(r),A=Ee(o),$=R?us:mt(r),z=A?us:mt(o),Z=($=$==Rn?pr:$)==pr,K=(z=z==Rn?pr:z)==pr,X=$==z;if(X&&Vr(r)){if(!Vr(o))return!1;R=!0,Z=!1}if(X&&!Z)return w||(w=new nr),R||Zn(r)?Dd(r,o,f,g,_,w):function(r,o,f,g,_,w,R){switch(f){case An:if(r.byteLength!=o.byteLength||r.byteOffset!=o.byteOffset)return!1;r=r.buffer,o=o.buffer;case hi:return!(r.byteLength!=o.byteLength||!w(new Os(r),new Os(o)));case ci:case ai:case ui:return ir(+r,+o);case ls:return r.name==o.name&&r.message==o.message;case li:case fi:return r==o+"";case er:var A=Pc;case tr:if(A||(A=ms),r.size!=o.size&&!(1&g))return!1;var z=R.get(r);if(z)return z==o;g|=2,R.set(r,o);var Z=Dd(A(r),A(o),g,_,w,R);return R.delete(r),Z;case ds:if(vi)return vi.call(r)==vi.call(o)}return!1}(r,o,$,f,g,_,w);if(!(1&f)){var ne=Z&&Ke.call(r,"__wrapped__"),ge=K&&Ke.call(o,"__wrapped__");if(ne||ge){var Se=ne?r.value():r,_e=ge?o.value():o;return w||(w=new nr),_(Se,_e,f,g,w)}}return!!X&&(w||(w=new nr),function(r,o,f,g,_,w){var R=1&f,A=Xc(r),$=A.length;if($!=Xc(o).length&&!R)return!1;for(var K=$;K--;){var X=A[K];if(!(R?X in o:Ke.call(o,X)))return!1}var ne=w.get(r),ge=w.get(o);if(ne&&ge)return ne==o&&ge==r;var Se=!0;w.set(r,o),w.set(o,r);for(var _e=R;++K<$;){var Re=r[X=A[K]],Ce=o[X];if(g)var Ut=R?g(Ce,Re,X,o,r,w):g(Re,Ce,X,r,o,w);if(!(Ut===t?Re===Ce||_(Re,Ce,f,g,w):Ut)){Se=!1;break}_e||(_e="constructor"==X)}if(Se&&!_e){var It=r.constructor,Lt=o.constructor;It!=Lt&&"constructor"in r&&"constructor"in o&&!("function"==typeof It&&It instanceof It&&"function"==typeof Lt&&Lt instanceof Lt)&&(Se=!1)}return w.delete(r),w.delete(o),Se}(r,o,f,g,_,w))}(r,o,f,g,Ii,_))}function kc(r,o,f,g){var _=f.length,w=_,R=!g;if(null==r)return!w;for(r=Be(r);_--;){var A=f[_];if(R&&A[2]?A[1]!==r[A[0]]:!(A[0]in r))return!1}for(;++_<w;){var $=(A=f[_])[0],z=r[$],Z=A[1];if(R&&A[2]){if(z===t&&!($ in r))return!1}else{var K=new nr;if(g)var X=g(z,Z,$,r,o,K);if(!(X===t?Ii(Z,z,3,g,K):X))return!1}}return!0}function nd(r){return!(!et(r)||function(r){return!!kf&&kf in r}(r))&&(wr(r)?U1:Nw).test(dn(r))}function id(r){return"function"==typeof r?r:null==r?Ct:"object"==typeof r?Ee(r)?cd(r[0],r[1]):od(r):xh(r)}function Mc(r){if(!xi(r))return Z1(r);var o=[];for(var f in Be(r))Ke.call(r,f)&&"constructor"!=f&&o.push(f);return o}function qc(r,o){return r<o}function sd(r,o){var f=-1,g=Rt(r)?F(r.length):[];return Mr(r,function(_,w,R){g[++f]=o(_,w,R)}),g}function od(r){var o=ra(r);return 1==o.length&&o[0][2]?Md(o[0][0],o[0][1]):function(f){return f===r||kc(f,r,o)}}function cd(r,o){return ia(r)&&kd(o)?Md(hr(r),o):function(f){var g=pa(f,r);return g===t&&g===o?ga(f,r):Ii(o,g,3)}}function Fs(r,o,f,g,_){r!==o&&Dc(o,function(w,R){if(_||(_=new nr),et(w))!function(r,o,f,g,_,w,R){var A=oa(r,f),$=oa(o,f),z=R.get($);if(z)jc(r,f,z);else{var Z=w?w(A,$,f+"",r,o,R):t,K=Z===t;if(K){var X=Ee($),ne=!X&&Vr($),ge=!X&&!ne&&Zn($);Z=$,X||ne||ge?Ee(A)?Z=A:it(A)?Z=Pt(A):ne?(K=!1,Z=vd($,!0)):ge?(K=!1,Z=bd($,!0)):Z=[]:Pi($)||_n($)?(Z=A,_n(A)?Z=_h(A):(!et(A)||wr(A))&&(Z=Ld($))):K=!1}K&&(R.set($,Z),_(Z,$,g,w,R),R.delete($)),jc(r,f,Z)}}(r,o,R,f,Fs,g,_);else{var A=g?g(oa(r,R),w,R+"",r,o,_):t;A===t&&(A=w),jc(r,R,A)}},At)}function ad(r,o){var f=r.length;if(f)return br(o+=o<0?f:0,f)?r[o]:t}function ud(r,o,f){o=o.length?Qe(o,function(w){return Ee(w)?function(R){return ln(R,1===w.length?w[0]:w)}:w}):[Ct];var g=-1;return o=Qe(o,$t(he())),function(j,q){var F=j.length;for(j.sort(function(w,R){return function(r,o,f){for(var g=-1,_=r.criteria,w=o.criteria,R=_.length,A=f.length;++g<R;){var $=wd(_[g],w[g]);if($)return g>=A?$:$*("desc"==f[g]?-1:1)}return r.index-o.index}(w,R,f)});F--;)j[F]=j[F].value;return j}(sd(r,function(w,R,A){return{criteria:Qe(o,function(z){return z(w)}),index:++g,value:w}}))}function ld(r,o,f){for(var g=-1,_=o.length,w={};++g<_;){var R=o[g],A=ln(r,R);f(A,R)&&Oi(w,zr(R,r),A)}return w}function zc(r,o,f,g){var _=g?p1:Tn,w=-1,R=o.length,A=r;for(r===o&&(o=Pt(o)),f&&(A=Qe(r,$t(f)));++w<R;)for(var $=0,z=o[w],Z=f?f(z):z;($=_(A,Z,$,g))>-1;)A!==r&&xs.call(A,$,1),xs.call(r,$,1);return r}function fd(r,o){for(var f=r?o.length:0,g=f-1;f--;){var _=o[f];if(f==g||_!==w){var w=_;br(_)?xs.call(r,_,1):Bc(r,_)}}return r}function Zc(r,o){return r+Rs(Kf()*(o-r+1))}function Vc(r,o){var f="";if(!r||o<1||o>Dr)return f;do{o%2&&(f+=r),(o=Rs(o/2))&&(r+=r)}while(o);return f}function Pe(r,o){return ca(qd(r,o,Ct),r+"")}function BE(r){return Hf(Vn(r))}function WE(r,o){var f=Vn(r);return Bs(f,un(o,0,f.length))}function Oi(r,o,f,g){if(!et(r))return r;for(var _=-1,w=(o=zr(o,r)).length,R=w-1,A=r;null!=A&&++_<w;){var $=hr(o[_]),z=f;if("__proto__"===$||"constructor"===$||"prototype"===$)return r;if(_!=R){var Z=A[$];(z=g?g(Z,$,A):t)===t&&(z=et(Z)?Z:br(o[_+1])?[]:{})}bi(A,$,z),A=A[$]}return r}var dd=As?function(r,o){return As.set(r,o),r}:Ct,HE=Ns?function(r,o){return Ns(r,"toString",{configurable:!0,enumerable:!1,value:ya(o),writable:!0})}:Ct;function GE(r){return Bs(Vn(r))}function Gt(r,o,f){var g=-1,_=r.length;o<0&&(o=-o>_?0:_+o),(f=f>_?_:f)<0&&(f+=_),_=o>f?0:f-o>>>0,o>>>=0;for(var w=F(_);++g<_;)w[g]=r[g+o];return w}function JE(r,o){var f;return Mr(r,function(g,_,w){return!(f=o(g,_,w))}),!!f}function Us(r,o,f){var g=0,_=null==r?g:r.length;if("number"==typeof o&&o==o&&_<=2147483647){for(;g<_;){var w=g+_>>>1,R=r[w];null!==R&&!Ft(R)&&(f?R<=o:R<o)?g=w+1:_=w}return _}return Kc(r,o,Ct,f)}function Kc(r,o,f,g){var _=0,w=null==r?0:r.length;if(0===w)return 0;for(var R=(o=f(o))!=o,A=null===o,$=Ft(o),z=o===t;_<w;){var Z=Rs((_+w)/2),K=f(r[Z]),X=K!==t,ne=null===K,ge=K==K,Se=Ft(K);if(R)var _e=g||ge;else _e=z?ge&&(g||X):A?ge&&X&&(g||!ne):$?ge&&X&&!ne&&(g||!Se):!ne&&!Se&&(g?K<=o:K<o);_e?_=Z+1:w=Z}return yt(w,4294967294)}function hd(r,o){for(var f=-1,g=r.length,_=0,w=[];++f<g;){var R=r[f],A=o?o(R):R;if(!f||!ir(A,$)){var $=A;w[_++]=0===R?0:R}}return w}function pd(r){return"number"==typeof r?r:Ft(r)?NaN:+r}function Dt(r){if("string"==typeof r)return r;if(Ee(r))return Qe(r,Dt)+"";if(Ft(r))return Bf?Bf.call(r):"";var o=r+"";return"0"==o&&1/r==-nn?"-0":o}function qr(r,o,f){var g=-1,_=_s,w=r.length,R=!0,A=[],$=A;if(f)R=!1,_=bc;else if(w>=200){var z=o?null:cI(r);if(z)return ms(z);R=!1,_=pi,$=new an}else $=o?[]:A;e:for(;++g<w;){var Z=r[g],K=o?o(Z):Z;if(Z=f||0!==Z?Z:0,R&&K==K){for(var X=$.length;X--;)if($[X]===K)continue e;o&&$.push(K),A.push(Z)}else _($,K,f)||($!==A&&$.push(K),A.push(Z))}return A}function Bc(r,o){return null==(r=zd(r,o=zr(o,r)))||delete r[hr(Jt(o))]}function gd(r,o,f,g){return Oi(r,o,f(ln(r,o)),g)}function Ls(r,o,f,g){for(var _=r.length,w=g?_:-1;(g?w--:++w<_)&&o(r[w],w,r););return f?Gt(r,g?0:w,g?w+1:_):Gt(r,g?w+1:0,g?_:w)}function _d(r,o){var f=r;return f instanceof Ae&&(f=f.value()),wc(o,function(g,_){return _.func.apply(_.thisArg,Ur([g],_.args))},f)}function Wc(r,o,f){var g=r.length;if(g<2)return g?qr(r[0]):[];for(var _=-1,w=F(g);++_<g;)for(var R=r[_],A=-1;++A<g;)A!=_&&(w[_]=wi(w[_]||R,r[A],o,f));return qr(_t(w,1),o,f)}function yd(r,o,f){for(var g=-1,_=r.length,w=o.length,R={};++g<_;)f(R,r[g],g<w?o[g]:t);return R}function Hc(r){return it(r)?r:[]}function Gc(r){return"function"==typeof r?r:Ct}function zr(r,o){return Ee(r)?r:ia(r,o)?[r]:Bd(Ze(r))}var YE=Pe;function Zr(r,o,f){var g=r.length;return f=f===t?g:f,!o&&f>=g?r:Gt(r,o,f)}var md=L1||function(r){return gt.clearTimeout(r)};function vd(r,o){if(o)return r.slice();var f=r.length,g=Mf?Mf(f):new r.constructor(f);return r.copy(g),g}function Jc(r){var o=new r.constructor(r.byteLength);return new Os(o).set(new Os(r)),o}function bd(r,o){var f=o?Jc(r.buffer):r.buffer;return new r.constructor(f,r.byteOffset,r.length)}function wd(r,o){if(r!==o){var f=r!==t,g=null===r,_=r==r,w=Ft(r),R=o!==t,A=null===o,$=o==o,z=Ft(o);if(!A&&!z&&!w&&r>o||w&&R&&$&&!A&&!z||g&&R&&$||!f&&$||!_)return 1;if(!g&&!w&&!z&&r<o||z&&f&&_&&!g&&!w||A&&f&&_||!R&&_||!$)return-1}return 0}function Ed(r,o,f,g){for(var _=-1,w=r.length,R=f.length,A=-1,$=o.length,z=ut(w-R,0),Z=F($+z),K=!g;++A<$;)Z[A]=o[A];for(;++_<R;)(K||_<w)&&(Z[f[_]]=r[_]);for(;z--;)Z[A++]=r[_++];return Z}function Id(r,o,f,g){for(var _=-1,w=r.length,R=-1,A=f.length,$=-1,z=o.length,Z=ut(w-A,0),K=F(Z+z),X=!g;++_<Z;)K[_]=r[_];for(var ne=_;++$<z;)K[ne+$]=o[$];for(;++R<A;)(X||_<w)&&(K[ne+f[R]]=r[_++]);return K}function Pt(r,o){var f=-1,g=r.length;for(o||(o=F(g));++f<g;)o[f]=r[f];return o}function dr(r,o,f,g){var _=!f;f||(f={});for(var w=-1,R=o.length;++w<R;){var A=o[w],$=g?g(f[A],r[A],A,f,r):t;$===t&&($=r[A]),_?yr(f,A,$):bi(f,A,$)}return f}function ks(r,o){return function(f,g){var _=Ee(f)?a1:SE,w=o?o():{};return _(f,r,he(g,2),w)}}function Mn(r){return Pe(function(o,f){var g=-1,_=f.length,w=_>1?f[_-1]:t,R=_>2?f[2]:t;for(w=r.length>3&&"function"==typeof w?(_--,w):t,R&&Et(f[0],f[1],R)&&(w=_<3?t:w,_=1),o=Be(o);++g<_;){var A=f[g];A&&r(o,A,g,w)}return o})}function Od(r,o){return function(f,g){if(null==f)return f;if(!Rt(f))return r(f,g);for(var _=f.length,w=o?_:-1,R=Be(f);(o?w--:++w<_)&&!1!==g(R[w],w,R););return f}}function Sd(r){return function(o,f,g){for(var _=-1,w=Be(o),R=g(o),A=R.length;A--;){var $=R[r?A:++_];if(!1===f(w[$],$,w))break}return o}}function xd(r){return function(o){var f=jn(o=Ze(o))?rr(o):t,g=f?f[0]:o.charAt(0),_=f?Zr(f,1).join(""):o.slice(1);return g[r]()+_}}function qn(r){return function(o){return wc(Oh(Ih(o).replace(Hw,"")),r,"")}}function Si(r){return function(){var o=arguments;switch(o.length){case 0:return new r;case 1:return new r(o[0]);case 2:return new r(o[0],o[1]);case 3:return new r(o[0],o[1],o[2]);case 4:return new r(o[0],o[1],o[2],o[3]);case 5:return new r(o[0],o[1],o[2],o[3],o[4]);case 6:return new r(o[0],o[1],o[2],o[3],o[4],o[5]);case 7:return new r(o[0],o[1],o[2],o[3],o[4],o[5],o[6])}var f=kn(r.prototype),g=r.apply(f,o);return et(g)?g:f}}function Nd(r){return function(o,f,g){var _=Be(o);if(!Rt(o)){var w=he(f,3);o=ht(o),f=function(A){return w(_[A],A,_)}}var R=r(o,f,g);return R>-1?_[w?o[R]:R]:t}}function Pd(r){return vr(function(o){var f=o.length,g=f,_=Wt.prototype.thru;for(r&&o.reverse();g--;){var w=o[g];if("function"!=typeof w)throw new Bt(p);if(_&&!R&&"wrapper"==Vs(w))var R=new Wt([],!0)}for(g=R?g:f;++g<f;){var A=Vs(w=o[g]),$="wrapper"==A?ta(w):t;R=$&&sa($[0])&&424==$[1]&&!$[4].length&&1==$[9]?R[Vs($[0])].apply(R,$[3]):1==w.length&&sa(w)?R[A]():R.thru(w)}return function(){var z=arguments,Z=z[0];if(R&&1==z.length&&Ee(Z))return R.plant(Z).value();for(var K=0,X=f?o[K].apply(this,z):Z;++K<f;)X=o[K].call(this,X);return X}})}function Ms(r,o,f,g,_,w,R,A,$,z){var Z=128&o,K=1&o,X=2&o,ne=24&o,ge=512&o,Se=X?t:Si(r);return function _e(){for(var Re=arguments.length,Ce=F(Re),Ut=Re;Ut--;)Ce[Ut]=arguments[Ut];if(ne)var It=zn(_e),Lt=y1(Ce,It);if(g&&(Ce=Ed(Ce,g,_,ne)),w&&(Ce=Id(Ce,w,R,ne)),Re-=Lt,ne&&Re<z){var st=Lr(Ce,It);return Cd(r,o,Ms,_e.placeholder,f,Ce,st,A,$,z-Re)}var sr=K?f:this,Ir=X?sr[r]:r;return Re=Ce.length,A?Ce=SI(Ce,A):ge&&Re>1&&Ce.reverse(),Z&&$<Re&&(Ce.length=$),this&&this!==gt&&this instanceof _e&&(Ir=Se||Si(Ir)),Ir.apply(sr,Ce)}}function Rd(r,o){return function(f,g){return function(r,o,f,g){return fr(r,function(_,w,R){o(g,f(_),w,R)}),g}(f,r,o(g),{})}}function qs(r,o){return function(f,g){var _;if(f===t&&g===t)return o;if(f!==t&&(_=f),g!==t){if(_===t)return g;"string"==typeof f||"string"==typeof g?(f=Dt(f),g=Dt(g)):(f=pd(f),g=pd(g)),_=r(f,g)}return _}}function Yc(r){return vr(function(o){return o=Qe(o,$t(he())),Pe(function(f){var g=this;return r(o,function(_){return jt(_,g,f)})})})}function zs(r,o){var f=(o=o===t?" ":Dt(o)).length;if(f<2)return f?Vc(o,r):o;var g=Vc(o,Ps(r/$n(o)));return jn(o)?Zr(rr(g),0,r).join(""):g.slice(0,r)}function Ad(r){return function(o,f,g){return g&&"number"!=typeof g&&Et(o,f,g)&&(f=g=t),o=Er(o),f===t?(f=o,o=0):f=Er(f),function(r,o,f,g){for(var _=-1,w=ut(Ps((o-r)/(f||1)),0),R=F(w);w--;)R[g?w:++_]=r,r+=f;return R}(o,f,g=g===t?o<f?1:-1:Er(g),r)}}function Zs(r){return function(o,f){return"string"==typeof o&&"string"==typeof f||(o=Yt(o),f=Yt(f)),r(o,f)}}function Cd(r,o,f,g,_,w,R,A,$,z){var Z=8&o;o|=Z?32:64,4&(o&=~(Z?64:32))||(o&=-4);var Se=[r,o,_,Z?w:t,Z?R:t,Z?t:w,Z?t:R,A,$,z],_e=f.apply(t,Se);return sa(r)&&Zd(_e,Se),_e.placeholder=g,Vd(_e,r,o)}function Qc(r){var o=at[r];return function(f,g){if(f=Yt(f),(g=null==g?0:yt(Oe(g),292))&&Vf(f)){var _=(Ze(f)+"e").split("e");return+((_=(Ze(o(_[0]+"e"+(+_[1]+g)))+"e").split("e"))[0]+"e"+(+_[1]-g))}return o(f)}}var cI=Un&&1/ms(new Un([,-0]))[1]==nn?function(r){return new Un(r)}:ba;function Td(r){return function(o){var f=mt(o);return f==er?Pc(o):f==tr?function(j){var q=-1,F=Array(j.size);return j.forEach(function(re){F[++q]=[re,re]}),F}(o):function(j,q){return Qe(q,function(F){return[F,j[F]]})}(o,r(o))}}function mr(r,o,f,g,_,w,R,A){var $=2&o;if(!$&&"function"!=typeof r)throw new Bt(p);var z=g?g.length:0;if(z||(o&=-97,g=_=t),R=R===t?R:ut(Oe(R),0),A=A===t?A:Oe(A),z-=_?_.length:0,64&o){var Z=g,K=_;g=_=t}var X=$?t:ta(r),ne=[r,o,f,g,_,Z,K,w,R,A];if(X&&function(r,o){var f=r[1],g=o[1],_=f|g;if(!(_<131||(128==g&&8==f||128==g&&256==f&&r[7].length<=o[8]||384==g&&o[7].length<=o[8]&&8==f)))return r;1&g&&(r[2]=o[2],_|=1&f?0:4);var A=o[3];if(A){var $=r[3];r[3]=$?Ed($,A,o[4]):A,r[4]=$?Lr(r[3],T):o[4]}(A=o[5])&&(r[5]=($=r[5])?Id($,A,o[6]):A,r[6]=$?Lr(r[5],T):o[6]),(A=o[7])&&(r[7]=A),128&g&&(r[8]=null==r[8]?o[8]:yt(r[8],o[8])),null==r[9]&&(r[9]=o[9]),r[0]=o[0],r[1]=_}(ne,X),r=ne[0],o=ne[1],f=ne[2],g=ne[3],_=ne[4],!(A=ne[9]=ne[9]===t?$?0:r.length:ut(ne[9]-z,0))&&24&o&&(o&=-25),o&&1!=o)ge=8==o||16==o?function(r,o,f){var g=Si(r);return function _(){for(var w=arguments.length,R=F(w),A=w,$=zn(_);A--;)R[A]=arguments[A];var z=w<3&&R[0]!==$&&R[w-1]!==$?[]:Lr(R,$);return(w-=z.length)<f?Cd(r,o,Ms,_.placeholder,t,R,z,t,t,f-w):jt(this&&this!==gt&&this instanceof _?g:r,this,R)}}(r,o,A):32!=o&&33!=o||_.length?Ms.apply(t,ne):function(r,o,f,g){var _=1&o,w=Si(r);return function R(){for(var A=-1,$=arguments.length,z=-1,Z=g.length,K=F(Z+$),X=this&&this!==gt&&this instanceof R?w:r;++z<Z;)K[z]=g[z];for(;$--;)K[z++]=arguments[++A];return jt(X,_?f:this,K)}}(r,o,f,g);else var ge=function(r,o,f){var g=1&o,_=Si(r);return function w(){return(this&&this!==gt&&this instanceof w?_:r).apply(g?f:this,arguments)}}(r,o,f);return Vd((X?dd:Zd)(ge,ne),r,o)}function jd(r,o,f,g){return r===t||ir(r,Fn[f])&&!Ke.call(g,f)?o:r}function $d(r,o,f,g,_,w){return et(r)&&et(o)&&(w.set(o,r),Fs(r,o,t,$d,w),w.delete(o)),r}function aI(r){return Pi(r)?t:r}function Dd(r,o,f,g,_,w){var R=1&f,A=r.length,$=o.length;if(A!=$&&!(R&&$>A))return!1;var z=w.get(r),Z=w.get(o);if(z&&Z)return z==o&&Z==r;var K=-1,X=!0,ne=2&f?new an:t;for(w.set(r,o),w.set(o,r);++K<A;){var ge=r[K],Se=o[K];if(g)var _e=R?g(Se,ge,K,o,r,w):g(ge,Se,K,r,o,w);if(_e!==t){if(_e)continue;X=!1;break}if(ne){if(!Ec(o,function(Re,Ce){if(!pi(ne,Ce)&&(ge===Re||_(ge,Re,f,g,w)))return ne.push(Ce)})){X=!1;break}}else if(ge!==Se&&!_(ge,Se,f,g,w)){X=!1;break}}return w.delete(r),w.delete(o),X}function vr(r){return ca(qd(r,t,Jd),r+"")}function Xc(r){return td(r,ht,na)}function ea(r){return td(r,At,Fd)}var ta=As?function(r){return As.get(r)}:ba;function Vs(r){for(var o=r.name+"",f=Ln[o],g=Ke.call(Ln,o)?f.length:0;g--;){var _=f[g],w=_.func;if(null==w||w==r)return _.name}return o}function zn(r){return(Ke.call(b,"placeholder")?b:r).placeholder}function he(){var r=b.iteratee||ma;return r=r===ma?id:r,arguments.length?r(arguments[0],arguments[1]):r}function Ks(r,o){var f=r.__data__;return function(r){var o=typeof r;return"string"==o||"number"==o||"symbol"==o||"boolean"==o?"__proto__"!==r:null===r}(o)?f["string"==typeof o?"string":"hash"]:f.map}function ra(r){for(var o=ht(r),f=o.length;f--;){var g=o[f],_=r[g];o[f]=[g,_,kd(_)]}return o}function fn(r,o){var f=function(j,q){return null==j?t:j[q]}(r,o);return nd(f)?f:t}var na=Ac?function(r){return null==r?[]:(r=Be(r),Fr(Ac(r),function(o){return zf.call(r,o)}))}:wa,Fd=Ac?function(r){for(var o=[];r;)Ur(o,na(r)),r=Ss(r);return o}:wa,mt=wt;function Ud(r,o,f){for(var g=-1,_=(o=zr(o,r)).length,w=!1;++g<_;){var R=hr(o[g]);if(!(w=null!=r&&f(r,R)))break;r=r[R]}return w||++g!=_?w:!!(_=null==r?0:r.length)&&Qs(_)&&br(R,_)&&(Ee(r)||_n(r))}function Ld(r){return"function"!=typeof r.constructor||xi(r)?{}:kn(Ss(r))}function yI(r){return Ee(r)||_n(r)||!!(Zf&&r&&r[Zf])}function br(r,o){var f=typeof r;return!!(o=o??Dr)&&("number"==f||"symbol"!=f&&Rw.test(r))&&r>-1&&r%1==0&&r<o}function Et(r,o,f){if(!et(f))return!1;var g=typeof o;return!!("number"==g?Rt(f)&&br(o,f.length):"string"==g&&o in f)&&ir(f[o],r)}function ia(r,o){if(Ee(r))return!1;var f=typeof r;return!("number"!=f&&"symbol"!=f&&"boolean"!=f&&null!=r&&!Ft(r))||pw.test(r)||!hw.test(r)||null!=o&&r in Be(o)}function sa(r){var o=Vs(r),f=b[o];if("function"!=typeof f||!(o in Ae.prototype))return!1;if(r===f)return!0;var g=ta(f);return!!g&&r===g[0]}(Cc&&mt(new Cc(new ArrayBuffer(1)))!=An||_i&&mt(new _i)!=er||Tc&&mt(Tc.resolve())!=Yl||Un&&mt(new Un)!=tr||yi&&mt(new yi)!=di)&&(mt=function(r){var o=wt(r),f=o==pr?r.constructor:t,g=f?dn(f):"";if(g)switch(g){case W1:return An;case H1:return er;case G1:return Yl;case J1:return tr;case Y1:return di}return o});var bI=bs?wr:Ea;function xi(r){var o=r&&r.constructor;return r===("function"==typeof o&&o.prototype||Fn)}function kd(r){return r==r&&!et(r)}function Md(r,o){return function(f){return null!=f&&f[r]===o&&(o!==t||r in Be(f))}}function qd(r,o,f){return o=ut(o===t?r.length-1:o,0),function(){for(var g=arguments,_=-1,w=ut(g.length-o,0),R=F(w);++_<w;)R[_]=g[o+_];_=-1;for(var A=F(o+1);++_<o;)A[_]=g[_];return A[o]=f(R),jt(r,this,A)}}function zd(r,o){return o.length<2?r:ln(r,Gt(o,0,-1))}function SI(r,o){for(var f=r.length,g=yt(o.length,f),_=Pt(r);g--;){var w=o[g];r[g]=br(w,f)?_[w]:t}return r}function oa(r,o){if(("constructor"!==o||"function"!=typeof r[o])&&"__proto__"!=o)return r[o]}var Zd=Kd(dd),Ni=M1||function(r,o){return gt.setTimeout(r,o)},ca=Kd(HE);function Vd(r,o,f){var g=o+"";return ca(r,function(r,o){var f=o.length;if(!f)return r;var g=f-1;return o[g]=(f>1?"& ":"")+o[g],o=o.join(f>2?", ":" "),r.replace(mw,"{\n/* [wrapped with "+o+"] */\n")}(g,function(r,o){return Kt(Xb,function(f){var g="_."+f[0];o&f[1]&&!_s(r,g)&&r.push(g)}),r.sort()}(function(r){var o=r.match(vw);return o?o[1].split(bw):[]}(g),f)))}function Kd(r){var o=0,f=0;return function(){var g=V1(),_=16-(g-f);if(f=g,_>0){if(++o>=800)return arguments[0]}else o=0;return r.apply(t,arguments)}}function Bs(r,o){var f=-1,g=r.length,_=g-1;for(o=o===t?g:o;++f<o;){var w=Zc(f,_),R=r[w];r[w]=r[f],r[f]=R}return r.length=o,r}var o,f,Bd=(o=Js(function(r){var o=[];return 46===r.charCodeAt(0)&&o.push(""),r.replace(gw,function(f,g,_,w){o.push(_?w.replace(Iw,"$1"):g||f)}),o},function(g){return 500===f.size&&f.clear(),g}),f=o.cache,o);function hr(r){if("string"==typeof r||Ft(r))return r;var o=r+"";return"0"==o&&1/r==-nn?"-0":o}function dn(r){if(null!=r){try{return ws.call(r)}catch{}try{return r+""}catch{}}return""}function Wd(r){if(r instanceof Ae)return r.clone();var o=new Wt(r.__wrapped__,r.__chain__);return o.__actions__=Pt(r.__actions__),o.__index__=r.__index__,o.__values__=r.__values__,o}var AI=Pe(function(r,o){return it(r)?wi(r,_t(o,1,it,!0)):[]}),CI=Pe(function(r,o){var f=Jt(o);return it(f)&&(f=t),it(r)?wi(r,_t(o,1,it,!0),he(f,2)):[]}),TI=Pe(function(r,o){var f=Jt(o);return it(f)&&(f=t),it(r)?wi(r,_t(o,1,it,!0),t,f):[]});function Hd(r,o,f){var g=null==r?0:r.length;if(!g)return-1;var _=null==f?0:Oe(f);return _<0&&(_=ut(g+_,0)),ys(r,he(o,3),_)}function Gd(r,o,f){var g=null==r?0:r.length;if(!g)return-1;var _=g-1;return f!==t&&(_=Oe(f),_=f<0?ut(g+_,0):yt(_,g-1)),ys(r,he(o,3),_,!0)}function Jd(r){return null!=r&&r.length?_t(r,1):[]}function Yd(r){return r&&r.length?r[0]:t}var ZI=Pe(function(r){var o=Qe(r,Hc);return o.length&&o[0]===r[0]?Lc(o):[]}),VI=Pe(function(r){var o=Jt(r),f=Qe(r,Hc);return o===Jt(f)?o=t:f.pop(),f.length&&f[0]===r[0]?Lc(f,he(o,2)):[]}),KI=Pe(function(r){var o=Jt(r),f=Qe(r,Hc);return(o="function"==typeof o?o:t)&&f.pop(),f.length&&f[0]===r[0]?Lc(f,t,o):[]});function Jt(r){var o=null==r?0:r.length;return o?r[o-1]:t}var GI=Pe(Qd);function Qd(r,o){return r&&r.length&&o&&o.length?zc(r,o):r}var QI=vr(function(r,o){var f=null==r?0:r.length,g=$c(r,o);return fd(r,Qe(o,function(_){return br(_,f)?+_:_}).sort(wd)),g});function aa(r){return null==r?r:B1.call(r)}var pO=Pe(function(r){return qr(_t(r,1,it,!0))}),gO=Pe(function(r){var o=Jt(r);return it(o)&&(o=t),qr(_t(r,1,it,!0),he(o,2))}),_O=Pe(function(r){var o=Jt(r);return o="function"==typeof o?o:t,qr(_t(r,1,it,!0),t,o)});function ua(r){if(!r||!r.length)return[];var o=0;return r=Fr(r,function(f){if(it(f))return o=ut(f.length,o),!0}),xc(o,function(f){return Qe(r,Ic(f))})}function Xd(r,o){if(!r||!r.length)return[];var f=ua(r);return null==o?f:Qe(f,function(g){return jt(o,t,g)})}var bO=Pe(function(r,o){return it(r)?wi(r,o):[]}),wO=Pe(function(r){return Wc(Fr(r,it))}),EO=Pe(function(r){var o=Jt(r);return it(o)&&(o=t),Wc(Fr(r,it),he(o,2))}),IO=Pe(function(r){var o=Jt(r);return o="function"==typeof o?o:t,Wc(Fr(r,it),t,o)}),OO=Pe(ua),NO=Pe(function(r){var o=r.length,f=o>1?r[o-1]:t;return f="function"==typeof f?(r.pop(),f):t,Xd(r,f)});function eh(r){var o=b(r);return o.__chain__=!0,o}function Ws(r,o){return o(r)}var RO=vr(function(r){var o=r.length,f=o?r[0]:0,g=this.__wrapped__,_=function(w){return $c(w,r)};return!(o>1||this.__actions__.length)&&g instanceof Ae&&br(f)?((g=g.slice(f,+f+(o?1:0))).__actions__.push({func:Ws,args:[_],thisArg:t}),new Wt(g,this.__chain__).thru(function(w){return o&&!w.length&&w.push(t),w})):this.thru(_)}),UO=ks(function(r,o,f){Ke.call(r,f)?++r[f]:yr(r,f,1)}),MO=Nd(Hd),qO=Nd(Gd);function th(r,o){return(Ee(r)?Kt:Mr)(r,he(o,3))}function rh(r,o){return(Ee(r)?u1:Qf)(r,he(o,3))}var KO=ks(function(r,o,f){Ke.call(r,f)?r[f].push(o):yr(r,f,[o])}),WO=Pe(function(r,o,f){var g=-1,_="function"==typeof o,w=Rt(r)?F(r.length):[];return Mr(r,function(R){w[++g]=_?jt(o,R,f):Ei(R,o,f)}),w}),HO=ks(function(r,o,f){yr(r,f,o)});function Hs(r,o){return(Ee(r)?Qe:sd)(r,he(o,3))}var JO=ks(function(r,o,f){r[f?0:1].push(o)},function(){return[[],[]]}),sS=Pe(function(r,o){if(null==r)return[];var f=o.length;return f>1&&Et(r,o[0],o[1])?o=[]:f>2&&Et(o[0],o[1],o[2])&&(o=[o[0]]),ud(r,_t(o,1),[])}),Gs=k1||function(){return gt.Date.now()};function nh(r,o,f){return o=f?t:o,mr(r,128,t,t,t,t,o=r&&null==o?r.length:o)}function ih(r,o){var f;if("function"!=typeof o)throw new Bt(p);return r=Oe(r),function(){return--r>0&&(f=o.apply(this,arguments)),r<=1&&(o=t),f}}var la=Pe(function(r,o,f){var g=1;if(f.length){var _=Lr(f,zn(la));g|=32}return mr(r,g,o,f,_)}),sh=Pe(function(r,o,f){var g=3;if(f.length){var _=Lr(f,zn(sh));g|=32}return mr(o,g,r,f,_)});function ah(r,o,f){var g,_,w,R,A,$,z=0,Z=!1,K=!1,X=!0;if("function"!=typeof r)throw new Bt(p);function ne(st){var sr=g,Ir=_;return g=_=t,z=st,R=r.apply(Ir,sr)}function ge(st){return z=st,A=Ni(Re,o),Z?ne(st):R}function _e(st){var sr=st-$;return $===t||sr>=o||sr<0||K&&st-z>=w}function Re(){var st=Gs();if(_e(st))return Ce(st);A=Ni(Re,function(st){var Nh=o-(st-$);return K?yt(Nh,w-(st-z)):Nh}(st))}function Ce(st){return A=t,X&&g?ne(st):(g=_=t,R)}function Lt(){var st=Gs(),sr=_e(st);if(g=arguments,_=this,$=st,sr){if(A===t)return ge($);if(K)return md(A),A=Ni(Re,o),ne($)}return A===t&&(A=Ni(Re,o)),R}return o=Yt(o)||0,et(f)&&(Z=!!f.leading,w=(K="maxWait"in f)?ut(Yt(f.maxWait)||0,o):w,X="trailing"in f?!!f.trailing:X),Lt.cancel=function(){A!==t&&md(A),z=0,g=$=_=A=t},Lt.flush=function(){return A===t?R:Ce(Gs())},Lt}var cS=Pe(function(r,o){return Yf(r,1,o)}),aS=Pe(function(r,o,f){return Yf(r,Yt(o)||0,f)});function Js(r,o){if("function"!=typeof r||null!=o&&"function"!=typeof o)throw new Bt(p);var f=function(){var g=arguments,_=o?o.apply(this,g):g[0],w=f.cache;if(w.has(_))return w.get(_);var R=r.apply(this,g);return f.cache=w.set(_,R)||w,R};return f.cache=new(Js.Cache||_r),f}function Ys(r){if("function"!=typeof r)throw new Bt(p);return function(){var o=arguments;switch(o.length){case 0:return!r.call(this);case 1:return!r.call(this,o[0]);case 2:return!r.call(this,o[0],o[1]);case 3:return!r.call(this,o[0],o[1],o[2])}return!r.apply(this,o)}}Js.Cache=_r;var fS=YE(function(r,o){var f=(o=1==o.length&&Ee(o[0])?Qe(o[0],$t(he())):Qe(_t(o,1),$t(he()))).length;return Pe(function(g){for(var _=-1,w=yt(g.length,f);++_<w;)g[_]=o[_].call(this,g[_]);return jt(r,this,g)})}),fa=Pe(function(r,o){var f=Lr(o,zn(fa));return mr(r,32,t,o,f)}),uh=Pe(function(r,o){var f=Lr(o,zn(uh));return mr(r,64,t,o,f)}),dS=vr(function(r,o){return mr(r,256,t,t,t,o)});function ir(r,o){return r===o||r!=r&&o!=o}var OS=Zs(Uc),SS=Zs(function(r,o){return r>=o}),_n=rd(function(){return arguments}())?rd:function(r){return rt(r)&&Ke.call(r,"callee")&&!zf.call(r,"callee")},Ee=F.isArray,xS=If?$t(If):function(r){return rt(r)&&wt(r)==hi};function Rt(r){return null!=r&&Qs(r.length)&&!wr(r)}function it(r){return rt(r)&&Rt(r)}var Vr=q1||Ea,PS=Of?$t(Of):function(r){return rt(r)&&wt(r)==ai};function da(r){if(!rt(r))return!1;var o=wt(r);return o==ls||"[object DOMException]"==o||"string"==typeof r.message&&"string"==typeof r.name&&!Pi(r)}function wr(r){if(!et(r))return!1;var o=wt(r);return o==fs||o==Jl||"[object AsyncFunction]"==o||"[object Proxy]"==o}function lh(r){return"number"==typeof r&&r==Oe(r)}function Qs(r){return"number"==typeof r&&r>-1&&r%1==0&&r<=Dr}function et(r){var o=typeof r;return null!=r&&("object"==o||"function"==o)}function rt(r){return null!=r&&"object"==typeof r}var fh=Sf?$t(Sf):function(r){return rt(r)&&mt(r)==er};function dh(r){return"number"==typeof r||rt(r)&&wt(r)==ui}function Pi(r){if(!rt(r)||wt(r)!=pr)return!1;var o=Ss(r);if(null===o)return!0;var f=Ke.call(o,"constructor")&&o.constructor;return"function"==typeof f&&f instanceof f&&ws.call(f)==D1}var ha=xf?$t(xf):function(r){return rt(r)&&wt(r)==li},hh=Nf?$t(Nf):function(r){return rt(r)&&mt(r)==tr};function Xs(r){return"string"==typeof r||!Ee(r)&&rt(r)&&wt(r)==fi}function Ft(r){return"symbol"==typeof r||rt(r)&&wt(r)==ds}var Zn=Pf?$t(Pf):function(r){return rt(r)&&Qs(r.length)&&!!Ge[wt(r)]},VS=Zs(qc),KS=Zs(function(r,o){return r<=o});function ph(r){if(!r)return[];if(Rt(r))return Xs(r)?rr(r):Pt(r);if(gi&&r[gi])return function(j){for(var q,F=[];!(q=j.next()).done;)F.push(q.value);return F}(r[gi]());var o=mt(r);return(o==er?Pc:o==tr?ms:Vn)(r)}function Er(r){return r?(r=Yt(r))===nn||r===-nn?17976931348623157e292*(r<0?-1:1):r==r?r:0:0===r?r:0}function Oe(r){var o=Er(r),f=o%1;return o==o?f?o-f:o:0}function gh(r){return r?un(Oe(r),0,lr):0}function Yt(r){if("number"==typeof r)return r;if(Ft(r))return NaN;if(et(r)){var o="function"==typeof r.valueOf?r.valueOf():r;r=et(o)?o+"":o}if("string"!=typeof r)return 0===r?r:+r;r=$f(r);var f=xw.test(r);return f||Pw.test(r)?o1(r.slice(2),f?2:8):Sw.test(r)?NaN:+r}function _h(r){return dr(r,At(r))}function Ze(r){return null==r?"":Dt(r)}var WS=Mn(function(r,o){if(xi(o)||Rt(o))dr(o,ht(o),r);else for(var f in o)Ke.call(o,f)&&bi(r,f,o[f])}),yh=Mn(function(r,o){dr(o,At(o),r)}),eo=Mn(function(r,o,f,g){dr(o,At(o),r,g)}),HS=Mn(function(r,o,f,g){dr(o,ht(o),r,g)}),GS=vr($c),YS=Pe(function(r,o){r=Be(r);var f=-1,g=o.length,_=g>2?o[2]:t;for(_&&Et(o[0],o[1],_)&&(g=1);++f<g;)for(var w=o[f],R=At(w),A=-1,$=R.length;++A<$;){var z=R[A],Z=r[z];(Z===t||ir(Z,Fn[z])&&!Ke.call(r,z))&&(r[z]=w[z])}return r}),QS=Pe(function(r){return r.push(t,$d),jt(mh,t,r)});function pa(r,o,f){var g=null==r?t:ln(r,o);return g===t?f:g}function ga(r,o){return null!=r&&Ud(r,o,CE)}var ax=Rd(function(r,o,f){null!=o&&"function"!=typeof o.toString&&(o=Es.call(o)),r[o]=f},ya(Ct)),ux=Rd(function(r,o,f){null!=o&&"function"!=typeof o.toString&&(o=Es.call(o)),Ke.call(r,o)?r[o].push(f):r[o]=[f]},he),lx=Pe(Ei);function ht(r){return Rt(r)?Wf(r):Mc(r)}function At(r){return Rt(r)?Wf(r,!0):function(r){if(!et(r))return function(r){var o=[];if(null!=r)for(var f in Be(r))o.push(f);return o}(r);var o=xi(r),f=[];for(var g in r)"constructor"==g&&(o||!Ke.call(r,g))||f.push(g);return f}(r)}var hx=Mn(function(r,o,f){Fs(r,o,f)}),mh=Mn(function(r,o,f,g){Fs(r,o,f,g)}),px=vr(function(r,o){var f={};if(null==r)return f;var g=!1;o=Qe(o,function(w){return w=zr(w,r),g||(g=w.length>1),w}),dr(r,ea(r),f),g&&(f=Ht(f,7,aI));for(var _=o.length;_--;)Bc(f,o[_]);return f}),_x=vr(function(r,o){return null==r?{}:function(r,o){return ld(r,o,function(f,g){return ga(r,g)})}(r,o)});function vh(r,o){if(null==r)return{};var f=Qe(ea(r),function(g){return[g]});return o=he(o),ld(r,f,function(g,_){return o(g,_[0])})}var bh=Td(ht),wh=Td(At);function Vn(r){return null==r?[]:Nc(r,ht(r))}var Px=qn(function(r,o,f){return o=o.toLowerCase(),r+(f?Eh(o):o)});function Eh(r){return _a(Ze(r).toLowerCase())}function Ih(r){return(r=Ze(r))&&r.replace(Aw,m1).replace(Gw,"")}var Tx=qn(function(r,o,f){return r+(f?"-":"")+o.toLowerCase()}),jx=qn(function(r,o,f){return r+(f?" ":"")+o.toLowerCase()}),$x=xd("toLowerCase"),qx=qn(function(r,o,f){return r+(f?"_":"")+o.toLowerCase()}),Zx=qn(function(r,o,f){return r+(f?" ":"")+_a(o)}),Xx=qn(function(r,o,f){return r+(f?" ":"")+o.toUpperCase()}),_a=xd("toUpperCase");function Oh(r,o,f){return r=Ze(r),(o=f?t:o)===t?function(j){return Qw.test(j)}(r)?function(j){return j.match(Jw)||[]}(r):function(j){return j.match(ww)||[]}(r):r.match(o)||[]}var Sh=Pe(function(r,o){try{return jt(r,t,o)}catch(f){return da(f)?f:new be(f)}}),eN=vr(function(r,o){return Kt(o,function(f){f=hr(f),yr(r,f,la(r[f],r))}),r});function ya(r){return function(){return r}}var iN=Pd(),sN=Pd(!0);function Ct(r){return r}function ma(r){return id("function"==typeof r?r:Ht(r,1))}var aN=Pe(function(r,o){return function(f){return Ei(f,r,o)}}),uN=Pe(function(r,o){return function(f){return Ei(r,f,o)}});function va(r,o,f){var g=ht(o),_=Ds(o,g);null==f&&(!et(o)||!_.length&&g.length)&&(f=o,o=r,r=this,_=Ds(o,ht(o)));var w=!(et(f)&&"chain"in f&&!f.chain),R=wr(r);return Kt(_,function(A){var $=o[A];r[A]=$,R&&(r.prototype[A]=function(){var z=this.__chain__;if(w||z){var Z=r(this.__wrapped__),K=Z.__actions__=Pt(this.__actions__);return K.push({func:$,args:arguments,thisArg:r}),Z.__chain__=z,Z}return $.apply(r,Ur([this.value()],arguments))})}),r}function ba(){}var dN=Yc(Qe),hN=Yc(Rf),pN=Yc(Ec);function xh(r){return ia(r)?Ic(hr(r)):function(r){return function(o){return ln(o,r)}}(r)}var _N=Ad(),yN=Ad(!0);function wa(){return[]}function Ea(){return!1}var ON=qs(function(r,o){return r+o},0),SN=Qc("ceil"),xN=qs(function(r,o){return r/o},1),NN=Qc("floor"),$N=qs(function(r,o){return r*o},1),DN=Qc("round"),FN=qs(function(r,o){return r-o},0);return b.after=function(r,o){if("function"!=typeof o)throw new Bt(p);return r=Oe(r),function(){if(--r<1)return o.apply(this,arguments)}},b.ary=nh,b.assign=WS,b.assignIn=yh,b.assignInWith=eo,b.assignWith=HS,b.at=GS,b.before=ih,b.bind=la,b.bindAll=eN,b.bindKey=sh,b.castArray=function(){if(!arguments.length)return[];var r=arguments[0];return Ee(r)?r:[r]},b.chain=eh,b.chunk=function(r,o,f){o=(f?Et(r,o,f):o===t)?1:ut(Oe(o),0);var g=null==r?0:r.length;if(!g||o<1)return[];for(var _=0,w=0,R=F(Ps(g/o));_<g;)R[w++]=Gt(r,_,_+=o);return R},b.compact=function(r){for(var o=-1,f=null==r?0:r.length,g=0,_=[];++o<f;){var w=r[o];w&&(_[g++]=w)}return _},b.concat=function(){var r=arguments.length;if(!r)return[];for(var o=F(r-1),f=arguments[0],g=r;g--;)o[g-1]=arguments[g];return Ur(Ee(f)?Pt(f):[f],_t(o,1))},b.cond=function(r){var o=null==r?0:r.length,f=he();return r=o?Qe(r,function(g){if("function"!=typeof g[1])throw new Bt(p);return[f(g[0]),g[1]]}):[],Pe(function(g){for(var _=-1;++_<o;){var w=r[_];if(jt(w[0],this,g))return jt(w[1],this,g)}})},b.conforms=function(r){return function(r){var o=ht(r);return function(f){return Jf(f,r,o)}}(Ht(r,1))},b.constant=ya,b.countBy=UO,b.create=function(r,o){var f=kn(r);return null==o?f:Gf(f,o)},b.curry=function oh(r,o,f){var g=mr(r,8,t,t,t,t,t,o=f?t:o);return g.placeholder=oh.placeholder,g},b.curryRight=function ch(r,o,f){var g=mr(r,16,t,t,t,t,t,o=f?t:o);return g.placeholder=ch.placeholder,g},b.debounce=ah,b.defaults=YS,b.defaultsDeep=QS,b.defer=cS,b.delay=aS,b.difference=AI,b.differenceBy=CI,b.differenceWith=TI,b.drop=function(r,o,f){var g=null==r?0:r.length;return g?Gt(r,(o=f||o===t?1:Oe(o))<0?0:o,g):[]},b.dropRight=function(r,o,f){var g=null==r?0:r.length;return g?Gt(r,0,(o=g-(o=f||o===t?1:Oe(o)))<0?0:o):[]},b.dropRightWhile=function(r,o){return r&&r.length?Ls(r,he(o,3),!0,!0):[]},b.dropWhile=function(r,o){return r&&r.length?Ls(r,he(o,3),!0):[]},b.fill=function(r,o,f,g){var _=null==r?0:r.length;return _?(f&&"number"!=typeof f&&Et(r,o,f)&&(f=0,g=_),function(r,o,f,g){var _=r.length;for((f=Oe(f))<0&&(f=-f>_?0:_+f),(g=g===t||g>_?_:Oe(g))<0&&(g+=_),g=f>g?0:gh(g);f<g;)r[f++]=o;return r}(r,o,f,g)):[]},b.filter=function(r,o){return(Ee(r)?Fr:Xf)(r,he(o,3))},b.flatMap=function(r,o){return _t(Hs(r,o),1)},b.flatMapDeep=function(r,o){return _t(Hs(r,o),nn)},b.flatMapDepth=function(r,o,f){return f=f===t?1:Oe(f),_t(Hs(r,o),f)},b.flatten=Jd,b.flattenDeep=function(r){return null!=r&&r.length?_t(r,nn):[]},b.flattenDepth=function(r,o){return null!=r&&r.length?_t(r,o=o===t?1:Oe(o)):[]},b.flip=function(r){return mr(r,512)},b.flow=iN,b.flowRight=sN,b.fromPairs=function(r){for(var o=-1,f=null==r?0:r.length,g={};++o<f;){var _=r[o];g[_[0]]=_[1]}return g},b.functions=function(r){return null==r?[]:Ds(r,ht(r))},b.functionsIn=function(r){return null==r?[]:Ds(r,At(r))},b.groupBy=KO,b.initial=function(r){return null!=r&&r.length?Gt(r,0,-1):[]},b.intersection=ZI,b.intersectionBy=VI,b.intersectionWith=KI,b.invert=ax,b.invertBy=ux,b.invokeMap=WO,b.iteratee=ma,b.keyBy=HO,b.keys=ht,b.keysIn=At,b.map=Hs,b.mapKeys=function(r,o){var f={};return o=he(o,3),fr(r,function(g,_,w){yr(f,o(g,_,w),g)}),f},b.mapValues=function(r,o){var f={};return o=he(o,3),fr(r,function(g,_,w){yr(f,_,o(g,_,w))}),f},b.matches=function(r){return od(Ht(r,1))},b.matchesProperty=function(r,o){return cd(r,Ht(o,1))},b.memoize=Js,b.merge=hx,b.mergeWith=mh,b.method=aN,b.methodOf=uN,b.mixin=va,b.negate=Ys,b.nthArg=function(r){return r=Oe(r),Pe(function(o){return ad(o,r)})},b.omit=px,b.omitBy=function(r,o){return vh(r,Ys(he(o)))},b.once=function(r){return ih(2,r)},b.orderBy=function(r,o,f,g){return null==r?[]:(Ee(o)||(o=null==o?[]:[o]),Ee(f=g?t:f)||(f=null==f?[]:[f]),ud(r,o,f))},b.over=dN,b.overArgs=fS,b.overEvery=hN,b.overSome=pN,b.partial=fa,b.partialRight=uh,b.partition=JO,b.pick=_x,b.pickBy=vh,b.property=xh,b.propertyOf=function(r){return function(o){return null==r?t:ln(r,o)}},b.pull=GI,b.pullAll=Qd,b.pullAllBy=function(r,o,f){return r&&r.length&&o&&o.length?zc(r,o,he(f,2)):r},b.pullAllWith=function(r,o,f){return r&&r.length&&o&&o.length?zc(r,o,t,f):r},b.pullAt=QI,b.range=_N,b.rangeRight=yN,b.rearg=dS,b.reject=function(r,o){return(Ee(r)?Fr:Xf)(r,Ys(he(o,3)))},b.remove=function(r,o){var f=[];if(!r||!r.length)return f;var g=-1,_=[],w=r.length;for(o=he(o,3);++g<w;){var R=r[g];o(R,g,r)&&(f.push(R),_.push(g))}return fd(r,_),f},b.rest=function(r,o){if("function"!=typeof r)throw new Bt(p);return Pe(r,o=o===t?o:Oe(o))},b.reverse=aa,b.sampleSize=function(r,o,f){return o=(f?Et(r,o,f):o===t)?1:Oe(o),(Ee(r)?IE:WE)(r,o)},b.set=function(r,o,f){return null==r?r:Oi(r,o,f)},b.setWith=function(r,o,f,g){return g="function"==typeof g?g:t,null==r?r:Oi(r,o,f,g)},b.shuffle=function(r){return(Ee(r)?OE:GE)(r)},b.slice=function(r,o,f){var g=null==r?0:r.length;return g?(f&&"number"!=typeof f&&Et(r,o,f)?(o=0,f=g):(o=null==o?0:Oe(o),f=f===t?g:Oe(f)),Gt(r,o,f)):[]},b.sortBy=sS,b.sortedUniq=function(r){return r&&r.length?hd(r):[]},b.sortedUniqBy=function(r,o){return r&&r.length?hd(r,he(o,2)):[]},b.split=function(r,o,f){return f&&"number"!=typeof f&&Et(r,o,f)&&(o=f=t),(f=f===t?lr:f>>>0)?(r=Ze(r))&&("string"==typeof o||null!=o&&!ha(o))&&!(o=Dt(o))&&jn(r)?Zr(rr(r),0,f):r.split(o,f):[]},b.spread=function(r,o){if("function"!=typeof r)throw new Bt(p);return o=null==o?0:ut(Oe(o),0),Pe(function(f){var g=f[o],_=Zr(f,0,o);return g&&Ur(_,g),jt(r,this,_)})},b.tail=function(r){var o=null==r?0:r.length;return o?Gt(r,1,o):[]},b.take=function(r,o,f){return r&&r.length?Gt(r,0,(o=f||o===t?1:Oe(o))<0?0:o):[]},b.takeRight=function(r,o,f){var g=null==r?0:r.length;return g?Gt(r,(o=g-(o=f||o===t?1:Oe(o)))<0?0:o,g):[]},b.takeRightWhile=function(r,o){return r&&r.length?Ls(r,he(o,3),!1,!0):[]},b.takeWhile=function(r,o){return r&&r.length?Ls(r,he(o,3)):[]},b.tap=function(r,o){return o(r),r},b.throttle=function(r,o,f){var g=!0,_=!0;if("function"!=typeof r)throw new Bt(p);return et(f)&&(g="leading"in f?!!f.leading:g,_="trailing"in f?!!f.trailing:_),ah(r,o,{leading:g,maxWait:o,trailing:_})},b.thru=Ws,b.toArray=ph,b.toPairs=bh,b.toPairsIn=wh,b.toPath=function(r){return Ee(r)?Qe(r,hr):Ft(r)?[r]:Pt(Bd(Ze(r)))},b.toPlainObject=_h,b.transform=function(r,o,f){var g=Ee(r),_=g||Vr(r)||Zn(r);if(o=he(o,4),null==f){var w=r&&r.constructor;f=_?g?new w:[]:et(r)&&wr(w)?kn(Ss(r)):{}}return(_?Kt:fr)(r,function(R,A,$){return o(f,R,A,$)}),f},b.unary=function(r){return nh(r,1)},b.union=pO,b.unionBy=gO,b.unionWith=_O,b.uniq=function(r){return r&&r.length?qr(r):[]},b.uniqBy=function(r,o){return r&&r.length?qr(r,he(o,2)):[]},b.uniqWith=function(r,o){return o="function"==typeof o?o:t,r&&r.length?qr(r,t,o):[]},b.unset=function(r,o){return null==r||Bc(r,o)},b.unzip=ua,b.unzipWith=Xd,b.update=function(r,o,f){return null==r?r:gd(r,o,Gc(f))},b.updateWith=function(r,o,f,g){return g="function"==typeof g?g:t,null==r?r:gd(r,o,Gc(f),g)},b.values=Vn,b.valuesIn=function(r){return null==r?[]:Nc(r,At(r))},b.without=bO,b.words=Oh,b.wrap=function(r,o){return fa(Gc(o),r)},b.xor=wO,b.xorBy=EO,b.xorWith=IO,b.zip=OO,b.zipObject=function(r,o){return yd(r||[],o||[],bi)},b.zipObjectDeep=function(r,o){return yd(r||[],o||[],Oi)},b.zipWith=NO,b.entries=bh,b.entriesIn=wh,b.extend=yh,b.extendWith=eo,va(b,b),b.add=ON,b.attempt=Sh,b.camelCase=Px,b.capitalize=Eh,b.ceil=SN,b.clamp=function(r,o,f){return f===t&&(f=o,o=t),f!==t&&(f=(f=Yt(f))==f?f:0),o!==t&&(o=(o=Yt(o))==o?o:0),un(Yt(r),o,f)},b.clone=function(r){return Ht(r,4)},b.cloneDeep=function(r){return Ht(r,5)},b.cloneDeepWith=function(r,o){return Ht(r,5,o="function"==typeof o?o:t)},b.cloneWith=function(r,o){return Ht(r,4,o="function"==typeof o?o:t)},b.conformsTo=function(r,o){return null==o||Jf(r,o,ht(o))},b.deburr=Ih,b.defaultTo=function(r,o){return null==r||r!=r?o:r},b.divide=xN,b.endsWith=function(r,o,f){r=Ze(r),o=Dt(o);var g=r.length,_=f=f===t?g:un(Oe(f),0,g);return(f-=o.length)>=0&&r.slice(f,_)==o},b.eq=ir,b.escape=function(r){return(r=Ze(r))&&lw.test(r)?r.replace(Xl,v1):r},b.escapeRegExp=function(r){return(r=Ze(r))&&_w.test(r)?r.replace(fc,"\\$&"):r},b.every=function(r,o,f){var g=Ee(r)?Rf:PE;return f&&Et(r,o,f)&&(o=t),g(r,he(o,3))},b.find=MO,b.findIndex=Hd,b.findKey=function(r,o){return Af(r,he(o,3),fr)},b.findLast=qO,b.findLastIndex=Gd,b.findLastKey=function(r,o){return Af(r,he(o,3),Fc)},b.floor=NN,b.forEach=th,b.forEachRight=rh,b.forIn=function(r,o){return null==r?r:Dc(r,he(o,3),At)},b.forInRight=function(r,o){return null==r?r:ed(r,he(o,3),At)},b.forOwn=function(r,o){return r&&fr(r,he(o,3))},b.forOwnRight=function(r,o){return r&&Fc(r,he(o,3))},b.get=pa,b.gt=OS,b.gte=SS,b.has=function(r,o){return null!=r&&Ud(r,o,AE)},b.hasIn=ga,b.head=Yd,b.identity=Ct,b.includes=function(r,o,f,g){r=Rt(r)?r:Vn(r),f=f&&!g?Oe(f):0;var _=r.length;return f<0&&(f=ut(_+f,0)),Xs(r)?f<=_&&r.indexOf(o,f)>-1:!!_&&Tn(r,o,f)>-1},b.indexOf=function(r,o,f){var g=null==r?0:r.length;if(!g)return-1;var _=null==f?0:Oe(f);return _<0&&(_=ut(g+_,0)),Tn(r,o,_)},b.inRange=function(r,o,f){return o=Er(o),f===t?(f=o,o=0):f=Er(f),function(r,o,f){return r>=yt(o,f)&&r<ut(o,f)}(r=Yt(r),o,f)},b.invoke=lx,b.isArguments=_n,b.isArray=Ee,b.isArrayBuffer=xS,b.isArrayLike=Rt,b.isArrayLikeObject=it,b.isBoolean=function(r){return!0===r||!1===r||rt(r)&&wt(r)==ci},b.isBuffer=Vr,b.isDate=PS,b.isElement=function(r){return rt(r)&&1===r.nodeType&&!Pi(r)},b.isEmpty=function(r){if(null==r)return!0;if(Rt(r)&&(Ee(r)||"string"==typeof r||"function"==typeof r.splice||Vr(r)||Zn(r)||_n(r)))return!r.length;var o=mt(r);if(o==er||o==tr)return!r.size;if(xi(r))return!Mc(r).length;for(var f in r)if(Ke.call(r,f))return!1;return!0},b.isEqual=function(r,o){return Ii(r,o)},b.isEqualWith=function(r,o,f){var g=(f="function"==typeof f?f:t)?f(r,o):t;return g===t?Ii(r,o,t,f):!!g},b.isError=da,b.isFinite=function(r){return"number"==typeof r&&Vf(r)},b.isFunction=wr,b.isInteger=lh,b.isLength=Qs,b.isMap=fh,b.isMatch=function(r,o){return r===o||kc(r,o,ra(o))},b.isMatchWith=function(r,o,f){return f="function"==typeof f?f:t,kc(r,o,ra(o),f)},b.isNaN=function(r){return dh(r)&&r!=+r},b.isNative=function(r){if(bI(r))throw new be("Unsupported core-js use. Try https://npms.io/search?q=ponyfill.");return nd(r)},b.isNil=function(r){return null==r},b.isNull=function(r){return null===r},b.isNumber=dh,b.isObject=et,b.isObjectLike=rt,b.isPlainObject=Pi,b.isRegExp=ha,b.isSafeInteger=function(r){return lh(r)&&r>=-Dr&&r<=Dr},b.isSet=hh,b.isString=Xs,b.isSymbol=Ft,b.isTypedArray=Zn,b.isUndefined=function(r){return r===t},b.isWeakMap=function(r){return rt(r)&&mt(r)==di},b.isWeakSet=function(r){return rt(r)&&"[object WeakSet]"==wt(r)},b.join=function(r,o){return null==r?"":z1.call(r,o)},b.kebabCase=Tx,b.last=Jt,b.lastIndexOf=function(r,o,f){var g=null==r?0:r.length;if(!g)return-1;var _=g;return f!==t&&(_=(_=Oe(f))<0?ut(g+_,0):yt(_,g-1)),o==o?function(j,q,F){for(var re=F+1;re--;)if(j[re]===q)return re;return re}(r,o,_):ys(r,Cf,_,!0)},b.lowerCase=jx,b.lowerFirst=$x,b.lt=VS,b.lte=KS,b.max=function(r){return r&&r.length?$s(r,Ct,Uc):t},b.maxBy=function(r,o){return r&&r.length?$s(r,he(o,2),Uc):t},b.mean=function(r){return Tf(r,Ct)},b.meanBy=function(r,o){return Tf(r,he(o,2))},b.min=function(r){return r&&r.length?$s(r,Ct,qc):t},b.minBy=function(r,o){return r&&r.length?$s(r,he(o,2),qc):t},b.stubArray=wa,b.stubFalse=Ea,b.stubObject=function(){return{}},b.stubString=function(){return""},b.stubTrue=function(){return!0},b.multiply=$N,b.nth=function(r,o){return r&&r.length?ad(r,Oe(o)):t},b.noConflict=function(){return gt._===this&&(gt._=F1),this},b.noop=ba,b.now=Gs,b.pad=function(r,o,f){r=Ze(r);var g=(o=Oe(o))?$n(r):0;if(!o||g>=o)return r;var _=(o-g)/2;return zs(Rs(_),f)+r+zs(Ps(_),f)},b.padEnd=function(r,o,f){r=Ze(r);var g=(o=Oe(o))?$n(r):0;return o&&g<o?r+zs(o-g,f):r},b.padStart=function(r,o,f){r=Ze(r);var g=(o=Oe(o))?$n(r):0;return o&&g<o?zs(o-g,f)+r:r},b.parseInt=function(r,o,f){return f||null==o?o=0:o&&(o=+o),K1(Ze(r).replace(dc,""),o||0)},b.random=function(r,o,f){if(f&&"boolean"!=typeof f&&Et(r,o,f)&&(o=f=t),f===t&&("boolean"==typeof o?(f=o,o=t):"boolean"==typeof r&&(f=r,r=t)),r===t&&o===t?(r=0,o=1):(r=Er(r),o===t?(o=r,r=0):o=Er(o)),r>o){var g=r;r=o,o=g}if(f||r%1||o%1){var _=Kf();return yt(r+_*(o-r+s1("1e-"+((_+"").length-1))),o)}return Zc(r,o)},b.reduce=function(r,o,f){var g=Ee(r)?wc:jf,_=arguments.length<3;return g(r,he(o,4),f,_,Mr)},b.reduceRight=function(r,o,f){var g=Ee(r)?l1:jf,_=arguments.length<3;return g(r,he(o,4),f,_,Qf)},b.repeat=function(r,o,f){return o=(f?Et(r,o,f):o===t)?1:Oe(o),Vc(Ze(r),o)},b.replace=function(){var r=arguments,o=Ze(r[0]);return r.length<3?o:o.replace(r[1],r[2])},b.result=function(r,o,f){var g=-1,_=(o=zr(o,r)).length;for(_||(_=1,r=t);++g<_;){var w=null==r?t:r[hr(o[g])];w===t&&(g=_,w=f),r=wr(w)?w.call(r):w}return r},b.round=DN,b.runInContext=j,b.sample=function(r){return(Ee(r)?Hf:BE)(r)},b.size=function(r){if(null==r)return 0;if(Rt(r))return Xs(r)?$n(r):r.length;var o=mt(r);return o==er||o==tr?r.size:Mc(r).length},b.snakeCase=qx,b.some=function(r,o,f){var g=Ee(r)?Ec:JE;return f&&Et(r,o,f)&&(o=t),g(r,he(o,3))},b.sortedIndex=function(r,o){return Us(r,o)},b.sortedIndexBy=function(r,o,f){return Kc(r,o,he(f,2))},b.sortedIndexOf=function(r,o){var f=null==r?0:r.length;if(f){var g=Us(r,o);if(g<f&&ir(r[g],o))return g}return-1},b.sortedLastIndex=function(r,o){return Us(r,o,!0)},b.sortedLastIndexBy=function(r,o,f){return Kc(r,o,he(f,2),!0)},b.sortedLastIndexOf=function(r,o){if(null!=r&&r.length){var g=Us(r,o,!0)-1;if(ir(r[g],o))return g}return-1},b.startCase=Zx,b.startsWith=function(r,o,f){return r=Ze(r),f=null==f?0:un(Oe(f),0,r.length),o=Dt(o),r.slice(f,f+o.length)==o},b.subtract=FN,b.sum=function(r){return r&&r.length?Sc(r,Ct):0},b.sumBy=function(r,o){return r&&r.length?Sc(r,he(o,2)):0},b.template=function(r,o,f){var g=b.templateSettings;f&&Et(r,o,f)&&(o=t),r=Ze(r),o=eo({},o,g,jd);var A,$,_=eo({},o.imports,g.imports,jd),w=ht(_),R=Nc(_,w),z=0,Z=o.interpolate||hs,K="__p += '",X=Rc((o.escape||hs).source+"|"+Z.source+"|"+(Z===ef?Ow:hs).source+"|"+(o.evaluate||hs).source+"|$","g"),ne="//# sourceURL="+(Ke.call(o,"sourceURL")?(o.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++e1+"]")+"\n";r.replace(X,function(_e,Re,Ce,Ut,It,Lt){return Ce||(Ce=Ut),K+=r.slice(z,Lt).replace(Cw,b1),Re&&(A=!0,K+="' +\n__e("+Re+") +\n'"),It&&($=!0,K+="';\n"+It+";\n__p += '"),Ce&&(K+="' +\n((__t = ("+Ce+")) == null ? '' : __t) +\n'"),z=Lt+_e.length,_e}),K+="';\n";var ge=Ke.call(o,"variable")&&o.variable;if(ge){if(Ew.test(ge))throw new be("Invalid `variable` option passed into `_.template`")}else K="with (obj) {\n"+K+"\n}\n";K=($?K.replace(ow,""):K).replace(cw,"$1").replace(aw,"$1;"),K="function("+(ge||"obj")+") {\n"+(ge?"":"obj || (obj = {});\n")+"var __t, __p = ''"+(A?", __e = _.escape":"")+($?", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n":";\n")+K+"return __p\n}";var Se=Sh(function(){return ze(w,ne+"return "+K).apply(t,R)});if(Se.source=K,da(Se))throw Se;return Se},b.times=function(r,o){if((r=Oe(r))<1||r>Dr)return[];var f=lr,g=yt(r,lr);o=he(o),r-=lr;for(var _=xc(g,o);++f<r;)o(f);return _},b.toFinite=Er,b.toInteger=Oe,b.toLength=gh,b.toLower=function(r){return Ze(r).toLowerCase()},b.toNumber=Yt,b.toSafeInteger=function(r){return r?un(Oe(r),-Dr,Dr):0===r?r:0},b.toString=Ze,b.toUpper=function(r){return Ze(r).toUpperCase()},b.trim=function(r,o,f){if((r=Ze(r))&&(f||o===t))return $f(r);if(!r||!(o=Dt(o)))return r;var g=rr(r),_=rr(o);return Zr(g,Df(g,_),Ff(g,_)+1).join("")},b.trimEnd=function(r,o,f){if((r=Ze(r))&&(f||o===t))return r.slice(0,Lf(r)+1);if(!r||!(o=Dt(o)))return r;var g=rr(r);return Zr(g,0,Ff(g,rr(o))+1).join("")},b.trimStart=function(r,o,f){if((r=Ze(r))&&(f||o===t))return r.replace(dc,"");if(!r||!(o=Dt(o)))return r;var g=rr(r);return Zr(g,Df(g,rr(o))).join("")},b.truncate=function(r,o){var f=30,g="...";if(et(o)){var _="separator"in o?o.separator:_;f="length"in o?Oe(o.length):f,g="omission"in o?Dt(o.omission):g}var w=(r=Ze(r)).length;if(jn(r)){var R=rr(r);w=R.length}if(f>=w)return r;var A=f-$n(g);if(A<1)return g;var $=R?Zr(R,0,A).join(""):r.slice(0,A);if(_===t)return $+g;if(R&&(A+=$.length-A),ha(_)){if(r.slice(A).search(_)){var z,Z=$;for(_.global||(_=Rc(_.source,Ze(tf.exec(_))+"g")),_.lastIndex=0;z=_.exec(Z);)var K=z.index;$=$.slice(0,K===t?A:K)}}else if(r.indexOf(Dt(_),A)!=A){var X=$.lastIndexOf(_);X>-1&&($=$.slice(0,X))}return $+g},b.unescape=function(r){return(r=Ze(r))&&uw.test(r)?r.replace(Ql,N1):r},b.uniqueId=function(r){var o=++$1;return Ze(r)+o},b.upperCase=Xx,b.upperFirst=_a,b.each=th,b.eachRight=rh,b.first=Yd,va(b,function(){var r={};return fr(b,function(o,f){Ke.call(b.prototype,f)||(r[f]=o)}),r}(),{chain:!1}),b.VERSION="4.17.21",Kt(["bind","bindKey","curry","curryRight","partial","partialRight"],function(r){b[r].placeholder=b}),Kt(["drop","take"],function(r,o){Ae.prototype[r]=function(f){f=f===t?1:ut(Oe(f),0);var g=this.__filtered__&&!o?new Ae(this):this.clone();return g.__filtered__?g.__takeCount__=yt(f,g.__takeCount__):g.__views__.push({size:yt(f,lr),type:r+(g.__dir__<0?"Right":"")}),g},Ae.prototype[r+"Right"]=function(f){return this.reverse()[r](f).reverse()}}),Kt(["filter","map","takeWhile"],function(r,o){var f=o+1,g=1==f||3==f;Ae.prototype[r]=function(_){var w=this.clone();return w.__iteratees__.push({iteratee:he(_,3),type:f}),w.__filtered__=w.__filtered__||g,w}}),Kt(["head","last"],function(r,o){var f="take"+(o?"Right":"");Ae.prototype[r]=function(){return this[f](1).value()[0]}}),Kt(["initial","tail"],function(r,o){var f="drop"+(o?"":"Right");Ae.prototype[r]=function(){return this.__filtered__?new Ae(this):this[f](1)}}),Ae.prototype.compact=function(){return this.filter(Ct)},Ae.prototype.find=function(r){return this.filter(r).head()},Ae.prototype.findLast=function(r){return this.reverse().find(r)},Ae.prototype.invokeMap=Pe(function(r,o){return"function"==typeof r?new Ae(this):this.map(function(f){return Ei(f,r,o)})}),Ae.prototype.reject=function(r){return this.filter(Ys(he(r)))},Ae.prototype.slice=function(r,o){r=Oe(r);var f=this;return f.__filtered__&&(r>0||o<0)?new Ae(f):(r<0?f=f.takeRight(-r):r&&(f=f.drop(r)),o!==t&&(f=(o=Oe(o))<0?f.dropRight(-o):f.take(o-r)),f)},Ae.prototype.takeRightWhile=function(r){return this.reverse().takeWhile(r).reverse()},Ae.prototype.toArray=function(){return this.take(lr)},fr(Ae.prototype,function(r,o){var f=/^(?:filter|find|map|reject)|While$/.test(o),g=/^(?:head|last)$/.test(o),_=b[g?"take"+("last"==o?"Right":""):o],w=g||/^find/.test(o);_&&(b.prototype[o]=function(){var R=this.__wrapped__,A=g?[1]:arguments,$=R instanceof Ae,z=A[0],Z=$||Ee(R),K=function(Re){var Ce=_.apply(b,Ur([Re],A));return g&&X?Ce[0]:Ce};Z&&f&&"function"==typeof z&&1!=z.length&&($=Z=!1);var X=this.__chain__,ne=!!this.__actions__.length,ge=w&&!X,Se=$&&!ne;if(!w&&Z){R=Se?R:new Ae(this);var _e=r.apply(R,A);return _e.__actions__.push({func:Ws,args:[K],thisArg:t}),new Wt(_e,X)}return ge&&Se?r.apply(this,A):(_e=this.thru(K),ge?g?_e.value()[0]:_e.value():_e)})}),Kt(["pop","push","shift","sort","splice","unshift"],function(r){var o=vs[r],f=/^(?:push|sort|unshift)$/.test(r)?"tap":"thru",g=/^(?:pop|shift)$/.test(r);b.prototype[r]=function(){var _=arguments;if(g&&!this.__chain__){var w=this.value();return o.apply(Ee(w)?w:[],_)}return this[f](function(R){return o.apply(Ee(R)?R:[],_)})}}),fr(Ae.prototype,function(r,o){var f=b[o];if(f){var g=f.name+"";Ke.call(Ln,g)||(Ln[g]=[]),Ln[g].push({name:o,func:f})}}),Ln[Ms(t,2).name]=[{name:"wrapper",func:t}],Ae.prototype.clone=function(){var r=new Ae(this.__wrapped__);return r.__actions__=Pt(this.__actions__),r.__dir__=this.__dir__,r.__filtered__=this.__filtered__,r.__iteratees__=Pt(this.__iteratees__),r.__takeCount__=this.__takeCount__,r.__views__=Pt(this.__views__),r},Ae.prototype.reverse=function(){if(this.__filtered__){var r=new Ae(this);r.__dir__=-1,r.__filtered__=!0}else(r=this.clone()).__dir__*=-1;return r},Ae.prototype.value=function(){var r=this.__wrapped__.value(),o=this.__dir__,f=Ee(r),g=o<0,_=f?r.length:0,w=function(r,o,f){for(var g=-1,_=f.length;++g<_;){var w=f[g],R=w.size;switch(w.type){case"drop":r+=R;break;case"dropRight":o-=R;break;case"take":o=yt(o,r+R);break;case"takeRight":r=ut(r,o-R)}}return{start:r,end:o}}(0,_,this.__views__),R=w.start,A=w.end,$=A-R,z=g?A:R-1,Z=this.__iteratees__,K=Z.length,X=0,ne=yt($,this.__takeCount__);if(!f||!g&&_==$&&ne==$)return _d(r,this.__actions__);var ge=[];e:for(;$--&&X<ne;){for(var Se=-1,_e=r[z+=o];++Se<K;){var Re=Z[Se],Ut=Re.type,It=(0,Re.iteratee)(_e);if(2==Ut)_e=It;else if(!It){if(1==Ut)continue e;break e}}ge[X++]=_e}return ge},b.prototype.at=RO,b.prototype.chain=function(){return eh(this)},b.prototype.commit=function(){return new Wt(this.value(),this.__chain__)},b.prototype.next=function(){this.__values__===t&&(this.__values__=ph(this.value()));var r=this.__index__>=this.__values__.length;return{done:r,value:r?t:this.__values__[this.__index__++]}},b.prototype.plant=function(r){for(var o,f=this;f instanceof Ts;){var g=Wd(f);g.__index__=0,g.__values__=t,o?_.__wrapped__=g:o=g;var _=g;f=f.__wrapped__}return _.__wrapped__=r,o},b.prototype.reverse=function(){var r=this.__wrapped__;if(r instanceof Ae){var o=r;return this.__actions__.length&&(o=new Ae(this)),(o=o.reverse()).__actions__.push({func:Ws,args:[aa],thisArg:t}),new Wt(o,this.__chain__)}return this.thru(aa)},b.prototype.toJSON=b.prototype.valueOf=b.prototype.value=function(){return _d(this.__wrapped__,this.__actions__)},b.prototype.first=b.prototype.head,gi&&(b.prototype[gi]=function(){return this}),b}();sn?((sn.exports=Dn)._=Dn,mc._=Dn):gt._=Dn}.call(si);var lb=Object.defineProperty,fb=Object.defineProperties,db=Object.getOwnPropertyDescriptors,Ul=Object.getOwnPropertySymbols,hb=Object.prototype.hasOwnProperty,pb=Object.prototype.propertyIsEnumerable,Ll=(n,e,t)=>e in n?lb(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,rs=(n,e)=>{for(var t in e||(e={}))hb.call(e,t)&&Ll(n,t,e[t]);if(Ul)for(var t of Ul(e))pb.call(e,t)&&Ll(n,t,e[t]);return n},gb=(n,e)=>fb(n,db(e));function Zt(n,e,t){let a;const l=Yo(n);return e.rpcMap&&(a=e.rpcMap[l]),a||(a=`https://rpc.walletconnect.com/v1?chainId=eip155:${l}&projectId=${t}`),a}function Yo(n){return n.includes("eip155")?Number(n.split(":")[1]):Number(n)}function kl(n){return n.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function Ml(n){var e,t,a,l;const d={};if(!function(n){return Object.getPrototypeOf(n)===Object.prototype&&Object.keys(n).length}(n))return d;for(const[p,m]of Object.entries(n)){const P=Yi(p)?[p]:m.chains,S=m.methods||[],T=m.events||[],D=m.rpcMap||{},Q=ni(p);d[Q]=gb(rs(rs({},d[Q]),m),{chains:ur(P,null==(e=d[Q])?void 0:e.chains),methods:ur(S,null==(t=d[Q])?void 0:t.methods),events:ur(T,null==(a=d[Q])?void 0:a.events),rpcMap:rs(rs({},D),null==(l=d[Q])?void 0:l.rpcMap)})}return d}function mb(n){return n.includes(":")?n.split(":")[2]:n}function vb(n){const e={};for(const[t,a]of Object.entries(n)){const l=a.methods||[],d=a.events||[],p=a.accounts||[],m=Yi(t)?[t]:a.chains?a.chains:kl(a.accounts);e[t]={chains:m,methods:l,events:d,accounts:p}}return e}const ql={},nt=n=>ql[n],Qo=(n,e)=>{ql[n]=e};class bb{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=nt("events"),this.client=nt("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 a=t||Zt(`${this.name}:${e}`,this.namespace);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,a)}this.events.emit("default_chain_changed",`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var a;e[t]=this.createHttpProvider(t,null==(a=this.namespace.rpcMap)?void 0:a[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 a=this.createHttpProvider(e,t);a&&(this.httpProviders[e]=a)}createHttpProvider(e,t){const a=t||Zt(e,this.namespace);return typeof a>"u"?void 0:new Pr.r(new rn.Z(a,nt("disableProviderPing")))}}class wb{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=nt("events"),this.client=nt("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}request(e){var t=this;return(0,N.Z)(function*(){switch(e.request.method){case"eth_requestAccounts":case"eth_accounts":return t.getAccounts();case"wallet_switchEthereumChain":return yield t.handleSwitchChain(e);case"eth_chainId":return parseInt(t.getDefaultChain())}return t.namespace.methods.includes(e.request.method)?yield t.client.request(e):t.getHttpProvider().request(e.request)})()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){const a=Yo(e);if(!this.httpProviders[a]){const l=t||Zt(`${this.name}:${a}`,this.namespace,this.client.core.projectId);if(!l)throw new Error(`No RPC url provided for chainId: ${a}`);this.setHttpProvider(a,l)}this.chainId=a,this.events.emit("default_chain_changed",`${this.name}:${a}`)}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 a=t||Zt(`${this.name}:${e}`,this.namespace,this.client.core.projectId);return typeof a>"u"?void 0:new Pr.r(new rn.k(a,nt("disableProviderPing")))}setHttpProvider(e,t){const a=this.createHttpProvider(e,t);a&&(this.httpProviders[e]=a)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var a;const l=Yo(t);e[l]=this.createHttpProvider(l,null==(a=this.namespace.rpcMap)?void 0:a[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.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}handleSwitchChain(e){var t=this;return(0,N.Z)(function*(){var a,l;let d=e.request.params?null==(a=e.request.params[0])?void 0:a.chainId:"0x0";d=d.startsWith("0x")?d:`0x${d}`;const p=parseInt(d,16);if(t.isChainApproved(p))t.setDefaultChain(`${p}`);else{if(!t.namespace.methods.includes("wallet_switchEthereumChain"))throw new Error(`Failed to switch to chain 'eip155:${p}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);yield t.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:d}]},chainId:null==(l=t.namespace.chains)?void 0:l[0]}),t.setDefaultChain(`${p}`)}return null})()}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}}class Eb{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=nt("events"),this.client=nt("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 a=t||Zt(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,a)}this.chainId=e,this.events.emit("default_chain_changed",`${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(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var a;e[t]=this.createHttpProvider(t,null==(a=this.namespace.rpcMap)?void 0:a[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 a=this.createHttpProvider(e,t);a&&(this.httpProviders[e]=a)}createHttpProvider(e,t){const a=t||Zt(e,this.namespace,this.client.core.projectId);return typeof a>"u"?void 0:new Pr.r(new rn.Z(a,nt("disableProviderPing")))}}class Ib{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=nt("events"),this.client=nt("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 a=t||Zt(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,a)}this.events.emit("default_chain_changed",`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var a;e[t]=this.createHttpProvider(t,null==(a=this.namespace.rpcMap)?void 0:a[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 a=this.createHttpProvider(e,t);a&&(this.httpProviders[e]=a)}createHttpProvider(e,t){const a=t||Zt(e,this.namespace,this.client.core.projectId);return typeof a>"u"?void 0:new Pr.r(new rn.Z(a,nt("disableProviderPing")))}}class Ob{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=nt("events"),this.client=nt("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 a=t||this.getCardanoRPCUrl(e);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,a)}this.events.emit("default_chain_changed",`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const a=this.getCardanoRPCUrl(t);e[t]=this.createHttpProvider(t,a)}),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 a=this.createHttpProvider(e,t);a&&(this.httpProviders[e]=a)}createHttpProvider(e,t){const a=t||this.getCardanoRPCUrl(e);return typeof a>"u"?void 0:new Pr.r(new rn.Z(a,nt("disableProviderPing")))}}class Sb{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=nt("events"),this.client=nt("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 a=t||Zt(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,a)}this.chainId=e,this.events.emit("default_chain_changed",`${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(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var a;e[t]=this.createHttpProvider(t,null==(a=this.namespace.rpcMap)?void 0:a[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 a=this.createHttpProvider(e,t);a&&(this.httpProviders[e]=a)}createHttpProvider(e,t){const a=t||Zt(e,this.namespace,this.client.core.projectId);return typeof a>"u"?void 0:new Pr.r(new rn.Z(a,nt("disableProviderPing")))}}class xb{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=nt("events"),this.client=nt("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 a=t||Zt(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!a)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,a)}this.chainId=e,this.events.emit("default_chain_changed",`${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(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var a;e[t]=this.createHttpProvider(t,null==(a=this.namespace.rpcMap)?void 0:a[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 a=this.createHttpProvider(e,t);a&&(this.httpProviders[e]=a)}createHttpProvider(e,t){const a=t||Zt(e,this.namespace,this.client.core.projectId);return typeof a>"u"?void 0:new Pr.r(new rn.Z(a,nt("disableProviderPing")))}}var Nb=Object.defineProperty,Pb=Object.defineProperties,Rb=Object.getOwnPropertyDescriptors,zl=Object.getOwnPropertySymbols,Ab=Object.prototype.hasOwnProperty,Cb=Object.prototype.propertyIsEnumerable,Zl=(n,e,t)=>e in n?Nb(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,ns=(n,e)=>{for(var t in e||(e={}))Ab.call(e,t)&&Zl(n,t,e[t]);if(zl)for(var t of zl(e))Cb.call(e,t)&&Zl(n,t,e[t]);return n},Xo=(n,e)=>Pb(n,Rb(e));class ec{constructor(e){this.events=new(Je()),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:Ti()(function(n){return((n,e)=>G0(n,J0(e)))(((n,e)=>{for(var t in e||(e={}))Y0.call(e,t)&&$l(n,t,e[t]);if(jl)for(var t of jl(e))Q0.call(e,t)&&$l(n,t,e[t]);return n})({},n),{level:n?.level||"info"})}({level:e?.logger||"error"})),this.disableProviderPing=e?.disableProviderPing||!1}static init(e){return(0,N.Z)(function*(){const t=new ec(e);return yield t.initialize(),t})()}request(e,t){var a=this;return(0,N.Z)(function*(){const[l,d]=a.validateChain(t);if(!a.session)throw new Error("Please call connect() before request()");return yield a.getProvider(l).request({request:ns({},e),chainId:`${l}:${d}`,topic:a.session.topic})})()}sendAsync(e,t,a){this.request(e,a).then(l=>t(null,l)).catch(l=>t(l,void 0))}enable(){var e=this;return(0,N.Z)(function*(){if(!e.client)throw new Error("Sign Client not initialized");return e.session||(yield e.connect({namespaces:e.namespaces,optionalNamespaces:e.optionalNamespaces,sessionProperties:e.sessionProperties})),yield e.requestAccounts()})()}disconnect(){var e=this;return(0,N.Z)(function*(){var t;if(!e.session)throw new Error("Please call connect() before enable()");yield e.client.disconnect({topic:null==(t=e.session)?void 0:t.topic,reason:Tr("USER_DISCONNECTED")}),yield e.cleanup()})()}connect(e){var t=this;return(0,N.Z)(function*(){if(!t.client)throw new Error("Sign Client not initialized");if(t.setNamespaces(e),yield t.cleanupPendingPairings(),!e.skipPairing)return yield t.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}pair(e){var t=this;return(0,N.Z)(function*(){t.shouldAbortPairingAttempt=!1;let a=0;do{if(t.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(a>=t.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:l,approval:d}=yield t.client.connect({pairingTopic:e,requiredNamespaces:t.namespaces,optionalNamespaces:t.optionalNamespaces,sessionProperties:t.sessionProperties});l&&(t.uri=l,t.events.emit("display_uri",l)),yield d().then(p=>{t.session=p,t.namespaces||(t.namespaces=vb(p.namespaces),t.persist("namespaces",t.namespaces))}).catch(p=>{if(p.message!==al)throw p;a++})}while(!t.session);return t.onConnect(),t.session})()}setDefaultChain(e,t){try{if(!this.session)return;const[a,l]=this.validateChain(e);this.getProvider(a).setDefaultChain(l,t)}catch(a){if(!/Please call connect/.test(a.message))throw a}}cleanupPendingPairings(e={}){var t=this;return(0,N.Z)(function*(){t.logger.info("Cleaning up inactive pairings...");const a=t.client.pairing.getAll();if(Pn(a)){for(const l of a)e.deletePairings?t.client.core.expirer.set(l.topic,0):yield t.client.core.relayer.subscriber.unsubscribe(l.topic);t.logger.info(`Inactive pairings cleared: ${a.length}`)}})()}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}checkStorage(){var e=this;return(0,N.Z)(function*(){e.namespaces=yield e.getFromStore("namespaces"),e.optionalNamespaces=(yield e.getFromStore("optionalNamespaces"))||{},e.client.session.length&&(e.session=e.client.session.get(e.client.session.keys[e.client.session.keys.length-1]),e.createProviders())})()}initialize(){var e=this;return(0,N.Z)(function*(){e.logger.trace("Initialized"),yield e.createClient(),yield e.checkStorage(),e.registerEventListeners()})()}createClient(){var e=this;return(0,N.Z)(function*(){e.client=e.providerOpts.client||(yield ko.init({logger:e.providerOpts.logger||"error",relayUrl:e.providerOpts.relayUrl||"wss://relay.walletconnect.com",projectId:e.providerOpts.projectId,metadata:e.providerOpts.metadata,storageOptions:e.providerOpts.storageOptions,storage:e.providerOpts.storage,name:e.providerOpts.name})),e.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(t=>ni(t)))];Qo("client",this.client),Qo("events",this.events),Qo("disableProviderPing",this.disableProviderPing),e.forEach(t=>{if(!this.session)return;const a=function(n,e){const t=Object.keys(e.namespaces).filter(l=>l.includes(n));if(!t.length)return[];const a=[];return t.forEach(l=>{a.push(...e.namespaces[l].accounts)}),a}(t,this.session),l=kl(a),d=function(n={},e={}){const t=Ml(n),a=Ml(e);return Jo.exports.merge(t,a)}(this.namespaces,this.optionalNamespaces),p=Xo(ns({},d[t]),{accounts:a,chains:l});switch(t){case"eip155":this.rpcProviders[t]=new wb({namespace:p});break;case"solana":this.rpcProviders[t]=new Eb({namespace:p});break;case"cosmos":this.rpcProviders[t]=new Ib({namespace:p});break;case"polkadot":this.rpcProviders[t]=new bb({namespace:p});break;case"cip34":this.rpcProviders[t]=new Ob({namespace:p});break;case"elrond":this.rpcProviders[t]=new Sb({namespace:p});break;case"multiversx":this.rpcProviders[t]=new xb({namespace:p})}})}registerEventListeners(){var e=this;if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",t=>{this.events.emit("session_ping",t)}),this.client.on("session_event",t=>{const{params:a}=t,{event:l}=a;if("accountsChanged"===l.name){const d=l.data;d&&Pn(d)&&this.events.emit("accountsChanged",d.map(mb))}else"chainChanged"===l.name?this.onChainChanged(a.chainId):this.events.emit(l.name,l.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:a})=>{var l;const{namespaces:d}=a,p=null==(l=this.client)?void 0:l.session.get(t);this.session=Xo(ns({},p),{namespaces:d}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:a})}),this.client.on("session_delete",function(){var t=(0,N.Z)(function*(a){yield e.cleanup(),e.events.emit("session_delete",a),e.events.emit("disconnect",Xo(ns({},Tr("USER_DISCONNECTED")),{data:a.topic}))});return function(a){return t.apply(this,arguments)}}()),this.on("default_chain_changed",t=>{this.onChainChanged(t,!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:a,sessionProperties:l}=e;t&&Object.keys(t).length&&(this.namespaces=t),a&&Object.keys(a).length&&(this.optionalNamespaces=a),this.sessionProperties=l,this.persist("namespaces",t),this.persist("optionalNamespaces",a)}validateChain(e){const[t,a]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,a];if(t&&!Object.keys(this.namespaces||{}).map(p=>ni(p)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&a)return[t,a];const l=ni(Object.keys(this.namespaces)[0]);return[l,this.rpcProviders[l].getDefaultChain()]}requestAccounts(){var e=this;return(0,N.Z)(function*(){const[t]=e.validateChain();return yield e.getProvider(t).requestAccounts()})()}onChainChanged(e,t=!1){var a;if(!this.namespaces)return;const[l,d]=this.validateChain(e);t||this.getProvider(l).setDefaultChain(d),(null!=(a=this.namespaces[l])?a:this.namespaces[`${l}:${d}`]).defaultChain=d,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",d)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}cleanup(){var e=this;return(0,N.Z)(function*(){e.session=void 0,e.namespaces=void 0,e.optionalNamespaces=void 0,e.sessionProperties=void 0,e.persist("namespaces",void 0),e.persist("optionalNamespaces",void 0),e.persist("sessionProperties",void 0),yield e.cleanupPendingPairings({deletePairings:!0})})()}persist(e,t){this.client.core.storage.setItem(`${Fl}/${e}`,t)}getFromStore(e){var t=this;return(0,N.Z)(function*(){return yield t.client.core.storage.getItem(`${Fl}/${e}`)})()}}const Tb=ec,is=["eth_sendTransaction","personal_sign"],Vl=["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"],ss=["chainChanged","accountsChanged"],Kl=["message","disconnect","connect"];var Ub=Object.defineProperty,Lb=Object.defineProperties,kb=Object.getOwnPropertyDescriptors,Bl=Object.getOwnPropertySymbols,Mb=Object.prototype.hasOwnProperty,qb=Object.prototype.propertyIsEnumerable,Wl=(n,e,t)=>e in n?Ub(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t,oi=(n,e)=>{for(var t in e||(e={}))Mb.call(e,t)&&Wl(n,t,e[t]);if(Bl)for(var t of Bl(e))qb.call(e,t)&&Wl(n,t,e[t]);return n},Hl=(n,e)=>Lb(n,kb(e));function os(n){return Number(n[0].split(":")[1])}function tc(n){return`0x${n.toString(16)}`}class cs{constructor(){this.events=new Le.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 init(e){return(0,N.Z)(function*(){const t=new cs;return yield t.initialize(e),t})()}request(e){var t=this;return(0,N.Z)(function*(){return yield t.signer.request(e,t.formatChainId(t.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}enable(){var e=this;return(0,N.Z)(function*(){return e.session||(yield e.connect()),yield e.request({method:"eth_requestAccounts"})})()}connect(e){var t=this;return(0,N.Z)(function*(){if(!t.signer.client)throw new Error("Provider not initialized. Call init() first");t.loadConnectOpts(e);const{required:a,optional:l}=function(n){const{chains:e,optionalChains:t,methods:a,optionalMethods:l,events:d,optionalEvents:p,rpcMap:m}=n;if(!Gr(e))throw new Error("Invalid chains");const P={chains:e,methods:a||is,events:d||ss,rpcMap:oi({},e.length?{[os(e)]:m[os(e)]}:{})},S=d?.filter(se=>!ss.includes(se)),T=a?.filter(se=>!is.includes(se));if(!(t||p||l||null!=S&&S.length||null!=T&&T.length))return{required:e.length?P:void 0};const Q={chains:[...new Set(S?.length&&T?.length||!t?P.chains.concat(t||[]):t)],methods:[...new Set(P.methods.concat(null!=l&&l.length?l:Vl))],events:[...new Set(P.events.concat(p||Kl))],rpcMap:m};return{required:e.length?P:void 0,optional:t.length?Q:void 0}}(t.rpc);try{const d=yield new Promise(function(){var m=(0,N.Z)(function*(P,S){var T;t.rpc.showQrModal&&(null==(T=t.modal)||T.subscribeModal(D=>{!D.open&&!t.signer.session&&(t.signer.abortPairingAttempt(),S(new Error("Connection request reset. Please try again.")))})),yield t.signer.connect(Hl(oi({namespaces:oi({},a&&{[t.namespace]:a})},l&&{optionalNamespaces:{[t.namespace]:l}}),{pairingTopic:e?.pairingTopic})).then(D=>{P(D)}).catch(D=>{S(new Error(D.message))})});return function(P,S){return m.apply(this,arguments)}}());if(!d)return;t.setChainIds(t.rpc.chains);const p=function(n,e=[]){const t=[];return Object.keys(n).forEach(a=>{e.length&&!e.includes(a)||t.push(...n[a].accounts)}),t}(d.namespaces,[t.namespace]);t.setAccounts(p),t.events.emit("connect",{chainId:tc(t.chainId)})}catch(d){throw t.signer.logger.error(d),d}finally{t.modal&&t.modal.closeModal()}})()}disconnect(){var e=this;return(0,N.Z)(function*(){e.session&&(yield e.signer.disconnect()),e.reset()})()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:t}=e,{event:a}=t;"accountsChanged"===a.name?(this.accounts=this.parseAccounts(a.data),this.events.emit("accountsChanged",this.accounts)):"chainChanged"===a.name?this.setChainId(this.formatChainId(a.data)):this.events.emit(a.name,a.data),this.events.emit("session_event",e)}),this.signer.on("chainChanged",e=>{const t=parseInt(e);this.chainId=t,this.events.emit("chainChanged",tc(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",Hl(oi({},function(n,e){const{message:t,code:a}=pp[n];return{message:e?`${t} ${e}`:t,code:a}}("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var t,a;this.rpc.showQrModal&&(null==(t=this.modal)||t.closeModal(),null==(a=this.modal)||a.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(a=>this.isCompatibleChainId(a)).map(a=>this.parseChainId(a));t.length&&(this.chainId=t[0],this.events.emit("chainChanged",tc(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,a,l]=e.split(":");return{chainId:`${t}:${a}`,address:l}}setAccounts(e){this.accounts=e.filter(t=>this.parseChainId(this.parseAccountId(t).chainId)===this.chainId).map(t=>this.parseAccountId(t).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var t,a;const l=null!=(t=e?.chains)?t:[],d=null!=(a=e?.optionalChains)?a:[],p=l.concat(d);if(!p.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const m=l.length?e?.methods||is:[],P=l.length?e?.events||ss:[],S=e?.optionalMethods||[],T=e?.optionalEvents||[],D=e?.rpcMap||this.buildRpcMap(p,e.projectId),Q=e?.qrModalOptions||void 0;return{chains:l?.map(se=>this.formatChainId(se)),optionalChains:d.map(se=>this.formatChainId(se)),methods:m,events:P,optionalMethods:S,optionalEvents:T,rpcMap:D,showQrModal:!(null==e||!e.showQrModal),qrModalOptions:Q,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,t){const a={};return e.forEach(l=>{a[l]=this.getRpcUrl(l,t)}),a}initialize(e){var t=this;return(0,N.Z)(function*(){if(t.rpc=t.getRpcConfig(e),t.chainId=os(t.rpc.chains.length?t.rpc.chains:t.rpc.optionalChains),t.signer=yield Tb.init({projectId:t.rpc.projectId,metadata:t.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storageOptions:e.storageOptions}),t.registerEventListeners(),yield t.loadPersistedSession(),t.rpc.showQrModal){let a;try{const{WalletConnectModal:l}=yield Promise.all([H.e(8592),H.e(2687)]).then(H.bind(H,52687));a=l}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(a)try{t.modal=new a(oi({walletConnectVersion:2,projectId:t.rpc.projectId,standaloneChains:t.rpc.chains},t.rpc.qrModalOptions))}catch(l){throw t.signer.logger.error(l),new Error("Could not generate WalletConnectModal Instance")}}})()}loadConnectOpts(e){if(!e)return;const{chains:t,optionalChains:a,rpcMap:l}=e;t&&Gr(t)&&(this.rpc.chains=t.map(d=>this.formatChainId(d)),t.forEach(d=>{this.rpc.rpcMap[d]=l?.[d]||this.getRpcUrl(d)})),a&&Gr(a)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=a?.map(d=>this.formatChainId(d)),a.forEach(d=>{this.rpc.rpcMap[d]=l?.[d]||this.getRpcUrl(d)}))}getRpcUrl(e,t){var a;return(null==(a=this.rpc.rpcMap)?void 0:a[e])||`https://rpc.walletconnect.com/v1/?chainId=eip155:${e}&projectId=${t||this.rpc.projectId}`}loadPersistedSession(){var e=this;return(0,N.Z)(function*(){if(!e.session)return;const t=yield e.signer.client.core.storage.getItem(`${e.STORAGE_KEY}/chainId`),a=e.session.namespaces[`${e.namespace}:${t}`]?e.session.namespaces[`${e.namespace}:${t}`]:e.session.namespaces[e.namespace];e.setChainIds(t?[e.formatChainId(t)]:a?.accounts),e.setAccounts(a?.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(t=>this.parseAccount(t))}}const Zb=cs},63581:(Qt,k)=>{function H(De){let Fe;return"undefined"!=typeof window&&void 0!==window[De]&&(Fe=window[De]),Fe}function N(De){const Fe=H(De);if(!Fe)throw new Error(`${De} is not defined in Window`);return Fe}Object.defineProperty(k,"__esModule",{value:!0}),k.getLocalStorage=k.getLocalStorageOrThrow=k.getCrypto=k.getCryptoOrThrow=k.getLocation=k.getLocationOrThrow=k.getNavigator=k.getNavigatorOrThrow=k.getDocument=k.getDocumentOrThrow=k.getFromWindowOrThrow=k.getFromWindow=void 0,k.getFromWindow=H,k.getFromWindowOrThrow=N,k.getDocumentOrThrow=function(){return N("document")},k.getDocument=function(){return H("document")},k.getNavigatorOrThrow=function(){return N("navigator")},k.getNavigator=function(){return H("navigator")},k.getLocationOrThrow=function(){return N("location")},k.getLocation=function(){return H("location")},k.getCryptoOrThrow=function(){return N("crypto")},k.getCrypto=function(){return H("crypto")},k.getLocalStorageOrThrow=function(){return N("localStorage")},k.getLocalStorage=function(){return H("localStorage")}},38541:(Qt,k,H)=>{H(63581)},32257:(Qt,k,H)=>{const N=H(82915),Le=H(65361),Je=H(95967),Ve=H(10979),We=Symbol("encodeFragmentIdentifier");function ye(y){if("string"!=typeof y||1!==y.length)throw new TypeError("arrayFormatSeparator must be single character string")}function L(y,O){return O.encode?O.strict?N(y):encodeURIComponent(y):y}function Ie(y,O){return O.decode?Le(y):y}function De(y){return Array.isArray(y)?y.sort():"object"==typeof y?De(Object.keys(y)).sort((O,I)=>Number(O)-Number(I)).map(O=>y[O]):y}function Fe(y){const O=y.indexOf("#");return-1!==O&&(y=y.slice(0,O)),y}function me(y){const O=(y=Fe(y)).indexOf("?");return-1===O?"":y.slice(O+1)}function je(y,O){return O.parseNumbers&&!Number.isNaN(Number(y))&&"string"==typeof y&&""!==y.trim()?y=Number(y):O.parseBooleans&&null!==y&&("true"===y.toLowerCase()||"false"===y.toLowerCase())&&(y="true"===y.toLowerCase()),y}function $e(y,O){ye((O=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},O)).arrayFormatSeparator);const I=function(y){let O;switch(y.arrayFormat){case"index":return(I,x,C)=>{O=/\[(\d*)\]$/.exec(I),I=I.replace(/\[\d*\]$/,""),O?(void 0===C[I]&&(C[I]={}),C[I][O[1]]=x):C[I]=x};case"bracket":return(I,x,C)=>{O=/(\[\])$/.exec(I),C[I=I.replace(/\[\]$/,"")]=O?void 0!==C[I]?[].concat(C[I],x):[x]:x};case"colon-list-separator":return(I,x,C)=>{O=/(:list)$/.exec(I),C[I=I.replace(/:list$/,"")]=O?void 0!==C[I]?[].concat(C[I],x):[x]:x};case"comma":case"separator":return(I,x,C)=>{const W="string"==typeof x&&x.includes(y.arrayFormatSeparator),M="string"==typeof x&&!W&&Ie(x,y).includes(y.arrayFormatSeparator);x=M?Ie(x,y):x;const we=W||M?x.split(y.arrayFormatSeparator).map(Kr=>Ie(Kr,y)):null===x?x:Ie(x,y);C[I]=we};case"bracket-separator":return(I,x,C)=>{const W=/(\[\])$/.test(I);if(I=I.replace(/\[\]$/,""),!W)return void(C[I]=x&&Ie(x,y));const M=null===x?[]:x.split(y.arrayFormatSeparator).map(we=>Ie(we,y));C[I]=void 0!==C[I]?[].concat(C[I],M):M};default:return(I,x,C)=>{C[I]=void 0!==C[I]?[].concat(C[I],x):x}}}(O),x=Object.create(null);if("string"!=typeof y||!(y=y.trim().replace(/^[?#&]/,"")))return x;for(const C of y.split("&")){if(""===C)continue;let[W,M]=Je(O.decode?C.replace(/\+/g," "):C,"=");M=void 0===M?null:["comma","separator","bracket-separator"].includes(O.arrayFormat)?M:Ie(M,O),I(Ie(W,O),M,x)}for(const C of Object.keys(x)){const W=x[C];if("object"==typeof W&&null!==W)for(const M of Object.keys(W))W[M]=je(W[M],O);else x[C]=je(W,O)}return!1===O.sort?x:(!0===O.sort?Object.keys(x).sort():Object.keys(x).sort(O.sort)).reduce((C,W)=>{const M=x[W];return C[W]=Boolean(M)&&"object"==typeof M&&!Array.isArray(M)?De(M):M,C},Object.create(null))}k.extract=me,k.parse=$e,k.stringify=(y,O)=>{if(!y)return"";ye((O=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},O)).arrayFormatSeparator);const I=M=>O.skipNull&&(y=>null==y)(y[M])||O.skipEmptyString&&""===y[M],x=function(y){switch(y.arrayFormat){case"index":return O=>(I,x)=>{const C=I.length;return void 0===x||y.skipNull&&null===x||y.skipEmptyString&&""===x?I:null===x?[...I,[L(O,y),"[",C,"]"].join("")]:[...I,[L(O,y),"[",L(C,y),"]=",L(x,y)].join("")]};case"bracket":return O=>(I,x)=>void 0===x||y.skipNull&&null===x||y.skipEmptyString&&""===x?I:null===x?[...I,[L(O,y),"[]"].join("")]:[...I,[L(O,y),"[]=",L(x,y)].join("")];case"colon-list-separator":return O=>(I,x)=>void 0===x||y.skipNull&&null===x||y.skipEmptyString&&""===x?I:null===x?[...I,[L(O,y),":list="].join("")]:[...I,[L(O,y),":list=",L(x,y)].join("")];case"comma":case"separator":case"bracket-separator":{const O="bracket-separator"===y.arrayFormat?"[]=":"=";return I=>(x,C)=>void 0===C||y.skipNull&&null===C||y.skipEmptyString&&""===C?x:(C=null===C?"":C,0===x.length?[[L(I,y),O,L(C,y)].join("")]:[[x,L(C,y)].join(y.arrayFormatSeparator)])}default:return O=>(I,x)=>void 0===x||y.skipNull&&null===x||y.skipEmptyString&&""===x?I:null===x?[...I,L(O,y)]:[...I,[L(O,y),"=",L(x,y)].join("")]}}(O),C={};for(const M of Object.keys(y))I(M)||(C[M]=y[M]);const W=Object.keys(C);return!1!==O.sort&&W.sort(O.sort),W.map(M=>{const we=y[M];return void 0===we?"":null===we?L(M,O):Array.isArray(we)?0===we.length&&"bracket-separator"===O.arrayFormat?L(M,O)+"[]":we.reduce(x(M),[]).join("&"):L(M,O)+"="+L(we,O)}).filter(M=>M.length>0).join("&")},k.parseUrl=(y,O)=>{O=Object.assign({decode:!0},O);const[I,x]=Je(y,"#");return Object.assign({url:I.split("?")[0]||"",query:$e(me(y),O)},O&&O.parseFragmentIdentifier&&x?{fragmentIdentifier:Ie(x,O)}:{})},k.stringifyUrl=(y,O)=>{O=Object.assign({encode:!0,strict:!0,[We]:!0},O);const I=Fe(y.url).split("?")[0]||"",x=k.extract(y.url),C=k.parse(x,{sort:!1}),W=Object.assign(C,y.query);let M=k.stringify(W,O);M&&(M=`?${M}`);let we=function(y){let O="";const I=y.indexOf("#");return-1!==I&&(O=y.slice(I)),O}(y.url);return y.fragmentIdentifier&&(we=`#${O[We]?L(y.fragmentIdentifier,O):y.fragmentIdentifier}`),`${I}${M}${we}`},k.pick=(y,O,I)=>{I=Object.assign({parseFragmentIdentifier:!0,[We]:!1},I);const{url:x,query:C,fragmentIdentifier:W}=k.parseUrl(y,I);return k.stringifyUrl({url:x,query:Ve(C,O),fragmentIdentifier:W},I)},k.exclude=(y,O,I)=>{const x=Array.isArray(O)?C=>!O.includes(C):(C,W)=>!O(C,W);return k.pick(y,x,I)}},98164:Qt=>{Qt.exports=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}},45418:(Qt,k)=>{function H(De){let Fe;return"undefined"!=typeof window&&void 0!==window[De]&&(Fe=window[De]),Fe}function N(De){const Fe=H(De);if(!Fe)throw new Error(`${De} is not defined in Window`);return Fe}Object.defineProperty(k,"__esModule",{value:!0}),k.getLocalStorage=k.getLocalStorageOrThrow=k.getCrypto=k.getCryptoOrThrow=k.getLocation=k.getLocationOrThrow=k.getNavigator=k.getNavigatorOrThrow=k.getDocument=k.getDocumentOrThrow=k.getFromWindowOrThrow=k.getFromWindow=void 0,k.getFromWindow=H,k.getFromWindowOrThrow=N,k.getDocumentOrThrow=function(){return N("document")},k.getDocument=function(){return H("document")},k.getNavigatorOrThrow=function(){return N("navigator")},k.getNavigator=function(){return H("navigator")},k.getLocationOrThrow=function(){return N("location")},k.getLocation=function(){return H("location")},k.getCryptoOrThrow=function(){return N("crypto")},k.getCrypto=function(){return H("crypto")},k.getLocalStorageOrThrow=function(){return N("localStorage")},k.getLocalStorage=function(){return H("localStorage")}},31846:(Qt,k,H)=>{k.D=void 0;const Le=H(45418);k.D=function(){let Ve,Te;try{Ve=Le.getDocumentOrThrow(),Te=Le.getLocationOrThrow()}catch{return null}function Ye(...me){const je=Ve.getElementsByTagName("meta");for(let $e=0;$e<je.length;$e++){const y=je[$e],O=["itemprop","property","name"].map(I=>y.getAttribute(I)).filter(I=>!!I&&me.includes(I));if(O.length&&O){const I=y.getAttribute("content");if(I)return I}}return""}const L=function(){let me=Ye("name","og:site_name","og:title","twitter:title");return me||(me=Ve.title),me}();return{description:Ye("description","og:description","twitter:description","keywords"),url:Te.origin,icons:function(){const me=Ve.getElementsByTagName("link"),je=[];for(let $e=0;$e<me.length;$e++){const y=me[$e],O=y.getAttribute("rel");if(O&&O.toLowerCase().indexOf("icon")>-1){const I=y.getAttribute("href");if(I)if(-1===I.toLowerCase().indexOf("https:")&&-1===I.toLowerCase().indexOf("http:")&&0!==I.indexOf("//")){let x=Te.protocol+"//"+Te.host;if(0===I.indexOf("/"))x+=I;else{const C=Te.pathname.split("/");C.pop(),x+=C.join("/")+"/"+I}je.push(x)}else 0===I.indexOf("//")?je.push(Te.protocol+I):je.push(I)}}return je}(),name:L}}},34955:(Qt,k,H)=>{const N=H(82915),Le=H(65361),Je=H(95967),Ve=H(10979),We=Symbol("encodeFragmentIdentifier");function ye(y){if("string"!=typeof y||1!==y.length)throw new TypeError("arrayFormatSeparator must be single character string")}function L(y,O){return O.encode?O.strict?N(y):encodeURIComponent(y):y}function Ie(y,O){return O.decode?Le(y):y}function De(y){return Array.isArray(y)?y.sort():"object"==typeof y?De(Object.keys(y)).sort((O,I)=>Number(O)-Number(I)).map(O=>y[O]):y}function Fe(y){const O=y.indexOf("#");return-1!==O&&(y=y.slice(0,O)),y}function me(y){const O=(y=Fe(y)).indexOf("?");return-1===O?"":y.slice(O+1)}function je(y,O){return O.parseNumbers&&!Number.isNaN(Number(y))&&"string"==typeof y&&""!==y.trim()?y=Number(y):O.parseBooleans&&null!==y&&("true"===y.toLowerCase()||"false"===y.toLowerCase())&&(y="true"===y.toLowerCase()),y}function $e(y,O){ye((O=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},O)).arrayFormatSeparator);const I=function(y){let O;switch(y.arrayFormat){case"index":return(I,x,C)=>{O=/\[(\d*)\]$/.exec(I),I=I.replace(/\[\d*\]$/,""),O?(void 0===C[I]&&(C[I]={}),C[I][O[1]]=x):C[I]=x};case"bracket":return(I,x,C)=>{O=/(\[\])$/.exec(I),C[I=I.replace(/\[\]$/,"")]=O?void 0!==C[I]?[].concat(C[I],x):[x]:x};case"colon-list-separator":return(I,x,C)=>{O=/(:list)$/.exec(I),C[I=I.replace(/:list$/,"")]=O?void 0!==C[I]?[].concat(C[I],x):[x]:x};case"comma":case"separator":return(I,x,C)=>{const W="string"==typeof x&&x.includes(y.arrayFormatSeparator),M="string"==typeof x&&!W&&Ie(x,y).includes(y.arrayFormatSeparator);x=M?Ie(x,y):x;const we=W||M?x.split(y.arrayFormatSeparator).map(Kr=>Ie(Kr,y)):null===x?x:Ie(x,y);C[I]=we};case"bracket-separator":return(I,x,C)=>{const W=/(\[\])$/.test(I);if(I=I.replace(/\[\]$/,""),!W)return void(C[I]=x&&Ie(x,y));const M=null===x?[]:x.split(y.arrayFormatSeparator).map(we=>Ie(we,y));C[I]=void 0!==C[I]?[].concat(C[I],M):M};default:return(I,x,C)=>{C[I]=void 0!==C[I]?[].concat(C[I],x):x}}}(O),x=Object.create(null);if("string"!=typeof y||!(y=y.trim().replace(/^[?#&]/,"")))return x;for(const C of y.split("&")){if(""===C)continue;let[W,M]=Je(O.decode?C.replace(/\+/g," "):C,"=");M=void 0===M?null:["comma","separator","bracket-separator"].includes(O.arrayFormat)?M:Ie(M,O),I(Ie(W,O),M,x)}for(const C of Object.keys(x)){const W=x[C];if("object"==typeof W&&null!==W)for(const M of Object.keys(W))W[M]=je(W[M],O);else x[C]=je(W,O)}return!1===O.sort?x:(!0===O.sort?Object.keys(x).sort():Object.keys(x).sort(O.sort)).reduce((C,W)=>{const M=x[W];return C[W]=Boolean(M)&&"object"==typeof M&&!Array.isArray(M)?De(M):M,C},Object.create(null))}k.extract=me,k.parse=$e,k.stringify=(y,O)=>{if(!y)return"";ye((O=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},O)).arrayFormatSeparator);const I=M=>O.skipNull&&(y=>null==y)(y[M])||O.skipEmptyString&&""===y[M],x=function(y){switch(y.arrayFormat){case"index":return O=>(I,x)=>{const C=I.length;return void 0===x||y.skipNull&&null===x||y.skipEmptyString&&""===x?I:null===x?[...I,[L(O,y),"[",C,"]"].join("")]:[...I,[L(O,y),"[",L(C,y),"]=",L(x,y)].join("")]};case"bracket":return O=>(I,x)=>void 0===x||y.skipNull&&null===x||y.skipEmptyString&&""===x?I:null===x?[...I,[L(O,y),"[]"].join("")]:[...I,[L(O,y),"[]=",L(x,y)].join("")];case"colon-list-separator":return O=>(I,x)=>void 0===x||y.skipNull&&null===x||y.skipEmptyString&&""===x?I:null===x?[...I,[L(O,y),":list="].join("")]:[...I,[L(O,y),":list=",L(x,y)].join("")];case"comma":case"separator":case"bracket-separator":{const O="bracket-separator"===y.arrayFormat?"[]=":"=";return I=>(x,C)=>void 0===C||y.skipNull&&null===C||y.skipEmptyString&&""===C?x:(C=null===C?"":C,0===x.length?[[L(I,y),O,L(C,y)].join("")]:[[x,L(C,y)].join(y.arrayFormatSeparator)])}default:return O=>(I,x)=>void 0===x||y.skipNull&&null===x||y.skipEmptyString&&""===x?I:null===x?[...I,L(O,y)]:[...I,[L(O,y),"=",L(x,y)].join("")]}}(O),C={};for(const M of Object.keys(y))I(M)||(C[M]=y[M]);const W=Object.keys(C);return!1!==O.sort&&W.sort(O.sort),W.map(M=>{const we=y[M];return void 0===we?"":null===we?L(M,O):Array.isArray(we)?0===we.length&&"bracket-separator"===O.arrayFormat?L(M,O)+"[]":we.reduce(x(M),[]).join("&"):L(M,O)+"="+L(we,O)}).filter(M=>M.length>0).join("&")},k.parseUrl=(y,O)=>{O=Object.assign({decode:!0},O);const[I,x]=Je(y,"#");return Object.assign({url:I.split("?")[0]||"",query:$e(me(y),O)},O&&O.parseFragmentIdentifier&&x?{fragmentIdentifier:Ie(x,O)}:{})},k.stringifyUrl=(y,O)=>{O=Object.assign({encode:!0,strict:!0,[We]:!0},O);const I=Fe(y.url).split("?")[0]||"",x=k.extract(y.url),C=k.parse(x,{sort:!1}),W=Object.assign(C,y.query);let M=k.stringify(W,O);M&&(M=`?${M}`);let we=function(y){let O="";const I=y.indexOf("#");return-1!==I&&(O=y.slice(I)),O}(y.url);return y.fragmentIdentifier&&(we=`#${O[We]?L(y.fragmentIdentifier,O):y.fragmentIdentifier}`),`${I}${M}${we}`},k.pick=(y,O,I)=>{I=Object.assign({parseFragmentIdentifier:!0,[We]:!1},I);const{url:x,query:C,fragmentIdentifier:W}=k.parseUrl(y,I);return k.stringifyUrl({url:x,query:Ve(C,O),fragmentIdentifier:W},I)},k.exclude=(y,O,I)=>{const x=Array.isArray(O)?C=>!O.includes(C):(C,W)=>!O(C,W);return k.pick(y,x,I)}},7092:(Qt,k)=>{function H(De){let Fe;return"undefined"!=typeof window&&void 0!==window[De]&&(Fe=window[De]),Fe}function N(De){const Fe=H(De);if(!Fe)throw new Error(`${De} is not defined in Window`);return Fe}Object.defineProperty(k,"__esModule",{value:!0}),k.getLocalStorage=k.getLocalStorageOrThrow=k.getCrypto=k.getCryptoOrThrow=k.getLocation=k.getLocationOrThrow=k.getNavigator=k.getNavigatorOrThrow=k.getDocument=k.getDocumentOrThrow=k.getFromWindowOrThrow=k.getFromWindow=void 0,k.getFromWindow=H,k.getFromWindowOrThrow=N,k.getDocumentOrThrow=function(){return N("document")},k.getDocument=function(){return H("document")},k.getNavigatorOrThrow=function(){return N("navigator")},k.getNavigator=function(){return H("navigator")},k.getLocationOrThrow=function(){return N("location")},k.getLocation=function(){return H("location")},k.getCryptoOrThrow=function(){return N("crypto")},k.getCrypto=function(){return H("crypto")},k.getLocalStorageOrThrow=function(){return N("localStorage")},k.getLocalStorage=function(){return H("localStorage")}},47274:(Qt,k,H)=>{H(7092)},49290:(Qt,k,H)=>{const N=H(82915),Le=H(65361),Je=H(95967),Ve=H(10979),We=Symbol("encodeFragmentIdentifier");function ye(y){if("string"!=typeof y||1!==y.length)throw new TypeError("arrayFormatSeparator must be single character string")}function L(y,O){return O.encode?O.strict?N(y):encodeURIComponent(y):y}function Ie(y,O){return O.decode?Le(y):y}function De(y){return Array.isArray(y)?y.sort():"object"==typeof y?De(Object.keys(y)).sort((O,I)=>Number(O)-Number(I)).map(O=>y[O]):y}function Fe(y){const O=y.indexOf("#");return-1!==O&&(y=y.slice(0,O)),y}function me(y){const O=(y=Fe(y)).indexOf("?");return-1===O?"":y.slice(O+1)}function je(y,O){return O.parseNumbers&&!Number.isNaN(Number(y))&&"string"==typeof y&&""!==y.trim()?y=Number(y):O.parseBooleans&&null!==y&&("true"===y.toLowerCase()||"false"===y.toLowerCase())&&(y="true"===y.toLowerCase()),y}function $e(y,O){ye((O=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},O)).arrayFormatSeparator);const I=function(y){let O;switch(y.arrayFormat){case"index":return(I,x,C)=>{O=/\[(\d*)\]$/.exec(I),I=I.replace(/\[\d*\]$/,""),O?(void 0===C[I]&&(C[I]={}),C[I][O[1]]=x):C[I]=x};case"bracket":return(I,x,C)=>{O=/(\[\])$/.exec(I),C[I=I.replace(/\[\]$/,"")]=O?void 0!==C[I]?[].concat(C[I],x):[x]:x};case"colon-list-separator":return(I,x,C)=>{O=/(:list)$/.exec(I),C[I=I.replace(/:list$/,"")]=O?void 0!==C[I]?[].concat(C[I],x):[x]:x};case"comma":case"separator":return(I,x,C)=>{const W="string"==typeof x&&x.includes(y.arrayFormatSeparator),M="string"==typeof x&&!W&&Ie(x,y).includes(y.arrayFormatSeparator);x=M?Ie(x,y):x;const we=W||M?x.split(y.arrayFormatSeparator).map(Kr=>Ie(Kr,y)):null===x?x:Ie(x,y);C[I]=we};case"bracket-separator":return(I,x,C)=>{const W=/(\[\])$/.test(I);if(I=I.replace(/\[\]$/,""),!W)return void(C[I]=x&&Ie(x,y));const M=null===x?[]:x.split(y.arrayFormatSeparator).map(we=>Ie(we,y));C[I]=void 0!==C[I]?[].concat(C[I],M):M};default:return(I,x,C)=>{C[I]=void 0!==C[I]?[].concat(C[I],x):x}}}(O),x=Object.create(null);if("string"!=typeof y||!(y=y.trim().replace(/^[?#&]/,"")))return x;for(const C of y.split("&")){if(""===C)continue;let[W,M]=Je(O.decode?C.replace(/\+/g," "):C,"=");M=void 0===M?null:["comma","separator","bracket-separator"].includes(O.arrayFormat)?M:Ie(M,O),I(Ie(W,O),M,x)}for(const C of Object.keys(x)){const W=x[C];if("object"==typeof W&&null!==W)for(const M of Object.keys(W))W[M]=je(W[M],O);else x[C]=je(W,O)}return!1===O.sort?x:(!0===O.sort?Object.keys(x).sort():Object.keys(x).sort(O.sort)).reduce((C,W)=>{const M=x[W];return C[W]=Boolean(M)&&"object"==typeof M&&!Array.isArray(M)?De(M):M,C},Object.create(null))}k.extract=me,k.parse=$e,k.stringify=(y,O)=>{if(!y)return"";ye((O=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},O)).arrayFormatSeparator);const I=M=>O.skipNull&&(y=>null==y)(y[M])||O.skipEmptyString&&""===y[M],x=function(y){switch(y.arrayFormat){case"index":return O=>(I,x)=>{const C=I.length;return void 0===x||y.skipNull&&null===x||y.skipEmptyString&&""===x?I:null===x?[...I,[L(O,y),"[",C,"]"].join("")]:[...I,[L(O,y),"[",L(C,y),"]=",L(x,y)].join("")]};case"bracket":return O=>(I,x)=>void 0===x||y.skipNull&&null===x||y.skipEmptyString&&""===x?I:null===x?[...I,[L(O,y),"[]"].join("")]:[...I,[L(O,y),"[]=",L(x,y)].join("")];case"colon-list-separator":return O=>(I,x)=>void 0===x||y.skipNull&&null===x||y.skipEmptyString&&""===x?I:null===x?[...I,[L(O,y),":list="].join("")]:[...I,[L(O,y),":list=",L(x,y)].join("")];case"comma":case"separator":case"bracket-separator":{const O="bracket-separator"===y.arrayFormat?"[]=":"=";return I=>(x,C)=>void 0===C||y.skipNull&&null===C||y.skipEmptyString&&""===C?x:(C=null===C?"":C,0===x.length?[[L(I,y),O,L(C,y)].join("")]:[[x,L(C,y)].join(y.arrayFormatSeparator)])}default:return O=>(I,x)=>void 0===x||y.skipNull&&null===x||y.skipEmptyString&&""===x?I:null===x?[...I,L(O,y)]:[...I,[L(O,y),"=",L(x,y)].join("")]}}(O),C={};for(const M of Object.keys(y))I(M)||(C[M]=y[M]);const W=Object.keys(C);return!1!==O.sort&&W.sort(O.sort),W.map(M=>{const we=y[M];return void 0===we?"":null===we?L(M,O):Array.isArray(we)?0===we.length&&"bracket-separator"===O.arrayFormat?L(M,O)+"[]":we.reduce(x(M),[]).join("&"):L(M,O)+"="+L(we,O)}).filter(M=>M.length>0).join("&")},k.parseUrl=(y,O)=>{O=Object.assign({decode:!0},O);const[I,x]=Je(y,"#");return Object.assign({url:I.split("?")[0]||"",query:$e(me(y),O)},O&&O.parseFragmentIdentifier&&x?{fragmentIdentifier:Ie(x,O)}:{})},k.stringifyUrl=(y,O)=>{O=Object.assign({encode:!0,strict:!0,[We]:!0},O);const I=Fe(y.url).split("?")[0]||"",x=k.extract(y.url),C=k.parse(x,{sort:!1}),W=Object.assign(C,y.query);let M=k.stringify(W,O);M&&(M=`?${M}`);let we=function(y){let O="";const I=y.indexOf("#");return-1!==I&&(O=y.slice(I)),O}(y.url);return y.fragmentIdentifier&&(we=`#${O[We]?L(y.fragmentIdentifier,O):y.fragmentIdentifier}`),`${I}${M}${we}`},k.pick=(y,O,I)=>{I=Object.assign({parseFragmentIdentifier:!0,[We]:!1},I);const{url:x,query:C,fragmentIdentifier:W}=k.parseUrl(y,I);return k.stringifyUrl({url:x,query:Ve(C,O),fragmentIdentifier:W},I)},k.exclude=(y,O,I)=>{const x=Array.isArray(O)?C=>!O.includes(C):(C,W)=>!O(C,W);return k.pick(y,x,I)}}}]);