const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-DHeGpow_.js","assets/index-F5308wi0.js","assets/index-B4tYLrKQ.css"])))=>i.map(i=>d[i]); import{i as Q0,e as Y0,f as Z0,h as X0,j as ew,k as tw,m as rw,o as iw,p as sw,q as nw,s as ow,r as aw,t as cw,u as uw,v as hw,w as qa,x as jl,y as X,z as xe,A as ra,B as ql,C as qn,H as lw,D as Ml,E as fw,F as pw,G as Ma,I as Ll,J as br,K as dw,L as gw,M as Ul,N as yw,O as La,_ as mw}from"./index-F5308wi0.js";import{d as vw,s as Ps,a as Mn,r as ww,f as ki,g as zl,i as Or,b as Ln,c as Ph,e as bw,h as _w,j as Ua,p as Ew,k as za,l as ka,m as ei,n as Iw,o as si}from"./index.es-Bgge-tB-.js";function Ha(s){return globalThis.Buffer!=null?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):s}function kl(s=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?Ha(globalThis.Buffer.allocUnsafe(s)):new Uint8Array(s)}function ba(s,t){t||(t=s.reduce((a,u)=>a+u.length,0));const r=kl(t);let n=0;for(const a of s)r.set(a,n),n+=a.length;return Ha(r)}const Oh={...Q0,...Y0,...Z0,...X0,...ew,...tw,...rw,...iw,...sw,...nw};function Hl(s,t,r,n){return{name:s,prefix:t,encoder:{name:s,prefix:t,encode:r},decoder:{decode:n}}}const Rh=Hl("utf8","u",s=>"u"+new TextDecoder("utf8").decode(s),s=>new TextEncoder().encode(s.substring(1))),ia=Hl("ascii","a",s=>{let t="a";for(let r=0;r<s.length;r++)t+=String.fromCharCode(s[r]);return t},s=>{s=s.substring(1);const t=kl(s.length);for(let r=0;r<s.length;r++)t[r]=s.charCodeAt(r);return t}),Kl={utf8:Rh,"utf-8":Rh,hex:Oh.base16,latin1:ia,ascii:ia,binary:ia,...Oh};function Vt(s,t="utf8"){const r=Kl[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Ha(globalThis.Buffer.from(s,"utf-8")):r.decoder.decode(`${r.prefix}${s}`)}function Dt(s,t="utf8"){const r=Kl[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(s.buffer,s.byteOffset,s.byteLength).toString("utf8"):r.encoder.encode(s).substring(1)}const xw={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe",batchFetchMessages:"waku_batchFetchMessages"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe",batchFetchMessages:"irn_batchFetchMessages"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe",batchFetchMessages:"iridium_batchFetchMessages"}};var _s={};(function(s){const t=cw,r=uw,n=ow,a=aw,u=P=>P==null,f=Symbol("encodeFragmentIdentifier");function y(P){switch(P.arrayFormat){case"index":return $=>(C,q)=>{const z=C.length;return q===void 0||P.skipNull&&q===null||P.skipEmptyString&&q===""?C:q===null?[...C,[w($,P),"[",z,"]"].join("")]:[...C,[w($,P),"[",w(z,P),"]=",w(q,P)].join("")]};case"bracket":return $=>(C,q)=>q===void 0||P.skipNull&&q===null||P.skipEmptyString&&q===""?C:q===null?[...C,[w($,P),"[]"].join("")]:[...C,[w($,P),"[]=",w(q,P)].join("")];case"colon-list-separator":return $=>(C,q)=>q===void 0||P.skipNull&&q===null||P.skipEmptyString&&q===""?C:q===null?[...C,[w($,P),":list="].join("")]:[...C,[w($,P),":list=",w(q,P)].join("")];case"comma":case"separator":case"bracket-separator":{const $=P.arrayFormat==="bracket-separator"?"[]=":"=";return C=>(q,z)=>z===void 0||P.skipNull&&z===null||P.skipEmptyString&&z===""?q:(z=z===null?"":z,q.length===0?[[w(C,P),$,w(z,P)].join("")]:[[q,w(z,P)].join(P.arrayFormatSeparator)])}default:return $=>(C,q)=>q===void 0||P.skipNull&&q===null||P.skipEmptyString&&q===""?C:q===null?[...C,w($,P)]:[...C,[w($,P),"=",w(q,P)].join("")]}}function m(P){let $;switch(P.arrayFormat){case"index":return(C,q,z)=>{if($=/\[(\d*)\]$/.exec(C),C=C.replace(/\[\d*\]$/,""),!$){z[C]=q;return}z[C]===void 0&&(z[C]={}),z[C][$[1]]=q};case"bracket":return(C,q,z)=>{if($=/(\[\])$/.exec(C),C=C.replace(/\[\]$/,""),!$){z[C]=q;return}if(z[C]===void 0){z[C]=[q];return}z[C]=[].concat(z[C],q)};case"colon-list-separator":return(C,q,z)=>{if($=/(:list)$/.exec(C),C=C.replace(/:list$/,""),!$){z[C]=q;return}if(z[C]===void 0){z[C]=[q];return}z[C]=[].concat(z[C],q)};case"comma":case"separator":return(C,q,z)=>{const K=typeof q=="string"&&q.includes(P.arrayFormatSeparator),W=typeof q=="string"&&!K&&_(q,P).includes(P.arrayFormatSeparator);q=W?_(q,P):q;const we=K||W?q.split(P.arrayFormatSeparator).map(tt=>_(tt,P)):q===null?q:_(q,P);z[C]=we};case"bracket-separator":return(C,q,z)=>{const K=/(\[\])$/.test(C);if(C=C.replace(/\[\]$/,""),!K){z[C]=q&&_(q,P);return}const W=q===null?[]:q.split(P.arrayFormatSeparator).map(we=>_(we,P));if(z[C]===void 0){z[C]=W;return}z[C]=[].concat(z[C],W)};default:return(C,q,z)=>{if(z[C]===void 0){z[C]=q;return}z[C]=[].concat(z[C],q)}}}function g(P){if(typeof P!="string"||P.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function w(P,$){return $.encode?$.strict?t(P):encodeURIComponent(P):P}function _(P,$){return $.decode?r(P):P}function O(P){return Array.isArray(P)?P.sort():typeof P=="object"?O(Object.keys(P)).sort(($,C)=>Number($)-Number(C)).map($=>P[$]):P}function j(P){const $=P.indexOf("#");return $!==-1&&(P=P.slice(0,$)),P}function N(P){let $="";const C=P.indexOf("#");return C!==-1&&($=P.slice(C)),$}function ee(P){P=j(P);const $=P.indexOf("?");return $===-1?"":P.slice($+1)}function ne(P,$){return $.parseNumbers&&!Number.isNaN(Number(P))&&typeof P=="string"&&P.trim()!==""?P=Number(P):$.parseBooleans&&P!==null&&(P.toLowerCase()==="true"||P.toLowerCase()==="false")&&(P=P.toLowerCase()==="true"),P}function oe(P,$){$=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},$),g($.arrayFormatSeparator);const C=m($),q=Object.create(null);if(typeof P!="string"||(P=P.trim().replace(/^[?#&]/,""),!P))return q;for(const z of P.split("&")){if(z==="")continue;let[K,W]=n($.decode?z.replace(/\+/g," "):z,"=");W=W===void 0?null:["comma","separator","bracket-separator"].includes($.arrayFormat)?W:_(W,$),C(_(K,$),W,q)}for(const z of Object.keys(q)){const K=q[z];if(typeof K=="object"&&K!==null)for(const W of Object.keys(K))K[W]=ne(K[W],$);else q[z]=ne(K,$)}return $.sort===!1?q:($.sort===!0?Object.keys(q).sort():Object.keys(q).sort($.sort)).reduce((z,K)=>{const W=q[K];return W&&typeof W=="object"&&!Array.isArray(W)?z[K]=O(W):z[K]=W,z},Object.create(null))}s.extract=ee,s.parse=oe,s.stringify=(P,$)=>{if(!P)return"";$=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},$),g($.arrayFormatSeparator);const C=W=>$.skipNull&&u(P[W])||$.skipEmptyString&&P[W]==="",q=y($),z={};for(const W of Object.keys(P))C(W)||(z[W]=P[W]);const K=Object.keys(z);return $.sort!==!1&&K.sort($.sort),K.map(W=>{const we=P[W];return we===void 0?"":we===null?w(W,$):Array.isArray(we)?we.length===0&&$.arrayFormat==="bracket-separator"?w(W,$)+"[]":we.reduce(q(W),[]).join("&"):w(W,$)+"="+w(we,$)}).filter(W=>W.length>0).join("&")},s.parseUrl=(P,$)=>{$=Object.assign({decode:!0},$);const[C,q]=n(P,"#");return Object.assign({url:C.split("?")[0]||"",query:oe(ee(P),$)},$&&$.parseFragmentIdentifier&&q?{fragmentIdentifier:_(q,$)}:{})},s.stringifyUrl=(P,$)=>{$=Object.assign({encode:!0,strict:!0,[f]:!0},$);const C=j(P.url).split("?")[0]||"",q=s.extract(P.url),z=s.parse(q,{sort:!1}),K=Object.assign(z,P.query);let W=s.stringify(K,$);W&&(W=`?${W}`);let we=N(P.url);return P.fragmentIdentifier&&(we=`#${$[f]?w(P.fragmentIdentifier,$):P.fragmentIdentifier}`),`${C}${W}${we}`},s.pick=(P,$,C)=>{C=Object.assign({parseFragmentIdentifier:!0,[f]:!1},C);const{url:q,query:z,fragmentIdentifier:K}=s.parseUrl(P,C);return s.stringifyUrl({url:q,query:a(z,$),fragmentIdentifier:K},C)},s.exclude=(P,$,C)=>{const q=Array.isArray($)?z=>!$.includes(z):(z,K)=>!$(z,K);return s.pick(P,q,C)}})(_s);const Sw=":";function Pw(s){const[t,r]=s.split(Sw);return{namespace:t,reference:r}}function Ow(s,t=[]){const r=[];return Object.keys(s).forEach(n=>{if(t.length&&!t.includes(n))return;const a=s[n];r.push(...a.accounts)}),r}function Vl(s,t){return s.includes(":")?[s]:t.chains||[]}const Fl="base10",Tt="base16",_a="base64pad",Ka="utf8",Bl=0,mi=1,Rw=0,Nh=1,Ea=12,Va=32;function Nw(){const s=ql.generateKeyPair();return{privateKey:Dt(s.secretKey,Tt),publicKey:Dt(s.publicKey,Tt)}}function Ia(){const s=qn.randomBytes(Va);return Dt(s,Tt)}function $w(s,t){const r=ql.sharedKey(Vt(s,Tt),Vt(t,Tt),!0),n=new lw(qa.SHA256,r).expand(Va);return Dt(n,Tt)}function Cw(s){const t=qa.hash(Vt(s,Tt));return Dt(t,Tt)}function Hi(s){const t=qa.hash(Vt(s,Ka));return Dt(t,Tt)}function Aw(s){return Vt(`${s}`,Fl)}function Os(s){return Number(Dt(s,Fl))}function Tw(s){const t=Aw(typeof s.type<"u"?s.type:Bl);if(Os(t)===mi&&typeof s.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof s.senderPublicKey<"u"?Vt(s.senderPublicKey,Tt):void 0,n=typeof s.iv<"u"?Vt(s.iv,Tt):qn.randomBytes(Ea),a=new Ml.ChaCha20Poly1305(Vt(s.symKey,Tt)).seal(n,Vt(s.message,Ka));return jw({type:t,sealed:a,iv:n,senderPublicKey:r})}function Dw(s){const t=new Ml.ChaCha20Poly1305(Vt(s.symKey,Tt)),{sealed:r,iv:n}=An(s.encoded),a=t.open(n,r);if(a===null)throw new Error("Failed to decrypt");return Dt(a,Ka)}function jw(s){if(Os(s.type)===mi){if(typeof s.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return Dt(ba([s.type,s.senderPublicKey,s.iv,s.sealed]),_a)}return Dt(ba([s.type,s.iv,s.sealed]),_a)}function An(s){const t=Vt(s,_a),r=t.slice(Rw,Nh),n=Nh;if(Os(r)===mi){const y=n+Va,m=y+Ea,g=t.slice(n,y),w=t.slice(y,m),_=t.slice(m);return{type:r,sealed:_,iv:w,senderPublicKey:g}}const a=n+Ea,u=t.slice(n,a),f=t.slice(a);return{type:r,sealed:f,iv:u}}function qw(s,t){const r=An(s);return Gl({type:Os(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?Dt(r.senderPublicKey,Tt):void 0,receiverPublicKey:t==null?void 0:t.receiverPublicKey})}function Gl(s){const t=(s==null?void 0:s.type)||Bl;if(t===mi){if(typeof(s==null?void 0:s.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(s==null?void 0:s.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:s==null?void 0:s.senderPublicKey,receiverPublicKey:s==null?void 0:s.receiverPublicKey}}function $h(s){return s.type===mi&&typeof s.senderPublicKey=="string"&&typeof s.receiverPublicKey=="string"}var Mw=Object.defineProperty,Ch=Object.getOwnPropertySymbols,Lw=Object.prototype.hasOwnProperty,Uw=Object.prototype.propertyIsEnumerable,Ah=(s,t,r)=>t in s?Mw(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,Th=(s,t)=>{for(var r in t||(t={}))Lw.call(t,r)&&Ah(s,r,t[r]);if(Ch)for(var r of Ch(t))Uw.call(t,r)&&Ah(s,r,t[r]);return s};const zw="ReactNative",Xt={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},kw="js";function Fa(){return typeof ra<"u"&&typeof ra.versions<"u"&&typeof ra.versions.node<"u"}function Vi(){return!fw()&&!!jl()&&navigator.product===zw}function Fi(){return!Fa()&&!!jl()}function Rs(){return Vi()?Xt.reactNative:Fa()?Xt.node:Fi()?Xt.browser:Xt.unknown}function Hw(){var s;try{return Vi()&&typeof xe<"u"&&typeof(xe==null?void 0:xe.Application)<"u"?(s=xe.Application)==null?void 0:s.applicationId:void 0}catch{return}}function Kw(s,t){let r=_s.parse(s);return r=Th(Th({},r),t),s=_s.stringify(r),s}function Vw(){return hw()||{name:"",description:"",url:"",icons:[""]}}function Fw(){if(Rs()===Xt.reactNative&&typeof xe<"u"&&typeof(xe==null?void 0:xe.Platform)<"u"){const{OS:r,Version:n}=xe.Platform;return[r,n].join("-")}const s=vw();if(s===null)return"unknown";const t=s.os?s.os.replace(" ","").toLowerCase():"unknown";return s.type==="browser"?[t,s.name,s.version].join("-"):[t,s.version].join("-")}function Bw(){var s;const t=Rs();return t===Xt.browser?[t,((s=pw())==null?void 0:s.host)||"unknown"].join(":"):t}function Gw(s,t,r){const n=Fw(),a=Bw();return[[s,t].join("-"),[kw,r].join("-"),n,a].join("/")}function Ww({protocol:s,version:t,relayUrl:r,sdkVersion:n,auth:a,projectId:u,useOnCloseEvent:f,bundleId:y}){const m=r.split("?"),g=Gw(s,t,n),w={auth:a,ua:g,projectId:u,useOnCloseEvent:f||void 0,origin:y||void 0},_=Kw(m[1]||"",w);return m[0]+"?"+_}function yi(s,t){return s.filter(r=>t.includes(r)).length===s.length}function Wl(s){return Object.fromEntries(s.entries())}function Jl(s){return new Map(Object.entries(s))}function Ui(s=X.FIVE_MINUTES,t){const r=X.toMiliseconds(s||X.FIVE_MINUTES);let n,a,u;return{resolve:f=>{u&&n&&(clearTimeout(u),n(f))},reject:f=>{u&&a&&(clearTimeout(u),a(f))},done:()=>new Promise((f,y)=>{u=setTimeout(()=>{y(new Error(t))},r),n=f,a=y})}}function Es(s,t,r){return new Promise(async(n,a)=>{const u=setTimeout(()=>a(new Error(r)),t);try{const f=await s;n(f)}catch(f){a(f)}clearTimeout(u)})}function Ql(s,t){if(typeof t=="string"&&t.startsWith(`${s}:`))return t;if(s.toLowerCase()==="topic"){if(typeof t!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}else if(s.toLowerCase()==="id"){if(typeof t!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${s}`)}function Jw(s){return Ql("topic",s)}function Qw(s){return Ql("id",s)}function Yl(s){const[t,r]=s.split(":"),n={id:void 0,topic:void 0};if(t==="topic"&&typeof r=="string")n.topic=r;else if(t==="id"&&Number.isInteger(Number(r)))n.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${r}`);return n}function wr(s,t){return X.fromMiliseconds(Date.now()+X.toMiliseconds(s))}function ti(s){return Date.now()>=X.toMiliseconds(s)}function Je(s,t){return`${s}${t?`:${t}`:""}`}function sa(s=[],t=[]){return[...new Set([...s,...t])]}async function Yw({id:s,topic:t,wcDeepLink:r}){try{if(!r)return;const n=typeof r=="string"?JSON.parse(r):r;let a=n==null?void 0:n.href;if(typeof a!="string")return;a.endsWith("/")&&(a=a.slice(0,-1));const u=`${a}/wc?requestId=${s}&sessionTopic=${t}`,f=Rs();f===Xt.browser?u.startsWith("https://")?window.open(u,"_blank","noreferrer noopener"):window.open(u,"_self","noreferrer noopener"):f===Xt.reactNative&&typeof(xe==null?void 0:xe.Linking)<"u"&&await xe.Linking.openURL(u)}catch(n){console.error(n)}}async function Zw(s,t){try{return await s.getItem(t)||(Fi()?localStorage.getItem(t):void 0)}catch(r){console.error(r)}}const Xw="irn";function xa(s){return(s==null?void 0:s.relay)||{protocol:Xw}}function Rn(s){const t=xw[s];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${s}`);return t}var eb=Object.defineProperty,Dh=Object.getOwnPropertySymbols,tb=Object.prototype.hasOwnProperty,rb=Object.prototype.propertyIsEnumerable,jh=(s,t,r)=>t in s?eb(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,ib=(s,t)=>{for(var r in t||(t={}))tb.call(t,r)&&jh(s,r,t[r]);if(Dh)for(var r of Dh(t))rb.call(t,r)&&jh(s,r,t[r]);return s};function sb(s,t="-"){const r={},n="relay"+t;return Object.keys(s).forEach(a=>{if(a.startsWith(n)){const u=a.replace(n,""),f=s[a];r[u]=f}}),r}function qh(s){s=s.includes("wc://")?s.replace("wc://",""):s,s=s.includes("wc:")?s.replace("wc:",""):s;const t=s.indexOf(":"),r=s.indexOf("?")!==-1?s.indexOf("?"):void 0,n=s.substring(0,t),a=s.substring(t+1,r).split("@"),u=typeof r<"u"?s.substring(r):"",f=_s.parse(u);return{protocol:n,topic:nb(a[0]),version:parseInt(a[1],10),symKey:f.symKey,relay:sb(f)}}function nb(s){return s.startsWith("//")?s.substring(2):s}function ob(s,t="-"){const r="relay",n={};return Object.keys(s).forEach(a=>{const u=r+t+a;s[a]&&(n[u]=s[a])}),n}function ab(s){return`${s.protocol}:${s.topic}@${s.version}?`+_s.stringify(ib({symKey:s.symKey},ob(s.relay)))}function Bi(s){const t=[];return s.forEach(r=>{const[n,a]=r.split(":");t.push(`${n}:${a}`)}),t}function cb(s){const t=[];return Object.values(s).forEach(r=>{t.push(...Bi(r.accounts))}),t}function ub(s,t){const r=[];return Object.values(s).forEach(n=>{Bi(n.accounts).includes(t)&&r.push(...n.methods)}),r}function hb(s,t){const r=[];return Object.values(s).forEach(n=>{Bi(n.accounts).includes(t)&&r.push(...n.events)}),r}function lb(s,t){const r=Nn(s,t);if(r)throw new Error(r.message);const n={};for(const[a,u]of Object.entries(s))n[a]={methods:u.methods,events:u.events,chains:u.accounts.map(f=>`${f.split(":")[0]}:${f.split(":")[1]}`)};return n}function Ba(s){return s.includes(":")}function vs(s){return Ba(s)?s.split(":")[0]:s}const fb={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}},pb={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 V(s,t){const{message:r,code:n}=pb[s];return{message:t?`${r} ${t}`:r,code:n}}function Fe(s,t){const{message:r,code:n}=fb[s];return{message:t?`${r} ${t}`:r,code:n}}function Nr(s,t){return!!Array.isArray(s)}function Ki(s){return Object.getPrototypeOf(s)===Object.prototype&&Object.keys(s).length}function Kt(s){return typeof s>"u"}function wt(s,t){return t&&Kt(s)?!0:typeof s=="string"&&!!s.trim().length}function Ga(s,t){return typeof s=="number"&&!isNaN(s)}function db(s,t){const{requiredNamespaces:r}=t,n=Object.keys(s.namespaces),a=Object.keys(r);let u=!0;return yi(a,n)?(n.forEach(f=>{const{accounts:y,methods:m,events:g}=s.namespaces[f],w=Bi(y),_=r[f];(!yi(Vl(f,_),w)||!yi(_.methods,m)||!yi(_.events,g))&&(u=!1)}),u):!1}function Tn(s){return wt(s,!1)&&s.includes(":")?s.split(":").length===2:!1}function gb(s){if(wt(s,!1)&&s.includes(":")){const t=s.split(":");if(t.length===3){const r=t[0]+":"+t[1];return!!t[2]&&Tn(r)}}return!1}function yb(s){if(wt(s,!1))try{return typeof new URL(s)<"u"}catch{return!1}return!1}function mb(s){var t;return(t=s==null?void 0:s.proposer)==null?void 0:t.publicKey}function vb(s){return s==null?void 0:s.topic}function wb(s,t){let r=null;return wt(s==null?void 0:s.publicKey,!1)||(r=V("MISSING_OR_INVALID",`${t} controller public key should be a string`)),r}function Mh(s){let t=!0;return Nr(s)?s.length&&(t=s.every(r=>wt(r,!1))):t=!1,t}function bb(s,t,r){let n=null;return Nr(t)&&t.length?t.forEach(a=>{n||Tn(a)||(n=Fe("UNSUPPORTED_CHAINS",`${r}, chain ${a} should be a string and conform to "namespace:chainId" format`))}):Tn(s)||(n=Fe("UNSUPPORTED_CHAINS",`${r}, 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"] }`)),n}function _b(s,t,r){let n=null;return Object.entries(s).forEach(([a,u])=>{if(n)return;const f=bb(a,Vl(a,u),`${t} ${r}`);f&&(n=f)}),n}function Eb(s,t){let r=null;return Nr(s)?s.forEach(n=>{r||gb(n)||(r=Fe("UNSUPPORTED_ACCOUNTS",`${t}, account ${n} should be a string and conform to "namespace:chainId:address" format`))}):r=Fe("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function Ib(s,t){let r=null;return Object.values(s).forEach(n=>{if(r)return;const a=Eb(n==null?void 0:n.accounts,`${t} namespace`);a&&(r=a)}),r}function xb(s,t){let r=null;return Mh(s==null?void 0:s.methods)?Mh(s==null?void 0:s.events)||(r=Fe("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):r=Fe("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),r}function Zl(s,t){let r=null;return Object.values(s).forEach(n=>{if(r)return;const a=xb(n,`${t}, namespace`);a&&(r=a)}),r}function Sb(s,t,r){let n=null;if(s&&Ki(s)){const a=Zl(s,t);a&&(n=a);const u=_b(s,t,r);u&&(n=u)}else n=V("MISSING_OR_INVALID",`${t}, ${r} should be an object with data`);return n}function Nn(s,t){let r=null;if(s&&Ki(s)){const n=Zl(s,t);n&&(r=n);const a=Ib(s,t);a&&(r=a)}else r=V("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return r}function Xl(s){return wt(s.protocol,!0)}function Pb(s,t){let r=!1;return s?s&&Nr(s)&&s.length&&s.forEach(n=>{r=Xl(n)}):r=!0,r}function Ob(s){return typeof s=="number"}function Ht(s){return typeof s<"u"&&typeof s!==null}function Rb(s){return!(!s||typeof s!="object"||!s.code||!Ga(s.code)||!s.message||!wt(s.message,!1))}function Nb(s){return!(Kt(s)||!wt(s.method,!1))}function $b(s){return!(Kt(s)||Kt(s.result)&&Kt(s.error)||!Ga(s.id)||!wt(s.jsonrpc,!1))}function Cb(s){return!(Kt(s)||!wt(s.name,!1))}function Lh(s,t){return!(!Tn(t)||!cb(s).includes(t))}function Ab(s,t,r){return wt(r,!1)?ub(s,t).includes(r):!1}function Tb(s,t,r){return wt(r,!1)?hb(s,t).includes(r):!1}function Uh(s,t,r){let n=null;const a=Db(s),u=jb(t),f=Object.keys(a),y=Object.keys(u),m=zh(Object.keys(s)),g=zh(Object.keys(t)),w=m.filter(_=>!g.includes(_));return w.length&&(n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces. Required: ${w.toString()} Received: ${Object.keys(t).toString()}`)),yi(f,y)||(n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces. Required: ${f.toString()} Approved: ${y.toString()}`)),Object.keys(t).forEach(_=>{if(!_.includes(":")||n)return;const O=Bi(t[_].accounts);O.includes(_)||(n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${_} Required: ${_} Approved: ${O.toString()}`))}),f.forEach(_=>{n||(yi(a[_].methods,u[_].methods)?yi(a[_].events,u[_].events)||(n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${_}`)):n=V("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${_}`))}),n}function Db(s){const t={};return Object.keys(s).forEach(r=>{var n;r.includes(":")?t[r]=s[r]:(n=s[r].chains)==null||n.forEach(a=>{t[a]={methods:s[r].methods,events:s[r].events}})}),t}function zh(s){return[...new Set(s.map(t=>t.includes(":")?t.split(":")[0]:t))]}function jb(s){const t={};return Object.keys(s).forEach(r=>{if(r.includes(":"))t[r]=s[r];else{const n=Bi(s[r].accounts);n==null||n.forEach(a=>{t[a]={accounts:s[r].accounts.filter(u=>u.includes(`${a}:`)),methods:s[r].methods,events:s[r].events}})}}),t}function qb(s,t){return Ga(s)&&s<=t.max&&s>=t.min}function kh(){const s=Rs();return new Promise(t=>{switch(s){case Xt.browser:t(Mb());break;case Xt.reactNative:t(Lb());break;case Xt.node:t(Ub());break;default:t(!0)}})}function Mb(){return Fi()&&(navigator==null?void 0:navigator.onLine)}async function Lb(){if(Vi()&&typeof xe<"u"&&xe!=null&&xe.NetInfo){const s=await(xe==null?void 0:xe.NetInfo.fetch());return s==null?void 0:s.isConnected}return!0}function Ub(){return!0}function zb(s){switch(Rs()){case Xt.browser:kb(s);break;case Xt.reactNative:Hb(s);break}}function kb(s){!Vi()&&Fi()&&(window.addEventListener("online",()=>s(!0)),window.addEventListener("offline",()=>s(!1)))}function Hb(s){var t;Vi()&&typeof xe<"u"&&xe!=null&&xe.NetInfo&&((t=xe)==null||t.NetInfo.addEventListener(r=>s(r==null?void 0:r.isConnected)))}const na={};let _n=class{static get(t){return na[t]}static set(t,r){na[t]=r}static delete(t){delete na[t]}};const Kb=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,Vb=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,Fb=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function Bb(s,t){if(s==="__proto__"||s==="constructor"&&t&&typeof t=="object"&&"prototype"in t){Gb(s);return}return t}function Gb(s){console.warn(`[destr] Dropping "${s}" key to prevent prototype pollution.`)}function En(s,t={}){if(typeof s!="string")return s;const r=s.trim();if(s[0]==='"'&&s.endsWith('"')&&!s.includes("\\"))return r.slice(1,-1);if(r.length<=9){const n=r.toLowerCase();if(n==="true")return!0;if(n==="false")return!1;if(n==="undefined")return;if(n==="null")return null;if(n==="nan")return Number.NaN;if(n==="infinity")return Number.POSITIVE_INFINITY;if(n==="-infinity")return Number.NEGATIVE_INFINITY}if(!Fb.test(s)){if(t.strict)throw new SyntaxError("[destr] Invalid JSON");return s}try{if(Kb.test(s)||Vb.test(s)){if(t.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(s,Bb)}return JSON.parse(s)}catch(n){if(t.strict)throw n;return s}}function Wb(s){return!s||typeof s.then!="function"?Promise.resolve(s):s}function vt(s,...t){try{return Wb(s(...t))}catch(r){return Promise.reject(r)}}function Jb(s){const t=typeof s;return s===null||t!=="object"&&t!=="function"}function Qb(s){const t=Object.getPrototypeOf(s);return!t||t.isPrototypeOf(Object)}function $n(s){if(Jb(s))return String(s);if(Qb(s)||Array.isArray(s))return JSON.stringify(s);if(typeof s.toJSON=="function")return $n(s.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function ef(){if(typeof Ma===void 0)throw new TypeError("[unstorage] Buffer is not supported!")}const Sa="base64:";function Yb(s){if(typeof s=="string")return s;ef();const t=Ma.from(s).toString("base64");return Sa+t}function Zb(s){return typeof s!="string"||!s.startsWith(Sa)?s:(ef(),Ma.from(s.slice(Sa.length),"base64"))}function kt(s){return s?s.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function Xb(...s){return kt(s.join(":"))}function In(s){return s=kt(s),s?s+":":""}const e1="memory",t1=()=>{const s=new Map;return{name:e1,options:{},hasItem(t){return s.has(t)},getItem(t){return s.get(t)??null},getItemRaw(t){return s.get(t)??null},setItem(t,r){s.set(t,r)},setItemRaw(t,r){s.set(t,r)},removeItem(t){s.delete(t)},getKeys(){return Array.from(s.keys())},clear(){s.clear()},dispose(){s.clear()}}};function r1(s={}){const t={mounts:{"":s.driver||t1()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=g=>{for(const w of t.mountpoints)if(g.startsWith(w))return{base:w,relativeKey:g.slice(w.length),driver:t.mounts[w]};return{base:"",relativeKey:g,driver:t.mounts[""]}},n=(g,w)=>t.mountpoints.filter(_=>_.startsWith(g)||w&&g.startsWith(_)).map(_=>({relativeBase:g.length>_.length?g.slice(_.length):void 0,mountpoint:_,driver:t.mounts[_]})),a=(g,w)=>{if(t.watching){w=kt(w);for(const _ of t.watchListeners)_(g,w)}},u=async()=>{if(!t.watching){t.watching=!0;for(const g in t.mounts)t.unwatch[g]=await Hh(t.mounts[g],a,g)}},f=async()=>{if(t.watching){for(const g in t.unwatch)await t.unwatch[g]();t.unwatch={},t.watching=!1}},y=(g,w,_)=>{const O=new Map,j=N=>{let ee=O.get(N.base);return ee||(ee={driver:N.driver,base:N.base,items:[]},O.set(N.base,ee)),ee};for(const N of g){const ee=typeof N=="string",ne=kt(ee?N:N.key),oe=ee?void 0:N.value,P=ee||!N.options?w:{...w,...N.options},$=r(ne);j($).items.push({key:ne,value:oe,relativeKey:$.relativeKey,options:P})}return Promise.all([...O.values()].map(N=>_(N))).then(N=>N.flat())},m={hasItem(g,w={}){g=kt(g);const{relativeKey:_,driver:O}=r(g);return vt(O.hasItem,_,w)},getItem(g,w={}){g=kt(g);const{relativeKey:_,driver:O}=r(g);return vt(O.getItem,_,w).then(j=>En(j))},getItems(g,w){return y(g,w,_=>_.driver.getItems?vt(_.driver.getItems,_.items.map(O=>({key:O.relativeKey,options:O.options})),w).then(O=>O.map(j=>({key:Xb(_.base,j.key),value:En(j.value)}))):Promise.all(_.items.map(O=>vt(_.driver.getItem,O.relativeKey,O.options).then(j=>({key:O.key,value:En(j)})))))},getItemRaw(g,w={}){g=kt(g);const{relativeKey:_,driver:O}=r(g);return O.getItemRaw?vt(O.getItemRaw,_,w):vt(O.getItem,_,w).then(j=>Zb(j))},async setItem(g,w,_={}){if(w===void 0)return m.removeItem(g);g=kt(g);const{relativeKey:O,driver:j}=r(g);j.setItem&&(await vt(j.setItem,O,$n(w),_),j.watch||a("update",g))},async setItems(g,w){await y(g,w,async _=>{if(_.driver.setItems)return vt(_.driver.setItems,_.items.map(O=>({key:O.relativeKey,value:$n(O.value),options:O.options})),w);_.driver.setItem&&await Promise.all(_.items.map(O=>vt(_.driver.setItem,O.relativeKey,$n(O.value),O.options)))})},async setItemRaw(g,w,_={}){if(w===void 0)return m.removeItem(g,_);g=kt(g);const{relativeKey:O,driver:j}=r(g);if(j.setItemRaw)await vt(j.setItemRaw,O,w,_);else if(j.setItem)await vt(j.setItem,O,Yb(w),_);else return;j.watch||a("update",g)},async removeItem(g,w={}){typeof w=="boolean"&&(w={removeMeta:w}),g=kt(g);const{relativeKey:_,driver:O}=r(g);O.removeItem&&(await vt(O.removeItem,_,w),(w.removeMeta||w.removeMata)&&await vt(O.removeItem,_+"$",w),O.watch||a("remove",g))},async getMeta(g,w={}){typeof w=="boolean"&&(w={nativeOnly:w}),g=kt(g);const{relativeKey:_,driver:O}=r(g),j=Object.create(null);if(O.getMeta&&Object.assign(j,await vt(O.getMeta,_,w)),!w.nativeOnly){const N=await vt(O.getItem,_+"$",w).then(ee=>En(ee));N&&typeof N=="object"&&(typeof N.atime=="string"&&(N.atime=new Date(N.atime)),typeof N.mtime=="string"&&(N.mtime=new Date(N.mtime)),Object.assign(j,N))}return j},setMeta(g,w,_={}){return this.setItem(g+"$",w,_)},removeMeta(g,w={}){return this.removeItem(g+"$",w)},async getKeys(g,w={}){g=In(g);const _=n(g,!0);let O=[];const j=[];for(const N of _){const ne=(await vt(N.driver.getKeys,N.relativeBase,w)).map(oe=>N.mountpoint+kt(oe)).filter(oe=>!O.some(P=>oe.startsWith(P)));j.push(...ne),O=[N.mountpoint,...O.filter(oe=>!oe.startsWith(N.mountpoint))]}return g?j.filter(N=>N.startsWith(g)&&!N.endsWith("$")):j.filter(N=>!N.endsWith("$"))},async clear(g,w={}){g=In(g),await Promise.all(n(g,!1).map(async _=>{if(_.driver.clear)return vt(_.driver.clear,_.relativeBase,w);if(_.driver.removeItem){const O=await _.driver.getKeys(_.relativeBase||"",w);return Promise.all(O.map(j=>_.driver.removeItem(j,w)))}}))},async dispose(){await Promise.all(Object.values(t.mounts).map(g=>Kh(g)))},async watch(g){return await u(),t.watchListeners.push(g),async()=>{t.watchListeners=t.watchListeners.filter(w=>w!==g),t.watchListeners.length===0&&await f()}},async unwatch(){t.watchListeners=[],await f()},mount(g,w){if(g=In(g),g&&t.mounts[g])throw new Error(`already mounted at ${g}`);return g&&(t.mountpoints.push(g),t.mountpoints.sort((_,O)=>O.length-_.length)),t.mounts[g]=w,t.watching&&Promise.resolve(Hh(w,a,g)).then(_=>{t.unwatch[g]=_}).catch(console.error),m},async unmount(g,w=!0){g=In(g),!(!g||!t.mounts[g])&&(t.watching&&g in t.unwatch&&(t.unwatch[g](),delete t.unwatch[g]),w&&await Kh(t.mounts[g]),t.mountpoints=t.mountpoints.filter(_=>_!==g),delete t.mounts[g])},getMount(g=""){g=kt(g)+":";const w=r(g);return{driver:w.driver,base:w.base}},getMounts(g="",w={}){return g=kt(g),n(g,w.parents).map(O=>({driver:O.driver,base:O.mountpoint}))}};return m}function Hh(s,t,r){return s.watch?s.watch((n,a)=>t(n,r+a)):()=>{}}async function Kh(s){typeof s.dispose=="function"&&await vt(s.dispose)}function vi(s){return new Promise((t,r)=>{s.oncomplete=s.onsuccess=()=>t(s.result),s.onabort=s.onerror=()=>r(s.error)})}function tf(s,t){const r=indexedDB.open(s);r.onupgradeneeded=()=>r.result.createObjectStore(t);const n=vi(r);return(a,u)=>n.then(f=>u(f.transaction(t,a).objectStore(t)))}let oa;function Ns(){return oa||(oa=tf("keyval-store","keyval")),oa}function Vh(s,t=Ns()){return t("readonly",r=>vi(r.get(s)))}function i1(s,t,r=Ns()){return r("readwrite",n=>(n.put(t,s),vi(n.transaction)))}function s1(s,t=Ns()){return t("readwrite",r=>(r.delete(s),vi(r.transaction)))}function n1(s=Ns()){return s("readwrite",t=>(t.clear(),vi(t.transaction)))}function o1(s,t){return s.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},vi(s.transaction)}function a1(s=Ns()){return s("readonly",t=>{if(t.getAllKeys)return vi(t.getAllKeys());const r=[];return o1(t,n=>r.push(n.key)).then(()=>r)})}const c1="idb-keyval";var u1=(s={})=>{const t=s.base&&s.base.length>0?`${s.base}:`:"",r=a=>t+a;let n;return s.dbName&&s.storeName&&(n=tf(s.dbName,s.storeName)),{name:c1,options:s,async hasItem(a){return!(typeof await Vh(r(a),n)>"u")},async getItem(a){return await Vh(r(a),n)??null},setItem(a,u){return i1(r(a),u,n)},removeItem(a){return s1(r(a),n)},getKeys(){return a1(n)},clear(){return n1(n)}}};const h1="WALLET_CONNECT_V2_INDEXED_DB",l1="keyvaluestorage";let f1=class{constructor(){this.indexedDb=r1({driver:u1({dbName:h1,storeName:l1})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(t=>[t.key,t.value])}async getItem(t){const r=await this.indexedDb.getItem(t);if(r!==null)return r}async setItem(t,r){await this.indexedDb.setItem(t,Ps(r))}async removeItem(t){await this.indexedDb.removeItem(t)}};var aa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof xe<"u"?xe:typeof self<"u"?self:{},Cn={exports:{}};(function(){let s;function t(){}s=t,s.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},s.prototype.setItem=function(r,n){this[r]=String(n)},s.prototype.removeItem=function(r){delete this[r]},s.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(n){r[n]=void 0,delete r[n]})},s.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},s.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof aa<"u"&&aa.localStorage?Cn.exports=aa.localStorage:typeof window<"u"&&window.localStorage?Cn.exports=window.localStorage:Cn.exports=new t})();function p1(s){var t;return[s[0],Mn((t=s[1])!=null?t:"")]}class d1{constructor(){this.localStorage=Cn.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(p1)}async getItem(t){const r=this.localStorage.getItem(t);if(r!==null)return Mn(r)}async setItem(t,r){this.localStorage.setItem(t,Ps(r))}async removeItem(t){this.localStorage.removeItem(t)}}const g1="wc_storage_version",Fh=1,y1=async(s,t,r)=>{const n=g1,a=await t.getItem(n);if(a&&a>=Fh){r(t);return}const u=await s.getKeys();if(!u.length){r(t);return}const f=[];for(;u.length;){const y=u.shift();if(!y)continue;const m=y.toLowerCase();if(m.includes("wc@")||m.includes("walletconnect")||m.includes("wc_")||m.includes("wallet_connect")){const g=await s.getItem(y);await t.setItem(y,g),f.push(y)}}await t.setItem(n,Fh),r(t),m1(s,f)},m1=async(s,t)=>{t.length&&t.forEach(async r=>{await s.removeItem(r)})};let v1=class{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0};const t=new d1;this.storage=t;try{const r=new f1;y1(t,r,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(t){return await this.initialize(),this.storage.getItem(t)}async setItem(t,r){return await this.initialize(),this.storage.setItem(t,r)}async removeItem(t){return await this.initialize(),this.storage.removeItem(t)}async initialize(){this.initialized||await new Promise(t=>{const r=setInterval(()=>{this.initialized&&(clearInterval(r),t())},20)})}};var Gi={};/*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */var Pa=function(s,t){return Pa=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n}||function(r,n){for(var a in n)n.hasOwnProperty(a)&&(r[a]=n[a])},Pa(s,t)};function w1(s,t){Pa(s,t);function r(){this.constructor=s}s.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r)}var Oa=function(){return Oa=Object.assign||function(t){for(var r,n=1,a=arguments.length;n<a;n++){r=arguments[n];for(var u in r)Object.prototype.hasOwnProperty.call(r,u)&&(t[u]=r[u])}return t},Oa.apply(this,arguments)};function b1(s,t){var r={};for(var n in s)Object.prototype.hasOwnProperty.call(s,n)&&t.indexOf(n)<0&&(r[n]=s[n]);if(s!=null&&typeof Object.getOwnPropertySymbols=="function")for(var a=0,n=Object.getOwnPropertySymbols(s);a<n.length;a++)t.indexOf(n[a])<0&&Object.prototype.propertyIsEnumerable.call(s,n[a])&&(r[n[a]]=s[n[a]]);return r}function _1(s,t,r,n){var a=arguments.length,u=a<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,r):n,f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")u=Reflect.decorate(s,t,r,n);else for(var y=s.length-1;y>=0;y--)(f=s[y])&&(u=(a<3?f(u):a>3?f(t,r,u):f(t,r))||u);return a>3&&u&&Object.defineProperty(t,r,u),u}function E1(s,t){return function(r,n){t(r,n,s)}}function I1(s,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(s,t)}function x1(s,t,r,n){function a(u){return u instanceof r?u:new r(function(f){f(u)})}return new(r||(r=Promise))(function(u,f){function y(w){try{g(n.next(w))}catch(_){f(_)}}function m(w){try{g(n.throw(w))}catch(_){f(_)}}function g(w){w.done?u(w.value):a(w.value).then(y,m)}g((n=n.apply(s,t||[])).next())})}function S1(s,t){var r={label:0,sent:function(){if(u[0]&1)throw u[1];return u[1]},trys:[],ops:[]},n,a,u,f;return f={next:y(0),throw:y(1),return:y(2)},typeof Symbol=="function"&&(f[Symbol.iterator]=function(){return this}),f;function y(g){return function(w){return m([g,w])}}function m(g){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,a&&(u=g[0]&2?a.return:g[0]?a.throw||((u=a.return)&&u.call(a),0):a.next)&&!(u=u.call(a,g[1])).done)return u;switch(a=0,u&&(g=[g[0]&2,u.value]),g[0]){case 0:case 1:u=g;break;case 4:return r.label++,{value:g[1],done:!1};case 5:r.label++,a=g[1],g=[0];continue;case 7:g=r.ops.pop(),r.trys.pop();continue;default:if(u=r.trys,!(u=u.length>0&&u[u.length-1])&&(g[0]===6||g[0]===2)){r=0;continue}if(g[0]===3&&(!u||g[1]>u[0]&&g[1]<u[3])){r.label=g[1];break}if(g[0]===6&&r.label<u[1]){r.label=u[1],u=g;break}if(u&&r.label<u[2]){r.label=u[2],r.ops.push(g);break}u[2]&&r.ops.pop(),r.trys.pop();continue}g=t.call(s,r)}catch(w){g=[6,w],a=0}finally{n=u=0}if(g[0]&5)throw g[1];return{value:g[0]?g[1]:void 0,done:!0}}}function P1(s,t,r,n){n===void 0&&(n=r),s[n]=t[r]}function O1(s,t){for(var r in s)r!=="default"&&!t.hasOwnProperty(r)&&(t[r]=s[r])}function Ra(s){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&s[t],n=0;if(r)return r.call(s);if(s&&typeof s.length=="number")return{next:function(){return s&&n>=s.length&&(s=void 0),{value:s&&s[n++],done:!s}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function rf(s,t){var r=typeof Symbol=="function"&&s[Symbol.iterator];if(!r)return s;var n=r.call(s),a,u=[],f;try{for(;(t===void 0||t-- >0)&&!(a=n.next()).done;)u.push(a.value)}catch(y){f={error:y}}finally{try{a&&!a.done&&(r=n.return)&&r.call(n)}finally{if(f)throw f.error}}return u}function R1(){for(var s=[],t=0;t<arguments.length;t++)s=s.concat(rf(arguments[t]));return s}function N1(){for(var s=0,t=0,r=arguments.length;t<r;t++)s+=arguments[t].length;for(var n=Array(s),a=0,t=0;t<r;t++)for(var u=arguments[t],f=0,y=u.length;f<y;f++,a++)n[a]=u[f];return n}function Is(s){return this instanceof Is?(this.v=s,this):new Is(s)}function $1(s,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(s,t||[]),a,u=[];return a={},f("next"),f("throw"),f("return"),a[Symbol.asyncIterator]=function(){return this},a;function f(O){n[O]&&(a[O]=function(j){return new Promise(function(N,ee){u.push([O,j,N,ee])>1||y(O,j)})})}function y(O,j){try{m(n[O](j))}catch(N){_(u[0][3],N)}}function m(O){O.value instanceof Is?Promise.resolve(O.value.v).then(g,w):_(u[0][2],O)}function g(O){y("next",O)}function w(O){y("throw",O)}function _(O,j){O(j),u.shift(),u.length&&y(u[0][0],u[0][1])}}function C1(s){var t,r;return t={},n("next"),n("throw",function(a){throw a}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(a,u){t[a]=s[a]?function(f){return(r=!r)?{value:Is(s[a](f)),done:a==="return"}:u?u(f):f}:u}}function A1(s){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=s[Symbol.asyncIterator],r;return t?t.call(s):(s=typeof Ra=="function"?Ra(s):s[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(u){r[u]=s[u]&&function(f){return new Promise(function(y,m){f=s[u](f),a(y,m,f.done,f.value)})}}function a(u,f,y,m){Promise.resolve(m).then(function(g){u({value:g,done:y})},f)}}function T1(s,t){return Object.defineProperty?Object.defineProperty(s,"raw",{value:t}):s.raw=t,s}function D1(s){if(s&&s.__esModule)return s;var t={};if(s!=null)for(var r in s)Object.hasOwnProperty.call(s,r)&&(t[r]=s[r]);return t.default=s,t}function j1(s){return s&&s.__esModule?s:{default:s}}function q1(s,t){if(!t.has(s))throw new TypeError("attempted to get private field on non-instance");return t.get(s)}function M1(s,t,r){if(!t.has(s))throw new TypeError("attempted to set private field on non-instance");return t.set(s,r),r}const L1=Object.freeze(Object.defineProperty({__proto__:null,get __assign(){return Oa},__asyncDelegator:C1,__asyncGenerator:$1,__asyncValues:A1,__await:Is,__awaiter:x1,__classPrivateFieldGet:q1,__classPrivateFieldSet:M1,__createBinding:P1,__decorate:_1,__exportStar:O1,__extends:w1,__generator:S1,__importDefault:j1,__importStar:D1,__makeTemplateObject:T1,__metadata:I1,__param:E1,__read:rf,__rest:b1,__spread:R1,__spreadArrays:N1,__values:Ra},Symbol.toStringTag,{value:"Module"})),Un=Ll(L1);var ls={},ca={},fs={};class wi{}const U1=Object.freeze(Object.defineProperty({__proto__:null,IEvents:wi},Symbol.toStringTag,{value:"Module"})),z1=Ll(U1);var Bh;function k1(){if(Bh)return fs;Bh=1,Object.defineProperty(fs,"__esModule",{value:!0}),fs.IHeartBeat=void 0;const s=z1;class t extends s.IEvents{constructor(n){super()}}return fs.IHeartBeat=t,fs}var Gh;function sf(){return Gh||(Gh=1,function(s){Object.defineProperty(s,"__esModule",{value:!0}),Un.__exportStar(k1(),s)}(ca)),ca}var ua={},gi={},Wh;function H1(){if(Wh)return gi;Wh=1,Object.defineProperty(gi,"__esModule",{value:!0}),gi.HEARTBEAT_EVENTS=gi.HEARTBEAT_INTERVAL=void 0;const s=X;return gi.HEARTBEAT_INTERVAL=s.FIVE_SECONDS,gi.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},gi}var Jh;function nf(){return Jh||(Jh=1,function(s){Object.defineProperty(s,"__esModule",{value:!0}),Un.__exportStar(H1(),s)}(ua)),ua}var Qh;function K1(){if(Qh)return ls;Qh=1,Object.defineProperty(ls,"__esModule",{value:!0}),ls.HeartBeat=void 0;const s=Un,t=br,r=X,n=sf(),a=nf();class u extends n.IHeartBeat{constructor(y){super(y),this.events=new t.EventEmitter,this.interval=a.HEARTBEAT_INTERVAL,this.interval=(y==null?void 0:y.interval)||a.HEARTBEAT_INTERVAL}static init(y){return s.__awaiter(this,void 0,void 0,function*(){const m=new u(y);return yield m.init(),m})}init(){return s.__awaiter(this,void 0,void 0,function*(){yield this.initialize()})}stop(){clearInterval(this.intervalRef)}on(y,m){this.events.on(y,m)}once(y,m){this.events.once(y,m)}off(y,m){this.events.off(y,m)}removeListener(y,m){this.events.removeListener(y,m)}initialize(){return s.__awaiter(this,void 0,void 0,function*(){this.intervalRef=setInterval(()=>this.pulse(),r.toMiliseconds(this.interval))})}pulse(){this.events.emit(a.HEARTBEAT_EVENTS.pulse)}}return ls.HeartBeat=u,ls}(function(s){Object.defineProperty(s,"__esModule",{value:!0});const t=Un;t.__exportStar(K1(),s),t.__exportStar(sf(),s),t.__exportStar(nf(),s)})(Gi);function V1(s){try{return JSON.stringify(s)}catch{return'"[Circular]"'}}var F1=B1;function B1(s,t,r){var n=r&&r.stringify||V1,a=1;if(typeof s=="object"&&s!==null){var u=t.length+a;if(u===1)return s;var f=new Array(u);f[0]=n(s);for(var y=1;y<u;y++)f[y]=n(t[y]);return f.join(" ")}if(typeof s!="string")return s;var m=t.length;if(m===0)return s;for(var g="",w=1-a,_=-1,O=s&&s.length||0,j=0;j<O;){if(s.charCodeAt(j)===37&&j+1<O){switch(_=_>-1?_:0,s.charCodeAt(j+1)){case 100:case 102:if(w>=m||t[w]==null)break;_<j&&(g+=s.slice(_,j)),g+=Number(t[w]),_=j+2,j++;break;case 105:if(w>=m||t[w]==null)break;_<j&&(g+=s.slice(_,j)),g+=Math.floor(Number(t[w])),_=j+2,j++;break;case 79:case 111:case 106:if(w>=m||t[w]===void 0)break;_<j&&(g+=s.slice(_,j));var N=typeof t[w];if(N==="string"){g+="'"+t[w]+"'",_=j+2,j++;break}if(N==="function"){g+=t[w].name||"<anonymous>",_=j+2,j++;break}g+=n(t[w]),_=j+2,j++;break;case 115:if(w>=m)break;_<j&&(g+=s.slice(_,j)),g+=String(t[w]),_=j+2,j++;break;case 37:_<j&&(g+=s.slice(_,j)),g+="%",_=j+2,j++,w--;break}++w}++j}return _===-1?s:(_<O&&(g+=s.slice(_)),g)}const Yh=F1;var G1=Rr;const xs=i_().console||{},W1={mapHttpRequest:xn,mapHttpResponse:xn,wrapRequestSerializer:ha,wrapResponseSerializer:ha,wrapErrorSerializer:ha,req:xn,res:xn,err:X1};function J1(s,t){return Array.isArray(s)?s.filter(function(n){return n!=="!stdSerializers.err"}):s===!0?Object.keys(t):!1}function Rr(s){s=s||{},s.browser=s.browser||{};const t=s.browser.transmit;if(t&&typeof t.send!="function")throw Error("pino: transmit option must have a send function");const r=s.browser.write||xs;s.browser.write&&(s.browser.asObject=!0);const n=s.serializers||{},a=J1(s.browser.serialize,n);let u=s.browser.serialize;Array.isArray(s.browser.serialize)&&s.browser.serialize.indexOf("!stdSerializers.err")>-1&&(u=!1);const f=["error","fatal","warn","info","debug","trace"];typeof r=="function"&&(r.error=r.fatal=r.warn=r.info=r.debug=r.trace=r),s.enabled===!1&&(s.level="silent");const y=s.level||"info",m=Object.create(r);m.log||(m.log=Ss),Object.defineProperty(m,"levelVal",{get:w}),Object.defineProperty(m,"level",{get:_,set:O});const g={transmit:t,serialize:a,asObject:s.browser.asObject,levels:f,timestamp:e_(s)};m.levels=Rr.levels,m.level=y,m.setMaxListeners=m.getMaxListeners=m.emit=m.addListener=m.on=m.prependListener=m.once=m.prependOnceListener=m.removeListener=m.removeAllListeners=m.listeners=m.listenerCount=m.eventNames=m.write=m.flush=Ss,m.serializers=n,m._serialize=a,m._stdErrSerialize=u,m.child=j,t&&(m._logEvent=Na());function w(){return this.level==="silent"?1/0:this.levels.values[this.level]}function _(){return this._level}function O(N){if(N!=="silent"&&!this.levels.values[N])throw Error("unknown level "+N);this._level=N,Mi(g,m,"error","log"),Mi(g,m,"fatal","error"),Mi(g,m,"warn","error"),Mi(g,m,"info","log"),Mi(g,m,"debug","log"),Mi(g,m,"trace","log")}function j(N,ee){if(!N)throw new Error("missing bindings for child Pino");ee=ee||{},a&&N.serializers&&(ee.serializers=N.serializers);const ne=ee.serializers;if(a&&ne){var oe=Object.assign({},n,ne),P=s.browser.serialize===!0?Object.keys(oe):a;delete N.serializers,zn([N],P,oe,this._stdErrSerialize)}function $(C){this._childLevel=(C._childLevel|0)+1,this.error=Li(C,N,"error"),this.fatal=Li(C,N,"fatal"),this.warn=Li(C,N,"warn"),this.info=Li(C,N,"info"),this.debug=Li(C,N,"debug"),this.trace=Li(C,N,"trace"),oe&&(this.serializers=oe,this._serialize=P),t&&(this._logEvent=Na([].concat(C._logEvent.bindings,N)))}return $.prototype=this,new $(this)}return m}Rr.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}};Rr.stdSerializers=W1;Rr.stdTimeFunctions=Object.assign({},{nullTime:of,epochTime:af,unixTime:t_,isoTime:r_});function Mi(s,t,r,n){const a=Object.getPrototypeOf(t);t[r]=t.levelVal>t.levels.values[r]?Ss:a[r]?a[r]:xs[r]||xs[n]||Ss,Q1(s,t,r)}function Q1(s,t,r){!s.transmit&&t[r]===Ss||(t[r]=function(n){return function(){const u=s.timestamp(),f=new Array(arguments.length),y=Object.getPrototypeOf&&Object.getPrototypeOf(this)===xs?xs:this;for(var m=0;m<f.length;m++)f[m]=arguments[m];if(s.serialize&&!s.asObject&&zn(f,this._serialize,this.serializers,this._stdErrSerialize),s.asObject?n.call(y,Y1(this,r,f,u)):n.apply(y,f),s.transmit){const g=s.transmit.level||t.level,w=Rr.levels.values[g],_=Rr.levels.values[r];if(_<w)return;Z1(this,{ts:u,methodLevel:r,methodValue:_,transmitLevel:g,transmitValue:Rr.levels.values[s.transmit.level||t.level],send:s.transmit.send,val:t.levelVal},f)}}}(t[r]))}function Y1(s,t,r,n){s._serialize&&zn(r,s._serialize,s.serializers,s._stdErrSerialize);const a=r.slice();let u=a[0];const f={};n&&(f.time=n),f.level=Rr.levels.values[t];let y=(s._childLevel|0)+1;if(y<1&&(y=1),u!==null&&typeof u=="object"){for(;y--&&typeof a[0]=="object";)Object.assign(f,a.shift());u=a.length?Yh(a.shift(),a):void 0}else typeof u=="string"&&(u=Yh(a.shift(),a));return u!==void 0&&(f.msg=u),f}function zn(s,t,r,n){for(const a in s)if(n&&s[a]instanceof Error)s[a]=Rr.stdSerializers.err(s[a]);else if(typeof s[a]=="object"&&!Array.isArray(s[a]))for(const u in s[a])t&&t.indexOf(u)>-1&&u in r&&(s[a][u]=r[u](s[a][u]))}function Li(s,t,r){return function(){const n=new Array(1+arguments.length);n[0]=t;for(var a=1;a<n.length;a++)n[a]=arguments[a-1];return s[r].apply(this,n)}}function Z1(s,t,r){const n=t.send,a=t.ts,u=t.methodLevel,f=t.methodValue,y=t.val,m=s._logEvent.bindings;zn(r,s._serialize||Object.keys(s.serializers),s.serializers,s._stdErrSerialize===void 0?!0:s._stdErrSerialize),s._logEvent.ts=a,s._logEvent.messages=r.filter(function(g){return m.indexOf(g)===-1}),s._logEvent.level.label=u,s._logEvent.level.value=f,n(u,s._logEvent,y),s._logEvent=Na(m)}function Na(s){return{ts:0,messages:[],bindings:s||[],level:{label:"",value:0}}}function X1(s){const t={type:s.constructor.name,msg:s.message,stack:s.stack};for(const r in s)t[r]===void 0&&(t[r]=s[r]);return t}function e_(s){return typeof s.timestamp=="function"?s.timestamp:s.timestamp===!1?of:af}function xn(){return{}}function ha(s){return s}function Ss(){}function of(){return!1}function af(){return Date.now()}function t_(){return Math.round(Date.now()/1e3)}function r_(){return new Date(Date.now()).toISOString()}function i_(){function s(t){return typeof t<"u"&&t}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return s(self)||s(window)||s(this)||{}}}const kn=dw(G1),s_={level:"info"},$s="custom_context";var n_=Object.defineProperty,o_=Object.defineProperties,a_=Object.getOwnPropertyDescriptors,Zh=Object.getOwnPropertySymbols,c_=Object.prototype.hasOwnProperty,u_=Object.prototype.propertyIsEnumerable,Xh=(s,t,r)=>t in s?n_(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,h_=(s,t)=>{for(var r in t||(t={}))c_.call(t,r)&&Xh(s,r,t[r]);if(Zh)for(var r of Zh(t))u_.call(t,r)&&Xh(s,r,t[r]);return s},l_=(s,t)=>o_(s,a_(t));function Hn(s){return l_(h_({},s),{level:(s==null?void 0:s.level)||s_.level})}function f_(s,t=$s){return s[t]||""}function p_(s,t,r=$s){return s[r]=t,s}function Ft(s,t=$s){let r="";return typeof s.bindings>"u"?r=f_(s,t):r=s.bindings().context||"",r}function d_(s,t,r=$s){const n=Ft(s,r);return n.trim()?`${n}/${t}`:t}function er(s,t,r=$s){const n=d_(s,t,r),a=s.child({context:n});return p_(a,n,r)}class g_ extends wi{constructor(t){super(),this.opts=t,this.protocol="wc",this.version=2}}let y_=class extends wi{constructor(t,r){super(),this.core=t,this.logger=r,this.records=new Map}},m_=class{constructor(t,r){this.logger=t,this.core=r}},v_=class extends wi{constructor(t,r){super(),this.relayer=t,this.logger=r}},w_=class extends wi{constructor(t){super()}},b_=class{constructor(t,r,n,a){this.core=t,this.logger=r,this.name=n}};class __ extends wi{constructor(t,r){super(),this.relayer=t,this.logger=r}}let E_=class extends wi{constructor(t,r){super(),this.core=t,this.logger=r}},I_=class{constructor(t,r){this.projectId=t,this.logger=r}},x_=class{constructor(t){this.opts=t,this.protocol="wc",this.version=2}},S_=class{constructor(t){this.client=t}};var Wa={},cf={};(function(s){Object.defineProperty(s,"__esModule",{value:!0});var t=gw,r=Ul;s.DIGEST_LENGTH=64,s.BLOCK_SIZE=128;var n=function(){function y(){this.digestLength=s.DIGEST_LENGTH,this.blockSize=s.BLOCK_SIZE,this._stateHi=new Int32Array(8),this._stateLo=new Int32Array(8),this._tempHi=new Int32Array(16),this._tempLo=new Int32Array(16),this._buffer=new Uint8Array(256),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return y.prototype._initState=function(){this._stateHi[0]=1779033703,this._stateHi[1]=3144134277,this._stateHi[2]=1013904242,this._stateHi[3]=2773480762,this._stateHi[4]=1359893119,this._stateHi[5]=2600822924,this._stateHi[6]=528734635,this._stateHi[7]=1541459225,this._stateLo[0]=4089235720,this._stateLo[1]=2227873595,this._stateLo[2]=4271175723,this._stateLo[3]=1595750129,this._stateLo[4]=2917565137,this._stateLo[5]=725511199,this._stateLo[6]=4215389547,this._stateLo[7]=327033209},y.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},y.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},y.prototype.update=function(m,g){if(g===void 0&&(g=m.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var w=0;if(this._bytesHashed+=g,this._bufferLength>0){for(;this._bufferLength<s.BLOCK_SIZE&&g>0;)this._buffer[this._bufferLength++]=m[w++],g--;this._bufferLength===this.blockSize&&(u(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(g>=this.blockSize&&(w=u(this._tempHi,this._tempLo,this._stateHi,this._stateLo,m,w,g),g%=this.blockSize);g>0;)this._buffer[this._bufferLength++]=m[w++],g--;return this},y.prototype.finish=function(m){if(!this._finished){var g=this._bytesHashed,w=this._bufferLength,_=g/536870912|0,O=g<<3,j=g%128<112?128:256;this._buffer[w]=128;for(var N=w+1;N<j-8;N++)this._buffer[N]=0;t.writeUint32BE(_,this._buffer,j-8),t.writeUint32BE(O,this._buffer,j-4),u(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,j),this._finished=!0}for(var N=0;N<this.digestLength/8;N++)t.writeUint32BE(this._stateHi[N],m,N*8),t.writeUint32BE(this._stateLo[N],m,N*8+4);return this},y.prototype.digest=function(){var m=new Uint8Array(this.digestLength);return this.finish(m),m},y.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{stateHi:new Int32Array(this._stateHi),stateLo:new Int32Array(this._stateLo),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},y.prototype.restoreState=function(m){return this._stateHi.set(m.stateHi),this._stateLo.set(m.stateLo),this._bufferLength=m.bufferLength,m.buffer&&this._buffer.set(m.buffer),this._bytesHashed=m.bytesHashed,this._finished=!1,this},y.prototype.cleanSavedState=function(m){r.wipe(m.stateHi),r.wipe(m.stateLo),m.buffer&&r.wipe(m.buffer),m.bufferLength=0,m.bytesHashed=0},y}();s.SHA512=n;var a=new Int32Array([1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591]);function u(y,m,g,w,_,O,j){for(var N=g[0],ee=g[1],ne=g[2],oe=g[3],P=g[4],$=g[5],C=g[6],q=g[7],z=w[0],K=w[1],W=w[2],we=w[3],tt=w[4],lr=w[5],_r=w[6],fr=w[7],k,H,Ue,$e,Y,G,B,J;j>=128;){for(var bt=0;bt<16;bt++){var Be=8*bt+O;y[bt]=t.readUint32BE(_,Be),m[bt]=t.readUint32BE(_,Be+4)}for(var bt=0;bt<80;bt++){var Wi=N,Er=ee,Kr=ne,A=oe,T=P,S=$,h=C,E=q,te=z,ce=K,pe=W,be=we,Ee=tt,me=lr,rt=_r,Qe=fr;if(k=q,H=fr,Y=H&65535,G=H>>>16,B=k&65535,J=k>>>16,k=(P>>>14|tt<<18)^(P>>>18|tt<<14)^(tt>>>9|P<<23),H=(tt>>>14|P<<18)^(tt>>>18|P<<14)^(P>>>9|tt<<23),Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,k=P&$^~P&C,H=tt&lr^~tt&_r,Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,k=a[bt*2],H=a[bt*2+1],Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,k=y[bt%16],H=m[bt%16],Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,G+=Y>>>16,B+=G>>>16,J+=B>>>16,Ue=B&65535|J<<16,$e=Y&65535|G<<16,k=Ue,H=$e,Y=H&65535,G=H>>>16,B=k&65535,J=k>>>16,k=(N>>>28|z<<4)^(z>>>2|N<<30)^(z>>>7|N<<25),H=(z>>>28|N<<4)^(N>>>2|z<<30)^(N>>>7|z<<25),Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,k=N&ee^N&ne^ee&ne,H=z&K^z&W^K&W,Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,G+=Y>>>16,B+=G>>>16,J+=B>>>16,E=B&65535|J<<16,Qe=Y&65535|G<<16,k=A,H=be,Y=H&65535,G=H>>>16,B=k&65535,J=k>>>16,k=Ue,H=$e,Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,G+=Y>>>16,B+=G>>>16,J+=B>>>16,A=B&65535|J<<16,be=Y&65535|G<<16,ee=Wi,ne=Er,oe=Kr,P=A,$=T,C=S,q=h,N=E,K=te,W=ce,we=pe,tt=be,lr=Ee,_r=me,fr=rt,z=Qe,bt%16===15)for(var Be=0;Be<16;Be++)k=y[Be],H=m[Be],Y=H&65535,G=H>>>16,B=k&65535,J=k>>>16,k=y[(Be+9)%16],H=m[(Be+9)%16],Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,Ue=y[(Be+1)%16],$e=m[(Be+1)%16],k=(Ue>>>1|$e<<31)^(Ue>>>8|$e<<24)^Ue>>>7,H=($e>>>1|Ue<<31)^($e>>>8|Ue<<24)^($e>>>7|Ue<<25),Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,Ue=y[(Be+14)%16],$e=m[(Be+14)%16],k=(Ue>>>19|$e<<13)^($e>>>29|Ue<<3)^Ue>>>6,H=($e>>>19|Ue<<13)^(Ue>>>29|$e<<3)^($e>>>6|Ue<<26),Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,G+=Y>>>16,B+=G>>>16,J+=B>>>16,y[Be]=B&65535|J<<16,m[Be]=Y&65535|G<<16}k=N,H=z,Y=H&65535,G=H>>>16,B=k&65535,J=k>>>16,k=g[0],H=w[0],Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,G+=Y>>>16,B+=G>>>16,J+=B>>>16,g[0]=N=B&65535|J<<16,w[0]=z=Y&65535|G<<16,k=ee,H=K,Y=H&65535,G=H>>>16,B=k&65535,J=k>>>16,k=g[1],H=w[1],Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,G+=Y>>>16,B+=G>>>16,J+=B>>>16,g[1]=ee=B&65535|J<<16,w[1]=K=Y&65535|G<<16,k=ne,H=W,Y=H&65535,G=H>>>16,B=k&65535,J=k>>>16,k=g[2],H=w[2],Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,G+=Y>>>16,B+=G>>>16,J+=B>>>16,g[2]=ne=B&65535|J<<16,w[2]=W=Y&65535|G<<16,k=oe,H=we,Y=H&65535,G=H>>>16,B=k&65535,J=k>>>16,k=g[3],H=w[3],Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,G+=Y>>>16,B+=G>>>16,J+=B>>>16,g[3]=oe=B&65535|J<<16,w[3]=we=Y&65535|G<<16,k=P,H=tt,Y=H&65535,G=H>>>16,B=k&65535,J=k>>>16,k=g[4],H=w[4],Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,G+=Y>>>16,B+=G>>>16,J+=B>>>16,g[4]=P=B&65535|J<<16,w[4]=tt=Y&65535|G<<16,k=$,H=lr,Y=H&65535,G=H>>>16,B=k&65535,J=k>>>16,k=g[5],H=w[5],Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,G+=Y>>>16,B+=G>>>16,J+=B>>>16,g[5]=$=B&65535|J<<16,w[5]=lr=Y&65535|G<<16,k=C,H=_r,Y=H&65535,G=H>>>16,B=k&65535,J=k>>>16,k=g[6],H=w[6],Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,G+=Y>>>16,B+=G>>>16,J+=B>>>16,g[6]=C=B&65535|J<<16,w[6]=_r=Y&65535|G<<16,k=q,H=fr,Y=H&65535,G=H>>>16,B=k&65535,J=k>>>16,k=g[7],H=w[7],Y+=H&65535,G+=H>>>16,B+=k&65535,J+=k>>>16,G+=Y>>>16,B+=G>>>16,J+=B>>>16,g[7]=q=B&65535|J<<16,w[7]=fr=Y&65535|G<<16,O+=128,j-=128}return O}function f(y){var m=new n;m.update(y);var g=m.digest();return m.clean(),g}s.hash=f})(cf);(function(s){Object.defineProperty(s,"__esModule",{value:!0}),s.convertSecretKeyToX25519=s.convertPublicKeyToX25519=s.verify=s.sign=s.extractPublicKeyFromSecretKey=s.generateKeyPair=s.generateKeyPairFromSeed=s.SEED_LENGTH=s.SECRET_KEY_LENGTH=s.PUBLIC_KEY_LENGTH=s.SIGNATURE_LENGTH=void 0;const t=qn,r=cf,n=Ul;s.SIGNATURE_LENGTH=64,s.PUBLIC_KEY_LENGTH=32,s.SECRET_KEY_LENGTH=64,s.SEED_LENGTH=32;function a(A){const T=new Float64Array(16);if(A)for(let S=0;S<A.length;S++)T[S]=A[S];return T}const u=new Uint8Array(32);u[0]=9;const f=a(),y=a([1]),m=a([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),g=a([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),w=a([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),_=a([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),O=a([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function j(A,T){for(let S=0;S<16;S++)A[S]=T[S]|0}function N(A){let T=1;for(let S=0;S<16;S++){let h=A[S]+T+65535;T=Math.floor(h/65536),A[S]=h-T*65536}A[0]+=T-1+37*(T-1)}function ee(A,T,S){const h=~(S-1);for(let E=0;E<16;E++){const te=h&(A[E]^T[E]);A[E]^=te,T[E]^=te}}function ne(A,T){const S=a(),h=a();for(let E=0;E<16;E++)h[E]=T[E];N(h),N(h),N(h);for(let E=0;E<2;E++){S[0]=h[0]-65517;for(let ce=1;ce<15;ce++)S[ce]=h[ce]-65535-(S[ce-1]>>16&1),S[ce-1]&=65535;S[15]=h[15]-32767-(S[14]>>16&1);const te=S[15]>>16&1;S[14]&=65535,ee(h,S,1-te)}for(let E=0;E<16;E++)A[2*E]=h[E]&255,A[2*E+1]=h[E]>>8}function oe(A,T){let S=0;for(let h=0;h<32;h++)S|=A[h]^T[h];return(1&S-1>>>8)-1}function P(A,T){const S=new Uint8Array(32),h=new Uint8Array(32);return ne(S,A),ne(h,T),oe(S,h)}function $(A){const T=new Uint8Array(32);return ne(T,A),T[0]&1}function C(A,T){for(let S=0;S<16;S++)A[S]=T[2*S]+(T[2*S+1]<<8);A[15]&=32767}function q(A,T,S){for(let h=0;h<16;h++)A[h]=T[h]+S[h]}function z(A,T,S){for(let h=0;h<16;h++)A[h]=T[h]-S[h]}function K(A,T,S){let h,E,te=0,ce=0,pe=0,be=0,Ee=0,me=0,rt=0,Qe=0,ke=0,Se=0,De=0,je=0,He=0,Re=0,qe=0,Pe=0,Me=0,Ye=0,it=0,_t=0,St=0,Nt=0,jt=0,Bt=0,tr=0,pr=0,Vr=0,ni=0,_i=0,Ei=0,Ji=0,st=S[0],nt=S[1],ot=S[2],at=S[3],Ze=S[4],ct=S[5],ut=S[6],ht=S[7],Ge=S[8],lt=S[9],We=S[10],ft=S[11],pt=S[12],dt=S[13],gt=S[14],yt=S[15];h=T[0],te+=h*st,ce+=h*nt,pe+=h*ot,be+=h*at,Ee+=h*Ze,me+=h*ct,rt+=h*ut,Qe+=h*ht,ke+=h*Ge,Se+=h*lt,De+=h*We,je+=h*ft,He+=h*pt,Re+=h*dt,qe+=h*gt,Pe+=h*yt,h=T[1],ce+=h*st,pe+=h*nt,be+=h*ot,Ee+=h*at,me+=h*Ze,rt+=h*ct,Qe+=h*ut,ke+=h*ht,Se+=h*Ge,De+=h*lt,je+=h*We,He+=h*ft,Re+=h*pt,qe+=h*dt,Pe+=h*gt,Me+=h*yt,h=T[2],pe+=h*st,be+=h*nt,Ee+=h*ot,me+=h*at,rt+=h*Ze,Qe+=h*ct,ke+=h*ut,Se+=h*ht,De+=h*Ge,je+=h*lt,He+=h*We,Re+=h*ft,qe+=h*pt,Pe+=h*dt,Me+=h*gt,Ye+=h*yt,h=T[3],be+=h*st,Ee+=h*nt,me+=h*ot,rt+=h*at,Qe+=h*Ze,ke+=h*ct,Se+=h*ut,De+=h*ht,je+=h*Ge,He+=h*lt,Re+=h*We,qe+=h*ft,Pe+=h*pt,Me+=h*dt,Ye+=h*gt,it+=h*yt,h=T[4],Ee+=h*st,me+=h*nt,rt+=h*ot,Qe+=h*at,ke+=h*Ze,Se+=h*ct,De+=h*ut,je+=h*ht,He+=h*Ge,Re+=h*lt,qe+=h*We,Pe+=h*ft,Me+=h*pt,Ye+=h*dt,it+=h*gt,_t+=h*yt,h=T[5],me+=h*st,rt+=h*nt,Qe+=h*ot,ke+=h*at,Se+=h*Ze,De+=h*ct,je+=h*ut,He+=h*ht,Re+=h*Ge,qe+=h*lt,Pe+=h*We,Me+=h*ft,Ye+=h*pt,it+=h*dt,_t+=h*gt,St+=h*yt,h=T[6],rt+=h*st,Qe+=h*nt,ke+=h*ot,Se+=h*at,De+=h*Ze,je+=h*ct,He+=h*ut,Re+=h*ht,qe+=h*Ge,Pe+=h*lt,Me+=h*We,Ye+=h*ft,it+=h*pt,_t+=h*dt,St+=h*gt,Nt+=h*yt,h=T[7],Qe+=h*st,ke+=h*nt,Se+=h*ot,De+=h*at,je+=h*Ze,He+=h*ct,Re+=h*ut,qe+=h*ht,Pe+=h*Ge,Me+=h*lt,Ye+=h*We,it+=h*ft,_t+=h*pt,St+=h*dt,Nt+=h*gt,jt+=h*yt,h=T[8],ke+=h*st,Se+=h*nt,De+=h*ot,je+=h*at,He+=h*Ze,Re+=h*ct,qe+=h*ut,Pe+=h*ht,Me+=h*Ge,Ye+=h*lt,it+=h*We,_t+=h*ft,St+=h*pt,Nt+=h*dt,jt+=h*gt,Bt+=h*yt,h=T[9],Se+=h*st,De+=h*nt,je+=h*ot,He+=h*at,Re+=h*Ze,qe+=h*ct,Pe+=h*ut,Me+=h*ht,Ye+=h*Ge,it+=h*lt,_t+=h*We,St+=h*ft,Nt+=h*pt,jt+=h*dt,Bt+=h*gt,tr+=h*yt,h=T[10],De+=h*st,je+=h*nt,He+=h*ot,Re+=h*at,qe+=h*Ze,Pe+=h*ct,Me+=h*ut,Ye+=h*ht,it+=h*Ge,_t+=h*lt,St+=h*We,Nt+=h*ft,jt+=h*pt,Bt+=h*dt,tr+=h*gt,pr+=h*yt,h=T[11],je+=h*st,He+=h*nt,Re+=h*ot,qe+=h*at,Pe+=h*Ze,Me+=h*ct,Ye+=h*ut,it+=h*ht,_t+=h*Ge,St+=h*lt,Nt+=h*We,jt+=h*ft,Bt+=h*pt,tr+=h*dt,pr+=h*gt,Vr+=h*yt,h=T[12],He+=h*st,Re+=h*nt,qe+=h*ot,Pe+=h*at,Me+=h*Ze,Ye+=h*ct,it+=h*ut,_t+=h*ht,St+=h*Ge,Nt+=h*lt,jt+=h*We,Bt+=h*ft,tr+=h*pt,pr+=h*dt,Vr+=h*gt,ni+=h*yt,h=T[13],Re+=h*st,qe+=h*nt,Pe+=h*ot,Me+=h*at,Ye+=h*Ze,it+=h*ct,_t+=h*ut,St+=h*ht,Nt+=h*Ge,jt+=h*lt,Bt+=h*We,tr+=h*ft,pr+=h*pt,Vr+=h*dt,ni+=h*gt,_i+=h*yt,h=T[14],qe+=h*st,Pe+=h*nt,Me+=h*ot,Ye+=h*at,it+=h*Ze,_t+=h*ct,St+=h*ut,Nt+=h*ht,jt+=h*Ge,Bt+=h*lt,tr+=h*We,pr+=h*ft,Vr+=h*pt,ni+=h*dt,_i+=h*gt,Ei+=h*yt,h=T[15],Pe+=h*st,Me+=h*nt,Ye+=h*ot,it+=h*at,_t+=h*Ze,St+=h*ct,Nt+=h*ut,jt+=h*ht,Bt+=h*Ge,tr+=h*lt,pr+=h*We,Vr+=h*ft,ni+=h*pt,_i+=h*dt,Ei+=h*gt,Ji+=h*yt,te+=38*Me,ce+=38*Ye,pe+=38*it,be+=38*_t,Ee+=38*St,me+=38*Nt,rt+=38*jt,Qe+=38*Bt,ke+=38*tr,Se+=38*pr,De+=38*Vr,je+=38*ni,He+=38*_i,Re+=38*Ei,qe+=38*Ji,E=1,h=te+E+65535,E=Math.floor(h/65536),te=h-E*65536,h=ce+E+65535,E=Math.floor(h/65536),ce=h-E*65536,h=pe+E+65535,E=Math.floor(h/65536),pe=h-E*65536,h=be+E+65535,E=Math.floor(h/65536),be=h-E*65536,h=Ee+E+65535,E=Math.floor(h/65536),Ee=h-E*65536,h=me+E+65535,E=Math.floor(h/65536),me=h-E*65536,h=rt+E+65535,E=Math.floor(h/65536),rt=h-E*65536,h=Qe+E+65535,E=Math.floor(h/65536),Qe=h-E*65536,h=ke+E+65535,E=Math.floor(h/65536),ke=h-E*65536,h=Se+E+65535,E=Math.floor(h/65536),Se=h-E*65536,h=De+E+65535,E=Math.floor(h/65536),De=h-E*65536,h=je+E+65535,E=Math.floor(h/65536),je=h-E*65536,h=He+E+65535,E=Math.floor(h/65536),He=h-E*65536,h=Re+E+65535,E=Math.floor(h/65536),Re=h-E*65536,h=qe+E+65535,E=Math.floor(h/65536),qe=h-E*65536,h=Pe+E+65535,E=Math.floor(h/65536),Pe=h-E*65536,te+=E-1+37*(E-1),E=1,h=te+E+65535,E=Math.floor(h/65536),te=h-E*65536,h=ce+E+65535,E=Math.floor(h/65536),ce=h-E*65536,h=pe+E+65535,E=Math.floor(h/65536),pe=h-E*65536,h=be+E+65535,E=Math.floor(h/65536),be=h-E*65536,h=Ee+E+65535,E=Math.floor(h/65536),Ee=h-E*65536,h=me+E+65535,E=Math.floor(h/65536),me=h-E*65536,h=rt+E+65535,E=Math.floor(h/65536),rt=h-E*65536,h=Qe+E+65535,E=Math.floor(h/65536),Qe=h-E*65536,h=ke+E+65535,E=Math.floor(h/65536),ke=h-E*65536,h=Se+E+65535,E=Math.floor(h/65536),Se=h-E*65536,h=De+E+65535,E=Math.floor(h/65536),De=h-E*65536,h=je+E+65535,E=Math.floor(h/65536),je=h-E*65536,h=He+E+65535,E=Math.floor(h/65536),He=h-E*65536,h=Re+E+65535,E=Math.floor(h/65536),Re=h-E*65536,h=qe+E+65535,E=Math.floor(h/65536),qe=h-E*65536,h=Pe+E+65535,E=Math.floor(h/65536),Pe=h-E*65536,te+=E-1+37*(E-1),A[0]=te,A[1]=ce,A[2]=pe,A[3]=be,A[4]=Ee,A[5]=me,A[6]=rt,A[7]=Qe,A[8]=ke,A[9]=Se,A[10]=De,A[11]=je,A[12]=He,A[13]=Re,A[14]=qe,A[15]=Pe}function W(A,T){K(A,T,T)}function we(A,T){const S=a();let h;for(h=0;h<16;h++)S[h]=T[h];for(h=253;h>=0;h--)W(S,S),h!==2&&h!==4&&K(S,S,T);for(h=0;h<16;h++)A[h]=S[h]}function tt(A,T){const S=a();let h;for(h=0;h<16;h++)S[h]=T[h];for(h=250;h>=0;h--)W(S,S),h!==1&&K(S,S,T);for(h=0;h<16;h++)A[h]=S[h]}function lr(A,T){const S=a(),h=a(),E=a(),te=a(),ce=a(),pe=a(),be=a(),Ee=a(),me=a();z(S,A[1],A[0]),z(me,T[1],T[0]),K(S,S,me),q(h,A[0],A[1]),q(me,T[0],T[1]),K(h,h,me),K(E,A[3],T[3]),K(E,E,g),K(te,A[2],T[2]),q(te,te,te),z(ce,h,S),z(pe,te,E),q(be,te,E),q(Ee,h,S),K(A[0],ce,pe),K(A[1],Ee,be),K(A[2],be,pe),K(A[3],ce,Ee)}function _r(A,T,S){for(let h=0;h<4;h++)ee(A[h],T[h],S)}function fr(A,T){const S=a(),h=a(),E=a();we(E,T[2]),K(S,T[0],E),K(h,T[1],E),ne(A,h),A[31]^=$(S)<<7}function k(A,T,S){j(A[0],f),j(A[1],y),j(A[2],y),j(A[3],f);for(let h=255;h>=0;--h){const E=S[h/8|0]>>(h&7)&1;_r(A,T,E),lr(T,A),lr(A,A),_r(A,T,E)}}function H(A,T){const S=[a(),a(),a(),a()];j(S[0],w),j(S[1],_),j(S[2],y),K(S[3],w,_),k(A,S,T)}function Ue(A){if(A.length!==s.SEED_LENGTH)throw new Error(`ed25519: seed must be ${s.SEED_LENGTH} bytes`);const T=(0,r.hash)(A);T[0]&=248,T[31]&=127,T[31]|=64;const S=new Uint8Array(32),h=[a(),a(),a(),a()];H(h,T),fr(S,h);const E=new Uint8Array(64);return E.set(A),E.set(S,32),{publicKey:S,secretKey:E}}s.generateKeyPairFromSeed=Ue;function $e(A){const T=(0,t.randomBytes)(32,A),S=Ue(T);return(0,n.wipe)(T),S}s.generateKeyPair=$e;function Y(A){if(A.length!==s.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${s.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(A.subarray(32))}s.extractPublicKeyFromSecretKey=Y;const G=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function B(A,T){let S,h,E,te;for(h=63;h>=32;--h){for(S=0,E=h-32,te=h-12;E<te;++E)T[E]+=S-16*T[h]*G[E-(h-32)],S=Math.floor((T[E]+128)/256),T[E]-=S*256;T[E]+=S,T[h]=0}for(S=0,E=0;E<32;E++)T[E]+=S-(T[31]>>4)*G[E],S=T[E]>>8,T[E]&=255;for(E=0;E<32;E++)T[E]-=S*G[E];for(h=0;h<32;h++)T[h+1]+=T[h]>>8,A[h]=T[h]&255}function J(A){const T=new Float64Array(64);for(let S=0;S<64;S++)T[S]=A[S];for(let S=0;S<64;S++)A[S]=0;B(A,T)}function bt(A,T){const S=new Float64Array(64),h=[a(),a(),a(),a()],E=(0,r.hash)(A.subarray(0,32));E[0]&=248,E[31]&=127,E[31]|=64;const te=new Uint8Array(64);te.set(E.subarray(32),32);const ce=new r.SHA512;ce.update(te.subarray(32)),ce.update(T);const pe=ce.digest();ce.clean(),J(pe),H(h,pe),fr(te,h),ce.reset(),ce.update(te.subarray(0,32)),ce.update(A.subarray(32)),ce.update(T);const be=ce.digest();J(be);for(let Ee=0;Ee<32;Ee++)S[Ee]=pe[Ee];for(let Ee=0;Ee<32;Ee++)for(let me=0;me<32;me++)S[Ee+me]+=be[Ee]*E[me];return B(te.subarray(32),S),te}s.sign=bt;function Be(A,T){const S=a(),h=a(),E=a(),te=a(),ce=a(),pe=a(),be=a();return j(A[2],y),C(A[1],T),W(E,A[1]),K(te,E,m),z(E,E,A[2]),q(te,A[2],te),W(ce,te),W(pe,ce),K(be,pe,ce),K(S,be,E),K(S,S,te),tt(S,S),K(S,S,E),K(S,S,te),K(S,S,te),K(A[0],S,te),W(h,A[0]),K(h,h,te),P(h,E)&&K(A[0],A[0],O),W(h,A[0]),K(h,h,te),P(h,E)?-1:($(A[0])===T[31]>>7&&z(A[0],f,A[0]),K(A[3],A[0],A[1]),0)}function Wi(A,T,S){const h=new Uint8Array(32),E=[a(),a(),a(),a()],te=[a(),a(),a(),a()];if(S.length!==s.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${s.SIGNATURE_LENGTH} bytes`);if(Be(te,A))return!1;const ce=new r.SHA512;ce.update(S.subarray(0,32)),ce.update(A),ce.update(T);const pe=ce.digest();return J(pe),k(E,te,pe),H(te,S.subarray(32)),lr(E,te),fr(h,E),!oe(S,h)}s.verify=Wi;function Er(A){let T=[a(),a(),a(),a()];if(Be(T,A))throw new Error("Ed25519: invalid public key");let S=a(),h=a(),E=T[1];q(S,y,E),z(h,y,E),we(h,h),K(S,S,h);let te=new Uint8Array(32);return ne(te,S),te}s.convertPublicKeyToX25519=Er;function Kr(A){const T=(0,r.hash)(A.subarray(0,32));T[0]&=248,T[31]&=127,T[31]|=64;const S=new Uint8Array(T.subarray(0,32));return(0,n.wipe)(T),S}s.convertSecretKeyToX25519=Kr})(Wa);const P_="EdDSA",O_="JWT",uf=".",hf="base64url",R_="utf8",N_="utf8",$_=":",C_="did",A_="key",el="base58btc",T_="z",D_="K36",j_=32;function Dn(s){return Dt(Vt(Ps(s),R_),hf)}function lf(s){const t=Vt(D_,el),r=T_+Dt(ba([t,s]),el);return[C_,A_,r].join($_)}function q_(s){return Dt(s,hf)}function M_(s){return Vt([Dn(s.header),Dn(s.payload)].join(uf),N_)}function L_(s){return[Dn(s.header),Dn(s.payload),q_(s.signature)].join(uf)}function tl(s=qn.randomBytes(j_)){return Wa.generateKeyPairFromSeed(s)}async function U_(s,t,r,n,a=X.fromMiliseconds(Date.now())){const u={alg:P_,typ:O_},f=lf(n.publicKey),y=a+r,m={iss:f,sub:s,aud:t,iat:a,exp:y},g=M_({header:u,payload:m}),w=Wa.sign(n.secretKey,g);return L_({header:u,payload:m,signature:w})}class kr extends ww{constructor(t){super(t),this.events=new br.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(t),this.connection.connected&&this.registerEventListeners()}async connect(t=this.connection){await this.open(t)}async disconnect(){await this.close()}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async request(t,r){return this.requestStrict(ki(t.method,t.params||[],t.id||zl().toString()),r)}async requestStrict(t,r){return new Promise(async(n,a)=>{if(!this.connection.connected)try{await this.open()}catch(u){a(u)}this.events.on(`${t.id}`,u=>{Or(u)?a(u.error):n(u.result)});try{await this.connection.send(t,r)}catch(u){a(u)}})}setConnection(t=this.connection){return t}onPayload(t){this.events.emit("payload",t),Ln(t)?this.events.emit(`${t.id}`,t):this.events.emit("message",{type:t.method,data:t.params})}onClose(t){t&&t.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${t.code} ${t.reason?`(${t.reason})`:""}`)),this.events.emit("disconnect")}async open(t=this.connection){this.connection===t&&this.connection.connected||(this.connection.connected&&this.close(),typeof t=="string"&&(await this.connection.open(t),t=this.connection),this.connection=this.setConnection(t),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",t=>this.onPayload(t)),this.connection.on("close",t=>this.onClose(t)),this.connection.on("error",t=>this.events.emit("error",t)),this.connection.on("register_error",t=>this.onClose()),this.hasRegisteredEventListeners=!0)}}const z_=()=>typeof WebSocket<"u"?WebSocket:typeof xe<"u"&&typeof xe.WebSocket<"u"?xe.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),k_=()=>typeof WebSocket<"u"||typeof xe<"u"&&typeof xe.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",rl=s=>s.split("?")[0],il=10,H_=z_();let K_=class{constructor(t){if(this.url=t,this.events=new br.EventEmitter,this.registering=!1,!Ph(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);this.url=t}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async open(t=this.url){await this.register(t)}async close(){return new Promise((t,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=n=>{this.onClose(n),t()},this.socket.close()})}async send(t){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(Ps(t))}catch(r){this.onError(t.id,r)}}register(t=this.url){if(!Ph(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,a)=>{this.events.once("register_error",u=>{this.resetMaxListeners(),a(u)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return a(new Error("WebSocket connection is missing or invalid"));n(this.socket)})})}return this.url=t,this.registering=!0,new Promise((r,n)=>{const a=new URLSearchParams(t).get("origin"),u=bw.isReactNative()?{headers:{origin:a}}:{rejectUnauthorized:!_w(t)},f=new H_(t,[],u);k_()?f.onerror=y=>{const m=y;n(this.emitError(m.error))}:f.on("error",y=>{n(this.emitError(y))}),f.onopen=()=>{this.onOpen(f),r(f)}})}onOpen(t){t.onmessage=r=>this.onPayload(r),t.onclose=r=>this.onClose(r),this.socket=t,this.registering=!1,this.events.emit("open")}onClose(t){this.socket=void 0,this.registering=!1,this.events.emit("close",t)}onPayload(t){if(typeof t.data>"u")return;const r=typeof t.data=="string"?Mn(t.data):t.data;this.events.emit("payload",r)}onError(t,r){const n=this.parseError(r),a=n.message||n.toString(),u=Ua(t,a);this.events.emit("payload",u)}parseError(t,r=this.url){return Ew(t,rl(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>il&&this.events.setMaxListeners(il)}emitError(t){const r=this.parseError(new Error((t==null?void 0:t.message)||`WebSocket connection failed for host: ${rl(this.url)}`));return this.events.emit("register_error",r),r}};var V_={};function F_(s,t){if(s.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var a=0;a<s.length;a++){var u=s.charAt(a),f=u.charCodeAt(0);if(r[f]!==255)throw new TypeError(u+" is ambiguous");r[f]=a}var y=s.length,m=s.charAt(0),g=Math.log(y)/Math.log(256),w=Math.log(256)/Math.log(y);function _(N){if(N instanceof Uint8Array||(ArrayBuffer.isView(N)?N=new Uint8Array(N.buffer,N.byteOffset,N.byteLength):Array.isArray(N)&&(N=Uint8Array.from(N))),!(N instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(N.length===0)return"";for(var ee=0,ne=0,oe=0,P=N.length;oe!==P&&N[oe]===0;)oe++,ee++;for(var $=(P-oe)*w+1>>>0,C=new Uint8Array($);oe!==P;){for(var q=N[oe],z=0,K=$-1;(q!==0||z<ne)&&K!==-1;K--,z++)q+=256*C[K]>>>0,C[K]=q%y>>>0,q=q/y>>>0;if(q!==0)throw new Error("Non-zero carry");ne=z,oe++}for(var W=$-ne;W!==$&&C[W]===0;)W++;for(var we=m.repeat(ee);W<$;++W)we+=s.charAt(C[W]);return we}function O(N){if(typeof N!="string")throw new TypeError("Expected String");if(N.length===0)return new Uint8Array;var ee=0;if(N[ee]!==" "){for(var ne=0,oe=0;N[ee]===m;)ne++,ee++;for(var P=(N.length-ee)*g+1>>>0,$=new Uint8Array(P);N[ee];){var C=r[N.charCodeAt(ee)];if(C===255)return;for(var q=0,z=P-1;(C!==0||q<oe)&&z!==-1;z--,q++)C+=y*$[z]>>>0,$[z]=C%256>>>0,C=C/256>>>0;if(C!==0)throw new Error("Non-zero carry");oe=q,ee++}if(N[ee]!==" "){for(var K=P-oe;K!==P&&$[K]===0;)K++;for(var W=new Uint8Array(ne+(P-K)),we=ne;K!==P;)W[we++]=$[K++];return W}}}function j(N){var ee=O(N);if(ee)return ee;throw new Error(`Non-${t} character`)}return{encode:_,decodeUnsafe:O,decode:j}}var B_=F_,G_=B_;const ff=s=>{if(s instanceof Uint8Array&&s.constructor.name==="Uint8Array")return s;if(s instanceof ArrayBuffer)return new Uint8Array(s);if(ArrayBuffer.isView(s))return new Uint8Array(s.buffer,s.byteOffset,s.byteLength);throw new Error("Unknown type, must be binary type")},W_=s=>new TextEncoder().encode(s),J_=s=>new TextDecoder().decode(s);class Q_{constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class Y_{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return pf(this,t)}}let Z_=class{constructor(t){this.decoders=t}or(t){return pf(this,t)}decode(t){const r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const pf=(s,t)=>new Z_({...s.decoders||{[s.prefix]:s},...t.decoders||{[t.prefix]:t}});class X_{constructor(t,r,n,a){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=a,this.encoder=new Q_(t,r,n),this.decoder=new Y_(t,r,a)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}const Kn=({name:s,prefix:t,encode:r,decode:n})=>new X_(s,t,r,n),Cs=({prefix:s,name:t,alphabet:r})=>{const{encode:n,decode:a}=G_(r,t);return Kn({prefix:s,name:t,encode:n,decode:u=>ff(a(u))})},eE=(s,t,r,n)=>{const a={};for(let w=0;w<t.length;++w)a[t[w]]=w;let u=s.length;for(;s[u-1]==="=";)--u;const f=new Uint8Array(u*r/8|0);let y=0,m=0,g=0;for(let w=0;w<u;++w){const _=a[s[w]];if(_===void 0)throw new SyntaxError(`Non-${n} character`);m=m<<r|_,y+=r,y>=8&&(y-=8,f[g++]=255&m>>y)}if(y>=r||255&m<<8-y)throw new SyntaxError("Unexpected end of data");return f},tE=(s,t,r)=>{const n=t[t.length-1]==="=",a=(1<<r)-1;let u="",f=0,y=0;for(let m=0;m<s.length;++m)for(y=y<<8|s[m],f+=8;f>r;)f-=r,u+=t[a&y>>f];if(f&&(u+=t[a&y<<r-f]),n)for(;u.length*r&7;)u+="=";return u},xt=({name:s,prefix:t,bitsPerChar:r,alphabet:n})=>Kn({prefix:t,name:s,encode(a){return tE(a,n,r)},decode(a){return eE(a,n,r,s)}}),rE=Kn({prefix:"\0",name:"identity",encode:s=>J_(s),decode:s=>W_(s)});var iE=Object.freeze({__proto__:null,identity:rE});const sE=xt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var nE=Object.freeze({__proto__:null,base2:sE});const oE=xt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var aE=Object.freeze({__proto__:null,base8:oE});const cE=Cs({prefix:"9",name:"base10",alphabet:"0123456789"});var uE=Object.freeze({__proto__:null,base10:cE});const hE=xt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),lE=xt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var fE=Object.freeze({__proto__:null,base16:hE,base16upper:lE});const pE=xt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),dE=xt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),gE=xt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),yE=xt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),mE=xt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),vE=xt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),wE=xt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),bE=xt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),_E=xt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var EE=Object.freeze({__proto__:null,base32:pE,base32upper:dE,base32pad:gE,base32padupper:yE,base32hex:mE,base32hexupper:vE,base32hexpad:wE,base32hexpadupper:bE,base32z:_E});const IE=Cs({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),xE=Cs({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var SE=Object.freeze({__proto__:null,base36:IE,base36upper:xE});const PE=Cs({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),OE=Cs({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var RE=Object.freeze({__proto__:null,base58btc:PE,base58flickr:OE});const NE=xt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),$E=xt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),CE=xt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),AE=xt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var TE=Object.freeze({__proto__:null,base64:NE,base64pad:$E,base64url:CE,base64urlpad:AE});const df=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),DE=df.reduce((s,t,r)=>(s[r]=t,s),[]),jE=df.reduce((s,t,r)=>(s[t.codePointAt(0)]=r,s),[]);function qE(s){return s.reduce((t,r)=>(t+=DE[r],t),"")}function ME(s){const t=[];for(const r of s){const n=jE[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(n)}return new Uint8Array(t)}const LE=Kn({prefix:"🚀",name:"base256emoji",encode:qE,decode:ME});var UE=Object.freeze({__proto__:null,base256emoji:LE}),zE=gf,sl=128,kE=127,HE=~kE,KE=Math.pow(2,31);function gf(s,t,r){t=t||[],r=r||0;for(var n=r;s>=KE;)t[r++]=s&255|sl,s/=128;for(;s&HE;)t[r++]=s&255|sl,s>>>=7;return t[r]=s|0,gf.bytes=r-n+1,t}var VE=$a,FE=128,nl=127;function $a(s,n){var r=0,n=n||0,a=0,u=n,f,y=s.length;do{if(u>=y)throw $a.bytes=0,new RangeError("Could not decode varint");f=s[u++],r+=a<28?(f&nl)<<a:(f&nl)*Math.pow(2,a),a+=7}while(f>=FE);return $a.bytes=u-n,r}var BE=Math.pow(2,7),GE=Math.pow(2,14),WE=Math.pow(2,21),JE=Math.pow(2,28),QE=Math.pow(2,35),YE=Math.pow(2,42),ZE=Math.pow(2,49),XE=Math.pow(2,56),eI=Math.pow(2,63),tI=function(s){return s<BE?1:s<GE?2:s<WE?3:s<JE?4:s<QE?5:s<YE?6:s<ZE?7:s<XE?8:s<eI?9:10},rI={encode:zE,decode:VE,encodingLength:tI},yf=rI;const ol=(s,t,r=0)=>(yf.encode(s,t,r),t),al=s=>yf.encodingLength(s),Ca=(s,t)=>{const r=t.byteLength,n=al(s),a=n+al(r),u=new Uint8Array(a+r);return ol(s,u,0),ol(r,u,n),u.set(t,a),new iI(s,r,t,u)};class iI{constructor(t,r,n,a){this.code=t,this.size=r,this.digest=n,this.bytes=a}}const mf=({name:s,code:t,encode:r})=>new sI(s,t,r);class sI{constructor(t,r,n){this.name=t,this.code=r,this.encode=n}digest(t){if(t instanceof Uint8Array){const r=this.encode(t);return r instanceof Uint8Array?Ca(this.code,r):r.then(n=>Ca(this.code,n))}else throw Error("Unknown type, must be binary type")}}const vf=s=>async t=>new Uint8Array(await crypto.subtle.digest(s,t)),nI=mf({name:"sha2-256",code:18,encode:vf("SHA-256")}),oI=mf({name:"sha2-512",code:19,encode:vf("SHA-512")});var aI=Object.freeze({__proto__:null,sha256:nI,sha512:oI});const wf=0,cI="identity",bf=ff,uI=s=>Ca(wf,bf(s)),hI={code:wf,name:cI,encode:bf,digest:uI};var lI=Object.freeze({__proto__:null,identity:hI});new TextEncoder,new TextDecoder;const cl={...iE,...nE,...aE,...uE,...fE,...EE,...SE,...RE,...TE,...UE};({...aI,...lI});function _f(s){return globalThis.Buffer!=null?new Uint8Array(s.buffer,s.byteOffset,s.byteLength):s}function fI(s=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?_f(globalThis.Buffer.allocUnsafe(s)):new Uint8Array(s)}function Ef(s,t,r,n){return{name:s,prefix:t,encoder:{name:s,prefix:t,encode:r},decoder:{decode:n}}}const ul=Ef("utf8","u",s=>"u"+new TextDecoder("utf8").decode(s),s=>new TextEncoder().encode(s.substring(1))),la=Ef("ascii","a",s=>{let t="a";for(let r=0;r<s.length;r++)t+=String.fromCharCode(s[r]);return t},s=>{s=s.substring(1);const t=fI(s.length);for(let r=0;r<s.length;r++)t[r]=s.charCodeAt(r);return t}),pI={utf8:ul,"utf-8":ul,hex:cl.base16,latin1:la,ascii:la,binary:la,...cl};function dI(s,t="utf8"){const r=pI[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?_f(globalThis.Buffer.from(s,"utf-8")):r.decoder.decode(`${r.prefix}${s}`)}const If="wc",gI=2,Ja="core",ri=`${If}@2:${Ja}:`,yI={name:Ja,logger:"error"},mI={database:":memory:"},vI="crypto",hl="client_ed25519_seed",wI=X.ONE_DAY,bI="keychain",_I="0.3",EI="messages",II="0.3",xI=X.SIX_HOURS,SI="publisher",xf="irn",PI="error",Sf="wss://relay.walletconnect.com",ll="wss://relay.walletconnect.org",OI="relayer",Rt={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},RI="_subscription",Ur={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},NI=X.ONE_SECOND,$I="2.10.6",CI=1e4,AI="0.3",TI="WALLETCONNECT_CLIENT_ID",vr={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},DI="subscription",jI="0.3",qI=X.FIVE_SECONDS*1e3,MI="pairing",LI="0.3",ps={wc_pairingDelete:{req:{ttl:X.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:X.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:X.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:X.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:X.ONE_DAY,prompt:!1,tag:0},res:{ttl:X.ONE_DAY,prompt:!1,tag:0}}},ws={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Pr={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},UI="history",zI="0.3",kI="expirer",hr={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},HI="0.3",fa="verify-api",zi="https://verify.walletconnect.com",Aa="https://verify.walletconnect.org",KI=[zi,Aa];class VI{constructor(t,r){this.core=t,this.logger=r,this.keychain=new Map,this.name=bI,this.version=_I,this.initialized=!1,this.storagePrefix=ri,this.init=async()=>{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}},this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=async(n,a)=>{this.isInitialized(),this.keychain.set(n,a),await this.persist()},this.get=n=>{this.isInitialized();const a=this.keychain.get(n);if(typeof a>"u"){const{message:u}=V("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(u)}return a},this.del=async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()},this.core=t,this.logger=er(r,this.name)}get context(){return Ft(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(t){await this.core.storage.setItem(this.storageKey,Wl(t))}async getKeyChain(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?Jl(t):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:t}=V("NOT_INITIALIZED",this.name);throw new Error(t)}}}class FI{constructor(t,r,n){this.core=t,this.logger=r,this.name=vI,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=a=>(this.isInitialized(),this.keychain.has(a)),this.getClientId=async()=>{this.isInitialized();const a=await this.getClientSeed(),u=tl(a);return lf(u.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const a=Nw();return this.setPrivateKey(a.publicKey,a.privateKey)},this.signJWT=async a=>{this.isInitialized();const u=await this.getClientSeed(),f=tl(u),y=Ia();return await U_(y,a,wI,f)},this.generateSharedKey=(a,u,f)=>{this.isInitialized();const y=this.getPrivateKey(a),m=$w(y,u);return this.setSymKey(m,f)},this.setSymKey=async(a,u)=>{this.isInitialized();const f=u||Cw(a);return await this.keychain.set(f,a),f},this.deleteKeyPair=async a=>{this.isInitialized(),await this.keychain.del(a)},this.deleteSymKey=async a=>{this.isInitialized(),await this.keychain.del(a)},this.encode=async(a,u,f)=>{this.isInitialized();const y=Gl(f),m=Ps(u);if($h(y)){const O=y.senderPublicKey,j=y.receiverPublicKey;a=await this.generateSharedKey(O,j)}const g=this.getSymKey(a),{type:w,senderPublicKey:_}=y;return Tw({type:w,symKey:g,message:m,senderPublicKey:_})},this.decode=async(a,u,f)=>{this.isInitialized();const y=qw(u,f);if($h(y)){const m=y.receiverPublicKey,g=y.senderPublicKey;a=await this.generateSharedKey(m,g)}try{const m=this.getSymKey(a),g=Dw({symKey:m,encoded:u});return Mn(g)}catch(m){this.logger.error(`Failed to decode message from topic: '${a}', clientId: '${await this.getClientId()}'`),this.logger.error(m)}},this.getPayloadType=a=>{const u=An(a);return Os(u.type)},this.getPayloadSenderPublicKey=a=>{const u=An(a);return u.senderPublicKey?Dt(u.senderPublicKey,Tt):void 0},this.core=t,this.logger=er(r,this.name),this.keychain=n||new VI(this.core,this.logger)}get context(){return Ft(this.logger)}async setPrivateKey(t,r){return await this.keychain.set(t,r),t}getPrivateKey(t){return this.keychain.get(t)}async getClientSeed(){let t="";try{t=this.keychain.get(hl)}catch{t=Ia(),await this.keychain.set(hl,t)}return dI(t,"base16")}getSymKey(t){return this.keychain.get(t)}isInitialized(){if(!this.initialized){const{message:t}=V("NOT_INITIALIZED",this.name);throw new Error(t)}}}class BI extends m_{constructor(t,r){super(t,r),this.logger=t,this.core=r,this.messages=new Map,this.name=EI,this.version=II,this.initialized=!1,this.storagePrefix=ri,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}},this.set=async(n,a)=>{this.isInitialized();const u=Hi(a);let f=this.messages.get(n);return typeof f>"u"&&(f={}),typeof f[u]<"u"||(f[u]=a,this.messages.set(n,f),await this.persist()),u},this.get=n=>{this.isInitialized();let a=this.messages.get(n);return typeof a>"u"&&(a={}),a},this.has=(n,a)=>{this.isInitialized();const u=this.get(n),f=Hi(a);return typeof u[f]<"u"},this.del=async n=>{this.isInitialized(),this.messages.delete(n),await this.persist()},this.logger=er(t,this.name),this.core=r}get context(){return Ft(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(t){await this.core.storage.setItem(this.storageKey,Wl(t))}async getRelayerMessages(){const t=await this.core.storage.getItem(this.storageKey);return typeof t<"u"?Jl(t):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:t}=V("NOT_INITIALIZED",this.name);throw new Error(t)}}}class GI extends v_{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.events=new br.EventEmitter,this.name=SI,this.queue=new Map,this.publishTimeout=X.toMiliseconds(X.TEN_SECONDS),this.needsTransportRestart=!1,this.publish=async(n,a,u)=>{var f;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:a,opts:u}});try{const y=(u==null?void 0:u.ttl)||xI,m=xa(u),g=(u==null?void 0:u.prompt)||!1,w=(u==null?void 0:u.tag)||0,_=(u==null?void 0:u.id)||zl().toString(),O={topic:n,message:a,opts:{ttl:y,relay:m,prompt:g,tag:w,id:_}},j=setTimeout(()=>this.queue.set(_,O),this.publishTimeout);try{await await Es(this.rpcPublish(n,a,y,m,g,w,_),this.publishTimeout,"Failed to publish payload, please try again."),this.removeRequestFromQueue(_),this.relayer.events.emit(Rt.publish,O)}catch(N){if(this.logger.debug("Publishing Payload stalled"),this.needsTransportRestart=!0,(f=u==null?void 0:u.internal)!=null&&f.throwOnFailedPublish)throw this.removeRequestFromQueue(_),N;return}finally{clearTimeout(j)}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:a,opts:u}})}catch(y){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(y),y}},this.on=(n,a)=>{this.events.on(n,a)},this.once=(n,a)=>{this.events.once(n,a)},this.off=(n,a)=>{this.events.off(n,a)},this.removeListener=(n,a)=>{this.events.removeListener(n,a)},this.relayer=t,this.logger=er(r,this.name),this.registerEventListeners()}get context(){return Ft(this.logger)}rpcPublish(t,r,n,a,u,f,y){var m,g,w,_;const O={method:Rn(a.protocol).publish,params:{topic:t,message:r,ttl:n,prompt:u,tag:f},id:y};return Kt((m=O.params)==null?void 0:m.prompt)&&((g=O.params)==null||delete g.prompt),Kt((w=O.params)==null?void 0:w.tag)&&((_=O.params)==null||delete _.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:O}),this.relayer.request(O)}removeRequestFromQueue(t){this.queue.delete(t)}checkQueue(){this.queue.forEach(async t=>{const{topic:r,message:n,opts:a}=t;await this.publish(r,n,a)})}registerEventListeners(){this.relayer.core.heartbeat.on(Gi.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Rt.connection_stalled);return}this.checkQueue()}),this.relayer.on(Rt.message_ack,t=>{this.removeRequestFromQueue(t.id.toString())})}}class WI{constructor(){this.map=new Map,this.set=(t,r)=>{const n=this.get(t);this.exists(t,r)||this.map.set(t,[...n,r])},this.get=t=>this.map.get(t)||[],this.exists=(t,r)=>this.get(t).includes(r),this.delete=(t,r)=>{if(typeof r>"u"){this.map.delete(t);return}if(!this.map.has(t))return;const n=this.get(t);if(!this.exists(t,r))return;const a=n.filter(u=>u!==r);if(!a.length){this.map.delete(t);return}this.map.set(t,a)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var JI=Object.defineProperty,QI=Object.defineProperties,YI=Object.getOwnPropertyDescriptors,fl=Object.getOwnPropertySymbols,ZI=Object.prototype.hasOwnProperty,XI=Object.prototype.propertyIsEnumerable,pl=(s,t,r)=>t in s?JI(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,ds=(s,t)=>{for(var r in t||(t={}))ZI.call(t,r)&&pl(s,r,t[r]);if(fl)for(var r of fl(t))XI.call(t,r)&&pl(s,r,t[r]);return s},pa=(s,t)=>QI(s,YI(t));class ex extends __{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.subscriptions=new Map,this.topicMap=new WI,this.events=new br.EventEmitter,this.name=DI,this.version=jI,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=ri,this.subscribeTimeout=1e4,this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=await this.relayer.core.crypto.getClientId())},this.subscribe=async(n,a)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:a}});try{const u=xa(a),f={topic:n,relay:u};this.pending.set(n,f);const y=await this.rpcSubscribe(n,u);return this.onSubscribe(y,f),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:a}}),y}catch(u){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(u),u}},this.unsubscribe=async(n,a)=>{await this.restartToComplete(),this.isInitialized(),typeof(a==null?void 0:a.id)<"u"?await this.unsubscribeById(n,a.id,a):await this.unsubscribeByTopic(n,a)},this.isSubscribed=async n=>this.topics.includes(n)?!0:await new Promise((a,u)=>{const f=new X.Watch;f.start(this.pendingSubscriptionWatchLabel);const y=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(y),f.stop(this.pendingSubscriptionWatchLabel),a(!0)),f.elapsed(this.pendingSubscriptionWatchLabel)>=qI&&(clearInterval(y),f.stop(this.pendingSubscriptionWatchLabel),u(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1),this.on=(n,a)=>{this.events.on(n,a)},this.once=(n,a)=>{this.events.once(n,a)},this.off=(n,a)=>{this.events.off(n,a)},this.removeListener=(n,a)=>{this.events.removeListener(n,a)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=t,this.logger=er(r,this.name),this.clientId=""}get context(){return Ft(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(t,r){let n=!1;try{n=this.getSubscription(t).topic===r}catch{}return n}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(t,r){const n=this.topicMap.get(t);await Promise.all(n.map(async a=>await this.unsubscribeById(t,a,r)))}async unsubscribeById(t,r,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:r,opts:n}});try{const a=xa(n);await this.rpcUnsubscribe(t,r,a);const u=Fe("USER_DISCONNECTED",`${this.name}, ${t}`);await this.onUnsubscribe(t,r,u),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:r,opts:n}})}catch(a){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(a),a}}async rpcSubscribe(t,r){const n={method:Rn(r.protocol).subscribe,params:{topic:t}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{await await Es(this.relayer.request(n),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Rt.connection_stalled)}return Hi(t+this.clientId)}async rpcBatchSubscribe(t){if(!t.length)return;const r=t[0].relay,n={method:Rn(r.protocol).batchSubscribe,params:{topics:t.map(a=>a.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{return await await Es(this.relayer.request(n),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(Rt.connection_stalled)}}rpcUnsubscribe(t,r,n){const a={method:Rn(n.protocol).unsubscribe,params:{topic:t,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:a}),this.relayer.request(a)}onSubscribe(t,r){this.setSubscription(t,pa(ds({},r),{id:t})),this.pending.delete(r.topic)}onBatchSubscribe(t){t.length&&t.forEach(r=>{this.setSubscription(r.id,ds({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(t,r,n){this.events.removeAllListeners(r),this.hasSubscription(r,t)&&this.deleteSubscription(r,n),await this.relayer.messages.del(t)}async setRelayerSubscriptions(t){await this.relayer.core.storage.setItem(this.storageKey,t)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(t,r){this.subscriptions.has(t)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:t,subscription:r}),this.addSubscription(t,r))}addSubscription(t,r){this.subscriptions.set(t,ds({},r)),this.topicMap.set(r.topic,t),this.events.emit(vr.created,r)}getSubscription(t){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:t});const r=this.subscriptions.get(t);if(!r){const{message:n}=V("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(n)}return r}deleteSubscription(t,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:t,reason:r});const n=this.getSubscription(t);this.subscriptions.delete(t),this.topicMap.delete(n.topic,t),this.events.emit(vr.deleted,pa(ds({},n),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(vr.sync)}async reset(){if(this.cached.length){const t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<t;r++){const n=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(n)}}this.events.emit(vr.resubscribed)}async restore(){try{const t=await this.getRelayerSubscriptions();if(typeof t>"u"||!t.length)return;if(this.subscriptions.size){const{message:r}=V("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(t){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(t)}}async batchSubscribe(t){if(!t.length)return;const r=await this.rpcBatchSubscribe(t);Nr(r)&&this.onBatchSubscribe(r.map((n,a)=>pa(ds({},t[a]),{id:n})))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||this.relayer.transportExplicitlyClosed)return;const t=[];this.pending.forEach(r=>{t.push(r)}),await this.batchSubscribe(t)}registerEventListeners(){this.relayer.core.heartbeat.on(Gi.HEARTBEAT_EVENTS.pulse,async()=>{await this.checkPending()}),this.relayer.on(Rt.connect,async()=>{await this.onConnect()}),this.relayer.on(Rt.disconnect,()=>{this.onDisconnect()}),this.events.on(vr.created,async t=>{const r=vr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),await this.persist()}),this.events.on(vr.deleted,async t=>{const r=vr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=V("NOT_INITIALIZED",this.name);throw new Error(t)}}async restartToComplete(){this.restartInProgress&&await new Promise(t=>{const r=setInterval(()=>{this.restartInProgress||(clearInterval(r),t())},this.pollingInterval)})}}var tx=Object.defineProperty,dl=Object.getOwnPropertySymbols,rx=Object.prototype.hasOwnProperty,ix=Object.prototype.propertyIsEnumerable,gl=(s,t,r)=>t in s?tx(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,sx=(s,t)=>{for(var r in t||(t={}))rx.call(t,r)&&gl(s,r,t[r]);if(dl)for(var r of dl(t))ix.call(t,r)&&gl(s,r,t[r]);return s};class nx extends w_{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new br.EventEmitter,this.name=OI,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","socket stalled"],this.hasExperiencedNetworkDisruption=!1,this.request=async r=>{this.logger.debug("Publishing Request Payload");try{return await this.toEstablishConnection(),await this.provider.request(r)}catch(n){throw this.logger.debug("Failed to Publish Request"),this.logger.error(n),n}},this.onPayloadHandler=r=>{this.onProviderPayload(r)},this.onConnectHandler=()=>{this.events.emit(Rt.connect)},this.onDisconnectHandler=()=>{this.onProviderDisconnect()},this.onProviderErrorHandler=r=>{this.logger.error(r),this.events.emit(Rt.error,r),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(Ur.payload,this.onPayloadHandler),this.provider.on(Ur.connect,this.onConnectHandler),this.provider.on(Ur.disconnect,this.onDisconnectHandler),this.provider.on(Ur.error,this.onProviderErrorHandler)},this.core=t.core,this.logger=typeof t.logger<"u"&&typeof t.logger!="string"?er(t.logger,this.name):kn(Hn({level:t.logger||PI})),this.messages=new BI(this.logger,t.core),this.subscriber=new ex(this,this.logger),this.publisher=new GI(this,this.logger),this.relayUrl=(t==null?void 0:t.relayUrl)||Sf,this.projectId=t.projectId,this.bundleId=Hw(),this.provider={}}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await this.createProvider(),await Promise.all([this.messages.init(),this.subscriber.init()]);try{await this.transportOpen()}catch{this.logger.warn(`Connection via ${this.relayUrl} failed, attempting to connect via failover domain ${ll}...`),await this.restartTransport(ll)}this.initialized=!0,setTimeout(async()=>{this.subscriber.topics.length===0&&(this.logger.info("No topics subscribed to after init, closing transport"),await this.transportClose(),this.transportExplicitlyClosed=!1)},CI)}get context(){return Ft(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(t,r,n){this.isInitialized(),await this.publisher.publish(t,r,n),await this.recordMessageEvent({topic:t,message:r,publishedAt:Date.now()})}async subscribe(t,r){var n;this.isInitialized();let a=((n=this.subscriber.topicMap.get(t))==null?void 0:n[0])||"";if(a)return a;let u;const f=y=>{y.topic===t&&(this.subscriber.off(vr.created,f),u())};return await Promise.all([new Promise(y=>{u=y,this.subscriber.on(vr.created,f)}),new Promise(async y=>{a=await this.subscriber.subscribe(t,r),y()})]),a}async unsubscribe(t,r){this.isInitialized(),await this.subscriber.unsubscribe(t,r)}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}off(t,r){this.events.off(t,r)}removeListener(t,r){this.events.removeListener(t,r)}async transportClose(){this.transportExplicitlyClosed=!0,this.hasExperiencedNetworkDisruption&&this.connected?await Es(this.provider.disconnect(),1e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.connected&&await this.provider.disconnect()}async transportOpen(t){if(this.transportExplicitlyClosed=!1,await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress){t&&t!==this.relayUrl&&(this.relayUrl=t,await this.transportClose(),await this.createProvider()),this.connectionAttemptInProgress=!0;try{await Promise.all([new Promise(r=>{if(!this.initialized)return r();this.subscriber.once(vr.resubscribed,()=>{r()})}),new Promise(async(r,n)=>{try{await Es(this.provider.connect(),1e4,`Socket stalled when trying to connect to ${this.relayUrl}`)}catch(a){n(a);return}r()})])}catch(r){this.logger.error(r);const n=r;if(!this.isConnectionStalled(n.message))throw r;this.provider.events.emit(Ur.disconnect)}finally{this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1}}}async restartTransport(t){await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress&&(this.relayUrl=t||this.relayUrl,await this.transportClose(),await this.createProvider(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await kh())throw new Error("No internet connection detected. Please restart your network and try again.")}isConnectionStalled(t){return this.staleConnectionErrors.some(r=>t.includes(r))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const t=await this.core.crypto.signJWT(this.relayUrl);this.provider=new kr(new K_(Ww({sdkVersion:$I,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:t,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners()}async recordMessageEvent(t){const{topic:r,message:n}=t;await this.messages.set(r,n)}async shouldIgnoreMessageEvent(t){const{topic:r,message:n}=t;if(!n||n.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${n}`),!0;if(!await this.subscriber.isSubscribed(r))return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`),!0;const a=this.messages.has(r,n);return a&&this.logger.debug(`Ignoring duplicate message: ${n}`),a}async onProviderPayload(t){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:t}),za(t)){if(!t.method.endsWith(RI))return;const r=t.params,{topic:n,message:a,publishedAt:u}=r.data,f={topic:n,message:a,publishedAt:u};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(sx({type:"event",event:r.id},f)),this.events.emit(r.id,f),await this.acknowledgePayload(t),await this.onMessageEvent(f)}else Ln(t)&&this.events.emit(Rt.message_ack,t)}async onMessageEvent(t){await this.shouldIgnoreMessageEvent(t)||(this.events.emit(Rt.message,t),await this.recordMessageEvent(t))}async acknowledgePayload(t){const r=ka(t.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(Ur.payload,this.onPayloadHandler),this.provider.off(Ur.connect,this.onConnectHandler),this.provider.off(Ur.disconnect,this.onDisconnectHandler),this.provider.off(Ur.error,this.onProviderErrorHandler)}async registerEventListeners(){this.events.on(Rt.connection_stalled,()=>{this.restartTransport().catch(r=>this.logger.error(r))});let t=await kh();zb(async r=>{this.initialized&&t!==r&&(t=r,r?await this.restartTransport().catch(n=>this.logger.error(n)):(this.hasExperiencedNetworkDisruption=!0,await this.transportClose().catch(n=>this.logger.error(n))))})}onProviderDisconnect(){this.events.emit(Rt.disconnect),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||(this.logger.info("attemptToReconnect called. Connecting..."),setTimeout(async()=>{await this.restartTransport().catch(t=>this.logger.error(t))},X.toMiliseconds(NI)))}isInitialized(){if(!this.initialized){const{message:t}=V("NOT_INITIALIZED",this.name);throw new Error(t)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectionAttemptInProgress)return await new Promise(t=>{const r=setInterval(()=>{this.connected&&(clearInterval(r),t())},this.connectionStatusPollingInterval)});await this.restartTransport()}}}var ox=Object.defineProperty,yl=Object.getOwnPropertySymbols,ax=Object.prototype.hasOwnProperty,cx=Object.prototype.propertyIsEnumerable,ml=(s,t,r)=>t in s?ox(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,vl=(s,t)=>{for(var r in t||(t={}))ax.call(t,r)&&ml(s,r,t[r]);if(yl)for(var r of yl(t))cx.call(t,r)&&ml(s,r,t[r]);return s};class Vn extends b_{constructor(t,r,n,a=ri,u=void 0){super(t,r,n,a),this.core=t,this.logger=r,this.name=n,this.map=new Map,this.version=AI,this.cached=[],this.initialized=!1,this.storagePrefix=ri,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(f=>{this.getKey&&f!==null&&!Kt(f)?this.map.set(this.getKey(f),f):mb(f)?this.map.set(f.id,f):vb(f)&&this.map.set(f.topic,f)}),this.cached=[],this.initialized=!0)},this.set=async(f,y)=>{this.isInitialized(),this.map.has(f)?await this.update(f,y):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:f,value:y}),this.map.set(f,y),await this.persist())},this.get=f=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:f}),this.getData(f)),this.getAll=f=>(this.isInitialized(),f?this.values.filter(y=>Object.keys(f).every(m=>yw(y[m],f[m]))):this.values),this.update=async(f,y)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:f,update:y});const m=vl(vl({},this.getData(f)),y);this.map.set(f,m),await this.persist()},this.delete=async(f,y)=>{this.isInitialized(),this.map.has(f)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:f,reason:y}),this.map.delete(f),await this.persist())},this.logger=er(r,this.name),this.storagePrefix=a,this.getKey=u}get context(){return Ft(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}async setDataStore(t){await this.core.storage.setItem(this.storageKey,t)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(t){const r=this.map.get(t);if(!r){const{message:n}=V("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(n),new Error(n)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const t=await this.getDataStore();if(typeof t>"u"||!t.length)return;if(this.map.size){const{message:r}=V("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(t){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(t)}}isInitialized(){if(!this.initialized){const{message:t}=V("NOT_INITIALIZED",this.name);throw new Error(t)}}}class ux{constructor(t,r){this.core=t,this.logger=r,this.name=MI,this.version=LI,this.events=new La,this.initialized=!1,this.storagePrefix=ri,this.ignoredPayloadTypes=[mi],this.registeredMethods=[],this.init=async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))},this.register=({methods:n})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...n])]},this.create=async()=>{this.isInitialized();const n=Ia(),a=await this.core.crypto.setSymKey(n),u=wr(X.FIVE_MINUTES),f={protocol:xf},y={topic:a,expiry:u,relay:f,active:!1},m=ab({protocol:this.core.protocol,version:this.core.version,topic:a,symKey:n,relay:f});return await this.pairings.set(a,y),await this.core.relayer.subscribe(a),this.core.expirer.set(a,u),{topic:a,uri:m}},this.pair=async n=>{this.isInitialized(),this.isValidPair(n);const{topic:a,symKey:u,relay:f}=qh(n.uri);let y;if(this.pairings.keys.includes(a)&&(y=this.pairings.get(a),y.active))throw new Error(`Pairing already exists: ${a}. Please try again with a new connection URI.`);const m=wr(X.FIVE_MINUTES),g={topic:a,relay:f,expiry:m,active:!1};return await this.pairings.set(a,g),this.core.expirer.set(a,m),n.activatePairing&&await this.activate({topic:a}),this.events.emit(ws.create,g),this.core.crypto.keychain.has(a)||(await this.core.crypto.setSymKey(u,a),await this.core.relayer.subscribe(a,{relay:f})),g},this.activate=async({topic:n})=>{this.isInitialized();const a=wr(X.THIRTY_DAYS);await this.pairings.update(n,{active:!0,expiry:a}),this.core.expirer.set(n,a)},this.ping=async n=>{this.isInitialized(),await this.isValidPing(n);const{topic:a}=n;if(this.pairings.keys.includes(a)){const u=await this.sendRequest(a,"wc_pairingPing",{}),{done:f,resolve:y,reject:m}=Ui();this.events.once(Je("pairing_ping",u),({error:g})=>{g?m(g):y()}),await f()}},this.updateExpiry=async({topic:n,expiry:a})=>{this.isInitialized(),await this.pairings.update(n,{expiry:a})},this.updateMetadata=async({topic:n,metadata:a})=>{this.isInitialized(),await this.pairings.update(n,{peerMetadata:a})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async n=>{this.isInitialized(),await this.isValidDisconnect(n);const{topic:a}=n;this.pairings.keys.includes(a)&&(await this.sendRequest(a,"wc_pairingDelete",Fe("USER_DISCONNECTED")),await this.deletePairing(a))},this.sendRequest=async(n,a,u)=>{const f=ki(a,u),y=await this.core.crypto.encode(n,f),m=ps[a].req;return this.core.history.set(n,f),this.core.relayer.publish(n,y,m),f.id},this.sendResult=async(n,a,u)=>{const f=ka(n,u),y=await this.core.crypto.encode(a,f),m=await this.core.history.get(a,n),g=ps[m.request.method].res;await this.core.relayer.publish(a,y,g),await this.core.history.resolve(f)},this.sendError=async(n,a,u)=>{const f=Ua(n,u),y=await this.core.crypto.encode(a,f),m=await this.core.history.get(a,n),g=ps[m.request.method]?ps[m.request.method].res:ps.unregistered_method.res;await this.core.relayer.publish(a,y,g),await this.core.history.resolve(f)},this.deletePairing=async(n,a)=>{await this.core.relayer.unsubscribe(n),await Promise.all([this.pairings.delete(n,Fe("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(n),a?Promise.resolve():this.core.expirer.del(n)])},this.cleanup=async()=>{const n=this.pairings.getAll().filter(a=>ti(a.expiry));await Promise.all(n.map(a=>this.deletePairing(a.topic)))},this.onRelayEventRequest=n=>{const{topic:a,payload:u}=n;switch(u.method){case"wc_pairingPing":return this.onPairingPingRequest(a,u);case"wc_pairingDelete":return this.onPairingDeleteRequest(a,u);default:return this.onUnknownRpcMethodRequest(a,u)}},this.onRelayEventResponse=async n=>{const{topic:a,payload:u}=n,f=(await this.core.history.get(a,u.id)).request.method;switch(f){case"wc_pairingPing":return this.onPairingPingResponse(a,u);default:return this.onUnknownRpcMethodResponse(f)}},this.onPairingPingRequest=async(n,a)=>{const{id:u}=a;try{this.isValidPing({topic:n}),await this.sendResult(u,n,!0),this.events.emit(ws.ping,{id:u,topic:n})}catch(f){await this.sendError(u,n,f),this.logger.error(f)}},this.onPairingPingResponse=(n,a)=>{const{id:u}=a;setTimeout(()=>{ei(a)?this.events.emit(Je("pairing_ping",u),{}):Or(a)&&this.events.emit(Je("pairing_ping",u),{error:a.error})},500)},this.onPairingDeleteRequest=async(n,a)=>{const{id:u}=a;try{this.isValidDisconnect({topic:n}),await this.deletePairing(n),this.events.emit(ws.delete,{id:u,topic:n})}catch(f){await this.sendError(u,n,f),this.logger.error(f)}},this.onUnknownRpcMethodRequest=async(n,a)=>{const{id:u,method:f}=a;try{if(this.registeredMethods.includes(f))return;const y=Fe("WC_METHOD_UNSUPPORTED",f);await this.sendError(u,n,y),this.logger.error(y)}catch(y){await this.sendError(u,n,y),this.logger.error(y)}},this.onUnknownRpcMethodResponse=n=>{this.registeredMethods.includes(n)||this.logger.error(Fe("WC_METHOD_UNSUPPORTED",n))},this.isValidPair=n=>{var a;if(!Ht(n)){const{message:f}=V("MISSING_OR_INVALID",`pair() params: ${n}`);throw new Error(f)}if(!yb(n.uri)){const{message:f}=V("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw new Error(f)}const u=qh(n.uri);if(!((a=u==null?void 0:u.relay)!=null&&a.protocol)){const{message:f}=V("MISSING_OR_INVALID","pair() uri#relay-protocol");throw new Error(f)}if(!(u!=null&&u.symKey)){const{message:f}=V("MISSING_OR_INVALID","pair() uri#symKey");throw new Error(f)}},this.isValidPing=async n=>{if(!Ht(n)){const{message:u}=V("MISSING_OR_INVALID",`ping() params: ${n}`);throw new Error(u)}const{topic:a}=n;await this.isValidPairingTopic(a)},this.isValidDisconnect=async n=>{if(!Ht(n)){const{message:u}=V("MISSING_OR_INVALID",`disconnect() params: ${n}`);throw new Error(u)}const{topic:a}=n;await this.isValidPairingTopic(a)},this.isValidPairingTopic=async n=>{if(!wt(n,!1)){const{message:a}=V("MISSING_OR_INVALID",`pairing topic should be a string: ${n}`);throw new Error(a)}if(!this.pairings.keys.includes(n)){const{message:a}=V("NO_MATCHING_KEY",`pairing topic doesn't exist: ${n}`);throw new Error(a)}if(ti(this.pairings.get(n).expiry)){await this.deletePairing(n);const{message:a}=V("EXPIRED",`pairing topic: ${n}`);throw new Error(a)}},this.core=t,this.logger=er(r,this.name),this.pairings=new Vn(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Ft(this.logger)}isInitialized(){if(!this.initialized){const{message:t}=V("NOT_INITIALIZED",this.name);throw new Error(t)}}registerRelayerEvents(){this.core.relayer.on(Rt.message,async t=>{const{topic:r,message:n}=t;if(!this.pairings.keys.includes(r)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))return;const a=await this.core.crypto.decode(r,n);try{za(a)?(this.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a})):Ln(a)&&(await this.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a}),this.core.history.delete(r,a.id))}catch(u){this.logger.error(u)}})}registerExpirerEvents(){this.core.expirer.on(hr.expired,async t=>{const{topic:r}=Yl(t.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit(ws.expire,{topic:r}))})}}class hx extends y_{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.records=new Map,this.events=new br.EventEmitter,this.name=UI,this.version=zI,this.cached=[],this.initialized=!1,this.storagePrefix=ri,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(n,a,u)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:n,request:a,chainId:u}),this.records.has(a.id))return;const f={id:a.id,topic:n,request:{method:a.method,params:a.params||null},chainId:u,expiry:wr(X.THIRTY_DAYS)};this.records.set(f.id,f),this.events.emit(Pr.created,f)},this.resolve=async n=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:n}),!this.records.has(n.id))return;const a=await this.getRecord(n.id);typeof a.response>"u"&&(a.response=Or(n)?{error:n.error}:{result:n.result},this.records.set(a.id,a),this.events.emit(Pr.updated,a))},this.get=async(n,a)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:a}),await this.getRecord(a)),this.delete=(n,a)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:a}),this.values.forEach(u=>{if(u.topic===n){if(typeof a<"u"&&u.id!==a)return;this.records.delete(u.id),this.events.emit(Pr.deleted,u)}})},this.exists=async(n,a)=>(this.isInitialized(),this.records.has(a)?(await this.getRecord(a)).topic===n:!1),this.on=(n,a)=>{this.events.on(n,a)},this.once=(n,a)=>{this.events.once(n,a)},this.off=(n,a)=>{this.events.off(n,a)},this.removeListener=(n,a)=>{this.events.removeListener(n,a)},this.logger=er(r,this.name)}get context(){return Ft(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const t=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const n={topic:r.topic,request:ki(r.request.method,r.request.params,r.id),chainId:r.chainId};return t.push(n)}),t}async setJsonRpcRecords(t){await this.core.storage.setItem(this.storageKey,t)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(t){this.isInitialized();const r=this.records.get(t);if(!r){const{message:n}=V("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(n)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Pr.sync)}async restore(){try{const t=await this.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(this.records.size){const{message:r}=V("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t)}}registerEventListeners(){this.events.on(Pr.created,t=>{const r=Pr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t}),this.persist()}),this.events.on(Pr.updated,t=>{const r=Pr.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t}),this.persist()}),this.events.on(Pr.deleted,t=>{const r=Pr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t}),this.persist()}),this.core.heartbeat.on(Gi.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup()})}cleanup(){try{this.records.forEach(t=>{X.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.delete(t.topic,t.id))})}catch(t){this.logger.warn(t)}}isInitialized(){if(!this.initialized){const{message:t}=V("NOT_INITIALIZED",this.name);throw new Error(t)}}}class lx extends E_{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.expirations=new Map,this.events=new br.EventEmitter,this.name=kI,this.version=HI,this.cached=[],this.initialized=!1,this.storagePrefix=ri,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=n=>{try{const a=this.formatTarget(n);return typeof this.getExpiration(a)<"u"}catch{return!1}},this.set=(n,a)=>{this.isInitialized();const u=this.formatTarget(n),f={target:u,expiry:a};this.expirations.set(u,f),this.checkExpiry(u,f),this.events.emit(hr.created,{target:u,expiration:f})},this.get=n=>{this.isInitialized();const a=this.formatTarget(n);return this.getExpiration(a)},this.del=n=>{if(this.isInitialized(),this.has(n)){const a=this.formatTarget(n),u=this.getExpiration(a);this.expirations.delete(a),this.events.emit(hr.deleted,{target:a,expiration:u})}},this.on=(n,a)=>{this.events.on(n,a)},this.once=(n,a)=>{this.events.once(n,a)},this.off=(n,a)=>{this.events.off(n,a)},this.removeListener=(n,a)=>{this.events.removeListener(n,a)},this.logger=er(r,this.name)}get context(){return Ft(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(t){if(typeof t=="string")return Jw(t);if(typeof t=="number")return Qw(t);const{message:r}=V("UNKNOWN_TYPE",`Target type: ${typeof t}`);throw new Error(r)}async setExpirations(t){await this.core.storage.setItem(this.storageKey,t)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(hr.sync)}async restore(){try{const t=await this.getExpirations();if(typeof t>"u"||!t.length)return;if(this.expirations.size){const{message:r}=V("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(t){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(t)}}getExpiration(t){const r=this.expirations.get(t);if(!r){const{message:n}=V("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(n),new Error(n)}return r}checkExpiry(t,r){const{expiry:n}=r;X.toMiliseconds(n)-Date.now()<=0&&this.expire(t,r)}expire(t,r){this.expirations.delete(t),this.events.emit(hr.expired,{target:t,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((t,r)=>this.checkExpiry(r,t))}registerEventListeners(){this.core.heartbeat.on(Gi.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(hr.created,t=>{const r=hr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist()}),this.events.on(hr.expired,t=>{const r=hr.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist()}),this.events.on(hr.deleted,t=>{const r=hr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist()})}isInitialized(){if(!this.initialized){const{message:t}=V("NOT_INITIALIZED",this.name);throw new Error(t)}}}class fx extends I_{constructor(t,r){super(t,r),this.projectId=t,this.logger=r,this.name=fa,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async n=>{if(this.verifyDisabled||Vi()||!Fi())return;const a=this.getVerifyUrl(n==null?void 0:n.verifyUrl);this.verifyUrl!==a&&this.removeIframe(),this.verifyUrl=a;try{await this.createIframe()}catch(u){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(u)}if(!this.initialized){this.removeIframe(),this.verifyUrl=Aa;try{await this.createIframe()}catch(u){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(u),this.verifyDisabled=!0}}},this.register=async n=>{this.initialized?this.sendPost(n.attestationId):(this.addToQueue(n.attestationId),await this.init())},this.resolve=async n=>{if(this.isDevEnv)return"";const a=this.getVerifyUrl(n==null?void 0:n.verifyUrl);let u;try{u=await this.fetchAttestation(n.attestationId,a)}catch(f){this.logger.info(`failed to resolve attestation: ${n.attestationId} from url: ${a}`),this.logger.info(f),u=await this.fetchAttestation(n.attestationId,Aa)}return u},this.fetchAttestation=async(n,a)=>{this.logger.info(`resolving attestation: ${n} from url: ${a}`);const u=this.startAbortTimer(X.ONE_SECOND*2),f=await fetch(`${a}/attestation/${n}`,{signal:this.abortController.signal});return clearTimeout(u),f.status===200?await f.json():void 0},this.addToQueue=n=>{this.queue.push(n)},this.processQueue=()=>{this.queue.length!==0&&(this.queue.forEach(n=>this.sendPost(n)),this.queue=[])},this.sendPost=n=>{var a;try{if(!this.iframe)return;(a=this.iframe.contentWindow)==null||a.postMessage(n,"*"),this.logger.info(`postMessage sent: ${n} ${this.verifyUrl}`)}catch{}},this.createIframe=async()=>{let n;const a=u=>{u.data==="verify_ready"&&(this.initialized=!0,this.processQueue(),window.removeEventListener("message",a),n())};await Promise.race([new Promise(u=>{if(document.getElementById(fa))return u();window.addEventListener("message",a);const f=document.createElement("iframe");f.id=fa,f.src=`${this.verifyUrl}/${this.projectId}`,f.style.display="none",document.body.append(f),this.iframe=f,n=u}),new Promise((u,f)=>setTimeout(()=>{window.removeEventListener("message",a),f("verify iframe load timeout")},X.toMiliseconds(X.FIVE_SECONDS)))])},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1)},this.getVerifyUrl=n=>{let a=n||zi;return KI.includes(a)||(this.logger.info(`verify url: ${a}, not included in trusted list, assigning default: ${zi}`),a=zi),a},this.logger=er(r,this.name),this.verifyUrl=zi,this.abortController=new AbortController,this.isDevEnv=Fa()&&V_.IS_VITEST}get context(){return Ft(this.logger)}startAbortTimer(t){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),X.toMiliseconds(t))}}var px=Object.defineProperty,wl=Object.getOwnPropertySymbols,dx=Object.prototype.hasOwnProperty,gx=Object.prototype.propertyIsEnumerable,bl=(s,t,r)=>t in s?px(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,_l=(s,t)=>{for(var r in t||(t={}))dx.call(t,r)&&bl(s,r,t[r]);if(wl)for(var r of wl(t))gx.call(t,r)&&bl(s,r,t[r]);return s};class Qa extends g_{constructor(t){super(t),this.protocol=If,this.version=gI,this.name=Ja,this.events=new br.EventEmitter,this.initialized=!1,this.on=(n,a)=>this.events.on(n,a),this.once=(n,a)=>this.events.once(n,a),this.off=(n,a)=>this.events.off(n,a),this.removeListener=(n,a)=>this.events.removeListener(n,a),this.projectId=t==null?void 0:t.projectId,this.relayUrl=(t==null?void 0:t.relayUrl)||Sf,this.customStoragePrefix=t!=null&&t.customStoragePrefix?`:${t.customStoragePrefix}`:"";const r=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:kn(Hn({level:(t==null?void 0:t.logger)||yI.logger}));this.logger=er(r,this.name),this.heartbeat=new Gi.HeartBeat,this.crypto=new FI(this,this.logger,t==null?void 0:t.keychain),this.history=new hx(this,this.logger),this.expirer=new lx(this,this.logger),this.storage=t!=null&&t.storage?t.storage:new v1(_l(_l({},mI),t==null?void 0:t.storageOptions)),this.relayer=new nx({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new ux(this,this.logger),this.verify=new fx(this.projectId||"",this.logger)}static async init(t){const r=new Qa(t);await r.initialize();const n=await r.crypto.getClientId();return await r.storage.setItem(TI,n),r}get context(){return Ft(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success")}catch(t){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,t),this.logger.error(t.message),t}}}const yx=Qa,Pf="wc",Of=2,Rf="client",Ya=`${Pf}@${Of}:${Rf}:`,da={name:Rf,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},El="WALLETCONNECT_DEEPLINK_CHOICE",mx="proposal",Nf="Proposal expired",vx="session",Sn=X.SEVEN_DAYS,wx="engine",gs={wc_sessionPropose:{req:{ttl:X.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:X.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:X.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:X.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:X.ONE_DAY,prompt:!1,tag:1104},res:{ttl:X.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:X.ONE_DAY,prompt:!1,tag:1106},res:{ttl:X.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:X.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:X.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:X.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:X.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:X.ONE_DAY,prompt:!1,tag:1112},res:{ttl:X.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:X.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:X.THIRTY_SECONDS,prompt:!1,tag:1115}}},ga={min:X.FIVE_MINUTES,max:X.SEVEN_DAYS},zr={idle:"IDLE",active:"ACTIVE"},bx="request",_x=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var Ex=Object.defineProperty,Ix=Object.defineProperties,xx=Object.getOwnPropertyDescriptors,Il=Object.getOwnPropertySymbols,Sx=Object.prototype.hasOwnProperty,Px=Object.prototype.propertyIsEnumerable,xl=(s,t,r)=>t in s?Ex(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,zt=(s,t)=>{for(var r in t||(t={}))Sx.call(t,r)&&xl(s,r,t[r]);if(Il)for(var r of Il(t))Px.call(t,r)&&xl(s,r,t[r]);return s},ys=(s,t)=>Ix(s,xx(t));class Ox extends S_{constructor(t){super(t),this.name=wx,this.events=new La,this.initialized=!1,this.ignoredPayloadTypes=[mi],this.requestQueue={state:zr.idle,queue:[]},this.sessionRequestQueue={state:zr.idle,queue:[]},this.requestQueueDelay=X.ONE_SECOND,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(gs)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},X.toMiliseconds(this.requestQueueDelay)))},this.connect=async r=>{await this.isInitialized();const n=ys(zt({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(n);const{pairingTopic:a,requiredNamespaces:u,optionalNamespaces:f,sessionProperties:y,relays:m}=n;let g=a,w,_=!1;if(g&&(_=this.client.core.pairing.pairings.get(g).active),!g||!_){const{topic:$,uri:C}=await this.client.core.pairing.create();g=$,w=C}const O=await this.client.core.crypto.generateKeyPair(),j=zt({requiredNamespaces:u,optionalNamespaces:f,relays:m??[{protocol:xf}],proposer:{publicKey:O,metadata:this.client.metadata}},y&&{sessionProperties:y}),{reject:N,resolve:ee,done:ne}=Ui(X.FIVE_MINUTES,Nf);if(this.events.once(Je("session_connect"),async({error:$,session:C})=>{if($)N($);else if(C){C.self.publicKey=O;const q=ys(zt({},C),{requiredNamespaces:C.requiredNamespaces,optionalNamespaces:C.optionalNamespaces});await this.client.session.set(C.topic,q),await this.setExpiry(C.topic,C.expiry),g&&await this.client.core.pairing.updateMetadata({topic:g,metadata:C.peer.metadata}),ee(q)}}),!g){const{message:$}=V("NO_MATCHING_KEY",`connect() pairing topic: ${g}`);throw new Error($)}const oe=await this.sendRequest({topic:g,method:"wc_sessionPropose",params:j}),P=wr(X.FIVE_MINUTES);return await this.setProposal(oe,zt({id:oe,expiry:P},j)),{uri:w,approval:ne}},this.pair=async r=>(await this.isInitialized(),await this.client.core.pairing.pair(r)),this.approve=async r=>{await this.isInitialized(),await this.isValidApprove(r);const{id:n,relayProtocol:a,namespaces:u,sessionProperties:f}=r,y=this.client.proposal.get(n);let{pairingTopic:m,proposer:g,requiredNamespaces:w,optionalNamespaces:_}=y;m=m||"",Ki(w)||(w=lb(u,"approve()"));const O=await this.client.core.crypto.generateKeyPair(),j=g.publicKey,N=await this.client.core.crypto.generateSharedKey(O,j);m&&n&&(await this.client.core.pairing.updateMetadata({topic:m,metadata:g.metadata}),await this.sendResult({id:n,topic:m,result:{relay:{protocol:a??"irn"},responderPublicKey:O}}),await this.client.proposal.delete(n,Fe("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:m}));const ee=zt({relay:{protocol:a??"irn"},namespaces:u,requiredNamespaces:w,optionalNamespaces:_,pairingTopic:m,controller:{publicKey:O,metadata:this.client.metadata},expiry:wr(Sn)},f&&{sessionProperties:f});await this.client.core.relayer.subscribe(N),await this.sendRequest({topic:N,method:"wc_sessionSettle",params:ee,throwOnFailedPublish:!0});const ne=ys(zt({},ee),{topic:N,pairingTopic:m,acknowledged:!1,self:ee.controller,peer:{publicKey:g.publicKey,metadata:g.metadata},controller:O});return await this.client.session.set(N,ne),await this.setExpiry(N,wr(Sn)),{topic:N,acknowledged:()=>new Promise(oe=>setTimeout(()=>oe(this.client.session.get(N)),500))}},this.reject=async r=>{await this.isInitialized(),await this.isValidReject(r);const{id:n,reason:a}=r,{pairingTopic:u}=this.client.proposal.get(n);u&&(await this.sendError(n,u,a),await this.client.proposal.delete(n,Fe("USER_DISCONNECTED")))},this.update=async r=>{await this.isInitialized(),await this.isValidUpdate(r);const{topic:n,namespaces:a}=r,u=await this.sendRequest({topic:n,method:"wc_sessionUpdate",params:{namespaces:a}}),{done:f,resolve:y,reject:m}=Ui();return this.events.once(Je("session_update",u),({error:g})=>{g?m(g):y()}),await this.client.session.update(n,{namespaces:a}),{acknowledged:f}},this.extend=async r=>{await this.isInitialized(),await this.isValidExtend(r);const{topic:n}=r,a=await this.sendRequest({topic:n,method:"wc_sessionExtend",params:{}}),{done:u,resolve:f,reject:y}=Ui();return this.events.once(Je("session_extend",a),({error:m})=>{m?y(m):f()}),await this.setExpiry(n,wr(Sn)),{acknowledged:u}},this.request=async r=>{await this.isInitialized(),await this.isValidRequest(r);const{chainId:n,request:a,topic:u,expiry:f}=r,y=Iw(),{done:m,resolve:g,reject:w}=Ui(f,"Request expired. Please try again.");return this.events.once(Je("session_request",y),({error:_,result:O})=>{_?w(_):g(O)}),await Promise.all([new Promise(async _=>{await this.sendRequest({clientRpcId:y,topic:u,method:"wc_sessionRequest",params:{request:a,chainId:n},expiry:f,throwOnFailedPublish:!0}).catch(O=>w(O)),this.client.events.emit("session_request_sent",{topic:u,request:a,chainId:n,id:y}),_()}),new Promise(async _=>{const O=await Zw(this.client.core.storage,El);Yw({id:y,topic:u,wcDeepLink:O}),_()}),m()]).then(_=>_[2])},this.respond=async r=>{await this.isInitialized(),await this.isValidRespond(r);const{topic:n,response:a}=r,{id:u}=a;ei(a)?await this.sendResult({id:u,topic:n,result:a.result,throwOnFailedPublish:!0}):Or(a)&&await this.sendError(u,n,a.error),this.cleanupAfterResponse(r)},this.ping=async r=>{await this.isInitialized(),await this.isValidPing(r);const{topic:n}=r;if(this.client.session.keys.includes(n)){const a=await this.sendRequest({topic:n,method:"wc_sessionPing",params:{}}),{done:u,resolve:f,reject:y}=Ui();this.events.once(Je("session_ping",a),({error:m})=>{m?y(m):f()}),await u()}else this.client.core.pairing.pairings.keys.includes(n)&&await this.client.core.pairing.ping({topic:n})},this.emit=async r=>{await this.isInitialized(),await this.isValidEmit(r);const{topic:n,event:a,chainId:u}=r;await this.sendRequest({topic:n,method:"wc_sessionEvent",params:{event:a,chainId:u}})},this.disconnect=async r=>{await this.isInitialized(),await this.isValidDisconnect(r);const{topic:n}=r;this.client.session.keys.includes(n)?(await this.sendRequest({topic:n,method:"wc_sessionDelete",params:Fe("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession(n)):await this.client.core.pairing.disconnect({topic:n})},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(n=>db(n,r))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async r=>{if(r.pairingTopic)try{const n=this.client.core.pairing.pairings.get(r.pairingTopic),a=this.client.core.pairing.pairings.getAll().filter(u=>{var f,y;return((f=u.peerMetadata)==null?void 0:f.url)&&((y=u.peerMetadata)==null?void 0:y.url)===r.peer.metadata.url&&u.topic&&u.topic!==n.topic});if(a.length===0)return;this.client.logger.info(`Cleaning up ${a.length} duplicate pairing(s)`),await Promise.all(a.map(u=>this.client.core.pairing.disconnect({topic:u.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(n){this.client.logger.error(n)}},this.deleteSession=async(r,n)=>{const{self:a}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),this.client.session.delete(r,Fe("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(a.publicKey)&&await this.client.core.crypto.deleteKeyPair(a.publicKey),this.client.core.crypto.keychain.has(r)&&await this.client.core.crypto.deleteSymKey(r),n||this.client.core.expirer.del(r),this.client.core.storage.removeItem(El).catch(u=>this.client.logger.warn(u))},this.deleteProposal=async(r,n)=>{await Promise.all([this.client.proposal.delete(r,Fe("USER_DISCONNECTED")),n?Promise.resolve():this.client.core.expirer.del(r)])},this.deletePendingSessionRequest=async(r,n,a=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,n),a?Promise.resolve():this.client.core.expirer.del(r)]),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(u=>u.id!==r),a&&(this.sessionRequestQueue.state=zr.idle)},this.setExpiry=async(r,n)=>{this.client.session.keys.includes(r)&&await this.client.session.update(r,{expiry:n}),this.client.core.expirer.set(r,n)},this.setProposal=async(r,n)=>{await this.client.proposal.set(r,n),this.client.core.expirer.set(r,n.expiry)},this.setPendingSessionRequest=async r=>{const n=gs.wc_sessionRequest.req.ttl,{id:a,topic:u,params:f,verifyContext:y}=r;await this.client.pendingRequest.set(a,{id:a,topic:u,params:f,verifyContext:y}),n&&this.client.core.expirer.set(a,wr(n))},this.sendRequest=async r=>{const{topic:n,method:a,params:u,expiry:f,relayRpcId:y,clientRpcId:m,throwOnFailedPublish:g}=r,w=ki(a,u,m);if(Fi()&&_x.includes(a)){const j=Hi(JSON.stringify(w));this.client.core.verify.register({attestationId:j})}const _=await this.client.core.crypto.encode(n,w),O=gs[a].req;return f&&(O.ttl=f),y&&(O.id=y),this.client.core.history.set(n,w),g?(O.internal=ys(zt({},O.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,_,O)):this.client.core.relayer.publish(n,_,O).catch(j=>this.client.logger.error(j)),w.id},this.sendResult=async r=>{const{id:n,topic:a,result:u,throwOnFailedPublish:f}=r,y=ka(n,u),m=await this.client.core.crypto.encode(a,y),g=await this.client.core.history.get(a,n),w=gs[g.request.method].res;f?(w.internal=ys(zt({},w.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(a,m,w)):this.client.core.relayer.publish(a,m,w).catch(_=>this.client.logger.error(_)),await this.client.core.history.resolve(y)},this.sendError=async(r,n,a)=>{const u=Ua(r,a),f=await this.client.core.crypto.encode(n,u),y=await this.client.core.history.get(n,r),m=gs[y.request.method].res;this.client.core.relayer.publish(n,f,m),await this.client.core.history.resolve(u)},this.cleanup=async()=>{const r=[],n=[];this.client.session.getAll().forEach(a=>{ti(a.expiry)&&r.push(a.topic)}),this.client.proposal.getAll().forEach(a=>{ti(a.expiry)&&n.push(a.id)}),await Promise.all([...r.map(a=>this.deleteSession(a)),...n.map(a=>this.deleteProposal(a))])},this.onRelayEventRequest=async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===zr.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=zr.active;const r=this.requestQueue.queue.shift();if(r)try{this.processRequest(r),await new Promise(n=>setTimeout(n,300))}catch(n){this.client.logger.warn(n)}}this.requestQueue.state=zr.idle},this.processRequest=r=>{const{topic:n,payload:a}=r,u=a.method;switch(u){case"wc_sessionPropose":return this.onSessionProposeRequest(n,a);case"wc_sessionSettle":return this.onSessionSettleRequest(n,a);case"wc_sessionUpdate":return this.onSessionUpdateRequest(n,a);case"wc_sessionExtend":return this.onSessionExtendRequest(n,a);case"wc_sessionPing":return this.onSessionPingRequest(n,a);case"wc_sessionDelete":return this.onSessionDeleteRequest(n,a);case"wc_sessionRequest":return this.onSessionRequest(n,a);case"wc_sessionEvent":return this.onSessionEventRequest(n,a);default:return this.client.logger.info(`Unsupported request method ${u}`)}},this.onRelayEventResponse=async r=>{const{topic:n,payload:a}=r,u=(await this.client.core.history.get(n,a.id)).request.method;switch(u){case"wc_sessionPropose":return this.onSessionProposeResponse(n,a);case"wc_sessionSettle":return this.onSessionSettleResponse(n,a);case"wc_sessionUpdate":return this.onSessionUpdateResponse(n,a);case"wc_sessionExtend":return this.onSessionExtendResponse(n,a);case"wc_sessionPing":return this.onSessionPingResponse(n,a);case"wc_sessionRequest":return this.onSessionRequestResponse(n,a);default:return this.client.logger.info(`Unsupported response method ${u}`)}},this.onRelayEventUnknownPayload=r=>{const{topic:n}=r,{message:a}=V("MISSING_OR_INVALID",`Decoded payload on topic ${n} is not identifiable as a JSON-RPC request or a response.`);throw new Error(a)},this.onSessionProposeRequest=async(r,n)=>{const{params:a,id:u}=n;try{this.isValidConnect(zt({},n.params));const f=wr(X.FIVE_MINUTES),y=zt({id:u,pairingTopic:r,expiry:f},a);await this.setProposal(u,y);const m=Hi(JSON.stringify(n)),g=await this.getVerifyContext(m,y.proposer.metadata);this.client.events.emit("session_proposal",{id:u,params:y,verifyContext:g})}catch(f){await this.sendError(u,r,f),this.client.logger.error(f)}},this.onSessionProposeResponse=async(r,n)=>{const{id:a}=n;if(ei(n)){const{result:u}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:u});const f=this.client.proposal.get(a);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:f});const y=f.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:y});const m=u.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:m});const g=await this.client.core.crypto.generateSharedKey(y,m);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:g});const w=await this.client.core.relayer.subscribe(g);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:w}),await this.client.core.pairing.activate({topic:r})}else Or(n)&&(await this.client.proposal.delete(a,Fe("USER_DISCONNECTED")),this.events.emit(Je("session_connect"),{error:n.error}))},this.onSessionSettleRequest=async(r,n)=>{const{id:a,params:u}=n;try{this.isValidSessionSettleRequest(u);const{relay:f,controller:y,expiry:m,namespaces:g,requiredNamespaces:w,optionalNamespaces:_,sessionProperties:O,pairingTopic:j}=n.params,N=zt({topic:r,relay:f,expiry:m,namespaces:g,acknowledged:!0,pairingTopic:j,requiredNamespaces:w,optionalNamespaces:_,controller:y.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:y.publicKey,metadata:y.metadata}},O&&{sessionProperties:O});await this.sendResult({id:n.id,topic:r,result:!0}),this.events.emit(Je("session_connect"),{session:N}),this.cleanupDuplicatePairings(N)}catch(f){await this.sendError(a,r,f),this.client.logger.error(f)}},this.onSessionSettleResponse=async(r,n)=>{const{id:a}=n;ei(n)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(Je("session_approve",a),{})):Or(n)&&(await this.client.session.delete(r,Fe("USER_DISCONNECTED")),this.events.emit(Je("session_approve",a),{error:n.error}))},this.onSessionUpdateRequest=async(r,n)=>{const{params:a,id:u}=n;try{const f=`${r}_session_update`,y=_n.get(f);if(y&&this.isRequestOutOfSync(y,u)){this.client.logger.info(`Discarding out of sync request - ${u}`);return}this.isValidUpdate(zt({topic:r},a)),await this.client.session.update(r,{namespaces:a.namespaces}),await this.sendResult({id:u,topic:r,result:!0}),this.client.events.emit("session_update",{id:u,topic:r,params:a}),_n.set(f,u)}catch(f){await this.sendError(u,r,f),this.client.logger.error(f)}},this.isRequestOutOfSync=(r,n)=>parseInt(n.toString().slice(0,-3))<=parseInt(r.toString().slice(0,-3)),this.onSessionUpdateResponse=(r,n)=>{const{id:a}=n;ei(n)?this.events.emit(Je("session_update",a),{}):Or(n)&&this.events.emit(Je("session_update",a),{error:n.error})},this.onSessionExtendRequest=async(r,n)=>{const{id:a}=n;try{this.isValidExtend({topic:r}),await this.setExpiry(r,wr(Sn)),await this.sendResult({id:a,topic:r,result:!0}),this.client.events.emit("session_extend",{id:a,topic:r})}catch(u){await this.sendError(a,r,u),this.client.logger.error(u)}},this.onSessionExtendResponse=(r,n)=>{const{id:a}=n;ei(n)?this.events.emit(Je("session_extend",a),{}):Or(n)&&this.events.emit(Je("session_extend",a),{error:n.error})},this.onSessionPingRequest=async(r,n)=>{const{id:a}=n;try{this.isValidPing({topic:r}),await this.sendResult({id:a,topic:r,result:!0}),this.client.events.emit("session_ping",{id:a,topic:r})}catch(u){await this.sendError(a,r,u),this.client.logger.error(u)}},this.onSessionPingResponse=(r,n)=>{const{id:a}=n;setTimeout(()=>{ei(n)?this.events.emit(Je("session_ping",a),{}):Or(n)&&this.events.emit(Je("session_ping",a),{error:n.error})},500)},this.onSessionDeleteRequest=async(r,n)=>{const{id:a}=n;try{this.isValidDisconnect({topic:r,reason:n.params}),await Promise.all([new Promise(u=>{this.client.core.relayer.once(Rt.publish,async()=>{u(await this.deleteSession(r))})}),this.sendResult({id:a,topic:r,result:!0})]),this.client.events.emit("session_delete",{id:a,topic:r})}catch(u){this.client.logger.error(u)}},this.onSessionRequest=async(r,n)=>{const{id:a,params:u}=n;try{this.isValidRequest(zt({topic:r},u));const f=Hi(JSON.stringify(ki("wc_sessionRequest",u,a))),y=this.client.session.get(r),m=await this.getVerifyContext(f,y.peer.metadata),g={id:a,topic:r,params:u,verifyContext:m};await this.setPendingSessionRequest(g),this.addSessionRequestToSessionRequestQueue(g),this.processSessionRequestQueue()}catch(f){await this.sendError(a,r,f),this.client.logger.error(f)}},this.onSessionRequestResponse=(r,n)=>{const{id:a}=n;ei(n)?this.events.emit(Je("session_request",a),{result:n.result}):Or(n)&&this.events.emit(Je("session_request",a),{error:n.error})},this.onSessionEventRequest=async(r,n)=>{const{id:a,params:u}=n;try{const f=`${r}_session_event_${u.event.name}`,y=_n.get(f);if(y&&this.isRequestOutOfSync(y,a)){this.client.logger.info(`Discarding out of sync request - ${a}`);return}this.isValidEmit(zt({topic:r},u)),this.client.events.emit("session_event",{id:a,topic:r,params:u}),_n.set(f,a)}catch(f){await this.sendError(a,r,f),this.client.logger.error(f)}},this.addSessionRequestToSessionRequestQueue=r=>{this.sessionRequestQueue.queue.push(r)},this.cleanupAfterResponse=r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=zr.idle,this.processSessionRequestQueue()},X.toMiliseconds(this.requestQueueDelay))},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===zr.active){this.client.logger.info("session request queue is already active.");return}const r=this.sessionRequestQueue.queue[0];if(!r){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=zr.active,this.client.events.emit("session_request",r)}catch(n){this.client.logger.error(n)}},this.onPairingCreated=r=>{if(r.active)return;const n=this.client.proposal.getAll().find(a=>a.pairingTopic===r.topic);n&&this.onSessionProposeRequest(r.topic,ki("wc_sessionPropose",{requiredNamespaces:n.requiredNamespaces,optionalNamespaces:n.optionalNamespaces,relays:n.relays,proposer:n.proposer,sessionProperties:n.sessionProperties},n.id))},this.isValidConnect=async r=>{if(!Ht(r)){const{message:m}=V("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(m)}const{pairingTopic:n,requiredNamespaces:a,optionalNamespaces:u,sessionProperties:f,relays:y}=r;if(Kt(n)||await this.isValidPairingTopic(n),!Pb(y)){const{message:m}=V("MISSING_OR_INVALID",`connect() relays: ${y}`);throw new Error(m)}!Kt(a)&&Ki(a)!==0&&this.validateNamespaces(a,"requiredNamespaces"),!Kt(u)&&Ki(u)!==0&&this.validateNamespaces(u,"optionalNamespaces"),Kt(f)||this.validateSessionProps(f,"sessionProperties")},this.validateNamespaces=(r,n)=>{const a=Sb(r,"connect()",n);if(a)throw new Error(a.message)},this.isValidApprove=async r=>{if(!Ht(r))throw new Error(V("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:n,namespaces:a,relayProtocol:u,sessionProperties:f}=r;await this.isValidProposalId(n);const y=this.client.proposal.get(n),m=Nn(a,"approve()");if(m)throw new Error(m.message);const g=Uh(y.requiredNamespaces,a,"approve()");if(g)throw new Error(g.message);if(!wt(u,!0)){const{message:w}=V("MISSING_OR_INVALID",`approve() relayProtocol: ${u}`);throw new Error(w)}Kt(f)||this.validateSessionProps(f,"sessionProperties")},this.isValidReject=async r=>{if(!Ht(r)){const{message:u}=V("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(u)}const{id:n,reason:a}=r;if(await this.isValidProposalId(n),!Rb(a)){const{message:u}=V("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(a)}`);throw new Error(u)}},this.isValidSessionSettleRequest=r=>{if(!Ht(r)){const{message:g}=V("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(g)}const{relay:n,controller:a,namespaces:u,expiry:f}=r;if(!Xl(n)){const{message:g}=V("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(g)}const y=wb(a,"onSessionSettleRequest()");if(y)throw new Error(y.message);const m=Nn(u,"onSessionSettleRequest()");if(m)throw new Error(m.message);if(ti(f)){const{message:g}=V("EXPIRED","onSessionSettleRequest()");throw new Error(g)}},this.isValidUpdate=async r=>{if(!Ht(r)){const{message:m}=V("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(m)}const{topic:n,namespaces:a}=r;await this.isValidSessionTopic(n);const u=this.client.session.get(n),f=Nn(a,"update()");if(f)throw new Error(f.message);const y=Uh(u.requiredNamespaces,a,"update()");if(y)throw new Error(y.message)},this.isValidExtend=async r=>{if(!Ht(r)){const{message:a}=V("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(a)}const{topic:n}=r;await this.isValidSessionTopic(n)},this.isValidRequest=async r=>{if(!Ht(r)){const{message:m}=V("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(m)}const{topic:n,request:a,chainId:u,expiry:f}=r;await this.isValidSessionTopic(n);const{namespaces:y}=this.client.session.get(n);if(!Lh(y,u)){const{message:m}=V("MISSING_OR_INVALID",`request() chainId: ${u}`);throw new Error(m)}if(!Nb(a)){const{message:m}=V("MISSING_OR_INVALID",`request() ${JSON.stringify(a)}`);throw new Error(m)}if(!Ab(y,u,a.method)){const{message:m}=V("MISSING_OR_INVALID",`request() method: ${a.method}`);throw new Error(m)}if(f&&!qb(f,ga)){const{message:m}=V("MISSING_OR_INVALID",`request() expiry: ${f}. Expiry must be a number (in seconds) between ${ga.min} and ${ga.max}`);throw new Error(m)}},this.isValidRespond=async r=>{if(!Ht(r)){const{message:u}=V("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(u)}const{topic:n,response:a}=r;if(await this.isValidSessionTopic(n),!$b(a)){const{message:u}=V("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(a)}`);throw new Error(u)}},this.isValidPing=async r=>{if(!Ht(r)){const{message:a}=V("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(a)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)},this.isValidEmit=async r=>{if(!Ht(r)){const{message:y}=V("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(y)}const{topic:n,event:a,chainId:u}=r;await this.isValidSessionTopic(n);const{namespaces:f}=this.client.session.get(n);if(!Lh(f,u)){const{message:y}=V("MISSING_OR_INVALID",`emit() chainId: ${u}`);throw new Error(y)}if(!Cb(a)){const{message:y}=V("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(a)}`);throw new Error(y)}if(!Tb(f,u,a.name)){const{message:y}=V("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(a)}`);throw new Error(y)}},this.isValidDisconnect=async r=>{if(!Ht(r)){const{message:a}=V("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(a)}const{topic:n}=r;await this.isValidSessionOrPairingTopic(n)},this.getVerifyContext=async(r,n)=>{const a={verified:{verifyUrl:n.verifyUrl||zi,validation:"UNKNOWN",origin:n.url||""}};try{const u=await this.client.core.verify.resolve({attestationId:r,verifyUrl:n.verifyUrl});u&&(a.verified.origin=u.origin,a.verified.isScam=u.isScam,a.verified.validation=u.origin===new URL(n.url).origin?"VALID":"INVALID")}catch(u){this.client.logger.info(u)}return this.client.logger.info(`Verify context: ${JSON.stringify(a)}`),a},this.validateSessionProps=(r,n)=>{Object.values(r).forEach(a=>{if(!wt(a,!1)){const{message:u}=V("MISSING_OR_INVALID",`${n} must be in Record<string, string> format. Received: ${JSON.stringify(a)}`);throw new Error(u)}})}}async isInitialized(){if(!this.initialized){const{message:t}=V("NOT_INITIALIZED",this.name);throw new Error(t)}await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Rt.message,async t=>{const{topic:r,message:n}=t;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(n)))return;const a=await this.client.core.crypto.decode(r,n);try{za(a)?(this.client.core.history.set(r,a),this.onRelayEventRequest({topic:r,payload:a})):Ln(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:r,payload:a}),this.client.core.history.delete(r,a.id)):this.onRelayEventUnknownPayload({topic:r,payload:a})}catch(u){this.client.logger.error(u)}})}registerExpirerEvents(){this.client.core.expirer.on(hr.expired,async t=>{const{topic:r,id:n}=Yl(t.target);if(n&&this.client.pendingRequest.keys.includes(n))return await this.deletePendingSessionRequest(n,V("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession(r,!0),this.client.events.emit("session_expire",{topic:r})):n&&(await this.deleteProposal(n,!0),this.client.events.emit("proposal_expire",{id:n}))})}registerPairingEvents(){this.client.core.pairing.events.on(ws.create,t=>this.onPairingCreated(t))}isValidPairingTopic(t){if(!wt(t,!1)){const{message:r}=V("MISSING_OR_INVALID",`pairing topic should be a string: ${t}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:r}=V("NO_MATCHING_KEY",`pairing topic doesn't exist: ${t}`);throw new Error(r)}if(ti(this.client.core.pairing.pairings.get(t).expiry)){const{message:r}=V("EXPIRED",`pairing topic: ${t}`);throw new Error(r)}}async isValidSessionTopic(t){if(!wt(t,!1)){const{message:r}=V("MISSING_OR_INVALID",`session topic should be a string: ${t}`);throw new Error(r)}if(!this.client.session.keys.includes(t)){const{message:r}=V("NO_MATCHING_KEY",`session topic doesn't exist: ${t}`);throw new Error(r)}if(ti(this.client.session.get(t).expiry)){await this.deleteSession(t);const{message:r}=V("EXPIRED",`session topic: ${t}`);throw new Error(r)}}async isValidSessionOrPairingTopic(t){if(this.client.session.keys.includes(t))await this.isValidSessionTopic(t);else if(this.client.core.pairing.pairings.keys.includes(t))this.isValidPairingTopic(t);else if(wt(t,!1)){const{message:r}=V("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${t}`);throw new Error(r)}else{const{message:r}=V("MISSING_OR_INVALID",`session or pairing topic should be a string: ${t}`);throw new Error(r)}}async isValidProposalId(t){if(!Ob(t)){const{message:r}=V("MISSING_OR_INVALID",`proposal id should be a number: ${t}`);throw new Error(r)}if(!this.client.proposal.keys.includes(t)){const{message:r}=V("NO_MATCHING_KEY",`proposal id doesn't exist: ${t}`);throw new Error(r)}if(ti(this.client.proposal.get(t).expiry)){await this.deleteProposal(t);const{message:r}=V("EXPIRED",`proposal id: ${t}`);throw new Error(r)}}}class Rx extends Vn{constructor(t,r){super(t,r,mx,Ya),this.core=t,this.logger=r}}class Nx extends Vn{constructor(t,r){super(t,r,vx,Ya),this.core=t,this.logger=r}}class $x extends Vn{constructor(t,r){super(t,r,bx,Ya,n=>n.id),this.core=t,this.logger=r}}let Cx=class $f extends x_{constructor(t){super(t),this.protocol=Pf,this.version=Of,this.name=da.name,this.events=new br.EventEmitter,this.on=(n,a)=>this.events.on(n,a),this.once=(n,a)=>this.events.once(n,a),this.off=(n,a)=>this.events.off(n,a),this.removeListener=(n,a)=>this.events.removeListener(n,a),this.removeAllListeners=n=>this.events.removeAllListeners(n),this.connect=async n=>{try{return await this.engine.connect(n)}catch(a){throw this.logger.error(a.message),a}},this.pair=async n=>{try{return await this.engine.pair(n)}catch(a){throw this.logger.error(a.message),a}},this.approve=async n=>{try{return await this.engine.approve(n)}catch(a){throw this.logger.error(a.message),a}},this.reject=async n=>{try{return await this.engine.reject(n)}catch(a){throw this.logger.error(a.message),a}},this.update=async n=>{try{return await this.engine.update(n)}catch(a){throw this.logger.error(a.message),a}},this.extend=async n=>{try{return await this.engine.extend(n)}catch(a){throw this.logger.error(a.message),a}},this.request=async n=>{try{return await this.engine.request(n)}catch(a){throw this.logger.error(a.message),a}},this.respond=async n=>{try{return await this.engine.respond(n)}catch(a){throw this.logger.error(a.message),a}},this.ping=async n=>{try{return await this.engine.ping(n)}catch(a){throw this.logger.error(a.message),a}},this.emit=async n=>{try{return await this.engine.emit(n)}catch(a){throw this.logger.error(a.message),a}},this.disconnect=async n=>{try{return await this.engine.disconnect(n)}catch(a){throw this.logger.error(a.message),a}},this.find=n=>{try{return this.engine.find(n)}catch(a){throw this.logger.error(a.message),a}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(n){throw this.logger.error(n.message),n}},this.name=(t==null?void 0:t.name)||da.name,this.metadata=(t==null?void 0:t.metadata)||Vw();const r=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:kn(Hn({level:(t==null?void 0:t.logger)||da.logger}));this.core=(t==null?void 0:t.core)||new yx(t),this.logger=er(r,this.name),this.session=new Nx(this.core,this.logger),this.proposal=new Rx(this.core,this.logger),this.pendingRequest=new $x(this.core,this.logger),this.engine=new Ox(this)}static async init(t){const r=new $f(t);return await r.initialize(),r}get context(){return Ft(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(t){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(t.message),t}}};const Sl="error",Ax="wss://relay.walletconnect.com",Tx="wc",Dx="universal_provider",Pl=`${Tx}@2:${Dx}:`,jx="https://rpc.walletconnect.com/v1/",Hr={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var ms=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof xe<"u"?xe:typeof self<"u"?self:{},Ta={exports:{}};/** * @license * Lodash <https://lodash.com/> * Copyright OpenJS Foundation and other contributors <https://openjsf.org/> * Released under MIT license <https://lodash.com/license> * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE> * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors */(function(s,t){(function(){var r,n="4.17.21",a=200,u="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",f="Expected a function",y="Invalid `variable` option passed into `_.template`",m="__lodash_hash_undefined__",g=500,w="__lodash_placeholder__",_=1,O=2,j=4,N=1,ee=2,ne=1,oe=2,P=4,$=8,C=16,q=32,z=64,K=128,W=256,we=512,tt=30,lr="...",_r=800,fr=16,k=1,H=2,Ue=3,$e=1/0,Y=9007199254740991,G=17976931348623157e292,B=NaN,J=4294967295,bt=J-1,Be=J>>>1,Wi=[["ary",K],["bind",ne],["bindKey",oe],["curry",$],["curryRight",C],["flip",we],["partial",q],["partialRight",z],["rearg",W]],Er="[object Arguments]",Kr="[object Array]",A="[object AsyncFunction]",T="[object Boolean]",S="[object Date]",h="[object DOMException]",E="[object Error]",te="[object Function]",ce="[object GeneratorFunction]",pe="[object Map]",be="[object Number]",Ee="[object Null]",me="[object Object]",rt="[object Promise]",Qe="[object Proxy]",ke="[object RegExp]",Se="[object Set]",De="[object String]",je="[object Symbol]",He="[object Undefined]",Re="[object WeakMap]",qe="[object WeakSet]",Pe="[object ArrayBuffer]",Me="[object DataView]",Ye="[object Float32Array]",it="[object Float64Array]",_t="[object Int8Array]",St="[object Int16Array]",Nt="[object Int32Array]",jt="[object Uint8Array]",Bt="[object Uint8ClampedArray]",tr="[object Uint16Array]",pr="[object Uint32Array]",Vr=/\b__p \+= '';/g,ni=/\b(__p \+=) '' \+/g,_i=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ei=/&(?:amp|lt|gt|quot|#39);/g,Ji=/[&<>"']/g,st=RegExp(Ei.source),nt=RegExp(Ji.source),ot=/<%-([\s\S]+?)%>/g,at=/<%([\s\S]+?)%>/g,Ze=/<%=([\s\S]+?)%>/g,ct=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,ut=/^\w*$/,ht=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ge=/[\\^$.*+?()[\]{}|]/g,lt=RegExp(Ge.source),We=/^\s+/,ft=/\s/,pt=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,dt=/\{\n\/\* \[wrapped with (.+)\] \*/,gt=/,? & /,yt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Tf=/[()=,{}\[\]\/\s]/,Df=/\\(\\)?/g,jf=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,ec=/\w*$/,qf=/^[-+]0x[0-9a-f]+$/i,Mf=/^0b[01]+$/i,Lf=/^\[object .+?Constructor\]$/,Uf=/^0o[0-7]+$/i,zf=/^(?:0|[1-9]\d*)$/,kf=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,As=/($^)/,Hf=/['\n\r\u2028\u2029\\]/g,Ts="\\ud800-\\udfff",Kf="\\u0300-\\u036f",Vf="\\ufe20-\\ufe2f",Ff="\\u20d0-\\u20ff",tc=Kf+Vf+Ff,rc="\\u2700-\\u27bf",ic="a-z\\xdf-\\xf6\\xf8-\\xff",Bf="\\xac\\xb1\\xd7\\xf7",Gf="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",Wf="\\u2000-\\u206f",Jf=" \\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",sc="A-Z\\xc0-\\xd6\\xd8-\\xde",nc="\\ufe0e\\ufe0f",oc=Bf+Gf+Wf+Jf,Fn="['’]",Qf="["+Ts+"]",ac="["+oc+"]",Ds="["+tc+"]",cc="\\d+",Yf="["+rc+"]",uc="["+ic+"]",hc="[^"+Ts+oc+cc+rc+ic+sc+"]",Bn="\\ud83c[\\udffb-\\udfff]",Zf="(?:"+Ds+"|"+Bn+")",lc="[^"+Ts+"]",Gn="(?:\\ud83c[\\udde6-\\uddff]){2}",Wn="[\\ud800-\\udbff][\\udc00-\\udfff]",Ii="["+sc+"]",fc="\\u200d",pc="(?:"+uc+"|"+hc+")",Xf="(?:"+Ii+"|"+hc+")",dc="(?:"+Fn+"(?:d|ll|m|re|s|t|ve))?",gc="(?:"+Fn+"(?:D|LL|M|RE|S|T|VE))?",yc=Zf+"?",mc="["+nc+"]?",ep="(?:"+fc+"(?:"+[lc,Gn,Wn].join("|")+")"+mc+yc+")*",tp="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",rp="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",vc=mc+yc+ep,ip="(?:"+[Yf,Gn,Wn].join("|")+")"+vc,sp="(?:"+[lc+Ds+"?",Ds,Gn,Wn,Qf].join("|")+")",np=RegExp(Fn,"g"),op=RegExp(Ds,"g"),Jn=RegExp(Bn+"(?="+Bn+")|"+sp+vc,"g"),ap=RegExp([Ii+"?"+uc+"+"+dc+"(?="+[ac,Ii,"$"].join("|")+")",Xf+"+"+gc+"(?="+[ac,Ii+pc,"$"].join("|")+")",Ii+"?"+pc+"+"+dc,Ii+"+"+gc,rp,tp,cc,ip].join("|"),"g"),cp=RegExp("["+fc+Ts+tc+nc+"]"),up=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,hp=["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"],lp=-1,Ce={};Ce[Ye]=Ce[it]=Ce[_t]=Ce[St]=Ce[Nt]=Ce[jt]=Ce[Bt]=Ce[tr]=Ce[pr]=!0,Ce[Er]=Ce[Kr]=Ce[Pe]=Ce[T]=Ce[Me]=Ce[S]=Ce[E]=Ce[te]=Ce[pe]=Ce[be]=Ce[me]=Ce[ke]=Ce[Se]=Ce[De]=Ce[Re]=!1;var Ne={};Ne[Er]=Ne[Kr]=Ne[Pe]=Ne[Me]=Ne[T]=Ne[S]=Ne[Ye]=Ne[it]=Ne[_t]=Ne[St]=Ne[Nt]=Ne[pe]=Ne[be]=Ne[me]=Ne[ke]=Ne[Se]=Ne[De]=Ne[je]=Ne[jt]=Ne[Bt]=Ne[tr]=Ne[pr]=!0,Ne[E]=Ne[te]=Ne[Re]=!1;var fp={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",Ç:"C",ç:"c",Ð:"D",ð:"d",È:"E",É:"E",Ê:"E",Ë:"E",è:"e",é:"e",ê:"e",ë:"e",Ì:"I",Í:"I",Î:"I",Ï:"I",ì:"i",í:"i",î:"i",ï:"i",Ñ:"N",ñ:"n",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ø:"O",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ø:"o",Ù:"U",Ú:"U",Û:"U",Ü:"U",ù:"u",ú:"u",û:"u",ü:"u",Ý:"Y",ý:"y",ÿ:"y",Æ:"Ae",æ:"ae",Þ:"Th",þ:"th",ß:"ss",Ā:"A",Ă:"A",Ą:"A",ā:"a",ă:"a",ą:"a",Ć:"C",Ĉ:"C",Ċ:"C",Č:"C",ć:"c",ĉ:"c",ċ:"c",č:"c",Ď:"D",Đ:"D",ď:"d",đ:"d",Ē:"E",Ĕ:"E",Ė:"E",Ę:"E",Ě:"E",ē:"e",ĕ:"e",ė:"e",ę:"e",ě:"e",Ĝ:"G",Ğ:"G",Ġ:"G",Ģ:"G",ĝ:"g",ğ:"g",ġ:"g",ģ:"g",Ĥ:"H",Ħ:"H",ĥ:"h",ħ:"h",Ĩ:"I",Ī:"I",Ĭ:"I",Į:"I",İ:"I",ĩ:"i",ī:"i",ĭ:"i",į:"i",ı:"i",Ĵ:"J",ĵ:"j",Ķ:"K",ķ:"k",ĸ:"k",Ĺ:"L",Ļ:"L",Ľ:"L",Ŀ:"L",Ł:"L",ĺ:"l",ļ:"l",ľ:"l",ŀ:"l",ł:"l",Ń:"N",Ņ:"N",Ň:"N",Ŋ:"N",ń:"n",ņ:"n",ň:"n",ŋ:"n",Ō:"O",Ŏ:"O",Ő:"O",ō:"o",ŏ:"o",ő:"o",Ŕ:"R",Ŗ:"R",Ř:"R",ŕ:"r",ŗ:"r",ř:"r",Ś:"S",Ŝ:"S",Ş:"S",Š:"S",ś:"s",ŝ:"s",ş:"s",š:"s",Ţ:"T",Ť:"T",Ŧ:"T",ţ:"t",ť:"t",ŧ:"t",Ũ:"U",Ū:"U",Ŭ:"U",Ů:"U",Ű:"U",Ų:"U",ũ:"u",ū:"u",ŭ:"u",ů:"u",ű:"u",ų:"u",Ŵ:"W",ŵ:"w",Ŷ:"Y",ŷ:"y",Ÿ:"Y",Ź:"Z",Ż:"Z",Ž:"Z",ź:"z",ż:"z",ž:"z",IJ:"IJ",ij:"ij",Œ:"Oe",œ:"oe",ʼn:"'n",ſ:"s"},pp={"&":"&","<":"<",">":">",'"':""","'":"'"},dp={"&":"&","<":"<",">":">",""":'"',"'":"'"},gp={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},yp=parseFloat,mp=parseInt,wc=typeof ms=="object"&&ms&&ms.Object===Object&&ms,vp=typeof self=="object"&&self&&self.Object===Object&&self,Et=wc||vp||Function("return this")(),Qn=t&&!t.nodeType&&t,oi=Qn&&!0&&s&&!s.nodeType&&s,bc=oi&&oi.exports===Qn,Yn=bc&&wc.process,rr=function(){try{var I=oi&&oi.require&&oi.require("util").types;return I||Yn&&Yn.binding&&Yn.binding("util")}catch{}}(),_c=rr&&rr.isArrayBuffer,Ec=rr&&rr.isDate,Ic=rr&&rr.isMap,xc=rr&&rr.isRegExp,Sc=rr&&rr.isSet,Pc=rr&&rr.isTypedArray;function Gt(I,D,R){switch(R.length){case 0:return I.call(D);case 1:return I.call(D,R[0]);case 2:return I.call(D,R[0],R[1]);case 3:return I.call(D,R[0],R[1],R[2])}return I.apply(D,R)}function wp(I,D,R,Q){for(var ae=-1,ve=I==null?0:I.length;++ae<ve;){var Xe=I[ae];D(Q,Xe,R(Xe),I)}return Q}function ir(I,D){for(var R=-1,Q=I==null?0:I.length;++R<Q&&D(I[R],R,I)!==!1;);return I}function bp(I,D){for(var R=I==null?0:I.length;R--&&D(I[R],R,I)!==!1;);return I}function Oc(I,D){for(var R=-1,Q=I==null?0:I.length;++R<Q;)if(!D(I[R],R,I))return!1;return!0}function Fr(I,D){for(var R=-1,Q=I==null?0:I.length,ae=0,ve=[];++R<Q;){var Xe=I[R];D(Xe,R,I)&&(ve[ae++]=Xe)}return ve}function js(I,D){var R=I==null?0:I.length;return!!R&&xi(I,D,0)>-1}function Zn(I,D,R){for(var Q=-1,ae=I==null?0:I.length;++Q<ae;)if(R(D,I[Q]))return!0;return!1}function Ae(I,D){for(var R=-1,Q=I==null?0:I.length,ae=Array(Q);++R<Q;)ae[R]=D(I[R],R,I);return ae}function Br(I,D){for(var R=-1,Q=D.length,ae=I.length;++R<Q;)I[ae+R]=D[R];return I}function Xn(I,D,R,Q){var ae=-1,ve=I==null?0:I.length;for(Q&&ve&&(R=I[++ae]);++ae<ve;)R=D(R,I[ae],ae,I);return R}function _p(I,D,R,Q){var ae=I==null?0:I.length;for(Q&&ae&&(R=I[--ae]);ae--;)R=D(R,I[ae],ae,I);return R}function eo(I,D){for(var R=-1,Q=I==null?0:I.length;++R<Q;)if(D(I[R],R,I))return!0;return!1}var Ep=to("length");function Ip(I){return I.split("")}function xp(I){return I.match(yt)||[]}function Rc(I,D,R){var Q;return R(I,function(ae,ve,Xe){if(D(ae,ve,Xe))return Q=ve,!1}),Q}function qs(I,D,R,Q){for(var ae=I.length,ve=R+(Q?1:-1);Q?ve--:++ve<ae;)if(D(I[ve],ve,I))return ve;return-1}function xi(I,D,R){return D===D?qp(I,D,R):qs(I,Nc,R)}function Sp(I,D,R,Q){for(var ae=R-1,ve=I.length;++ae<ve;)if(Q(I[ae],D))return ae;return-1}function Nc(I){return I!==I}function $c(I,D){var R=I==null?0:I.length;return R?io(I,D)/R:B}function to(I){return function(D){return D==null?r:D[I]}}function ro(I){return function(D){return I==null?r:I[D]}}function Cc(I,D,R,Q,ae){return ae(I,function(ve,Xe,Oe){R=Q?(Q=!1,ve):D(R,ve,Xe,Oe)}),R}function Pp(I,D){var R=I.length;for(I.sort(D);R--;)I[R]=I[R].value;return I}function io(I,D){for(var R,Q=-1,ae=I.length;++Q<ae;){var ve=D(I[Q]);ve!==r&&(R=R===r?ve:R+ve)}return R}function so(I,D){for(var R=-1,Q=Array(I);++R<I;)Q[R]=D(R);return Q}function Op(I,D){return Ae(D,function(R){return[R,I[R]]})}function Ac(I){return I&&I.slice(0,qc(I)+1).replace(We,"")}function Wt(I){return function(D){return I(D)}}function no(I,D){return Ae(D,function(R){return I[R]})}function Qi(I,D){return I.has(D)}function Tc(I,D){for(var R=-1,Q=I.length;++R<Q&&xi(D,I[R],0)>-1;);return R}function Dc(I,D){for(var R=I.length;R--&&xi(D,I[R],0)>-1;);return R}function Rp(I,D){for(var R=I.length,Q=0;R--;)I[R]===D&&++Q;return Q}var Np=ro(fp),$p=ro(pp);function Cp(I){return"\\"+gp[I]}function Ap(I,D){return I==null?r:I[D]}function Si(I){return cp.test(I)}function Tp(I){return up.test(I)}function Dp(I){for(var D,R=[];!(D=I.next()).done;)R.push(D.value);return R}function oo(I){var D=-1,R=Array(I.size);return I.forEach(function(Q,ae){R[++D]=[ae,Q]}),R}function jc(I,D){return function(R){return I(D(R))}}function Gr(I,D){for(var R=-1,Q=I.length,ae=0,ve=[];++R<Q;){var Xe=I[R];(Xe===D||Xe===w)&&(I[R]=w,ve[ae++]=R)}return ve}function Ms(I){var D=-1,R=Array(I.size);return I.forEach(function(Q){R[++D]=Q}),R}function jp(I){var D=-1,R=Array(I.size);return I.forEach(function(Q){R[++D]=[Q,Q]}),R}function qp(I,D,R){for(var Q=R-1,ae=I.length;++Q<ae;)if(I[Q]===D)return Q;return-1}function Mp(I,D,R){for(var Q=R+1;Q--;)if(I[Q]===D)return Q;return Q}function Pi(I){return Si(I)?Up(I):Ep(I)}function dr(I){return Si(I)?zp(I):Ip(I)}function qc(I){for(var D=I.length;D--&&ft.test(I.charAt(D)););return D}var Lp=ro(dp);function Up(I){for(var D=Jn.lastIndex=0;Jn.test(I);)++D;return D}function zp(I){return I.match(Jn)||[]}function kp(I){return I.match(ap)||[]}var Hp=function I(D){D=D==null?Et:Oi.defaults(Et.Object(),D,Oi.pick(Et,hp));var R=D.Array,Q=D.Date,ae=D.Error,ve=D.Function,Xe=D.Math,Oe=D.Object,ao=D.RegExp,Kp=D.String,sr=D.TypeError,Ls=R.prototype,Vp=ve.prototype,Ri=Oe.prototype,Us=D["__core-js_shared__"],zs=Vp.toString,Ie=Ri.hasOwnProperty,Fp=0,Mc=function(){var e=/[^.]+$/.exec(Us&&Us.keys&&Us.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),ks=Ri.toString,Bp=zs.call(Oe),Gp=Et._,Wp=ao("^"+zs.call(Ie).replace(Ge,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Hs=bc?D.Buffer:r,Wr=D.Symbol,Ks=D.Uint8Array,Lc=Hs?Hs.allocUnsafe:r,Vs=jc(Oe.getPrototypeOf,Oe),Uc=Oe.create,zc=Ri.propertyIsEnumerable,Fs=Ls.splice,kc=Wr?Wr.isConcatSpreadable:r,Yi=Wr?Wr.iterator:r,ai=Wr?Wr.toStringTag:r,Bs=function(){try{var e=fi(Oe,"defineProperty");return e({},"",{}),e}catch{}}(),Jp=D.clearTimeout!==Et.clearTimeout&&D.clearTimeout,Qp=Q&&Q.now!==Et.Date.now&&Q.now,Yp=D.setTimeout!==Et.setTimeout&&D.setTimeout,Gs=Xe.ceil,Ws=Xe.floor,co=Oe.getOwnPropertySymbols,Zp=Hs?Hs.isBuffer:r,Hc=D.isFinite,Xp=Ls.join,ed=jc(Oe.keys,Oe),et=Xe.max,Pt=Xe.min,td=Q.now,rd=D.parseInt,Kc=Xe.random,id=Ls.reverse,uo=fi(D,"DataView"),Zi=fi(D,"Map"),ho=fi(D,"Promise"),Ni=fi(D,"Set"),Xi=fi(D,"WeakMap"),es=fi(Oe,"create"),Js=Xi&&new Xi,$i={},sd=pi(uo),nd=pi(Zi),od=pi(ho),ad=pi(Ni),cd=pi(Xi),Qs=Wr?Wr.prototype:r,ts=Qs?Qs.valueOf:r,Vc=Qs?Qs.toString:r;function p(e){if(ze(e)&&!ue(e)&&!(e instanceof ge)){if(e instanceof nr)return e;if(Ie.call(e,"__wrapped__"))return Fu(e)}return new nr(e)}var Ci=function(){function e(){}return function(i){if(!Le(i))return{};if(Uc)return Uc(i);e.prototype=i;var o=new e;return e.prototype=r,o}}();function Ys(){}function nr(e,i){this.__wrapped__=e,this.__actions__=[],this.__chain__=!!i,this.__index__=0,this.__values__=r}p.templateSettings={escape:ot,evaluate:at,interpolate:Ze,variable:"",imports:{_:p}},p.prototype=Ys.prototype,p.prototype.constructor=p,nr.prototype=Ci(Ys.prototype),nr.prototype.constructor=nr;function ge(e){this.__wrapped__=e,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=J,this.__views__=[]}function ud(){var e=new ge(this.__wrapped__);return e.__actions__=qt(this.__actions__),e.__dir__=this.__dir__,e.__filtered__=this.__filtered__,e.__iteratees__=qt(this.__iteratees__),e.__takeCount__=this.__takeCount__,e.__views__=qt(this.__views__),e}function hd(){if(this.__filtered__){var e=new ge(this);e.__dir__=-1,e.__filtered__=!0}else e=this.clone(),e.__dir__*=-1;return e}function ld(){var e=this.__wrapped__.value(),i=this.__dir__,o=ue(e),c=i<0,l=o?e.length:0,d=Ig(0,l,this.__views__),v=d.start,b=d.end,x=b-v,M=c?b:v-1,L=this.__iteratees__,U=L.length,F=0,Z=Pt(x,this.__takeCount__);if(!o||!c&&l==x&&Z==x)return du(e,this.__actions__);var ie=[];e:for(;x--&&F<Z;){M+=i;for(var le=-1,se=e[M];++le<U;){var de=L[le],ye=de.iteratee,Yt=de.type,At=ye(se);if(Yt==H)se=At;else if(!At){if(Yt==k)continue e;break e}}ie[F++]=se}return ie}ge.prototype=Ci(Ys.prototype),ge.prototype.constructor=ge;function ci(e){var i=-1,o=e==null?0:e.length;for(this.clear();++i<o;){var c=e[i];this.set(c[0],c[1])}}function fd(){this.__data__=es?es(null):{},this.size=0}function pd(e){var i=this.has(e)&&delete this.__data__[e];return this.size-=i?1:0,i}function dd(e){var i=this.__data__;if(es){var o=i[e];return o===m?r:o}return Ie.call(i,e)?i[e]:r}function gd(e){var i=this.__data__;return es?i[e]!==r:Ie.call(i,e)}function yd(e,i){var o=this.__data__;return this.size+=this.has(e)?0:1,o[e]=es&&i===r?m:i,this}ci.prototype.clear=fd,ci.prototype.delete=pd,ci.prototype.get=dd,ci.prototype.has=gd,ci.prototype.set=yd;function $r(e){var i=-1,o=e==null?0:e.length;for(this.clear();++i<o;){var c=e[i];this.set(c[0],c[1])}}function md(){this.__data__=[],this.size=0}function vd(e){var i=this.__data__,o=Zs(i,e);if(o<0)return!1;var c=i.length-1;return o==c?i.pop():Fs.call(i,o,1),--this.size,!0}function wd(e){var i=this.__data__,o=Zs(i,e);return o<0?r:i[o][1]}function bd(e){return Zs(this.__data__,e)>-1}function _d(e,i){var o=this.__data__,c=Zs(o,e);return c<0?(++this.size,o.push([e,i])):o[c][1]=i,this}$r.prototype.clear=md,$r.prototype.delete=vd,$r.prototype.get=wd,$r.prototype.has=bd,$r.prototype.set=_d;function Cr(e){var i=-1,o=e==null?0:e.length;for(this.clear();++i<o;){var c=e[i];this.set(c[0],c[1])}}function Ed(){this.size=0,this.__data__={hash:new ci,map:new(Zi||$r),string:new ci}}function Id(e){var i=ln(this,e).delete(e);return this.size-=i?1:0,i}function xd(e){return ln(this,e).get(e)}function Sd(e){return ln(this,e).has(e)}function Pd(e,i){var o=ln(this,e),c=o.size;return o.set(e,i),this.size+=o.size==c?0:1,this}Cr.prototype.clear=Ed,Cr.prototype.delete=Id,Cr.prototype.get=xd,Cr.prototype.has=Sd,Cr.prototype.set=Pd;function ui(e){var i=-1,o=e==null?0:e.length;for(this.__data__=new Cr;++i<o;)this.add(e[i])}function Od(e){return this.__data__.set(e,m),this}function Rd(e){return this.__data__.has(e)}ui.prototype.add=ui.prototype.push=Od,ui.prototype.has=Rd;function gr(e){var i=this.__data__=new $r(e);this.size=i.size}function Nd(){this.__data__=new $r,this.size=0}function $d(e){var i=this.__data__,o=i.delete(e);return this.size=i.size,o}function Cd(e){return this.__data__.get(e)}function Ad(e){return this.__data__.has(e)}function Td(e,i){var o=this.__data__;if(o instanceof $r){var c=o.__data__;if(!Zi||c.length<a-1)return c.push([e,i]),this.size=++o.size,this;o=this.__data__=new Cr(c)}return o.set(e,i),this.size=o.size,this}gr.prototype.clear=Nd,gr.prototype.delete=$d,gr.prototype.get=Cd,gr.prototype.has=Ad,gr.prototype.set=Td;function Fc(e,i){var o=ue(e),c=!o&&di(e),l=!o&&!c&&Xr(e),d=!o&&!c&&!l&&ji(e),v=o||c||l||d,b=v?so(e.length,Kp):[],x=b.length;for(var M in e)(i||Ie.call(e,M))&&!(v&&(M=="length"||l&&(M=="offset"||M=="parent")||d&&(M=="buffer"||M=="byteLength"||M=="byteOffset")||jr(M,x)))&&b.push(M);return b}function Bc(e){var i=e.length;return i?e[Eo(0,i-1)]:r}function Dd(e,i){return fn(qt(e),hi(i,0,e.length))}function jd(e){return fn(qt(e))}function lo(e,i,o){(o!==r&&!yr(e[i],o)||o===r&&!(i in e))&&Ar(e,i,o)}function rs(e,i,o){var c=e[i];(!(Ie.call(e,i)&&yr(c,o))||o===r&&!(i in e))&&Ar(e,i,o)}function Zs(e,i){for(var o=e.length;o--;)if(yr(e[o][0],i))return o;return-1}function qd(e,i,o,c){return Jr(e,function(l,d,v){i(c,l,o(l),v)}),c}function Gc(e,i){return e&&xr(i,mt(i),e)}function Md(e,i){return e&&xr(i,Lt(i),e)}function Ar(e,i,o){i=="__proto__"&&Bs?Bs(e,i,{configurable:!0,enumerable:!0,value:o,writable:!0}):e[i]=o}function fo(e,i){for(var o=-1,c=i.length,l=R(c),d=e==null;++o<c;)l[o]=d?r:Go(e,i[o]);return l}function hi(e,i,o){return e===e&&(o!==r&&(e=e<=o?e:o),i!==r&&(e=e>=i?e:i)),e}function or(e,i,o,c,l,d){var v,b=i&_,x=i&O,M=i&j;if(o&&(v=l?o(e,c,l,d):o(e)),v!==r)return v;if(!Le(e))return e;var L=ue(e);if(L){if(v=Sg(e),!b)return qt(e,v)}else{var U=Ot(e),F=U==te||U==ce;if(Xr(e))return mu(e,b);if(U==me||U==Er||F&&!l){if(v=x||F?{}:qu(e),!b)return x?dg(e,Md(v,e)):pg(e,Gc(v,e))}else{if(!Ne[U])return l?e:{};v=Pg(e,U,b)}}d||(d=new gr);var Z=d.get(e);if(Z)return Z;d.set(e,v),lh(e)?e.forEach(function(se){v.add(or(se,i,o,se,e,d))}):uh(e)&&e.forEach(function(se,de){v.set(de,or(se,i,o,de,e,d))});var ie=M?x?To:Ao:x?Lt:mt,le=L?r:ie(e);return ir(le||e,function(se,de){le&&(de=se,se=e[de]),rs(v,de,or(se,i,o,de,e,d))}),v}function Ld(e){var i=mt(e);return function(o){return Wc(o,e,i)}}function Wc(e,i,o){var c=o.length;if(e==null)return!c;for(e=Oe(e);c--;){var l=o[c],d=i[l],v=e[l];if(v===r&&!(l in e)||!d(v))return!1}return!0}function Jc(e,i,o){if(typeof e!="function")throw new sr(f);return us(function(){e.apply(r,o)},i)}function is(e,i,o,c){var l=-1,d=js,v=!0,b=e.length,x=[],M=i.length;if(!b)return x;o&&(i=Ae(i,Wt(o))),c?(d=Zn,v=!1):i.length>=a&&(d=Qi,v=!1,i=new ui(i));e:for(;++l<b;){var L=e[l],U=o==null?L:o(L);if(L=c||L!==0?L:0,v&&U===U){for(var F=M;F--;)if(i[F]===U)continue e;x.push(L)}else d(i,U,c)||x.push(L)}return x}var Jr=Eu(Ir),Qc=Eu(go,!0);function Ud(e,i){var o=!0;return Jr(e,function(c,l,d){return o=!!i(c,l,d),o}),o}function Xs(e,i,o){for(var c=-1,l=e.length;++c<l;){var d=e[c],v=i(d);if(v!=null&&(b===r?v===v&&!Qt(v):o(v,b)))var b=v,x=d}return x}function zd(e,i,o,c){var l=e.length;for(o=he(o),o<0&&(o=-o>l?0:l+o),c=c===r||c>l?l:he(c),c<0&&(c+=l),c=o>c?0:ph(c);o<c;)e[o++]=i;return e}function Yc(e,i){var o=[];return Jr(e,function(c,l,d){i(c,l,d)&&o.push(c)}),o}function It(e,i,o,c,l){var d=-1,v=e.length;for(o||(o=Rg),l||(l=[]);++d<v;){var b=e[d];i>0&&o(b)?i>1?It(b,i-1,o,c,l):Br(l,b):c||(l[l.length]=b)}return l}var po=Iu(),Zc=Iu(!0);function Ir(e,i){return e&&po(e,i,mt)}function go(e,i){return e&&Zc(e,i,mt)}function en(e,i){return Fr(i,function(o){return qr(e[o])})}function li(e,i){i=Yr(i,e);for(var o=0,c=i.length;e!=null&&o<c;)e=e[Sr(i[o++])];return o&&o==c?e:r}function Xc(e,i,o){var c=i(e);return ue(e)?c:Br(c,o(e))}function $t(e){return e==null?e===r?He:Ee:ai&&ai in Oe(e)?Eg(e):jg(e)}function yo(e,i){return e>i}function kd(e,i){return e!=null&&Ie.call(e,i)}function Hd(e,i){return e!=null&&i in Oe(e)}function Kd(e,i,o){return e>=Pt(i,o)&&e<et(i,o)}function mo(e,i,o){for(var c=o?Zn:js,l=e[0].length,d=e.length,v=d,b=R(d),x=1/0,M=[];v--;){var L=e[v];v&&i&&(L=Ae(L,Wt(i))),x=Pt(L.length,x),b[v]=!o&&(i||l>=120&&L.length>=120)?new ui(v&&L):r}L=e[0];var U=-1,F=b[0];e:for(;++U<l&&M.length<x;){var Z=L[U],ie=i?i(Z):Z;if(Z=o||Z!==0?Z:0,!(F?Qi(F,ie):c(M,ie,o))){for(v=d;--v;){var le=b[v];if(!(le?Qi(le,ie):c(e[v],ie,o)))continue e}F&&F.push(ie),M.push(Z)}}return M}function Vd(e,i,o,c){return Ir(e,function(l,d,v){i(c,o(l),d,v)}),c}function ss(e,i,o){i=Yr(i,e),e=zu(e,i);var c=e==null?e:e[Sr(cr(i))];return c==null?r:Gt(c,e,o)}function eu(e){return ze(e)&&$t(e)==Er}function Fd(e){return ze(e)&&$t(e)==Pe}function Bd(e){return ze(e)&&$t(e)==S}function ns(e,i,o,c,l){return e===i?!0:e==null||i==null||!ze(e)&&!ze(i)?e!==e&&i!==i:Gd(e,i,o,c,ns,l)}function Gd(e,i,o,c,l,d){var v=ue(e),b=ue(i),x=v?Kr:Ot(e),M=b?Kr:Ot(i);x=x==Er?me:x,M=M==Er?me:M;var L=x==me,U=M==me,F=x==M;if(F&&Xr(e)){if(!Xr(i))return!1;v=!0,L=!1}if(F&&!L)return d||(d=new gr),v||ji(e)?Tu(e,i,o,c,l,d):bg(e,i,x,o,c,l,d);if(!(o&N)){var Z=L&&Ie.call(e,"__wrapped__"),ie=U&&Ie.call(i,"__wrapped__");if(Z||ie){var le=Z?e.value():e,se=ie?i.value():i;return d||(d=new gr),l(le,se,o,c,d)}}return F?(d||(d=new gr),_g(e,i,o,c,l,d)):!1}function Wd(e){return ze(e)&&Ot(e)==pe}function vo(e,i,o,c){var l=o.length,d=l,v=!c;if(e==null)return!d;for(e=Oe(e);l--;){var b=o[l];if(v&&b[2]?b[1]!==e[b[0]]:!(b[0]in e))return!1}for(;++l<d;){b=o[l];var x=b[0],M=e[x],L=b[1];if(v&&b[2]){if(M===r&&!(x in e))return!1}else{var U=new gr;if(c)var F=c(M,L,x,e,i,U);if(!(F===r?ns(L,M,N|ee,c,U):F))return!1}}return!0}function tu(e){if(!Le(e)||$g(e))return!1;var i=qr(e)?Wp:Lf;return i.test(pi(e))}function Jd(e){return ze(e)&&$t(e)==ke}function Qd(e){return ze(e)&&Ot(e)==Se}function Yd(e){return ze(e)&&vn(e.length)&&!!Ce[$t(e)]}function ru(e){return typeof e=="function"?e:e==null?Ut:typeof e=="object"?ue(e)?nu(e[0],e[1]):su(e):xh(e)}function wo(e){if(!cs(e))return ed(e);var i=[];for(var o in Oe(e))Ie.call(e,o)&&o!="constructor"&&i.push(o);return i}function Zd(e){if(!Le(e))return Dg(e);var i=cs(e),o=[];for(var c in e)c=="constructor"&&(i||!Ie.call(e,c))||o.push(c);return o}function bo(e,i){return e<i}function iu(e,i){var o=-1,c=Mt(e)?R(e.length):[];return Jr(e,function(l,d,v){c[++o]=i(l,d,v)}),c}function su(e){var i=jo(e);return i.length==1&&i[0][2]?Lu(i[0][0],i[0][1]):function(o){return o===e||vo(o,e,i)}}function nu(e,i){return Mo(e)&&Mu(i)?Lu(Sr(e),i):function(o){var c=Go(o,e);return c===r&&c===i?Wo(o,e):ns(i,c,N|ee)}}function tn(e,i,o,c,l){e!==i&&po(i,function(d,v){if(l||(l=new gr),Le(d))Xd(e,i,v,o,tn,c,l);else{var b=c?c(Uo(e,v),d,v+"",e,i,l):r;b===r&&(b=d),lo(e,v,b)}},Lt)}function Xd(e,i,o,c,l,d,v){var b=Uo(e,o),x=Uo(i,o),M=v.get(x);if(M){lo(e,o,M);return}var L=d?d(b,x,o+"",e,i,v):r,U=L===r;if(U){var F=ue(x),Z=!F&&Xr(x),ie=!F&&!Z&&ji(x);L=x,F||Z||ie?ue(b)?L=b:Ke(b)?L=qt(b):Z?(U=!1,L=mu(x,!0)):ie?(U=!1,L=vu(x,!0)):L=[]:hs(x)||di(x)?(L=b,di(b)?L=dh(b):(!Le(b)||qr(b))&&(L=qu(x))):U=!1}U&&(v.set(x,L),l(L,x,c,d,v),v.delete(x)),lo(e,o,L)}function ou(e,i){var o=e.length;if(o)return i+=i<0?o:0,jr(i,o)?e[i]:r}function au(e,i,o){i.length?i=Ae(i,function(d){return ue(d)?function(v){return li(v,d.length===1?d[0]:d)}:d}):i=[Ut];var c=-1;i=Ae(i,Wt(re()));var l=iu(e,function(d,v,b){var x=Ae(i,function(M){return M(d)});return{criteria:x,index:++c,value:d}});return Pp(l,function(d,v){return fg(d,v,o)})}function eg(e,i){return cu(e,i,function(o,c){return Wo(e,c)})}function cu(e,i,o){for(var c=-1,l=i.length,d={};++c<l;){var v=i[c],b=li(e,v);o(b,v)&&os(d,Yr(v,e),b)}return d}function tg(e){return function(i){return li(i,e)}}function _o(e,i,o,c){var l=c?Sp:xi,d=-1,v=i.length,b=e;for(e===i&&(i=qt(i)),o&&(b=Ae(e,Wt(o)));++d<v;)for(var x=0,M=i[d],L=o?o(M):M;(x=l(b,L,x,c))>-1;)b!==e&&Fs.call(b,x,1),Fs.call(e,x,1);return e}function uu(e,i){for(var o=e?i.length:0,c=o-1;o--;){var l=i[o];if(o==c||l!==d){var d=l;jr(l)?Fs.call(e,l,1):So(e,l)}}return e}function Eo(e,i){return e+Ws(Kc()*(i-e+1))}function rg(e,i,o,c){for(var l=-1,d=et(Gs((i-e)/(o||1)),0),v=R(d);d--;)v[c?d:++l]=e,e+=o;return v}function Io(e,i){var o="";if(!e||i<1||i>Y)return o;do i%2&&(o+=e),i=Ws(i/2),i&&(e+=e);while(i);return o}function fe(e,i){return zo(Uu(e,i,Ut),e+"")}function ig(e){return Bc(qi(e))}function sg(e,i){var o=qi(e);return fn(o,hi(i,0,o.length))}function os(e,i,o,c){if(!Le(e))return e;i=Yr(i,e);for(var l=-1,d=i.length,v=d-1,b=e;b!=null&&++l<d;){var x=Sr(i[l]),M=o;if(x==="__proto__"||x==="constructor"||x==="prototype")return e;if(l!=v){var L=b[x];M=c?c(L,x,b):r,M===r&&(M=Le(L)?L:jr(i[l+1])?[]:{})}rs(b,x,M),b=b[x]}return e}var hu=Js?function(e,i){return Js.set(e,i),e}:Ut,ng=Bs?function(e,i){return Bs(e,"toString",{configurable:!0,enumerable:!1,value:Qo(i),writable:!0})}:Ut;function og(e){return fn(qi(e))}function ar(e,i,o){var c=-1,l=e.length;i<0&&(i=-i>l?0:l+i),o=o>l?l:o,o<0&&(o+=l),l=i>o?0:o-i>>>0,i>>>=0;for(var d=R(l);++c<l;)d[c]=e[c+i];return d}function ag(e,i){var o;return Jr(e,function(c,l,d){return o=i(c,l,d),!o}),!!o}function rn(e,i,o){var c=0,l=e==null?c:e.length;if(typeof i=="number"&&i===i&&l<=Be){for(;c<l;){var d=c+l>>>1,v=e[d];v!==null&&!Qt(v)&&(o?v<=i:v<i)?c=d+1:l=d}return l}return xo(e,i,Ut,o)}function xo(e,i,o,c){var l=0,d=e==null?0:e.length;if(d===0)return 0;i=o(i);for(var v=i!==i,b=i===null,x=Qt(i),M=i===r;l<d;){var L=Ws((l+d)/2),U=o(e[L]),F=U!==r,Z=U===null,ie=U===U,le=Qt(U);if(v)var se=c||ie;else M?se=ie&&(c||F):b?se=ie&&F&&(c||!Z):x?se=ie&&F&&!Z&&(c||!le):Z||le?se=!1:se=c?U<=i:U<i;se?l=L+1:d=L}return Pt(d,bt)}function lu(e,i){for(var o=-1,c=e.length,l=0,d=[];++o<c;){var v=e[o],b=i?i(v):v;if(!o||!yr(b,x)){var x=b;d[l++]=v===0?0:v}}return d}function fu(e){return typeof e=="number"?e:Qt(e)?B:+e}function Jt(e){if(typeof e=="string")return e;if(ue(e))return Ae(e,Jt)+"";if(Qt(e))return Vc?Vc.call(e):"";var i=e+"";return i=="0"&&1/e==-$e?"-0":i}function Qr(e,i,o){var c=-1,l=js,d=e.length,v=!0,b=[],x=b;if(o)v=!1,l=Zn;else if(d>=a){var M=i?null:vg(e);if(M)return Ms(M);v=!1,l=Qi,x=new ui}else x=i?[]:b;e:for(;++c<d;){var L=e[c],U=i?i(L):L;if(L=o||L!==0?L:0,v&&U===U){for(var F=x.length;F--;)if(x[F]===U)continue e;i&&x.push(U),b.push(L)}else l(x,U,o)||(x!==b&&x.push(U),b.push(L))}return b}function So(e,i){return i=Yr(i,e),e=zu(e,i),e==null||delete e[Sr(cr(i))]}function pu(e,i,o,c){return os(e,i,o(li(e,i)),c)}function sn(e,i,o,c){for(var l=e.length,d=c?l:-1;(c?d--:++d<l)&&i(e[d],d,e););return o?ar(e,c?0:d,c?d+1:l):ar(e,c?d+1:0,c?l:d)}function du(e,i){var o=e;return o instanceof ge&&(o=o.value()),Xn(i,function(c,l){return l.func.apply(l.thisArg,Br([c],l.args))},o)}function Po(e,i,o){var c=e.length;if(c<2)return c?Qr(e[0]):[];for(var l=-1,d=R(c);++l<c;)for(var v=e[l],b=-1;++b<c;)b!=l&&(d[l]=is(d[l]||v,e[b],i,o));return Qr(It(d,1),i,o)}function gu(e,i,o){for(var c=-1,l=e.length,d=i.length,v={};++c<l;){var b=c<d?i[c]:r;o(v,e[c],b)}return v}function Oo(e){return Ke(e)?e:[]}function Ro(e){return typeof e=="function"?e:Ut}function Yr(e,i){return ue(e)?e:Mo(e,i)?[e]:Vu(_e(e))}var cg=fe;function Zr(e,i,o){var c=e.length;return o=o===r?c:o,!i&&o>=c?e:ar(e,i,o)}var yu=Jp||function(e){return Et.clearTimeout(e)};function mu(e,i){if(i)return e.slice();var o=e.length,c=Lc?Lc(o):new e.constructor(o);return e.copy(c),c}function No(e){var i=new e.constructor(e.byteLength);return new Ks(i).set(new Ks(e)),i}function ug(e,i){var o=i?No(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.byteLength)}function hg(e){var i=new e.constructor(e.source,ec.exec(e));return i.lastIndex=e.lastIndex,i}function lg(e){return ts?Oe(ts.call(e)):{}}function vu(e,i){var o=i?No(e.buffer):e.buffer;return new e.constructor(o,e.byteOffset,e.length)}function wu(e,i){if(e!==i){var o=e!==r,c=e===null,l=e===e,d=Qt(e),v=i!==r,b=i===null,x=i===i,M=Qt(i);if(!b&&!M&&!d&&e>i||d&&v&&x&&!b&&!M||c&&v&&x||!o&&x||!l)return 1;if(!c&&!d&&!M&&e<i||M&&o&&l&&!c&&!d||b&&o&&l||!v&&l||!x)return-1}return 0}function fg(e,i,o){for(var c=-1,l=e.criteria,d=i.criteria,v=l.length,b=o.length;++c<v;){var x=wu(l[c],d[c]);if(x){if(c>=b)return x;var M=o[c];return x*(M=="desc"?-1:1)}}return e.index-i.index}function bu(e,i,o,c){for(var l=-1,d=e.length,v=o.length,b=-1,x=i.length,M=et(d-v,0),L=R(x+M),U=!c;++b<x;)L[b]=i[b];for(;++l<v;)(U||l<d)&&(L[o[l]]=e[l]);for(;M--;)L[b++]=e[l++];return L}function _u(e,i,o,c){for(var l=-1,d=e.length,v=-1,b=o.length,x=-1,M=i.length,L=et(d-b,0),U=R(L+M),F=!c;++l<L;)U[l]=e[l];for(var Z=l;++x<M;)U[Z+x]=i[x];for(;++v<b;)(F||l<d)&&(U[Z+o[v]]=e[l++]);return U}function qt(e,i){var o=-1,c=e.length;for(i||(i=R(c));++o<c;)i[o]=e[o];return i}function xr(e,i,o,c){var l=!o;o||(o={});for(var d=-1,v=i.length;++d<v;){var b=i[d],x=c?c(o[b],e[b],b,o,e):r;x===r&&(x=e[b]),l?Ar(o,b,x):rs(o,b,x)}return o}function pg(e,i){return xr(e,qo(e),i)}function dg(e,i){return xr(e,Du(e),i)}function nn(e,i){return function(o,c){var l=ue(o)?wp:qd,d=i?i():{};return l(o,e,re(c,2),d)}}function Ai(e){return fe(function(i,o){var c=-1,l=o.length,d=l>1?o[l-1]:r,v=l>2?o[2]:r;for(d=e.length>3&&typeof d=="function"?(l--,d):r,v&&Ct(o[0],o[1],v)&&(d=l<3?r:d,l=1),i=Oe(i);++c<l;){var b=o[c];b&&e(i,b,c,d)}return i})}function Eu(e,i){return function(o,c){if(o==null)return o;if(!Mt(o))return e(o,c);for(var l=o.length,d=i?l:-1,v=Oe(o);(i?d--:++d<l)&&c(v[d],d,v)!==!1;);return o}}function Iu(e){return function(i,o,c){for(var l=-1,d=Oe(i),v=c(i),b=v.length;b--;){var x=v[e?b:++l];if(o(d[x],x,d)===!1)break}return i}}function gg(e,i,o){var c=i&ne,l=as(e);function d(){var v=this&&this!==Et&&this instanceof d?l:e;return v.apply(c?o:this,arguments)}return d}function xu(e){return function(i){i=_e(i);var o=Si(i)?dr(i):r,c=o?o[0]:i.charAt(0),l=o?Zr(o,1).join(""):i.slice(1);return c[e]()+l}}function Ti(e){return function(i){return Xn(Eh(_h(i).replace(np,"")),e,"")}}function as(e){return function(){var i=arguments;switch(i.length){case 0:return new e;case 1:return new e(i[0]);case 2:return new e(i[0],i[1]);case 3:return new e(i[0],i[1],i[2]);case 4:return new e(i[0],i[1],i[2],i[3]);case 5:return new e(i[0],i[1],i[2],i[3],i[4]);case 6:return new e(i[0],i[1],i[2],i[3],i[4],i[5]);case 7:return new e(i[0],i[1],i[2],i[3],i[4],i[5],i[6])}var o=Ci(e.prototype),c=e.apply(o,i);return Le(c)?c:o}}function yg(e,i,o){var c=as(e);function l(){for(var d=arguments.length,v=R(d),b=d,x=Di(l);b--;)v[b]=arguments[b];var M=d<3&&v[0]!==x&&v[d-1]!==x?[]:Gr(v,x);if(d-=M.length,d<o)return Nu(e,i,on,l.placeholder,r,v,M,r,r,o-d);var L=this&&this!==Et&&this instanceof l?c:e;return Gt(L,this,v)}return l}function Su(e){return function(i,o,c){var l=Oe(i);if(!Mt(i)){var d=re(o,3);i=mt(i),o=function(b){return d(l[b],b,l)}}var v=e(i,o,c);return v>-1?l[d?i[v]:v]:r}}function Pu(e){return Dr(function(i){var o=i.length,c=o,l=nr.prototype.thru;for(e&&i.reverse();c--;){var d=i[c];if(typeof d!="function")throw new sr(f);if(l&&!v&&hn(d)=="wrapper")var v=new nr([],!0)}for(c=v?c:o;++c<o;){d=i[c];var b=hn(d),x=b=="wrapper"?Do(d):r;x&&Lo(x[0])&&x[1]==(K|$|q|W)&&!x[4].length&&x[9]==1?v=v[hn(x[0])].apply(v,x[3]):v=d.length==1&&Lo(d)?v[b]():v.thru(d)}return function(){var M=arguments,L=M[0];if(v&&M.length==1&&ue(L))return v.plant(L).value();for(var U=0,F=o?i[U].apply(this,M):L;++U<o;)F=i[U].call(this,F);return F}})}function on(e,i,o,c,l,d,v,b,x,M){var L=i&K,U=i&ne,F=i&oe,Z=i&($|C),ie=i&we,le=F?r:as(e);function se(){for(var de=arguments.length,ye=R(de),Yt=de;Yt--;)ye[Yt]=arguments[Yt];if(Z)var At=Di(se),Zt=Rp(ye,At);if(c&&(ye=bu(ye,c,l,Z)),d&&(ye=_u(ye,d,v,Z)),de-=Zt,Z&&de<M){var Ve=Gr(ye,At);return Nu(e,i,on,se.placeholder,o,ye,Ve,b,x,M-de)}var mr=U?o:this,Lr=F?mr[e]:e;return de=ye.length,b?ye=qg(ye,b):ie&&de>1&&ye.reverse(),L&&x<de&&(ye.length=x),this&&this!==Et&&this instanceof se&&(Lr=le||as(Lr)),Lr.apply(mr,ye)}return se}function Ou(e,i){return function(o,c){return Vd(o,e,i(c),{})}}function an(e,i){return function(o,c){var l;if(o===r&&c===r)return i;if(o!==r&&(l=o),c!==r){if(l===r)return c;typeof o=="string"||typeof c=="string"?(o=Jt(o),c=Jt(c)):(o=fu(o),c=fu(c)),l=e(o,c)}return l}}function $o(e){return Dr(function(i){return i=Ae(i,Wt(re())),fe(function(o){var c=this;return e(i,function(l){return Gt(l,c,o)})})})}function cn(e,i){i=i===r?" ":Jt(i);var o=i.length;if(o<2)return o?Io(i,e):i;var c=Io(i,Gs(e/Pi(i)));return Si(i)?Zr(dr(c),0,e).join(""):c.slice(0,e)}function mg(e,i,o,c){var l=i&ne,d=as(e);function v(){for(var b=-1,x=arguments.length,M=-1,L=c.length,U=R(L+x),F=this&&this!==Et&&this instanceof v?d:e;++M<L;)U[M]=c[M];for(;x--;)U[M++]=arguments[++b];return Gt(F,l?o:this,U)}return v}function Ru(e){return function(i,o,c){return c&&typeof c!="number"&&Ct(i,o,c)&&(o=c=r),i=Mr(i),o===r?(o=i,i=0):o=Mr(o),c=c===r?i<o?1:-1:Mr(c),rg(i,o,c,e)}}function un(e){return function(i,o){return typeof i=="string"&&typeof o=="string"||(i=ur(i),o=ur(o)),e(i,o)}}function Nu(e,i,o,c,l,d,v,b,x,M){var L=i&$,U=L?v:r,F=L?r:v,Z=L?d:r,ie=L?r:d;i|=L?q:z,i&=~(L?z:q),i&P||(i&=~(ne|oe));var le=[e,i,l,Z,U,ie,F,b,x,M],se=o.apply(r,le);return Lo(e)&&ku(se,le),se.placeholder=c,Hu(se,e,i)}function Co(e){var i=Xe[e];return function(o,c){if(o=ur(o),c=c==null?0:Pt(he(c),292),c&&Hc(o)){var l=(_e(o)+"e").split("e"),d=i(l[0]+"e"+(+l[1]+c));return l=(_e(d)+"e").split("e"),+(l[0]+"e"+(+l[1]-c))}return i(o)}}var vg=Ni&&1/Ms(new Ni([,-0]))[1]==$e?function(e){return new Ni(e)}:Xo;function $u(e){return function(i){var o=Ot(i);return o==pe?oo(i):o==Se?jp(i):Op(i,e(i))}}function Tr(e,i,o,c,l,d,v,b){var x=i&oe;if(!x&&typeof e!="function")throw new sr(f);var M=c?c.length:0;if(M||(i&=~(q|z),c=l=r),v=v===r?v:et(he(v),0),b=b===r?b:he(b),M-=l?l.length:0,i&z){var L=c,U=l;c=l=r}var F=x?r:Do(e),Z=[e,i,o,c,l,L,U,d,v,b];if(F&&Tg(Z,F),e=Z[0],i=Z[1],o=Z[2],c=Z[3],l=Z[4],b=Z[9]=Z[9]===r?x?0:e.length:et(Z[9]-M,0),!b&&i&($|C)&&(i&=~($|C)),!i||i==ne)var ie=gg(e,i,o);else i==$||i==C?ie=yg(e,i,b):(i==q||i==(ne|q))&&!l.length?ie=mg(e,i,o,c):ie=on.apply(r,Z);var le=F?hu:ku;return Hu(le(ie,Z),e,i)}function Cu(e,i,o,c){return e===r||yr(e,Ri[o])&&!Ie.call(c,o)?i:e}function Au(e,i,o,c,l,d){return Le(e)&&Le(i)&&(d.set(i,e),tn(e,i,r,Au,d),d.delete(i)),e}function wg(e){return hs(e)?r:e}function Tu(e,i,o,c,l,d){var v=o&N,b=e.length,x=i.length;if(b!=x&&!(v&&x>b))return!1;var M=d.get(e),L=d.get(i);if(M&&L)return M==i&&L==e;var U=-1,F=!0,Z=o&ee?new ui:r;for(d.set(e,i),d.set(i,e);++U<b;){var ie=e[U],le=i[U];if(c)var se=v?c(le,ie,U,i,e,d):c(ie,le,U,e,i,d);if(se!==r){if(se)continue;F=!1;break}if(Z){if(!eo(i,function(de,ye){if(!Qi(Z,ye)&&(ie===de||l(ie,de,o,c,d)))return Z.push(ye)})){F=!1;break}}else if(!(ie===le||l(ie,le,o,c,d))){F=!1;break}}return d.delete(e),d.delete(i),F}function bg(e,i,o,c,l,d,v){switch(o){case Me:if(e.byteLength!=i.byteLength||e.byteOffset!=i.byteOffset)return!1;e=e.buffer,i=i.buffer;case Pe:return!(e.byteLength!=i.byteLength||!d(new Ks(e),new Ks(i)));case T:case S:case be:return yr(+e,+i);case E:return e.name==i.name&&e.message==i.message;case ke:case De:return e==i+"";case pe:var b=oo;case Se:var x=c&N;if(b||(b=Ms),e.size!=i.size&&!x)return!1;var M=v.get(e);if(M)return M==i;c|=ee,v.set(e,i);var L=Tu(b(e),b(i),c,l,d,v);return v.delete(e),L;case je:if(ts)return ts.call(e)==ts.call(i)}return!1}function _g(e,i,o,c,l,d){var v=o&N,b=Ao(e),x=b.length,M=Ao(i),L=M.length;if(x!=L&&!v)return!1;for(var U=x;U--;){var F=b[U];if(!(v?F in i:Ie.call(i,F)))return!1}var Z=d.get(e),ie=d.get(i);if(Z&&ie)return Z==i&&ie==e;var le=!0;d.set(e,i),d.set(i,e);for(var se=v;++U<x;){F=b[U];var de=e[F],ye=i[F];if(c)var Yt=v?c(ye,de,F,i,e,d):c(de,ye,F,e,i,d);if(!(Yt===r?de===ye||l(de,ye,o,c,d):Yt)){le=!1;break}se||(se=F=="constructor")}if(le&&!se){var At=e.constructor,Zt=i.constructor;At!=Zt&&"constructor"in e&&"constructor"in i&&!(typeof At=="function"&&At instanceof At&&typeof Zt=="function"&&Zt instanceof Zt)&&(le=!1)}return d.delete(e),d.delete(i),le}function Dr(e){return zo(Uu(e,r,Wu),e+"")}function Ao(e){return Xc(e,mt,qo)}function To(e){return Xc(e,Lt,Du)}var Do=Js?function(e){return Js.get(e)}:Xo;function hn(e){for(var i=e.name+"",o=$i[i],c=Ie.call($i,i)?o.length:0;c--;){var l=o[c],d=l.func;if(d==null||d==e)return l.name}return i}function Di(e){var i=Ie.call(p,"placeholder")?p:e;return i.placeholder}function re(){var e=p.iteratee||Yo;return e=e===Yo?ru:e,arguments.length?e(arguments[0],arguments[1]):e}function ln(e,i){var o=e.__data__;return Ng(i)?o[typeof i=="string"?"string":"hash"]:o.map}function jo(e){for(var i=mt(e),o=i.length;o--;){var c=i[o],l=e[c];i[o]=[c,l,Mu(l)]}return i}function fi(e,i){var o=Ap(e,i);return tu(o)?o:r}function Eg(e){var i=Ie.call(e,ai),o=e[ai];try{e[ai]=r;var c=!0}catch{}var l=ks.call(e);return c&&(i?e[ai]=o:delete e[ai]),l}var qo=co?function(e){return e==null?[]:(e=Oe(e),Fr(co(e),function(i){return zc.call(e,i)}))}:ea,Du=co?function(e){for(var i=[];e;)Br(i,qo(e)),e=Vs(e);return i}:ea,Ot=$t;(uo&&Ot(new uo(new ArrayBuffer(1)))!=Me||Zi&&Ot(new Zi)!=pe||ho&&Ot(ho.resolve())!=rt||Ni&&Ot(new Ni)!=Se||Xi&&Ot(new Xi)!=Re)&&(Ot=function(e){var i=$t(e),o=i==me?e.constructor:r,c=o?pi(o):"";if(c)switch(c){case sd:return Me;case nd:return pe;case od:return rt;case ad:return Se;case cd:return Re}return i});function Ig(e,i,o){for(var c=-1,l=o.length;++c<l;){var d=o[c],v=d.size;switch(d.type){case"drop":e+=v;break;case"dropRight":i-=v;break;case"take":i=Pt(i,e+v);break;case"takeRight":e=et(e,i-v);break}}return{start:e,end:i}}function xg(e){var i=e.match(dt);return i?i[1].split(gt):[]}function ju(e,i,o){i=Yr(i,e);for(var c=-1,l=i.length,d=!1;++c<l;){var v=Sr(i[c]);if(!(d=e!=null&&o(e,v)))break;e=e[v]}return d||++c!=l?d:(l=e==null?0:e.length,!!l&&vn(l)&&jr(v,l)&&(ue(e)||di(e)))}function Sg(e){var i=e.length,o=new e.constructor(i);return i&&typeof e[0]=="string"&&Ie.call(e,"index")&&(o.index=e.index,o.input=e.input),o}function qu(e){return typeof e.constructor=="function"&&!cs(e)?Ci(Vs(e)):{}}function Pg(e,i,o){var c=e.constructor;switch(i){case Pe:return No(e);case T:case S:return new c(+e);case Me:return ug(e,o);case Ye:case it:case _t:case St:case Nt:case jt:case Bt:case tr:case pr:return vu(e,o);case pe:return new c;case be:case De:return new c(e);case ke:return hg(e);case Se:return new c;case je:return lg(e)}}function Og(e,i){var o=i.length;if(!o)return e;var c=o-1;return i[c]=(o>1?"& ":"")+i[c],i=i.join(o>2?", ":" "),e.replace(pt,`{ /* [wrapped with `+i+`] */ `)}function Rg(e){return ue(e)||di(e)||!!(kc&&e&&e[kc])}function jr(e,i){var o=typeof e;return i=i??Y,!!i&&(o=="number"||o!="symbol"&&zf.test(e))&&e>-1&&e%1==0&&e<i}function Ct(e,i,o){if(!Le(o))return!1;var c=typeof i;return(c=="number"?Mt(o)&&jr(i,o.length):c=="string"&&i in o)?yr(o[i],e):!1}function Mo(e,i){if(ue(e))return!1;var o=typeof e;return o=="number"||o=="symbol"||o=="boolean"||e==null||Qt(e)?!0:ut.test(e)||!ct.test(e)||i!=null&&e in Oe(i)}function Ng(e){var i=typeof e;return i=="string"||i=="number"||i=="symbol"||i=="boolean"?e!=="__proto__":e===null}function Lo(e){var i=hn(e),o=p[i];if(typeof o!="function"||!(i in ge.prototype))return!1;if(e===o)return!0;var c=Do(o);return!!c&&e===c[0]}function $g(e){return!!Mc&&Mc in e}var Cg=Us?qr:ta;function cs(e){var i=e&&e.constructor,o=typeof i=="function"&&i.prototype||Ri;return e===o}function Mu(e){return e===e&&!Le(e)}function Lu(e,i){return function(o){return o==null?!1:o[e]===i&&(i!==r||e in Oe(o))}}function Ag(e){var i=yn(e,function(c){return o.size===g&&o.clear(),c}),o=i.cache;return i}function Tg(e,i){var o=e[1],c=i[1],l=o|c,d=l<(ne|oe|K),v=c==K&&o==$||c==K&&o==W&&e[7].length<=i[8]||c==(K|W)&&i[7].length<=i[8]&&o==$;if(!(d||v))return e;c&ne&&(e[2]=i[2],l|=o&ne?0:P);var b=i[3];if(b){var x=e[3];e[3]=x?bu(x,b,i[4]):b,e[4]=x?Gr(e[3],w):i[4]}return b=i[5],b&&(x=e[5],e[5]=x?_u(x,b,i[6]):b,e[6]=x?Gr(e[5],w):i[6]),b=i[7],b&&(e[7]=b),c&K&&(e[8]=e[8]==null?i[8]:Pt(e[8],i[8])),e[9]==null&&(e[9]=i[9]),e[0]=i[0],e[1]=l,e}function Dg(e){var i=[];if(e!=null)for(var o in Oe(e))i.push(o);return i}function jg(e){return ks.call(e)}function Uu(e,i,o){return i=et(i===r?e.length-1:i,0),function(){for(var c=arguments,l=-1,d=et(c.length-i,0),v=R(d);++l<d;)v[l]=c[i+l];l=-1;for(var b=R(i+1);++l<i;)b[l]=c[l];return b[i]=o(v),Gt(e,this,b)}}function zu(e,i){return i.length<2?e:li(e,ar(i,0,-1))}function qg(e,i){for(var o=e.length,c=Pt(i.length,o),l=qt(e);c--;){var d=i[c];e[c]=jr(d,o)?l[d]:r}return e}function Uo(e,i){if(!(i==="constructor"&&typeof e[i]=="function")&&i!="__proto__")return e[i]}var ku=Ku(hu),us=Yp||function(e,i){return Et.setTimeout(e,i)},zo=Ku(ng);function Hu(e,i,o){var c=i+"";return zo(e,Og(c,Mg(xg(c),o)))}function Ku(e){var i=0,o=0;return function(){var c=td(),l=fr-(c-o);if(o=c,l>0){if(++i>=_r)return arguments[0]}else i=0;return e.apply(r,arguments)}}function fn(e,i){var o=-1,c=e.length,l=c-1;for(i=i===r?c:i;++o<i;){var d=Eo(o,l),v=e[d];e[d]=e[o],e[o]=v}return e.length=i,e}var Vu=Ag(function(e){var i=[];return e.charCodeAt(0)===46&&i.push(""),e.replace(ht,function(o,c,l,d){i.push(l?d.replace(Df,"$1"):c||o)}),i});function Sr(e){if(typeof e=="string"||Qt(e))return e;var i=e+"";return i=="0"&&1/e==-$e?"-0":i}function pi(e){if(e!=null){try{return zs.call(e)}catch{}try{return e+""}catch{}}return""}function Mg(e,i){return ir(Wi,function(o){var c="_."+o[0];i&o[1]&&!js(e,c)&&e.push(c)}),e.sort()}function Fu(e){if(e instanceof ge)return e.clone();var i=new nr(e.__wrapped__,e.__chain__);return i.__actions__=qt(e.__actions__),i.__index__=e.__index__,i.__values__=e.__values__,i}function Lg(e,i,o){(o?Ct(e,i,o):i===r)?i=1:i=et(he(i),0);var c=e==null?0:e.length;if(!c||i<1)return[];for(var l=0,d=0,v=R(Gs(c/i));l<c;)v[d++]=ar(e,l,l+=i);return v}function Ug(e){for(var i=-1,o=e==null?0:e.length,c=0,l=[];++i<o;){var d=e[i];d&&(l[c++]=d)}return l}function zg(){var e=arguments.length;if(!e)return[];for(var i=R(e-1),o=arguments[0],c=e;c--;)i[c-1]=arguments[c];return Br(ue(o)?qt(o):[o],It(i,1))}var kg=fe(function(e,i){return Ke(e)?is(e,It(i,1,Ke,!0)):[]}),Hg=fe(function(e,i){var o=cr(i);return Ke(o)&&(o=r),Ke(e)?is(e,It(i,1,Ke,!0),re(o,2)):[]}),Kg=fe(function(e,i){var o=cr(i);return Ke(o)&&(o=r),Ke(e)?is(e,It(i,1,Ke,!0),r,o):[]});function Vg(e,i,o){var c=e==null?0:e.length;return c?(i=o||i===r?1:he(i),ar(e,i<0?0:i,c)):[]}function Fg(e,i,o){var c=e==null?0:e.length;return c?(i=o||i===r?1:he(i),i=c-i,ar(e,0,i<0?0:i)):[]}function Bg(e,i){return e&&e.length?sn(e,re(i,3),!0,!0):[]}function Gg(e,i){return e&&e.length?sn(e,re(i,3),!0):[]}function Wg(e,i,o,c){var l=e==null?0:e.length;return l?(o&&typeof o!="number"&&Ct(e,i,o)&&(o=0,c=l),zd(e,i,o,c)):[]}function Bu(e,i,o){var c=e==null?0:e.length;if(!c)return-1;var l=o==null?0:he(o);return l<0&&(l=et(c+l,0)),qs(e,re(i,3),l)}function Gu(e,i,o){var c=e==null?0:e.length;if(!c)return-1;var l=c-1;return o!==r&&(l=he(o),l=o<0?et(c+l,0):Pt(l,c-1)),qs(e,re(i,3),l,!0)}function Wu(e){var i=e==null?0:e.length;return i?It(e,1):[]}function Jg(e){var i=e==null?0:e.length;return i?It(e,$e):[]}function Qg(e,i){var o=e==null?0:e.length;return o?(i=i===r?1:he(i),It(e,i)):[]}function Yg(e){for(var i=-1,o=e==null?0:e.length,c={};++i<o;){var l=e[i];c[l[0]]=l[1]}return c}function Ju(e){return e&&e.length?e[0]:r}function Zg(e,i,o){var c=e==null?0:e.length;if(!c)return-1;var l=o==null?0:he(o);return l<0&&(l=et(c+l,0)),xi(e,i,l)}function Xg(e){var i=e==null?0:e.length;return i?ar(e,0,-1):[]}var ey=fe(function(e){var i=Ae(e,Oo);return i.length&&i[0]===e[0]?mo(i):[]}),ty=fe(function(e){var i=cr(e),o=Ae(e,Oo);return i===cr(o)?i=r:o.pop(),o.length&&o[0]===e[0]?mo(o,re(i,2)):[]}),ry=fe(function(e){var i=cr(e),o=Ae(e,Oo);return i=typeof i=="function"?i:r,i&&o.pop(),o.length&&o[0]===e[0]?mo(o,r,i):[]});function iy(e,i){return e==null?"":Xp.call(e,i)}function cr(e){var i=e==null?0:e.length;return i?e[i-1]:r}function sy(e,i,o){var c=e==null?0:e.length;if(!c)return-1;var l=c;return o!==r&&(l=he(o),l=l<0?et(c+l,0):Pt(l,c-1)),i===i?Mp(e,i,l):qs(e,Nc,l,!0)}function ny(e,i){return e&&e.length?ou(e,he(i)):r}var oy=fe(Qu);function Qu(e,i){return e&&e.length&&i&&i.length?_o(e,i):e}function ay(e,i,o){return e&&e.length&&i&&i.length?_o(e,i,re(o,2)):e}function cy(e,i,o){return e&&e.length&&i&&i.length?_o(e,i,r,o):e}var uy=Dr(function(e,i){var o=e==null?0:e.length,c=fo(e,i);return uu(e,Ae(i,function(l){return jr(l,o)?+l:l}).sort(wu)),c});function hy(e,i){var o=[];if(!(e&&e.length))return o;var c=-1,l=[],d=e.length;for(i=re(i,3);++c<d;){var v=e[c];i(v,c,e)&&(o.push(v),l.push(c))}return uu(e,l),o}function ko(e){return e==null?e:id.call(e)}function ly(e,i,o){var c=e==null?0:e.length;return c?(o&&typeof o!="number"&&Ct(e,i,o)?(i=0,o=c):(i=i==null?0:he(i),o=o===r?c:he(o)),ar(e,i,o)):[]}function fy(e,i){return rn(e,i)}function py(e,i,o){return xo(e,i,re(o,2))}function dy(e,i){var o=e==null?0:e.length;if(o){var c=rn(e,i);if(c<o&&yr(e[c],i))return c}return-1}function gy(e,i){return rn(e,i,!0)}function yy(e,i,o){return xo(e,i,re(o,2),!0)}function my(e,i){var o=e==null?0:e.length;if(o){var c=rn(e,i,!0)-1;if(yr(e[c],i))return c}return-1}function vy(e){return e&&e.length?lu(e):[]}function wy(e,i){return e&&e.length?lu(e,re(i,2)):[]}function by(e){var i=e==null?0:e.length;return i?ar(e,1,i):[]}function _y(e,i,o){return e&&e.length?(i=o||i===r?1:he(i),ar(e,0,i<0?0:i)):[]}function Ey(e,i,o){var c=e==null?0:e.length;return c?(i=o||i===r?1:he(i),i=c-i,ar(e,i<0?0:i,c)):[]}function Iy(e,i){return e&&e.length?sn(e,re(i,3),!1,!0):[]}function xy(e,i){return e&&e.length?sn(e,re(i,3)):[]}var Sy=fe(function(e){return Qr(It(e,1,Ke,!0))}),Py=fe(function(e){var i=cr(e);return Ke(i)&&(i=r),Qr(It(e,1,Ke,!0),re(i,2))}),Oy=fe(function(e){var i=cr(e);return i=typeof i=="function"?i:r,Qr(It(e,1,Ke,!0),r,i)});function Ry(e){return e&&e.length?Qr(e):[]}function Ny(e,i){return e&&e.length?Qr(e,re(i,2)):[]}function $y(e,i){return i=typeof i=="function"?i:r,e&&e.length?Qr(e,r,i):[]}function Ho(e){if(!(e&&e.length))return[];var i=0;return e=Fr(e,function(o){if(Ke(o))return i=et(o.length,i),!0}),so(i,function(o){return Ae(e,to(o))})}function Yu(e,i){if(!(e&&e.length))return[];var o=Ho(e);return i==null?o:Ae(o,function(c){return Gt(i,r,c)})}var Cy=fe(function(e,i){return Ke(e)?is(e,i):[]}),Ay=fe(function(e){return Po(Fr(e,Ke))}),Ty=fe(function(e){var i=cr(e);return Ke(i)&&(i=r),Po(Fr(e,Ke),re(i,2))}),Dy=fe(function(e){var i=cr(e);return i=typeof i=="function"?i:r,Po(Fr(e,Ke),r,i)}),jy=fe(Ho);function qy(e,i){return gu(e||[],i||[],rs)}function My(e,i){return gu(e||[],i||[],os)}var Ly=fe(function(e){var i=e.length,o=i>1?e[i-1]:r;return o=typeof o=="function"?(e.pop(),o):r,Yu(e,o)});function Zu(e){var i=p(e);return i.__chain__=!0,i}function Uy(e,i){return i(e),e}function pn(e,i){return i(e)}var zy=Dr(function(e){var i=e.length,o=i?e[0]:0,c=this.__wrapped__,l=function(d){return fo(d,e)};return i>1||this.__actions__.length||!(c instanceof ge)||!jr(o)?this.thru(l):(c=c.slice(o,+o+(i?1:0)),c.__actions__.push({func:pn,args:[l],thisArg:r}),new nr(c,this.__chain__).thru(function(d){return i&&!d.length&&d.push(r),d}))});function ky(){return Zu(this)}function Hy(){return new nr(this.value(),this.__chain__)}function Ky(){this.__values__===r&&(this.__values__=fh(this.value()));var e=this.__index__>=this.__values__.length,i=e?r:this.__values__[this.__index__++];return{done:e,value:i}}function Vy(){return this}function Fy(e){for(var i,o=this;o instanceof Ys;){var c=Fu(o);c.__index__=0,c.__values__=r,i?l.__wrapped__=c:i=c;var l=c;o=o.__wrapped__}return l.__wrapped__=e,i}function By(){var e=this.__wrapped__;if(e instanceof ge){var i=e;return this.__actions__.length&&(i=new ge(this)),i=i.reverse(),i.__actions__.push({func:pn,args:[ko],thisArg:r}),new nr(i,this.__chain__)}return this.thru(ko)}function Gy(){return du(this.__wrapped__,this.__actions__)}var Wy=nn(function(e,i,o){Ie.call(e,o)?++e[o]:Ar(e,o,1)});function Jy(e,i,o){var c=ue(e)?Oc:Ud;return o&&Ct(e,i,o)&&(i=r),c(e,re(i,3))}function Qy(e,i){var o=ue(e)?Fr:Yc;return o(e,re(i,3))}var Yy=Su(Bu),Zy=Su(Gu);function Xy(e,i){return It(dn(e,i),1)}function em(e,i){return It(dn(e,i),$e)}function tm(e,i,o){return o=o===r?1:he(o),It(dn(e,i),o)}function Xu(e,i){var o=ue(e)?ir:Jr;return o(e,re(i,3))}function eh(e,i){var o=ue(e)?bp:Qc;return o(e,re(i,3))}var rm=nn(function(e,i,o){Ie.call(e,o)?e[o].push(i):Ar(e,o,[i])});function im(e,i,o,c){e=Mt(e)?e:qi(e),o=o&&!c?he(o):0;var l=e.length;return o<0&&(o=et(l+o,0)),wn(e)?o<=l&&e.indexOf(i,o)>-1:!!l&&xi(e,i,o)>-1}var sm=fe(function(e,i,o){var c=-1,l=typeof i=="function",d=Mt(e)?R(e.length):[];return Jr(e,function(v){d[++c]=l?Gt(i,v,o):ss(v,i,o)}),d}),nm=nn(function(e,i,o){Ar(e,o,i)});function dn(e,i){var o=ue(e)?Ae:iu;return o(e,re(i,3))}function om(e,i,o,c){return e==null?[]:(ue(i)||(i=i==null?[]:[i]),o=c?r:o,ue(o)||(o=o==null?[]:[o]),au(e,i,o))}var am=nn(function(e,i,o){e[o?0:1].push(i)},function(){return[[],[]]});function cm(e,i,o){var c=ue(e)?Xn:Cc,l=arguments.length<3;return c(e,re(i,4),o,l,Jr)}function um(e,i,o){var c=ue(e)?_p:Cc,l=arguments.length<3;return c(e,re(i,4),o,l,Qc)}function hm(e,i){var o=ue(e)?Fr:Yc;return o(e,mn(re(i,3)))}function lm(e){var i=ue(e)?Bc:ig;return i(e)}function fm(e,i,o){(o?Ct(e,i,o):i===r)?i=1:i=he(i);var c=ue(e)?Dd:sg;return c(e,i)}function pm(e){var i=ue(e)?jd:og;return i(e)}function dm(e){if(e==null)return 0;if(Mt(e))return wn(e)?Pi(e):e.length;var i=Ot(e);return i==pe||i==Se?e.size:wo(e).length}function gm(e,i,o){var c=ue(e)?eo:ag;return o&&Ct(e,i,o)&&(i=r),c(e,re(i,3))}var ym=fe(function(e,i){if(e==null)return[];var o=i.length;return o>1&&Ct(e,i[0],i[1])?i=[]:o>2&&Ct(i[0],i[1],i[2])&&(i=[i[0]]),au(e,It(i,1),[])}),gn=Qp||function(){return Et.Date.now()};function mm(e,i){if(typeof i!="function")throw new sr(f);return e=he(e),function(){if(--e<1)return i.apply(this,arguments)}}function th(e,i,o){return i=o?r:i,i=e&&i==null?e.length:i,Tr(e,K,r,r,r,r,i)}function rh(e,i){var o;if(typeof i!="function")throw new sr(f);return e=he(e),function(){return--e>0&&(o=i.apply(this,arguments)),e<=1&&(i=r),o}}var Ko=fe(function(e,i,o){var c=ne;if(o.length){var l=Gr(o,Di(Ko));c|=q}return Tr(e,c,i,o,l)}),ih=fe(function(e,i,o){var c=ne|oe;if(o.length){var l=Gr(o,Di(ih));c|=q}return Tr(i,c,e,o,l)});function sh(e,i,o){i=o?r:i;var c=Tr(e,$,r,r,r,r,r,i);return c.placeholder=sh.placeholder,c}function nh(e,i,o){i=o?r:i;var c=Tr(e,C,r,r,r,r,r,i);return c.placeholder=nh.placeholder,c}function oh(e,i,o){var c,l,d,v,b,x,M=0,L=!1,U=!1,F=!0;if(typeof e!="function")throw new sr(f);i=ur(i)||0,Le(o)&&(L=!!o.leading,U="maxWait"in o,d=U?et(ur(o.maxWait)||0,i):d,F="trailing"in o?!!o.trailing:F);function Z(Ve){var mr=c,Lr=l;return c=l=r,M=Ve,v=e.apply(Lr,mr),v}function ie(Ve){return M=Ve,b=us(de,i),L?Z(Ve):v}function le(Ve){var mr=Ve-x,Lr=Ve-M,Sh=i-mr;return U?Pt(Sh,d-Lr):Sh}function se(Ve){var mr=Ve-x,Lr=Ve-M;return x===r||mr>=i||mr<0||U&&Lr>=d}function de(){var Ve=gn();if(se(Ve))return ye(Ve);b=us(de,le(Ve))}function ye(Ve){return b=r,F&&c?Z(Ve):(c=l=r,v)}function Yt(){b!==r&&yu(b),M=0,c=x=l=b=r}function At(){return b===r?v:ye(gn())}function Zt(){var Ve=gn(),mr=se(Ve);if(c=arguments,l=this,x=Ve,mr){if(b===r)return ie(x);if(U)return yu(b),b=us(de,i),Z(x)}return b===r&&(b=us(de,i)),v}return Zt.cancel=Yt,Zt.flush=At,Zt}var vm=fe(function(e,i){return Jc(e,1,i)}),wm=fe(function(e,i,o){return Jc(e,ur(i)||0,o)});function bm(e){return Tr(e,we)}function yn(e,i){if(typeof e!="function"||i!=null&&typeof i!="function")throw new sr(f);var o=function(){var c=arguments,l=i?i.apply(this,c):c[0],d=o.cache;if(d.has(l))return d.get(l);var v=e.apply(this,c);return o.cache=d.set(l,v)||d,v};return o.cache=new(yn.Cache||Cr),o}yn.Cache=Cr;function mn(e){if(typeof e!="function")throw new sr(f);return function(){var i=arguments;switch(i.length){case 0:return!e.call(this);case 1:return!e.call(this,i[0]);case 2:return!e.call(this,i[0],i[1]);case 3:return!e.call(this,i[0],i[1],i[2])}return!e.apply(this,i)}}function _m(e){return rh(2,e)}var Em=cg(function(e,i){i=i.length==1&&ue(i[0])?Ae(i[0],Wt(re())):Ae(It(i,1),Wt(re()));var o=i.length;return fe(function(c){for(var l=-1,d=Pt(c.length,o);++l<d;)c[l]=i[l].call(this,c[l]);return Gt(e,this,c)})}),Vo=fe(function(e,i){var o=Gr(i,Di(Vo));return Tr(e,q,r,i,o)}),ah=fe(function(e,i){var o=Gr(i,Di(ah));return Tr(e,z,r,i,o)}),Im=Dr(function(e,i){return Tr(e,W,r,r,r,i)});function xm(e,i){if(typeof e!="function")throw new sr(f);return i=i===r?i:he(i),fe(e,i)}function Sm(e,i){if(typeof e!="function")throw new sr(f);return i=i==null?0:et(he(i),0),fe(function(o){var c=o[i],l=Zr(o,0,i);return c&&Br(l,c),Gt(e,this,l)})}function Pm(e,i,o){var c=!0,l=!0;if(typeof e!="function")throw new sr(f);return Le(o)&&(c="leading"in o?!!o.leading:c,l="trailing"in o?!!o.trailing:l),oh(e,i,{leading:c,maxWait:i,trailing:l})}function Om(e){return th(e,1)}function Rm(e,i){return Vo(Ro(i),e)}function Nm(){if(!arguments.length)return[];var e=arguments[0];return ue(e)?e:[e]}function $m(e){return or(e,j)}function Cm(e,i){return i=typeof i=="function"?i:r,or(e,j,i)}function Am(e){return or(e,_|j)}function Tm(e,i){return i=typeof i=="function"?i:r,or(e,_|j,i)}function Dm(e,i){return i==null||Wc(e,i,mt(i))}function yr(e,i){return e===i||e!==e&&i!==i}var jm=un(yo),qm=un(function(e,i){return e>=i}),di=eu(function(){return arguments}())?eu:function(e){return ze(e)&&Ie.call(e,"callee")&&!zc.call(e,"callee")},ue=R.isArray,Mm=_c?Wt(_c):Fd;function Mt(e){return e!=null&&vn(e.length)&&!qr(e)}function Ke(e){return ze(e)&&Mt(e)}function Lm(e){return e===!0||e===!1||ze(e)&&$t(e)==T}var Xr=Zp||ta,Um=Ec?Wt(Ec):Bd;function zm(e){return ze(e)&&e.nodeType===1&&!hs(e)}function km(e){if(e==null)return!0;if(Mt(e)&&(ue(e)||typeof e=="string"||typeof e.splice=="function"||Xr(e)||ji(e)||di(e)))return!e.length;var i=Ot(e);if(i==pe||i==Se)return!e.size;if(cs(e))return!wo(e).length;for(var o in e)if(Ie.call(e,o))return!1;return!0}function Hm(e,i){return ns(e,i)}function Km(e,i,o){o=typeof o=="function"?o:r;var c=o?o(e,i):r;return c===r?ns(e,i,r,o):!!c}function Fo(e){if(!ze(e))return!1;var i=$t(e);return i==E||i==h||typeof e.message=="string"&&typeof e.name=="string"&&!hs(e)}function Vm(e){return typeof e=="number"&&Hc(e)}function qr(e){if(!Le(e))return!1;var i=$t(e);return i==te||i==ce||i==A||i==Qe}function ch(e){return typeof e=="number"&&e==he(e)}function vn(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=Y}function Le(e){var i=typeof e;return e!=null&&(i=="object"||i=="function")}function ze(e){return e!=null&&typeof e=="object"}var uh=Ic?Wt(Ic):Wd;function Fm(e,i){return e===i||vo(e,i,jo(i))}function Bm(e,i,o){return o=typeof o=="function"?o:r,vo(e,i,jo(i),o)}function Gm(e){return hh(e)&&e!=+e}function Wm(e){if(Cg(e))throw new ae(u);return tu(e)}function Jm(e){return e===null}function Qm(e){return e==null}function hh(e){return typeof e=="number"||ze(e)&&$t(e)==be}function hs(e){if(!ze(e)||$t(e)!=me)return!1;var i=Vs(e);if(i===null)return!0;var o=Ie.call(i,"constructor")&&i.constructor;return typeof o=="function"&&o instanceof o&&zs.call(o)==Bp}var Bo=xc?Wt(xc):Jd;function Ym(e){return ch(e)&&e>=-Y&&e<=Y}var lh=Sc?Wt(Sc):Qd;function wn(e){return typeof e=="string"||!ue(e)&&ze(e)&&$t(e)==De}function Qt(e){return typeof e=="symbol"||ze(e)&&$t(e)==je}var ji=Pc?Wt(Pc):Yd;function Zm(e){return e===r}function Xm(e){return ze(e)&&Ot(e)==Re}function ev(e){return ze(e)&&$t(e)==qe}var tv=un(bo),rv=un(function(e,i){return e<=i});function fh(e){if(!e)return[];if(Mt(e))return wn(e)?dr(e):qt(e);if(Yi&&e[Yi])return Dp(e[Yi]());var i=Ot(e),o=i==pe?oo:i==Se?Ms:qi;return o(e)}function Mr(e){if(!e)return e===0?e:0;if(e=ur(e),e===$e||e===-$e){var i=e<0?-1:1;return i*G}return e===e?e:0}function he(e){var i=Mr(e),o=i%1;return i===i?o?i-o:i:0}function ph(e){return e?hi(he(e),0,J):0}function ur(e){if(typeof e=="number")return e;if(Qt(e))return B;if(Le(e)){var i=typeof e.valueOf=="function"?e.valueOf():e;e=Le(i)?i+"":i}if(typeof e!="string")return e===0?e:+e;e=Ac(e);var o=Mf.test(e);return o||Uf.test(e)?mp(e.slice(2),o?2:8):qf.test(e)?B:+e}function dh(e){return xr(e,Lt(e))}function iv(e){return e?hi(he(e),-Y,Y):e===0?e:0}function _e(e){return e==null?"":Jt(e)}var sv=Ai(function(e,i){if(cs(i)||Mt(i)){xr(i,mt(i),e);return}for(var o in i)Ie.call(i,o)&&rs(e,o,i[o])}),gh=Ai(function(e,i){xr(i,Lt(i),e)}),bn=Ai(function(e,i,o,c){xr(i,Lt(i),e,c)}),nv=Ai(function(e,i,o,c){xr(i,mt(i),e,c)}),ov=Dr(fo);function av(e,i){var o=Ci(e);return i==null?o:Gc(o,i)}var cv=fe(function(e,i){e=Oe(e);var o=-1,c=i.length,l=c>2?i[2]:r;for(l&&Ct(i[0],i[1],l)&&(c=1);++o<c;)for(var d=i[o],v=Lt(d),b=-1,x=v.length;++b<x;){var M=v[b],L=e[M];(L===r||yr(L,Ri[M])&&!Ie.call(e,M))&&(e[M]=d[M])}return e}),uv=fe(function(e){return e.push(r,Au),Gt(yh,r,e)});function hv(e,i){return Rc(e,re(i,3),Ir)}function lv(e,i){return Rc(e,re(i,3),go)}function fv(e,i){return e==null?e:po(e,re(i,3),Lt)}function pv(e,i){return e==null?e:Zc(e,re(i,3),Lt)}function dv(e,i){return e&&Ir(e,re(i,3))}function gv(e,i){return e&&go(e,re(i,3))}function yv(e){return e==null?[]:en(e,mt(e))}function mv(e){return e==null?[]:en(e,Lt(e))}function Go(e,i,o){var c=e==null?r:li(e,i);return c===r?o:c}function vv(e,i){return e!=null&&ju(e,i,kd)}function Wo(e,i){return e!=null&&ju(e,i,Hd)}var wv=Ou(function(e,i,o){i!=null&&typeof i.toString!="function"&&(i=ks.call(i)),e[i]=o},Qo(Ut)),bv=Ou(function(e,i,o){i!=null&&typeof i.toString!="function"&&(i=ks.call(i)),Ie.call(e,i)?e[i].push(o):e[i]=[o]},re),_v=fe(ss);function mt(e){return Mt(e)?Fc(e):wo(e)}function Lt(e){return Mt(e)?Fc(e,!0):Zd(e)}function Ev(e,i){var o={};return i=re(i,3),Ir(e,function(c,l,d){Ar(o,i(c,l,d),c)}),o}function Iv(e,i){var o={};return i=re(i,3),Ir(e,function(c,l,d){Ar(o,l,i(c,l,d))}),o}var xv=Ai(function(e,i,o){tn(e,i,o)}),yh=Ai(function(e,i,o,c){tn(e,i,o,c)}),Sv=Dr(function(e,i){var o={};if(e==null)return o;var c=!1;i=Ae(i,function(d){return d=Yr(d,e),c||(c=d.length>1),d}),xr(e,To(e),o),c&&(o=or(o,_|O|j,wg));for(var l=i.length;l--;)So(o,i[l]);return o});function Pv(e,i){return mh(e,mn(re(i)))}var Ov=Dr(function(e,i){return e==null?{}:eg(e,i)});function mh(e,i){if(e==null)return{};var o=Ae(To(e),function(c){return[c]});return i=re(i),cu(e,o,function(c,l){return i(c,l[0])})}function Rv(e,i,o){i=Yr(i,e);var c=-1,l=i.length;for(l||(l=1,e=r);++c<l;){var d=e==null?r:e[Sr(i[c])];d===r&&(c=l,d=o),e=qr(d)?d.call(e):d}return e}function Nv(e,i,o){return e==null?e:os(e,i,o)}function $v(e,i,o,c){return c=typeof c=="function"?c:r,e==null?e:os(e,i,o,c)}var vh=$u(mt),wh=$u(Lt);function Cv(e,i,o){var c=ue(e),l=c||Xr(e)||ji(e);if(i=re(i,4),o==null){var d=e&&e.constructor;l?o=c?new d:[]:Le(e)?o=qr(d)?Ci(Vs(e)):{}:o={}}return(l?ir:Ir)(e,function(v,b,x){return i(o,v,b,x)}),o}function Av(e,i){return e==null?!0:So(e,i)}function Tv(e,i,o){return e==null?e:pu(e,i,Ro(o))}function Dv(e,i,o,c){return c=typeof c=="function"?c:r,e==null?e:pu(e,i,Ro(o),c)}function qi(e){return e==null?[]:no(e,mt(e))}function jv(e){return e==null?[]:no(e,Lt(e))}function qv(e,i,o){return o===r&&(o=i,i=r),o!==r&&(o=ur(o),o=o===o?o:0),i!==r&&(i=ur(i),i=i===i?i:0),hi(ur(e),i,o)}function Mv(e,i,o){return i=Mr(i),o===r?(o=i,i=0):o=Mr(o),e=ur(e),Kd(e,i,o)}function Lv(e,i,o){if(o&&typeof o!="boolean"&&Ct(e,i,o)&&(i=o=r),o===r&&(typeof i=="boolean"?(o=i,i=r):typeof e=="boolean"&&(o=e,e=r)),e===r&&i===r?(e=0,i=1):(e=Mr(e),i===r?(i=e,e=0):i=Mr(i)),e>i){var c=e;e=i,i=c}if(o||e%1||i%1){var l=Kc();return Pt(e+l*(i-e+yp("1e-"+((l+"").length-1))),i)}return Eo(e,i)}var Uv=Ti(function(e,i,o){return i=i.toLowerCase(),e+(o?bh(i):i)});function bh(e){return Jo(_e(e).toLowerCase())}function _h(e){return e=_e(e),e&&e.replace(kf,Np).replace(op,"")}function zv(e,i,o){e=_e(e),i=Jt(i);var c=e.length;o=o===r?c:hi(he(o),0,c);var l=o;return o-=i.length,o>=0&&e.slice(o,l)==i}function kv(e){return e=_e(e),e&&nt.test(e)?e.replace(Ji,$p):e}function Hv(e){return e=_e(e),e&<.test(e)?e.replace(Ge,"\\$&"):e}var Kv=Ti(function(e,i,o){return e+(o?"-":"")+i.toLowerCase()}),Vv=Ti(function(e,i,o){return e+(o?" ":"")+i.toLowerCase()}),Fv=xu("toLowerCase");function Bv(e,i,o){e=_e(e),i=he(i);var c=i?Pi(e):0;if(!i||c>=i)return e;var l=(i-c)/2;return cn(Ws(l),o)+e+cn(Gs(l),o)}function Gv(e,i,o){e=_e(e),i=he(i);var c=i?Pi(e):0;return i&&c<i?e+cn(i-c,o):e}function Wv(e,i,o){e=_e(e),i=he(i);var c=i?Pi(e):0;return i&&c<i?cn(i-c,o)+e:e}function Jv(e,i,o){return o||i==null?i=0:i&&(i=+i),rd(_e(e).replace(We,""),i||0)}function Qv(e,i,o){return(o?Ct(e,i,o):i===r)?i=1:i=he(i),Io(_e(e),i)}function Yv(){var e=arguments,i=_e(e[0]);return e.length<3?i:i.replace(e[1],e[2])}var Zv=Ti(function(e,i,o){return e+(o?"_":"")+i.toLowerCase()});function Xv(e,i,o){return o&&typeof o!="number"&&Ct(e,i,o)&&(i=o=r),o=o===r?J:o>>>0,o?(e=_e(e),e&&(typeof i=="string"||i!=null&&!Bo(i))&&(i=Jt(i),!i&&Si(e))?Zr(dr(e),0,o):e.split(i,o)):[]}var e0=Ti(function(e,i,o){return e+(o?" ":"")+Jo(i)});function t0(e,i,o){return e=_e(e),o=o==null?0:hi(he(o),0,e.length),i=Jt(i),e.slice(o,o+i.length)==i}function r0(e,i,o){var c=p.templateSettings;o&&Ct(e,i,o)&&(i=r),e=_e(e),i=bn({},i,c,Cu);var l=bn({},i.imports,c.imports,Cu),d=mt(l),v=no(l,d),b,x,M=0,L=i.interpolate||As,U="__p += '",F=ao((i.escape||As).source+"|"+L.source+"|"+(L===Ze?jf:As).source+"|"+(i.evaluate||As).source+"|$","g"),Z="//# sourceURL="+(Ie.call(i,"sourceURL")?(i.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++lp+"]")+` `;e.replace(F,function(se,de,ye,Yt,At,Zt){return ye||(ye=Yt),U+=e.slice(M,Zt).replace(Hf,Cp),de&&(b=!0,U+=`' + __e(`+de+`) + '`),At&&(x=!0,U+=`'; `+At+`; __p += '`),ye&&(U+=`' + ((__t = (`+ye+`)) == null ? '' : __t) + '`),M=Zt+se.length,se}),U+=`'; `;var ie=Ie.call(i,"variable")&&i.variable;if(!ie)U=`with (obj) { `+U+` } `;else if(Tf.test(ie))throw new ae(y);U=(x?U.replace(Vr,""):U).replace(ni,"$1").replace(_i,"$1;"),U="function("+(ie||"obj")+`) { `+(ie?"":`obj || (obj = {}); `)+"var __t, __p = ''"+(b?", __e = _.escape":"")+(x?`, __j = Array.prototype.join; function print() { __p += __j.call(arguments, '') } `:`; `)+U+`return __p }`;var le=Ih(function(){return ve(d,Z+"return "+U).apply(r,v)});if(le.source=U,Fo(le))throw le;return le}function i0(e){return _e(e).toLowerCase()}function s0(e){return _e(e).toUpperCase()}function n0(e,i,o){if(e=_e(e),e&&(o||i===r))return Ac(e);if(!e||!(i=Jt(i)))return e;var c=dr(e),l=dr(i),d=Tc(c,l),v=Dc(c,l)+1;return Zr(c,d,v).join("")}function o0(e,i,o){if(e=_e(e),e&&(o||i===r))return e.slice(0,qc(e)+1);if(!e||!(i=Jt(i)))return e;var c=dr(e),l=Dc(c,dr(i))+1;return Zr(c,0,l).join("")}function a0(e,i,o){if(e=_e(e),e&&(o||i===r))return e.replace(We,"");if(!e||!(i=Jt(i)))return e;var c=dr(e),l=Tc(c,dr(i));return Zr(c,l).join("")}function c0(e,i){var o=tt,c=lr;if(Le(i)){var l="separator"in i?i.separator:l;o="length"in i?he(i.length):o,c="omission"in i?Jt(i.omission):c}e=_e(e);var d=e.length;if(Si(e)){var v=dr(e);d=v.length}if(o>=d)return e;var b=o-Pi(c);if(b<1)return c;var x=v?Zr(v,0,b).join(""):e.slice(0,b);if(l===r)return x+c;if(v&&(b+=x.length-b),Bo(l)){if(e.slice(b).search(l)){var M,L=x;for(l.global||(l=ao(l.source,_e(ec.exec(l))+"g")),l.lastIndex=0;M=l.exec(L);)var U=M.index;x=x.slice(0,U===r?b:U)}}else if(e.indexOf(Jt(l),b)!=b){var F=x.lastIndexOf(l);F>-1&&(x=x.slice(0,F))}return x+c}function u0(e){return e=_e(e),e&&st.test(e)?e.replace(Ei,Lp):e}var h0=Ti(function(e,i,o){return e+(o?" ":"")+i.toUpperCase()}),Jo=xu("toUpperCase");function Eh(e,i,o){return e=_e(e),i=o?r:i,i===r?Tp(e)?kp(e):xp(e):e.match(i)||[]}var Ih=fe(function(e,i){try{return Gt(e,r,i)}catch(o){return Fo(o)?o:new ae(o)}}),l0=Dr(function(e,i){return ir(i,function(o){o=Sr(o),Ar(e,o,Ko(e[o],e))}),e});function f0(e){var i=e==null?0:e.length,o=re();return e=i?Ae(e,function(c){if(typeof c[1]!="function")throw new sr(f);return[o(c[0]),c[1]]}):[],fe(function(c){for(var l=-1;++l<i;){var d=e[l];if(Gt(d[0],this,c))return Gt(d[1],this,c)}})}function p0(e){return Ld(or(e,_))}function Qo(e){return function(){return e}}function d0(e,i){return e==null||e!==e?i:e}var g0=Pu(),y0=Pu(!0);function Ut(e){return e}function Yo(e){return ru(typeof e=="function"?e:or(e,_))}function m0(e){return su(or(e,_))}function v0(e,i){return nu(e,or(i,_))}var w0=fe(function(e,i){return function(o){return ss(o,e,i)}}),b0=fe(function(e,i){return function(o){return ss(e,o,i)}});function Zo(e,i,o){var c=mt(i),l=en(i,c);o==null&&!(Le(i)&&(l.length||!c.length))&&(o=i,i=e,e=this,l=en(i,mt(i)));var d=!(Le(o)&&"chain"in o)||!!o.chain,v=qr(e);return ir(l,function(b){var x=i[b];e[b]=x,v&&(e.prototype[b]=function(){var M=this.__chain__;if(d||M){var L=e(this.__wrapped__),U=L.__actions__=qt(this.__actions__);return U.push({func:x,args:arguments,thisArg:e}),L.__chain__=M,L}return x.apply(e,Br([this.value()],arguments))})}),e}function _0(){return Et._===this&&(Et._=Gp),this}function Xo(){}function E0(e){return e=he(e),fe(function(i){return ou(i,e)})}var I0=$o(Ae),x0=$o(Oc),S0=$o(eo);function xh(e){return Mo(e)?to(Sr(e)):tg(e)}function P0(e){return function(i){return e==null?r:li(e,i)}}var O0=Ru(),R0=Ru(!0);function ea(){return[]}function ta(){return!1}function N0(){return{}}function $0(){return""}function C0(){return!0}function A0(e,i){if(e=he(e),e<1||e>Y)return[];var o=J,c=Pt(e,J);i=re(i),e-=J;for(var l=so(c,i);++o<e;)i(o);return l}function T0(e){return ue(e)?Ae(e,Sr):Qt(e)?[e]:qt(Vu(_e(e)))}function D0(e){var i=++Fp;return _e(e)+i}var j0=an(function(e,i){return e+i},0),q0=Co("ceil"),M0=an(function(e,i){return e/i},1),L0=Co("floor");function U0(e){return e&&e.length?Xs(e,Ut,yo):r}function z0(e,i){return e&&e.length?Xs(e,re(i,2),yo):r}function k0(e){return $c(e,Ut)}function H0(e,i){return $c(e,re(i,2))}function K0(e){return e&&e.length?Xs(e,Ut,bo):r}function V0(e,i){return e&&e.length?Xs(e,re(i,2),bo):r}var F0=an(function(e,i){return e*i},1),B0=Co("round"),G0=an(function(e,i){return e-i},0);function W0(e){return e&&e.length?io(e,Ut):0}function J0(e,i){return e&&e.length?io(e,re(i,2)):0}return p.after=mm,p.ary=th,p.assign=sv,p.assignIn=gh,p.assignInWith=bn,p.assignWith=nv,p.at=ov,p.before=rh,p.bind=Ko,p.bindAll=l0,p.bindKey=ih,p.castArray=Nm,p.chain=Zu,p.chunk=Lg,p.compact=Ug,p.concat=zg,p.cond=f0,p.conforms=p0,p.constant=Qo,p.countBy=Wy,p.create=av,p.curry=sh,p.curryRight=nh,p.debounce=oh,p.defaults=cv,p.defaultsDeep=uv,p.defer=vm,p.delay=wm,p.difference=kg,p.differenceBy=Hg,p.differenceWith=Kg,p.drop=Vg,p.dropRight=Fg,p.dropRightWhile=Bg,p.dropWhile=Gg,p.fill=Wg,p.filter=Qy,p.flatMap=Xy,p.flatMapDeep=em,p.flatMapDepth=tm,p.flatten=Wu,p.flattenDeep=Jg,p.flattenDepth=Qg,p.flip=bm,p.flow=g0,p.flowRight=y0,p.fromPairs=Yg,p.functions=yv,p.functionsIn=mv,p.groupBy=rm,p.initial=Xg,p.intersection=ey,p.intersectionBy=ty,p.intersectionWith=ry,p.invert=wv,p.invertBy=bv,p.invokeMap=sm,p.iteratee=Yo,p.keyBy=nm,p.keys=mt,p.keysIn=Lt,p.map=dn,p.mapKeys=Ev,p.mapValues=Iv,p.matches=m0,p.matchesProperty=v0,p.memoize=yn,p.merge=xv,p.mergeWith=yh,p.method=w0,p.methodOf=b0,p.mixin=Zo,p.negate=mn,p.nthArg=E0,p.omit=Sv,p.omitBy=Pv,p.once=_m,p.orderBy=om,p.over=I0,p.overArgs=Em,p.overEvery=x0,p.overSome=S0,p.partial=Vo,p.partialRight=ah,p.partition=am,p.pick=Ov,p.pickBy=mh,p.property=xh,p.propertyOf=P0,p.pull=oy,p.pullAll=Qu,p.pullAllBy=ay,p.pullAllWith=cy,p.pullAt=uy,p.range=O0,p.rangeRight=R0,p.rearg=Im,p.reject=hm,p.remove=hy,p.rest=xm,p.reverse=ko,p.sampleSize=fm,p.set=Nv,p.setWith=$v,p.shuffle=pm,p.slice=ly,p.sortBy=ym,p.sortedUniq=vy,p.sortedUniqBy=wy,p.split=Xv,p.spread=Sm,p.tail=by,p.take=_y,p.takeRight=Ey,p.takeRightWhile=Iy,p.takeWhile=xy,p.tap=Uy,p.throttle=Pm,p.thru=pn,p.toArray=fh,p.toPairs=vh,p.toPairsIn=wh,p.toPath=T0,p.toPlainObject=dh,p.transform=Cv,p.unary=Om,p.union=Sy,p.unionBy=Py,p.unionWith=Oy,p.uniq=Ry,p.uniqBy=Ny,p.uniqWith=$y,p.unset=Av,p.unzip=Ho,p.unzipWith=Yu,p.update=Tv,p.updateWith=Dv,p.values=qi,p.valuesIn=jv,p.without=Cy,p.words=Eh,p.wrap=Rm,p.xor=Ay,p.xorBy=Ty,p.xorWith=Dy,p.zip=jy,p.zipObject=qy,p.zipObjectDeep=My,p.zipWith=Ly,p.entries=vh,p.entriesIn=wh,p.extend=gh,p.extendWith=bn,Zo(p,p),p.add=j0,p.attempt=Ih,p.camelCase=Uv,p.capitalize=bh,p.ceil=q0,p.clamp=qv,p.clone=$m,p.cloneDeep=Am,p.cloneDeepWith=Tm,p.cloneWith=Cm,p.conformsTo=Dm,p.deburr=_h,p.defaultTo=d0,p.divide=M0,p.endsWith=zv,p.eq=yr,p.escape=kv,p.escapeRegExp=Hv,p.every=Jy,p.find=Yy,p.findIndex=Bu,p.findKey=hv,p.findLast=Zy,p.findLastIndex=Gu,p.findLastKey=lv,p.floor=L0,p.forEach=Xu,p.forEachRight=eh,p.forIn=fv,p.forInRight=pv,p.forOwn=dv,p.forOwnRight=gv,p.get=Go,p.gt=jm,p.gte=qm,p.has=vv,p.hasIn=Wo,p.head=Ju,p.identity=Ut,p.includes=im,p.indexOf=Zg,p.inRange=Mv,p.invoke=_v,p.isArguments=di,p.isArray=ue,p.isArrayBuffer=Mm,p.isArrayLike=Mt,p.isArrayLikeObject=Ke,p.isBoolean=Lm,p.isBuffer=Xr,p.isDate=Um,p.isElement=zm,p.isEmpty=km,p.isEqual=Hm,p.isEqualWith=Km,p.isError=Fo,p.isFinite=Vm,p.isFunction=qr,p.isInteger=ch,p.isLength=vn,p.isMap=uh,p.isMatch=Fm,p.isMatchWith=Bm,p.isNaN=Gm,p.isNative=Wm,p.isNil=Qm,p.isNull=Jm,p.isNumber=hh,p.isObject=Le,p.isObjectLike=ze,p.isPlainObject=hs,p.isRegExp=Bo,p.isSafeInteger=Ym,p.isSet=lh,p.isString=wn,p.isSymbol=Qt,p.isTypedArray=ji,p.isUndefined=Zm,p.isWeakMap=Xm,p.isWeakSet=ev,p.join=iy,p.kebabCase=Kv,p.last=cr,p.lastIndexOf=sy,p.lowerCase=Vv,p.lowerFirst=Fv,p.lt=tv,p.lte=rv,p.max=U0,p.maxBy=z0,p.mean=k0,p.meanBy=H0,p.min=K0,p.minBy=V0,p.stubArray=ea,p.stubFalse=ta,p.stubObject=N0,p.stubString=$0,p.stubTrue=C0,p.multiply=F0,p.nth=ny,p.noConflict=_0,p.noop=Xo,p.now=gn,p.pad=Bv,p.padEnd=Gv,p.padStart=Wv,p.parseInt=Jv,p.random=Lv,p.reduce=cm,p.reduceRight=um,p.repeat=Qv,p.replace=Yv,p.result=Rv,p.round=B0,p.runInContext=I,p.sample=lm,p.size=dm,p.snakeCase=Zv,p.some=gm,p.sortedIndex=fy,p.sortedIndexBy=py,p.sortedIndexOf=dy,p.sortedLastIndex=gy,p.sortedLastIndexBy=yy,p.sortedLastIndexOf=my,p.startCase=e0,p.startsWith=t0,p.subtract=G0,p.sum=W0,p.sumBy=J0,p.template=r0,p.times=A0,p.toFinite=Mr,p.toInteger=he,p.toLength=ph,p.toLower=i0,p.toNumber=ur,p.toSafeInteger=iv,p.toString=_e,p.toUpper=s0,p.trim=n0,p.trimEnd=o0,p.trimStart=a0,p.truncate=c0,p.unescape=u0,p.uniqueId=D0,p.upperCase=h0,p.upperFirst=Jo,p.each=Xu,p.eachRight=eh,p.first=Ju,Zo(p,function(){var e={};return Ir(p,function(i,o){Ie.call(p.prototype,o)||(e[o]=i)}),e}(),{chain:!1}),p.VERSION=n,ir(["bind","bindKey","curry","curryRight","partial","partialRight"],function(e){p[e].placeholder=p}),ir(["drop","take"],function(e,i){ge.prototype[e]=function(o){o=o===r?1:et(he(o),0);var c=this.__filtered__&&!i?new ge(this):this.clone();return c.__filtered__?c.__takeCount__=Pt(o,c.__takeCount__):c.__views__.push({size:Pt(o,J),type:e+(c.__dir__<0?"Right":"")}),c},ge.prototype[e+"Right"]=function(o){return this.reverse()[e](o).reverse()}}),ir(["filter","map","takeWhile"],function(e,i){var o=i+1,c=o==k||o==Ue;ge.prototype[e]=function(l){var d=this.clone();return d.__iteratees__.push({iteratee:re(l,3),type:o}),d.__filtered__=d.__filtered__||c,d}}),ir(["head","last"],function(e,i){var o="take"+(i?"Right":"");ge.prototype[e]=function(){return this[o](1).value()[0]}}),ir(["initial","tail"],function(e,i){var o="drop"+(i?"":"Right");ge.prototype[e]=function(){return this.__filtered__?new ge(this):this[o](1)}}),ge.prototype.compact=function(){return this.filter(Ut)},ge.prototype.find=function(e){return this.filter(e).head()},ge.prototype.findLast=function(e){return this.reverse().find(e)},ge.prototype.invokeMap=fe(function(e,i){return typeof e=="function"?new ge(this):this.map(function(o){return ss(o,e,i)})}),ge.prototype.reject=function(e){return this.filter(mn(re(e)))},ge.prototype.slice=function(e,i){e=he(e);var o=this;return o.__filtered__&&(e>0||i<0)?new ge(o):(e<0?o=o.takeRight(-e):e&&(o=o.drop(e)),i!==r&&(i=he(i),o=i<0?o.dropRight(-i):o.take(i-e)),o)},ge.prototype.takeRightWhile=function(e){return this.reverse().takeWhile(e).reverse()},ge.prototype.toArray=function(){return this.take(J)},Ir(ge.prototype,function(e,i){var o=/^(?:filter|find|map|reject)|While$/.test(i),c=/^(?:head|last)$/.test(i),l=p[c?"take"+(i=="last"?"Right":""):i],d=c||/^find/.test(i);l&&(p.prototype[i]=function(){var v=this.__wrapped__,b=c?[1]:arguments,x=v instanceof ge,M=b[0],L=x||ue(v),U=function(de){var ye=l.apply(p,Br([de],b));return c&&F?ye[0]:ye};L&&o&&typeof M=="function"&&M.length!=1&&(x=L=!1);var F=this.__chain__,Z=!!this.__actions__.length,ie=d&&!F,le=x&&!Z;if(!d&&L){v=le?v:new ge(this);var se=e.apply(v,b);return se.__actions__.push({func:pn,args:[U],thisArg:r}),new nr(se,F)}return ie&&le?e.apply(this,b):(se=this.thru(U),ie?c?se.value()[0]:se.value():se)})}),ir(["pop","push","shift","sort","splice","unshift"],function(e){var i=Ls[e],o=/^(?:push|sort|unshift)$/.test(e)?"tap":"thru",c=/^(?:pop|shift)$/.test(e);p.prototype[e]=function(){var l=arguments;if(c&&!this.__chain__){var d=this.value();return i.apply(ue(d)?d:[],l)}return this[o](function(v){return i.apply(ue(v)?v:[],l)})}}),Ir(ge.prototype,function(e,i){var o=p[i];if(o){var c=o.name+"";Ie.call($i,c)||($i[c]=[]),$i[c].push({name:i,func:o})}}),$i[on(r,oe).name]=[{name:"wrapper",func:r}],ge.prototype.clone=ud,ge.prototype.reverse=hd,ge.prototype.value=ld,p.prototype.at=zy,p.prototype.chain=ky,p.prototype.commit=Hy,p.prototype.next=Ky,p.prototype.plant=Fy,p.prototype.reverse=By,p.prototype.toJSON=p.prototype.valueOf=p.prototype.value=Gy,p.prototype.first=p.prototype.head,Yi&&(p.prototype[Yi]=Vy),p},Oi=Hp();oi?((oi.exports=Oi)._=Oi,Qn._=Oi):Et._=Oi}).call(ms)})(Ta,Ta.exports);var qx=Object.defineProperty,Mx=Object.defineProperties,Lx=Object.getOwnPropertyDescriptors,Ol=Object.getOwnPropertySymbols,Ux=Object.prototype.hasOwnProperty,zx=Object.prototype.propertyIsEnumerable,Rl=(s,t,r)=>t in s?qx(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,Pn=(s,t)=>{for(var r in t||(t={}))Ux.call(t,r)&&Rl(s,r,t[r]);if(Ol)for(var r of Ol(t))zx.call(t,r)&&Rl(s,r,t[r]);return s},kx=(s,t)=>Mx(s,Lx(t));function ii(s,t,r){var n;const a=Pw(s);return((n=t.rpcMap)==null?void 0:n[a.reference])||`${jx}?chainId=${a.namespace}:${a.reference}&projectId=${r}`}function bi(s){return s.includes(":")?s.split(":")[1]:s}function Cf(s){return s.map(t=>`${t.split(":")[0]}:${t.split(":")[1]}`)}function Hx(s,t){const r=Object.keys(t.namespaces).filter(a=>a.includes(s));if(!r.length)return[];const n=[];return r.forEach(a=>{const u=t.namespaces[a].accounts;n.push(...u)}),n}function Kx(s={},t={}){const r=Nl(s),n=Nl(t);return Ta.exports.merge(r,n)}function Nl(s){var t,r,n,a;const u={};if(!Ki(s))return u;for(const[f,y]of Object.entries(s)){const m=Ba(f)?[f]:y.chains,g=y.methods||[],w=y.events||[],_=y.rpcMap||{},O=vs(f);u[O]=kx(Pn(Pn({},u[O]),y),{chains:sa(m,(t=u[O])==null?void 0:t.chains),methods:sa(g,(r=u[O])==null?void 0:r.methods),events:sa(w,(n=u[O])==null?void 0:n.events),rpcMap:Pn(Pn({},_),(a=u[O])==null?void 0:a.rpcMap)})}return u}function Vx(s){return s.includes(":")?s.split(":")[2]:s}function Fx(s){const t={};for(const[r,n]of Object.entries(s)){const a=n.methods||[],u=n.events||[],f=n.accounts||[],y=Ba(r)?[r]:n.chains?n.chains:Cf(n.accounts);t[r]={chains:y,methods:a,events:u,accounts:f}}return t}function ya(s){return typeof s=="number"?s:s.includes("0x")?parseInt(s,16):s.includes(":")?Number(s.split(":")[1]):Number(s)}const Af={},Te=s=>Af[s],ma=(s,t)=>{Af[s]=t};class Bx{constructor(t){this.name="polkadot",this.namespace=t.namespace,this.events=Te("events"),this.client=Te("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(Hr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var n;const a=bi(r);t[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const n=this.createHttpProvider(t,r);n&&(this.httpProviders[t]=n)}createHttpProvider(t,r){const n=r||ii(t,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);return new kr(new si(n,Te("disableProviderPing")))}}class Gx{constructor(t){this.name="eip155",this.namespace=t.namespace,this.events=Te("events"),this.client=Te("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(t){switch(t.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(t);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(t.request.method)?await this.client.request(t):this.getHttpProvider().request(t.request)}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(parseInt(t),r),this.chainId=parseInt(t),this.events.emit(Hr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}createHttpProvider(t,r){const n=r||ii(`${this.name}:${t}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);return new kr(new si(n,Te("disableProviderPing")))}setHttpProvider(t,r){const n=this.createHttpProvider(t,r);n&&(this.httpProviders[t]=n)}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var n;const a=parseInt(bi(r));t[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[r])}),t}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const t=this.chainId,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}async handleSwitchChain(t){var r,n;let a=t.request.params?(r=t.request.params[0])==null?void 0:r.chainId:"0x0";a=a.startsWith("0x")?a:`0x${a}`;const u=parseInt(a,16);if(this.isChainApproved(u))this.setDefaultChain(`${u}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:t.topic,request:{method:t.request.method,params:[{chainId:a}]},chainId:(n=this.namespace.chains)==null?void 0:n[0]}),this.setDefaultChain(`${u}`);else throw new Error(`Failed to switch to chain 'eip155:${u}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(t){return this.namespace.chains.includes(`${this.name}:${t}`)}}class Wx{constructor(t){this.name="solana",this.namespace=t.namespace,this.events=Te("events"),this.client=Te("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(Hr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var n;const a=bi(r);t[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const n=this.createHttpProvider(t,r);n&&(this.httpProviders[t]=n)}createHttpProvider(t,r){const n=r||ii(t,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);return new kr(new si(n,Te("disableProviderPing")))}}class Jx{constructor(t){this.name="cosmos",this.namespace=t.namespace,this.events=Te("events"),this.client=Te("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(Hr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var n;const a=bi(r);t[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const n=this.createHttpProvider(t,r);n&&(this.httpProviders[t]=n)}createHttpProvider(t,r){const n=r||ii(t,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);return new kr(new si(n,Te("disableProviderPing")))}}class Qx{constructor(t){this.name="cip34",this.namespace=t.namespace,this.events=Te("events"),this.client=Te("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(Hr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{const n=this.getCardanoRPCUrl(r),a=bi(r);t[a]=this.createHttpProvider(a,n)}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}getCardanoRPCUrl(t){const r=this.namespace.rpcMap;if(r)return r[t]}setHttpProvider(t,r){const n=this.createHttpProvider(t,r);n&&(this.httpProviders[t]=n)}createHttpProvider(t,r){const n=r||this.getCardanoRPCUrl(t);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);return new kr(new si(n,Te("disableProviderPing")))}}class Yx{constructor(t){this.name="elrond",this.namespace=t.namespace,this.events=Te("events"),this.client=Te("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(Hr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var n;const a=bi(r);t[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const n=this.createHttpProvider(t,r);n&&(this.httpProviders[t]=n)}createHttpProvider(t,r){const n=r||ii(t,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);return new kr(new si(n,Te("disableProviderPing")))}}class Zx{constructor(t){this.name="multiversx",this.namespace=t.namespace,this.events=Te("events"),this.client=Te("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){this.httpProviders[t]||this.setHttpProvider(t,r),this.chainId=t,this.events.emit(Hr.DEFAULT_CHAIN_CHANGED,`${this.name}:${t}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}getAccounts(){const t=this.namespace.accounts;return t?[...new Set(t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var n;const a=bi(r);t[a]=this.createHttpProvider(a,(n=this.namespace.rpcMap)==null?void 0:n[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const n=this.createHttpProvider(t,r);n&&(this.httpProviders[t]=n)}createHttpProvider(t,r){const n=r||ii(t,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);return new kr(new si(n,Te("disableProviderPing")))}}class Xx{constructor(t){this.name="near",this.namespace=t.namespace,this.events=Te("events"),this.client=Te("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(t){this.namespace=Object.assign(this.namespace,t)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const t=this.namespace.chains[0];if(!t)throw new Error("ChainId not found");return t.split(":")[1]}request(t){return this.namespace.methods.includes(t.request.method)?this.client.request(t):this.getHttpProvider().request(t.request)}setDefaultChain(t,r){if(this.chainId=t,!this.httpProviders[t]){const n=r||ii(`${this.name}:${t}`,this.namespace);if(!n)throw new Error(`No RPC url provided for chainId: ${t}`);this.setHttpProvider(t,n)}this.events.emit(Hr.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const t=this.namespace.accounts;return t?t.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const t={};return this.namespace.chains.forEach(r=>{var n;t[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[r])}),t}getHttpProvider(){const t=`${this.name}:${this.chainId}`,r=this.httpProviders[t];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${t} not found`);return r}setHttpProvider(t,r){const n=this.createHttpProvider(t,r);n&&(this.httpProviders[t]=n)}createHttpProvider(t,r){const n=r||ii(t,this.namespace);return typeof n>"u"?void 0:new kr(new si(n,Te("disableProviderPing")))}}var eS=Object.defineProperty,tS=Object.defineProperties,rS=Object.getOwnPropertyDescriptors,$l=Object.getOwnPropertySymbols,iS=Object.prototype.hasOwnProperty,sS=Object.prototype.propertyIsEnumerable,Cl=(s,t,r)=>t in s?eS(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,On=(s,t)=>{for(var r in t||(t={}))iS.call(t,r)&&Cl(s,r,t[r]);if($l)for(var r of $l(t))sS.call(t,r)&&Cl(s,r,t[r]);return s},va=(s,t)=>tS(s,rS(t));class Za{constructor(t){this.events=new La,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=t,this.logger=typeof(t==null?void 0:t.logger)<"u"&&typeof(t==null?void 0:t.logger)!="string"?t.logger:kn(Hn({level:(t==null?void 0:t.logger)||Sl})),this.disableProviderPing=(t==null?void 0:t.disableProviderPing)||!1}static async init(t){const r=new Za(t);return await r.initialize(),r}async request(t,r){const[n,a]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(n).request({request:On({},t),chainId:`${n}:${a}`,topic:this.session.topic})}sendAsync(t,r,n){this.request(t,n).then(a=>r(null,a)).catch(a=>r(a,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var t;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(t=this.session)==null?void 0:t.topic,reason:Fe("USER_DISCONNECTED")}),await this.cleanup()}async connect(t){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(t),await this.cleanupPendingPairings(),!t.skipPairing)return await this.pair(t.pairingTopic)}on(t,r){this.events.on(t,r)}once(t,r){this.events.once(t,r)}removeListener(t,r){this.events.removeListener(t,r)}off(t,r){this.events.off(t,r)}get isWalletConnect(){return!0}async pair(t){this.shouldAbortPairingAttempt=!1;let r=0;do{if(this.shouldAbortPairingAttempt)throw new Error("Pairing aborted");if(r>=this.maxPairingAttempts)throw new Error("Max auto pairing attempts reached");const{uri:n,approval:a}=await this.client.connect({pairingTopic:t,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});n&&(this.uri=n,this.events.emit("display_uri",n)),await a().then(u=>{this.session=u,this.namespaces||(this.namespaces=Fx(u.namespaces),this.persist("namespaces",this.namespaces))}).catch(u=>{if(u.message!==Nf)throw u;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(t,r){try{if(!this.session)return;const[n,a]=this.validateChain(t);this.getProvider(n).setDefaultChain(a,r)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(t={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(Nr(r)){for(const n of r)t.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info(`Inactive pairings cleared: ${r.length}`)}}abortPairingAttempt(){this.shouldAbortPairingAttempt=!0}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const t=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[t]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await Cx.init({logger:this.providerOpts.logger||Sl,relayUrl:this.providerOpts.relayUrl||Ax,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const t=[...new Set(Object.keys(this.session.namespaces).map(r=>vs(r)))];ma("client",this.client),ma("events",this.events),ma("disableProviderPing",this.disableProviderPing),t.forEach(r=>{if(!this.session)return;const n=Hx(r,this.session),a=Cf(n),u=Kx(this.namespaces,this.optionalNamespaces),f=va(On({},u[r]),{accounts:n,chains:a});switch(r){case"eip155":this.rpcProviders[r]=new Gx({namespace:f});break;case"solana":this.rpcProviders[r]=new Wx({namespace:f});break;case"cosmos":this.rpcProviders[r]=new Jx({namespace:f});break;case"polkadot":this.rpcProviders[r]=new Bx({namespace:f});break;case"cip34":this.rpcProviders[r]=new Qx({namespace:f});break;case"elrond":this.rpcProviders[r]=new Yx({namespace:f});break;case"multiversx":this.rpcProviders[r]=new Zx({namespace:f});break;case"near":this.rpcProviders[r]=new Xx({namespace:f});break}})}registerEventListeners(){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:r}=t,{event:n}=r;if(n.name==="accountsChanged"){const a=n.data;a&&Nr(a)&&this.events.emit("accountsChanged",a.map(Vx))}else if(n.name==="chainChanged"){const a=r.chainId,u=r.event.data,f=vs(a),y=ya(a)!==ya(u)?`${f}:${ya(u)}`:a;this.onChainChanged(y)}else this.events.emit(n.name,n.data);this.events.emit("session_event",t)}),this.client.on("session_update",({topic:t,params:r})=>{var n;const{namespaces:a}=r,u=(n=this.client)==null?void 0:n.session.get(t);this.session=va(On({},u),{namespaces:a}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:r})}),this.client.on("session_delete",async t=>{await this.cleanup(),this.events.emit("session_delete",t),this.events.emit("disconnect",va(On({},Fe("USER_DISCONNECTED")),{data:t.topic}))}),this.on(Hr.DEFAULT_CHAIN_CHANGED,t=>{this.onChainChanged(t,!0)})}getProvider(t){if(!this.rpcProviders[t])throw new Error(`Provider not found: ${t}`);return this.rpcProviders[t]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(t=>{var r;this.getProvider(t).updateNamespace((r=this.session)==null?void 0:r.namespaces[t])})}setNamespaces(t){const{namespaces:r,optionalNamespaces:n,sessionProperties:a}=t;r&&Object.keys(r).length&&(this.namespaces=r),n&&Object.keys(n).length&&(this.optionalNamespaces=n),this.sessionProperties=a,this.persist("namespaces",r),this.persist("optionalNamespaces",n)}validateChain(t){const[r,n]=(t==null?void 0:t.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,n];if(r&&!Object.keys(this.namespaces||{}).map(f=>vs(f)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&n)return[r,n];const a=vs(Object.keys(this.namespaces)[0]),u=this.rpcProviders[a].getDefaultChain();return[a,u]}async requestAccounts(){const[t]=this.validateChain();return await this.getProvider(t).requestAccounts()}onChainChanged(t,r=!1){var n;if(!this.namespaces)return;const[a,u]=this.validateChain(t);r||this.getProvider(a).setDefaultChain(u),((n=this.namespaces[a])!=null?n:this.namespaces[`${a}:${u}`]).defaultChain=u,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",u)}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(t,r){this.client.core.storage.setItem(`${Pl}/${t}`,r)}async getFromStore(t){return await this.client.core.storage.getItem(`${Pl}/${t}`)}}const nS=Za,oS="wc",aS="ethereum_provider",cS=`${oS}@2:${aS}:`,uS="https://rpc.walletconnect.com/v1/",Da=["eth_sendTransaction","personal_sign"],hS=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode"],ja=["chainChanged","accountsChanged"],lS=["chainChanged","accountsChanged","message","disconnect","connect"];var fS=Object.defineProperty,pS=Object.defineProperties,dS=Object.getOwnPropertyDescriptors,Al=Object.getOwnPropertySymbols,gS=Object.prototype.hasOwnProperty,yS=Object.prototype.propertyIsEnumerable,Tl=(s,t,r)=>t in s?fS(s,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):s[t]=r,bs=(s,t)=>{for(var r in t||(t={}))gS.call(t,r)&&Tl(s,r,t[r]);if(Al)for(var r of Al(t))yS.call(t,r)&&Tl(s,r,t[r]);return s},Dl=(s,t)=>pS(s,dS(t));function jn(s){return Number(s[0].split(":")[1])}function wa(s){return`0x${s.toString(16)}`}function mS(s){const{chains:t,optionalChains:r,methods:n,optionalMethods:a,events:u,optionalEvents:f,rpcMap:y}=s;if(!Nr(t))throw new Error("Invalid chains");const m={chains:t,methods:n||Da,events:u||ja,rpcMap:bs({},t.length?{[jn(t)]:y[jn(t)]}:{})},g=u==null?void 0:u.filter(j=>!ja.includes(j)),w=n==null?void 0:n.filter(j=>!Da.includes(j));if(!r&&!f&&!a&&!(g!=null&&g.length)&&!(w!=null&&w.length))return{required:t.length?m:void 0};const _=(g==null?void 0:g.length)&&(w==null?void 0:w.length)||!r,O={chains:[...new Set(_?m.chains.concat(r||[]):r)],methods:[...new Set(m.methods.concat(a!=null&&a.length?a:hS))],events:[...new Set(m.events.concat(f!=null&&f.length?f:lS))],rpcMap:y};return{required:t.length?m:void 0,optional:r.length?O:void 0}}class Xa{constructor(){this.events=new br.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=cS,this.on=(t,r)=>(this.events.on(t,r),this),this.once=(t,r)=>(this.events.once(t,r),this),this.removeListener=(t,r)=>(this.events.removeListener(t,r),this),this.off=(t,r)=>(this.events.off(t,r),this),this.parseAccount=t=>this.isCompatibleChainId(t)?this.parseAccountId(t).address:t,this.signer={},this.rpc={}}static async init(t){const r=new Xa;return await r.initialize(t),r}async request(t){return await this.signer.request(t,this.formatChainId(this.chainId))}sendAsync(t,r){this.signer.sendAsync(t,r,this.formatChainId(this.chainId))}get connected(){return this.signer.client?this.signer.client.core.relayer.connected:!1}get connecting(){return this.signer.client?this.signer.client.core.relayer.connecting:!1}async enable(){return this.session||await this.connect(),await this.request({method:"eth_requestAccounts"})}async connect(t){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(t);const{required:r,optional:n}=mS(this.rpc);try{const a=await new Promise(async(f,y)=>{var m;this.rpc.showQrModal&&((m=this.modal)==null||m.subscribeModal(g=>{!g.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),y(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(Dl(bs({namespaces:bs({},r&&{[this.namespace]:r})},n&&{optionalNamespaces:{[this.namespace]:n}}),{pairingTopic:t==null?void 0:t.pairingTopic})).then(g=>{f(g)}).catch(g=>{y(new Error(g.message))})});if(!a)return;const u=Ow(a.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:u),this.setAccounts(u),this.events.emit("connect",{chainId:wa(this.chainId)})}catch(a){throw this.signer.logger.error(a),a}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",t=>{const{params:r}=t,{event:n}=r;n.name==="accountsChanged"?(this.accounts=this.parseAccounts(n.data),this.events.emit("accountsChanged",this.accounts)):n.name==="chainChanged"?this.setChainId(this.formatChainId(n.data)):this.events.emit(n.name,n.data),this.events.emit("session_event",t)}),this.signer.on("chainChanged",t=>{const r=parseInt(t);this.chainId=r,this.events.emit("chainChanged",wa(this.chainId)),this.persist()}),this.signer.on("session_update",t=>{this.events.emit("session_update",t)}),this.signer.on("session_delete",t=>{this.reset(),this.events.emit("session_delete",t),this.events.emit("disconnect",Dl(bs({},Fe("USER_DISCONNECTED")),{data:t.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",t=>{var r,n;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(n=this.modal)==null||n.openModal({uri:t})),this.events.emit("display_uri",t)})}switchEthereumChain(t){this.request({method:"wallet_switchEthereumChain",params:[{chainId:t.toString(16)}]})}isCompatibleChainId(t){return typeof t=="string"?t.startsWith(`${this.namespace}:`):!1}formatChainId(t){return`${this.namespace}:${t}`}parseChainId(t){return Number(t.split(":")[1])}setChainIds(t){const r=t.filter(n=>this.isCompatibleChainId(n)).map(n=>this.parseChainId(n));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",wa(this.chainId)),this.persist())}setChainId(t){if(this.isCompatibleChainId(t)){const r=this.parseChainId(t);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(t){const[r,n,a]=t.split(":");return{chainId:`${r}:${n}`,address:a}}setAccounts(t){this.accounts=t.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(t){var r,n;const a=(r=t==null?void 0:t.chains)!=null?r:[],u=(n=t==null?void 0:t.optionalChains)!=null?n:[],f=a.concat(u);if(!f.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const y=a.length?(t==null?void 0:t.methods)||Da:[],m=a.length?(t==null?void 0:t.events)||ja:[],g=(t==null?void 0:t.optionalMethods)||[],w=(t==null?void 0:t.optionalEvents)||[],_=(t==null?void 0:t.rpcMap)||this.buildRpcMap(f,t.projectId),O=(t==null?void 0:t.qrModalOptions)||void 0;return{chains:a==null?void 0:a.map(j=>this.formatChainId(j)),optionalChains:u.map(j=>this.formatChainId(j)),methods:y,events:m,optionalMethods:g,optionalEvents:w,rpcMap:_,showQrModal:!!(t!=null&&t.showQrModal),qrModalOptions:O,projectId:t.projectId,metadata:t.metadata}}buildRpcMap(t,r){const n={};return t.forEach(a=>{n[a]=this.getRpcUrl(a,r)}),n}async initialize(t){if(this.rpc=this.getRpcConfig(t),this.chainId=this.rpc.chains.length?jn(this.rpc.chains):jn(this.rpc.optionalChains),this.signer=await nS.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:t.disableProviderPing,relayUrl:t.relayUrl,storageOptions:t.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{const{WalletConnectModal:n}=await mw(()=>import("./index-DHeGpow_.js").then(a=>a.i),__vite__mapDeps([0,1,2]));r=n}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(bs({walletConnectVersion:2,projectId:this.rpc.projectId,standaloneChains:this.rpc.chains},this.rpc.qrModalOptions))}catch(n){throw this.signer.logger.error(n),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(t){if(!t)return;const{chains:r,optionalChains:n,rpcMap:a}=t;r&&Nr(r)&&(this.rpc.chains=r.map(u=>this.formatChainId(u)),r.forEach(u=>{this.rpc.rpcMap[u]=(a==null?void 0:a[u])||this.getRpcUrl(u)})),n&&Nr(n)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=n==null?void 0:n.map(u=>this.formatChainId(u)),n.forEach(u=>{this.rpc.rpcMap[u]=(a==null?void 0:a[u])||this.getRpcUrl(u)}))}getRpcUrl(t,r){var n;return((n=this.rpc.rpcMap)==null?void 0:n[t])||`${uS}?chainId=eip155:${t}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const t=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${t}`]?this.session.namespaces[`${this.namespace}:${t}`]:this.session.namespaces[this.namespace];this.setChainIds(t?[this.formatChainId(t)]:r==null?void 0:r.accounts),this.setAccounts(r==null?void 0:r.accounts)}reset(){this.chainId=1,this.accounts=[]}persist(){this.session&&this.signer.client.core.storage.setItem(`${this.STORAGE_KEY}/chainId`,this.chainId)}parseAccounts(t){return typeof t=="string"||t instanceof String?[this.parseAccount(t)]:t.map(r=>this.parseAccount(r))}}const DS=Xa;export{DS as EthereumProvider,lS as OPTIONAL_EVENTS,hS as OPTIONAL_METHODS,ja as REQUIRED_EVENTS,Da as REQUIRED_METHODS,Xa as default};