@dcl/auth-site 1.3.2 → 1.3.3-8009192434.commit-1e77840
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/fortmatic-8a0b2762.js +14 -0
- package/assets/fortmatic-8a0b2762.js.map +1 -0
- package/assets/index-4cf41abe.js +2 -0
- package/assets/index-4cf41abe.js.map +1 -0
- package/assets/index-64a60925.js +2 -0
- package/assets/index-64a60925.js.map +1 -0
- package/assets/{index-72e592dc.css → index-6f1e1795.css} +3 -3
- package/assets/{index-cef13447.js → index-7dd14ae0.js} +2 -2
- package/assets/{index-cef13447.js.map → index-7dd14ae0.js.map} +1 -1
- package/assets/{index-bc8cee49.js → index-806f36a6.js} +4 -4
- package/assets/{index-bc8cee49.js.map → index-806f36a6.js.map} +1 -1
- package/assets/index-9d42ed15.js +6 -0
- package/assets/index-9d42ed15.js.map +1 -0
- package/assets/index-a5727b0e.js +158 -0
- package/assets/{index-8cb9a6f2.js.map → index-a5727b0e.js.map} +1 -1
- package/assets/index.es-76c7d42b.js +34 -0
- package/assets/index.es-76c7d42b.js.map +1 -0
- package/assets/tslib.es6-c2094241.js +15 -0
- package/assets/tslib.es6-c2094241.js.map +1 -0
- package/index.html +2 -2
- package/package.json +3 -3
- package/assets/index-8cb9a6f2.js +0 -219
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import{_ as Q_,b as zu,d as X_,r as Z_,p as hi,g as Et,c as Pr,e as zr,a as eb,$ as Bu,f as lf}from"./index-a5727b0e.js";import{t as tb}from"./tslib.es6-c2094241.js";const rb=Symbol(),ff=Object.getPrototypeOf,Du=new WeakMap,ib=i=>i&&(Du.has(i)?Du.get(i):ff(i)===Object.prototype||ff(i)===Array.prototype),nb=i=>ib(i)&&i[rb]||null,df=(i,e=!0)=>{Du.set(i,e)},Zc=i=>typeof i=="object"&&i!==null,zi=new WeakMap,Zo=new WeakSet,sb=(i=Object.is,e=(b,E)=>new Proxy(b,E),r=b=>Zc(b)&&!Zo.has(b)&&(Array.isArray(b)||!(Symbol.iterator in b))&&!(b instanceof WeakMap)&&!(b instanceof WeakSet)&&!(b instanceof Error)&&!(b instanceof Number)&&!(b instanceof Date)&&!(b instanceof String)&&!(b instanceof RegExp)&&!(b instanceof ArrayBuffer),s=b=>{switch(b.status){case"fulfilled":return b.value;case"rejected":throw b.reason;default:throw b}},o=new WeakMap,h=(b,E,C=s)=>{const N=o.get(b);if((N==null?void 0:N[0])===E)return N[1];const P=Array.isArray(b)?[]:Object.create(Object.getPrototypeOf(b));return df(P,!0),o.set(b,[E,P]),Reflect.ownKeys(b).forEach(F=>{if(Object.getOwnPropertyDescriptor(P,F))return;const k=Reflect.get(b,F),K={value:k,enumerable:!0,configurable:!0};if(Zo.has(k))df(k,!1);else if(k instanceof Promise)delete K.value,K.get=()=>C(k);else if(zi.has(k)){const[ee,A]=zi.get(k);K.value=h(ee,A(),C)}Object.defineProperty(P,F,K)}),Object.preventExtensions(P)},p=new WeakMap,f=[1,1],g=b=>{if(!Zc(b))throw new Error("object required");const E=p.get(b);if(E)return E;let C=f[0];const N=new Set,P=(B,z=++f[0])=>{C!==z&&(C=z,N.forEach(W=>W(B,z)))};let F=f[1];const k=(B=++f[1])=>(F!==B&&!N.size&&(F=B,ee.forEach(([z])=>{const W=z[1](B);W>C&&(C=W)})),C),K=B=>(z,W)=>{const oe=[...z];oe[1]=[B,...oe[1]],P(oe,W)},ee=new Map,A=(B,z)=>{if(N.size){const W=z[3](K(B));ee.set(B,[z,W])}else ee.set(B,[z])},$=B=>{var z;const W=ee.get(B);W&&(ee.delete(B),(z=W[1])==null||z.call(W))},S=B=>(N.add(B),N.size===1&&ee.forEach(([W,oe],fe)=>{const T=W[3](K(fe));ee.set(fe,[W,T])}),()=>{N.delete(B),N.size===0&&ee.forEach(([W,oe],fe)=>{oe&&(oe(),ee.set(fe,[W]))})}),I=Array.isArray(b)?[]:Object.create(Object.getPrototypeOf(b)),c=e(I,{deleteProperty(B,z){const W=Reflect.get(B,z);$(z);const oe=Reflect.deleteProperty(B,z);return oe&&P(["delete",[z],W]),oe},set(B,z,W,oe){const fe=Reflect.has(B,z),T=Reflect.get(B,z,oe);if(fe&&(i(T,W)||p.has(W)&&i(T,p.get(W))))return!0;$(z),Zc(W)&&(W=nb(W)||W);let H=W;if(W instanceof Promise)W.then(ce=>{W.status="fulfilled",W.value=ce,P(["resolve",[z],ce])}).catch(ce=>{W.status="rejected",W.reason=ce,P(["reject",[z],ce])});else{!zi.has(W)&&r(W)&&(H=g(W));const ce=!Zo.has(H)&&zi.get(H);ce&&A(z,ce)}return Reflect.set(B,z,H,oe),P(["set",[z],W,T]),!0}});p.set(b,c);const m=[I,k,h,S];return zi.set(c,m),Reflect.ownKeys(b).forEach(B=>{const z=Object.getOwnPropertyDescriptor(b,B);"value"in z&&(c[B]=b[B],delete z.value,delete z.writable),Object.defineProperty(I,B,z)}),c})=>[g,zi,Zo,i,e,r,s,o,h,p,f],[ob]=sb();function Vi(i={}){return ob(i)}function yn(i,e,r){const s=zi.get(i);let o;const h=[],p=s[3];let f=!1;const b=p(E=>{if(h.push(E),r){e(h.splice(0));return}o||(o=Promise.resolve().then(()=>{o=void 0,f&&e(h.splice(0))}))});return f=!0,()=>{f=!1,b()}}function ab(i,e){const r=zi.get(i),[s,o,h]=r;return h(s,o(),e)}const Wt=Vi({history:["ConnectWallet"],view:"ConnectWallet",data:void 0}),np={state:Wt,subscribe(i){return yn(Wt,()=>i(Wt))},push(i,e){i!==Wt.view&&(Wt.view=i,e&&(Wt.data=e),Wt.history.push(i))},reset(i){Wt.view=i,Wt.history=[i]},replace(i){Wt.history.length>1&&(Wt.history[Wt.history.length-1]=i,Wt.view=i)},goBack(){if(Wt.history.length>1){Wt.history.pop();const[i]=Wt.history.slice(-1);Wt.view=i}},setData(i){Wt.data=i}},rr={WALLETCONNECT_DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",WCM_VERSION:"WCM_VERSION",RECOMMENDED_WALLET_AMOUNT:9,isMobile(){return typeof window<"u"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},isAndroid(){return rr.isMobile()&&navigator.userAgent.toLowerCase().includes("android")},isIos(){const i=navigator.userAgent.toLowerCase();return rr.isMobile()&&(i.includes("iphone")||i.includes("ipad"))},isHttpUrl(i){return i.startsWith("http://")||i.startsWith("https://")},isArray(i){return Array.isArray(i)&&i.length>0},formatNativeUrl(i,e,r){if(rr.isHttpUrl(i))return this.formatUniversalUrl(i,e,r);let s=i;s.includes("://")||(s=i.replaceAll("/","").replaceAll(":",""),s=`${s}://`),s.endsWith("/")||(s=`${s}/`),this.setWalletConnectDeepLink(s,r);const o=encodeURIComponent(e);return`${s}wc?uri=${o}`},formatUniversalUrl(i,e,r){if(!rr.isHttpUrl(i))return this.formatNativeUrl(i,e,r);let s=i;s.endsWith("/")||(s=`${s}/`),this.setWalletConnectDeepLink(s,r);const o=encodeURIComponent(e);return`${s}wc?uri=${o}`},async wait(i){return new Promise(e=>{setTimeout(e,i)})},openHref(i,e){window.open(i,e,"noreferrer noopener")},setWalletConnectDeepLink(i,e){try{localStorage.setItem(rr.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:i,name:e}))}catch{console.info("Unable to set WalletConnect deep link")}},setWalletConnectAndroidDeepLink(i){try{const[e]=i.split("?");localStorage.setItem(rr.WALLETCONNECT_DEEPLINK_CHOICE,JSON.stringify({href:e,name:"Android"}))}catch{console.info("Unable to set WalletConnect android deep link")}},removeWalletConnectDeepLink(){try{localStorage.removeItem(rr.WALLETCONNECT_DEEPLINK_CHOICE)}catch{console.info("Unable to remove WalletConnect deep link")}},setModalVersionInStorage(){try{typeof localStorage<"u"&&localStorage.setItem(rr.WCM_VERSION,"2.6.2")}catch{console.info("Unable to set Web3Modal version in storage")}},getWalletRouterData(){var i;const e=(i=np.state.data)==null?void 0:i.Wallet;if(!e)throw new Error('Missing "Wallet" view data');return e}},cb=typeof location<"u"&&(location.hostname.includes("localhost")||location.protocol.includes("https")),er=Vi({enabled:cb,userSessionId:"",events:[],connectedWalletId:void 0}),ub={state:er,subscribe(i){return yn(er.events,()=>i(ab(er.events[er.events.length-1])))},initialize(){er.enabled&&typeof(crypto==null?void 0:crypto.randomUUID)<"u"&&(er.userSessionId=crypto.randomUUID())},setConnectedWalletId(i){er.connectedWalletId=i},click(i){if(er.enabled){const e={type:"CLICK",name:i.name,userSessionId:er.userSessionId,timestamp:Date.now(),data:i};er.events.push(e)}},track(i){if(er.enabled){const e={type:"TRACK",name:i.name,userSessionId:er.userSessionId,timestamp:Date.now(),data:i};er.events.push(e)}},view(i){if(er.enabled){const e={type:"VIEW",name:i.name,userSessionId:er.userSessionId,timestamp:Date.now(),data:i};er.events.push(e)}}},oi=Vi({chains:void 0,walletConnectUri:void 0,isAuth:!1,isCustomDesktop:!1,isCustomMobile:!1,isDataLoaded:!1,isUiLoaded:!1}),Zr={state:oi,subscribe(i){return yn(oi,()=>i(oi))},setChains(i){oi.chains=i},setWalletConnectUri(i){oi.walletConnectUri=i},setIsCustomDesktop(i){oi.isCustomDesktop=i},setIsCustomMobile(i){oi.isCustomMobile=i},setIsDataLoaded(i){oi.isDataLoaded=i},setIsUiLoaded(i){oi.isUiLoaded=i},setIsAuth(i){oi.isAuth=i}},ea=Vi({projectId:"",mobileWallets:void 0,desktopWallets:void 0,walletImages:void 0,chains:void 0,enableAuthMode:!1,enableExplorer:!0,explorerExcludedWalletIds:void 0,explorerRecommendedWalletIds:void 0,termsOfServiceUrl:void 0,privacyPolicyUrl:void 0}),Jn={state:ea,subscribe(i){return yn(ea,()=>i(ea))},setConfig(i){var e,r;ub.initialize(),Zr.setChains(i.chains),Zr.setIsAuth(!!i.enableAuthMode),Zr.setIsCustomMobile(!!((e=i.mobileWallets)!=null&&e.length)),Zr.setIsCustomDesktop(!!((r=i.desktopWallets)!=null&&r.length)),rr.setModalVersionInStorage(),Object.assign(ea,i)}};var hb=Object.defineProperty,pf=Object.getOwnPropertySymbols,lb=Object.prototype.hasOwnProperty,fb=Object.prototype.propertyIsEnumerable,gf=(i,e,r)=>e in i?hb(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,db=(i,e)=>{for(var r in e||(e={}))lb.call(e,r)&&gf(i,r,e[r]);if(pf)for(var r of pf(e))fb.call(e,r)&&gf(i,r,e[r]);return i};const Su="https://explorer-api.walletconnect.com",Iu="wcm",xu="js-2.6.2";async function ta(i,e){const r=db({sdkType:Iu,sdkVersion:xu},e),s=new URL(i,Su);return s.searchParams.append("projectId",Jn.state.projectId),Object.entries(r).forEach(([o,h])=>{h&&s.searchParams.append(o,String(h))}),(await fetch(s)).json()}const hn={async getDesktopListings(i){return ta("/w3m/v1/getDesktopListings",i)},async getMobileListings(i){return ta("/w3m/v1/getMobileListings",i)},async getInjectedListings(i){return ta("/w3m/v1/getInjectedListings",i)},async getAllListings(i){return ta("/w3m/v1/getAllListings",i)},getWalletImageUrl(i){return`${Su}/w3m/v1/getWalletImage/${i}?projectId=${Jn.state.projectId}&sdkType=${Iu}&sdkVersion=${xu}`},getAssetImageUrl(i){return`${Su}/w3m/v1/getAssetImage/${i}?projectId=${Jn.state.projectId}&sdkType=${Iu}&sdkVersion=${xu}`}};var pb=Object.defineProperty,vf=Object.getOwnPropertySymbols,gb=Object.prototype.hasOwnProperty,vb=Object.prototype.propertyIsEnumerable,yf=(i,e,r)=>e in i?pb(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,yb=(i,e)=>{for(var r in e||(e={}))gb.call(e,r)&&yf(i,r,e[r]);if(vf)for(var r of vf(e))vb.call(e,r)&&yf(i,r,e[r]);return i};const mf=rr.isMobile(),ai=Vi({wallets:{listings:[],total:0,page:1},search:{listings:[],total:0,page:1},recomendedWallets:[]}),eI={state:ai,async getRecomendedWallets(){const{explorerRecommendedWalletIds:i,explorerExcludedWalletIds:e}=Jn.state;if(i==="NONE"||e==="ALL"&&!i)return ai.recomendedWallets;if(rr.isArray(i)){const r={recommendedIds:i.join(",")},{listings:s}=await hn.getAllListings(r),o=Object.values(s);o.sort((h,p)=>{const f=i.indexOf(h.id),g=i.indexOf(p.id);return f-g}),ai.recomendedWallets=o}else{const{chains:r,isAuth:s}=Zr.state,o=r==null?void 0:r.join(","),h=rr.isArray(e),p={page:1,sdks:s?"auth_v1":void 0,entries:rr.RECOMMENDED_WALLET_AMOUNT,chains:o,version:2,excludedIds:h?e.join(","):void 0},{listings:f}=mf?await hn.getMobileListings(p):await hn.getDesktopListings(p);ai.recomendedWallets=Object.values(f)}return ai.recomendedWallets},async getWallets(i){const e=yb({},i),{explorerRecommendedWalletIds:r,explorerExcludedWalletIds:s}=Jn.state,{recomendedWallets:o}=ai;if(s==="ALL")return ai.wallets;o.length?e.excludedIds=o.map(C=>C.id).join(","):rr.isArray(r)&&(e.excludedIds=r.join(",")),rr.isArray(s)&&(e.excludedIds=[e.excludedIds,s].filter(Boolean).join(",")),Zr.state.isAuth&&(e.sdks="auth_v1");const{page:h,search:p}=i,{listings:f,total:g}=mf?await hn.getMobileListings(e):await hn.getDesktopListings(e),b=Object.values(f),E=p?"search":"wallets";return ai[E]={listings:[...ai[E].listings,...b],total:g,page:h??1},{listings:b,total:g}},getWalletImageUrl(i){return hn.getWalletImageUrl(i)},getAssetImageUrl(i){return hn.getAssetImageUrl(i)},resetSearch(){ai.search={listings:[],total:0,page:1}}},zn=Vi({open:!1}),eu={state:zn,subscribe(i){return yn(zn,()=>i(zn))},async open(i){return new Promise(e=>{const{isUiLoaded:r,isDataLoaded:s}=Zr.state;if(rr.removeWalletConnectDeepLink(),Zr.setWalletConnectUri(i==null?void 0:i.uri),Zr.setChains(i==null?void 0:i.chains),np.reset("ConnectWallet"),r&&s)zn.open=!0,e();else{const o=setInterval(()=>{const h=Zr.state;h.isUiLoaded&&h.isDataLoaded&&(clearInterval(o),zn.open=!0,e())},200)}})},close(){zn.open=!1}};var mb=Object.defineProperty,_f=Object.getOwnPropertySymbols,_b=Object.prototype.hasOwnProperty,bb=Object.prototype.propertyIsEnumerable,bf=(i,e,r)=>e in i?mb(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,wb=(i,e)=>{for(var r in e||(e={}))_b.call(e,r)&&bf(i,r,e[r]);if(_f)for(var r of _f(e))bb.call(e,r)&&bf(i,r,e[r]);return i};function Eb(){return typeof matchMedia<"u"&&matchMedia("(prefers-color-scheme: dark)").matches}const bs=Vi({themeMode:Eb()?"dark":"light"}),wf={state:bs,subscribe(i){return yn(bs,()=>i(bs))},setThemeConfig(i){const{themeMode:e,themeVariables:r}=i;e&&(bs.themeMode=e),r&&(bs.themeVariables=wb({},r))}},ln=Vi({open:!1,message:"",variant:"success"}),tI={state:ln,subscribe(i){return yn(ln,()=>i(ln))},openToast(i,e){ln.open=!0,ln.message=i,ln.variant=e},closeToast(){ln.open=!1}};let Db=class{constructor(e){this.openModal=eu.open,this.closeModal=eu.close,this.subscribeModal=eu.subscribe,this.setTheme=wf.setThemeConfig,wf.setThemeConfig(e),Jn.setConfig(e),this.initUi()}async initUi(){if(typeof window<"u"){await Q_(()=>import("./index-7dd14ae0.js"),["assets/index-7dd14ae0.js","assets/index-a5727b0e.js","assets/index-6f1e1795.css","assets/tslib.es6-c2094241.js"]);const e=document.createElement("wcm-modal");document.body.insertAdjacentElement("beforeend",e),Zr.setIsUiLoaded(!0)}}};const Sb=Object.freeze(Object.defineProperty({__proto__:null,WalletConnectModal:Db},Symbol.toStringTag,{value:"Module"})),Ib=zu(Sb);var ku={},ya={},Ue={},sp={};(function(i){Object.defineProperty(i,"__esModule",{value:!0});function e(f,g){var b=f>>>16&65535,E=f&65535,C=g>>>16&65535,N=g&65535;return E*N+(b*N+E*C<<16>>>0)|0}i.mul=Math.imul||e;function r(f,g){return f+g|0}i.add=r;function s(f,g){return f-g|0}i.sub=s;function o(f,g){return f<<g|f>>>32-g}i.rotl=o;function h(f,g){return f<<32-g|f>>>g}i.rotr=h;function p(f){return typeof f=="number"&&isFinite(f)&&Math.floor(f)===f}i.isInteger=Number.isInteger||p,i.MAX_SAFE_INTEGER=9007199254740991,i.isSafeInteger=function(f){return i.isInteger(f)&&f>=-i.MAX_SAFE_INTEGER&&f<=i.MAX_SAFE_INTEGER}})(sp);Object.defineProperty(Ue,"__esModule",{value:!0});var op=sp;function xb(i,e){return e===void 0&&(e=0),(i[e+0]<<8|i[e+1])<<16>>16}Ue.readInt16BE=xb;function Ob(i,e){return e===void 0&&(e=0),(i[e+0]<<8|i[e+1])>>>0}Ue.readUint16BE=Ob;function Cb(i,e){return e===void 0&&(e=0),(i[e+1]<<8|i[e])<<16>>16}Ue.readInt16LE=Cb;function Pb(i,e){return e===void 0&&(e=0),(i[e+1]<<8|i[e])>>>0}Ue.readUint16LE=Pb;function ap(i,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=i>>>8,e[r+1]=i>>>0,e}Ue.writeUint16BE=ap;Ue.writeInt16BE=ap;function cp(i,e,r){return e===void 0&&(e=new Uint8Array(2)),r===void 0&&(r=0),e[r+0]=i>>>0,e[r+1]=i>>>8,e}Ue.writeUint16LE=cp;Ue.writeInt16LE=cp;function Ou(i,e){return e===void 0&&(e=0),i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3]}Ue.readInt32BE=Ou;function Cu(i,e){return e===void 0&&(e=0),(i[e]<<24|i[e+1]<<16|i[e+2]<<8|i[e+3])>>>0}Ue.readUint32BE=Cu;function Pu(i,e){return e===void 0&&(e=0),i[e+3]<<24|i[e+2]<<16|i[e+1]<<8|i[e]}Ue.readInt32LE=Pu;function Au(i,e){return e===void 0&&(e=0),(i[e+3]<<24|i[e+2]<<16|i[e+1]<<8|i[e])>>>0}Ue.readUint32LE=Au;function ca(i,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=i>>>24,e[r+1]=i>>>16,e[r+2]=i>>>8,e[r+3]=i>>>0,e}Ue.writeUint32BE=ca;Ue.writeInt32BE=ca;function ua(i,e,r){return e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0),e[r+0]=i>>>0,e[r+1]=i>>>8,e[r+2]=i>>>16,e[r+3]=i>>>24,e}Ue.writeUint32LE=ua;Ue.writeInt32LE=ua;function Ab(i,e){e===void 0&&(e=0);var r=Ou(i,e),s=Ou(i,e+4);return r*4294967296+s-(s>>31)*4294967296}Ue.readInt64BE=Ab;function Tb(i,e){e===void 0&&(e=0);var r=Cu(i,e),s=Cu(i,e+4);return r*4294967296+s}Ue.readUint64BE=Tb;function Rb(i,e){e===void 0&&(e=0);var r=Pu(i,e),s=Pu(i,e+4);return s*4294967296+r-(r>>31)*4294967296}Ue.readInt64LE=Rb;function Nb(i,e){e===void 0&&(e=0);var r=Au(i,e),s=Au(i,e+4);return s*4294967296+r}Ue.readUint64LE=Nb;function up(i,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),ca(i/4294967296>>>0,e,r),ca(i>>>0,e,r+4),e}Ue.writeUint64BE=up;Ue.writeInt64BE=up;function hp(i,e,r){return e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0),ua(i>>>0,e,r),ua(i/4294967296>>>0,e,r+4),e}Ue.writeUint64LE=hp;Ue.writeInt64LE=hp;function $b(i,e,r){if(r===void 0&&(r=0),i%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(i/8>e.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var s=0,o=1,h=i/8+r-1;h>=r;h--)s+=e[h]*o,o*=256;return s}Ue.readUintBE=$b;function Lb(i,e,r){if(r===void 0&&(r=0),i%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(i/8>e.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var s=0,o=1,h=r;h<r+i/8;h++)s+=e[h]*o,o*=256;return s}Ue.readUintLE=Lb;function Ub(i,e,r,s){if(r===void 0&&(r=new Uint8Array(i/8)),s===void 0&&(s=0),i%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!op.isSafeInteger(e))throw new Error("writeUintBE value must be an integer");for(var o=1,h=i/8+s-1;h>=s;h--)r[h]=e/o&255,o*=256;return r}Ue.writeUintBE=Ub;function Fb(i,e,r,s){if(r===void 0&&(r=new Uint8Array(i/8)),s===void 0&&(s=0),i%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!op.isSafeInteger(e))throw new Error("writeUintLE value must be an integer");for(var o=1,h=s;h<s+i/8;h++)r[h]=e/o&255,o*=256;return r}Ue.writeUintLE=Fb;function Mb(i,e){e===void 0&&(e=0);var r=new DataView(i.buffer,i.byteOffset,i.byteLength);return r.getFloat32(e)}Ue.readFloat32BE=Mb;function jb(i,e){e===void 0&&(e=0);var r=new DataView(i.buffer,i.byteOffset,i.byteLength);return r.getFloat32(e,!0)}Ue.readFloat32LE=jb;function qb(i,e){e===void 0&&(e=0);var r=new DataView(i.buffer,i.byteOffset,i.byteLength);return r.getFloat64(e)}Ue.readFloat64BE=qb;function Hb(i,e){e===void 0&&(e=0);var r=new DataView(i.buffer,i.byteOffset,i.byteLength);return r.getFloat64(e,!0)}Ue.readFloat64LE=Hb;function zb(i,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var s=new DataView(e.buffer,e.byteOffset,e.byteLength);return s.setFloat32(r,i),e}Ue.writeFloat32BE=zb;function Bb(i,e,r){e===void 0&&(e=new Uint8Array(4)),r===void 0&&(r=0);var s=new DataView(e.buffer,e.byteOffset,e.byteLength);return s.setFloat32(r,i,!0),e}Ue.writeFloat32LE=Bb;function kb(i,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var s=new DataView(e.buffer,e.byteOffset,e.byteLength);return s.setFloat64(r,i),e}Ue.writeFloat64BE=kb;function Kb(i,e,r){e===void 0&&(e=new Uint8Array(8)),r===void 0&&(r=0);var s=new DataView(e.buffer,e.byteOffset,e.byteLength);return s.setFloat64(r,i,!0),e}Ue.writeFloat64LE=Kb;var Tr={};Object.defineProperty(Tr,"__esModule",{value:!0});function Vb(i){for(var e=0;e<i.length;e++)i[e]=0;return i}Tr.wipe=Vb;Object.defineProperty(ya,"__esModule",{value:!0});var tr=Ue,Tu=Tr,Wb=20;function Gb(i,e,r){for(var s=1634760805,o=857760878,h=2036477234,p=1797285236,f=r[3]<<24|r[2]<<16|r[1]<<8|r[0],g=r[7]<<24|r[6]<<16|r[5]<<8|r[4],b=r[11]<<24|r[10]<<16|r[9]<<8|r[8],E=r[15]<<24|r[14]<<16|r[13]<<8|r[12],C=r[19]<<24|r[18]<<16|r[17]<<8|r[16],N=r[23]<<24|r[22]<<16|r[21]<<8|r[20],P=r[27]<<24|r[26]<<16|r[25]<<8|r[24],F=r[31]<<24|r[30]<<16|r[29]<<8|r[28],k=e[3]<<24|e[2]<<16|e[1]<<8|e[0],K=e[7]<<24|e[6]<<16|e[5]<<8|e[4],ee=e[11]<<24|e[10]<<16|e[9]<<8|e[8],A=e[15]<<24|e[14]<<16|e[13]<<8|e[12],$=s,S=o,I=h,_=p,c=f,m=g,B=b,z=E,W=C,oe=N,fe=P,T=F,H=k,ce=K,ie=ee,Y=A,re=0;re<Wb;re+=2)$=$+c|0,H^=$,H=H>>>32-16|H<<16,W=W+H|0,c^=W,c=c>>>32-12|c<<12,S=S+m|0,ce^=S,ce=ce>>>32-16|ce<<16,oe=oe+ce|0,m^=oe,m=m>>>32-12|m<<12,I=I+B|0,ie^=I,ie=ie>>>32-16|ie<<16,fe=fe+ie|0,B^=fe,B=B>>>32-12|B<<12,_=_+z|0,Y^=_,Y=Y>>>32-16|Y<<16,T=T+Y|0,z^=T,z=z>>>32-12|z<<12,I=I+B|0,ie^=I,ie=ie>>>32-8|ie<<8,fe=fe+ie|0,B^=fe,B=B>>>32-7|B<<7,_=_+z|0,Y^=_,Y=Y>>>32-8|Y<<8,T=T+Y|0,z^=T,z=z>>>32-7|z<<7,S=S+m|0,ce^=S,ce=ce>>>32-8|ce<<8,oe=oe+ce|0,m^=oe,m=m>>>32-7|m<<7,$=$+c|0,H^=$,H=H>>>32-8|H<<8,W=W+H|0,c^=W,c=c>>>32-7|c<<7,$=$+m|0,Y^=$,Y=Y>>>32-16|Y<<16,fe=fe+Y|0,m^=fe,m=m>>>32-12|m<<12,S=S+B|0,H^=S,H=H>>>32-16|H<<16,T=T+H|0,B^=T,B=B>>>32-12|B<<12,I=I+z|0,ce^=I,ce=ce>>>32-16|ce<<16,W=W+ce|0,z^=W,z=z>>>32-12|z<<12,_=_+c|0,ie^=_,ie=ie>>>32-16|ie<<16,oe=oe+ie|0,c^=oe,c=c>>>32-12|c<<12,I=I+z|0,ce^=I,ce=ce>>>32-8|ce<<8,W=W+ce|0,z^=W,z=z>>>32-7|z<<7,_=_+c|0,ie^=_,ie=ie>>>32-8|ie<<8,oe=oe+ie|0,c^=oe,c=c>>>32-7|c<<7,S=S+B|0,H^=S,H=H>>>32-8|H<<8,T=T+H|0,B^=T,B=B>>>32-7|B<<7,$=$+m|0,Y^=$,Y=Y>>>32-8|Y<<8,fe=fe+Y|0,m^=fe,m=m>>>32-7|m<<7;tr.writeUint32LE($+s|0,i,0),tr.writeUint32LE(S+o|0,i,4),tr.writeUint32LE(I+h|0,i,8),tr.writeUint32LE(_+p|0,i,12),tr.writeUint32LE(c+f|0,i,16),tr.writeUint32LE(m+g|0,i,20),tr.writeUint32LE(B+b|0,i,24),tr.writeUint32LE(z+E|0,i,28),tr.writeUint32LE(W+C|0,i,32),tr.writeUint32LE(oe+N|0,i,36),tr.writeUint32LE(fe+P|0,i,40),tr.writeUint32LE(T+F|0,i,44),tr.writeUint32LE(H+k|0,i,48),tr.writeUint32LE(ce+K|0,i,52),tr.writeUint32LE(ie+ee|0,i,56),tr.writeUint32LE(Y+A|0,i,60)}function lp(i,e,r,s,o){if(o===void 0&&(o=0),i.length!==32)throw new Error("ChaCha: key size must be 32 bytes");if(s.length<r.length)throw new Error("ChaCha: destination is shorter than source");var h,p;if(o===0){if(e.length!==8&&e.length!==12)throw new Error("ChaCha nonce must be 8 or 12 bytes");h=new Uint8Array(16),p=h.length-e.length,h.set(e,p)}else{if(e.length!==16)throw new Error("ChaCha nonce with counter must be 16 bytes");h=e,p=o}for(var f=new Uint8Array(64),g=0;g<r.length;g+=64){Gb(f,h,i);for(var b=g;b<g+64&&b<r.length;b++)s[b]=r[b]^f[b-g];Jb(h,0,p)}return Tu.wipe(f),o===0&&Tu.wipe(h),s}ya.streamXOR=lp;function Yb(i,e,r,s){return s===void 0&&(s=0),Tu.wipe(r),lp(i,e,r,r,s)}ya.stream=Yb;function Jb(i,e,r){for(var s=1;r--;)s=s+(i[e]&255)|0,i[e]=s&255,s>>>=8,e++;if(s>0)throw new Error("ChaCha: counter overflow")}var fp={},Wi={};Object.defineProperty(Wi,"__esModule",{value:!0});function Qb(i,e,r){return~(i-1)&e|i-1&r}Wi.select=Qb;function Xb(i,e){return(i|0)-(e|0)-1>>>31&1}Wi.lessOrEqual=Xb;function dp(i,e){if(i.length!==e.length)return 0;for(var r=0,s=0;s<i.length;s++)r|=i[s]^e[s];return 1&r-1>>>8}Wi.compare=dp;function Zb(i,e){return i.length===0||e.length===0?!1:dp(i,e)!==0}Wi.equal=Zb;(function(i){Object.defineProperty(i,"__esModule",{value:!0});var e=Wi,r=Tr;i.DIGEST_LENGTH=16;var s=function(){function p(f){this.digestLength=i.DIGEST_LENGTH,this._buffer=new Uint8Array(16),this._r=new Uint16Array(10),this._h=new Uint16Array(10),this._pad=new Uint16Array(8),this._leftover=0,this._fin=0,this._finished=!1;var g=f[0]|f[1]<<8;this._r[0]=g&8191;var b=f[2]|f[3]<<8;this._r[1]=(g>>>13|b<<3)&8191;var E=f[4]|f[5]<<8;this._r[2]=(b>>>10|E<<6)&7939;var C=f[6]|f[7]<<8;this._r[3]=(E>>>7|C<<9)&8191;var N=f[8]|f[9]<<8;this._r[4]=(C>>>4|N<<12)&255,this._r[5]=N>>>1&8190;var P=f[10]|f[11]<<8;this._r[6]=(N>>>14|P<<2)&8191;var F=f[12]|f[13]<<8;this._r[7]=(P>>>11|F<<5)&8065;var k=f[14]|f[15]<<8;this._r[8]=(F>>>8|k<<8)&8191,this._r[9]=k>>>5&127,this._pad[0]=f[16]|f[17]<<8,this._pad[1]=f[18]|f[19]<<8,this._pad[2]=f[20]|f[21]<<8,this._pad[3]=f[22]|f[23]<<8,this._pad[4]=f[24]|f[25]<<8,this._pad[5]=f[26]|f[27]<<8,this._pad[6]=f[28]|f[29]<<8,this._pad[7]=f[30]|f[31]<<8}return p.prototype._blocks=function(f,g,b){for(var E=this._fin?0:2048,C=this._h[0],N=this._h[1],P=this._h[2],F=this._h[3],k=this._h[4],K=this._h[5],ee=this._h[6],A=this._h[7],$=this._h[8],S=this._h[9],I=this._r[0],_=this._r[1],c=this._r[2],m=this._r[3],B=this._r[4],z=this._r[5],W=this._r[6],oe=this._r[7],fe=this._r[8],T=this._r[9];b>=16;){var H=f[g+0]|f[g+1]<<8;C+=H&8191;var ce=f[g+2]|f[g+3]<<8;N+=(H>>>13|ce<<3)&8191;var ie=f[g+4]|f[g+5]<<8;P+=(ce>>>10|ie<<6)&8191;var Y=f[g+6]|f[g+7]<<8;F+=(ie>>>7|Y<<9)&8191;var re=f[g+8]|f[g+9]<<8;k+=(Y>>>4|re<<12)&8191,K+=re>>>1&8191;var J=f[g+10]|f[g+11]<<8;ee+=(re>>>14|J<<2)&8191;var ne=f[g+12]|f[g+13]<<8;A+=(J>>>11|ne<<5)&8191;var xe=f[g+14]|f[g+15]<<8;$+=(ne>>>8|xe<<8)&8191,S+=xe>>>5|E;var se=0,be=se;be+=C*I,be+=N*(5*T),be+=P*(5*fe),be+=F*(5*oe),be+=k*(5*W),se=be>>>13,be&=8191,be+=K*(5*z),be+=ee*(5*B),be+=A*(5*m),be+=$*(5*c),be+=S*(5*_),se+=be>>>13,be&=8191;var le=se;le+=C*_,le+=N*I,le+=P*(5*T),le+=F*(5*fe),le+=k*(5*oe),se=le>>>13,le&=8191,le+=K*(5*W),le+=ee*(5*z),le+=A*(5*B),le+=$*(5*m),le+=S*(5*c),se+=le>>>13,le&=8191;var me=se;me+=C*c,me+=N*_,me+=P*I,me+=F*(5*T),me+=k*(5*fe),se=me>>>13,me&=8191,me+=K*(5*oe),me+=ee*(5*W),me+=A*(5*z),me+=$*(5*B),me+=S*(5*m),se+=me>>>13,me&=8191;var q=se;q+=C*m,q+=N*c,q+=P*_,q+=F*I,q+=k*(5*T),se=q>>>13,q&=8191,q+=K*(5*fe),q+=ee*(5*oe),q+=A*(5*W),q+=$*(5*z),q+=S*(5*B),se+=q>>>13,q&=8191;var j=se;j+=C*B,j+=N*m,j+=P*c,j+=F*_,j+=k*I,se=j>>>13,j&=8191,j+=K*(5*T),j+=ee*(5*fe),j+=A*(5*oe),j+=$*(5*W),j+=S*(5*z),se+=j>>>13,j&=8191;var R=se;R+=C*z,R+=N*B,R+=P*m,R+=F*c,R+=k*_,se=R>>>13,R&=8191,R+=K*I,R+=ee*(5*T),R+=A*(5*fe),R+=$*(5*oe),R+=S*(5*W),se+=R>>>13,R&=8191;var l=se;l+=C*W,l+=N*z,l+=P*B,l+=F*m,l+=k*c,se=l>>>13,l&=8191,l+=K*_,l+=ee*I,l+=A*(5*T),l+=$*(5*fe),l+=S*(5*oe),se+=l>>>13,l&=8191;var x=se;x+=C*oe,x+=N*W,x+=P*z,x+=F*B,x+=k*m,se=x>>>13,x&=8191,x+=K*c,x+=ee*_,x+=A*I,x+=$*(5*T),x+=S*(5*fe),se+=x>>>13,x&=8191;var ae=se;ae+=C*fe,ae+=N*oe,ae+=P*W,ae+=F*z,ae+=k*B,se=ae>>>13,ae&=8191,ae+=K*m,ae+=ee*c,ae+=A*_,ae+=$*I,ae+=S*(5*T),se+=ae>>>13,ae&=8191;var de=se;de+=C*T,de+=N*fe,de+=P*oe,de+=F*W,de+=k*z,se=de>>>13,de&=8191,de+=K*B,de+=ee*m,de+=A*c,de+=$*_,de+=S*I,se+=de>>>13,de&=8191,se=(se<<2)+se|0,se=se+be|0,be=se&8191,se=se>>>13,le+=se,C=be,N=le,P=me,F=q,k=j,K=R,ee=l,A=x,$=ae,S=de,g+=16,b-=16}this._h[0]=C,this._h[1]=N,this._h[2]=P,this._h[3]=F,this._h[4]=k,this._h[5]=K,this._h[6]=ee,this._h[7]=A,this._h[8]=$,this._h[9]=S},p.prototype.finish=function(f,g){g===void 0&&(g=0);var b=new Uint16Array(10),E,C,N,P;if(this._leftover){for(P=this._leftover,this._buffer[P++]=1;P<16;P++)this._buffer[P]=0;this._fin=1,this._blocks(this._buffer,0,16)}for(E=this._h[1]>>>13,this._h[1]&=8191,P=2;P<10;P++)this._h[P]+=E,E=this._h[P]>>>13,this._h[P]&=8191;for(this._h[0]+=E*5,E=this._h[0]>>>13,this._h[0]&=8191,this._h[1]+=E,E=this._h[1]>>>13,this._h[1]&=8191,this._h[2]+=E,b[0]=this._h[0]+5,E=b[0]>>>13,b[0]&=8191,P=1;P<10;P++)b[P]=this._h[P]+E,E=b[P]>>>13,b[P]&=8191;for(b[9]-=8192,C=(E^1)-1,P=0;P<10;P++)b[P]&=C;for(C=~C,P=0;P<10;P++)this._h[P]=this._h[P]&C|b[P];for(this._h[0]=(this._h[0]|this._h[1]<<13)&65535,this._h[1]=(this._h[1]>>>3|this._h[2]<<10)&65535,this._h[2]=(this._h[2]>>>6|this._h[3]<<7)&65535,this._h[3]=(this._h[3]>>>9|this._h[4]<<4)&65535,this._h[4]=(this._h[4]>>>12|this._h[5]<<1|this._h[6]<<14)&65535,this._h[5]=(this._h[6]>>>2|this._h[7]<<11)&65535,this._h[6]=(this._h[7]>>>5|this._h[8]<<8)&65535,this._h[7]=(this._h[8]>>>8|this._h[9]<<5)&65535,N=this._h[0]+this._pad[0],this._h[0]=N&65535,P=1;P<8;P++)N=(this._h[P]+this._pad[P]|0)+(N>>>16)|0,this._h[P]=N&65535;return f[g+0]=this._h[0]>>>0,f[g+1]=this._h[0]>>>8,f[g+2]=this._h[1]>>>0,f[g+3]=this._h[1]>>>8,f[g+4]=this._h[2]>>>0,f[g+5]=this._h[2]>>>8,f[g+6]=this._h[3]>>>0,f[g+7]=this._h[3]>>>8,f[g+8]=this._h[4]>>>0,f[g+9]=this._h[4]>>>8,f[g+10]=this._h[5]>>>0,f[g+11]=this._h[5]>>>8,f[g+12]=this._h[6]>>>0,f[g+13]=this._h[6]>>>8,f[g+14]=this._h[7]>>>0,f[g+15]=this._h[7]>>>8,this._finished=!0,this},p.prototype.update=function(f){var g=0,b=f.length,E;if(this._leftover){E=16-this._leftover,E>b&&(E=b);for(var C=0;C<E;C++)this._buffer[this._leftover+C]=f[g+C];if(b-=E,g+=E,this._leftover+=E,this._leftover<16)return this;this._blocks(this._buffer,0,16),this._leftover=0}if(b>=16&&(E=b-b%16,this._blocks(f,g,E),g+=E,b-=E),b){for(var C=0;C<b;C++)this._buffer[this._leftover+C]=f[g+C];this._leftover+=b}return this},p.prototype.digest=function(){if(this._finished)throw new Error("Poly1305 was finished");var f=new Uint8Array(16);return this.finish(f),f},p.prototype.clean=function(){return r.wipe(this._buffer),r.wipe(this._r),r.wipe(this._h),r.wipe(this._pad),this._leftover=0,this._fin=0,this._finished=!0,this},p}();i.Poly1305=s;function o(p,f){var g=new s(p);g.update(f);var b=g.digest();return g.clean(),b}i.oneTimeAuth=o;function h(p,f){return p.length!==i.DIGEST_LENGTH||f.length!==i.DIGEST_LENGTH?!1:e.equal(p,f)}i.equal=h})(fp);(function(i){Object.defineProperty(i,"__esModule",{value:!0});var e=ya,r=fp,s=Tr,o=Ue,h=Wi;i.KEY_LENGTH=32,i.NONCE_LENGTH=12,i.TAG_LENGTH=16;var p=new Uint8Array(16),f=function(){function g(b){if(this.nonceLength=i.NONCE_LENGTH,this.tagLength=i.TAG_LENGTH,b.length!==i.KEY_LENGTH)throw new Error("ChaCha20Poly1305 needs 32-byte key");this._key=new Uint8Array(b)}return g.prototype.seal=function(b,E,C,N){if(b.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");var P=new Uint8Array(16);P.set(b,P.length-b.length);var F=new Uint8Array(32);e.stream(this._key,P,F,4);var k=E.length+this.tagLength,K;if(N){if(N.length!==k)throw new Error("ChaCha20Poly1305: incorrect destination length");K=N}else K=new Uint8Array(k);return e.streamXOR(this._key,P,E,K,4),this._authenticate(K.subarray(K.length-this.tagLength,K.length),F,K.subarray(0,K.length-this.tagLength),C),s.wipe(P),K},g.prototype.open=function(b,E,C,N){if(b.length>16)throw new Error("ChaCha20Poly1305: incorrect nonce length");if(E.length<this.tagLength)return null;var P=new Uint8Array(16);P.set(b,P.length-b.length);var F=new Uint8Array(32);e.stream(this._key,P,F,4);var k=new Uint8Array(this.tagLength);if(this._authenticate(k,F,E.subarray(0,E.length-this.tagLength),C),!h.equal(k,E.subarray(E.length-this.tagLength,E.length)))return null;var K=E.length-this.tagLength,ee;if(N){if(N.length!==K)throw new Error("ChaCha20Poly1305: incorrect destination length");ee=N}else ee=new Uint8Array(K);return e.streamXOR(this._key,P,E.subarray(0,E.length-this.tagLength),ee,4),s.wipe(P),ee},g.prototype.clean=function(){return s.wipe(this._key),this},g.prototype._authenticate=function(b,E,C,N){var P=new r.Poly1305(E);N&&(P.update(N),N.length%16>0&&P.update(p.subarray(N.length%16))),P.update(C),C.length%16>0&&P.update(p.subarray(C.length%16));var F=new Uint8Array(8);N&&o.writeUint64LE(N.length,F),P.update(F),o.writeUint64LE(C.length,F),P.update(F);for(var k=P.digest(),K=0;K<k.length;K++)b[K]=k[K];P.clean(),s.wipe(k),s.wipe(F)},g}();i.ChaCha20Poly1305=f})(ku);var pp={},qs={},Ku={};Object.defineProperty(Ku,"__esModule",{value:!0});function ew(i){return typeof i.saveState<"u"&&typeof i.restoreState<"u"&&typeof i.cleanSavedState<"u"}Ku.isSerializableHash=ew;Object.defineProperty(qs,"__esModule",{value:!0});var ci=Ku,tw=Wi,rw=Tr,gp=function(){function i(e,r){this._finished=!1,this._inner=new e,this._outer=new e,this.blockSize=this._outer.blockSize,this.digestLength=this._outer.digestLength;var s=new Uint8Array(this.blockSize);r.length>this.blockSize?this._inner.update(r).finish(s).clean():s.set(r);for(var o=0;o<s.length;o++)s[o]^=54;this._inner.update(s);for(var o=0;o<s.length;o++)s[o]^=106;this._outer.update(s),ci.isSerializableHash(this._inner)&&ci.isSerializableHash(this._outer)&&(this._innerKeyedState=this._inner.saveState(),this._outerKeyedState=this._outer.saveState()),rw.wipe(s)}return i.prototype.reset=function(){if(!ci.isSerializableHash(this._inner)||!ci.isSerializableHash(this._outer))throw new Error("hmac: can't reset() because hash doesn't implement restoreState()");return this._inner.restoreState(this._innerKeyedState),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},i.prototype.clean=function(){ci.isSerializableHash(this._inner)&&this._inner.cleanSavedState(this._innerKeyedState),ci.isSerializableHash(this._outer)&&this._outer.cleanSavedState(this._outerKeyedState),this._inner.clean(),this._outer.clean()},i.prototype.update=function(e){return this._inner.update(e),this},i.prototype.finish=function(e){return this._finished?(this._outer.finish(e),this):(this._inner.finish(e),this._outer.update(e.subarray(0,this.digestLength)).finish(e),this._finished=!0,this)},i.prototype.digest=function(){var e=new Uint8Array(this.digestLength);return this.finish(e),e},i.prototype.saveState=function(){if(!ci.isSerializableHash(this._inner))throw new Error("hmac: can't saveState() because hash doesn't implement it");return this._inner.saveState()},i.prototype.restoreState=function(e){if(!ci.isSerializableHash(this._inner)||!ci.isSerializableHash(this._outer))throw new Error("hmac: can't restoreState() because hash doesn't implement it");return this._inner.restoreState(e),this._outer.restoreState(this._outerKeyedState),this._finished=!1,this},i.prototype.cleanSavedState=function(e){if(!ci.isSerializableHash(this._inner))throw new Error("hmac: can't cleanSavedState() because hash doesn't implement it");this._inner.cleanSavedState(e)},i}();qs.HMAC=gp;function iw(i,e,r){var s=new gp(i,e);s.update(r);var o=s.digest();return s.clean(),o}qs.hmac=iw;qs.equal=tw.equal;Object.defineProperty(pp,"__esModule",{value:!0});var Ef=qs,Df=Tr,nw=function(){function i(e,r,s,o){s===void 0&&(s=new Uint8Array(0)),this._counter=new Uint8Array(1),this._hash=e,this._info=o;var h=Ef.hmac(this._hash,s,r);this._hmac=new Ef.HMAC(e,h),this._buffer=new Uint8Array(this._hmac.digestLength),this._bufpos=this._buffer.length}return i.prototype._fillBuffer=function(){this._counter[0]++;var e=this._counter[0];if(e===0)throw new Error("hkdf: cannot expand more");this._hmac.reset(),e>1&&this._hmac.update(this._buffer),this._info&&this._hmac.update(this._info),this._hmac.update(this._counter),this._hmac.finish(this._buffer),this._bufpos=0},i.prototype.expand=function(e){for(var r=new Uint8Array(e),s=0;s<r.length;s++)this._bufpos===this._buffer.length&&this._fillBuffer(),r[s]=this._buffer[this._bufpos++];return r},i.prototype.clean=function(){this._hmac.clean(),Df.wipe(this._buffer),Df.wipe(this._counter),this._bufpos=0},i}(),sw=pp.HKDF=nw,Qn={},ma={},_a={};Object.defineProperty(_a,"__esModule",{value:!0});_a.BrowserRandomSource=void 0;const Sf=65536;class ow{constructor(){this.isAvailable=!1,this.isInstantiated=!1;const e=typeof self<"u"?self.crypto||self.msCrypto:null;e&&e.getRandomValues!==void 0&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");const r=new Uint8Array(e);for(let s=0;s<r.length;s+=Sf)this._crypto.getRandomValues(r.subarray(s,s+Math.min(r.length-s,Sf)));return r}}_a.BrowserRandomSource=ow;var ba={};Object.defineProperty(ba,"__esModule",{value:!0});ba.NodeRandomSource=void 0;const aw=Tr;class cw{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof X_<"u"){const e=Z_();e&&e.randomBytes&&(this._crypto=e,this.isAvailable=!0,this.isInstantiated=!0)}}randomBytes(e){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let r=this._crypto.randomBytes(e);if(r.length!==e)throw new Error("NodeRandomSource: got fewer bytes than requested");const s=new Uint8Array(e);for(let o=0;o<s.length;o++)s[o]=r[o];return(0,aw.wipe)(r),s}}ba.NodeRandomSource=cw;Object.defineProperty(ma,"__esModule",{value:!0});ma.SystemRandomSource=void 0;const uw=_a,hw=ba;class lw{constructor(){if(this.isAvailable=!1,this.name="",this._source=new uw.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new hw.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(e){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(e)}}ma.SystemRandomSource=lw;(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.randomStringForEntropy=i.randomString=i.randomUint32=i.randomBytes=i.defaultRandomSource=void 0;const e=ma,r=Ue,s=Tr;i.defaultRandomSource=new e.SystemRandomSource;function o(b,E=i.defaultRandomSource){return E.randomBytes(b)}i.randomBytes=o;function h(b=i.defaultRandomSource){const E=o(4,b),C=(0,r.readUint32LE)(E);return(0,s.wipe)(E),C}i.randomUint32=h;const p="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function f(b,E=p,C=i.defaultRandomSource){if(E.length<2)throw new Error("randomString charset is too short");if(E.length>256)throw new Error("randomString charset is too long");let N="";const P=E.length,F=256-256%P;for(;b>0;){const k=o(Math.ceil(b*256/F),C);for(let K=0;K<k.length&&b>0;K++){const ee=k[K];ee<F&&(N+=E.charAt(ee%P),b--)}(0,s.wipe)(k)}return N}i.randomString=f;function g(b,E=p,C=i.defaultRandomSource){const N=Math.ceil(b/(Math.log(E.length)/Math.LN2));return f(N,E,C)}i.randomStringForEntropy=g})(Qn);var wa={};(function(i){Object.defineProperty(i,"__esModule",{value:!0});var e=Ue,r=Tr;i.DIGEST_LENGTH=32,i.BLOCK_SIZE=64;var s=function(){function f(){this.digestLength=i.DIGEST_LENGTH,this.blockSize=i.BLOCK_SIZE,this._state=new Int32Array(8),this._temp=new Int32Array(64),this._buffer=new Uint8Array(128),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this.reset()}return f.prototype._initState=function(){this._state[0]=1779033703,this._state[1]=3144134277,this._state[2]=1013904242,this._state[3]=2773480762,this._state[4]=1359893119,this._state[5]=2600822924,this._state[6]=528734635,this._state[7]=1541459225},f.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},f.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._temp),this.reset()},f.prototype.update=function(g,b){if(b===void 0&&(b=g.length),this._finished)throw new Error("SHA256: can't update because hash was finished.");var E=0;if(this._bytesHashed+=b,this._bufferLength>0){for(;this._bufferLength<this.blockSize&&b>0;)this._buffer[this._bufferLength++]=g[E++],b--;this._bufferLength===this.blockSize&&(h(this._temp,this._state,this._buffer,0,this.blockSize),this._bufferLength=0)}for(b>=this.blockSize&&(E=h(this._temp,this._state,g,E,b),b%=this.blockSize);b>0;)this._buffer[this._bufferLength++]=g[E++],b--;return this},f.prototype.finish=function(g){if(!this._finished){var b=this._bytesHashed,E=this._bufferLength,C=b/536870912|0,N=b<<3,P=b%64<56?64:128;this._buffer[E]=128;for(var F=E+1;F<P-8;F++)this._buffer[F]=0;e.writeUint32BE(C,this._buffer,P-8),e.writeUint32BE(N,this._buffer,P-4),h(this._temp,this._state,this._buffer,0,P),this._finished=!0}for(var F=0;F<this.digestLength/4;F++)e.writeUint32BE(this._state[F],g,F*4);return this},f.prototype.digest=function(){var g=new Uint8Array(this.digestLength);return this.finish(g),g},f.prototype.saveState=function(){if(this._finished)throw new Error("SHA256: cannot save finished state");return{state:new Int32Array(this._state),buffer:this._bufferLength>0?new Uint8Array(this._buffer):void 0,bufferLength:this._bufferLength,bytesHashed:this._bytesHashed}},f.prototype.restoreState=function(g){return this._state.set(g.state),this._bufferLength=g.bufferLength,g.buffer&&this._buffer.set(g.buffer),this._bytesHashed=g.bytesHashed,this._finished=!1,this},f.prototype.cleanSavedState=function(g){r.wipe(g.state),g.buffer&&r.wipe(g.buffer),g.bufferLength=0,g.bytesHashed=0},f}();i.SHA256=s;var o=new Int32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]);function h(f,g,b,E,C){for(;C>=64;){for(var N=g[0],P=g[1],F=g[2],k=g[3],K=g[4],ee=g[5],A=g[6],$=g[7],S=0;S<16;S++){var I=E+S*4;f[S]=e.readUint32BE(b,I)}for(var S=16;S<64;S++){var _=f[S-2],c=(_>>>17|_<<32-17)^(_>>>19|_<<32-19)^_>>>10;_=f[S-15];var m=(_>>>7|_<<32-7)^(_>>>18|_<<32-18)^_>>>3;f[S]=(c+f[S-7]|0)+(m+f[S-16]|0)}for(var S=0;S<64;S++){var c=(((K>>>6|K<<26)^(K>>>11|K<<21)^(K>>>25|K<<7))+(K&ee^~K&A)|0)+($+(o[S]+f[S]|0)|0)|0,m=((N>>>2|N<<32-2)^(N>>>13|N<<32-13)^(N>>>22|N<<32-22))+(N&P^N&F^P&F)|0;$=A,A=ee,ee=K,K=k+c|0,k=F,F=P,P=N,N=c+m|0}g[0]+=N,g[1]+=P,g[2]+=F,g[3]+=k,g[4]+=K,g[5]+=ee,g[6]+=A,g[7]+=$,E+=64,C-=64}return E}function p(f){var g=new s;g.update(f);var b=g.digest();return g.clean(),b}i.hash=p})(wa);var Vu={};(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.sharedKey=i.generateKeyPair=i.generateKeyPairFromSeed=i.scalarMultBase=i.scalarMult=i.SHARED_KEY_LENGTH=i.SECRET_KEY_LENGTH=i.PUBLIC_KEY_LENGTH=void 0;const e=Qn,r=Tr;i.PUBLIC_KEY_LENGTH=32,i.SECRET_KEY_LENGTH=32,i.SHARED_KEY_LENGTH=32;function s(S){const I=new Float64Array(16);if(S)for(let _=0;_<S.length;_++)I[_]=S[_];return I}const o=new Uint8Array(32);o[0]=9;const h=s([56129,1]);function p(S){let I=1;for(let _=0;_<16;_++){let c=S[_]+I+65535;I=Math.floor(c/65536),S[_]=c-I*65536}S[0]+=I-1+37*(I-1)}function f(S,I,_){const c=~(_-1);for(let m=0;m<16;m++){const B=c&(S[m]^I[m]);S[m]^=B,I[m]^=B}}function g(S,I){const _=s(),c=s();for(let m=0;m<16;m++)c[m]=I[m];p(c),p(c),p(c);for(let m=0;m<2;m++){_[0]=c[0]-65517;for(let z=1;z<15;z++)_[z]=c[z]-65535-(_[z-1]>>16&1),_[z-1]&=65535;_[15]=c[15]-32767-(_[14]>>16&1);const B=_[15]>>16&1;_[14]&=65535,f(c,_,1-B)}for(let m=0;m<16;m++)S[2*m]=c[m]&255,S[2*m+1]=c[m]>>8}function b(S,I){for(let _=0;_<16;_++)S[_]=I[2*_]+(I[2*_+1]<<8);S[15]&=32767}function E(S,I,_){for(let c=0;c<16;c++)S[c]=I[c]+_[c]}function C(S,I,_){for(let c=0;c<16;c++)S[c]=I[c]-_[c]}function N(S,I,_){let c,m,B=0,z=0,W=0,oe=0,fe=0,T=0,H=0,ce=0,ie=0,Y=0,re=0,J=0,ne=0,xe=0,se=0,be=0,le=0,me=0,q=0,j=0,R=0,l=0,x=0,ae=0,de=0,Se=0,ze=0,Ke=0,Fe=0,pt=0,gt=0,je=_[0],Ie=_[1],Ne=_[2],$e=_[3],qe=_[4],Ce=_[5],Le=_[6],De=_[7],Pe=_[8],Be=_[9],Oe=_[10],Ve=_[11],Ge=_[12],et=_[13],tt=_[14],Je=_[15];c=I[0],B+=c*je,z+=c*Ie,W+=c*Ne,oe+=c*$e,fe+=c*qe,T+=c*Ce,H+=c*Le,ce+=c*De,ie+=c*Pe,Y+=c*Be,re+=c*Oe,J+=c*Ve,ne+=c*Ge,xe+=c*et,se+=c*tt,be+=c*Je,c=I[1],z+=c*je,W+=c*Ie,oe+=c*Ne,fe+=c*$e,T+=c*qe,H+=c*Ce,ce+=c*Le,ie+=c*De,Y+=c*Pe,re+=c*Be,J+=c*Oe,ne+=c*Ve,xe+=c*Ge,se+=c*et,be+=c*tt,le+=c*Je,c=I[2],W+=c*je,oe+=c*Ie,fe+=c*Ne,T+=c*$e,H+=c*qe,ce+=c*Ce,ie+=c*Le,Y+=c*De,re+=c*Pe,J+=c*Be,ne+=c*Oe,xe+=c*Ve,se+=c*Ge,be+=c*et,le+=c*tt,me+=c*Je,c=I[3],oe+=c*je,fe+=c*Ie,T+=c*Ne,H+=c*$e,ce+=c*qe,ie+=c*Ce,Y+=c*Le,re+=c*De,J+=c*Pe,ne+=c*Be,xe+=c*Oe,se+=c*Ve,be+=c*Ge,le+=c*et,me+=c*tt,q+=c*Je,c=I[4],fe+=c*je,T+=c*Ie,H+=c*Ne,ce+=c*$e,ie+=c*qe,Y+=c*Ce,re+=c*Le,J+=c*De,ne+=c*Pe,xe+=c*Be,se+=c*Oe,be+=c*Ve,le+=c*Ge,me+=c*et,q+=c*tt,j+=c*Je,c=I[5],T+=c*je,H+=c*Ie,ce+=c*Ne,ie+=c*$e,Y+=c*qe,re+=c*Ce,J+=c*Le,ne+=c*De,xe+=c*Pe,se+=c*Be,be+=c*Oe,le+=c*Ve,me+=c*Ge,q+=c*et,j+=c*tt,R+=c*Je,c=I[6],H+=c*je,ce+=c*Ie,ie+=c*Ne,Y+=c*$e,re+=c*qe,J+=c*Ce,ne+=c*Le,xe+=c*De,se+=c*Pe,be+=c*Be,le+=c*Oe,me+=c*Ve,q+=c*Ge,j+=c*et,R+=c*tt,l+=c*Je,c=I[7],ce+=c*je,ie+=c*Ie,Y+=c*Ne,re+=c*$e,J+=c*qe,ne+=c*Ce,xe+=c*Le,se+=c*De,be+=c*Pe,le+=c*Be,me+=c*Oe,q+=c*Ve,j+=c*Ge,R+=c*et,l+=c*tt,x+=c*Je,c=I[8],ie+=c*je,Y+=c*Ie,re+=c*Ne,J+=c*$e,ne+=c*qe,xe+=c*Ce,se+=c*Le,be+=c*De,le+=c*Pe,me+=c*Be,q+=c*Oe,j+=c*Ve,R+=c*Ge,l+=c*et,x+=c*tt,ae+=c*Je,c=I[9],Y+=c*je,re+=c*Ie,J+=c*Ne,ne+=c*$e,xe+=c*qe,se+=c*Ce,be+=c*Le,le+=c*De,me+=c*Pe,q+=c*Be,j+=c*Oe,R+=c*Ve,l+=c*Ge,x+=c*et,ae+=c*tt,de+=c*Je,c=I[10],re+=c*je,J+=c*Ie,ne+=c*Ne,xe+=c*$e,se+=c*qe,be+=c*Ce,le+=c*Le,me+=c*De,q+=c*Pe,j+=c*Be,R+=c*Oe,l+=c*Ve,x+=c*Ge,ae+=c*et,de+=c*tt,Se+=c*Je,c=I[11],J+=c*je,ne+=c*Ie,xe+=c*Ne,se+=c*$e,be+=c*qe,le+=c*Ce,me+=c*Le,q+=c*De,j+=c*Pe,R+=c*Be,l+=c*Oe,x+=c*Ve,ae+=c*Ge,de+=c*et,Se+=c*tt,ze+=c*Je,c=I[12],ne+=c*je,xe+=c*Ie,se+=c*Ne,be+=c*$e,le+=c*qe,me+=c*Ce,q+=c*Le,j+=c*De,R+=c*Pe,l+=c*Be,x+=c*Oe,ae+=c*Ve,de+=c*Ge,Se+=c*et,ze+=c*tt,Ke+=c*Je,c=I[13],xe+=c*je,se+=c*Ie,be+=c*Ne,le+=c*$e,me+=c*qe,q+=c*Ce,j+=c*Le,R+=c*De,l+=c*Pe,x+=c*Be,ae+=c*Oe,de+=c*Ve,Se+=c*Ge,ze+=c*et,Ke+=c*tt,Fe+=c*Je,c=I[14],se+=c*je,be+=c*Ie,le+=c*Ne,me+=c*$e,q+=c*qe,j+=c*Ce,R+=c*Le,l+=c*De,x+=c*Pe,ae+=c*Be,de+=c*Oe,Se+=c*Ve,ze+=c*Ge,Ke+=c*et,Fe+=c*tt,pt+=c*Je,c=I[15],be+=c*je,le+=c*Ie,me+=c*Ne,q+=c*$e,j+=c*qe,R+=c*Ce,l+=c*Le,x+=c*De,ae+=c*Pe,de+=c*Be,Se+=c*Oe,ze+=c*Ve,Ke+=c*Ge,Fe+=c*et,pt+=c*tt,gt+=c*Je,B+=38*le,z+=38*me,W+=38*q,oe+=38*j,fe+=38*R,T+=38*l,H+=38*x,ce+=38*ae,ie+=38*de,Y+=38*Se,re+=38*ze,J+=38*Ke,ne+=38*Fe,xe+=38*pt,se+=38*gt,m=1,c=B+m+65535,m=Math.floor(c/65536),B=c-m*65536,c=z+m+65535,m=Math.floor(c/65536),z=c-m*65536,c=W+m+65535,m=Math.floor(c/65536),W=c-m*65536,c=oe+m+65535,m=Math.floor(c/65536),oe=c-m*65536,c=fe+m+65535,m=Math.floor(c/65536),fe=c-m*65536,c=T+m+65535,m=Math.floor(c/65536),T=c-m*65536,c=H+m+65535,m=Math.floor(c/65536),H=c-m*65536,c=ce+m+65535,m=Math.floor(c/65536),ce=c-m*65536,c=ie+m+65535,m=Math.floor(c/65536),ie=c-m*65536,c=Y+m+65535,m=Math.floor(c/65536),Y=c-m*65536,c=re+m+65535,m=Math.floor(c/65536),re=c-m*65536,c=J+m+65535,m=Math.floor(c/65536),J=c-m*65536,c=ne+m+65535,m=Math.floor(c/65536),ne=c-m*65536,c=xe+m+65535,m=Math.floor(c/65536),xe=c-m*65536,c=se+m+65535,m=Math.floor(c/65536),se=c-m*65536,c=be+m+65535,m=Math.floor(c/65536),be=c-m*65536,B+=m-1+37*(m-1),m=1,c=B+m+65535,m=Math.floor(c/65536),B=c-m*65536,c=z+m+65535,m=Math.floor(c/65536),z=c-m*65536,c=W+m+65535,m=Math.floor(c/65536),W=c-m*65536,c=oe+m+65535,m=Math.floor(c/65536),oe=c-m*65536,c=fe+m+65535,m=Math.floor(c/65536),fe=c-m*65536,c=T+m+65535,m=Math.floor(c/65536),T=c-m*65536,c=H+m+65535,m=Math.floor(c/65536),H=c-m*65536,c=ce+m+65535,m=Math.floor(c/65536),ce=c-m*65536,c=ie+m+65535,m=Math.floor(c/65536),ie=c-m*65536,c=Y+m+65535,m=Math.floor(c/65536),Y=c-m*65536,c=re+m+65535,m=Math.floor(c/65536),re=c-m*65536,c=J+m+65535,m=Math.floor(c/65536),J=c-m*65536,c=ne+m+65535,m=Math.floor(c/65536),ne=c-m*65536,c=xe+m+65535,m=Math.floor(c/65536),xe=c-m*65536,c=se+m+65535,m=Math.floor(c/65536),se=c-m*65536,c=be+m+65535,m=Math.floor(c/65536),be=c-m*65536,B+=m-1+37*(m-1),S[0]=B,S[1]=z,S[2]=W,S[3]=oe,S[4]=fe,S[5]=T,S[6]=H,S[7]=ce,S[8]=ie,S[9]=Y,S[10]=re,S[11]=J,S[12]=ne,S[13]=xe,S[14]=se,S[15]=be}function P(S,I){N(S,I,I)}function F(S,I){const _=s();for(let c=0;c<16;c++)_[c]=I[c];for(let c=253;c>=0;c--)P(_,_),c!==2&&c!==4&&N(_,_,I);for(let c=0;c<16;c++)S[c]=_[c]}function k(S,I){const _=new Uint8Array(32),c=new Float64Array(80),m=s(),B=s(),z=s(),W=s(),oe=s(),fe=s();for(let ie=0;ie<31;ie++)_[ie]=S[ie];_[31]=S[31]&127|64,_[0]&=248,b(c,I);for(let ie=0;ie<16;ie++)B[ie]=c[ie];m[0]=W[0]=1;for(let ie=254;ie>=0;--ie){const Y=_[ie>>>3]>>>(ie&7)&1;f(m,B,Y),f(z,W,Y),E(oe,m,z),C(m,m,z),E(z,B,W),C(B,B,W),P(W,oe),P(fe,m),N(m,z,m),N(z,B,oe),E(oe,m,z),C(m,m,z),P(B,m),C(z,W,fe),N(m,z,h),E(m,m,W),N(z,z,m),N(m,W,fe),N(W,B,c),P(B,oe),f(m,B,Y),f(z,W,Y)}for(let ie=0;ie<16;ie++)c[ie+16]=m[ie],c[ie+32]=z[ie],c[ie+48]=B[ie],c[ie+64]=W[ie];const T=c.subarray(32),H=c.subarray(16);F(T,T),N(H,H,T);const ce=new Uint8Array(32);return g(ce,H),ce}i.scalarMult=k;function K(S){return k(S,o)}i.scalarMultBase=K;function ee(S){if(S.length!==i.SECRET_KEY_LENGTH)throw new Error(`x25519: seed must be ${i.SECRET_KEY_LENGTH} bytes`);const I=new Uint8Array(S);return{publicKey:K(I),secretKey:I}}i.generateKeyPairFromSeed=ee;function A(S){const I=(0,e.randomBytes)(32,S),_=ee(I);return(0,r.wipe)(I),_}i.generateKeyPair=A;function $(S,I,_=!1){if(S.length!==i.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect secret key length");if(I.length!==i.PUBLIC_KEY_LENGTH)throw new Error("X25519: incorrect public key length");const c=k(S,I);if(_){let m=0;for(let B=0;B<c.length;B++)m|=c[B];if(m===0)throw new Error("X25519: invalid shared key")}return c}i.sharedKey=$})(Vu);function Wu(i){return globalThis.Buffer!=null?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):i}function vp(i=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?Wu(globalThis.Buffer.allocUnsafe(i)):new Uint8Array(i)}function Ru(i,e){e||(e=i.reduce((o,h)=>o+h.length,0));const r=vp(e);let s=0;for(const o of i)r.set(o,s),s+=o.length;return Wu(r)}function fw(i,e){if(i.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),s=0;s<r.length;s++)r[s]=255;for(var o=0;o<i.length;o++){var h=i.charAt(o),p=h.charCodeAt(0);if(r[p]!==255)throw new TypeError(h+" is ambiguous");r[p]=o}var f=i.length,g=i.charAt(0),b=Math.log(f)/Math.log(256),E=Math.log(256)/Math.log(f);function C(F){if(F instanceof Uint8Array||(ArrayBuffer.isView(F)?F=new Uint8Array(F.buffer,F.byteOffset,F.byteLength):Array.isArray(F)&&(F=Uint8Array.from(F))),!(F instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(F.length===0)return"";for(var k=0,K=0,ee=0,A=F.length;ee!==A&&F[ee]===0;)ee++,k++;for(var $=(A-ee)*E+1>>>0,S=new Uint8Array($);ee!==A;){for(var I=F[ee],_=0,c=$-1;(I!==0||_<K)&&c!==-1;c--,_++)I+=256*S[c]>>>0,S[c]=I%f>>>0,I=I/f>>>0;if(I!==0)throw new Error("Non-zero carry");K=_,ee++}for(var m=$-K;m!==$&&S[m]===0;)m++;for(var B=g.repeat(k);m<$;++m)B+=i.charAt(S[m]);return B}function N(F){if(typeof F!="string")throw new TypeError("Expected String");if(F.length===0)return new Uint8Array;var k=0;if(F[k]!==" "){for(var K=0,ee=0;F[k]===g;)K++,k++;for(var A=(F.length-k)*b+1>>>0,$=new Uint8Array(A);F[k];){var S=r[F.charCodeAt(k)];if(S===255)return;for(var I=0,_=A-1;(S!==0||I<ee)&&_!==-1;_--,I++)S+=f*$[_]>>>0,$[_]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");ee=I,k++}if(F[k]!==" "){for(var c=A-ee;c!==A&&$[c]===0;)c++;for(var m=new Uint8Array(K+(A-c)),B=K;c!==A;)m[B++]=$[c++];return m}}}function P(F){var k=N(F);if(k)return k;throw new Error(`Non-${e} character`)}return{encode:C,decodeUnsafe:N,decode:P}}var dw=fw,pw=dw;const gw=i=>{if(i instanceof Uint8Array&&i.constructor.name==="Uint8Array")return i;if(i instanceof ArrayBuffer)return new Uint8Array(i);if(ArrayBuffer.isView(i))return new Uint8Array(i.buffer,i.byteOffset,i.byteLength);throw new Error("Unknown type, must be binary type")},vw=i=>new TextEncoder().encode(i),yw=i=>new TextDecoder().decode(i);class mw{constructor(e,r,s){this.name=e,this.prefix=r,this.baseEncode=s}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class _w{constructor(e,r,s){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=s}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return yp(this,e)}}class bw{constructor(e){this.decoders=e}or(e){return yp(this,e)}decode(e){const r=e[0],s=this.decoders[r];if(s)return s.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const yp=(i,e)=>new bw({...i.decoders||{[i.prefix]:i},...e.decoders||{[e.prefix]:e}});class ww{constructor(e,r,s,o){this.name=e,this.prefix=r,this.baseEncode=s,this.baseDecode=o,this.encoder=new mw(e,r,s),this.decoder=new _w(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Ea=({name:i,prefix:e,encode:r,decode:s})=>new ww(i,e,r,s),Hs=({prefix:i,name:e,alphabet:r})=>{const{encode:s,decode:o}=pw(r,e);return Ea({prefix:i,name:e,encode:s,decode:h=>gw(o(h))})},Ew=(i,e,r,s)=>{const o={};for(let E=0;E<e.length;++E)o[e[E]]=E;let h=i.length;for(;i[h-1]==="=";)--h;const p=new Uint8Array(h*r/8|0);let f=0,g=0,b=0;for(let E=0;E<h;++E){const C=o[i[E]];if(C===void 0)throw new SyntaxError(`Non-${s} character`);g=g<<r|C,f+=r,f>=8&&(f-=8,p[b++]=255&g>>f)}if(f>=r||255&g<<8-f)throw new SyntaxError("Unexpected end of data");return p},Dw=(i,e,r)=>{const s=e[e.length-1]==="=",o=(1<<r)-1;let h="",p=0,f=0;for(let g=0;g<i.length;++g)for(f=f<<8|i[g],p+=8;p>r;)p-=r,h+=e[o&f>>p];if(p&&(h+=e[o&f<<r-p]),s)for(;h.length*r&7;)h+="=";return h},Jt=({name:i,prefix:e,bitsPerChar:r,alphabet:s})=>Ea({prefix:e,name:i,encode(o){return Dw(o,s,r)},decode(o){return Ew(o,s,r,i)}}),Sw=Ea({prefix:"\0",name:"identity",encode:i=>yw(i),decode:i=>vw(i)}),Iw=Object.freeze(Object.defineProperty({__proto__:null,identity:Sw},Symbol.toStringTag,{value:"Module"})),xw=Jt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Ow=Object.freeze(Object.defineProperty({__proto__:null,base2:xw},Symbol.toStringTag,{value:"Module"})),Cw=Jt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Pw=Object.freeze(Object.defineProperty({__proto__:null,base8:Cw},Symbol.toStringTag,{value:"Module"})),Aw=Hs({prefix:"9",name:"base10",alphabet:"0123456789"}),Tw=Object.freeze(Object.defineProperty({__proto__:null,base10:Aw},Symbol.toStringTag,{value:"Module"})),Rw=Jt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Nw=Jt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),$w=Object.freeze(Object.defineProperty({__proto__:null,base16:Rw,base16upper:Nw},Symbol.toStringTag,{value:"Module"})),Lw=Jt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Uw=Jt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Fw=Jt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Mw=Jt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),jw=Jt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),qw=Jt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Hw=Jt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),zw=Jt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Bw=Jt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),kw=Object.freeze(Object.defineProperty({__proto__:null,base32:Lw,base32hex:jw,base32hexpad:Hw,base32hexpadupper:zw,base32hexupper:qw,base32pad:Fw,base32padupper:Mw,base32upper:Uw,base32z:Bw},Symbol.toStringTag,{value:"Module"})),Kw=Hs({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Vw=Hs({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Ww=Object.freeze(Object.defineProperty({__proto__:null,base36:Kw,base36upper:Vw},Symbol.toStringTag,{value:"Module"})),Gw=Hs({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Yw=Hs({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),Jw=Object.freeze(Object.defineProperty({__proto__:null,base58btc:Gw,base58flickr:Yw},Symbol.toStringTag,{value:"Module"})),Qw=Jt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Xw=Jt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Zw=Jt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),eE=Jt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),tE=Object.freeze(Object.defineProperty({__proto__:null,base64:Qw,base64pad:Xw,base64url:Zw,base64urlpad:eE},Symbol.toStringTag,{value:"Module"})),mp=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),rE=mp.reduce((i,e,r)=>(i[r]=e,i),[]),iE=mp.reduce((i,e,r)=>(i[e.codePointAt(0)]=r,i),[]);function nE(i){return i.reduce((e,r)=>(e+=rE[r],e),"")}function sE(i){const e=[];for(const r of i){const s=iE[r.codePointAt(0)];if(s===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(s)}return new Uint8Array(e)}const oE=Ea({prefix:"🚀",name:"base256emoji",encode:nE,decode:sE}),aE=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:oE},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const If={...Iw,...Ow,...Pw,...Tw,...$w,...kw,...Ww,...Jw,...tE,...aE};function _p(i,e,r,s){return{name:i,prefix:e,encoder:{name:i,prefix:e,encode:r},decoder:{decode:s}}}const xf=_p("utf8","u",i=>"u"+new TextDecoder("utf8").decode(i),i=>new TextEncoder().encode(i.substring(1))),tu=_p("ascii","a",i=>{let e="a";for(let r=0;r<i.length;r++)e+=String.fromCharCode(i[r]);return e},i=>{i=i.substring(1);const e=vp(i.length);for(let r=0;r<i.length;r++)e[r]=i.charCodeAt(r);return e}),bp={utf8:xf,"utf-8":xf,hex:If.base16,latin1:tu,ascii:tu,binary:tu,...If};function Er(i,e="utf8"){const r=bp[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Wu(globalThis.Buffer.from(i,"utf-8")):r.decoder.decode(`${r.prefix}${i}`)}function dr(i,e="utf8"){const r=bp[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(i.buffer,i.byteOffset,i.byteLength).toString("utf8"):r.encoder.encode(i).substring(1)}var Of=globalThis&&globalThis.__spreadArray||function(i,e,r){if(r||arguments.length===2)for(var s=0,o=e.length,h;s<o;s++)(h||!(s in e))&&(h||(h=Array.prototype.slice.call(e,0,s)),h[s]=e[s]);return i.concat(h||Array.prototype.slice.call(e))},cE=function(){function i(e,r,s){this.name=e,this.version=r,this.os=s,this.type="browser"}return i}(),uE=function(){function i(e){this.version=e,this.type="node",this.name="node",this.os=hi.platform}return i}(),hE=function(){function i(e,r,s,o){this.name=e,this.version=r,this.os=s,this.bot=o,this.type="bot-device"}return i}(),lE=function(){function i(){this.type="bot",this.bot=!0,this.name="bot",this.version=null,this.os=null}return i}(),fE=function(){function i(){this.type="react-native",this.name="react-native",this.version=null,this.os=null}return i}(),dE=/alexa|bot|crawl(er|ing)|facebookexternalhit|feedburner|google web preview|nagios|postrank|pingdom|slurp|spider|yahoo!|yandex/,pE=/(nuhk|curl|Googlebot|Yammybot|Openbot|Slurp|MSNBot|Ask\ Jeeves\/Teoma|ia_archiver)/,Cf=3,gE=[["aol",/AOLShield\/([0-9\._]+)/],["edge",/Edge\/([0-9\._]+)/],["edge-ios",/EdgiOS\/([0-9\._]+)/],["yandexbrowser",/YaBrowser\/([0-9\._]+)/],["kakaotalk",/KAKAOTALK\s([0-9\.]+)/],["samsung",/SamsungBrowser\/([0-9\.]+)/],["silk",/\bSilk\/([0-9._-]+)\b/],["miui",/MiuiBrowser\/([0-9\.]+)$/],["beaker",/BeakerBrowser\/([0-9\.]+)/],["edge-chromium",/EdgA?\/([0-9\.]+)/],["chromium-webview",/(?!Chrom.*OPR)wv\).*Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["chrome",/(?!Chrom.*OPR)Chrom(?:e|ium)\/([0-9\.]+)(:?\s|$)/],["phantomjs",/PhantomJS\/([0-9\.]+)(:?\s|$)/],["crios",/CriOS\/([0-9\.]+)(:?\s|$)/],["firefox",/Firefox\/([0-9\.]+)(?:\s|$)/],["fxios",/FxiOS\/([0-9\.]+)/],["opera-mini",/Opera Mini.*Version\/([0-9\.]+)/],["opera",/Opera\/([0-9\.]+)(?:\s|$)/],["opera",/OPR\/([0-9\.]+)(:?\s|$)/],["pie",/^Microsoft Pocket Internet Explorer\/(\d+\.\d+)$/],["pie",/^Mozilla\/\d\.\d+\s\(compatible;\s(?:MSP?IE|MSInternet Explorer) (\d+\.\d+);.*Windows CE.*\)$/],["netfront",/^Mozilla\/\d\.\d+.*NetFront\/(\d.\d)/],["ie",/Trident\/7\.0.*rv\:([0-9\.]+).*\).*Gecko$/],["ie",/MSIE\s([0-9\.]+);.*Trident\/[4-7].0/],["ie",/MSIE\s(7\.0)/],["bb10",/BB10;\sTouch.*Version\/([0-9\.]+)/],["android",/Android\s([0-9\.]+)/],["ios",/Version\/([0-9\._]+).*Mobile.*Safari.*/],["safari",/Version\/([0-9\._]+).*Safari/],["facebook",/FB[AS]V\/([0-9\.]+)/],["instagram",/Instagram\s([0-9\.]+)/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Mobile/],["ios-webview",/AppleWebKit\/([0-9\.]+).*Gecko\)$/],["curl",/^curl\/([0-9\.]+)$/],["searchbot",dE]],Pf=[["iOS",/iP(hone|od|ad)/],["Android OS",/Android/],["BlackBerry OS",/BlackBerry|BB10/],["Windows Mobile",/IEMobile/],["Amazon OS",/Kindle/],["Windows 3.11",/Win16/],["Windows 95",/(Windows 95)|(Win95)|(Windows_95)/],["Windows 98",/(Windows 98)|(Win98)/],["Windows 2000",/(Windows NT 5.0)|(Windows 2000)/],["Windows XP",/(Windows NT 5.1)|(Windows XP)/],["Windows Server 2003",/(Windows NT 5.2)/],["Windows Vista",/(Windows NT 6.0)/],["Windows 7",/(Windows NT 6.1)/],["Windows 8",/(Windows NT 6.2)/],["Windows 8.1",/(Windows NT 6.3)/],["Windows 10",/(Windows NT 10.0)/],["Windows ME",/Windows ME/],["Windows CE",/Windows CE|WinCE|Microsoft Pocket Internet Explorer/],["Open BSD",/OpenBSD/],["Sun OS",/SunOS/],["Chrome OS",/CrOS/],["Linux",/(Linux)|(X11)/],["Mac OS",/(Mac_PowerPC)|(Macintosh)/],["QNX",/QNX/],["BeOS",/BeOS/],["OS/2",/OS\/2/]];function vE(i){return i?Af(i):typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"?new fE:typeof navigator<"u"?Af(navigator.userAgent):_E()}function yE(i){return i!==""&&gE.reduce(function(e,r){var s=r[0],o=r[1];if(e)return e;var h=o.exec(i);return!!h&&[s,h]},!1)}function Af(i){var e=yE(i);if(!e)return null;var r=e[0],s=e[1];if(r==="searchbot")return new lE;var o=s[1]&&s[1].split(".").join("_").split("_").slice(0,3);o?o.length<Cf&&(o=Of(Of([],o,!0),bE(Cf-o.length),!0)):o=[];var h=o.join("."),p=mE(i),f=pE.exec(i);return f&&f[1]?new hE(r,h,p,f[1]):new cE(r,h,p)}function mE(i){for(var e=0,r=Pf.length;e<r;e++){var s=Pf[e],o=s[0],h=s[1],p=h.exec(i);if(p)return o}return null}function _E(){var i=typeof hi<"u"&&hi.version;return i?new uE(hi.version.slice(1)):null}function bE(i){for(var e=[],r=0;r<i;r++)e.push("0");return e}var ye={};const Br=zu(tb);var ru={},ws={},Tf;function wE(){if(Tf)return ws;Tf=1,Object.defineProperty(ws,"__esModule",{value:!0}),ws.delay=void 0;function i(e){return new Promise(r=>{setTimeout(()=>{r(!0)},e)})}return ws.delay=i,ws}var fn={},iu={},dn={},Rf;function EE(){return Rf||(Rf=1,Object.defineProperty(dn,"__esModule",{value:!0}),dn.ONE_THOUSAND=dn.ONE_HUNDRED=void 0,dn.ONE_HUNDRED=100,dn.ONE_THOUSAND=1e3),dn}var nu={},Nf;function DE(){return Nf||(Nf=1,function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.ONE_YEAR=i.FOUR_WEEKS=i.THREE_WEEKS=i.TWO_WEEKS=i.ONE_WEEK=i.THIRTY_DAYS=i.SEVEN_DAYS=i.FIVE_DAYS=i.THREE_DAYS=i.ONE_DAY=i.TWENTY_FOUR_HOURS=i.TWELVE_HOURS=i.SIX_HOURS=i.THREE_HOURS=i.ONE_HOUR=i.SIXTY_MINUTES=i.THIRTY_MINUTES=i.TEN_MINUTES=i.FIVE_MINUTES=i.ONE_MINUTE=i.SIXTY_SECONDS=i.THIRTY_SECONDS=i.TEN_SECONDS=i.FIVE_SECONDS=i.ONE_SECOND=void 0,i.ONE_SECOND=1,i.FIVE_SECONDS=5,i.TEN_SECONDS=10,i.THIRTY_SECONDS=30,i.SIXTY_SECONDS=60,i.ONE_MINUTE=i.SIXTY_SECONDS,i.FIVE_MINUTES=i.ONE_MINUTE*5,i.TEN_MINUTES=i.ONE_MINUTE*10,i.THIRTY_MINUTES=i.ONE_MINUTE*30,i.SIXTY_MINUTES=i.ONE_MINUTE*60,i.ONE_HOUR=i.SIXTY_MINUTES,i.THREE_HOURS=i.ONE_HOUR*3,i.SIX_HOURS=i.ONE_HOUR*6,i.TWELVE_HOURS=i.ONE_HOUR*12,i.TWENTY_FOUR_HOURS=i.ONE_HOUR*24,i.ONE_DAY=i.TWENTY_FOUR_HOURS,i.THREE_DAYS=i.ONE_DAY*3,i.FIVE_DAYS=i.ONE_DAY*5,i.SEVEN_DAYS=i.ONE_DAY*7,i.THIRTY_DAYS=i.ONE_DAY*30,i.ONE_WEEK=i.SEVEN_DAYS,i.TWO_WEEKS=i.ONE_WEEK*2,i.THREE_WEEKS=i.ONE_WEEK*3,i.FOUR_WEEKS=i.ONE_WEEK*4,i.ONE_YEAR=i.ONE_DAY*365}(nu)),nu}var $f;function wp(){return $f||($f=1,function(i){Object.defineProperty(i,"__esModule",{value:!0});const e=Br;e.__exportStar(EE(),i),e.__exportStar(DE(),i)}(iu)),iu}var Lf;function SE(){if(Lf)return fn;Lf=1,Object.defineProperty(fn,"__esModule",{value:!0}),fn.fromMiliseconds=fn.toMiliseconds=void 0;const i=wp();function e(s){return s*i.ONE_THOUSAND}fn.toMiliseconds=e;function r(s){return Math.floor(s/i.ONE_THOUSAND)}return fn.fromMiliseconds=r,fn}var Uf;function IE(){return Uf||(Uf=1,function(i){Object.defineProperty(i,"__esModule",{value:!0});const e=Br;e.__exportStar(wE(),i),e.__exportStar(SE(),i)}(ru)),ru}var Bn={},Ff;function xE(){if(Ff)return Bn;Ff=1,Object.defineProperty(Bn,"__esModule",{value:!0}),Bn.Watch=void 0;class i{constructor(){this.timestamps=new Map}start(r){if(this.timestamps.has(r))throw new Error(`Watch already started for label: ${r}`);this.timestamps.set(r,{started:Date.now()})}stop(r){const s=this.get(r);if(typeof s.elapsed<"u")throw new Error(`Watch already stopped for label: ${r}`);const o=Date.now()-s.started;this.timestamps.set(r,{started:s.started,elapsed:o})}get(r){const s=this.timestamps.get(r);if(typeof s>"u")throw new Error(`No timestamp found for label: ${r}`);return s}elapsed(r){const s=this.get(r);return s.elapsed||Date.now()-s.started}}return Bn.Watch=i,Bn.default=i,Bn}var su={},Es={},Mf;function OE(){if(Mf)return Es;Mf=1,Object.defineProperty(Es,"__esModule",{value:!0}),Es.IWatch=void 0;class i{}return Es.IWatch=i,Es}var jf;function CE(){return jf||(jf=1,function(i){Object.defineProperty(i,"__esModule",{value:!0}),Br.__exportStar(OE(),i)}(su)),su}(function(i){Object.defineProperty(i,"__esModule",{value:!0});const e=Br;e.__exportStar(IE(),i),e.__exportStar(xE(),i),e.__exportStar(CE(),i),e.__exportStar(wp(),i)})(ye);var lt={};Object.defineProperty(lt,"__esModule",{value:!0});lt.getLocalStorage=lt.getLocalStorageOrThrow=lt.getCrypto=lt.getCryptoOrThrow=Dp=lt.getLocation=lt.getLocationOrThrow=Gu=lt.getNavigator=lt.getNavigatorOrThrow=Ep=lt.getDocument=lt.getDocumentOrThrow=lt.getFromWindowOrThrow=lt.getFromWindow=void 0;function mn(i){let e;return typeof window<"u"&&typeof window[i]<"u"&&(e=window[i]),e}lt.getFromWindow=mn;function Xn(i){const e=mn(i);if(!e)throw new Error(`${i} is not defined in Window`);return e}lt.getFromWindowOrThrow=Xn;function PE(){return Xn("document")}lt.getDocumentOrThrow=PE;function AE(){return mn("document")}var Ep=lt.getDocument=AE;function TE(){return Xn("navigator")}lt.getNavigatorOrThrow=TE;function RE(){return mn("navigator")}var Gu=lt.getNavigator=RE;function NE(){return Xn("location")}lt.getLocationOrThrow=NE;function $E(){return mn("location")}var Dp=lt.getLocation=$E;function LE(){return Xn("crypto")}lt.getCryptoOrThrow=LE;function UE(){return mn("crypto")}lt.getCrypto=UE;function FE(){return Xn("localStorage")}lt.getLocalStorageOrThrow=FE;function ME(){return mn("localStorage")}lt.getLocalStorage=ME;var Yu={};Object.defineProperty(Yu,"__esModule",{value:!0});var Sp=Yu.getWindowMetadata=void 0;const qf=lt;function jE(){let i,e;try{i=qf.getDocumentOrThrow(),e=qf.getLocationOrThrow()}catch{return null}function r(){const C=i.getElementsByTagName("link"),N=[];for(let P=0;P<C.length;P++){const F=C[P],k=F.getAttribute("rel");if(k&&k.toLowerCase().indexOf("icon")>-1){const K=F.getAttribute("href");if(K)if(K.toLowerCase().indexOf("https:")===-1&&K.toLowerCase().indexOf("http:")===-1&&K.indexOf("//")!==0){let ee=e.protocol+"//"+e.host;if(K.indexOf("/")===0)ee+=K;else{const A=e.pathname.split("/");A.pop();const $=A.join("/");ee+=$+"/"+K}N.push(ee)}else if(K.indexOf("//")===0){const ee=e.protocol+K;N.push(ee)}else N.push(K)}}return N}function s(...C){const N=i.getElementsByTagName("meta");for(let P=0;P<N.length;P++){const F=N[P],k=["itemprop","property","name"].map(K=>F.getAttribute(K)).filter(K=>K?C.includes(K):!1);if(k.length&&k){const K=F.getAttribute("content");if(K)return K}}return""}function o(){let C=s("name","og:site_name","og:title","twitter:title");return C||(C=i.title),C}function h(){return s("description","og:description","twitter:description","keywords")}const p=o(),f=h(),g=e.origin,b=r();return{description:f,url:g,icons:b,name:p}}Sp=Yu.getWindowMetadata=jE;var Fs={},qE=i=>encodeURIComponent(i).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),Ip="%[a-f0-9]{2}",Hf=new RegExp("("+Ip+")|([^%]+?)","gi"),zf=new RegExp("("+Ip+")+","gi");function Nu(i,e){try{return[decodeURIComponent(i.join(""))]}catch{}if(i.length===1)return i;e=e||1;var r=i.slice(0,e),s=i.slice(e);return Array.prototype.concat.call([],Nu(r),Nu(s))}function HE(i){try{return decodeURIComponent(i)}catch{for(var e=i.match(Hf)||[],r=1;r<e.length;r++)i=Nu(e,r).join(""),e=i.match(Hf)||[];return i}}function zE(i){for(var e={"%FE%FF":"��","%FF%FE":"��"},r=zf.exec(i);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var s=HE(r[0]);s!==r[0]&&(e[r[0]]=s)}r=zf.exec(i)}e["%C2"]="�";for(var o=Object.keys(e),h=0;h<o.length;h++){var p=o[h];i=i.replace(new RegExp(p,"g"),e[p])}return i}var BE=function(i){if(typeof i!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof i+"`");try{return i=i.replace(/\+/g," "),decodeURIComponent(i)}catch{return zE(i)}},kE=(i,e)=>{if(!(typeof i=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[i];const r=i.indexOf(e);return r===-1?[i]:[i.slice(0,r),i.slice(r+e.length)]},KE=function(i,e){for(var r={},s=Object.keys(i),o=Array.isArray(e),h=0;h<s.length;h++){var p=s[h],f=i[p];(o?e.indexOf(p)!==-1:e(p,f,i))&&(r[p]=f)}return r};(function(i){const e=qE,r=BE,s=kE,o=KE,h=A=>A==null,p=Symbol("encodeFragmentIdentifier");function f(A){switch(A.arrayFormat){case"index":return $=>(S,I)=>{const _=S.length;return I===void 0||A.skipNull&&I===null||A.skipEmptyString&&I===""?S:I===null?[...S,[E($,A),"[",_,"]"].join("")]:[...S,[E($,A),"[",E(_,A),"]=",E(I,A)].join("")]};case"bracket":return $=>(S,I)=>I===void 0||A.skipNull&&I===null||A.skipEmptyString&&I===""?S:I===null?[...S,[E($,A),"[]"].join("")]:[...S,[E($,A),"[]=",E(I,A)].join("")];case"colon-list-separator":return $=>(S,I)=>I===void 0||A.skipNull&&I===null||A.skipEmptyString&&I===""?S:I===null?[...S,[E($,A),":list="].join("")]:[...S,[E($,A),":list=",E(I,A)].join("")];case"comma":case"separator":case"bracket-separator":{const $=A.arrayFormat==="bracket-separator"?"[]=":"=";return S=>(I,_)=>_===void 0||A.skipNull&&_===null||A.skipEmptyString&&_===""?I:(_=_===null?"":_,I.length===0?[[E(S,A),$,E(_,A)].join("")]:[[I,E(_,A)].join(A.arrayFormatSeparator)])}default:return $=>(S,I)=>I===void 0||A.skipNull&&I===null||A.skipEmptyString&&I===""?S:I===null?[...S,E($,A)]:[...S,[E($,A),"=",E(I,A)].join("")]}}function g(A){let $;switch(A.arrayFormat){case"index":return(S,I,_)=>{if($=/\[(\d*)\]$/.exec(S),S=S.replace(/\[\d*\]$/,""),!$){_[S]=I;return}_[S]===void 0&&(_[S]={}),_[S][$[1]]=I};case"bracket":return(S,I,_)=>{if($=/(\[\])$/.exec(S),S=S.replace(/\[\]$/,""),!$){_[S]=I;return}if(_[S]===void 0){_[S]=[I];return}_[S]=[].concat(_[S],I)};case"colon-list-separator":return(S,I,_)=>{if($=/(:list)$/.exec(S),S=S.replace(/:list$/,""),!$){_[S]=I;return}if(_[S]===void 0){_[S]=[I];return}_[S]=[].concat(_[S],I)};case"comma":case"separator":return(S,I,_)=>{const c=typeof I=="string"&&I.includes(A.arrayFormatSeparator),m=typeof I=="string"&&!c&&C(I,A).includes(A.arrayFormatSeparator);I=m?C(I,A):I;const B=c||m?I.split(A.arrayFormatSeparator).map(z=>C(z,A)):I===null?I:C(I,A);_[S]=B};case"bracket-separator":return(S,I,_)=>{const c=/(\[\])$/.test(S);if(S=S.replace(/\[\]$/,""),!c){_[S]=I&&C(I,A);return}const m=I===null?[]:I.split(A.arrayFormatSeparator).map(B=>C(B,A));if(_[S]===void 0){_[S]=m;return}_[S]=[].concat(_[S],m)};default:return(S,I,_)=>{if(_[S]===void 0){_[S]=I;return}_[S]=[].concat(_[S],I)}}}function b(A){if(typeof A!="string"||A.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function E(A,$){return $.encode?$.strict?e(A):encodeURIComponent(A):A}function C(A,$){return $.decode?r(A):A}function N(A){return Array.isArray(A)?A.sort():typeof A=="object"?N(Object.keys(A)).sort(($,S)=>Number($)-Number(S)).map($=>A[$]):A}function P(A){const $=A.indexOf("#");return $!==-1&&(A=A.slice(0,$)),A}function F(A){let $="";const S=A.indexOf("#");return S!==-1&&($=A.slice(S)),$}function k(A){A=P(A);const $=A.indexOf("?");return $===-1?"":A.slice($+1)}function K(A,$){return $.parseNumbers&&!Number.isNaN(Number(A))&&typeof A=="string"&&A.trim()!==""?A=Number(A):$.parseBooleans&&A!==null&&(A.toLowerCase()==="true"||A.toLowerCase()==="false")&&(A=A.toLowerCase()==="true"),A}function ee(A,$){$=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},$),b($.arrayFormatSeparator);const S=g($),I=Object.create(null);if(typeof A!="string"||(A=A.trim().replace(/^[?#&]/,""),!A))return I;for(const _ of A.split("&")){if(_==="")continue;let[c,m]=s($.decode?_.replace(/\+/g," "):_,"=");m=m===void 0?null:["comma","separator","bracket-separator"].includes($.arrayFormat)?m:C(m,$),S(C(c,$),m,I)}for(const _ of Object.keys(I)){const c=I[_];if(typeof c=="object"&&c!==null)for(const m of Object.keys(c))c[m]=K(c[m],$);else I[_]=K(c,$)}return $.sort===!1?I:($.sort===!0?Object.keys(I).sort():Object.keys(I).sort($.sort)).reduce((_,c)=>{const m=I[c];return m&&typeof m=="object"&&!Array.isArray(m)?_[c]=N(m):_[c]=m,_},Object.create(null))}i.extract=k,i.parse=ee,i.stringify=(A,$)=>{if(!A)return"";$=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},$),b($.arrayFormatSeparator);const S=m=>$.skipNull&&h(A[m])||$.skipEmptyString&&A[m]==="",I=f($),_={};for(const m of Object.keys(A))S(m)||(_[m]=A[m]);const c=Object.keys(_);return $.sort!==!1&&c.sort($.sort),c.map(m=>{const B=A[m];return B===void 0?"":B===null?E(m,$):Array.isArray(B)?B.length===0&&$.arrayFormat==="bracket-separator"?E(m,$)+"[]":B.reduce(I(m),[]).join("&"):E(m,$)+"="+E(B,$)}).filter(m=>m.length>0).join("&")},i.parseUrl=(A,$)=>{$=Object.assign({decode:!0},$);const[S,I]=s(A,"#");return Object.assign({url:S.split("?")[0]||"",query:ee(k(A),$)},$&&$.parseFragmentIdentifier&&I?{fragmentIdentifier:C(I,$)}:{})},i.stringifyUrl=(A,$)=>{$=Object.assign({encode:!0,strict:!0,[p]:!0},$);const S=P(A.url).split("?")[0]||"",I=i.extract(A.url),_=i.parse(I,{sort:!1}),c=Object.assign(_,A.query);let m=i.stringify(c,$);m&&(m=`?${m}`);let B=F(A.url);return A.fragmentIdentifier&&(B=`#${$[p]?E(A.fragmentIdentifier,$):A.fragmentIdentifier}`),`${S}${m}${B}`},i.pick=(A,$,S)=>{S=Object.assign({parseFragmentIdentifier:!0,[p]:!1},S);const{url:I,query:_,fragmentIdentifier:c}=i.parseUrl(A,S);return i.stringifyUrl({url:I,query:o(_,$),fragmentIdentifier:c},S)},i.exclude=(A,$,S)=>{const I=Array.isArray($)?_=>!$.includes(_):(_,c)=>!$(_,c);return i.pick(A,I,S)}})(Fs);const VE={waku:{publish:"waku_publish",batchPublish:"waku_batchPublish",subscribe:"waku_subscribe",batchSubscribe:"waku_batchSubscribe",subscription:"waku_subscription",unsubscribe:"waku_unsubscribe",batchUnsubscribe:"waku_batchUnsubscribe"},irn:{publish:"irn_publish",batchPublish:"irn_batchPublish",subscribe:"irn_subscribe",batchSubscribe:"irn_batchSubscribe",subscription:"irn_subscription",unsubscribe:"irn_unsubscribe",batchUnsubscribe:"irn_batchUnsubscribe"},iridium:{publish:"iridium_publish",batchPublish:"iridium_batchPublish",subscribe:"iridium_subscribe",batchSubscribe:"iridium_batchSubscribe",subscription:"iridium_subscription",unsubscribe:"iridium_unsubscribe",batchUnsubscribe:"iridium_batchUnsubscribe"}},WE=":";function GE(i){const[e,r]=i.split(WE);return{namespace:e,reference:r}}function YE(i,e=[]){const r=[];return Object.keys(i).forEach(s=>{if(e.length&&!e.includes(s))return;const o=i[s];r.push(...o.accounts)}),r}function xp(i,e){return i.includes(":")?[i]:e.chains||[]}const Op="base10",fr="base16",$u="base64pad",Ju="utf8",Cp=0,_n=1,JE=0,Bf=1,Lu=12,Qu=32;function QE(){const i=Vu.generateKeyPair();return{privateKey:dr(i.secretKey,fr),publicKey:dr(i.publicKey,fr)}}function Uu(){const i=Qn.randomBytes(Qu);return dr(i,fr)}function XE(i,e){const r=Vu.sharedKey(Er(i,fr),Er(e,fr),!0),s=new sw(wa.SHA256,r).expand(Qu);return dr(s,fr)}function ZE(i){const e=wa.hash(Er(i,fr));return dr(e,fr)}function Wn(i){const e=wa.hash(Er(i,Ju));return dr(e,fr)}function e3(i){return Er(`${i}`,Op)}function zs(i){return Number(dr(i,Op))}function t3(i){const e=e3(typeof i.type<"u"?i.type:Cp);if(zs(e)===_n&&typeof i.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const r=typeof i.senderPublicKey<"u"?Er(i.senderPublicKey,fr):void 0,s=typeof i.iv<"u"?Er(i.iv,fr):Qn.randomBytes(Lu),o=new ku.ChaCha20Poly1305(Er(i.symKey,fr)).seal(s,Er(i.message,Ju));return i3({type:e,sealed:o,iv:s,senderPublicKey:r})}function r3(i){const e=new ku.ChaCha20Poly1305(Er(i.symKey,fr)),{sealed:r,iv:s}=ha(i.encoded),o=e.open(s,r);if(o===null)throw new Error("Failed to decrypt");return dr(o,Ju)}function i3(i){if(zs(i.type)===_n){if(typeof i.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return dr(Ru([i.type,i.senderPublicKey,i.iv,i.sealed]),$u)}return dr(Ru([i.type,i.iv,i.sealed]),$u)}function ha(i){const e=Er(i,$u),r=e.slice(JE,Bf),s=Bf;if(zs(r)===_n){const f=s+Qu,g=f+Lu,b=e.slice(s,f),E=e.slice(f,g),C=e.slice(g);return{type:r,sealed:C,iv:E,senderPublicKey:b}}const o=s+Lu,h=e.slice(s,o),p=e.slice(o);return{type:r,sealed:p,iv:h}}function n3(i,e){const r=ha(i);return Pp({type:zs(r.type),senderPublicKey:typeof r.senderPublicKey<"u"?dr(r.senderPublicKey,fr):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function Pp(i){const e=(i==null?void 0:i.type)||Cp;if(e===_n){if(typeof(i==null?void 0:i.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(i==null?void 0:i.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:i==null?void 0:i.senderPublicKey,receiverPublicKey:i==null?void 0:i.receiverPublicKey}}function kf(i){return i.type===_n&&typeof i.senderPublicKey=="string"&&typeof i.receiverPublicKey=="string"}var s3=Object.defineProperty,Kf=Object.getOwnPropertySymbols,o3=Object.prototype.hasOwnProperty,a3=Object.prototype.propertyIsEnumerable,Vf=(i,e,r)=>e in i?s3(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,Wf=(i,e)=>{for(var r in e||(e={}))o3.call(e,r)&&Vf(i,r,e[r]);if(Kf)for(var r of Kf(e))a3.call(e,r)&&Vf(i,r,e[r]);return i};const c3="ReactNative",Ar={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},u3="js";function Xu(){return typeof hi<"u"&&typeof hi.versions<"u"&&typeof hi.versions.node<"u"}function Bs(){return!Ep()&&!!Gu()&&navigator.product===c3}function ks(){return!Xu()&&!!Gu()}function Ks(){return Bs()?Ar.reactNative:Xu()?Ar.node:ks()?Ar.browser:Ar.unknown}function h3(i,e){let r=Fs.parse(i);return r=Wf(Wf({},r),e),i=Fs.stringify(r),i}function l3(){return Sp()||{name:"",description:"",url:"",icons:[""]}}function f3(){if(Ks()===Ar.reactNative&&typeof Et<"u"&&typeof(Et==null?void 0:Et.Platform)<"u"){const{OS:r,Version:s}=Et.Platform;return[r,s].join("-")}const i=vE();if(i===null)return"unknown";const e=i.os?i.os.replace(" ","").toLowerCase():"unknown";return i.type==="browser"?[e,i.name,i.version].join("-"):[e,i.version].join("-")}function d3(){var i;const e=Ks();return e===Ar.browser?[e,((i=Dp())==null?void 0:i.host)||"unknown"].join(":"):e}function p3(i,e,r){const s=f3(),o=d3();return[[i,e].join("-"),[u3,r].join("-"),s,o].join("/")}function g3({protocol:i,version:e,relayUrl:r,sdkVersion:s,auth:o,projectId:h,useOnCloseEvent:p}){const f=r.split("?"),g=p3(i,e,s),b={auth:o,ua:g,projectId:h,useOnCloseEvent:p||void 0},E=h3(f[1]||"",b);return f[0]+"?"+E}function vn(i,e){return i.filter(r=>e.includes(r)).length===i.length}function Ap(i){return Object.fromEntries(i.entries())}function Tp(i){return new Map(Object.entries(i))}function kn(i=ye.FIVE_MINUTES,e){const r=ye.toMiliseconds(i||ye.FIVE_MINUTES);let s,o,h;return{resolve:p=>{h&&s&&(clearTimeout(h),s(p))},reject:p=>{h&&o&&(clearTimeout(h),o(p))},done:()=>new Promise((p,f)=>{h=setTimeout(()=>{f(new Error(e))},r),s=p,o=f})}}function Ms(i,e,r){return new Promise(async(s,o)=>{const h=setTimeout(()=>o(new Error(r)),e);try{const p=await i;s(p)}catch(p){o(p)}clearTimeout(h)})}function Rp(i,e){if(typeof e=="string"&&e.startsWith(`${i}:`))return e;if(i.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(i.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${i}`)}function v3(i){return Rp("topic",i)}function y3(i){return Rp("id",i)}function Np(i){const[e,r]=i.split(":"),s={id:void 0,topic:void 0};if(e==="topic"&&typeof r=="string")s.topic=r;else if(e==="id"&&Number.isInteger(Number(r)))s.id=Number(r);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${r}`);return s}function Qr(i,e){return ye.fromMiliseconds((e||Date.now())+ye.toMiliseconds(i))}function Bi(i){return Date.now()>=ye.toMiliseconds(i)}function zt(i,e){return`${i}${e?`:${e}`:""}`}function ou(i=[],e=[]){return[...new Set([...i,...e])]}async function m3({id:i,topic:e,wcDeepLink:r}){try{if(!r)return;const s=typeof r=="string"?JSON.parse(r):r;let o=s==null?void 0:s.href;if(typeof o!="string")return;o.endsWith("/")&&(o=o.slice(0,-1));const h=`${o}/wc?requestId=${i}&sessionTopic=${e}`,p=Ks();p===Ar.browser?h.startsWith("https://")?window.open(h,"_blank","noreferrer noopener"):window.open(h,"_self","noreferrer noopener"):p===Ar.reactNative&&typeof(Et==null?void 0:Et.Linking)<"u"&&await Et.Linking.openURL(h)}catch(s){console.error(s)}}const _3="irn";function Fu(i){return(i==null?void 0:i.relay)||{protocol:_3}}function oa(i){const e=VE[i];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${i}`);return e}var b3=Object.defineProperty,Gf=Object.getOwnPropertySymbols,w3=Object.prototype.hasOwnProperty,E3=Object.prototype.propertyIsEnumerable,Yf=(i,e,r)=>e in i?b3(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,D3=(i,e)=>{for(var r in e||(e={}))w3.call(e,r)&&Yf(i,r,e[r]);if(Gf)for(var r of Gf(e))E3.call(e,r)&&Yf(i,r,e[r]);return i};function S3(i,e="-"){const r={},s="relay"+e;return Object.keys(i).forEach(o=>{if(o.startsWith(s)){const h=o.replace(s,""),p=i[o];r[h]=p}}),r}function I3(i){i=i.includes("wc://")?i.replace("wc://",""):i,i=i.includes("wc:")?i.replace("wc:",""):i;const e=i.indexOf(":"),r=i.indexOf("?")!==-1?i.indexOf("?"):void 0,s=i.substring(0,e),o=i.substring(e+1,r).split("@"),h=typeof r<"u"?i.substring(r):"",p=Fs.parse(h);return{protocol:s,topic:x3(o[0]),version:parseInt(o[1],10),symKey:p.symKey,relay:S3(p)}}function x3(i){return i.startsWith("//")?i.substring(2):i}function O3(i,e="-"){const r="relay",s={};return Object.keys(i).forEach(o=>{const h=r+e+o;i[o]&&(s[h]=i[o])}),s}function C3(i){return`${i.protocol}:${i.topic}@${i.version}?`+Fs.stringify(D3({symKey:i.symKey},O3(i.relay)))}function Zn(i){const e=[];return i.forEach(r=>{const[s,o]=r.split(":");e.push(`${s}:${o}`)}),e}function P3(i){const e=[];return Object.values(i).forEach(r=>{e.push(...Zn(r.accounts))}),e}function A3(i,e){const r=[];return Object.values(i).forEach(s=>{Zn(s.accounts).includes(e)&&r.push(...s.methods)}),r}function T3(i,e){const r=[];return Object.values(i).forEach(s=>{Zn(s.accounts).includes(e)&&r.push(...s.events)}),r}function R3(i,e){const r=aa(i,e);if(r)throw new Error(r.message);const s={};for(const[o,h]of Object.entries(i))s[o]={methods:h.methods,events:h.events,chains:h.accounts.map(p=>`${p.split(":")[0]}:${p.split(":")[1]}`)};return s}function Zu(i){return i.includes(":")}function Ns(i){return Zu(i)?i.split(":")[0]:i}const N3={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}},$3={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 he(i,e){const{message:r,code:s}=$3[i];return{message:e?`${r} ${e}`:r,code:s}}function $t(i,e){const{message:r,code:s}=N3[i];return{message:e?`${r} ${e}`:r,code:s}}function li(i,e){return Array.isArray(i)?typeof e<"u"&&i.length?i.every(e):!0:!1}function Gn(i){return Object.getPrototypeOf(i)===Object.prototype&&Object.keys(i).length}function lr(i){return typeof i>"u"}function Gt(i,e){return e&&lr(i)?!0:typeof i=="string"&&!!i.trim().length}function eh(i,e){return e&&lr(i)?!0:typeof i=="number"&&!isNaN(i)}function L3(i,e){const{requiredNamespaces:r}=e,s=Object.keys(i.namespaces),o=Object.keys(r);let h=!0;return vn(o,s)?(s.forEach(p=>{const{accounts:f,methods:g,events:b}=i.namespaces[p],E=Zn(f),C=r[p];(!vn(xp(p,C),E)||!vn(C.methods,g)||!vn(C.events,b))&&(h=!1)}),h):!1}function la(i){return Gt(i,!1)&&i.includes(":")?i.split(":").length===2:!1}function U3(i){if(Gt(i,!1)&&i.includes(":")){const e=i.split(":");if(e.length===3){const r=e[0]+":"+e[1];return!!e[2]&&la(r)}}return!1}function F3(i){if(Gt(i,!1))try{return typeof new URL(i)<"u"}catch{return!1}return!1}function M3(i){var e;return(e=i==null?void 0:i.proposer)==null?void 0:e.publicKey}function j3(i){return i==null?void 0:i.topic}function q3(i,e){let r=null;return Gt(i==null?void 0:i.publicKey,!1)||(r=he("MISSING_OR_INVALID",`${e} controller public key should be a string`)),r}function Jf(i){let e=!0;return li(i)?i.length&&(e=i.every(r=>Gt(r,!1))):e=!1,e}function H3(i,e,r){let s=null;return li(e)&&e.length?e.forEach(o=>{s||la(o)||(s=$t("UNSUPPORTED_CHAINS",`${r}, chain ${o} should be a string and conform to "namespace:chainId" format`))}):la(i)||(s=$t("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"] }`)),s}function z3(i,e,r){let s=null;return Object.entries(i).forEach(([o,h])=>{if(s)return;const p=H3(o,xp(o,h),`${e} ${r}`);p&&(s=p)}),s}function B3(i,e){let r=null;return li(i)?i.forEach(s=>{r||U3(s)||(r=$t("UNSUPPORTED_ACCOUNTS",`${e}, account ${s} should be a string and conform to "namespace:chainId:address" format`))}):r=$t("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),r}function k3(i,e){let r=null;return Object.values(i).forEach(s=>{if(r)return;const o=B3(s==null?void 0:s.accounts,`${e} namespace`);o&&(r=o)}),r}function K3(i,e){let r=null;return Jf(i==null?void 0:i.methods)?Jf(i==null?void 0:i.events)||(r=$t("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):r=$t("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),r}function $p(i,e){let r=null;return Object.values(i).forEach(s=>{if(r)return;const o=K3(s,`${e}, namespace`);o&&(r=o)}),r}function V3(i,e,r){let s=null;if(i&&Gn(i)){const o=$p(i,e);o&&(s=o);const h=z3(i,e,r);h&&(s=h)}else s=he("MISSING_OR_INVALID",`${e}, ${r} should be an object with data`);return s}function aa(i,e){let r=null;if(i&&Gn(i)){const s=$p(i,e);s&&(r=s);const o=k3(i,e);o&&(r=o)}else r=he("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return r}function Lp(i){return Gt(i.protocol,!0)}function W3(i,e){let r=!1;return e&&!i?r=!0:i&&li(i)&&i.length&&i.forEach(s=>{r=Lp(s)}),r}function G3(i){return typeof i=="number"}function wr(i){return typeof i<"u"&&typeof i!==null}function Y3(i){return!(!i||typeof i!="object"||!i.code||!eh(i.code,!1)||!i.message||!Gt(i.message,!1))}function J3(i){return!(lr(i)||!Gt(i.method,!1))}function Q3(i){return!(lr(i)||lr(i.result)&&lr(i.error)||!eh(i.id,!1)||!Gt(i.jsonrpc,!1))}function X3(i){return!(lr(i)||!Gt(i.name,!1))}function Qf(i,e){return!(!la(e)||!P3(i).includes(e))}function Z3(i,e,r){return Gt(r,!1)?A3(i,e).includes(r):!1}function e6(i,e,r){return Gt(r,!1)?T3(i,e).includes(r):!1}function Xf(i,e,r){let s=null;const o=t6(i),h=r6(e),p=Object.keys(o),f=Object.keys(h),g=Zf(Object.keys(i)),b=Zf(Object.keys(e)),E=g.filter(C=>!b.includes(C));return E.length&&(s=he("NON_CONFORMING_NAMESPACES",`${r} namespaces keys don't satisfy requiredNamespaces.
|
|
2
|
+
Required: ${E.toString()}
|
|
3
|
+
Received: ${Object.keys(e).toString()}`)),vn(p,f)||(s=he("NON_CONFORMING_NAMESPACES",`${r} namespaces chains don't satisfy required namespaces.
|
|
4
|
+
Required: ${p.toString()}
|
|
5
|
+
Approved: ${f.toString()}`)),Object.keys(e).forEach(C=>{if(!C.includes(":")||s)return;const N=Zn(e[C].accounts);N.includes(C)||(s=he("NON_CONFORMING_NAMESPACES",`${r} namespaces accounts don't satisfy namespace accounts for ${C}
|
|
6
|
+
Required: ${C}
|
|
7
|
+
Approved: ${N.toString()}`))}),p.forEach(C=>{s||(vn(o[C].methods,h[C].methods)?vn(o[C].events,h[C].events)||(s=he("NON_CONFORMING_NAMESPACES",`${r} namespaces events don't satisfy namespace events for ${C}`)):s=he("NON_CONFORMING_NAMESPACES",`${r} namespaces methods don't satisfy namespace methods for ${C}`))}),s}function t6(i){const e={};return Object.keys(i).forEach(r=>{var s;r.includes(":")?e[r]=i[r]:(s=i[r].chains)==null||s.forEach(o=>{e[o]={methods:i[r].methods,events:i[r].events}})}),e}function Zf(i){return[...new Set(i.map(e=>e.includes(":")?e.split(":")[0]:e))]}function r6(i){const e={};return Object.keys(i).forEach(r=>{if(r.includes(":"))e[r]=i[r];else{const s=Zn(i[r].accounts);s==null||s.forEach(o=>{e[o]={accounts:i[r].accounts.filter(h=>h.includes(`${o}:`)),methods:i[r].methods,events:i[r].events}})}}),e}function i6(i,e){return eh(i,!1)&&i<=e.max&&i>=e.min}function ed(){const i=Ks();return new Promise(e=>{switch(i){case Ar.browser:e(n6());break;case Ar.reactNative:e(s6());break;case Ar.node:e(o6());break;default:e(!0)}})}function n6(){return ks()&&(navigator==null?void 0:navigator.onLine)}async function s6(){if(Bs()&&typeof Et<"u"&&Et!=null&&Et.NetInfo){const i=await(Et==null?void 0:Et.NetInfo.fetch());return i==null?void 0:i.isConnected}return!0}function o6(){return!0}function a6(i){switch(Ks()){case Ar.browser:c6(i);break;case Ar.reactNative:u6(i);break}}function c6(i){!Bs()&&ks()&&(window.addEventListener("online",()=>i(!0)),window.addEventListener("offline",()=>i(!1)))}function u6(i){var e;Bs()&&typeof Et<"u"&&Et!=null&&Et.NetInfo&&((e=Et)==null||e.NetInfo.addEventListener(r=>i(r==null?void 0:r.isConnected)))}const au={};let ra=class{static get(e){return au[e]}static set(e,r){au[e]=r}static delete(e){delete au[e]}};var Da={},Vs={};Object.defineProperty(Vs,"__esModule",{value:!0});function h6(i){if(typeof i!="string")throw new Error(`Cannot safe json parse value of type ${typeof i}`);try{return JSON.parse(i)}catch{return i}}Vs.safeJsonParse=h6;function l6(i){return typeof i=="string"?i:JSON.stringify(i,(e,r)=>typeof r>"u"?null:r)}Vs.safeJsonStringify=l6;var Ds={exports:{}},td;function f6(){return td||(td=1,function(){let i;function e(){}i=e,i.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},i.prototype.setItem=function(r,s){this[r]=String(s)},i.prototype.removeItem=function(r){delete this[r]},i.prototype.clear=function(){const r=this;Object.keys(r).forEach(function(s){r[s]=void 0,delete r[s]})},i.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},i.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Pr<"u"&&Pr.localStorage?Ds.exports=Pr.localStorage:typeof window<"u"&&window.localStorage?Ds.exports=window.localStorage:Ds.exports=new e}()),Ds.exports}var cu={},Ss={},rd;function d6(){if(rd)return Ss;rd=1,Object.defineProperty(Ss,"__esModule",{value:!0}),Ss.IKeyValueStorage=void 0;class i{}return Ss.IKeyValueStorage=i,Ss}var Is={},id;function p6(){if(id)return Is;id=1,Object.defineProperty(Is,"__esModule",{value:!0}),Is.parseEntry=void 0;const i=Vs;function e(r){var s;return[r[0],i.safeJsonParse((s=r[1])!==null&&s!==void 0?s:"")]}return Is.parseEntry=e,Is}var nd;function g6(){return nd||(nd=1,function(i){Object.defineProperty(i,"__esModule",{value:!0});const e=Br;e.__exportStar(d6(),i),e.__exportStar(p6(),i)}(cu)),cu}Object.defineProperty(Da,"__esModule",{value:!0});Da.KeyValueStorage=void 0;const Kn=Br,sd=Vs,v6=Kn.__importDefault(f6()),y6=g6();class Up{constructor(){this.localStorage=v6.default}getKeys(){return Kn.__awaiter(this,void 0,void 0,function*(){return Object.keys(this.localStorage)})}getEntries(){return Kn.__awaiter(this,void 0,void 0,function*(){return Object.entries(this.localStorage).map(y6.parseEntry)})}getItem(e){return Kn.__awaiter(this,void 0,void 0,function*(){const r=this.localStorage.getItem(e);if(r!==null)return sd.safeJsonParse(r)})}setItem(e,r){return Kn.__awaiter(this,void 0,void 0,function*(){this.localStorage.setItem(e,sd.safeJsonStringify(r))})}removeItem(e){return Kn.__awaiter(this,void 0,void 0,function*(){this.localStorage.removeItem(e)})}}Da.KeyValueStorage=Up;var m6=Da.default=Up,es={},xs={},uu={},Os={};let bn=class{};const _6=Object.freeze(Object.defineProperty({__proto__:null,IEvents:bn},Symbol.toStringTag,{value:"Module"})),b6=zu(_6);var od;function w6(){if(od)return Os;od=1,Object.defineProperty(Os,"__esModule",{value:!0}),Os.IHeartBeat=void 0;const i=b6;class e extends i.IEvents{constructor(s){super()}}return Os.IHeartBeat=e,Os}var ad;function Fp(){return ad||(ad=1,function(i){Object.defineProperty(i,"__esModule",{value:!0}),Br.__exportStar(w6(),i)}(uu)),uu}var hu={},pn={},cd;function E6(){if(cd)return pn;cd=1,Object.defineProperty(pn,"__esModule",{value:!0}),pn.HEARTBEAT_EVENTS=pn.HEARTBEAT_INTERVAL=void 0;const i=ye;return pn.HEARTBEAT_INTERVAL=i.FIVE_SECONDS,pn.HEARTBEAT_EVENTS={pulse:"heartbeat_pulse"},pn}var ud;function Mp(){return ud||(ud=1,function(i){Object.defineProperty(i,"__esModule",{value:!0}),Br.__exportStar(E6(),i)}(hu)),hu}var hd;function D6(){if(hd)return xs;hd=1,Object.defineProperty(xs,"__esModule",{value:!0}),xs.HeartBeat=void 0;const i=Br,e=zr,r=ye,s=Fp(),o=Mp();class h extends s.IHeartBeat{constructor(f){super(f),this.events=new e.EventEmitter,this.interval=o.HEARTBEAT_INTERVAL,this.interval=(f==null?void 0:f.interval)||o.HEARTBEAT_INTERVAL}static init(f){return i.__awaiter(this,void 0,void 0,function*(){const g=new h(f);return yield g.init(),g})}init(){return i.__awaiter(this,void 0,void 0,function*(){yield this.initialize()})}stop(){clearInterval(this.intervalRef)}on(f,g){this.events.on(f,g)}once(f,g){this.events.once(f,g)}off(f,g){this.events.off(f,g)}removeListener(f,g){this.events.removeListener(f,g)}initialize(){return i.__awaiter(this,void 0,void 0,function*(){this.intervalRef=setInterval(()=>this.pulse(),r.toMiliseconds(this.interval))})}pulse(){this.events.emit(o.HEARTBEAT_EVENTS.pulse)}}return xs.HeartBeat=h,xs}(function(i){Object.defineProperty(i,"__esModule",{value:!0});const e=Br;e.__exportStar(D6(),i),e.__exportStar(Fp(),i),e.__exportStar(Mp(),i)})(es);var Ze={},lu,ld;function S6(){if(ld)return lu;ld=1;function i(r){try{return JSON.stringify(r)}catch{return'"[Circular]"'}}lu=e;function e(r,s,o){var h=o&&o.stringify||i,p=1;if(typeof r=="object"&&r!==null){var f=s.length+p;if(f===1)return r;var g=new Array(f);g[0]=h(r);for(var b=1;b<f;b++)g[b]=h(s[b]);return g.join(" ")}if(typeof r!="string")return r;var E=s.length;if(E===0)return r;for(var C="",N=1-p,P=-1,F=r&&r.length||0,k=0;k<F;){if(r.charCodeAt(k)===37&&k+1<F){switch(P=P>-1?P:0,r.charCodeAt(k+1)){case 100:case 102:if(N>=E||s[N]==null)break;P<k&&(C+=r.slice(P,k)),C+=Number(s[N]),P=k+2,k++;break;case 105:if(N>=E||s[N]==null)break;P<k&&(C+=r.slice(P,k)),C+=Math.floor(Number(s[N])),P=k+2,k++;break;case 79:case 111:case 106:if(N>=E||s[N]===void 0)break;P<k&&(C+=r.slice(P,k));var K=typeof s[N];if(K==="string"){C+="'"+s[N]+"'",P=k+2,k++;break}if(K==="function"){C+=s[N].name||"<anonymous>",P=k+2,k++;break}C+=h(s[N]),P=k+2,k++;break;case 115:if(N>=E)break;P<k&&(C+=r.slice(P,k)),C+=String(s[N]),P=k+2,k++;break;case 37:P<k&&(C+=r.slice(P,k)),C+="%",P=k+2,k++,N--;break}++N}++k}return P===-1?r:(P<F&&(C+=r.slice(P)),C)}return lu}var fu,fd;function I6(){if(fd)return fu;fd=1;const i=S6();fu=o;const e=I().console||{},r={mapHttpRequest:F,mapHttpResponse:F,wrapRequestSerializer:k,wrapResponseSerializer:k,wrapErrorSerializer:k,req:F,res:F,err:N};function s(_,c){return Array.isArray(_)?_.filter(function(B){return B!=="!stdSerializers.err"}):_===!0?Object.keys(c):!1}function o(_){_=_||{},_.browser=_.browser||{};const c=_.browser.transmit;if(c&&typeof c.send!="function")throw Error("pino: transmit option must have a send function");const m=_.browser.write||e;_.browser.write&&(_.browser.asObject=!0);const B=_.serializers||{},z=s(_.browser.serialize,B);let W=_.browser.serialize;Array.isArray(_.browser.serialize)&&_.browser.serialize.indexOf("!stdSerializers.err")>-1&&(W=!1);const oe=["error","fatal","warn","info","debug","trace"];typeof m=="function"&&(m.error=m.fatal=m.warn=m.info=m.debug=m.trace=m),_.enabled===!1&&(_.level="silent");const fe=_.level||"info",T=Object.create(m);T.log||(T.log=K),Object.defineProperty(T,"levelVal",{get:ce}),Object.defineProperty(T,"level",{get:ie,set:Y});const H={transmit:c,serialize:z,asObject:_.browser.asObject,levels:oe,timestamp:P(_)};T.levels=o.levels,T.level=fe,T.setMaxListeners=T.getMaxListeners=T.emit=T.addListener=T.on=T.prependListener=T.once=T.prependOnceListener=T.removeListener=T.removeAllListeners=T.listeners=T.listenerCount=T.eventNames=T.write=T.flush=K,T.serializers=B,T._serialize=z,T._stdErrSerialize=W,T.child=re,c&&(T._logEvent=C());function ce(){return this.level==="silent"?1/0:this.levels.values[this.level]}function ie(){return this._level}function Y(J){if(J!=="silent"&&!this.levels.values[J])throw Error("unknown level "+J);this._level=J,h(H,T,"error","log"),h(H,T,"fatal","error"),h(H,T,"warn","error"),h(H,T,"info","log"),h(H,T,"debug","log"),h(H,T,"trace","log")}function re(J,ne){if(!J)throw new Error("missing bindings for child Pino");ne=ne||{},z&&J.serializers&&(ne.serializers=J.serializers);const xe=ne.serializers;if(z&&xe){var se=Object.assign({},B,xe),be=_.browser.serialize===!0?Object.keys(se):z;delete J.serializers,g([J],be,se,this._stdErrSerialize)}function le(me){this._childLevel=(me._childLevel|0)+1,this.error=b(me,J,"error"),this.fatal=b(me,J,"fatal"),this.warn=b(me,J,"warn"),this.info=b(me,J,"info"),this.debug=b(me,J,"debug"),this.trace=b(me,J,"trace"),se&&(this.serializers=se,this._serialize=be),c&&(this._logEvent=C([].concat(me._logEvent.bindings,J)))}return le.prototype=this,new le(this)}return T}o.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"}},o.stdSerializers=r,o.stdTimeFunctions=Object.assign({},{nullTime:ee,epochTime:A,unixTime:$,isoTime:S});function h(_,c,m,B){const z=Object.getPrototypeOf(c);c[m]=c.levelVal>c.levels.values[m]?K:z[m]?z[m]:e[m]||e[B]||K,p(_,c,m)}function p(_,c,m){!_.transmit&&c[m]===K||(c[m]=function(B){return function(){const W=_.timestamp(),oe=new Array(arguments.length),fe=Object.getPrototypeOf&&Object.getPrototypeOf(this)===e?e:this;for(var T=0;T<oe.length;T++)oe[T]=arguments[T];if(_.serialize&&!_.asObject&&g(oe,this._serialize,this.serializers,this._stdErrSerialize),_.asObject?B.call(fe,f(this,m,oe,W)):B.apply(fe,oe),_.transmit){const H=_.transmit.level||c.level,ce=o.levels.values[H],ie=o.levels.values[m];if(ie<ce)return;E(this,{ts:W,methodLevel:m,methodValue:ie,transmitLevel:H,transmitValue:o.levels.values[_.transmit.level||c.level],send:_.transmit.send,val:c.levelVal},oe)}}}(c[m]))}function f(_,c,m,B){_._serialize&&g(m,_._serialize,_.serializers,_._stdErrSerialize);const z=m.slice();let W=z[0];const oe={};B&&(oe.time=B),oe.level=o.levels.values[c];let fe=(_._childLevel|0)+1;if(fe<1&&(fe=1),W!==null&&typeof W=="object"){for(;fe--&&typeof z[0]=="object";)Object.assign(oe,z.shift());W=z.length?i(z.shift(),z):void 0}else typeof W=="string"&&(W=i(z.shift(),z));return W!==void 0&&(oe.msg=W),oe}function g(_,c,m,B){for(const z in _)if(B&&_[z]instanceof Error)_[z]=o.stdSerializers.err(_[z]);else if(typeof _[z]=="object"&&!Array.isArray(_[z]))for(const W in _[z])c&&c.indexOf(W)>-1&&W in m&&(_[z][W]=m[W](_[z][W]))}function b(_,c,m){return function(){const B=new Array(1+arguments.length);B[0]=c;for(var z=1;z<B.length;z++)B[z]=arguments[z-1];return _[m].apply(this,B)}}function E(_,c,m){const B=c.send,z=c.ts,W=c.methodLevel,oe=c.methodValue,fe=c.val,T=_._logEvent.bindings;g(m,_._serialize||Object.keys(_.serializers),_.serializers,_._stdErrSerialize===void 0?!0:_._stdErrSerialize),_._logEvent.ts=z,_._logEvent.messages=m.filter(function(H){return T.indexOf(H)===-1}),_._logEvent.level.label=W,_._logEvent.level.value=oe,B(W,_._logEvent,fe),_._logEvent=C(T)}function C(_){return{ts:0,messages:[],bindings:_||[],level:{label:"",value:0}}}function N(_){const c={type:_.constructor.name,msg:_.message,stack:_.stack};for(const m in _)c[m]===void 0&&(c[m]=_[m]);return c}function P(_){return typeof _.timestamp=="function"?_.timestamp:_.timestamp===!1?ee:A}function F(){return{}}function k(_){return _}function K(){}function ee(){return!1}function A(){return Date.now()}function $(){return Math.round(Date.now()/1e3)}function S(){return new Date(Date.now()).toISOString()}function I(){function _(c){return typeof c<"u"&&c}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 _(self)||_(window)||_(this)||{}}}return fu}var gn={},dd;function jp(){return dd||(dd=1,Object.defineProperty(gn,"__esModule",{value:!0}),gn.PINO_CUSTOM_CONTEXT_KEY=gn.PINO_LOGGER_DEFAULTS=void 0,gn.PINO_LOGGER_DEFAULTS={level:"info"},gn.PINO_CUSTOM_CONTEXT_KEY="custom_context"),gn}var hr={},pd;function x6(){if(pd)return hr;pd=1,Object.defineProperty(hr,"__esModule",{value:!0}),hr.generateChildLogger=hr.formatChildLoggerContext=hr.getLoggerContext=hr.setBrowserLoggerContext=hr.getBrowserLoggerContext=hr.getDefaultLoggerOptions=void 0;const i=jp();function e(f){return Object.assign(Object.assign({},f),{level:(f==null?void 0:f.level)||i.PINO_LOGGER_DEFAULTS.level})}hr.getDefaultLoggerOptions=e;function r(f,g=i.PINO_CUSTOM_CONTEXT_KEY){return f[g]||""}hr.getBrowserLoggerContext=r;function s(f,g,b=i.PINO_CUSTOM_CONTEXT_KEY){return f[b]=g,f}hr.setBrowserLoggerContext=s;function o(f,g=i.PINO_CUSTOM_CONTEXT_KEY){let b="";return typeof f.bindings>"u"?b=r(f,g):b=f.bindings().context||"",b}hr.getLoggerContext=o;function h(f,g,b=i.PINO_CUSTOM_CONTEXT_KEY){const E=o(f,b);return E.trim()?`${E}/${g}`:g}hr.formatChildLoggerContext=h;function p(f,g,b=i.PINO_CUSTOM_CONTEXT_KEY){const E=h(f,g,b),C=f.child({context:E});return s(C,E,b)}return hr.generateChildLogger=p,hr}(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.pino=void 0;const e=Br,r=e.__importDefault(I6());Object.defineProperty(i,"pino",{enumerable:!0,get:function(){return r.default}}),e.__exportStar(jp(),i),e.__exportStar(x6(),i)})(Ze);class O6 extends bn{constructor(e){super(),this.opts=e,this.protocol="wc",this.version=2}}class C6 extends bn{constructor(e,r){super(),this.core=e,this.logger=r,this.records=new Map}}class P6{constructor(e,r){this.logger=e,this.core=r}}let A6=class extends bn{constructor(e,r){super(),this.relayer=e,this.logger=r}},T6=class extends bn{constructor(e){super()}},R6=class{constructor(e,r,s,o){this.core=e,this.logger=r,this.name=s}};class N6 extends bn{constructor(e,r){super(),this.relayer=e,this.logger=r}}let $6=class extends bn{constructor(e,r){super(),this.core=e,this.logger=r}},L6=class{constructor(e,r){this.projectId=e,this.logger=r}},U6=class{constructor(e){this.opts=e,this.protocol="wc",this.version=2}},F6=class{constructor(e){this.client=e}};const M6=i=>JSON.stringify(i,(e,r)=>typeof r=="bigint"?r.toString()+"n":r),j6=i=>{const e=/([\[:])?(\d{17,}|(?:[9](?:[1-9]07199254740991|0[1-9]7199254740991|00[8-9]199254740991|007[2-9]99254740991|007199[3-9]54740991|0071992[6-9]4740991|00719925[5-9]740991|007199254[8-9]40991|0071992547[5-9]0991|00719925474[1-9]991|00719925474099[2-9])))([,\}\]])/g,r=i.replace(e,'$1"$2n"$3');return JSON.parse(r,(s,o)=>typeof o=="string"&&o.match(/^\d+n$/)?BigInt(o.substring(0,o.length-1)):o)};function th(i){if(typeof i!="string")throw new Error(`Cannot safe json parse value of type ${typeof i}`);try{return j6(i)}catch{return i}}function js(i){return typeof i=="string"?i:M6(i)||""}var rh={},qp={};(function(i){Object.defineProperty(i,"__esModule",{value:!0});var e=Ue,r=Tr;i.DIGEST_LENGTH=64,i.BLOCK_SIZE=128;var s=function(){function f(){this.digestLength=i.DIGEST_LENGTH,this.blockSize=i.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 f.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},f.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},f.prototype.clean=function(){r.wipe(this._buffer),r.wipe(this._tempHi),r.wipe(this._tempLo),this.reset()},f.prototype.update=function(g,b){if(b===void 0&&(b=g.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var E=0;if(this._bytesHashed+=b,this._bufferLength>0){for(;this._bufferLength<i.BLOCK_SIZE&&b>0;)this._buffer[this._bufferLength++]=g[E++],b--;this._bufferLength===this.blockSize&&(h(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0)}for(b>=this.blockSize&&(E=h(this._tempHi,this._tempLo,this._stateHi,this._stateLo,g,E,b),b%=this.blockSize);b>0;)this._buffer[this._bufferLength++]=g[E++],b--;return this},f.prototype.finish=function(g){if(!this._finished){var b=this._bytesHashed,E=this._bufferLength,C=b/536870912|0,N=b<<3,P=b%128<112?128:256;this._buffer[E]=128;for(var F=E+1;F<P-8;F++)this._buffer[F]=0;e.writeUint32BE(C,this._buffer,P-8),e.writeUint32BE(N,this._buffer,P-4),h(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,P),this._finished=!0}for(var F=0;F<this.digestLength/8;F++)e.writeUint32BE(this._stateHi[F],g,F*8),e.writeUint32BE(this._stateLo[F],g,F*8+4);return this},f.prototype.digest=function(){var g=new Uint8Array(this.digestLength);return this.finish(g),g},f.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}},f.prototype.restoreState=function(g){return this._stateHi.set(g.stateHi),this._stateLo.set(g.stateLo),this._bufferLength=g.bufferLength,g.buffer&&this._buffer.set(g.buffer),this._bytesHashed=g.bytesHashed,this._finished=!1,this},f.prototype.cleanSavedState=function(g){r.wipe(g.stateHi),r.wipe(g.stateLo),g.buffer&&r.wipe(g.buffer),g.bufferLength=0,g.bytesHashed=0},f}();i.SHA512=s;var o=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 h(f,g,b,E,C,N,P){for(var F=b[0],k=b[1],K=b[2],ee=b[3],A=b[4],$=b[5],S=b[6],I=b[7],_=E[0],c=E[1],m=E[2],B=E[3],z=E[4],W=E[5],oe=E[6],fe=E[7],T,H,ce,ie,Y,re,J,ne;P>=128;){for(var xe=0;xe<16;xe++){var se=8*xe+N;f[xe]=e.readUint32BE(C,se),g[xe]=e.readUint32BE(C,se+4)}for(var xe=0;xe<80;xe++){var be=F,le=k,me=K,q=ee,j=A,R=$,l=S,x=I,ae=_,de=c,Se=m,ze=B,Ke=z,Fe=W,pt=oe,gt=fe;if(T=I,H=fe,Y=H&65535,re=H>>>16,J=T&65535,ne=T>>>16,T=(A>>>14|z<<32-14)^(A>>>18|z<<32-18)^(z>>>41-32|A<<32-(41-32)),H=(z>>>14|A<<32-14)^(z>>>18|A<<32-18)^(A>>>41-32|z<<32-(41-32)),Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,T=A&$^~A&S,H=z&W^~z&oe,Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,T=o[xe*2],H=o[xe*2+1],Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,T=f[xe%16],H=g[xe%16],Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,re+=Y>>>16,J+=re>>>16,ne+=J>>>16,ce=J&65535|ne<<16,ie=Y&65535|re<<16,T=ce,H=ie,Y=H&65535,re=H>>>16,J=T&65535,ne=T>>>16,T=(F>>>28|_<<32-28)^(_>>>34-32|F<<32-(34-32))^(_>>>39-32|F<<32-(39-32)),H=(_>>>28|F<<32-28)^(F>>>34-32|_<<32-(34-32))^(F>>>39-32|_<<32-(39-32)),Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,T=F&k^F&K^k&K,H=_&c^_&m^c&m,Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,re+=Y>>>16,J+=re>>>16,ne+=J>>>16,x=J&65535|ne<<16,gt=Y&65535|re<<16,T=q,H=ze,Y=H&65535,re=H>>>16,J=T&65535,ne=T>>>16,T=ce,H=ie,Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,re+=Y>>>16,J+=re>>>16,ne+=J>>>16,q=J&65535|ne<<16,ze=Y&65535|re<<16,k=be,K=le,ee=me,A=q,$=j,S=R,I=l,F=x,c=ae,m=de,B=Se,z=ze,W=Ke,oe=Fe,fe=pt,_=gt,xe%16===15)for(var se=0;se<16;se++)T=f[se],H=g[se],Y=H&65535,re=H>>>16,J=T&65535,ne=T>>>16,T=f[(se+9)%16],H=g[(se+9)%16],Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,ce=f[(se+1)%16],ie=g[(se+1)%16],T=(ce>>>1|ie<<32-1)^(ce>>>8|ie<<32-8)^ce>>>7,H=(ie>>>1|ce<<32-1)^(ie>>>8|ce<<32-8)^(ie>>>7|ce<<32-7),Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,ce=f[(se+14)%16],ie=g[(se+14)%16],T=(ce>>>19|ie<<32-19)^(ie>>>61-32|ce<<32-(61-32))^ce>>>6,H=(ie>>>19|ce<<32-19)^(ce>>>61-32|ie<<32-(61-32))^(ie>>>6|ce<<32-6),Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,re+=Y>>>16,J+=re>>>16,ne+=J>>>16,f[se]=J&65535|ne<<16,g[se]=Y&65535|re<<16}T=F,H=_,Y=H&65535,re=H>>>16,J=T&65535,ne=T>>>16,T=b[0],H=E[0],Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,re+=Y>>>16,J+=re>>>16,ne+=J>>>16,b[0]=F=J&65535|ne<<16,E[0]=_=Y&65535|re<<16,T=k,H=c,Y=H&65535,re=H>>>16,J=T&65535,ne=T>>>16,T=b[1],H=E[1],Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,re+=Y>>>16,J+=re>>>16,ne+=J>>>16,b[1]=k=J&65535|ne<<16,E[1]=c=Y&65535|re<<16,T=K,H=m,Y=H&65535,re=H>>>16,J=T&65535,ne=T>>>16,T=b[2],H=E[2],Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,re+=Y>>>16,J+=re>>>16,ne+=J>>>16,b[2]=K=J&65535|ne<<16,E[2]=m=Y&65535|re<<16,T=ee,H=B,Y=H&65535,re=H>>>16,J=T&65535,ne=T>>>16,T=b[3],H=E[3],Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,re+=Y>>>16,J+=re>>>16,ne+=J>>>16,b[3]=ee=J&65535|ne<<16,E[3]=B=Y&65535|re<<16,T=A,H=z,Y=H&65535,re=H>>>16,J=T&65535,ne=T>>>16,T=b[4],H=E[4],Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,re+=Y>>>16,J+=re>>>16,ne+=J>>>16,b[4]=A=J&65535|ne<<16,E[4]=z=Y&65535|re<<16,T=$,H=W,Y=H&65535,re=H>>>16,J=T&65535,ne=T>>>16,T=b[5],H=E[5],Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,re+=Y>>>16,J+=re>>>16,ne+=J>>>16,b[5]=$=J&65535|ne<<16,E[5]=W=Y&65535|re<<16,T=S,H=oe,Y=H&65535,re=H>>>16,J=T&65535,ne=T>>>16,T=b[6],H=E[6],Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,re+=Y>>>16,J+=re>>>16,ne+=J>>>16,b[6]=S=J&65535|ne<<16,E[6]=oe=Y&65535|re<<16,T=I,H=fe,Y=H&65535,re=H>>>16,J=T&65535,ne=T>>>16,T=b[7],H=E[7],Y+=H&65535,re+=H>>>16,J+=T&65535,ne+=T>>>16,re+=Y>>>16,J+=re>>>16,ne+=J>>>16,b[7]=I=J&65535|ne<<16,E[7]=fe=Y&65535|re<<16,N+=128,P-=128}return N}function p(f){var g=new s;g.update(f);var b=g.digest();return g.clean(),b}i.hash=p})(qp);(function(i){Object.defineProperty(i,"__esModule",{value:!0}),i.convertSecretKeyToX25519=i.convertPublicKeyToX25519=i.verify=i.sign=i.extractPublicKeyFromSecretKey=i.generateKeyPair=i.generateKeyPairFromSeed=i.SEED_LENGTH=i.SECRET_KEY_LENGTH=i.PUBLIC_KEY_LENGTH=i.SIGNATURE_LENGTH=void 0;const e=Qn,r=qp,s=Tr;i.SIGNATURE_LENGTH=64,i.PUBLIC_KEY_LENGTH=32,i.SECRET_KEY_LENGTH=64,i.SEED_LENGTH=32;function o(q){const j=new Float64Array(16);if(q)for(let R=0;R<q.length;R++)j[R]=q[R];return j}const h=new Uint8Array(32);h[0]=9;const p=o(),f=o([1]),g=o([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),b=o([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),E=o([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),C=o([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),N=o([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function P(q,j){for(let R=0;R<16;R++)q[R]=j[R]|0}function F(q){let j=1;for(let R=0;R<16;R++){let l=q[R]+j+65535;j=Math.floor(l/65536),q[R]=l-j*65536}q[0]+=j-1+37*(j-1)}function k(q,j,R){const l=~(R-1);for(let x=0;x<16;x++){const ae=l&(q[x]^j[x]);q[x]^=ae,j[x]^=ae}}function K(q,j){const R=o(),l=o();for(let x=0;x<16;x++)l[x]=j[x];F(l),F(l),F(l);for(let x=0;x<2;x++){R[0]=l[0]-65517;for(let de=1;de<15;de++)R[de]=l[de]-65535-(R[de-1]>>16&1),R[de-1]&=65535;R[15]=l[15]-32767-(R[14]>>16&1);const ae=R[15]>>16&1;R[14]&=65535,k(l,R,1-ae)}for(let x=0;x<16;x++)q[2*x]=l[x]&255,q[2*x+1]=l[x]>>8}function ee(q,j){let R=0;for(let l=0;l<32;l++)R|=q[l]^j[l];return(1&R-1>>>8)-1}function A(q,j){const R=new Uint8Array(32),l=new Uint8Array(32);return K(R,q),K(l,j),ee(R,l)}function $(q){const j=new Uint8Array(32);return K(j,q),j[0]&1}function S(q,j){for(let R=0;R<16;R++)q[R]=j[2*R]+(j[2*R+1]<<8);q[15]&=32767}function I(q,j,R){for(let l=0;l<16;l++)q[l]=j[l]+R[l]}function _(q,j,R){for(let l=0;l<16;l++)q[l]=j[l]-R[l]}function c(q,j,R){let l,x,ae=0,de=0,Se=0,ze=0,Ke=0,Fe=0,pt=0,gt=0,je=0,Ie=0,Ne=0,$e=0,qe=0,Ce=0,Le=0,De=0,Pe=0,Be=0,Oe=0,Ve=0,Ge=0,et=0,tt=0,Je=0,nr=0,pr=0,ei=0,sr=0,fi=0,Ti=0,Yi=0,Dt=R[0],vt=R[1],St=R[2],It=R[3],bt=R[4],yt=R[5],Lt=R[6],Ut=R[7],xt=R[8],Ft=R[9],Ot=R[10],At=R[11],Ct=R[12],ht=R[13],Mt=R[14],jt=R[15];l=j[0],ae+=l*Dt,de+=l*vt,Se+=l*St,ze+=l*It,Ke+=l*bt,Fe+=l*yt,pt+=l*Lt,gt+=l*Ut,je+=l*xt,Ie+=l*Ft,Ne+=l*Ot,$e+=l*At,qe+=l*Ct,Ce+=l*ht,Le+=l*Mt,De+=l*jt,l=j[1],de+=l*Dt,Se+=l*vt,ze+=l*St,Ke+=l*It,Fe+=l*bt,pt+=l*yt,gt+=l*Lt,je+=l*Ut,Ie+=l*xt,Ne+=l*Ft,$e+=l*Ot,qe+=l*At,Ce+=l*Ct,Le+=l*ht,De+=l*Mt,Pe+=l*jt,l=j[2],Se+=l*Dt,ze+=l*vt,Ke+=l*St,Fe+=l*It,pt+=l*bt,gt+=l*yt,je+=l*Lt,Ie+=l*Ut,Ne+=l*xt,$e+=l*Ft,qe+=l*Ot,Ce+=l*At,Le+=l*Ct,De+=l*ht,Pe+=l*Mt,Be+=l*jt,l=j[3],ze+=l*Dt,Ke+=l*vt,Fe+=l*St,pt+=l*It,gt+=l*bt,je+=l*yt,Ie+=l*Lt,Ne+=l*Ut,$e+=l*xt,qe+=l*Ft,Ce+=l*Ot,Le+=l*At,De+=l*Ct,Pe+=l*ht,Be+=l*Mt,Oe+=l*jt,l=j[4],Ke+=l*Dt,Fe+=l*vt,pt+=l*St,gt+=l*It,je+=l*bt,Ie+=l*yt,Ne+=l*Lt,$e+=l*Ut,qe+=l*xt,Ce+=l*Ft,Le+=l*Ot,De+=l*At,Pe+=l*Ct,Be+=l*ht,Oe+=l*Mt,Ve+=l*jt,l=j[5],Fe+=l*Dt,pt+=l*vt,gt+=l*St,je+=l*It,Ie+=l*bt,Ne+=l*yt,$e+=l*Lt,qe+=l*Ut,Ce+=l*xt,Le+=l*Ft,De+=l*Ot,Pe+=l*At,Be+=l*Ct,Oe+=l*ht,Ve+=l*Mt,Ge+=l*jt,l=j[6],pt+=l*Dt,gt+=l*vt,je+=l*St,Ie+=l*It,Ne+=l*bt,$e+=l*yt,qe+=l*Lt,Ce+=l*Ut,Le+=l*xt,De+=l*Ft,Pe+=l*Ot,Be+=l*At,Oe+=l*Ct,Ve+=l*ht,Ge+=l*Mt,et+=l*jt,l=j[7],gt+=l*Dt,je+=l*vt,Ie+=l*St,Ne+=l*It,$e+=l*bt,qe+=l*yt,Ce+=l*Lt,Le+=l*Ut,De+=l*xt,Pe+=l*Ft,Be+=l*Ot,Oe+=l*At,Ve+=l*Ct,Ge+=l*ht,et+=l*Mt,tt+=l*jt,l=j[8],je+=l*Dt,Ie+=l*vt,Ne+=l*St,$e+=l*It,qe+=l*bt,Ce+=l*yt,Le+=l*Lt,De+=l*Ut,Pe+=l*xt,Be+=l*Ft,Oe+=l*Ot,Ve+=l*At,Ge+=l*Ct,et+=l*ht,tt+=l*Mt,Je+=l*jt,l=j[9],Ie+=l*Dt,Ne+=l*vt,$e+=l*St,qe+=l*It,Ce+=l*bt,Le+=l*yt,De+=l*Lt,Pe+=l*Ut,Be+=l*xt,Oe+=l*Ft,Ve+=l*Ot,Ge+=l*At,et+=l*Ct,tt+=l*ht,Je+=l*Mt,nr+=l*jt,l=j[10],Ne+=l*Dt,$e+=l*vt,qe+=l*St,Ce+=l*It,Le+=l*bt,De+=l*yt,Pe+=l*Lt,Be+=l*Ut,Oe+=l*xt,Ve+=l*Ft,Ge+=l*Ot,et+=l*At,tt+=l*Ct,Je+=l*ht,nr+=l*Mt,pr+=l*jt,l=j[11],$e+=l*Dt,qe+=l*vt,Ce+=l*St,Le+=l*It,De+=l*bt,Pe+=l*yt,Be+=l*Lt,Oe+=l*Ut,Ve+=l*xt,Ge+=l*Ft,et+=l*Ot,tt+=l*At,Je+=l*Ct,nr+=l*ht,pr+=l*Mt,ei+=l*jt,l=j[12],qe+=l*Dt,Ce+=l*vt,Le+=l*St,De+=l*It,Pe+=l*bt,Be+=l*yt,Oe+=l*Lt,Ve+=l*Ut,Ge+=l*xt,et+=l*Ft,tt+=l*Ot,Je+=l*At,nr+=l*Ct,pr+=l*ht,ei+=l*Mt,sr+=l*jt,l=j[13],Ce+=l*Dt,Le+=l*vt,De+=l*St,Pe+=l*It,Be+=l*bt,Oe+=l*yt,Ve+=l*Lt,Ge+=l*Ut,et+=l*xt,tt+=l*Ft,Je+=l*Ot,nr+=l*At,pr+=l*Ct,ei+=l*ht,sr+=l*Mt,fi+=l*jt,l=j[14],Le+=l*Dt,De+=l*vt,Pe+=l*St,Be+=l*It,Oe+=l*bt,Ve+=l*yt,Ge+=l*Lt,et+=l*Ut,tt+=l*xt,Je+=l*Ft,nr+=l*Ot,pr+=l*At,ei+=l*Ct,sr+=l*ht,fi+=l*Mt,Ti+=l*jt,l=j[15],De+=l*Dt,Pe+=l*vt,Be+=l*St,Oe+=l*It,Ve+=l*bt,Ge+=l*yt,et+=l*Lt,tt+=l*Ut,Je+=l*xt,nr+=l*Ft,pr+=l*Ot,ei+=l*At,sr+=l*Ct,fi+=l*ht,Ti+=l*Mt,Yi+=l*jt,ae+=38*Pe,de+=38*Be,Se+=38*Oe,ze+=38*Ve,Ke+=38*Ge,Fe+=38*et,pt+=38*tt,gt+=38*Je,je+=38*nr,Ie+=38*pr,Ne+=38*ei,$e+=38*sr,qe+=38*fi,Ce+=38*Ti,Le+=38*Yi,x=1,l=ae+x+65535,x=Math.floor(l/65536),ae=l-x*65536,l=de+x+65535,x=Math.floor(l/65536),de=l-x*65536,l=Se+x+65535,x=Math.floor(l/65536),Se=l-x*65536,l=ze+x+65535,x=Math.floor(l/65536),ze=l-x*65536,l=Ke+x+65535,x=Math.floor(l/65536),Ke=l-x*65536,l=Fe+x+65535,x=Math.floor(l/65536),Fe=l-x*65536,l=pt+x+65535,x=Math.floor(l/65536),pt=l-x*65536,l=gt+x+65535,x=Math.floor(l/65536),gt=l-x*65536,l=je+x+65535,x=Math.floor(l/65536),je=l-x*65536,l=Ie+x+65535,x=Math.floor(l/65536),Ie=l-x*65536,l=Ne+x+65535,x=Math.floor(l/65536),Ne=l-x*65536,l=$e+x+65535,x=Math.floor(l/65536),$e=l-x*65536,l=qe+x+65535,x=Math.floor(l/65536),qe=l-x*65536,l=Ce+x+65535,x=Math.floor(l/65536),Ce=l-x*65536,l=Le+x+65535,x=Math.floor(l/65536),Le=l-x*65536,l=De+x+65535,x=Math.floor(l/65536),De=l-x*65536,ae+=x-1+37*(x-1),x=1,l=ae+x+65535,x=Math.floor(l/65536),ae=l-x*65536,l=de+x+65535,x=Math.floor(l/65536),de=l-x*65536,l=Se+x+65535,x=Math.floor(l/65536),Se=l-x*65536,l=ze+x+65535,x=Math.floor(l/65536),ze=l-x*65536,l=Ke+x+65535,x=Math.floor(l/65536),Ke=l-x*65536,l=Fe+x+65535,x=Math.floor(l/65536),Fe=l-x*65536,l=pt+x+65535,x=Math.floor(l/65536),pt=l-x*65536,l=gt+x+65535,x=Math.floor(l/65536),gt=l-x*65536,l=je+x+65535,x=Math.floor(l/65536),je=l-x*65536,l=Ie+x+65535,x=Math.floor(l/65536),Ie=l-x*65536,l=Ne+x+65535,x=Math.floor(l/65536),Ne=l-x*65536,l=$e+x+65535,x=Math.floor(l/65536),$e=l-x*65536,l=qe+x+65535,x=Math.floor(l/65536),qe=l-x*65536,l=Ce+x+65535,x=Math.floor(l/65536),Ce=l-x*65536,l=Le+x+65535,x=Math.floor(l/65536),Le=l-x*65536,l=De+x+65535,x=Math.floor(l/65536),De=l-x*65536,ae+=x-1+37*(x-1),q[0]=ae,q[1]=de,q[2]=Se,q[3]=ze,q[4]=Ke,q[5]=Fe,q[6]=pt,q[7]=gt,q[8]=je,q[9]=Ie,q[10]=Ne,q[11]=$e,q[12]=qe,q[13]=Ce,q[14]=Le,q[15]=De}function m(q,j){c(q,j,j)}function B(q,j){const R=o();let l;for(l=0;l<16;l++)R[l]=j[l];for(l=253;l>=0;l--)m(R,R),l!==2&&l!==4&&c(R,R,j);for(l=0;l<16;l++)q[l]=R[l]}function z(q,j){const R=o();let l;for(l=0;l<16;l++)R[l]=j[l];for(l=250;l>=0;l--)m(R,R),l!==1&&c(R,R,j);for(l=0;l<16;l++)q[l]=R[l]}function W(q,j){const R=o(),l=o(),x=o(),ae=o(),de=o(),Se=o(),ze=o(),Ke=o(),Fe=o();_(R,q[1],q[0]),_(Fe,j[1],j[0]),c(R,R,Fe),I(l,q[0],q[1]),I(Fe,j[0],j[1]),c(l,l,Fe),c(x,q[3],j[3]),c(x,x,b),c(ae,q[2],j[2]),I(ae,ae,ae),_(de,l,R),_(Se,ae,x),I(ze,ae,x),I(Ke,l,R),c(q[0],de,Se),c(q[1],Ke,ze),c(q[2],ze,Se),c(q[3],de,Ke)}function oe(q,j,R){for(let l=0;l<4;l++)k(q[l],j[l],R)}function fe(q,j){const R=o(),l=o(),x=o();B(x,j[2]),c(R,j[0],x),c(l,j[1],x),K(q,l),q[31]^=$(R)<<7}function T(q,j,R){P(q[0],p),P(q[1],f),P(q[2],f),P(q[3],p);for(let l=255;l>=0;--l){const x=R[l/8|0]>>(l&7)&1;oe(q,j,x),W(j,q),W(q,q),oe(q,j,x)}}function H(q,j){const R=[o(),o(),o(),o()];P(R[0],E),P(R[1],C),P(R[2],f),c(R[3],E,C),T(q,R,j)}function ce(q){if(q.length!==i.SEED_LENGTH)throw new Error(`ed25519: seed must be ${i.SEED_LENGTH} bytes`);const j=(0,r.hash)(q);j[0]&=248,j[31]&=127,j[31]|=64;const R=new Uint8Array(32),l=[o(),o(),o(),o()];H(l,j),fe(R,l);const x=new Uint8Array(64);return x.set(q),x.set(R,32),{publicKey:R,secretKey:x}}i.generateKeyPairFromSeed=ce;function ie(q){const j=(0,e.randomBytes)(32,q),R=ce(j);return(0,s.wipe)(j),R}i.generateKeyPair=ie;function Y(q){if(q.length!==i.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${i.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(q.subarray(32))}i.extractPublicKeyFromSecretKey=Y;const re=new Float64Array([237,211,245,92,26,99,18,88,214,156,247,162,222,249,222,20,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,16]);function J(q,j){let R,l,x,ae;for(l=63;l>=32;--l){for(R=0,x=l-32,ae=l-12;x<ae;++x)j[x]+=R-16*j[l]*re[x-(l-32)],R=Math.floor((j[x]+128)/256),j[x]-=R*256;j[x]+=R,j[l]=0}for(R=0,x=0;x<32;x++)j[x]+=R-(j[31]>>4)*re[x],R=j[x]>>8,j[x]&=255;for(x=0;x<32;x++)j[x]-=R*re[x];for(l=0;l<32;l++)j[l+1]+=j[l]>>8,q[l]=j[l]&255}function ne(q){const j=new Float64Array(64);for(let R=0;R<64;R++)j[R]=q[R];for(let R=0;R<64;R++)q[R]=0;J(q,j)}function xe(q,j){const R=new Float64Array(64),l=[o(),o(),o(),o()],x=(0,r.hash)(q.subarray(0,32));x[0]&=248,x[31]&=127,x[31]|=64;const ae=new Uint8Array(64);ae.set(x.subarray(32),32);const de=new r.SHA512;de.update(ae.subarray(32)),de.update(j);const Se=de.digest();de.clean(),ne(Se),H(l,Se),fe(ae,l),de.reset(),de.update(ae.subarray(0,32)),de.update(q.subarray(32)),de.update(j);const ze=de.digest();ne(ze);for(let Ke=0;Ke<32;Ke++)R[Ke]=Se[Ke];for(let Ke=0;Ke<32;Ke++)for(let Fe=0;Fe<32;Fe++)R[Ke+Fe]+=ze[Ke]*x[Fe];return J(ae.subarray(32),R),ae}i.sign=xe;function se(q,j){const R=o(),l=o(),x=o(),ae=o(),de=o(),Se=o(),ze=o();return P(q[2],f),S(q[1],j),m(x,q[1]),c(ae,x,g),_(x,x,q[2]),I(ae,q[2],ae),m(de,ae),m(Se,de),c(ze,Se,de),c(R,ze,x),c(R,R,ae),z(R,R),c(R,R,x),c(R,R,ae),c(R,R,ae),c(q[0],R,ae),m(l,q[0]),c(l,l,ae),A(l,x)&&c(q[0],q[0],N),m(l,q[0]),c(l,l,ae),A(l,x)?-1:($(q[0])===j[31]>>7&&_(q[0],p,q[0]),c(q[3],q[0],q[1]),0)}function be(q,j,R){const l=new Uint8Array(32),x=[o(),o(),o(),o()],ae=[o(),o(),o(),o()];if(R.length!==i.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${i.SIGNATURE_LENGTH} bytes`);if(se(ae,q))return!1;const de=new r.SHA512;de.update(R.subarray(0,32)),de.update(q),de.update(j);const Se=de.digest();return ne(Se),T(x,ae,Se),H(ae,R.subarray(32)),W(x,ae),fe(l,x),!ee(R,l)}i.verify=be;function le(q){let j=[o(),o(),o(),o()];if(se(j,q))throw new Error("Ed25519: invalid public key");let R=o(),l=o(),x=j[1];I(R,f,x),_(l,f,x),B(l,l),c(R,R,l);let ae=new Uint8Array(32);return K(ae,R),ae}i.convertPublicKeyToX25519=le;function me(q){const j=(0,r.hash)(q.subarray(0,32));j[0]&=248,j[31]&=127,j[31]|=64;const R=new Uint8Array(j.subarray(0,32));return(0,s.wipe)(j),R}i.convertSecretKeyToX25519=me})(rh);const q6="EdDSA",H6="JWT",Hp=".",zp="base64url",z6="utf8",B6="utf8",k6=":",K6="did",V6="key",gd="base58btc",W6="z",G6="K36",Y6=32;function fa(i){return dr(Er(js(i),z6),zp)}function Bp(i){const e=Er(G6,gd),r=W6+dr(Ru([e,i]),gd);return[K6,V6,r].join(k6)}function J6(i){return dr(i,zp)}function Q6(i){return Er([fa(i.header),fa(i.payload)].join(Hp),B6)}function X6(i){return[fa(i.header),fa(i.payload),J6(i.signature)].join(Hp)}function vd(i=Qn.randomBytes(Y6)){return rh.generateKeyPairFromSeed(i)}async function Z6(i,e,r,s,o=ye.fromMiliseconds(Date.now())){const h={alg:q6,typ:H6},p=Bp(s.publicKey),f=o+r,g={iss:p,sub:i,aud:e,iat:o,exp:f},b=Q6({header:h,payload:g}),E=rh.sign(s.secretKey,b);return X6({header:h,payload:g,signature:E})}const eD="PARSE_ERROR",tD="INVALID_REQUEST",rD="METHOD_NOT_FOUND",iD="INVALID_PARAMS",kp="INTERNAL_ERROR",ih="SERVER_ERROR",nD=[-32700,-32600,-32601,-32602,-32603],Us={[eD]:{code:-32700,message:"Parse error"},[tD]:{code:-32600,message:"Invalid Request"},[rD]:{code:-32601,message:"Method not found"},[iD]:{code:-32602,message:"Invalid params"},[kp]:{code:-32603,message:"Internal error"},[ih]:{code:-32e3,message:"Server error"}},Kp=ih;function sD(i){return nD.includes(i)}function yd(i){return Object.keys(Us).includes(i)?Us[i]:Us[Kp]}function oD(i){const e=Object.values(Us).find(r=>r.code===i);return e||Us[Kp]}function Vp(i,e,r){return i.message.includes("getaddrinfo ENOTFOUND")||i.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${e}`):i}var Wp={},Si={},md;function aD(){if(md)return Si;md=1,Object.defineProperty(Si,"__esModule",{value:!0}),Si.isBrowserCryptoAvailable=Si.getSubtleCrypto=Si.getBrowerCrypto=void 0;function i(){return(Pr===null||Pr===void 0?void 0:Pr.crypto)||(Pr===null||Pr===void 0?void 0:Pr.msCrypto)||{}}Si.getBrowerCrypto=i;function e(){const s=i();return s.subtle||s.webkitSubtle}Si.getSubtleCrypto=e;function r(){return!!i()&&!!e()}return Si.isBrowserCryptoAvailable=r,Si}var Ii={},_d;function cD(){if(_d)return Ii;_d=1,Object.defineProperty(Ii,"__esModule",{value:!0}),Ii.isBrowser=Ii.isNode=Ii.isReactNative=void 0;function i(){return typeof document>"u"&&typeof navigator<"u"&&navigator.product==="ReactNative"}Ii.isReactNative=i;function e(){return typeof hi<"u"&&typeof hi.versions<"u"&&typeof hi.versions.node<"u"}Ii.isNode=e;function r(){return!i()&&!e()}return Ii.isBrowser=r,Ii}(function(i){Object.defineProperty(i,"__esModule",{value:!0});const e=Br;e.__exportStar(aD(),i),e.__exportStar(cD(),i)})(Wp);function nh(i=3){const e=Date.now()*Math.pow(10,i),r=Math.floor(Math.random()*Math.pow(10,i));return e+r}function Gp(i=6){return BigInt(nh(i))}function Yn(i,e,r){return{id:r||nh(),jsonrpc:"2.0",method:i,params:e}}function sh(i,e){return{id:i,jsonrpc:"2.0",result:e}}function Sa(i,e,r){return{id:i,jsonrpc:"2.0",error:uD(e,r)}}function uD(i,e){return typeof i>"u"?yd(kp):(typeof i=="string"&&(i=Object.assign(Object.assign({},yd(ih)),{message:i})),typeof e<"u"&&(i.data=e),sD(i.code)&&(i=oD(i.code)),i)}class hD{}class lD extends hD{constructor(){super()}}class fD extends lD{constructor(e){super()}}const dD="^https?:",pD="^wss?:";function gD(i){const e=i.match(new RegExp(/^\w+:/,"gi"));if(!(!e||!e.length))return e[0]}function Yp(i,e){const r=gD(i);return typeof r>"u"?!1:new RegExp(e).test(r)}function bd(i){return Yp(i,dD)}function wd(i){return Yp(i,pD)}function vD(i){return new RegExp("wss?://localhost(:d{2,5})?").test(i)}function Jp(i){return typeof i=="object"&&"id"in i&&"jsonrpc"in i&&i.jsonrpc==="2.0"}function oh(i){return Jp(i)&&"method"in i}function Ia(i){return Jp(i)&&(Ci(i)||Xr(i))}function Ci(i){return"result"in i}function Xr(i){return"error"in i}class Pi extends fD{constructor(e){super(e),this.events=new zr.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async request(e,r){return this.requestStrict(Yn(e.method,e.params||[],e.id||Gp().toString()),r)}async requestStrict(e,r){return new Promise(async(s,o)=>{if(!this.connection.connected)try{await this.open()}catch(h){o(h)}this.events.on(`${e.id}`,h=>{Xr(h)?o(h.error):s(h.result)});try{await this.connection.send(e,r)}catch(h){o(h)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),Ia(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}}var du,Ed;function yD(){return Ed||(Ed=1,du=function(){throw new Error("ws does not work in the browser. Browser clients must use the native WebSocket object")}),du}const mD=()=>typeof WebSocket<"u"?WebSocket:typeof Et<"u"&&typeof Et.WebSocket<"u"?Et.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:yD(),_D=()=>typeof WebSocket<"u"||typeof Et<"u"&&typeof Et.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Dd=i=>i.split("?")[0],Sd=10,bD=mD();class wD{constructor(e){if(this.url=e,this.events=new zr.EventEmitter,this.registering=!1,!wd(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=s=>{this.onClose(s),e()},this.socket.close()})}async send(e,r){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(js(e))}catch(s){this.onError(e.id,s)}}register(e=this.url){if(!wd(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((s,o)=>{this.events.once("register_error",h=>{this.resetMaxListeners(),o(h)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return o(new Error("WebSocket connection is missing or invalid"));s(this.socket)})})}return this.url=e,this.registering=!0,new Promise((r,s)=>{const o=Wp.isReactNative()?void 0:{rejectUnauthorized:!vD(e)},h=new bD(e,[],o);_D()?h.onerror=p=>{const f=p;s(this.emitError(f.error))}:h.on("error",p=>{s(this.emitError(p))}),h.onopen=()=>{this.onOpen(h),r(h)}})}onOpen(e){e.onmessage=r=>this.onPayload(r),e.onclose=r=>this.onClose(r),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?th(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const s=this.parseError(r),o=s.message||s.toString(),h=Sa(e,o);this.events.emit("payload",h)}parseError(e,r=this.url){return Vp(e,Dd(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Sd&&this.events.setMaxListeners(Sd)}emitError(e){const r=this.parseError(new Error((e==null?void 0:e.message)||`WebSocket connection failed for host: ${Dd(this.url)}`));return this.events.emit("register_error",r),r}}var da={exports:{}};da.exports;(function(i,e){var r=200,s="__lodash_hash_undefined__",o=1,h=2,p=9007199254740991,f="[object Arguments]",g="[object Array]",b="[object AsyncFunction]",E="[object Boolean]",C="[object Date]",N="[object Error]",P="[object Function]",F="[object GeneratorFunction]",k="[object Map]",K="[object Number]",ee="[object Null]",A="[object Object]",$="[object Promise]",S="[object Proxy]",I="[object RegExp]",_="[object Set]",c="[object String]",m="[object Symbol]",B="[object Undefined]",z="[object WeakMap]",W="[object ArrayBuffer]",oe="[object DataView]",fe="[object Float32Array]",T="[object Float64Array]",H="[object Int8Array]",ce="[object Int16Array]",ie="[object Int32Array]",Y="[object Uint8Array]",re="[object Uint8ClampedArray]",J="[object Uint16Array]",ne="[object Uint32Array]",xe=/[\\^$.*+?()[\]{}|]/g,se=/^\[object .+?Constructor\]$/,be=/^(?:0|[1-9]\d*)$/,le={};le[fe]=le[T]=le[H]=le[ce]=le[ie]=le[Y]=le[re]=le[J]=le[ne]=!0,le[f]=le[g]=le[W]=le[E]=le[oe]=le[C]=le[N]=le[P]=le[k]=le[K]=le[A]=le[I]=le[_]=le[c]=le[z]=!1;var me=typeof Pr=="object"&&Pr&&Pr.Object===Object&&Pr,q=typeof self=="object"&&self&&self.Object===Object&&self,j=me||q||Function("return this")(),R=e&&!e.nodeType&&e,l=R&&!0&&i&&!i.nodeType&&i,x=l&&l.exports===R,ae=x&&me.process,de=function(){try{return ae&&ae.binding&&ae.binding("util")}catch{}}(),Se=de&&de.isTypedArray;function ze(w,L){for(var Z=-1,pe=w==null?0:w.length,at=0,Te=[];++Z<pe;){var ft=w[Z];L(ft,Z,w)&&(Te[at++]=ft)}return Te}function Ke(w,L){for(var Z=-1,pe=L.length,at=w.length;++Z<pe;)w[at+Z]=L[Z];return w}function Fe(w,L){for(var Z=-1,pe=w==null?0:w.length;++Z<pe;)if(L(w[Z],Z,w))return!0;return!1}function pt(w,L){for(var Z=-1,pe=Array(w);++Z<w;)pe[Z]=L(Z);return pe}function gt(w){return function(L){return w(L)}}function je(w,L){return w.has(L)}function Ie(w,L){return w==null?void 0:w[L]}function Ne(w){var L=-1,Z=Array(w.size);return w.forEach(function(pe,at){Z[++L]=[at,pe]}),Z}function $e(w,L){return function(Z){return w(L(Z))}}function qe(w){var L=-1,Z=Array(w.size);return w.forEach(function(pe){Z[++L]=pe}),Z}var Ce=Array.prototype,Le=Function.prototype,De=Object.prototype,Pe=j["__core-js_shared__"],Be=Le.toString,Oe=De.hasOwnProperty,Ve=function(){var w=/[^.]+$/.exec(Pe&&Pe.keys&&Pe.keys.IE_PROTO||"");return w?"Symbol(src)_1."+w:""}(),Ge=De.toString,et=RegExp("^"+Be.call(Oe).replace(xe,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),tt=x?j.Buffer:void 0,Je=j.Symbol,nr=j.Uint8Array,pr=De.propertyIsEnumerable,ei=Ce.splice,sr=Je?Je.toStringTag:void 0,fi=Object.getOwnPropertySymbols,Ti=tt?tt.isBuffer:void 0,Yi=$e(Object.keys,Object),Dt=Dr(j,"DataView"),vt=Dr(j,"Map"),St=Dr(j,"Promise"),It=Dr(j,"Set"),bt=Dr(j,"WeakMap"),yt=Dr(Object,"create"),Lt=pi(Dt),Ut=pi(vt),xt=pi(St),Ft=pi(It),Ot=pi(bt),At=Je?Je.prototype:void 0,Ct=At?At.valueOf:void 0;function ht(w){var L=-1,Z=w==null?0:w.length;for(this.clear();++L<Z;){var pe=w[L];this.set(pe[0],pe[1])}}function Mt(){this.__data__=yt?yt(null):{},this.size=0}function jt(w){var L=this.has(w)&&delete this.__data__[w];return this.size-=L?1:0,L}function Pa(w){var L=this.__data__;if(yt){var Z=L[w];return Z===s?void 0:Z}return Oe.call(L,w)?L[w]:void 0}function Aa(w){var L=this.__data__;return yt?L[w]!==void 0:Oe.call(L,w)}function Ta(w,L){var Z=this.__data__;return this.size+=this.has(w)?0:1,Z[w]=yt&&L===void 0?s:L,this}ht.prototype.clear=Mt,ht.prototype.delete=jt,ht.prototype.get=Pa,ht.prototype.has=Aa,ht.prototype.set=Ta;function Rr(w){var L=-1,Z=w==null?0:w.length;for(this.clear();++L<Z;){var pe=w[L];this.set(pe[0],pe[1])}}function Ra(){this.__data__=[],this.size=0}function Na(w){var L=this.__data__,Z=Ji(L,w);if(Z<0)return!1;var pe=L.length-1;return Z==pe?L.pop():ei.call(L,Z,1),--this.size,!0}function $a(w){var L=this.__data__,Z=Ji(L,w);return Z<0?void 0:L[Z][1]}function La(w){return Ji(this.__data__,w)>-1}function Ua(w,L){var Z=this.__data__,pe=Ji(Z,w);return pe<0?(++this.size,Z.push([w,L])):Z[pe][1]=L,this}Rr.prototype.clear=Ra,Rr.prototype.delete=Na,Rr.prototype.get=$a,Rr.prototype.has=La,Rr.prototype.set=Ua;function di(w){var L=-1,Z=w==null?0:w.length;for(this.clear();++L<Z;){var pe=w[L];this.set(pe[0],pe[1])}}function En(){this.size=0,this.__data__={hash:new ht,map:new(vt||Rr),string:new ht}}function Fa(w){var L=Ri(this,w).delete(w);return this.size-=L?1:0,L}function Dn(w){return Ri(this,w).get(w)}function Ma(w){return Ri(this,w).has(w)}function ja(w,L){var Z=Ri(this,w),pe=Z.size;return Z.set(w,L),this.size+=Z.size==pe?0:1,this}di.prototype.clear=En,di.prototype.delete=Fa,di.prototype.get=Dn,di.prototype.has=Ma,di.prototype.set=ja;function Sn(w){var L=-1,Z=w==null?0:w.length;for(this.__data__=new di;++L<Z;)this.add(w[L])}function Gs(w){return this.__data__.set(w,s),this}function Ys(w){return this.__data__.has(w)}Sn.prototype.add=Sn.prototype.push=Gs,Sn.prototype.has=Ys;function kr(w){var L=this.__data__=new Rr(w);this.size=L.size}function qa(){this.__data__=new Rr,this.size=0}function Ha(w){var L=this.__data__,Z=L.delete(w);return this.size=L.size,Z}function za(w){return this.__data__.get(w)}function Ba(w){return this.__data__.has(w)}function Js(w,L){var Z=this.__data__;if(Z instanceof Rr){var pe=Z.__data__;if(!vt||pe.length<r-1)return pe.push([w,L]),this.size=++Z.size,this;Z=this.__data__=new di(pe)}return Z.set(w,L),this.size=Z.size,this}kr.prototype.clear=qa,kr.prototype.delete=Ha,kr.prototype.get=za,kr.prototype.has=Ba,kr.prototype.set=Js;function Qs(w,L){var Z=On(w),pe=!Z&&uo(w),at=!Z&&!pe&&is(w),Te=!Z&&!pe&&!at&&fo(w),ft=Z||pe||at||Te,qt=ft?pt(w.length,String):[],Qe=qt.length;for(var ct in w)(L||Oe.call(w,ct))&&!(ft&&(ct=="length"||at&&(ct=="offset"||ct=="parent")||Te&&(ct=="buffer"||ct=="byteLength"||ct=="byteOffset")||no(ct,Qe)))&&qt.push(ct);return qt}function Ji(w,L){for(var Z=w.length;Z--;)if(co(w[Z][0],L))return Z;return-1}function ts(w,L,Z){var pe=L(w);return On(w)?pe:Ke(pe,Z(w))}function Qi(w){return w==null?w===void 0?B:ee:sr&&sr in Object(w)?ro(w):Va(w)}function rs(w){return Zi(w)&&Qi(w)==f}function Xi(w,L,Z,pe,at){return w===L?!0:w==null||L==null||!Zi(w)&&!Zi(L)?w!==w&&L!==L:Xs(w,L,Z,pe,Xi,at)}function Xs(w,L,Z,pe,at,Te){var ft=On(w),qt=On(L),Qe=ft?g:ti(w),ct=qt?g:ti(L);Qe=Qe==f?A:Qe,ct=ct==f?A:ct;var Tt=Qe==A,gr=ct==A,Ht=Qe==ct;if(Ht&&is(w)){if(!is(L))return!1;ft=!0,Tt=!1}if(Ht&&!Tt)return Te||(Te=new kr),ft||fo(w)?In(w,L,Z,pe,at,Te):Ka(w,L,Qe,Z,pe,at,Te);if(!(Z&o)){var dt=Tt&&Oe.call(w,"__wrapped__"),or=gr&&Oe.call(L,"__wrapped__");if(dt||or){var Kr=dt?w.value():w,Nr=or?L.value():L;return Te||(Te=new kr),at(Kr,Nr,Z,pe,Te)}}return Ht?(Te||(Te=new kr),to(w,L,Z,pe,at,Te)):!1}function ka(w){if(!lo(w)||oo(w))return!1;var L=Cn(w)?et:se;return L.test(pi(w))}function Zs(w){return Zi(w)&&ho(w.length)&&!!le[Qi(w)]}function eo(w){if(!ao(w))return Yi(w);var L=[];for(var Z in Object(w))Oe.call(w,Z)&&Z!="constructor"&&L.push(Z);return L}function In(w,L,Z,pe,at,Te){var ft=Z&o,qt=w.length,Qe=L.length;if(qt!=Qe&&!(ft&&Qe>qt))return!1;var ct=Te.get(w);if(ct&&Te.get(L))return ct==L;var Tt=-1,gr=!0,Ht=Z&h?new Sn:void 0;for(Te.set(w,L),Te.set(L,w);++Tt<qt;){var dt=w[Tt],or=L[Tt];if(pe)var Kr=ft?pe(or,dt,Tt,L,w,Te):pe(dt,or,Tt,w,L,Te);if(Kr!==void 0){if(Kr)continue;gr=!1;break}if(Ht){if(!Fe(L,function(Nr,ri){if(!je(Ht,ri)&&(dt===Nr||at(dt,Nr,Z,pe,Te)))return Ht.push(ri)})){gr=!1;break}}else if(!(dt===or||at(dt,or,Z,pe,Te))){gr=!1;break}}return Te.delete(w),Te.delete(L),gr}function Ka(w,L,Z,pe,at,Te,ft){switch(Z){case oe:if(w.byteLength!=L.byteLength||w.byteOffset!=L.byteOffset)return!1;w=w.buffer,L=L.buffer;case W:return!(w.byteLength!=L.byteLength||!Te(new nr(w),new nr(L)));case E:case C:case K:return co(+w,+L);case N:return w.name==L.name&&w.message==L.message;case I:case c:return w==L+"";case k:var qt=Ne;case _:var Qe=pe&o;if(qt||(qt=qe),w.size!=L.size&&!Qe)return!1;var ct=ft.get(w);if(ct)return ct==L;pe|=h,ft.set(w,L);var Tt=In(qt(w),qt(L),pe,at,Te,ft);return ft.delete(w),Tt;case m:if(Ct)return Ct.call(w)==Ct.call(L)}return!1}function to(w,L,Z,pe,at,Te){var ft=Z&o,qt=xn(w),Qe=qt.length,ct=xn(L),Tt=ct.length;if(Qe!=Tt&&!ft)return!1;for(var gr=Qe;gr--;){var Ht=qt[gr];if(!(ft?Ht in L:Oe.call(L,Ht)))return!1}var dt=Te.get(w);if(dt&&Te.get(L))return dt==L;var or=!0;Te.set(w,L),Te.set(L,w);for(var Kr=ft;++gr<Qe;){Ht=qt[gr];var Nr=w[Ht],ri=L[Ht];if(pe)var ns=ft?pe(ri,Nr,Ht,L,w,Te):pe(Nr,ri,Ht,w,L,Te);if(!(ns===void 0?Nr===ri||at(Nr,ri,Z,pe,Te):ns)){or=!1;break}Kr||(Kr=Ht=="constructor")}if(or&&!Kr){var en=w.constructor,Kt=L.constructor;en!=Kt&&"constructor"in w&&"constructor"in L&&!(typeof en=="function"&&en instanceof en&&typeof Kt=="function"&&Kt instanceof Kt)&&(or=!1)}return Te.delete(w),Te.delete(L),or}function xn(w){return ts(w,Ya,io)}function Ri(w,L){var Z=w.__data__;return so(L)?Z[typeof L=="string"?"string":"hash"]:Z.map}function Dr(w,L){var Z=Ie(w,L);return ka(Z)?Z:void 0}function ro(w){var L=Oe.call(w,sr),Z=w[sr];try{w[sr]=void 0;var pe=!0}catch{}var at=Ge.call(w);return pe&&(L?w[sr]=Z:delete w[sr]),at}var io=fi?function(w){return w==null?[]:(w=Object(w),ze(fi(w),function(L){return pr.call(w,L)}))}:ot,ti=Qi;(Dt&&ti(new Dt(new ArrayBuffer(1)))!=oe||vt&&ti(new vt)!=k||St&&ti(St.resolve())!=$||It&&ti(new It)!=_||bt&&ti(new bt)!=z)&&(ti=function(w){var L=Qi(w),Z=L==A?w.constructor:void 0,pe=Z?pi(Z):"";if(pe)switch(pe){case Lt:return oe;case Ut:return k;case xt:return $;case Ft:return _;case Ot:return z}return L});function no(w,L){return L=L??p,!!L&&(typeof w=="number"||be.test(w))&&w>-1&&w%1==0&&w<L}function so(w){var L=typeof w;return L=="string"||L=="number"||L=="symbol"||L=="boolean"?w!=="__proto__":w===null}function oo(w){return!!Ve&&Ve in w}function ao(w){var L=w&&w.constructor,Z=typeof L=="function"&&L.prototype||De;return w===Z}function Va(w){return Ge.call(w)}function pi(w){if(w!=null){try{return Be.call(w)}catch{}try{return w+""}catch{}}return""}function co(w,L){return w===L||w!==w&&L!==L}var uo=rs(function(){return arguments}())?rs:function(w){return Zi(w)&&Oe.call(w,"callee")&&!pr.call(w,"callee")},On=Array.isArray;function Wa(w){return w!=null&&ho(w.length)&&!Cn(w)}var is=Ti||st;function Ga(w,L){return Xi(w,L)}function Cn(w){if(!lo(w))return!1;var L=Qi(w);return L==P||L==F||L==b||L==S}function ho(w){return typeof w=="number"&&w>-1&&w%1==0&&w<=p}function lo(w){var L=typeof w;return w!=null&&(L=="object"||L=="function")}function Zi(w){return w!=null&&typeof w=="object"}var fo=Se?gt(Se):Zs;function Ya(w){return Wa(w)?Qs(w):eo(w)}function ot(){return[]}function st(){return!1}i.exports=Ga})(da,da.exports);var ED=da.exports;const DD=eb(ED);function SD(i,e){if(i.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),s=0;s<r.length;s++)r[s]=255;for(var o=0;o<i.length;o++){var h=i.charAt(o),p=h.charCodeAt(0);if(r[p]!==255)throw new TypeError(h+" is ambiguous");r[p]=o}var f=i.length,g=i.charAt(0),b=Math.log(f)/Math.log(256),E=Math.log(256)/Math.log(f);function C(F){if(F instanceof Uint8Array||(ArrayBuffer.isView(F)?F=new Uint8Array(F.buffer,F.byteOffset,F.byteLength):Array.isArray(F)&&(F=Uint8Array.from(F))),!(F instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(F.length===0)return"";for(var k=0,K=0,ee=0,A=F.length;ee!==A&&F[ee]===0;)ee++,k++;for(var $=(A-ee)*E+1>>>0,S=new Uint8Array($);ee!==A;){for(var I=F[ee],_=0,c=$-1;(I!==0||_<K)&&c!==-1;c--,_++)I+=256*S[c]>>>0,S[c]=I%f>>>0,I=I/f>>>0;if(I!==0)throw new Error("Non-zero carry");K=_,ee++}for(var m=$-K;m!==$&&S[m]===0;)m++;for(var B=g.repeat(k);m<$;++m)B+=i.charAt(S[m]);return B}function N(F){if(typeof F!="string")throw new TypeError("Expected String");if(F.length===0)return new Uint8Array;var k=0;if(F[k]!==" "){for(var K=0,ee=0;F[k]===g;)K++,k++;for(var A=(F.length-k)*b+1>>>0,$=new Uint8Array(A);F[k];){var S=r[F.charCodeAt(k)];if(S===255)return;for(var I=0,_=A-1;(S!==0||I<ee)&&_!==-1;_--,I++)S+=f*$[_]>>>0,$[_]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");ee=I,k++}if(F[k]!==" "){for(var c=A-ee;c!==A&&$[c]===0;)c++;for(var m=new Uint8Array(K+(A-c)),B=K;c!==A;)m[B++]=$[c++];return m}}}function P(F){var k=N(F);if(k)return k;throw new Error(`Non-${e} character`)}return{encode:C,decodeUnsafe:N,decode:P}}var ID=SD,xD=ID;const Qp=i=>{if(i instanceof Uint8Array&&i.constructor.name==="Uint8Array")return i;if(i instanceof ArrayBuffer)return new Uint8Array(i);if(ArrayBuffer.isView(i))return new Uint8Array(i.buffer,i.byteOffset,i.byteLength);throw new Error("Unknown type, must be binary type")},OD=i=>new TextEncoder().encode(i),CD=i=>new TextDecoder().decode(i);class PD{constructor(e,r,s){this.name=e,this.prefix=r,this.baseEncode=s}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class AD{constructor(e,r,s){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=s}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Xp(this,e)}}class TD{constructor(e){this.decoders=e}or(e){return Xp(this,e)}decode(e){const r=e[0],s=this.decoders[r];if(s)return s.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Xp=(i,e)=>new TD({...i.decoders||{[i.prefix]:i},...e.decoders||{[e.prefix]:e}});let RD=class{constructor(e,r,s,o){this.name=e,this.prefix=r,this.baseEncode=s,this.baseDecode=o,this.encoder=new PD(e,r,s),this.decoder=new AD(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const xa=({name:i,prefix:e,encode:r,decode:s})=>new RD(i,e,r,s),Ws=({prefix:i,name:e,alphabet:r})=>{const{encode:s,decode:o}=xD(r,e);return xa({prefix:i,name:e,encode:s,decode:h=>Qp(o(h))})},ND=(i,e,r,s)=>{const o={};for(let E=0;E<e.length;++E)o[e[E]]=E;let h=i.length;for(;i[h-1]==="=";)--h;const p=new Uint8Array(h*r/8|0);let f=0,g=0,b=0;for(let E=0;E<h;++E){const C=o[i[E]];if(C===void 0)throw new SyntaxError(`Non-${s} character`);g=g<<r|C,f+=r,f>=8&&(f-=8,p[b++]=255&g>>f)}if(f>=r||255&g<<8-f)throw new SyntaxError("Unexpected end of data");return p},$D=(i,e,r)=>{const s=e[e.length-1]==="=",o=(1<<r)-1;let h="",p=0,f=0;for(let g=0;g<i.length;++g)for(f=f<<8|i[g],p+=8;p>r;)p-=r,h+=e[o&f>>p];if(p&&(h+=e[o&f<<r-p]),s)for(;h.length*r&7;)h+="=";return h},Qt=({name:i,prefix:e,bitsPerChar:r,alphabet:s})=>xa({prefix:e,name:i,encode(o){return $D(o,s,r)},decode(o){return ND(o,s,r,i)}}),LD=xa({prefix:"\0",name:"identity",encode:i=>CD(i),decode:i=>OD(i)});var UD=Object.freeze({__proto__:null,identity:LD});const FD=Qt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var MD=Object.freeze({__proto__:null,base2:FD});const jD=Qt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var qD=Object.freeze({__proto__:null,base8:jD});const HD=Ws({prefix:"9",name:"base10",alphabet:"0123456789"});var zD=Object.freeze({__proto__:null,base10:HD});const BD=Qt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),kD=Qt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var KD=Object.freeze({__proto__:null,base16:BD,base16upper:kD});const VD=Qt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),WD=Qt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),GD=Qt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),YD=Qt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),JD=Qt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),QD=Qt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),XD=Qt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),ZD=Qt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),e2=Qt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var t2=Object.freeze({__proto__:null,base32:VD,base32upper:WD,base32pad:GD,base32padupper:YD,base32hex:JD,base32hexupper:QD,base32hexpad:XD,base32hexpadupper:ZD,base32z:e2});const r2=Ws({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),i2=Ws({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var n2=Object.freeze({__proto__:null,base36:r2,base36upper:i2});const s2=Ws({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),o2=Ws({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var a2=Object.freeze({__proto__:null,base58btc:s2,base58flickr:o2});const c2=Qt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),u2=Qt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),h2=Qt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),l2=Qt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var f2=Object.freeze({__proto__:null,base64:c2,base64pad:u2,base64url:h2,base64urlpad:l2});const Zp=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),d2=Zp.reduce((i,e,r)=>(i[r]=e,i),[]),p2=Zp.reduce((i,e,r)=>(i[e.codePointAt(0)]=r,i),[]);function g2(i){return i.reduce((e,r)=>(e+=d2[r],e),"")}function v2(i){const e=[];for(const r of i){const s=p2[r.codePointAt(0)];if(s===void 0)throw new Error(`Non-base256emoji character: ${r}`);e.push(s)}return new Uint8Array(e)}const y2=xa({prefix:"🚀",name:"base256emoji",encode:g2,decode:v2});var m2=Object.freeze({__proto__:null,base256emoji:y2}),_2=eg,Id=128,b2=127,w2=~b2,E2=Math.pow(2,31);function eg(i,e,r){e=e||[],r=r||0;for(var s=r;i>=E2;)e[r++]=i&255|Id,i/=128;for(;i&w2;)e[r++]=i&255|Id,i>>>=7;return e[r]=i|0,eg.bytes=r-s+1,e}var D2=Mu,S2=128,xd=127;function Mu(i,s){var r=0,s=s||0,o=0,h=s,p,f=i.length;do{if(h>=f)throw Mu.bytes=0,new RangeError("Could not decode varint");p=i[h++],r+=o<28?(p&xd)<<o:(p&xd)*Math.pow(2,o),o+=7}while(p>=S2);return Mu.bytes=h-s,r}var I2=Math.pow(2,7),x2=Math.pow(2,14),O2=Math.pow(2,21),C2=Math.pow(2,28),P2=Math.pow(2,35),A2=Math.pow(2,42),T2=Math.pow(2,49),R2=Math.pow(2,56),N2=Math.pow(2,63),$2=function(i){return i<I2?1:i<x2?2:i<O2?3:i<C2?4:i<P2?5:i<A2?6:i<T2?7:i<R2?8:i<N2?9:10},L2={encode:_2,decode:D2,encodingLength:$2},tg=L2;const Od=(i,e,r=0)=>(tg.encode(i,e,r),e),Cd=i=>tg.encodingLength(i),ju=(i,e)=>{const r=e.byteLength,s=Cd(i),o=s+Cd(r),h=new Uint8Array(o+r);return Od(i,h,0),Od(r,h,s),h.set(e,o),new U2(i,r,e,h)};class U2{constructor(e,r,s,o){this.code=e,this.size=r,this.digest=s,this.bytes=o}}const rg=({name:i,code:e,encode:r})=>new F2(i,e,r);class F2{constructor(e,r,s){this.name=e,this.code=r,this.encode=s}digest(e){if(e instanceof Uint8Array){const r=this.encode(e);return r instanceof Uint8Array?ju(this.code,r):r.then(s=>ju(this.code,s))}else throw Error("Unknown type, must be binary type")}}const ig=i=>async e=>new Uint8Array(await crypto.subtle.digest(i,e)),M2=rg({name:"sha2-256",code:18,encode:ig("SHA-256")}),j2=rg({name:"sha2-512",code:19,encode:ig("SHA-512")});var q2=Object.freeze({__proto__:null,sha256:M2,sha512:j2});const ng=0,H2="identity",sg=Qp,z2=i=>ju(ng,sg(i)),B2={code:ng,name:H2,encode:sg,digest:z2};var k2=Object.freeze({__proto__:null,identity:B2});new TextEncoder,new TextDecoder;const Pd={...UD,...MD,...qD,...zD,...KD,...t2,...n2,...a2,...f2,...m2};({...q2,...k2});function og(i){return globalThis.Buffer!=null?new Uint8Array(i.buffer,i.byteOffset,i.byteLength):i}function K2(i=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?og(globalThis.Buffer.allocUnsafe(i)):new Uint8Array(i)}function ag(i,e,r,s){return{name:i,prefix:e,encoder:{name:i,prefix:e,encode:r},decoder:{decode:s}}}const Ad=ag("utf8","u",i=>"u"+new TextDecoder("utf8").decode(i),i=>new TextEncoder().encode(i.substring(1))),pu=ag("ascii","a",i=>{let e="a";for(let r=0;r<i.length;r++)e+=String.fromCharCode(i[r]);return e},i=>{i=i.substring(1);const e=K2(i.length);for(let r=0;r<i.length;r++)e[r]=i.charCodeAt(r);return e}),V2={utf8:Ad,"utf-8":Ad,hex:Pd.base16,latin1:pu,ascii:pu,binary:pu,...Pd};function W2(i,e="utf8"){const r=V2[e];if(!r)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?og(globalThis.Buffer.from(i,"utf-8")):r.decoder.decode(`${r.prefix}${i}`)}const cg="wc",G2=2,ah="core",ki=`${cg}@2:${ah}:`,Y2={name:ah,logger:"error"},J2={database:":memory:"},Q2="crypto",Td="client_ed25519_seed",X2=ye.ONE_DAY,Z2="keychain",eS="0.3",tS="messages",rS="0.3",iS=ye.SIX_HOURS,nS="publisher",ug="irn",sS="error",hg="wss://relay.walletconnect.com",Rd="wss://relay.walletconnect.org",oS="relayer",ir={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"},aS="_subscription",xi={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},cS=ye.ONE_SECOND,uS="2.10.4",hS=1e4,lS="0.3",fS="WALLETCONNECT_CLIENT_ID",Jr={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},dS="subscription",pS="0.3",gS=ye.FIVE_SECONDS*1e3,vS="pairing",yS="0.3",Cs={wc_pairingDelete:{req:{ttl:ye.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:ye.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:ye.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:ye.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:ye.ONE_DAY,prompt:!1,tag:0},res:{ttl:ye.ONE_DAY,prompt:!1,tag:0}}},$s={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},ui={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},mS="history",_S="0.3",bS="expirer",Hr={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},wS="0.3",gu="verify-api",Vn="https://verify.walletconnect.com",qu="https://verify.walletconnect.org",ES=[Vn,qu];class DS{constructor(e,r){this.core=e,this.logger=r,this.keychain=new Map,this.name=Z2,this.version=eS,this.initialized=!1,this.storagePrefix=ki,this.init=async()=>{if(!this.initialized){const s=await this.getKeyChain();typeof s<"u"&&(this.keychain=s),this.initialized=!0}},this.has=s=>(this.isInitialized(),this.keychain.has(s)),this.set=async(s,o)=>{this.isInitialized(),this.keychain.set(s,o),await this.persist()},this.get=s=>{this.isInitialized();const o=this.keychain.get(s);if(typeof o>"u"){const{message:h}=he("NO_MATCHING_KEY",`${this.name}: ${s}`);throw new Error(h)}return o},this.del=async s=>{this.isInitialized(),this.keychain.delete(s),await this.persist()},this.core=e,this.logger=Ze.generateChildLogger(r,this.name)}get context(){return Ze.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,Ap(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Tp(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=he("NOT_INITIALIZED",this.name);throw new Error(e)}}}class SS{constructor(e,r,s){this.core=e,this.logger=r,this.name=Q2,this.initialized=!1,this.init=async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)},this.hasKeys=o=>(this.isInitialized(),this.keychain.has(o)),this.getClientId=async()=>{this.isInitialized();const o=await this.getClientSeed(),h=vd(o);return Bp(h.publicKey)},this.generateKeyPair=()=>{this.isInitialized();const o=QE();return this.setPrivateKey(o.publicKey,o.privateKey)},this.signJWT=async o=>{this.isInitialized();const h=await this.getClientSeed(),p=vd(h),f=Uu();return await Z6(f,o,X2,p)},this.generateSharedKey=(o,h,p)=>{this.isInitialized();const f=this.getPrivateKey(o),g=XE(f,h);return this.setSymKey(g,p)},this.setSymKey=async(o,h)=>{this.isInitialized();const p=h||ZE(o);return await this.keychain.set(p,o),p},this.deleteKeyPair=async o=>{this.isInitialized(),await this.keychain.del(o)},this.deleteSymKey=async o=>{this.isInitialized(),await this.keychain.del(o)},this.encode=async(o,h,p)=>{this.isInitialized();const f=Pp(p),g=js(h);if(kf(f)){const N=f.senderPublicKey,P=f.receiverPublicKey;o=await this.generateSharedKey(N,P)}const b=this.getSymKey(o),{type:E,senderPublicKey:C}=f;return t3({type:E,symKey:b,message:g,senderPublicKey:C})},this.decode=async(o,h,p)=>{this.isInitialized();const f=n3(h,p);if(kf(f)){const g=f.receiverPublicKey,b=f.senderPublicKey;o=await this.generateSharedKey(g,b)}try{const g=this.getSymKey(o),b=r3({symKey:g,encoded:h});return th(b)}catch(g){this.logger.error(`Failed to decode message from topic: '${o}', clientId: '${await this.getClientId()}'`),this.logger.error(g)}},this.getPayloadType=o=>{const h=ha(o);return zs(h.type)},this.getPayloadSenderPublicKey=o=>{const h=ha(o);return h.senderPublicKey?dr(h.senderPublicKey,fr):void 0},this.core=e,this.logger=Ze.generateChildLogger(r,this.name),this.keychain=s||new DS(this.core,this.logger)}get context(){return Ze.getLoggerContext(this.logger)}async setPrivateKey(e,r){return await this.keychain.set(e,r),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(Td)}catch{e=Uu(),await this.keychain.set(Td,e)}return W2(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=he("NOT_INITIALIZED",this.name);throw new Error(e)}}}class IS extends P6{constructor(e,r){super(e,r),this.logger=e,this.core=r,this.messages=new Map,this.name=tS,this.version=rS,this.initialized=!1,this.storagePrefix=ki,this.init=async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const s=await this.getRelayerMessages();typeof s<"u"&&(this.messages=s),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(s){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(s)}finally{this.initialized=!0}}},this.set=async(s,o)=>{this.isInitialized();const h=Wn(o);let p=this.messages.get(s);return typeof p>"u"&&(p={}),typeof p[h]<"u"||(p[h]=o,this.messages.set(s,p),await this.persist()),h},this.get=s=>{this.isInitialized();let o=this.messages.get(s);return typeof o>"u"&&(o={}),o},this.has=(s,o)=>{this.isInitialized();const h=this.get(s),p=Wn(o);return typeof h[p]<"u"},this.del=async s=>{this.isInitialized(),this.messages.delete(s),await this.persist()},this.logger=Ze.generateChildLogger(e,this.name),this.core=r}get context(){return Ze.getLoggerContext(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,Ap(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?Tp(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=he("NOT_INITIALIZED",this.name);throw new Error(e)}}}class xS extends A6{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.events=new zr.EventEmitter,this.name=nS,this.queue=new Map,this.publishTimeout=ye.toMiliseconds(ye.TEN_SECONDS),this.needsTransportRestart=!1,this.publish=async(s,o,h)=>{var p;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:s,message:o,opts:h}});try{const f=(h==null?void 0:h.ttl)||iS,g=Fu(h),b=(h==null?void 0:h.prompt)||!1,E=(h==null?void 0:h.tag)||0,C=(h==null?void 0:h.id)||Gp().toString(),N={topic:s,message:o,opts:{ttl:f,relay:g,prompt:b,tag:E,id:C}},P=setTimeout(()=>this.queue.set(C,N),this.publishTimeout);try{await await Ms(this.rpcPublish(s,o,f,g,b,E,C),this.publishTimeout,"Failed to publish payload, please try again."),this.removeRequestFromQueue(C),this.relayer.events.emit(ir.publish,N)}catch(F){if(this.logger.debug("Publishing Payload stalled"),this.needsTransportRestart=!0,(p=h==null?void 0:h.internal)!=null&&p.throwOnFailedPublish)throw this.removeRequestFromQueue(C),F;return}finally{clearTimeout(P)}this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:s,message:o,opts:h}})}catch(f){throw this.logger.debug("Failed to Publish Payload"),this.logger.error(f),f}},this.on=(s,o)=>{this.events.on(s,o)},this.once=(s,o)=>{this.events.once(s,o)},this.off=(s,o)=>{this.events.off(s,o)},this.removeListener=(s,o)=>{this.events.removeListener(s,o)},this.relayer=e,this.logger=Ze.generateChildLogger(r,this.name),this.registerEventListeners()}get context(){return Ze.getLoggerContext(this.logger)}rpcPublish(e,r,s,o,h,p,f){var g,b,E,C;const N={method:oa(o.protocol).publish,params:{topic:e,message:r,ttl:s,prompt:h,tag:p},id:f};return lr((g=N.params)==null?void 0:g.prompt)&&((b=N.params)==null||delete b.prompt),lr((E=N.params)==null?void 0:E.tag)&&((C=N.params)==null||delete C.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:N}),this.relayer.request(N)}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async e=>{const{topic:r,message:s,opts:o}=e;await this.publish(r,s,o)})}registerEventListeners(){this.relayer.core.heartbeat.on(es.HEARTBEAT_EVENTS.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(ir.connection_stalled);return}this.checkQueue()}),this.relayer.on(ir.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}class OS{constructor(){this.map=new Map,this.set=(e,r)=>{const s=this.get(e);this.exists(e,r)||this.map.set(e,[...s,r])},this.get=e=>this.map.get(e)||[],this.exists=(e,r)=>this.get(e).includes(r),this.delete=(e,r)=>{if(typeof r>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const s=this.get(e);if(!this.exists(e,r))return;const o=s.filter(h=>h!==r);if(!o.length){this.map.delete(e);return}this.map.set(e,o)},this.clear=()=>{this.map.clear()}}get topics(){return Array.from(this.map.keys())}}var CS=Object.defineProperty,PS=Object.defineProperties,AS=Object.getOwnPropertyDescriptors,Nd=Object.getOwnPropertySymbols,TS=Object.prototype.hasOwnProperty,RS=Object.prototype.propertyIsEnumerable,$d=(i,e,r)=>e in i?CS(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,Ps=(i,e)=>{for(var r in e||(e={}))TS.call(e,r)&&$d(i,r,e[r]);if(Nd)for(var r of Nd(e))RS.call(e,r)&&$d(i,r,e[r]);return i},vu=(i,e)=>PS(i,AS(e));class NS extends N6{constructor(e,r){super(e,r),this.relayer=e,this.logger=r,this.subscriptions=new Map,this.topicMap=new OS,this.events=new zr.EventEmitter,this.name=dS,this.version=pS,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=ki,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(s,o)=>{await this.restartToComplete(),this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:s,opts:o}});try{const h=Fu(o),p={topic:s,relay:h};this.pending.set(s,p);const f=await this.rpcSubscribe(s,h);return this.onSubscribe(f,p),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:s,opts:o}}),f}catch(h){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(h),h}},this.unsubscribe=async(s,o)=>{await this.restartToComplete(),this.isInitialized(),typeof(o==null?void 0:o.id)<"u"?await this.unsubscribeById(s,o.id,o):await this.unsubscribeByTopic(s,o)},this.isSubscribed=async s=>this.topics.includes(s)?!0:await new Promise((o,h)=>{const p=new ye.Watch;p.start(this.pendingSubscriptionWatchLabel);const f=setInterval(()=>{!this.pending.has(s)&&this.topics.includes(s)&&(clearInterval(f),p.stop(this.pendingSubscriptionWatchLabel),o(!0)),p.elapsed(this.pendingSubscriptionWatchLabel)>=gS&&(clearInterval(f),p.stop(this.pendingSubscriptionWatchLabel),h(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1),this.on=(s,o)=>{this.events.on(s,o)},this.once=(s,o)=>{this.events.once(s,o)},this.off=(s,o)=>{this.events.off(s,o)},this.removeListener=(s,o)=>{this.events.removeListener(s,o)},this.restart=async()=>{this.restartInProgress=!0,await this.restore(),await this.reset(),this.restartInProgress=!1},this.relayer=e,this.logger=Ze.generateChildLogger(r,this.name),this.clientId=""}get context(){return Ze.getLoggerContext(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(e,r){let s=!1;try{s=this.getSubscription(e).topic===r}catch{}return s}onEnable(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,r){const s=this.topicMap.get(e);await Promise.all(s.map(async o=>await this.unsubscribeById(e,o,r)))}async unsubscribeById(e,r,s){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:s}});try{const o=Fu(s);await this.rpcUnsubscribe(e,r,o);const h=$t("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,r,h),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:r,opts:s}})}catch(o){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(o),o}}async rpcSubscribe(e,r){const s={method:oa(r.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{await await Ms(this.relayer.request(s),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(ir.connection_stalled)}return Wn(e+this.clientId)}async rpcBatchSubscribe(e){if(!e.length)return;const r=e[0].relay,s={method:oa(r.protocol).batchSubscribe,params:{topics:e.map(o=>o.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{return await await Ms(this.relayer.request(s),this.subscribeTimeout)}catch{this.logger.debug("Outgoing Relay Payload stalled"),this.relayer.events.emit(ir.connection_stalled)}}rpcUnsubscribe(e,r,s){const o={method:oa(s.protocol).unsubscribe,params:{topic:e,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:o}),this.relayer.request(o)}onSubscribe(e,r){this.setSubscription(e,vu(Ps({},r),{id:e})),this.pending.delete(r.topic)}onBatchSubscribe(e){e.length&&e.forEach(r=>{this.setSubscription(r.id,Ps({},r)),this.pending.delete(r.topic)})}async onUnsubscribe(e,r,s){this.events.removeAllListeners(r),this.hasSubscription(r,e)&&this.deleteSubscription(r,s),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,r){this.subscriptions.has(e)||(this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:r}),this.addSubscription(e,r))}addSubscription(e,r){this.subscriptions.set(e,Ps({},r)),this.topicMap.set(r.topic,e),this.events.emit(Jr.created,r)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const r=this.subscriptions.get(e);if(!r){const{message:s}=he("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(s)}return r}deleteSubscription(e,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:r});const s=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(s.topic,e),this.events.emit(Jr.deleted,vu(Ps({},s),{reason:r}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(Jr.sync)}async reset(){if(this.cached.length){const e=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<e;r++){const s=this.cached.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(s)}}this.events.emit(Jr.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:r}=he("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){if(!e.length)return;const r=await this.rpcBatchSubscribe(e);li(r)&&this.onBatchSubscribe(r.map((s,o)=>vu(Ps({},e[o]),{id:s})))}async onConnect(){this.restartInProgress||(await this.restart(),this.onEnable())}onDisconnect(){this.onDisable()}async checkPending(){if(!this.initialized||this.relayer.transportExplicitlyClosed)return;const e=[];this.pending.forEach(r=>{e.push(r)}),await this.batchSubscribe(e)}registerEventListeners(){this.relayer.core.heartbeat.on(es.HEARTBEAT_EVENTS.pulse,async()=>{await this.checkPending()}),this.relayer.on(ir.connect,async()=>{await this.onConnect()}),this.relayer.on(ir.disconnect,()=>{this.onDisconnect()}),this.events.on(Jr.created,async e=>{const r=Jr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()}),this.events.on(Jr.deleted,async e=>{const r=Jr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),await this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=he("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(){this.restartInProgress&&await new Promise(e=>{const r=setInterval(()=>{this.restartInProgress||(clearInterval(r),e())},this.pollingInterval)})}}var $S=Object.defineProperty,Ld=Object.getOwnPropertySymbols,LS=Object.prototype.hasOwnProperty,US=Object.prototype.propertyIsEnumerable,Ud=(i,e,r)=>e in i?$S(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,FS=(i,e)=>{for(var r in e||(e={}))LS.call(e,r)&&Ud(i,r,e[r]);if(Ld)for(var r of Ld(e))US.call(e,r)&&Ud(i,r,e[r]);return i};class MS extends T6{constructor(e){super(e),this.protocol="wc",this.version=2,this.events=new zr.EventEmitter,this.name=oS,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(s){throw this.logger.debug("Failed to Publish Request"),this.logger.error(s),s}},this.onPayloadHandler=r=>{this.onProviderPayload(r)},this.onConnectHandler=()=>{this.events.emit(ir.connect)},this.onDisconnectHandler=()=>{this.onProviderDisconnect()},this.onProviderErrorHandler=r=>{this.logger.error(r),this.events.emit(ir.error,r),this.logger.info("Fatal socket error received, closing transport"),this.transportClose()},this.registerProviderListeners=()=>{this.provider.on(xi.payload,this.onPayloadHandler),this.provider.on(xi.connect,this.onConnectHandler),this.provider.on(xi.disconnect,this.onDisconnectHandler),this.provider.on(xi.error,this.onProviderErrorHandler)},this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?Ze.generateChildLogger(e.logger,this.name):Ze.pino(Ze.getDefaultLoggerOptions({level:e.logger||sS})),this.messages=new IS(this.logger,e.core),this.subscriber=new NS(this,this.logger),this.publisher=new xS(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||hg,this.projectId=e.projectId,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 ${Rd}...`),await this.restartTransport(Rd)}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)},hS)}get context(){return Ze.getLoggerContext(this.logger)}get connected(){return this.provider.connection.connected}get connecting(){return this.provider.connection.connecting}async publish(e,r,s){this.isInitialized(),await this.publisher.publish(e,r,s),await this.recordMessageEvent({topic:e,message:r,publishedAt:Date.now()})}async subscribe(e,r){var s;this.isInitialized();let o=((s=this.subscriber.topicMap.get(e))==null?void 0:s[0])||"";if(o)return o;let h;const p=f=>{f.topic===e&&(this.subscriber.off(Jr.created,p),h())};return await Promise.all([new Promise(f=>{h=f,this.subscriber.on(Jr.created,p)}),new Promise(async f=>{o=await this.subscriber.subscribe(e,r),f()})]),o}async unsubscribe(e,r){this.isInitialized(),await this.subscriber.unsubscribe(e,r)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async transportClose(){this.transportExplicitlyClosed=!0,this.hasExperiencedNetworkDisruption&&this.connected?await Ms(this.provider.disconnect(),1e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.connected&&await this.provider.disconnect()}async transportOpen(e){if(this.transportExplicitlyClosed=!1,await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress){e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportClose(),await this.createProvider()),this.connectionAttemptInProgress=!0;try{await Promise.all([new Promise(r=>{if(!this.initialized)return r();this.subscriber.once(Jr.resubscribed,()=>{r()})}),new Promise(async(r,s)=>{try{await Ms(this.provider.connect(),1e4,`Socket stalled when trying to connect to ${this.relayUrl}`)}catch(o){s(o);return}r()})])}catch(r){this.logger.error(r);const s=r;if(!this.isConnectionStalled(s.message))throw r;this.provider.events.emit(xi.disconnect)}finally{this.connectionAttemptInProgress=!1,this.hasExperiencedNetworkDisruption=!1}}}async restartTransport(e){await this.confirmOnlineStateOrThrow(),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.transportClose(),await this.createProvider(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await ed())throw new Error("No internet connection detected. Please restart your network and try again.")}isConnectionStalled(e){return this.staleConnectionErrors.some(r=>e.includes(r))}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Pi(new wD(g3({sdkVersion:uS,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:r,message:s}=e;await this.messages.set(r,s)}async shouldIgnoreMessageEvent(e){const{topic:r,message:s}=e;if(!s||s.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${s}`),!0;if(!await this.subscriber.isSubscribed(r))return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`),!0;const o=this.messages.has(r,s);return o&&this.logger.debug(`Ignoring duplicate message: ${s}`),o}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),oh(e)){if(!e.method.endsWith(aS))return;const r=e.params,{topic:s,message:o,publishedAt:h}=r.data,p={topic:s,message:o,publishedAt:h};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(FS({type:"event",event:r.id},p)),this.events.emit(r.id,p),await this.acknowledgePayload(e),await this.onMessageEvent(p)}else Ia(e)&&this.events.emit(ir.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(ir.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const r=sh(e.id,!0);await this.provider.connection.send(r)}unregisterProviderListeners(){this.provider.off(xi.payload,this.onPayloadHandler),this.provider.off(xi.connect,this.onConnectHandler),this.provider.off(xi.disconnect,this.onDisconnectHandler),this.provider.off(xi.error,this.onProviderErrorHandler)}async registerEventListeners(){this.events.on(ir.connection_stalled,()=>{this.restartTransport().catch(r=>this.logger.error(r))});let e=await ed();a6(async r=>{this.initialized&&e!==r&&(e=r,r?await this.restartTransport().catch(s=>this.logger.error(s)):(this.hasExperiencedNetworkDisruption=!0,await this.transportClose().catch(s=>this.logger.error(s))))})}onProviderDisconnect(){this.events.emit(ir.disconnect),this.attemptToReconnect()}attemptToReconnect(){this.transportExplicitlyClosed||(this.logger.info("attemptToReconnect called. Connecting..."),setTimeout(async()=>{await this.restartTransport().catch(e=>this.logger.error(e))},ye.toMiliseconds(cS)))}isInitialized(){if(!this.initialized){const{message:e}=he("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectionAttemptInProgress)return await new Promise(e=>{const r=setInterval(()=>{this.connected&&(clearInterval(r),e())},this.connectionStatusPollingInterval)});await this.restartTransport()}}}var jS=Object.defineProperty,Fd=Object.getOwnPropertySymbols,qS=Object.prototype.hasOwnProperty,HS=Object.prototype.propertyIsEnumerable,Md=(i,e,r)=>e in i?jS(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,jd=(i,e)=>{for(var r in e||(e={}))qS.call(e,r)&&Md(i,r,e[r]);if(Fd)for(var r of Fd(e))HS.call(e,r)&&Md(i,r,e[r]);return i};class Oa extends R6{constructor(e,r,s,o=ki,h=void 0){super(e,r,s,o),this.core=e,this.logger=r,this.name=s,this.map=new Map,this.version=lS,this.cached=[],this.initialized=!1,this.storagePrefix=ki,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(p=>{this.getKey&&p!==null&&!lr(p)?this.map.set(this.getKey(p),p):M3(p)?this.map.set(p.id,p):j3(p)&&this.map.set(p.topic,p)}),this.cached=[],this.initialized=!0)},this.set=async(p,f)=>{this.isInitialized(),this.map.has(p)?await this.update(p,f):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:p,value:f}),this.map.set(p,f),await this.persist())},this.get=p=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:p}),this.getData(p)),this.getAll=p=>(this.isInitialized(),p?this.values.filter(f=>Object.keys(p).every(g=>DD(f[g],p[g]))):this.values),this.update=async(p,f)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:p,update:f});const g=jd(jd({},this.getData(p)),f);this.map.set(p,g),await this.persist()},this.delete=async(p,f)=>{this.isInitialized(),this.map.has(p)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:p,reason:f}),this.map.delete(p),await this.persist())},this.logger=Ze.generateChildLogger(r,this.name),this.storagePrefix=o,this.getKey=h}get context(){return Ze.getLoggerContext(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(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const r=this.map.get(e);if(!r){const{message:s}=he("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(s),new Error(s)}return r}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:r}=he("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=he("NOT_INITIALIZED",this.name);throw new Error(e)}}}class zS{constructor(e,r){this.core=e,this.logger=r,this.name=vS,this.version=yS,this.events=new Bu,this.initialized=!1,this.storagePrefix=ki,this.ignoredPayloadTypes=[_n],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:s})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...s])]},this.create=async()=>{this.isInitialized();const s=Uu(),o=await this.core.crypto.setSymKey(s),h=Qr(ye.FIVE_MINUTES),p={protocol:ug},f={topic:o,expiry:h,relay:p,active:!1},g=C3({protocol:this.core.protocol,version:this.core.version,topic:o,symKey:s,relay:p});return await this.pairings.set(o,f),await this.core.relayer.subscribe(o),this.core.expirer.set(o,h),{topic:o,uri:g}},this.pair=async s=>{this.isInitialized(),this.isValidPair(s);const{topic:o,symKey:h,relay:p}=I3(s.uri);let f;if(this.pairings.keys.includes(o)&&(f=this.pairings.get(o),f.active))throw new Error(`Pairing already exists: ${o}. Please try again with a new connection URI.`);this.core.crypto.keychain.has(o)||(await this.core.crypto.setSymKey(h,o),await this.core.relayer.subscribe(o,{relay:p}));const g=Qr(ye.FIVE_MINUTES),b={topic:o,relay:p,expiry:g,active:!1};return await this.pairings.set(o,b),this.core.expirer.set(o,g),s.activatePairing&&await this.activate({topic:o}),this.events.emit($s.create,b),b},this.activate=async({topic:s})=>{this.isInitialized();const o=Qr(ye.THIRTY_DAYS);await this.pairings.update(s,{active:!0,expiry:o}),this.core.expirer.set(s,o)},this.ping=async s=>{this.isInitialized(),await this.isValidPing(s);const{topic:o}=s;if(this.pairings.keys.includes(o)){const h=await this.sendRequest(o,"wc_pairingPing",{}),{done:p,resolve:f,reject:g}=kn();this.events.once(zt("pairing_ping",h),({error:b})=>{b?g(b):f()}),await p()}},this.updateExpiry=async({topic:s,expiry:o})=>{this.isInitialized(),await this.pairings.update(s,{expiry:o})},this.updateMetadata=async({topic:s,metadata:o})=>{this.isInitialized(),await this.pairings.update(s,{peerMetadata:o})},this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=async s=>{this.isInitialized(),await this.isValidDisconnect(s);const{topic:o}=s;this.pairings.keys.includes(o)&&(await this.sendRequest(o,"wc_pairingDelete",$t("USER_DISCONNECTED")),await this.deletePairing(o))},this.sendRequest=async(s,o,h)=>{const p=Yn(o,h),f=await this.core.crypto.encode(s,p),g=Cs[o].req;return this.core.history.set(s,p),this.core.relayer.publish(s,f,g),p.id},this.sendResult=async(s,o,h)=>{const p=sh(s,h),f=await this.core.crypto.encode(o,p),g=await this.core.history.get(o,s),b=Cs[g.request.method].res;await this.core.relayer.publish(o,f,b),await this.core.history.resolve(p)},this.sendError=async(s,o,h)=>{const p=Sa(s,h),f=await this.core.crypto.encode(o,p),g=await this.core.history.get(o,s),b=Cs[g.request.method]?Cs[g.request.method].res:Cs.unregistered_method.res;await this.core.relayer.publish(o,f,b),await this.core.history.resolve(p)},this.deletePairing=async(s,o)=>{await this.core.relayer.unsubscribe(s),await Promise.all([this.pairings.delete(s,$t("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(s),o?Promise.resolve():this.core.expirer.del(s)])},this.cleanup=async()=>{const s=this.pairings.getAll().filter(o=>Bi(o.expiry));await Promise.all(s.map(o=>this.deletePairing(o.topic)))},this.onRelayEventRequest=s=>{const{topic:o,payload:h}=s;switch(h.method){case"wc_pairingPing":return this.onPairingPingRequest(o,h);case"wc_pairingDelete":return this.onPairingDeleteRequest(o,h);default:return this.onUnknownRpcMethodRequest(o,h)}},this.onRelayEventResponse=async s=>{const{topic:o,payload:h}=s,p=(await this.core.history.get(o,h.id)).request.method;switch(p){case"wc_pairingPing":return this.onPairingPingResponse(o,h);default:return this.onUnknownRpcMethodResponse(p)}},this.onPairingPingRequest=async(s,o)=>{const{id:h}=o;try{this.isValidPing({topic:s}),await this.sendResult(h,s,!0),this.events.emit($s.ping,{id:h,topic:s})}catch(p){await this.sendError(h,s,p),this.logger.error(p)}},this.onPairingPingResponse=(s,o)=>{const{id:h}=o;setTimeout(()=>{Ci(o)?this.events.emit(zt("pairing_ping",h),{}):Xr(o)&&this.events.emit(zt("pairing_ping",h),{error:o.error})},500)},this.onPairingDeleteRequest=async(s,o)=>{const{id:h}=o;try{this.isValidDisconnect({topic:s}),await this.deletePairing(s),this.events.emit($s.delete,{id:h,topic:s})}catch(p){await this.sendError(h,s,p),this.logger.error(p)}},this.onUnknownRpcMethodRequest=async(s,o)=>{const{id:h,method:p}=o;try{if(this.registeredMethods.includes(p))return;const f=$t("WC_METHOD_UNSUPPORTED",p);await this.sendError(h,s,f),this.logger.error(f)}catch(f){await this.sendError(h,s,f),this.logger.error(f)}},this.onUnknownRpcMethodResponse=s=>{this.registeredMethods.includes(s)||this.logger.error($t("WC_METHOD_UNSUPPORTED",s))},this.isValidPair=s=>{if(!wr(s)){const{message:o}=he("MISSING_OR_INVALID",`pair() params: ${s}`);throw new Error(o)}if(!F3(s.uri)){const{message:o}=he("MISSING_OR_INVALID",`pair() uri: ${s.uri}`);throw new Error(o)}},this.isValidPing=async s=>{if(!wr(s)){const{message:h}=he("MISSING_OR_INVALID",`ping() params: ${s}`);throw new Error(h)}const{topic:o}=s;await this.isValidPairingTopic(o)},this.isValidDisconnect=async s=>{if(!wr(s)){const{message:h}=he("MISSING_OR_INVALID",`disconnect() params: ${s}`);throw new Error(h)}const{topic:o}=s;await this.isValidPairingTopic(o)},this.isValidPairingTopic=async s=>{if(!Gt(s,!1)){const{message:o}=he("MISSING_OR_INVALID",`pairing topic should be a string: ${s}`);throw new Error(o)}if(!this.pairings.keys.includes(s)){const{message:o}=he("NO_MATCHING_KEY",`pairing topic doesn't exist: ${s}`);throw new Error(o)}if(Bi(this.pairings.get(s).expiry)){await this.deletePairing(s);const{message:o}=he("EXPIRED",`pairing topic: ${s}`);throw new Error(o)}},this.core=e,this.logger=Ze.generateChildLogger(r,this.name),this.pairings=new Oa(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Ze.getLoggerContext(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=he("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(ir.message,async e=>{const{topic:r,message:s}=e;if(!this.pairings.keys.includes(r)||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(s)))return;const o=await this.core.crypto.decode(r,s);try{oh(o)?(this.core.history.set(r,o),this.onRelayEventRequest({topic:r,payload:o})):Ia(o)&&(await this.core.history.resolve(o),await this.onRelayEventResponse({topic:r,payload:o}),this.core.history.delete(r,o.id))}catch(h){this.logger.error(h)}})}registerExpirerEvents(){this.core.expirer.on(Hr.expired,async e=>{const{topic:r}=Np(e.target);r&&this.pairings.keys.includes(r)&&(await this.deletePairing(r,!0),this.events.emit($s.expire,{topic:r}))})}}class BS extends C6{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.records=new Map,this.events=new zr.EventEmitter,this.name=mS,this.version=_S,this.cached=[],this.initialized=!1,this.storagePrefix=ki,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(s=>this.records.set(s.id,s)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.set=(s,o,h)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:s,request:o,chainId:h}),this.records.has(o.id))return;const p={id:o.id,topic:s,request:{method:o.method,params:o.params||null},chainId:h,expiry:Qr(ye.THIRTY_DAYS)};this.records.set(p.id,p),this.events.emit(ui.created,p)},this.resolve=async s=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:s}),!this.records.has(s.id))return;const o=await this.getRecord(s.id);typeof o.response>"u"&&(o.response=Xr(s)?{error:s.error}:{result:s.result},this.records.set(o.id,o),this.events.emit(ui.updated,o))},this.get=async(s,o)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:s,id:o}),await this.getRecord(o)),this.delete=(s,o)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:o}),this.values.forEach(h=>{if(h.topic===s){if(typeof o<"u"&&h.id!==o)return;this.records.delete(h.id),this.events.emit(ui.deleted,h)}})},this.exists=async(s,o)=>(this.isInitialized(),this.records.has(o)?(await this.getRecord(o)).topic===s:!1),this.on=(s,o)=>{this.events.on(s,o)},this.once=(s,o)=>{this.events.once(s,o)},this.off=(s,o)=>{this.events.off(s,o)},this.removeListener=(s,o)=>{this.events.removeListener(s,o)},this.logger=Ze.generateChildLogger(r,this.name)}get context(){return Ze.getLoggerContext(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 e=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;const s={topic:r.topic,request:Yn(r.request.method,r.request.params,r.id),chainId:r.chainId};return e.push(s)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const r=this.records.get(e);if(!r){const{message:s}=he("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(s)}return r}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(ui.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:r}=he("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(ui.created,e=>{const r=ui.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(ui.updated,e=>{const r=ui.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.events.on(ui.deleted,e=>{const r=ui.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:e}),this.persist()}),this.core.heartbeat.on(es.HEARTBEAT_EVENTS.pulse,()=>{this.cleanup()})}cleanup(){try{this.records.forEach(e=>{ye.toMiliseconds(e.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${e.id}`),this.delete(e.topic,e.id))})}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=he("NOT_INITIALIZED",this.name);throw new Error(e)}}}class kS extends $6{constructor(e,r){super(e,r),this.core=e,this.logger=r,this.expirations=new Map,this.events=new zr.EventEmitter,this.name=bS,this.version=wS,this.cached=[],this.initialized=!1,this.storagePrefix=ki,this.init=async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(s=>this.expirations.set(s.target,s)),this.cached=[],this.registerEventListeners(),this.initialized=!0)},this.has=s=>{try{const o=this.formatTarget(s);return typeof this.getExpiration(o)<"u"}catch{return!1}},this.set=(s,o)=>{this.isInitialized();const h=this.formatTarget(s),p={target:h,expiry:o};this.expirations.set(h,p),this.checkExpiry(h,p),this.events.emit(Hr.created,{target:h,expiration:p})},this.get=s=>{this.isInitialized();const o=this.formatTarget(s);return this.getExpiration(o)},this.del=s=>{if(this.isInitialized(),this.has(s)){const o=this.formatTarget(s),h=this.getExpiration(o);this.expirations.delete(o),this.events.emit(Hr.deleted,{target:o,expiration:h})}},this.on=(s,o)=>{this.events.on(s,o)},this.once=(s,o)=>{this.events.once(s,o)},this.off=(s,o)=>{this.events.off(s,o)},this.removeListener=(s,o)=>{this.events.removeListener(s,o)},this.logger=Ze.generateChildLogger(r,this.name)}get context(){return Ze.getLoggerContext(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(e){if(typeof e=="string")return v3(e);if(typeof e=="number")return y3(e);const{message:r}=he("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(r)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(Hr.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:r}=he("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const r=this.expirations.get(e);if(!r){const{message:s}=he("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(s),new Error(s)}return r}checkExpiry(e,r){const{expiry:s}=r;ye.toMiliseconds(s)-Date.now()<=0&&this.expire(e,r)}expire(e,r){this.expirations.delete(e),this.events.emit(Hr.expired,{target:e,expiration:r})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,r)=>this.checkExpiry(r,e))}registerEventListeners(){this.core.heartbeat.on(es.HEARTBEAT_EVENTS.pulse,()=>this.checkExpirations()),this.events.on(Hr.created,e=>{const r=Hr.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Hr.expired,e=>{const r=Hr.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()}),this.events.on(Hr.deleted,e=>{const r=Hr.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=he("NOT_INITIALIZED",this.name);throw new Error(e)}}}class KS extends L6{constructor(e,r){super(e,r),this.projectId=e,this.logger=r,this.name=gu,this.initialized=!1,this.queue=[],this.verifyDisabled=!1,this.init=async s=>{if(this.verifyDisabled||Bs()||!ks())return;const o=this.getVerifyUrl(s==null?void 0:s.verifyUrl);this.verifyUrl!==o&&this.removeIframe(),this.verifyUrl=o;try{await this.createIframe()}catch(h){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(h)}if(!this.initialized){this.removeIframe(),this.verifyUrl=qu;try{await this.createIframe()}catch(h){this.logger.info(`Verify iframe failed to load: ${this.verifyUrl}`),this.logger.info(h),this.verifyDisabled=!0}}},this.register=async s=>{this.initialized?this.sendPost(s.attestationId):(this.addToQueue(s.attestationId),await this.init())},this.resolve=async s=>{if(this.isDevEnv)return"";const o=this.getVerifyUrl(s==null?void 0:s.verifyUrl);let h;try{h=await this.fetchAttestation(s.attestationId,o)}catch(p){this.logger.info(`failed to resolve attestation: ${s.attestationId} from url: ${o}`),this.logger.info(p),h=await this.fetchAttestation(s.attestationId,qu)}return h},this.fetchAttestation=async(s,o)=>{this.logger.info(`resolving attestation: ${s} from url: ${o}`);const h=this.startAbortTimer(ye.ONE_SECOND*2),p=await fetch(`${o}/attestation/${s}`,{signal:this.abortController.signal});return clearTimeout(h),p.status===200?await p.json():void 0},this.addToQueue=s=>{this.queue.push(s)},this.processQueue=()=>{this.queue.length!==0&&(this.queue.forEach(s=>this.sendPost(s)),this.queue=[])},this.sendPost=s=>{var o;try{if(!this.iframe)return;(o=this.iframe.contentWindow)==null||o.postMessage(s,"*"),this.logger.info(`postMessage sent: ${s} ${this.verifyUrl}`)}catch{}},this.createIframe=async()=>{let s;const o=h=>{h.data==="verify_ready"&&(this.initialized=!0,this.processQueue(),window.removeEventListener("message",o),s())};await Promise.race([new Promise(h=>{if(document.getElementById(gu))return h();window.addEventListener("message",o);const p=document.createElement("iframe");p.id=gu,p.src=`${this.verifyUrl}/${this.projectId}`,p.style.display="none",document.body.append(p),this.iframe=p,s=h}),new Promise((h,p)=>setTimeout(()=>{window.removeEventListener("message",o),p("verify iframe load timeout")},ye.toMiliseconds(ye.FIVE_SECONDS)))])},this.removeIframe=()=>{this.iframe&&(this.iframe.remove(),this.iframe=void 0,this.initialized=!1)},this.getVerifyUrl=s=>{let o=s||Vn;return ES.includes(o)||(this.logger.info(`verify url: ${o}, not included in trusted list, assigning default: ${Vn}`),o=Vn),o},this.logger=Ze.generateChildLogger(r,this.name),this.verifyUrl=Vn,this.abortController=new AbortController,this.isDevEnv=Xu()&&{}.IS_VITEST}get context(){return Ze.getLoggerContext(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),ye.toMiliseconds(e))}}var VS=Object.defineProperty,qd=Object.getOwnPropertySymbols,WS=Object.prototype.hasOwnProperty,GS=Object.prototype.propertyIsEnumerable,Hd=(i,e,r)=>e in i?VS(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,zd=(i,e)=>{for(var r in e||(e={}))WS.call(e,r)&&Hd(i,r,e[r]);if(qd)for(var r of qd(e))GS.call(e,r)&&Hd(i,r,e[r]);return i};class ch extends O6{constructor(e){super(e),this.protocol=cg,this.version=G2,this.name=ah,this.events=new zr.EventEmitter,this.initialized=!1,this.on=(s,o)=>this.events.on(s,o),this.once=(s,o)=>this.events.once(s,o),this.off=(s,o)=>this.events.off(s,o),this.removeListener=(s,o)=>this.events.removeListener(s,o),this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||hg,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const r=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:Ze.pino(Ze.getDefaultLoggerOptions({level:(e==null?void 0:e.logger)||Y2.logger}));this.logger=Ze.generateChildLogger(r,this.name),this.heartbeat=new es.HeartBeat,this.crypto=new SS(this,this.logger,e==null?void 0:e.keychain),this.history=new BS(this,this.logger),this.expirer=new kS(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new m6(zd(zd({},J2),e==null?void 0:e.storageOptions)),this.relayer=new MS({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new zS(this,this.logger),this.verify=new KS(this.projectId||"",this.logger)}static async init(e){const r=new ch(e);await r.initialize();const s=await r.crypto.getClientId();return await r.storage.setItem(fS,s),r}get context(){return Ze.getLoggerContext(this.logger)}async start(){this.initialized||await this.initialize()}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const YS=ch,lg="wc",fg=2,dg="client",uh=`${lg}@${fg}:${dg}:`,yu={name:dg,logger:"error",controller:!1,relayUrl:"wss://relay.walletconnect.com"},Bd="WALLETCONNECT_DEEPLINK_CHOICE",JS="proposal",pg="Proposal expired",QS="session",ia=ye.SEVEN_DAYS,XS="engine",As={wc_sessionPropose:{req:{ttl:ye.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:ye.FIVE_MINUTES,prompt:!1,tag:1101}},wc_sessionSettle:{req:{ttl:ye.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:ye.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:ye.ONE_DAY,prompt:!1,tag:1104},res:{ttl:ye.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:ye.ONE_DAY,prompt:!1,tag:1106},res:{ttl:ye.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:ye.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:ye.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:ye.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:ye.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:ye.ONE_DAY,prompt:!1,tag:1112},res:{ttl:ye.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:ye.THIRTY_SECONDS,prompt:!1,tag:1114},res:{ttl:ye.THIRTY_SECONDS,prompt:!1,tag:1115}}},mu={min:ye.FIVE_MINUTES,max:ye.SEVEN_DAYS},Oi={idle:"IDLE",active:"ACTIVE"},ZS="request",e5=["wc_sessionPropose","wc_sessionRequest","wc_authRequest"];var t5=Object.defineProperty,r5=Object.defineProperties,i5=Object.getOwnPropertyDescriptors,kd=Object.getOwnPropertySymbols,n5=Object.prototype.hasOwnProperty,s5=Object.prototype.propertyIsEnumerable,Kd=(i,e,r)=>e in i?t5(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,br=(i,e)=>{for(var r in e||(e={}))n5.call(e,r)&&Kd(i,r,e[r]);if(kd)for(var r of kd(e))s5.call(e,r)&&Kd(i,r,e[r]);return i},Ts=(i,e)=>r5(i,i5(e));class o5 extends F6{constructor(e){super(e),this.name=XS,this.events=new Bu,this.initialized=!1,this.ignoredPayloadTypes=[_n],this.requestQueue={state:Oi.idle,queue:[]},this.sessionRequestQueue={state:Oi.idle,queue:[]},this.requestQueueDelay=ye.ONE_SECOND,this.init=async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),this.client.core.pairing.register({methods:Object.keys(As)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},ye.toMiliseconds(this.requestQueueDelay)))},this.connect=async r=>{await this.isInitialized();const s=Ts(br({},r),{requiredNamespaces:r.requiredNamespaces||{},optionalNamespaces:r.optionalNamespaces||{}});await this.isValidConnect(s);const{pairingTopic:o,requiredNamespaces:h,optionalNamespaces:p,sessionProperties:f,relays:g}=s;let b=o,E,C=!1;if(b&&(C=this.client.core.pairing.pairings.get(b).active),!b||!C){const{topic:$,uri:S}=await this.client.core.pairing.create();b=$,E=S}const N=await this.client.core.crypto.generateKeyPair(),P=br({requiredNamespaces:h,optionalNamespaces:p,relays:g??[{protocol:ug}],proposer:{publicKey:N,metadata:this.client.metadata}},f&&{sessionProperties:f}),{reject:F,resolve:k,done:K}=kn(ye.FIVE_MINUTES,pg);if(this.events.once(zt("session_connect"),async({error:$,session:S})=>{if($)F($);else if(S){S.self.publicKey=N;const I=Ts(br({},S),{requiredNamespaces:S.requiredNamespaces,optionalNamespaces:S.optionalNamespaces});await this.client.session.set(S.topic,I),await this.setExpiry(S.topic,S.expiry),b&&await this.client.core.pairing.updateMetadata({topic:b,metadata:S.peer.metadata}),k(I)}}),!b){const{message:$}=he("NO_MATCHING_KEY",`connect() pairing topic: ${b}`);throw new Error($)}const ee=await this.sendRequest({topic:b,method:"wc_sessionPropose",params:P}),A=Qr(ye.FIVE_MINUTES);return await this.setProposal(ee,br({id:ee,expiry:A},P)),{uri:E,approval:K}},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:s,relayProtocol:o,namespaces:h,sessionProperties:p}=r,f=this.client.proposal.get(s);let{pairingTopic:g,proposer:b,requiredNamespaces:E,optionalNamespaces:C}=f;g=g||"",Gn(E)||(E=R3(h,"approve()"));const N=await this.client.core.crypto.generateKeyPair(),P=b.publicKey,F=await this.client.core.crypto.generateSharedKey(N,P);g&&s&&(await this.client.core.pairing.updateMetadata({topic:g,metadata:b.metadata}),await this.sendResult({id:s,topic:g,result:{relay:{protocol:o??"irn"},responderPublicKey:N}}),await this.client.proposal.delete(s,$t("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:g}));const k=br({relay:{protocol:o??"irn"},namespaces:h,requiredNamespaces:E,optionalNamespaces:C,pairingTopic:g,controller:{publicKey:N,metadata:this.client.metadata},expiry:Qr(ia)},p&&{sessionProperties:p});await this.client.core.relayer.subscribe(F),await this.sendRequest({topic:F,method:"wc_sessionSettle",params:k,throwOnFailedPublish:!0});const K=Ts(br({},k),{topic:F,pairingTopic:g,acknowledged:!1,self:k.controller,peer:{publicKey:b.publicKey,metadata:b.metadata},controller:N});return await this.client.session.set(F,K),await this.setExpiry(F,Qr(ia)),{topic:F,acknowledged:()=>new Promise(ee=>setTimeout(()=>ee(this.client.session.get(F)),500))}},this.reject=async r=>{await this.isInitialized(),await this.isValidReject(r);const{id:s,reason:o}=r,{pairingTopic:h}=this.client.proposal.get(s);h&&(await this.sendError(s,h,o),await this.client.proposal.delete(s,$t("USER_DISCONNECTED")))},this.update=async r=>{await this.isInitialized(),await this.isValidUpdate(r);const{topic:s,namespaces:o}=r,h=await this.sendRequest({topic:s,method:"wc_sessionUpdate",params:{namespaces:o}}),{done:p,resolve:f,reject:g}=kn();return this.events.once(zt("session_update",h),({error:b})=>{b?g(b):f()}),await this.client.session.update(s,{namespaces:o}),{acknowledged:p}},this.extend=async r=>{await this.isInitialized(),await this.isValidExtend(r);const{topic:s}=r,o=await this.sendRequest({topic:s,method:"wc_sessionExtend",params:{}}),{done:h,resolve:p,reject:f}=kn();return this.events.once(zt("session_extend",o),({error:g})=>{g?f(g):p()}),await this.setExpiry(s,Qr(ia)),{acknowledged:h}},this.request=async r=>{await this.isInitialized(),await this.isValidRequest(r);const{chainId:s,request:o,topic:h,expiry:p}=r,f=nh(),{done:g,resolve:b,reject:E}=kn(p,"Request expired. Please try again.");return this.events.once(zt("session_request",f),({error:C,result:N})=>{C?E(C):b(N)}),await Promise.all([new Promise(async C=>{await this.sendRequest({clientRpcId:f,topic:h,method:"wc_sessionRequest",params:{request:o,chainId:s},expiry:p,throwOnFailedPublish:!0}).catch(N=>E(N)),this.client.events.emit("session_request_sent",{topic:h,request:o,chainId:s,id:f}),C()}),new Promise(async C=>{const N=await this.client.core.storage.getItem(Bd);m3({id:f,topic:h,wcDeepLink:N}),C()}),g()]).then(C=>C[2])},this.respond=async r=>{await this.isInitialized(),await this.isValidRespond(r);const{topic:s,response:o}=r,{id:h}=o;Ci(o)?await this.sendResult({id:h,topic:s,result:o.result,throwOnFailedPublish:!0}):Xr(o)&&await this.sendError(h,s,o.error),this.cleanupAfterResponse(r)},this.ping=async r=>{await this.isInitialized(),await this.isValidPing(r);const{topic:s}=r;if(this.client.session.keys.includes(s)){const o=await this.sendRequest({topic:s,method:"wc_sessionPing",params:{}}),{done:h,resolve:p,reject:f}=kn();this.events.once(zt("session_ping",o),({error:g})=>{g?f(g):p()}),await h()}else this.client.core.pairing.pairings.keys.includes(s)&&await this.client.core.pairing.ping({topic:s})},this.emit=async r=>{await this.isInitialized(),await this.isValidEmit(r);const{topic:s,event:o,chainId:h}=r;await this.sendRequest({topic:s,method:"wc_sessionEvent",params:{event:o,chainId:h}})},this.disconnect=async r=>{await this.isInitialized(),await this.isValidDisconnect(r);const{topic:s}=r;this.client.session.keys.includes(s)?(await this.sendRequest({topic:s,method:"wc_sessionDelete",params:$t("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession(s)):await this.client.core.pairing.disconnect({topic:s})},this.find=r=>(this.isInitialized(),this.client.session.getAll().filter(s=>L3(s,r))),this.getPendingSessionRequests=()=>(this.isInitialized(),this.client.pendingRequest.getAll()),this.cleanupDuplicatePairings=async r=>{if(r.pairingTopic)try{const s=this.client.core.pairing.pairings.get(r.pairingTopic),o=this.client.core.pairing.pairings.getAll().filter(h=>{var p,f;return((p=h.peerMetadata)==null?void 0:p.url)&&((f=h.peerMetadata)==null?void 0:f.url)===r.peer.metadata.url&&h.topic&&h.topic!==s.topic});if(o.length===0)return;this.client.logger.info(`Cleaning up ${o.length} duplicate pairing(s)`),await Promise.all(o.map(h=>this.client.core.pairing.disconnect({topic:h.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(s){this.client.logger.error(s)}},this.deleteSession=async(r,s)=>{const{self:o}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),this.client.session.delete(r,$t("USER_DISCONNECTED")),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(r)&&await this.client.core.crypto.deleteSymKey(r),s||this.client.core.expirer.del(r),this.client.core.storage.removeItem(Bd).catch(h=>this.client.logger.warn(h))},this.deleteProposal=async(r,s)=>{await Promise.all([this.client.proposal.delete(r,$t("USER_DISCONNECTED")),s?Promise.resolve():this.client.core.expirer.del(r)])},this.deletePendingSessionRequest=async(r,s,o=!1)=>{await Promise.all([this.client.pendingRequest.delete(r,s),o?Promise.resolve():this.client.core.expirer.del(r)]),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(h=>h.id!==r),o&&(this.sessionRequestQueue.state=Oi.idle)},this.setExpiry=async(r,s)=>{this.client.session.keys.includes(r)&&await this.client.session.update(r,{expiry:s}),this.client.core.expirer.set(r,s)},this.setProposal=async(r,s)=>{await this.client.proposal.set(r,s),this.client.core.expirer.set(r,s.expiry)},this.setPendingSessionRequest=async r=>{const s=As.wc_sessionRequest.req.ttl,{id:o,topic:h,params:p,verifyContext:f}=r;await this.client.pendingRequest.set(o,{id:o,topic:h,params:p,verifyContext:f}),s&&this.client.core.expirer.set(o,Qr(s))},this.sendRequest=async r=>{const{topic:s,method:o,params:h,expiry:p,relayRpcId:f,clientRpcId:g,throwOnFailedPublish:b}=r,E=Yn(o,h,g);if(ks()&&e5.includes(o)){const P=Wn(JSON.stringify(E));this.client.core.verify.register({attestationId:P})}const C=await this.client.core.crypto.encode(s,E),N=As[o].req;return p&&(N.ttl=p),f&&(N.id=f),this.client.core.history.set(s,E),b?(N.internal=Ts(br({},N.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,C,N)):this.client.core.relayer.publish(s,C,N).catch(P=>this.client.logger.error(P)),E.id},this.sendResult=async r=>{const{id:s,topic:o,result:h,throwOnFailedPublish:p}=r,f=sh(s,h),g=await this.client.core.crypto.encode(o,f),b=await this.client.core.history.get(o,s),E=As[b.request.method].res;p?(E.internal=Ts(br({},E.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(o,g,E)):this.client.core.relayer.publish(o,g,E).catch(C=>this.client.logger.error(C)),await this.client.core.history.resolve(f)},this.sendError=async(r,s,o)=>{const h=Sa(r,o),p=await this.client.core.crypto.encode(s,h),f=await this.client.core.history.get(s,r),g=As[f.request.method].res;this.client.core.relayer.publish(s,p,g),await this.client.core.history.resolve(h)},this.cleanup=async()=>{const r=[],s=[];this.client.session.getAll().forEach(o=>{Bi(o.expiry)&&r.push(o.topic)}),this.client.proposal.getAll().forEach(o=>{Bi(o.expiry)&&s.push(o.id)}),await Promise.all([...r.map(o=>this.deleteSession(o)),...s.map(o=>this.deleteProposal(o))])},this.onRelayEventRequest=async r=>{this.requestQueue.queue.push(r),await this.processRequestsQueue()},this.processRequestsQueue=async()=>{if(this.requestQueue.state===Oi.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=Oi.active;const r=this.requestQueue.queue.shift();if(r)try{this.processRequest(r),await new Promise(s=>setTimeout(s,300))}catch(s){this.client.logger.warn(s)}}this.requestQueue.state=Oi.idle},this.processRequest=r=>{const{topic:s,payload:o}=r,h=o.method;switch(h){case"wc_sessionPropose":return this.onSessionProposeRequest(s,o);case"wc_sessionSettle":return this.onSessionSettleRequest(s,o);case"wc_sessionUpdate":return this.onSessionUpdateRequest(s,o);case"wc_sessionExtend":return this.onSessionExtendRequest(s,o);case"wc_sessionPing":return this.onSessionPingRequest(s,o);case"wc_sessionDelete":return this.onSessionDeleteRequest(s,o);case"wc_sessionRequest":return this.onSessionRequest(s,o);case"wc_sessionEvent":return this.onSessionEventRequest(s,o);default:return this.client.logger.info(`Unsupported request method ${h}`)}},this.onRelayEventResponse=async r=>{const{topic:s,payload:o}=r,h=(await this.client.core.history.get(s,o.id)).request.method;switch(h){case"wc_sessionPropose":return this.onSessionProposeResponse(s,o);case"wc_sessionSettle":return this.onSessionSettleResponse(s,o);case"wc_sessionUpdate":return this.onSessionUpdateResponse(s,o);case"wc_sessionExtend":return this.onSessionExtendResponse(s,o);case"wc_sessionPing":return this.onSessionPingResponse(s,o);case"wc_sessionRequest":return this.onSessionRequestResponse(s,o);default:return this.client.logger.info(`Unsupported response method ${h}`)}},this.onRelayEventUnknownPayload=r=>{const{topic:s}=r,{message:o}=he("MISSING_OR_INVALID",`Decoded payload on topic ${s} is not identifiable as a JSON-RPC request or a response.`);throw new Error(o)},this.onSessionProposeRequest=async(r,s)=>{const{params:o,id:h}=s;try{this.isValidConnect(br({},s.params));const p=Qr(ye.FIVE_MINUTES),f=br({id:h,pairingTopic:r,expiry:p},o);await this.setProposal(h,f);const g=Wn(JSON.stringify(s)),b=await this.getVerifyContext(g,f.proposer.metadata);this.client.events.emit("session_proposal",{id:h,params:f,verifyContext:b})}catch(p){await this.sendError(h,r,p),this.client.logger.error(p)}},this.onSessionProposeResponse=async(r,s)=>{const{id:o}=s;if(Ci(s)){const{result:h}=s;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:h});const p=this.client.proposal.get(o);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:p});const f=p.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:f});const g=h.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:g});const b=await this.client.core.crypto.generateSharedKey(f,g);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",sessionTopic:b});const E=await this.client.core.relayer.subscribe(b);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:E}),await this.client.core.pairing.activate({topic:r})}else Xr(s)&&(await this.client.proposal.delete(o,$t("USER_DISCONNECTED")),this.events.emit(zt("session_connect"),{error:s.error}))},this.onSessionSettleRequest=async(r,s)=>{const{id:o,params:h}=s;try{this.isValidSessionSettleRequest(h);const{relay:p,controller:f,expiry:g,namespaces:b,requiredNamespaces:E,optionalNamespaces:C,sessionProperties:N,pairingTopic:P}=s.params,F=br({topic:r,relay:p,expiry:g,namespaces:b,acknowledged:!0,pairingTopic:P,requiredNamespaces:E,optionalNamespaces:C,controller:f.publicKey,self:{publicKey:"",metadata:this.client.metadata},peer:{publicKey:f.publicKey,metadata:f.metadata}},N&&{sessionProperties:N});await this.sendResult({id:s.id,topic:r,result:!0}),this.events.emit(zt("session_connect"),{session:F}),this.cleanupDuplicatePairings(F)}catch(p){await this.sendError(o,r,p),this.client.logger.error(p)}},this.onSessionSettleResponse=async(r,s)=>{const{id:o}=s;Ci(s)?(await this.client.session.update(r,{acknowledged:!0}),this.events.emit(zt("session_approve",o),{})):Xr(s)&&(await this.client.session.delete(r,$t("USER_DISCONNECTED")),this.events.emit(zt("session_approve",o),{error:s.error}))},this.onSessionUpdateRequest=async(r,s)=>{const{params:o,id:h}=s;try{const p=`${r}_session_update`,f=ra.get(p);if(f&&this.isRequestOutOfSync(f,h)){this.client.logger.info(`Discarding out of sync request - ${h}`);return}this.isValidUpdate(br({topic:r},o)),await this.client.session.update(r,{namespaces:o.namespaces}),await this.sendResult({id:h,topic:r,result:!0}),this.client.events.emit("session_update",{id:h,topic:r,params:o}),ra.set(p,h)}catch(p){await this.sendError(h,r,p),this.client.logger.error(p)}},this.isRequestOutOfSync=(r,s)=>parseInt(s.toString().slice(0,-3))<=parseInt(r.toString().slice(0,-3)),this.onSessionUpdateResponse=(r,s)=>{const{id:o}=s;Ci(s)?this.events.emit(zt("session_update",o),{}):Xr(s)&&this.events.emit(zt("session_update",o),{error:s.error})},this.onSessionExtendRequest=async(r,s)=>{const{id:o}=s;try{this.isValidExtend({topic:r}),await this.setExpiry(r,Qr(ia)),await this.sendResult({id:o,topic:r,result:!0}),this.client.events.emit("session_extend",{id:o,topic:r})}catch(h){await this.sendError(o,r,h),this.client.logger.error(h)}},this.onSessionExtendResponse=(r,s)=>{const{id:o}=s;Ci(s)?this.events.emit(zt("session_extend",o),{}):Xr(s)&&this.events.emit(zt("session_extend",o),{error:s.error})},this.onSessionPingRequest=async(r,s)=>{const{id:o}=s;try{this.isValidPing({topic:r}),await this.sendResult({id:o,topic:r,result:!0}),this.client.events.emit("session_ping",{id:o,topic:r})}catch(h){await this.sendError(o,r,h),this.client.logger.error(h)}},this.onSessionPingResponse=(r,s)=>{const{id:o}=s;setTimeout(()=>{Ci(s)?this.events.emit(zt("session_ping",o),{}):Xr(s)&&this.events.emit(zt("session_ping",o),{error:s.error})},500)},this.onSessionDeleteRequest=async(r,s)=>{const{id:o}=s;try{this.isValidDisconnect({topic:r,reason:s.params}),await Promise.all([new Promise(h=>{this.client.core.relayer.once(ir.publish,async()=>{h(await this.deleteSession(r))})}),this.sendResult({id:o,topic:r,result:!0})]),this.client.events.emit("session_delete",{id:o,topic:r})}catch(h){this.client.logger.error(h)}},this.onSessionRequest=async(r,s)=>{const{id:o,params:h}=s;try{this.isValidRequest(br({topic:r},h));const p=Wn(JSON.stringify(Yn("wc_sessionRequest",h,o))),f=this.client.session.get(r),g=await this.getVerifyContext(p,f.peer.metadata),b={id:o,topic:r,params:h,verifyContext:g};await this.setPendingSessionRequest(b),this.addSessionRequestToSessionRequestQueue(b),this.processSessionRequestQueue()}catch(p){await this.sendError(o,r,p),this.client.logger.error(p)}},this.onSessionRequestResponse=(r,s)=>{const{id:o}=s;Ci(s)?this.events.emit(zt("session_request",o),{result:s.result}):Xr(s)&&this.events.emit(zt("session_request",o),{error:s.error})},this.onSessionEventRequest=async(r,s)=>{const{id:o,params:h}=s;try{const p=`${r}_session_event_${h.event.name}`,f=ra.get(p);if(f&&this.isRequestOutOfSync(f,o)){this.client.logger.info(`Discarding out of sync request - ${o}`);return}this.isValidEmit(br({topic:r},h)),this.client.events.emit("session_event",{id:o,topic:r,params:h}),ra.set(p,o)}catch(p){await this.sendError(o,r,p),this.client.logger.error(p)}},this.addSessionRequestToSessionRequestQueue=r=>{this.sessionRequestQueue.queue.push(r)},this.cleanupAfterResponse=r=>{this.deletePendingSessionRequest(r.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Oi.idle,this.processSessionRequestQueue()},ye.toMiliseconds(this.requestQueueDelay))},this.processSessionRequestQueue=()=>{if(this.sessionRequestQueue.state===Oi.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=Oi.active,this.client.events.emit("session_request",r)}catch(s){this.client.logger.error(s)}},this.onPairingCreated=r=>{if(r.active)return;const s=this.client.proposal.getAll().find(o=>o.pairingTopic===r.topic);s&&this.onSessionProposeRequest(r.topic,Yn("wc_sessionPropose",{requiredNamespaces:s.requiredNamespaces,optionalNamespaces:s.optionalNamespaces,relays:s.relays,proposer:s.proposer},s.id))},this.isValidConnect=async r=>{if(!wr(r)){const{message:g}=he("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(r)}`);throw new Error(g)}const{pairingTopic:s,requiredNamespaces:o,optionalNamespaces:h,sessionProperties:p,relays:f}=r;if(lr(s)||await this.isValidPairingTopic(s),!W3(f,!0)){const{message:g}=he("MISSING_OR_INVALID",`connect() relays: ${f}`);throw new Error(g)}!lr(o)&&Gn(o)!==0&&this.validateNamespaces(o,"requiredNamespaces"),!lr(h)&&Gn(h)!==0&&this.validateNamespaces(h,"optionalNamespaces"),lr(p)||this.validateSessionProps(p,"sessionProperties")},this.validateNamespaces=(r,s)=>{const o=V3(r,"connect()",s);if(o)throw new Error(o.message)},this.isValidApprove=async r=>{if(!wr(r))throw new Error(he("MISSING_OR_INVALID",`approve() params: ${r}`).message);const{id:s,namespaces:o,relayProtocol:h,sessionProperties:p}=r;await this.isValidProposalId(s);const f=this.client.proposal.get(s),g=aa(o,"approve()");if(g)throw new Error(g.message);const b=Xf(f.requiredNamespaces,o,"approve()");if(b)throw new Error(b.message);if(!Gt(h,!0)){const{message:E}=he("MISSING_OR_INVALID",`approve() relayProtocol: ${h}`);throw new Error(E)}lr(p)||this.validateSessionProps(p,"sessionProperties")},this.isValidReject=async r=>{if(!wr(r)){const{message:h}=he("MISSING_OR_INVALID",`reject() params: ${r}`);throw new Error(h)}const{id:s,reason:o}=r;if(await this.isValidProposalId(s),!Y3(o)){const{message:h}=he("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(o)}`);throw new Error(h)}},this.isValidSessionSettleRequest=r=>{if(!wr(r)){const{message:b}=he("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${r}`);throw new Error(b)}const{relay:s,controller:o,namespaces:h,expiry:p}=r;if(!Lp(s)){const{message:b}=he("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(b)}const f=q3(o,"onSessionSettleRequest()");if(f)throw new Error(f.message);const g=aa(h,"onSessionSettleRequest()");if(g)throw new Error(g.message);if(Bi(p)){const{message:b}=he("EXPIRED","onSessionSettleRequest()");throw new Error(b)}},this.isValidUpdate=async r=>{if(!wr(r)){const{message:g}=he("MISSING_OR_INVALID",`update() params: ${r}`);throw new Error(g)}const{topic:s,namespaces:o}=r;await this.isValidSessionTopic(s);const h=this.client.session.get(s),p=aa(o,"update()");if(p)throw new Error(p.message);const f=Xf(h.requiredNamespaces,o,"update()");if(f)throw new Error(f.message)},this.isValidExtend=async r=>{if(!wr(r)){const{message:o}=he("MISSING_OR_INVALID",`extend() params: ${r}`);throw new Error(o)}const{topic:s}=r;await this.isValidSessionTopic(s)},this.isValidRequest=async r=>{if(!wr(r)){const{message:g}=he("MISSING_OR_INVALID",`request() params: ${r}`);throw new Error(g)}const{topic:s,request:o,chainId:h,expiry:p}=r;await this.isValidSessionTopic(s);const{namespaces:f}=this.client.session.get(s);if(!Qf(f,h)){const{message:g}=he("MISSING_OR_INVALID",`request() chainId: ${h}`);throw new Error(g)}if(!J3(o)){const{message:g}=he("MISSING_OR_INVALID",`request() ${JSON.stringify(o)}`);throw new Error(g)}if(!Z3(f,h,o.method)){const{message:g}=he("MISSING_OR_INVALID",`request() method: ${o.method}`);throw new Error(g)}if(p&&!i6(p,mu)){const{message:g}=he("MISSING_OR_INVALID",`request() expiry: ${p}. Expiry must be a number (in seconds) between ${mu.min} and ${mu.max}`);throw new Error(g)}},this.isValidRespond=async r=>{if(!wr(r)){const{message:h}=he("MISSING_OR_INVALID",`respond() params: ${r}`);throw new Error(h)}const{topic:s,response:o}=r;if(await this.isValidSessionTopic(s),!Q3(o)){const{message:h}=he("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(o)}`);throw new Error(h)}},this.isValidPing=async r=>{if(!wr(r)){const{message:o}=he("MISSING_OR_INVALID",`ping() params: ${r}`);throw new Error(o)}const{topic:s}=r;await this.isValidSessionOrPairingTopic(s)},this.isValidEmit=async r=>{if(!wr(r)){const{message:f}=he("MISSING_OR_INVALID",`emit() params: ${r}`);throw new Error(f)}const{topic:s,event:o,chainId:h}=r;await this.isValidSessionTopic(s);const{namespaces:p}=this.client.session.get(s);if(!Qf(p,h)){const{message:f}=he("MISSING_OR_INVALID",`emit() chainId: ${h}`);throw new Error(f)}if(!X3(o)){const{message:f}=he("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(o)}`);throw new Error(f)}if(!e6(p,h,o.name)){const{message:f}=he("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(o)}`);throw new Error(f)}},this.isValidDisconnect=async r=>{if(!wr(r)){const{message:o}=he("MISSING_OR_INVALID",`disconnect() params: ${r}`);throw new Error(o)}const{topic:s}=r;await this.isValidSessionOrPairingTopic(s)},this.getVerifyContext=async(r,s)=>{const o={verified:{verifyUrl:s.verifyUrl||Vn,validation:"UNKNOWN",origin:s.url||""}};try{const h=await this.client.core.verify.resolve({attestationId:r,verifyUrl:s.verifyUrl});h&&(o.verified.origin=h.origin,o.verified.isScam=h.isScam,o.verified.validation=h.origin===new URL(s.url).origin?"VALID":"INVALID")}catch(h){this.client.logger.info(h)}return this.client.logger.info(`Verify context: ${JSON.stringify(o)}`),o},this.validateSessionProps=(r,s)=>{Object.values(r).forEach(o=>{if(!Gt(o,!1)){const{message:h}=he("MISSING_OR_INVALID",`${s} must be in Record<string, string> format. Received: ${JSON.stringify(o)}`);throw new Error(h)}})}}async isInitialized(){if(!this.initialized){const{message:e}=he("NOT_INITIALIZED",this.name);throw new Error(e)}await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(ir.message,async e=>{const{topic:r,message:s}=e;if(this.ignoredPayloadTypes.includes(this.client.core.crypto.getPayloadType(s)))return;const o=await this.client.core.crypto.decode(r,s);try{oh(o)?(this.client.core.history.set(r,o),this.onRelayEventRequest({topic:r,payload:o})):Ia(o)?(await this.client.core.history.resolve(o),await this.onRelayEventResponse({topic:r,payload:o}),this.client.core.history.delete(r,o.id)):this.onRelayEventUnknownPayload({topic:r,payload:o})}catch(h){this.client.logger.error(h)}})}registerExpirerEvents(){this.client.core.expirer.on(Hr.expired,async e=>{const{topic:r,id:s}=Np(e.target);if(s&&this.client.pendingRequest.keys.includes(s))return await this.deletePendingSessionRequest(s,he("EXPIRED"),!0);r?this.client.session.keys.includes(r)&&(await this.deleteSession(r,!0),this.client.events.emit("session_expire",{topic:r})):s&&(await this.deleteProposal(s,!0),this.client.events.emit("proposal_expire",{id:s}))})}registerPairingEvents(){this.client.core.pairing.events.on($s.create,e=>this.onPairingCreated(e))}isValidPairingTopic(e){if(!Gt(e,!1)){const{message:r}=he("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(r)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:r}=he("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(r)}if(Bi(this.client.core.pairing.pairings.get(e).expiry)){const{message:r}=he("EXPIRED",`pairing topic: ${e}`);throw new Error(r)}}async isValidSessionTopic(e){if(!Gt(e,!1)){const{message:r}=he("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(r)}if(!this.client.session.keys.includes(e)){const{message:r}=he("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(r)}if(Bi(this.client.session.get(e).expiry)){await this.deleteSession(e);const{message:r}=he("EXPIRED",`session topic: ${e}`);throw new Error(r)}}async isValidSessionOrPairingTopic(e){if(this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(Gt(e,!1)){const{message:r}=he("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(r)}else{const{message:r}=he("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(r)}}async isValidProposalId(e){if(!G3(e)){const{message:r}=he("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(r)}if(!this.client.proposal.keys.includes(e)){const{message:r}=he("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(r)}if(Bi(this.client.proposal.get(e).expiry)){await this.deleteProposal(e);const{message:r}=he("EXPIRED",`proposal id: ${e}`);throw new Error(r)}}}class a5 extends Oa{constructor(e,r){super(e,r,JS,uh),this.core=e,this.logger=r}}class c5 extends Oa{constructor(e,r){super(e,r,QS,uh),this.core=e,this.logger=r}}class u5 extends Oa{constructor(e,r){super(e,r,ZS,uh,s=>s.id),this.core=e,this.logger=r}}let h5=class gg extends U6{constructor(e){super(e),this.protocol=lg,this.version=fg,this.name=yu.name,this.events=new zr.EventEmitter,this.on=(s,o)=>this.events.on(s,o),this.once=(s,o)=>this.events.once(s,o),this.off=(s,o)=>this.events.off(s,o),this.removeListener=(s,o)=>this.events.removeListener(s,o),this.removeAllListeners=s=>this.events.removeAllListeners(s),this.connect=async s=>{try{return await this.engine.connect(s)}catch(o){throw this.logger.error(o.message),o}},this.pair=async s=>{try{return await this.engine.pair(s)}catch(o){throw this.logger.error(o.message),o}},this.approve=async s=>{try{return await this.engine.approve(s)}catch(o){throw this.logger.error(o.message),o}},this.reject=async s=>{try{return await this.engine.reject(s)}catch(o){throw this.logger.error(o.message),o}},this.update=async s=>{try{return await this.engine.update(s)}catch(o){throw this.logger.error(o.message),o}},this.extend=async s=>{try{return await this.engine.extend(s)}catch(o){throw this.logger.error(o.message),o}},this.request=async s=>{try{return await this.engine.request(s)}catch(o){throw this.logger.error(o.message),o}},this.respond=async s=>{try{return await this.engine.respond(s)}catch(o){throw this.logger.error(o.message),o}},this.ping=async s=>{try{return await this.engine.ping(s)}catch(o){throw this.logger.error(o.message),o}},this.emit=async s=>{try{return await this.engine.emit(s)}catch(o){throw this.logger.error(o.message),o}},this.disconnect=async s=>{try{return await this.engine.disconnect(s)}catch(o){throw this.logger.error(o.message),o}},this.find=s=>{try{return this.engine.find(s)}catch(o){throw this.logger.error(o.message),o}},this.getPendingSessionRequests=()=>{try{return this.engine.getPendingSessionRequests()}catch(s){throw this.logger.error(s.message),s}},this.name=(e==null?void 0:e.name)||yu.name,this.metadata=(e==null?void 0:e.metadata)||l3();const r=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:Ze.pino(Ze.getDefaultLoggerOptions({level:(e==null?void 0:e.logger)||yu.logger}));this.core=(e==null?void 0:e.core)||new YS(e),this.logger=Ze.generateChildLogger(r,this.name),this.session=new c5(this.core,this.logger),this.proposal=new a5(this.core,this.logger),this.pendingRequest=new u5(this.core,this.logger),this.engine=new o5(this)}static async init(e){const r=new gg(e);return await r.initialize(),r}get context(){return Ze.getLoggerContext(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.engine.init(),this.core.verify.init({verifyUrl:this.metadata.verifyUrl}),this.logger.info("SignClient Initialization Success")}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};const l5={Accept:"application/json","Content-Type":"application/json"},f5="POST",Vd={headers:l5,method:f5},Wd=10;class Gi{constructor(e,r=!1){if(this.url=e,this.disableProviderPing=r,this.events=new zr.EventEmitter,this.isAvailable=!1,this.registering=!1,!bd(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);this.url=e,this.disableProviderPing=r}get connected(){return this.isAvailable}get connecting(){return this.registering}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}off(e,r){this.events.off(e,r)}removeListener(e,r){this.events.removeListener(e,r)}async open(e=this.url){await this.register(e)}async close(){if(!this.isAvailable)throw new Error("Connection already closed");this.onClose()}async send(e,r){this.isAvailable||await this.register();try{const s=js(e),h=await(await lf(this.url,Object.assign(Object.assign({},Vd),{body:s}))).json();this.onPayload({data:h})}catch(s){this.onError(e.id,s)}}async register(e=this.url){if(!bd(e))throw new Error(`Provided URL is not compatible with HTTP connection: ${e}`);if(this.registering){const r=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((s,o)=>{this.events.once("register_error",h=>{this.resetMaxListeners(),o(h)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.isAvailable>"u")return o(new Error("HTTP connection is missing or invalid"));s()})})}this.url=e,this.registering=!0;try{if(!this.disableProviderPing){const r=js({id:1,jsonrpc:"2.0",method:"test",params:[]});await lf(e,Object.assign(Object.assign({},Vd),{body:r}))}this.onOpen()}catch(r){const s=this.parseError(r);throw this.events.emit("register_error",s),this.onClose(),s}}onOpen(){this.isAvailable=!0,this.registering=!1,this.events.emit("open")}onClose(){this.isAvailable=!1,this.registering=!1,this.events.emit("close")}onPayload(e){if(typeof e.data>"u")return;const r=typeof e.data=="string"?th(e.data):e.data;this.events.emit("payload",r)}onError(e,r){const s=this.parseError(r),o=s.message||s.toString(),h=Sa(e,o);this.events.emit("payload",h)}parseError(e,r=this.url){return Vp(e,r,"HTTP")}resetMaxListeners(){this.events.getMaxListeners()>Wd&&this.events.setMaxListeners(Wd)}}const Gd="error",d5="wss://relay.walletconnect.com",p5="wc",g5="universal_provider",Yd=`${p5}@2:${g5}:`,v5="https://rpc.walletconnect.com/v1/",Ai={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var Rs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof Et<"u"?Et:typeof self<"u"?self:{},Hu={exports:{}};/**
|
|
8
|
+
* @license
|
|
9
|
+
* Lodash <https://lodash.com/>
|
|
10
|
+
* Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
|
|
11
|
+
* Released under MIT license <https://lodash.com/license>
|
|
12
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
13
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
14
|
+
*/(function(i,e){(function(){var r,s="4.17.21",o=200,h="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",p="Expected a function",f="Invalid `variable` option passed into `_.template`",g="__lodash_hash_undefined__",b=500,E="__lodash_placeholder__",C=1,N=2,P=4,F=1,k=2,K=1,ee=2,A=4,$=8,S=16,I=32,_=64,c=128,m=256,B=512,z=30,W="...",oe=800,fe=16,T=1,H=2,ce=3,ie=1/0,Y=9007199254740991,re=17976931348623157e292,J=0/0,ne=4294967295,xe=ne-1,se=ne>>>1,be=[["ary",c],["bind",K],["bindKey",ee],["curry",$],["curryRight",S],["flip",B],["partial",I],["partialRight",_],["rearg",m]],le="[object Arguments]",me="[object Array]",q="[object AsyncFunction]",j="[object Boolean]",R="[object Date]",l="[object DOMException]",x="[object Error]",ae="[object Function]",de="[object GeneratorFunction]",Se="[object Map]",ze="[object Number]",Ke="[object Null]",Fe="[object Object]",pt="[object Promise]",gt="[object Proxy]",je="[object RegExp]",Ie="[object Set]",Ne="[object String]",$e="[object Symbol]",qe="[object Undefined]",Ce="[object WeakMap]",Le="[object WeakSet]",De="[object ArrayBuffer]",Pe="[object DataView]",Be="[object Float32Array]",Oe="[object Float64Array]",Ve="[object Int8Array]",Ge="[object Int16Array]",et="[object Int32Array]",tt="[object Uint8Array]",Je="[object Uint8ClampedArray]",nr="[object Uint16Array]",pr="[object Uint32Array]",ei=/\b__p \+= '';/g,sr=/\b(__p \+=) '' \+/g,fi=/(__e\(.*?\)|\b__t\)) \+\n'';/g,Ti=/&(?:amp|lt|gt|quot|#39);/g,Yi=/[&<>"']/g,Dt=RegExp(Ti.source),vt=RegExp(Yi.source),St=/<%-([\s\S]+?)%>/g,It=/<%([\s\S]+?)%>/g,bt=/<%=([\s\S]+?)%>/g,yt=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Lt=/^\w*$/,Ut=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,xt=/[\\^$.*+?()[\]{}|]/g,Ft=RegExp(xt.source),Ot=/^\s+/,At=/\s/,Ct=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,ht=/\{\n\/\* \[wrapped with (.+)\] \*/,Mt=/,? & /,jt=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Pa=/[()=,{}\[\]\/\s]/,Aa=/\\(\\)?/g,Ta=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,Rr=/\w*$/,Ra=/^[-+]0x[0-9a-f]+$/i,Na=/^0b[01]+$/i,$a=/^\[object .+?Constructor\]$/,La=/^0o[0-7]+$/i,Ua=/^(?:0|[1-9]\d*)$/,di=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,En=/($^)/,Fa=/['\n\r\u2028\u2029\\]/g,Dn="\\ud800-\\udfff",Ma="\\u0300-\\u036f",ja="\\ufe20-\\ufe2f",Sn="\\u20d0-\\u20ff",Gs=Ma+ja+Sn,Ys="\\u2700-\\u27bf",kr="a-z\\xdf-\\xf6\\xf8-\\xff",qa="\\xac\\xb1\\xd7\\xf7",Ha="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",za="\\u2000-\\u206f",Ba=" \\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",Js="A-Z\\xc0-\\xd6\\xd8-\\xde",Qs="\\ufe0e\\ufe0f",Ji=qa+Ha+za+Ba,ts="['’]",Qi="["+Dn+"]",rs="["+Ji+"]",Xi="["+Gs+"]",Xs="\\d+",ka="["+Ys+"]",Zs="["+kr+"]",eo="[^"+Dn+Ji+Xs+Ys+kr+Js+"]",In="\\ud83c[\\udffb-\\udfff]",Ka="(?:"+Xi+"|"+In+")",to="[^"+Dn+"]",xn="(?:\\ud83c[\\udde6-\\uddff]){2}",Ri="[\\ud800-\\udbff][\\udc00-\\udfff]",Dr="["+Js+"]",ro="\\u200d",io="(?:"+Zs+"|"+eo+")",ti="(?:"+Dr+"|"+eo+")",no="(?:"+ts+"(?:d|ll|m|re|s|t|ve))?",so="(?:"+ts+"(?:D|LL|M|RE|S|T|VE))?",oo=Ka+"?",ao="["+Qs+"]?",Va="(?:"+ro+"(?:"+[to,xn,Ri].join("|")+")"+ao+oo+")*",pi="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",co="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",uo=ao+oo+Va,On="(?:"+[ka,xn,Ri].join("|")+")"+uo,Wa="(?:"+[to+Xi+"?",Xi,xn,Ri,Qi].join("|")+")",is=RegExp(ts,"g"),Ga=RegExp(Xi,"g"),Cn=RegExp(In+"(?="+In+")|"+Wa+uo,"g"),ho=RegExp([Dr+"?"+Zs+"+"+no+"(?="+[rs,Dr,"$"].join("|")+")",ti+"+"+so+"(?="+[rs,Dr+io,"$"].join("|")+")",Dr+"?"+io+"+"+no,Dr+"+"+so,co,pi,Xs,On].join("|"),"g"),lo=RegExp("["+ro+Dn+Gs+Qs+"]"),Zi=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,fo=["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"],Ya=-1,ot={};ot[Be]=ot[Oe]=ot[Ve]=ot[Ge]=ot[et]=ot[tt]=ot[Je]=ot[nr]=ot[pr]=!0,ot[le]=ot[me]=ot[De]=ot[j]=ot[Pe]=ot[R]=ot[x]=ot[ae]=ot[Se]=ot[ze]=ot[Fe]=ot[je]=ot[Ie]=ot[Ne]=ot[Ce]=!1;var st={};st[le]=st[me]=st[De]=st[Pe]=st[j]=st[R]=st[Be]=st[Oe]=st[Ve]=st[Ge]=st[et]=st[Se]=st[ze]=st[Fe]=st[je]=st[Ie]=st[Ne]=st[$e]=st[tt]=st[Je]=st[nr]=st[pr]=!0,st[x]=st[ae]=st[Ce]=!1;var w={À:"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"},L={"&":"&","<":"<",">":">",'"':""","'":"'"},Z={"&":"&","<":"<",">":">",""":'"',"'":"'"},pe={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},at=parseFloat,Te=parseInt,ft=typeof Rs=="object"&&Rs&&Rs.Object===Object&&Rs,qt=typeof self=="object"&&self&&self.Object===Object&&self,Qe=ft||qt||Function("return this")(),ct=e&&!e.nodeType&&e,Tt=ct&&!0&&i&&!i.nodeType&&i,gr=Tt&&Tt.exports===ct,Ht=gr&&ft.process,dt=function(){try{var U=Tt&&Tt.require&&Tt.require("util").types;return U||Ht&&Ht.binding&&Ht.binding("util")}catch{}}(),or=dt&&dt.isArrayBuffer,Kr=dt&&dt.isDate,Nr=dt&&dt.isMap,ri=dt&&dt.isRegExp,ns=dt&&dt.isSet,en=dt&&dt.isTypedArray;function Kt(U,G,V){switch(V.length){case 0:return U.call(G);case 1:return U.call(G,V[0]);case 2:return U.call(G,V[0],V[1]);case 3:return U.call(G,V[0],V[1],V[2])}return U.apply(G,V)}function bg(U,G,V,ge){for(var Ae=-1,rt=U==null?0:U.length;++Ae<rt;){var Bt=U[Ae];G(ge,Bt,V(Bt),U)}return ge}function $r(U,G){for(var V=-1,ge=U==null?0:U.length;++V<ge&&G(U[V],V,U)!==!1;);return U}function wg(U,G){for(var V=U==null?0:U.length;V--&&G(U[V],V,U)!==!1;);return U}function lh(U,G){for(var V=-1,ge=U==null?0:U.length;++V<ge;)if(!G(U[V],V,U))return!1;return!0}function Ni(U,G){for(var V=-1,ge=U==null?0:U.length,Ae=0,rt=[];++V<ge;){var Bt=U[V];G(Bt,V,U)&&(rt[Ae++]=Bt)}return rt}function po(U,G){var V=U==null?0:U.length;return!!V&&Pn(U,G,0)>-1}function Ja(U,G,V){for(var ge=-1,Ae=U==null?0:U.length;++ge<Ae;)if(V(G,U[ge]))return!0;return!1}function mt(U,G){for(var V=-1,ge=U==null?0:U.length,Ae=Array(ge);++V<ge;)Ae[V]=G(U[V],V,U);return Ae}function $i(U,G){for(var V=-1,ge=G.length,Ae=U.length;++V<ge;)U[Ae+V]=G[V];return U}function Qa(U,G,V,ge){var Ae=-1,rt=U==null?0:U.length;for(ge&&rt&&(V=U[++Ae]);++Ae<rt;)V=G(V,U[Ae],Ae,U);return V}function Eg(U,G,V,ge){var Ae=U==null?0:U.length;for(ge&&Ae&&(V=U[--Ae]);Ae--;)V=G(V,U[Ae],Ae,U);return V}function Xa(U,G){for(var V=-1,ge=U==null?0:U.length;++V<ge;)if(G(U[V],V,U))return!0;return!1}var Dg=Za("length");function Sg(U){return U.split("")}function Ig(U){return U.match(jt)||[]}function fh(U,G,V){var ge;return V(U,function(Ae,rt,Bt){if(G(Ae,rt,Bt))return ge=rt,!1}),ge}function go(U,G,V,ge){for(var Ae=U.length,rt=V+(ge?1:-1);ge?rt--:++rt<Ae;)if(G(U[rt],rt,U))return rt;return-1}function Pn(U,G,V){return G===G?Fg(U,G,V):go(U,dh,V)}function xg(U,G,V,ge){for(var Ae=V-1,rt=U.length;++Ae<rt;)if(ge(U[Ae],G))return Ae;return-1}function dh(U){return U!==U}function ph(U,G){var V=U==null?0:U.length;return V?tc(U,G)/V:J}function Za(U){return function(G){return G==null?r:G[U]}}function ec(U){return function(G){return U==null?r:U[G]}}function gh(U,G,V,ge,Ae){return Ae(U,function(rt,Bt,ut){V=ge?(ge=!1,rt):G(V,rt,Bt,ut)}),V}function Og(U,G){var V=U.length;for(U.sort(G);V--;)U[V]=U[V].value;return U}function tc(U,G){for(var V,ge=-1,Ae=U.length;++ge<Ae;){var rt=G(U[ge]);rt!==r&&(V=V===r?rt:V+rt)}return V}function rc(U,G){for(var V=-1,ge=Array(U);++V<U;)ge[V]=G(V);return ge}function Cg(U,G){return mt(G,function(V){return[V,U[V]]})}function vh(U){return U&&U.slice(0,bh(U)+1).replace(Ot,"")}function Sr(U){return function(G){return U(G)}}function ic(U,G){return mt(G,function(V){return U[V]})}function ss(U,G){return U.has(G)}function yh(U,G){for(var V=-1,ge=U.length;++V<ge&&Pn(G,U[V],0)>-1;);return V}function mh(U,G){for(var V=U.length;V--&&Pn(G,U[V],0)>-1;);return V}function Pg(U,G){for(var V=U.length,ge=0;V--;)U[V]===G&&++ge;return ge}var Ag=ec(w),Tg=ec(L);function Rg(U){return"\\"+pe[U]}function Ng(U,G){return U==null?r:U[G]}function An(U){return lo.test(U)}function $g(U){return Zi.test(U)}function Lg(U){for(var G,V=[];!(G=U.next()).done;)V.push(G.value);return V}function nc(U){var G=-1,V=Array(U.size);return U.forEach(function(ge,Ae){V[++G]=[Ae,ge]}),V}function _h(U,G){return function(V){return U(G(V))}}function Li(U,G){for(var V=-1,ge=U.length,Ae=0,rt=[];++V<ge;){var Bt=U[V];(Bt===G||Bt===E)&&(U[V]=E,rt[Ae++]=V)}return rt}function vo(U){var G=-1,V=Array(U.size);return U.forEach(function(ge){V[++G]=ge}),V}function Ug(U){var G=-1,V=Array(U.size);return U.forEach(function(ge){V[++G]=[ge,ge]}),V}function Fg(U,G,V){for(var ge=V-1,Ae=U.length;++ge<Ae;)if(U[ge]===G)return ge;return-1}function Mg(U,G,V){for(var ge=V+1;ge--;)if(U[ge]===G)return ge;return ge}function Tn(U){return An(U)?qg(U):Dg(U)}function Vr(U){return An(U)?Hg(U):Sg(U)}function bh(U){for(var G=U.length;G--&&At.test(U.charAt(G)););return G}var jg=ec(Z);function qg(U){for(var G=Cn.lastIndex=0;Cn.test(U);)++G;return G}function Hg(U){return U.match(Cn)||[]}function zg(U){return U.match(ho)||[]}var Bg=function U(G){G=G==null?Qe:Rn.defaults(Qe.Object(),G,Rn.pick(Qe,fo));var V=G.Array,ge=G.Date,Ae=G.Error,rt=G.Function,Bt=G.Math,ut=G.Object,sc=G.RegExp,kg=G.String,Lr=G.TypeError,yo=V.prototype,Kg=rt.prototype,Nn=ut.prototype,mo=G["__core-js_shared__"],_o=Kg.toString,nt=Nn.hasOwnProperty,Vg=0,wh=function(){var t=/[^.]+$/.exec(mo&&mo.keys&&mo.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),bo=Nn.toString,Wg=_o.call(ut),Gg=Qe._,Yg=sc("^"+_o.call(nt).replace(xt,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),wo=gr?G.Buffer:r,Ui=G.Symbol,Eo=G.Uint8Array,Eh=wo?wo.allocUnsafe:r,Do=_h(ut.getPrototypeOf,ut),Dh=ut.create,Sh=Nn.propertyIsEnumerable,So=yo.splice,Ih=Ui?Ui.isConcatSpreadable:r,os=Ui?Ui.iterator:r,tn=Ui?Ui.toStringTag:r,Io=function(){try{var t=an(ut,"defineProperty");return t({},"",{}),t}catch{}}(),Jg=G.clearTimeout!==Qe.clearTimeout&&G.clearTimeout,Qg=ge&&ge.now!==Qe.Date.now&&ge.now,Xg=G.setTimeout!==Qe.setTimeout&&G.setTimeout,xo=Bt.ceil,Oo=Bt.floor,oc=ut.getOwnPropertySymbols,Zg=wo?wo.isBuffer:r,xh=G.isFinite,e0=yo.join,t0=_h(ut.keys,ut),kt=Bt.max,Xt=Bt.min,r0=ge.now,i0=G.parseInt,Oh=Bt.random,n0=yo.reverse,ac=an(G,"DataView"),as=an(G,"Map"),cc=an(G,"Promise"),$n=an(G,"Set"),cs=an(G,"WeakMap"),us=an(ut,"create"),Co=cs&&new cs,Ln={},s0=cn(ac),o0=cn(as),a0=cn(cc),c0=cn($n),u0=cn(cs),Po=Ui?Ui.prototype:r,hs=Po?Po.valueOf:r,Ch=Po?Po.toString:r;function v(t){if(Pt(t)&&!Re(t)&&!(t instanceof Ye)){if(t instanceof Ur)return t;if(nt.call(t,"__wrapped__"))return Pl(t)}return new Ur(t)}var Un=function(){function t(){}return function(n){if(!wt(n))return{};if(Dh)return Dh(n);t.prototype=n;var a=new t;return t.prototype=r,a}}();function Ao(){}function Ur(t,n){this.__wrapped__=t,this.__actions__=[],this.__chain__=!!n,this.__index__=0,this.__values__=r}v.templateSettings={escape:St,evaluate:It,interpolate:bt,variable:"",imports:{_:v}},v.prototype=Ao.prototype,v.prototype.constructor=v,Ur.prototype=Un(Ao.prototype),Ur.prototype.constructor=Ur;function Ye(t){this.__wrapped__=t,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=ne,this.__views__=[]}function h0(){var t=new Ye(this.__wrapped__);return t.__actions__=vr(this.__actions__),t.__dir__=this.__dir__,t.__filtered__=this.__filtered__,t.__iteratees__=vr(this.__iteratees__),t.__takeCount__=this.__takeCount__,t.__views__=vr(this.__views__),t}function l0(){if(this.__filtered__){var t=new Ye(this);t.__dir__=-1,t.__filtered__=!0}else t=this.clone(),t.__dir__*=-1;return t}function f0(){var t=this.__wrapped__.value(),n=this.__dir__,a=Re(t),u=n<0,d=a?t.length:0,y=S1(0,d,this.__views__),D=y.start,O=y.end,M=O-D,Q=u?O:D-1,X=this.__iteratees__,te=X.length,ue=0,ve=Xt(M,this.__takeCount__);if(!a||!u&&d==M&&ve==M)return Xh(t,this.__actions__);var we=[];e:for(;M--&&ue<ve;){Q+=n;for(var He=-1,Ee=t[Q];++He<te;){var We=X[He],Xe=We.iteratee,Or=We.type,ur=Xe(Ee);if(Or==H)Ee=ur;else if(!ur){if(Or==T)continue e;break e}}we[ue++]=Ee}return we}Ye.prototype=Un(Ao.prototype),Ye.prototype.constructor=Ye;function rn(t){var n=-1,a=t==null?0:t.length;for(this.clear();++n<a;){var u=t[n];this.set(u[0],u[1])}}function d0(){this.__data__=us?us(null):{},this.size=0}function p0(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}function g0(t){var n=this.__data__;if(us){var a=n[t];return a===g?r:a}return nt.call(n,t)?n[t]:r}function v0(t){var n=this.__data__;return us?n[t]!==r:nt.call(n,t)}function y0(t,n){var a=this.__data__;return this.size+=this.has(t)?0:1,a[t]=us&&n===r?g:n,this}rn.prototype.clear=d0,rn.prototype.delete=p0,rn.prototype.get=g0,rn.prototype.has=v0,rn.prototype.set=y0;function gi(t){var n=-1,a=t==null?0:t.length;for(this.clear();++n<a;){var u=t[n];this.set(u[0],u[1])}}function m0(){this.__data__=[],this.size=0}function _0(t){var n=this.__data__,a=To(n,t);if(a<0)return!1;var u=n.length-1;return a==u?n.pop():So.call(n,a,1),--this.size,!0}function b0(t){var n=this.__data__,a=To(n,t);return a<0?r:n[a][1]}function w0(t){return To(this.__data__,t)>-1}function E0(t,n){var a=this.__data__,u=To(a,t);return u<0?(++this.size,a.push([t,n])):a[u][1]=n,this}gi.prototype.clear=m0,gi.prototype.delete=_0,gi.prototype.get=b0,gi.prototype.has=w0,gi.prototype.set=E0;function vi(t){var n=-1,a=t==null?0:t.length;for(this.clear();++n<a;){var u=t[n];this.set(u[0],u[1])}}function D0(){this.size=0,this.__data__={hash:new rn,map:new(as||gi),string:new rn}}function S0(t){var n=Bo(this,t).delete(t);return this.size-=n?1:0,n}function I0(t){return Bo(this,t).get(t)}function x0(t){return Bo(this,t).has(t)}function O0(t,n){var a=Bo(this,t),u=a.size;return a.set(t,n),this.size+=a.size==u?0:1,this}vi.prototype.clear=D0,vi.prototype.delete=S0,vi.prototype.get=I0,vi.prototype.has=x0,vi.prototype.set=O0;function nn(t){var n=-1,a=t==null?0:t.length;for(this.__data__=new vi;++n<a;)this.add(t[n])}function C0(t){return this.__data__.set(t,g),this}function P0(t){return this.__data__.has(t)}nn.prototype.add=nn.prototype.push=C0,nn.prototype.has=P0;function Wr(t){var n=this.__data__=new gi(t);this.size=n.size}function A0(){this.__data__=new gi,this.size=0}function T0(t){var n=this.__data__,a=n.delete(t);return this.size=n.size,a}function R0(t){return this.__data__.get(t)}function N0(t){return this.__data__.has(t)}function $0(t,n){var a=this.__data__;if(a instanceof gi){var u=a.__data__;if(!as||u.length<o-1)return u.push([t,n]),this.size=++a.size,this;a=this.__data__=new vi(u)}return a.set(t,n),this.size=a.size,this}Wr.prototype.clear=A0,Wr.prototype.delete=T0,Wr.prototype.get=R0,Wr.prototype.has=N0,Wr.prototype.set=$0;function Ph(t,n){var a=Re(t),u=!a&&un(t),d=!a&&!u&&Hi(t),y=!a&&!u&&!d&&qn(t),D=a||u||d||y,O=D?rc(t.length,kg):[],M=O.length;for(var Q in t)(n||nt.call(t,Q))&&!(D&&(Q=="length"||d&&(Q=="offset"||Q=="parent")||y&&(Q=="buffer"||Q=="byteLength"||Q=="byteOffset")||bi(Q,M)))&&O.push(Q);return O}function Ah(t){var n=t.length;return n?t[_c(0,n-1)]:r}function L0(t,n){return ko(vr(t),sn(n,0,t.length))}function U0(t){return ko(vr(t))}function uc(t,n,a){(a!==r&&!Gr(t[n],a)||a===r&&!(n in t))&&yi(t,n,a)}function ls(t,n,a){var u=t[n];(!(nt.call(t,n)&&Gr(u,a))||a===r&&!(n in t))&&yi(t,n,a)}function To(t,n){for(var a=t.length;a--;)if(Gr(t[a][0],n))return a;return-1}function F0(t,n,a,u){return Fi(t,function(d,y,D){n(u,d,a(d),D)}),u}function Th(t,n){return t&&ni(n,Vt(n),t)}function M0(t,n){return t&&ni(n,mr(n),t)}function yi(t,n,a){n=="__proto__"&&Io?Io(t,n,{configurable:!0,enumerable:!0,value:a,writable:!0}):t[n]=a}function hc(t,n){for(var a=-1,u=n.length,d=V(u),y=t==null;++a<u;)d[a]=y?r:kc(t,n[a]);return d}function sn(t,n,a){return t===t&&(a!==r&&(t=t<=a?t:a),n!==r&&(t=t>=n?t:n)),t}function Fr(t,n,a,u,d,y){var D,O=n&C,M=n&N,Q=n&P;if(a&&(D=d?a(t,u,d,y):a(t)),D!==r)return D;if(!wt(t))return t;var X=Re(t);if(X){if(D=x1(t),!O)return vr(t,D)}else{var te=Zt(t),ue=te==ae||te==de;if(Hi(t))return tl(t,O);if(te==Fe||te==le||ue&&!d){if(D=M||ue?{}:bl(t),!O)return M?g1(t,M0(D,t)):p1(t,Th(D,t))}else{if(!st[te])return d?t:{};D=O1(t,te,O)}}y||(y=new Wr);var ve=y.get(t);if(ve)return ve;y.set(t,D),Yl(t)?t.forEach(function(Ee){D.add(Fr(Ee,n,a,Ee,t,y))}):Wl(t)&&t.forEach(function(Ee,We){D.set(We,Fr(Ee,n,a,We,t,y))});var we=Q?M?Ac:Pc:M?mr:Vt,He=X?r:we(t);return $r(He||t,function(Ee,We){He&&(We=Ee,Ee=t[We]),ls(D,We,Fr(Ee,n,a,We,t,y))}),D}function j0(t){var n=Vt(t);return function(a){return Rh(a,t,n)}}function Rh(t,n,a){var u=a.length;if(t==null)return!u;for(t=ut(t);u--;){var d=a[u],y=n[d],D=t[d];if(D===r&&!(d in t)||!y(D))return!1}return!0}function Nh(t,n,a){if(typeof t!="function")throw new Lr(p);return ms(function(){t.apply(r,a)},n)}function fs(t,n,a,u){var d=-1,y=po,D=!0,O=t.length,M=[],Q=n.length;if(!O)return M;a&&(n=mt(n,Sr(a))),u?(y=Ja,D=!1):n.length>=o&&(y=ss,D=!1,n=new nn(n));e:for(;++d<O;){var X=t[d],te=a==null?X:a(X);if(X=u||X!==0?X:0,D&&te===te){for(var ue=Q;ue--;)if(n[ue]===te)continue e;M.push(X)}else y(n,te,u)||M.push(X)}return M}var Fi=ol(ii),$h=ol(fc,!0);function q0(t,n){var a=!0;return Fi(t,function(u,d,y){return a=!!n(u,d,y),a}),a}function Ro(t,n,a){for(var u=-1,d=t.length;++u<d;){var y=t[u],D=n(y);if(D!=null&&(O===r?D===D&&!xr(D):a(D,O)))var O=D,M=y}return M}function H0(t,n,a,u){var d=t.length;for(a=Me(a),a<0&&(a=-a>d?0:d+a),u=u===r||u>d?d:Me(u),u<0&&(u+=d),u=a>u?0:Ql(u);a<u;)t[a++]=n;return t}function Lh(t,n){var a=[];return Fi(t,function(u,d,y){n(u,d,y)&&a.push(u)}),a}function Yt(t,n,a,u,d){var y=-1,D=t.length;for(a||(a=P1),d||(d=[]);++y<D;){var O=t[y];n>0&&a(O)?n>1?Yt(O,n-1,a,u,d):$i(d,O):u||(d[d.length]=O)}return d}var lc=al(),Uh=al(!0);function ii(t,n){return t&&lc(t,n,Vt)}function fc(t,n){return t&&Uh(t,n,Vt)}function No(t,n){return Ni(n,function(a){return wi(t[a])})}function on(t,n){n=ji(n,t);for(var a=0,u=n.length;t!=null&&a<u;)t=t[si(n[a++])];return a&&a==u?t:r}function Fh(t,n,a){var u=n(t);return Re(t)?u:$i(u,a(t))}function ar(t){return t==null?t===r?qe:Ke:tn&&tn in ut(t)?D1(t):U1(t)}function dc(t,n){return t>n}function z0(t,n){return t!=null&&nt.call(t,n)}function B0(t,n){return t!=null&&n in ut(t)}function k0(t,n,a){return t>=Xt(n,a)&&t<kt(n,a)}function pc(t,n,a){for(var u=a?Ja:po,d=t[0].length,y=t.length,D=y,O=V(y),M=1/0,Q=[];D--;){var X=t[D];D&&n&&(X=mt(X,Sr(n))),M=Xt(X.length,M),O[D]=!a&&(n||d>=120&&X.length>=120)?new nn(D&&X):r}X=t[0];var te=-1,ue=O[0];e:for(;++te<d&&Q.length<M;){var ve=X[te],we=n?n(ve):ve;if(ve=a||ve!==0?ve:0,!(ue?ss(ue,we):u(Q,we,a))){for(D=y;--D;){var He=O[D];if(!(He?ss(He,we):u(t[D],we,a)))continue e}ue&&ue.push(we),Q.push(ve)}}return Q}function K0(t,n,a,u){return ii(t,function(d,y,D){n(u,a(d),y,D)}),u}function ds(t,n,a){n=ji(n,t),t=Sl(t,n);var u=t==null?t:t[si(jr(n))];return u==null?r:Kt(u,t,a)}function Mh(t){return Pt(t)&&ar(t)==le}function V0(t){return Pt(t)&&ar(t)==De}function W0(t){return Pt(t)&&ar(t)==R}function ps(t,n,a,u,d){return t===n?!0:t==null||n==null||!Pt(t)&&!Pt(n)?t!==t&&n!==n:G0(t,n,a,u,ps,d)}function G0(t,n,a,u,d,y){var D=Re(t),O=Re(n),M=D?me:Zt(t),Q=O?me:Zt(n);M=M==le?Fe:M,Q=Q==le?Fe:Q;var X=M==Fe,te=Q==Fe,ue=M==Q;if(ue&&Hi(t)){if(!Hi(n))return!1;D=!0,X=!1}if(ue&&!X)return y||(y=new Wr),D||qn(t)?yl(t,n,a,u,d,y):w1(t,n,M,a,u,d,y);if(!(a&F)){var ve=X&&nt.call(t,"__wrapped__"),we=te&&nt.call(n,"__wrapped__");if(ve||we){var He=ve?t.value():t,Ee=we?n.value():n;return y||(y=new Wr),d(He,Ee,a,u,y)}}return ue?(y||(y=new Wr),E1(t,n,a,u,d,y)):!1}function Y0(t){return Pt(t)&&Zt(t)==Se}function gc(t,n,a,u){var d=a.length,y=d,D=!u;if(t==null)return!y;for(t=ut(t);d--;){var O=a[d];if(D&&O[2]?O[1]!==t[O[0]]:!(O[0]in t))return!1}for(;++d<y;){O=a[d];var M=O[0],Q=t[M],X=O[1];if(D&&O[2]){if(Q===r&&!(M in t))return!1}else{var te=new Wr;if(u)var ue=u(Q,X,M,t,n,te);if(!(ue===r?ps(X,Q,F|k,u,te):ue))return!1}}return!0}function jh(t){if(!wt(t)||T1(t))return!1;var n=wi(t)?Yg:$a;return n.test(cn(t))}function J0(t){return Pt(t)&&ar(t)==je}function Q0(t){return Pt(t)&&Zt(t)==Ie}function X0(t){return Pt(t)&&Jo(t.length)&&!!ot[ar(t)]}function qh(t){return typeof t=="function"?t:t==null?_r:typeof t=="object"?Re(t)?Bh(t[0],t[1]):zh(t):uf(t)}function vc(t){if(!ys(t))return t0(t);var n=[];for(var a in ut(t))nt.call(t,a)&&a!="constructor"&&n.push(a);return n}function Z0(t){if(!wt(t))return L1(t);var n=ys(t),a=[];for(var u in t)u=="constructor"&&(n||!nt.call(t,u))||a.push(u);return a}function yc(t,n){return t<n}function Hh(t,n){var a=-1,u=yr(t)?V(t.length):[];return Fi(t,function(d,y,D){u[++a]=n(d,y,D)}),u}function zh(t){var n=Rc(t);return n.length==1&&n[0][2]?El(n[0][0],n[0][1]):function(a){return a===t||gc(a,t,n)}}function Bh(t,n){return $c(t)&&wl(n)?El(si(t),n):function(a){var u=kc(a,t);return u===r&&u===n?Kc(a,t):ps(n,u,F|k)}}function $o(t,n,a,u,d){t!==n&&lc(n,function(y,D){if(d||(d=new Wr),wt(y))e1(t,n,D,a,$o,u,d);else{var O=u?u(Uc(t,D),y,D+"",t,n,d):r;O===r&&(O=y),uc(t,D,O)}},mr)}function e1(t,n,a,u,d,y,D){var O=Uc(t,a),M=Uc(n,a),Q=D.get(M);if(Q){uc(t,a,Q);return}var X=y?y(O,M,a+"",t,n,D):r,te=X===r;if(te){var ue=Re(M),ve=!ue&&Hi(M),we=!ue&&!ve&&qn(M);X=M,ue||ve||we?Re(O)?X=O:Rt(O)?X=vr(O):ve?(te=!1,X=tl(M,!0)):we?(te=!1,X=rl(M,!0)):X=[]:_s(M)||un(M)?(X=O,un(O)?X=Xl(O):(!wt(O)||wi(O))&&(X=bl(M))):te=!1}te&&(D.set(M,X),d(X,M,u,y,D),D.delete(M)),uc(t,a,X)}function kh(t,n){var a=t.length;if(a)return n+=n<0?a:0,bi(n,a)?t[n]:r}function Kh(t,n,a){n.length?n=mt(n,function(y){return Re(y)?function(D){return on(D,y.length===1?y[0]:y)}:y}):n=[_r];var u=-1;n=mt(n,Sr(_e()));var d=Hh(t,function(y,D,O){var M=mt(n,function(Q){return Q(y)});return{criteria:M,index:++u,value:y}});return Og(d,function(y,D){return d1(y,D,a)})}function t1(t,n){return Vh(t,n,function(a,u){return Kc(t,u)})}function Vh(t,n,a){for(var u=-1,d=n.length,y={};++u<d;){var D=n[u],O=on(t,D);a(O,D)&&gs(y,ji(D,t),O)}return y}function r1(t){return function(n){return on(n,t)}}function mc(t,n,a,u){var d=u?xg:Pn,y=-1,D=n.length,O=t;for(t===n&&(n=vr(n)),a&&(O=mt(t,Sr(a)));++y<D;)for(var M=0,Q=n[y],X=a?a(Q):Q;(M=d(O,X,M,u))>-1;)O!==t&&So.call(O,M,1),So.call(t,M,1);return t}function Wh(t,n){for(var a=t?n.length:0,u=a-1;a--;){var d=n[a];if(a==u||d!==y){var y=d;bi(d)?So.call(t,d,1):Ec(t,d)}}return t}function _c(t,n){return t+Oo(Oh()*(n-t+1))}function i1(t,n,a,u){for(var d=-1,y=kt(xo((n-t)/(a||1)),0),D=V(y);y--;)D[u?y:++d]=t,t+=a;return D}function bc(t,n){var a="";if(!t||n<1||n>Y)return a;do n%2&&(a+=t),n=Oo(n/2),n&&(t+=t);while(n);return a}function ke(t,n){return Fc(Dl(t,n,_r),t+"")}function n1(t){return Ah(Hn(t))}function s1(t,n){var a=Hn(t);return ko(a,sn(n,0,a.length))}function gs(t,n,a,u){if(!wt(t))return t;n=ji(n,t);for(var d=-1,y=n.length,D=y-1,O=t;O!=null&&++d<y;){var M=si(n[d]),Q=a;if(M==="__proto__"||M==="constructor"||M==="prototype")return t;if(d!=D){var X=O[M];Q=u?u(X,M,O):r,Q===r&&(Q=wt(X)?X:bi(n[d+1])?[]:{})}ls(O,M,Q),O=O[M]}return t}var Gh=Co?function(t,n){return Co.set(t,n),t}:_r,o1=Io?function(t,n){return Io(t,"toString",{configurable:!0,enumerable:!1,value:Wc(n),writable:!0})}:_r;function a1(t){return ko(Hn(t))}function Mr(t,n,a){var u=-1,d=t.length;n<0&&(n=-n>d?0:d+n),a=a>d?d:a,a<0&&(a+=d),d=n>a?0:a-n>>>0,n>>>=0;for(var y=V(d);++u<d;)y[u]=t[u+n];return y}function c1(t,n){var a;return Fi(t,function(u,d,y){return a=n(u,d,y),!a}),!!a}function Lo(t,n,a){var u=0,d=t==null?u:t.length;if(typeof n=="number"&&n===n&&d<=se){for(;u<d;){var y=u+d>>>1,D=t[y];D!==null&&!xr(D)&&(a?D<=n:D<n)?u=y+1:d=y}return d}return wc(t,n,_r,a)}function wc(t,n,a,u){var d=0,y=t==null?0:t.length;if(y===0)return 0;n=a(n);for(var D=n!==n,O=n===null,M=xr(n),Q=n===r;d<y;){var X=Oo((d+y)/2),te=a(t[X]),ue=te!==r,ve=te===null,we=te===te,He=xr(te);if(D)var Ee=u||we;else Q?Ee=we&&(u||ue):O?Ee=we&&ue&&(u||!ve):M?Ee=we&&ue&&!ve&&(u||!He):ve||He?Ee=!1:Ee=u?te<=n:te<n;Ee?d=X+1:y=X}return Xt(y,xe)}function Yh(t,n){for(var a=-1,u=t.length,d=0,y=[];++a<u;){var D=t[a],O=n?n(D):D;if(!a||!Gr(O,M)){var M=O;y[d++]=D===0?0:D}}return y}function Jh(t){return typeof t=="number"?t:xr(t)?J:+t}function Ir(t){if(typeof t=="string")return t;if(Re(t))return mt(t,Ir)+"";if(xr(t))return Ch?Ch.call(t):"";var n=t+"";return n=="0"&&1/t==-ie?"-0":n}function Mi(t,n,a){var u=-1,d=po,y=t.length,D=!0,O=[],M=O;if(a)D=!1,d=Ja;else if(y>=o){var Q=n?null:_1(t);if(Q)return vo(Q);D=!1,d=ss,M=new nn}else M=n?[]:O;e:for(;++u<y;){var X=t[u],te=n?n(X):X;if(X=a||X!==0?X:0,D&&te===te){for(var ue=M.length;ue--;)if(M[ue]===te)continue e;n&&M.push(te),O.push(X)}else d(M,te,a)||(M!==O&&M.push(te),O.push(X))}return O}function Ec(t,n){return n=ji(n,t),t=Sl(t,n),t==null||delete t[si(jr(n))]}function Qh(t,n,a,u){return gs(t,n,a(on(t,n)),u)}function Uo(t,n,a,u){for(var d=t.length,y=u?d:-1;(u?y--:++y<d)&&n(t[y],y,t););return a?Mr(t,u?0:y,u?y+1:d):Mr(t,u?y+1:0,u?d:y)}function Xh(t,n){var a=t;return a instanceof Ye&&(a=a.value()),Qa(n,function(u,d){return d.func.apply(d.thisArg,$i([u],d.args))},a)}function Dc(t,n,a){var u=t.length;if(u<2)return u?Mi(t[0]):[];for(var d=-1,y=V(u);++d<u;)for(var D=t[d],O=-1;++O<u;)O!=d&&(y[d]=fs(y[d]||D,t[O],n,a));return Mi(Yt(y,1),n,a)}function Zh(t,n,a){for(var u=-1,d=t.length,y=n.length,D={};++u<d;){var O=u<y?n[u]:r;a(D,t[u],O)}return D}function Sc(t){return Rt(t)?t:[]}function Ic(t){return typeof t=="function"?t:_r}function ji(t,n){return Re(t)?t:$c(t,n)?[t]:Cl(it(t))}var u1=ke;function qi(t,n,a){var u=t.length;return a=a===r?u:a,!n&&a>=u?t:Mr(t,n,a)}var el=Jg||function(t){return Qe.clearTimeout(t)};function tl(t,n){if(n)return t.slice();var a=t.length,u=Eh?Eh(a):new t.constructor(a);return t.copy(u),u}function xc(t){var n=new t.constructor(t.byteLength);return new Eo(n).set(new Eo(t)),n}function h1(t,n){var a=n?xc(t.buffer):t.buffer;return new t.constructor(a,t.byteOffset,t.byteLength)}function l1(t){var n=new t.constructor(t.source,Rr.exec(t));return n.lastIndex=t.lastIndex,n}function f1(t){return hs?ut(hs.call(t)):{}}function rl(t,n){var a=n?xc(t.buffer):t.buffer;return new t.constructor(a,t.byteOffset,t.length)}function il(t,n){if(t!==n){var a=t!==r,u=t===null,d=t===t,y=xr(t),D=n!==r,O=n===null,M=n===n,Q=xr(n);if(!O&&!Q&&!y&&t>n||y&&D&&M&&!O&&!Q||u&&D&&M||!a&&M||!d)return 1;if(!u&&!y&&!Q&&t<n||Q&&a&&d&&!u&&!y||O&&a&&d||!D&&d||!M)return-1}return 0}function d1(t,n,a){for(var u=-1,d=t.criteria,y=n.criteria,D=d.length,O=a.length;++u<D;){var M=il(d[u],y[u]);if(M){if(u>=O)return M;var Q=a[u];return M*(Q=="desc"?-1:1)}}return t.index-n.index}function nl(t,n,a,u){for(var d=-1,y=t.length,D=a.length,O=-1,M=n.length,Q=kt(y-D,0),X=V(M+Q),te=!u;++O<M;)X[O]=n[O];for(;++d<D;)(te||d<y)&&(X[a[d]]=t[d]);for(;Q--;)X[O++]=t[d++];return X}function sl(t,n,a,u){for(var d=-1,y=t.length,D=-1,O=a.length,M=-1,Q=n.length,X=kt(y-O,0),te=V(X+Q),ue=!u;++d<X;)te[d]=t[d];for(var ve=d;++M<Q;)te[ve+M]=n[M];for(;++D<O;)(ue||d<y)&&(te[ve+a[D]]=t[d++]);return te}function vr(t,n){var a=-1,u=t.length;for(n||(n=V(u));++a<u;)n[a]=t[a];return n}function ni(t,n,a,u){var d=!a;a||(a={});for(var y=-1,D=n.length;++y<D;){var O=n[y],M=u?u(a[O],t[O],O,a,t):r;M===r&&(M=t[O]),d?yi(a,O,M):ls(a,O,M)}return a}function p1(t,n){return ni(t,Nc(t),n)}function g1(t,n){return ni(t,ml(t),n)}function Fo(t,n){return function(a,u){var d=Re(a)?bg:F0,y=n?n():{};return d(a,t,_e(u,2),y)}}function Fn(t){return ke(function(n,a){var u=-1,d=a.length,y=d>1?a[d-1]:r,D=d>2?a[2]:r;for(y=t.length>3&&typeof y=="function"?(d--,y):r,D&&cr(a[0],a[1],D)&&(y=d<3?r:y,d=1),n=ut(n);++u<d;){var O=a[u];O&&t(n,O,u,y)}return n})}function ol(t,n){return function(a,u){if(a==null)return a;if(!yr(a))return t(a,u);for(var d=a.length,y=n?d:-1,D=ut(a);(n?y--:++y<d)&&u(D[y],y,D)!==!1;);return a}}function al(t){return function(n,a,u){for(var d=-1,y=ut(n),D=u(n),O=D.length;O--;){var M=D[t?O:++d];if(a(y[M],M,y)===!1)break}return n}}function v1(t,n,a){var u=n&K,d=vs(t);function y(){var D=this&&this!==Qe&&this instanceof y?d:t;return D.apply(u?a:this,arguments)}return y}function cl(t){return function(n){n=it(n);var a=An(n)?Vr(n):r,u=a?a[0]:n.charAt(0),d=a?qi(a,1).join(""):n.slice(1);return u[t]()+d}}function Mn(t){return function(n){return Qa(af(of(n).replace(is,"")),t,"")}}function vs(t){return function(){var n=arguments;switch(n.length){case 0:return new t;case 1:return new t(n[0]);case 2:return new t(n[0],n[1]);case 3:return new t(n[0],n[1],n[2]);case 4:return new t(n[0],n[1],n[2],n[3]);case 5:return new t(n[0],n[1],n[2],n[3],n[4]);case 6:return new t(n[0],n[1],n[2],n[3],n[4],n[5]);case 7:return new t(n[0],n[1],n[2],n[3],n[4],n[5],n[6])}var a=Un(t.prototype),u=t.apply(a,n);return wt(u)?u:a}}function y1(t,n,a){var u=vs(t);function d(){for(var y=arguments.length,D=V(y),O=y,M=jn(d);O--;)D[O]=arguments[O];var Q=y<3&&D[0]!==M&&D[y-1]!==M?[]:Li(D,M);if(y-=Q.length,y<a)return dl(t,n,Mo,d.placeholder,r,D,Q,r,r,a-y);var X=this&&this!==Qe&&this instanceof d?u:t;return Kt(X,this,D)}return d}function ul(t){return function(n,a,u){var d=ut(n);if(!yr(n)){var y=_e(a,3);n=Vt(n),a=function(O){return y(d[O],O,d)}}var D=t(n,a,u);return D>-1?d[y?n[D]:D]:r}}function hl(t){return _i(function(n){var a=n.length,u=a,d=Ur.prototype.thru;for(t&&n.reverse();u--;){var y=n[u];if(typeof y!="function")throw new Lr(p);if(d&&!D&&zo(y)=="wrapper")var D=new Ur([],!0)}for(u=D?u:a;++u<a;){y=n[u];var O=zo(y),M=O=="wrapper"?Tc(y):r;M&&Lc(M[0])&&M[1]==(c|$|I|m)&&!M[4].length&&M[9]==1?D=D[zo(M[0])].apply(D,M[3]):D=y.length==1&&Lc(y)?D[O]():D.thru(y)}return function(){var Q=arguments,X=Q[0];if(D&&Q.length==1&&Re(X))return D.plant(X).value();for(var te=0,ue=a?n[te].apply(this,Q):X;++te<a;)ue=n[te].call(this,ue);return ue}})}function Mo(t,n,a,u,d,y,D,O,M,Q){var X=n&c,te=n&K,ue=n&ee,ve=n&($|S),we=n&B,He=ue?r:vs(t);function Ee(){for(var We=arguments.length,Xe=V(We),Or=We;Or--;)Xe[Or]=arguments[Or];if(ve)var ur=jn(Ee),Cr=Pg(Xe,ur);if(u&&(Xe=nl(Xe,u,d,ve)),y&&(Xe=sl(Xe,y,D,ve)),We-=Cr,ve&&We<Q){var Nt=Li(Xe,ur);return dl(t,n,Mo,Ee.placeholder,a,Xe,Nt,O,M,Q-We)}var Yr=te?a:this,Di=ue?Yr[t]:t;return We=Xe.length,O?Xe=F1(Xe,O):we&&We>1&&Xe.reverse(),X&&M<We&&(Xe.length=M),this&&this!==Qe&&this instanceof Ee&&(Di=He||vs(Di)),Di.apply(Yr,Xe)}return Ee}function ll(t,n){return function(a,u){return K0(a,t,n(u),{})}}function jo(t,n){return function(a,u){var d;if(a===r&&u===r)return n;if(a!==r&&(d=a),u!==r){if(d===r)return u;typeof a=="string"||typeof u=="string"?(a=Ir(a),u=Ir(u)):(a=Jh(a),u=Jh(u)),d=t(a,u)}return d}}function Oc(t){return _i(function(n){return n=mt(n,Sr(_e())),ke(function(a){var u=this;return t(n,function(d){return Kt(d,u,a)})})})}function qo(t,n){n=n===r?" ":Ir(n);var a=n.length;if(a<2)return a?bc(n,t):n;var u=bc(n,xo(t/Tn(n)));return An(n)?qi(Vr(u),0,t).join(""):u.slice(0,t)}function m1(t,n,a,u){var d=n&K,y=vs(t);function D(){for(var O=-1,M=arguments.length,Q=-1,X=u.length,te=V(X+M),ue=this&&this!==Qe&&this instanceof D?y:t;++Q<X;)te[Q]=u[Q];for(;M--;)te[Q++]=arguments[++O];return Kt(ue,d?a:this,te)}return D}function fl(t){return function(n,a,u){return u&&typeof u!="number"&&cr(n,a,u)&&(a=u=r),n=Ei(n),a===r?(a=n,n=0):a=Ei(a),u=u===r?n<a?1:-1:Ei(u),i1(n,a,u,t)}}function Ho(t){return function(n,a){return typeof n=="string"&&typeof a=="string"||(n=qr(n),a=qr(a)),t(n,a)}}function dl(t,n,a,u,d,y,D,O,M,Q){var X=n&$,te=X?D:r,ue=X?r:D,ve=X?y:r,we=X?r:y;n|=X?I:_,n&=~(X?_:I),n&A||(n&=~(K|ee));var He=[t,n,d,ve,te,we,ue,O,M,Q],Ee=a.apply(r,He);return Lc(t)&&Il(Ee,He),Ee.placeholder=u,xl(Ee,t,n)}function Cc(t){var n=Bt[t];return function(a,u){if(a=qr(a),u=u==null?0:Xt(Me(u),292),u&&xh(a)){var d=(it(a)+"e").split("e"),y=n(d[0]+"e"+(+d[1]+u));return d=(it(y)+"e").split("e"),+(d[0]+"e"+(+d[1]-u))}return n(a)}}var _1=$n&&1/vo(new $n([,-0]))[1]==ie?function(t){return new $n(t)}:Jc;function pl(t){return function(n){var a=Zt(n);return a==Se?nc(n):a==Ie?Ug(n):Cg(n,t(n))}}function mi(t,n,a,u,d,y,D,O){var M=nⅇif(!M&&typeof t!="function")throw new Lr(p);var Q=u?u.length:0;if(Q||(n&=~(I|_),u=d=r),D=D===r?D:kt(Me(D),0),O=O===r?O:Me(O),Q-=d?d.length:0,n&_){var X=u,te=d;u=d=r}var ue=M?r:Tc(t),ve=[t,n,a,u,d,X,te,y,D,O];if(ue&&$1(ve,ue),t=ve[0],n=ve[1],a=ve[2],u=ve[3],d=ve[4],O=ve[9]=ve[9]===r?M?0:t.length:kt(ve[9]-Q,0),!O&&n&($|S)&&(n&=~($|S)),!n||n==K)var we=v1(t,n,a);else n==$||n==S?we=y1(t,n,O):(n==I||n==(K|I))&&!d.length?we=m1(t,n,a,u):we=Mo.apply(r,ve);var He=ue?Gh:Il;return xl(He(we,ve),t,n)}function gl(t,n,a,u){return t===r||Gr(t,Nn[a])&&!nt.call(u,a)?n:t}function vl(t,n,a,u,d,y){return wt(t)&&wt(n)&&(y.set(n,t),$o(t,n,r,vl,y),y.delete(n)),t}function b1(t){return _s(t)?r:t}function yl(t,n,a,u,d,y){var D=a&F,O=t.length,M=n.length;if(O!=M&&!(D&&M>O))return!1;var Q=y.get(t),X=y.get(n);if(Q&&X)return Q==n&&X==t;var te=-1,ue=!0,ve=a&k?new nn:r;for(y.set(t,n),y.set(n,t);++te<O;){var we=t[te],He=n[te];if(u)var Ee=D?u(He,we,te,n,t,y):u(we,He,te,t,n,y);if(Ee!==r){if(Ee)continue;ue=!1;break}if(ve){if(!Xa(n,function(We,Xe){if(!ss(ve,Xe)&&(we===We||d(we,We,a,u,y)))return ve.push(Xe)})){ue=!1;break}}else if(!(we===He||d(we,He,a,u,y))){ue=!1;break}}return y.delete(t),y.delete(n),ue}function w1(t,n,a,u,d,y,D){switch(a){case Pe:if(t.byteLength!=n.byteLength||t.byteOffset!=n.byteOffset)return!1;t=t.buffer,n=n.buffer;case De:return!(t.byteLength!=n.byteLength||!y(new Eo(t),new Eo(n)));case j:case R:case ze:return Gr(+t,+n);case x:return t.name==n.name&&t.message==n.message;case je:case Ne:return t==n+"";case Se:var O=nc;case Ie:var M=u&F;if(O||(O=vo),t.size!=n.size&&!M)return!1;var Q=D.get(t);if(Q)return Q==n;u|=k,D.set(t,n);var X=yl(O(t),O(n),u,d,y,D);return D.delete(t),X;case $e:if(hs)return hs.call(t)==hs.call(n)}return!1}function E1(t,n,a,u,d,y){var D=a&F,O=Pc(t),M=O.length,Q=Pc(n),X=Q.length;if(M!=X&&!D)return!1;for(var te=M;te--;){var ue=O[te];if(!(D?ue in n:nt.call(n,ue)))return!1}var ve=y.get(t),we=y.get(n);if(ve&&we)return ve==n&&we==t;var He=!0;y.set(t,n),y.set(n,t);for(var Ee=D;++te<M;){ue=O[te];var We=t[ue],Xe=n[ue];if(u)var Or=D?u(Xe,We,ue,n,t,y):u(We,Xe,ue,t,n,y);if(!(Or===r?We===Xe||d(We,Xe,a,u,y):Or)){He=!1;break}Ee||(Ee=ue=="constructor")}if(He&&!Ee){var ur=t.constructor,Cr=n.constructor;ur!=Cr&&"constructor"in t&&"constructor"in n&&!(typeof ur=="function"&&ur instanceof ur&&typeof Cr=="function"&&Cr instanceof Cr)&&(He=!1)}return y.delete(t),y.delete(n),He}function _i(t){return Fc(Dl(t,r,Rl),t+"")}function Pc(t){return Fh(t,Vt,Nc)}function Ac(t){return Fh(t,mr,ml)}var Tc=Co?function(t){return Co.get(t)}:Jc;function zo(t){for(var n=t.name+"",a=Ln[n],u=nt.call(Ln,n)?a.length:0;u--;){var d=a[u],y=d.func;if(y==null||y==t)return d.name}return n}function jn(t){var n=nt.call(v,"placeholder")?v:t;return n.placeholder}function _e(){var t=v.iteratee||Gc;return t=t===Gc?qh:t,arguments.length?t(arguments[0],arguments[1]):t}function Bo(t,n){var a=t.__data__;return A1(n)?a[typeof n=="string"?"string":"hash"]:a.map}function Rc(t){for(var n=Vt(t),a=n.length;a--;){var u=n[a],d=t[u];n[a]=[u,d,wl(d)]}return n}function an(t,n){var a=Ng(t,n);return jh(a)?a:r}function D1(t){var n=nt.call(t,tn),a=t[tn];try{t[tn]=r;var u=!0}catch{}var d=bo.call(t);return u&&(n?t[tn]=a:delete t[tn]),d}var Nc=oc?function(t){return t==null?[]:(t=ut(t),Ni(oc(t),function(n){return Sh.call(t,n)}))}:Qc,ml=oc?function(t){for(var n=[];t;)$i(n,Nc(t)),t=Do(t);return n}:Qc,Zt=ar;(ac&&Zt(new ac(new ArrayBuffer(1)))!=Pe||as&&Zt(new as)!=Se||cc&&Zt(cc.resolve())!=pt||$n&&Zt(new $n)!=Ie||cs&&Zt(new cs)!=Ce)&&(Zt=function(t){var n=ar(t),a=n==Fe?t.constructor:r,u=a?cn(a):"";if(u)switch(u){case s0:return Pe;case o0:return Se;case a0:return pt;case c0:return Ie;case u0:return Ce}return n});function S1(t,n,a){for(var u=-1,d=a.length;++u<d;){var y=a[u],D=y.size;switch(y.type){case"drop":t+=D;break;case"dropRight":n-=D;break;case"take":n=Xt(n,t+D);break;case"takeRight":t=kt(t,n-D);break}}return{start:t,end:n}}function I1(t){var n=t.match(ht);return n?n[1].split(Mt):[]}function _l(t,n,a){n=ji(n,t);for(var u=-1,d=n.length,y=!1;++u<d;){var D=si(n[u]);if(!(y=t!=null&&a(t,D)))break;t=t[D]}return y||++u!=d?y:(d=t==null?0:t.length,!!d&&Jo(d)&&bi(D,d)&&(Re(t)||un(t)))}function x1(t){var n=t.length,a=new t.constructor(n);return n&&typeof t[0]=="string"&&nt.call(t,"index")&&(a.index=t.index,a.input=t.input),a}function bl(t){return typeof t.constructor=="function"&&!ys(t)?Un(Do(t)):{}}function O1(t,n,a){var u=t.constructor;switch(n){case De:return xc(t);case j:case R:return new u(+t);case Pe:return h1(t,a);case Be:case Oe:case Ve:case Ge:case et:case tt:case Je:case nr:case pr:return rl(t,a);case Se:return new u;case ze:case Ne:return new u(t);case je:return l1(t);case Ie:return new u;case $e:return f1(t)}}function C1(t,n){var a=n.length;if(!a)return t;var u=a-1;return n[u]=(a>1?"& ":"")+n[u],n=n.join(a>2?", ":" "),t.replace(Ct,`{
|
|
15
|
+
/* [wrapped with `+n+`] */
|
|
16
|
+
`)}function P1(t){return Re(t)||un(t)||!!(Ih&&t&&t[Ih])}function bi(t,n){var a=typeof t;return n=n??Y,!!n&&(a=="number"||a!="symbol"&&Ua.test(t))&&t>-1&&t%1==0&&t<n}function cr(t,n,a){if(!wt(a))return!1;var u=typeof n;return(u=="number"?yr(a)&&bi(n,a.length):u=="string"&&n in a)?Gr(a[n],t):!1}function $c(t,n){if(Re(t))return!1;var a=typeof t;return a=="number"||a=="symbol"||a=="boolean"||t==null||xr(t)?!0:Lt.test(t)||!yt.test(t)||n!=null&&t in ut(n)}function A1(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}function Lc(t){var n=zo(t),a=v[n];if(typeof a!="function"||!(n in Ye.prototype))return!1;if(t===a)return!0;var u=Tc(a);return!!u&&t===u[0]}function T1(t){return!!wh&&wh in t}var R1=mo?wi:Xc;function ys(t){var n=t&&t.constructor,a=typeof n=="function"&&n.prototype||Nn;return t===a}function wl(t){return t===t&&!wt(t)}function El(t,n){return function(a){return a==null?!1:a[t]===n&&(n!==r||t in ut(a))}}function N1(t){var n=Go(t,function(u){return a.size===b&&a.clear(),u}),a=n.cache;return n}function $1(t,n){var a=t[1],u=n[1],d=a|u,y=d<(K|ee|c),D=u==c&&a==$||u==c&&a==m&&t[7].length<=n[8]||u==(c|m)&&n[7].length<=n[8]&&a==$;if(!(y||D))return t;u&K&&(t[2]=n[2],d|=a&K?0:A);var O=n[3];if(O){var M=t[3];t[3]=M?nl(M,O,n[4]):O,t[4]=M?Li(t[3],E):n[4]}return O=n[5],O&&(M=t[5],t[5]=M?sl(M,O,n[6]):O,t[6]=M?Li(t[5],E):n[6]),O=n[7],O&&(t[7]=O),u&c&&(t[8]=t[8]==null?n[8]:Xt(t[8],n[8])),t[9]==null&&(t[9]=n[9]),t[0]=n[0],t[1]=d,t}function L1(t){var n=[];if(t!=null)for(var a in ut(t))n.push(a);return n}function U1(t){return bo.call(t)}function Dl(t,n,a){return n=kt(n===r?t.length-1:n,0),function(){for(var u=arguments,d=-1,y=kt(u.length-n,0),D=V(y);++d<y;)D[d]=u[n+d];d=-1;for(var O=V(n+1);++d<n;)O[d]=u[d];return O[n]=a(D),Kt(t,this,O)}}function Sl(t,n){return n.length<2?t:on(t,Mr(n,0,-1))}function F1(t,n){for(var a=t.length,u=Xt(n.length,a),d=vr(t);u--;){var y=n[u];t[u]=bi(y,a)?d[y]:r}return t}function Uc(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}var Il=Ol(Gh),ms=Xg||function(t,n){return Qe.setTimeout(t,n)},Fc=Ol(o1);function xl(t,n,a){var u=n+"";return Fc(t,C1(u,M1(I1(u),a)))}function Ol(t){var n=0,a=0;return function(){var u=r0(),d=fe-(u-a);if(a=u,d>0){if(++n>=oe)return arguments[0]}else n=0;return t.apply(r,arguments)}}function ko(t,n){var a=-1,u=t.length,d=u-1;for(n=n===r?u:n;++a<n;){var y=_c(a,d),D=t[y];t[y]=t[a],t[a]=D}return t.length=n,t}var Cl=N1(function(t){var n=[];return t.charCodeAt(0)===46&&n.push(""),t.replace(Ut,function(a,u,d,y){n.push(d?y.replace(Aa,"$1"):u||a)}),n});function si(t){if(typeof t=="string"||xr(t))return t;var n=t+"";return n=="0"&&1/t==-ie?"-0":n}function cn(t){if(t!=null){try{return _o.call(t)}catch{}try{return t+""}catch{}}return""}function M1(t,n){return $r(be,function(a){var u="_."+a[0];n&a[1]&&!po(t,u)&&t.push(u)}),t.sort()}function Pl(t){if(t instanceof Ye)return t.clone();var n=new Ur(t.__wrapped__,t.__chain__);return n.__actions__=vr(t.__actions__),n.__index__=t.__index__,n.__values__=t.__values__,n}function j1(t,n,a){(a?cr(t,n,a):n===r)?n=1:n=kt(Me(n),0);var u=t==null?0:t.length;if(!u||n<1)return[];for(var d=0,y=0,D=V(xo(u/n));d<u;)D[y++]=Mr(t,d,d+=n);return D}function q1(t){for(var n=-1,a=t==null?0:t.length,u=0,d=[];++n<a;){var y=t[n];y&&(d[u++]=y)}return d}function H1(){var t=arguments.length;if(!t)return[];for(var n=V(t-1),a=arguments[0],u=t;u--;)n[u-1]=arguments[u];return $i(Re(a)?vr(a):[a],Yt(n,1))}var z1=ke(function(t,n){return Rt(t)?fs(t,Yt(n,1,Rt,!0)):[]}),B1=ke(function(t,n){var a=jr(n);return Rt(a)&&(a=r),Rt(t)?fs(t,Yt(n,1,Rt,!0),_e(a,2)):[]}),k1=ke(function(t,n){var a=jr(n);return Rt(a)&&(a=r),Rt(t)?fs(t,Yt(n,1,Rt,!0),r,a):[]});function K1(t,n,a){var u=t==null?0:t.length;return u?(n=a||n===r?1:Me(n),Mr(t,n<0?0:n,u)):[]}function V1(t,n,a){var u=t==null?0:t.length;return u?(n=a||n===r?1:Me(n),n=u-n,Mr(t,0,n<0?0:n)):[]}function W1(t,n){return t&&t.length?Uo(t,_e(n,3),!0,!0):[]}function G1(t,n){return t&&t.length?Uo(t,_e(n,3),!0):[]}function Y1(t,n,a,u){var d=t==null?0:t.length;return d?(a&&typeof a!="number"&&cr(t,n,a)&&(a=0,u=d),H0(t,n,a,u)):[]}function Al(t,n,a){var u=t==null?0:t.length;if(!u)return-1;var d=a==null?0:Me(a);return d<0&&(d=kt(u+d,0)),go(t,_e(n,3),d)}function Tl(t,n,a){var u=t==null?0:t.length;if(!u)return-1;var d=u-1;return a!==r&&(d=Me(a),d=a<0?kt(u+d,0):Xt(d,u-1)),go(t,_e(n,3),d,!0)}function Rl(t){var n=t==null?0:t.length;return n?Yt(t,1):[]}function J1(t){var n=t==null?0:t.length;return n?Yt(t,ie):[]}function Q1(t,n){var a=t==null?0:t.length;return a?(n=n===r?1:Me(n),Yt(t,n)):[]}function X1(t){for(var n=-1,a=t==null?0:t.length,u={};++n<a;){var d=t[n];u[d[0]]=d[1]}return u}function Nl(t){return t&&t.length?t[0]:r}function Z1(t,n,a){var u=t==null?0:t.length;if(!u)return-1;var d=a==null?0:Me(a);return d<0&&(d=kt(u+d,0)),Pn(t,n,d)}function ev(t){var n=t==null?0:t.length;return n?Mr(t,0,-1):[]}var tv=ke(function(t){var n=mt(t,Sc);return n.length&&n[0]===t[0]?pc(n):[]}),rv=ke(function(t){var n=jr(t),a=mt(t,Sc);return n===jr(a)?n=r:a.pop(),a.length&&a[0]===t[0]?pc(a,_e(n,2)):[]}),iv=ke(function(t){var n=jr(t),a=mt(t,Sc);return n=typeof n=="function"?n:r,n&&a.pop(),a.length&&a[0]===t[0]?pc(a,r,n):[]});function nv(t,n){return t==null?"":e0.call(t,n)}function jr(t){var n=t==null?0:t.length;return n?t[n-1]:r}function sv(t,n,a){var u=t==null?0:t.length;if(!u)return-1;var d=u;return a!==r&&(d=Me(a),d=d<0?kt(u+d,0):Xt(d,u-1)),n===n?Mg(t,n,d):go(t,dh,d,!0)}function ov(t,n){return t&&t.length?kh(t,Me(n)):r}var av=ke($l);function $l(t,n){return t&&t.length&&n&&n.length?mc(t,n):t}function cv(t,n,a){return t&&t.length&&n&&n.length?mc(t,n,_e(a,2)):t}function uv(t,n,a){return t&&t.length&&n&&n.length?mc(t,n,r,a):t}var hv=_i(function(t,n){var a=t==null?0:t.length,u=hc(t,n);return Wh(t,mt(n,function(d){return bi(d,a)?+d:d}).sort(il)),u});function lv(t,n){var a=[];if(!(t&&t.length))return a;var u=-1,d=[],y=t.length;for(n=_e(n,3);++u<y;){var D=t[u];n(D,u,t)&&(a.push(D),d.push(u))}return Wh(t,d),a}function Mc(t){return t==null?t:n0.call(t)}function fv(t,n,a){var u=t==null?0:t.length;return u?(a&&typeof a!="number"&&cr(t,n,a)?(n=0,a=u):(n=n==null?0:Me(n),a=a===r?u:Me(a)),Mr(t,n,a)):[]}function dv(t,n){return Lo(t,n)}function pv(t,n,a){return wc(t,n,_e(a,2))}function gv(t,n){var a=t==null?0:t.length;if(a){var u=Lo(t,n);if(u<a&&Gr(t[u],n))return u}return-1}function vv(t,n){return Lo(t,n,!0)}function yv(t,n,a){return wc(t,n,_e(a,2),!0)}function mv(t,n){var a=t==null?0:t.length;if(a){var u=Lo(t,n,!0)-1;if(Gr(t[u],n))return u}return-1}function _v(t){return t&&t.length?Yh(t):[]}function bv(t,n){return t&&t.length?Yh(t,_e(n,2)):[]}function wv(t){var n=t==null?0:t.length;return n?Mr(t,1,n):[]}function Ev(t,n,a){return t&&t.length?(n=a||n===r?1:Me(n),Mr(t,0,n<0?0:n)):[]}function Dv(t,n,a){var u=t==null?0:t.length;return u?(n=a||n===r?1:Me(n),n=u-n,Mr(t,n<0?0:n,u)):[]}function Sv(t,n){return t&&t.length?Uo(t,_e(n,3),!1,!0):[]}function Iv(t,n){return t&&t.length?Uo(t,_e(n,3)):[]}var xv=ke(function(t){return Mi(Yt(t,1,Rt,!0))}),Ov=ke(function(t){var n=jr(t);return Rt(n)&&(n=r),Mi(Yt(t,1,Rt,!0),_e(n,2))}),Cv=ke(function(t){var n=jr(t);return n=typeof n=="function"?n:r,Mi(Yt(t,1,Rt,!0),r,n)});function Pv(t){return t&&t.length?Mi(t):[]}function Av(t,n){return t&&t.length?Mi(t,_e(n,2)):[]}function Tv(t,n){return n=typeof n=="function"?n:r,t&&t.length?Mi(t,r,n):[]}function jc(t){if(!(t&&t.length))return[];var n=0;return t=Ni(t,function(a){if(Rt(a))return n=kt(a.length,n),!0}),rc(n,function(a){return mt(t,Za(a))})}function Ll(t,n){if(!(t&&t.length))return[];var a=jc(t);return n==null?a:mt(a,function(u){return Kt(n,r,u)})}var Rv=ke(function(t,n){return Rt(t)?fs(t,n):[]}),Nv=ke(function(t){return Dc(Ni(t,Rt))}),$v=ke(function(t){var n=jr(t);return Rt(n)&&(n=r),Dc(Ni(t,Rt),_e(n,2))}),Lv=ke(function(t){var n=jr(t);return n=typeof n=="function"?n:r,Dc(Ni(t,Rt),r,n)}),Uv=ke(jc);function Fv(t,n){return Zh(t||[],n||[],ls)}function Mv(t,n){return Zh(t||[],n||[],gs)}var jv=ke(function(t){var n=t.length,a=n>1?t[n-1]:r;return a=typeof a=="function"?(t.pop(),a):r,Ll(t,a)});function Ul(t){var n=v(t);return n.__chain__=!0,n}function qv(t,n){return n(t),t}function Ko(t,n){return n(t)}var Hv=_i(function(t){var n=t.length,a=n?t[0]:0,u=this.__wrapped__,d=function(y){return hc(y,t)};return n>1||this.__actions__.length||!(u instanceof Ye)||!bi(a)?this.thru(d):(u=u.slice(a,+a+(n?1:0)),u.__actions__.push({func:Ko,args:[d],thisArg:r}),new Ur(u,this.__chain__).thru(function(y){return n&&!y.length&&y.push(r),y}))});function zv(){return Ul(this)}function Bv(){return new Ur(this.value(),this.__chain__)}function kv(){this.__values__===r&&(this.__values__=Jl(this.value()));var t=this.__index__>=this.__values__.length,n=t?r:this.__values__[this.__index__++];return{done:t,value:n}}function Kv(){return this}function Vv(t){for(var n,a=this;a instanceof Ao;){var u=Pl(a);u.__index__=0,u.__values__=r,n?d.__wrapped__=u:n=u;var d=u;a=a.__wrapped__}return d.__wrapped__=t,n}function Wv(){var t=this.__wrapped__;if(t instanceof Ye){var n=t;return this.__actions__.length&&(n=new Ye(this)),n=n.reverse(),n.__actions__.push({func:Ko,args:[Mc],thisArg:r}),new Ur(n,this.__chain__)}return this.thru(Mc)}function Gv(){return Xh(this.__wrapped__,this.__actions__)}var Yv=Fo(function(t,n,a){nt.call(t,a)?++t[a]:yi(t,a,1)});function Jv(t,n,a){var u=Re(t)?lh:q0;return a&&cr(t,n,a)&&(n=r),u(t,_e(n,3))}function Qv(t,n){var a=Re(t)?Ni:Lh;return a(t,_e(n,3))}var Xv=ul(Al),Zv=ul(Tl);function ey(t,n){return Yt(Vo(t,n),1)}function ty(t,n){return Yt(Vo(t,n),ie)}function ry(t,n,a){return a=a===r?1:Me(a),Yt(Vo(t,n),a)}function Fl(t,n){var a=Re(t)?$r:Fi;return a(t,_e(n,3))}function Ml(t,n){var a=Re(t)?wg:$h;return a(t,_e(n,3))}var iy=Fo(function(t,n,a){nt.call(t,a)?t[a].push(n):yi(t,a,[n])});function ny(t,n,a,u){t=yr(t)?t:Hn(t),a=a&&!u?Me(a):0;var d=t.length;return a<0&&(a=kt(d+a,0)),Qo(t)?a<=d&&t.indexOf(n,a)>-1:!!d&&Pn(t,n,a)>-1}var sy=ke(function(t,n,a){var u=-1,d=typeof n=="function",y=yr(t)?V(t.length):[];return Fi(t,function(D){y[++u]=d?Kt(n,D,a):ds(D,n,a)}),y}),oy=Fo(function(t,n,a){yi(t,a,n)});function Vo(t,n){var a=Re(t)?mt:Hh;return a(t,_e(n,3))}function ay(t,n,a,u){return t==null?[]:(Re(n)||(n=n==null?[]:[n]),a=u?r:a,Re(a)||(a=a==null?[]:[a]),Kh(t,n,a))}var cy=Fo(function(t,n,a){t[a?0:1].push(n)},function(){return[[],[]]});function uy(t,n,a){var u=Re(t)?Qa:gh,d=arguments.length<3;return u(t,_e(n,4),a,d,Fi)}function hy(t,n,a){var u=Re(t)?Eg:gh,d=arguments.length<3;return u(t,_e(n,4),a,d,$h)}function ly(t,n){var a=Re(t)?Ni:Lh;return a(t,Yo(_e(n,3)))}function fy(t){var n=Re(t)?Ah:n1;return n(t)}function dy(t,n,a){(a?cr(t,n,a):n===r)?n=1:n=Me(n);var u=Re(t)?L0:s1;return u(t,n)}function py(t){var n=Re(t)?U0:a1;return n(t)}function gy(t){if(t==null)return 0;if(yr(t))return Qo(t)?Tn(t):t.length;var n=Zt(t);return n==Se||n==Ie?t.size:vc(t).length}function vy(t,n,a){var u=Re(t)?Xa:c1;return a&&cr(t,n,a)&&(n=r),u(t,_e(n,3))}var yy=ke(function(t,n){if(t==null)return[];var a=n.length;return a>1&&cr(t,n[0],n[1])?n=[]:a>2&&cr(n[0],n[1],n[2])&&(n=[n[0]]),Kh(t,Yt(n,1),[])}),Wo=Qg||function(){return Qe.Date.now()};function my(t,n){if(typeof n!="function")throw new Lr(p);return t=Me(t),function(){if(--t<1)return n.apply(this,arguments)}}function jl(t,n,a){return n=a?r:n,n=t&&n==null?t.length:n,mi(t,c,r,r,r,r,n)}function ql(t,n){var a;if(typeof n!="function")throw new Lr(p);return t=Me(t),function(){return--t>0&&(a=n.apply(this,arguments)),t<=1&&(n=r),a}}var qc=ke(function(t,n,a){var u=K;if(a.length){var d=Li(a,jn(qc));u|=I}return mi(t,u,n,a,d)}),Hl=ke(function(t,n,a){var u=K|ee;if(a.length){var d=Li(a,jn(Hl));u|=I}return mi(n,u,t,a,d)});function zl(t,n,a){n=a?r:n;var u=mi(t,$,r,r,r,r,r,n);return u.placeholder=zl.placeholder,u}function Bl(t,n,a){n=a?r:n;var u=mi(t,S,r,r,r,r,r,n);return u.placeholder=Bl.placeholder,u}function kl(t,n,a){var u,d,y,D,O,M,Q=0,X=!1,te=!1,ue=!0;if(typeof t!="function")throw new Lr(p);n=qr(n)||0,wt(a)&&(X=!!a.leading,te="maxWait"in a,y=te?kt(qr(a.maxWait)||0,n):y,ue="trailing"in a?!!a.trailing:ue);function ve(Nt){var Yr=u,Di=d;return u=d=r,Q=Nt,D=t.apply(Di,Yr),D}function we(Nt){return Q=Nt,O=ms(We,n),X?ve(Nt):D}function He(Nt){var Yr=Nt-M,Di=Nt-Q,hf=n-Yr;return te?Xt(hf,y-Di):hf}function Ee(Nt){var Yr=Nt-M,Di=Nt-Q;return M===r||Yr>=n||Yr<0||te&&Di>=y}function We(){var Nt=Wo();if(Ee(Nt))return Xe(Nt);O=ms(We,He(Nt))}function Xe(Nt){return O=r,ue&&u?ve(Nt):(u=d=r,D)}function Or(){O!==r&&el(O),Q=0,u=M=d=O=r}function ur(){return O===r?D:Xe(Wo())}function Cr(){var Nt=Wo(),Yr=Ee(Nt);if(u=arguments,d=this,M=Nt,Yr){if(O===r)return we(M);if(te)return el(O),O=ms(We,n),ve(M)}return O===r&&(O=ms(We,n)),D}return Cr.cancel=Or,Cr.flush=ur,Cr}var _y=ke(function(t,n){return Nh(t,1,n)}),by=ke(function(t,n,a){return Nh(t,qr(n)||0,a)});function wy(t){return mi(t,B)}function Go(t,n){if(typeof t!="function"||n!=null&&typeof n!="function")throw new Lr(p);var a=function(){var u=arguments,d=n?n.apply(this,u):u[0],y=a.cache;if(y.has(d))return y.get(d);var D=t.apply(this,u);return a.cache=y.set(d,D)||y,D};return a.cache=new(Go.Cache||vi),a}Go.Cache=vi;function Yo(t){if(typeof t!="function")throw new Lr(p);return function(){var n=arguments;switch(n.length){case 0:return!t.call(this);case 1:return!t.call(this,n[0]);case 2:return!t.call(this,n[0],n[1]);case 3:return!t.call(this,n[0],n[1],n[2])}return!t.apply(this,n)}}function Ey(t){return ql(2,t)}var Dy=u1(function(t,n){n=n.length==1&&Re(n[0])?mt(n[0],Sr(_e())):mt(Yt(n,1),Sr(_e()));var a=n.length;return ke(function(u){for(var d=-1,y=Xt(u.length,a);++d<y;)u[d]=n[d].call(this,u[d]);return Kt(t,this,u)})}),Hc=ke(function(t,n){var a=Li(n,jn(Hc));return mi(t,I,r,n,a)}),Kl=ke(function(t,n){var a=Li(n,jn(Kl));return mi(t,_,r,n,a)}),Sy=_i(function(t,n){return mi(t,m,r,r,r,n)});function Iy(t,n){if(typeof t!="function")throw new Lr(p);return n=n===r?n:Me(n),ke(t,n)}function xy(t,n){if(typeof t!="function")throw new Lr(p);return n=n==null?0:kt(Me(n),0),ke(function(a){var u=a[n],d=qi(a,0,n);return u&&$i(d,u),Kt(t,this,d)})}function Oy(t,n,a){var u=!0,d=!0;if(typeof t!="function")throw new Lr(p);return wt(a)&&(u="leading"in a?!!a.leading:u,d="trailing"in a?!!a.trailing:d),kl(t,n,{leading:u,maxWait:n,trailing:d})}function Cy(t){return jl(t,1)}function Py(t,n){return Hc(Ic(n),t)}function Ay(){if(!arguments.length)return[];var t=arguments[0];return Re(t)?t:[t]}function Ty(t){return Fr(t,P)}function Ry(t,n){return n=typeof n=="function"?n:r,Fr(t,P,n)}function Ny(t){return Fr(t,C|P)}function $y(t,n){return n=typeof n=="function"?n:r,Fr(t,C|P,n)}function Ly(t,n){return n==null||Rh(t,n,Vt(n))}function Gr(t,n){return t===n||t!==t&&n!==n}var Uy=Ho(dc),Fy=Ho(function(t,n){return t>=n}),un=Mh(function(){return arguments}())?Mh:function(t){return Pt(t)&&nt.call(t,"callee")&&!Sh.call(t,"callee")},Re=V.isArray,My=or?Sr(or):V0;function yr(t){return t!=null&&Jo(t.length)&&!wi(t)}function Rt(t){return Pt(t)&&yr(t)}function jy(t){return t===!0||t===!1||Pt(t)&&ar(t)==j}var Hi=Zg||Xc,qy=Kr?Sr(Kr):W0;function Hy(t){return Pt(t)&&t.nodeType===1&&!_s(t)}function zy(t){if(t==null)return!0;if(yr(t)&&(Re(t)||typeof t=="string"||typeof t.splice=="function"||Hi(t)||qn(t)||un(t)))return!t.length;var n=Zt(t);if(n==Se||n==Ie)return!t.size;if(ys(t))return!vc(t).length;for(var a in t)if(nt.call(t,a))return!1;return!0}function By(t,n){return ps(t,n)}function ky(t,n,a){a=typeof a=="function"?a:r;var u=a?a(t,n):r;return u===r?ps(t,n,r,a):!!u}function zc(t){if(!Pt(t))return!1;var n=ar(t);return n==x||n==l||typeof t.message=="string"&&typeof t.name=="string"&&!_s(t)}function Ky(t){return typeof t=="number"&&xh(t)}function wi(t){if(!wt(t))return!1;var n=ar(t);return n==ae||n==de||n==q||n==gt}function Vl(t){return typeof t=="number"&&t==Me(t)}function Jo(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=Y}function wt(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}function Pt(t){return t!=null&&typeof t=="object"}var Wl=Nr?Sr(Nr):Y0;function Vy(t,n){return t===n||gc(t,n,Rc(n))}function Wy(t,n,a){return a=typeof a=="function"?a:r,gc(t,n,Rc(n),a)}function Gy(t){return Gl(t)&&t!=+t}function Yy(t){if(R1(t))throw new Ae(h);return jh(t)}function Jy(t){return t===null}function Qy(t){return t==null}function Gl(t){return typeof t=="number"||Pt(t)&&ar(t)==ze}function _s(t){if(!Pt(t)||ar(t)!=Fe)return!1;var n=Do(t);if(n===null)return!0;var a=nt.call(n,"constructor")&&n.constructor;return typeof a=="function"&&a instanceof a&&_o.call(a)==Wg}var Bc=ri?Sr(ri):J0;function Xy(t){return Vl(t)&&t>=-Y&&t<=Y}var Yl=ns?Sr(ns):Q0;function Qo(t){return typeof t=="string"||!Re(t)&&Pt(t)&&ar(t)==Ne}function xr(t){return typeof t=="symbol"||Pt(t)&&ar(t)==$e}var qn=en?Sr(en):X0;function Zy(t){return t===r}function em(t){return Pt(t)&&Zt(t)==Ce}function tm(t){return Pt(t)&&ar(t)==Le}var rm=Ho(yc),im=Ho(function(t,n){return t<=n});function Jl(t){if(!t)return[];if(yr(t))return Qo(t)?Vr(t):vr(t);if(os&&t[os])return Lg(t[os]());var n=Zt(t),a=n==Se?nc:n==Ie?vo:Hn;return a(t)}function Ei(t){if(!t)return t===0?t:0;if(t=qr(t),t===ie||t===-ie){var n=t<0?-1:1;return n*re}return t===t?t:0}function Me(t){var n=Ei(t),a=n%1;return n===n?a?n-a:n:0}function Ql(t){return t?sn(Me(t),0,ne):0}function qr(t){if(typeof t=="number")return t;if(xr(t))return J;if(wt(t)){var n=typeof t.valueOf=="function"?t.valueOf():t;t=wt(n)?n+"":n}if(typeof t!="string")return t===0?t:+t;t=vh(t);var a=Na.test(t);return a||La.test(t)?Te(t.slice(2),a?2:8):Ra.test(t)?J:+t}function Xl(t){return ni(t,mr(t))}function nm(t){return t?sn(Me(t),-Y,Y):t===0?t:0}function it(t){return t==null?"":Ir(t)}var sm=Fn(function(t,n){if(ys(n)||yr(n)){ni(n,Vt(n),t);return}for(var a in n)nt.call(n,a)&&ls(t,a,n[a])}),Zl=Fn(function(t,n){ni(n,mr(n),t)}),Xo=Fn(function(t,n,a,u){ni(n,mr(n),t,u)}),om=Fn(function(t,n,a,u){ni(n,Vt(n),t,u)}),am=_i(hc);function cm(t,n){var a=Un(t);return n==null?a:Th(a,n)}var um=ke(function(t,n){t=ut(t);var a=-1,u=n.length,d=u>2?n[2]:r;for(d&&cr(n[0],n[1],d)&&(u=1);++a<u;)for(var y=n[a],D=mr(y),O=-1,M=D.length;++O<M;){var Q=D[O],X=t[Q];(X===r||Gr(X,Nn[Q])&&!nt.call(t,Q))&&(t[Q]=y[Q])}return t}),hm=ke(function(t){return t.push(r,vl),Kt(ef,r,t)});function lm(t,n){return fh(t,_e(n,3),ii)}function fm(t,n){return fh(t,_e(n,3),fc)}function dm(t,n){return t==null?t:lc(t,_e(n,3),mr)}function pm(t,n){return t==null?t:Uh(t,_e(n,3),mr)}function gm(t,n){return t&&ii(t,_e(n,3))}function vm(t,n){return t&&fc(t,_e(n,3))}function ym(t){return t==null?[]:No(t,Vt(t))}function mm(t){return t==null?[]:No(t,mr(t))}function kc(t,n,a){var u=t==null?r:on(t,n);return u===r?a:u}function _m(t,n){return t!=null&&_l(t,n,z0)}function Kc(t,n){return t!=null&&_l(t,n,B0)}var bm=ll(function(t,n,a){n!=null&&typeof n.toString!="function"&&(n=bo.call(n)),t[n]=a},Wc(_r)),wm=ll(function(t,n,a){n!=null&&typeof n.toString!="function"&&(n=bo.call(n)),nt.call(t,n)?t[n].push(a):t[n]=[a]},_e),Em=ke(ds);function Vt(t){return yr(t)?Ph(t):vc(t)}function mr(t){return yr(t)?Ph(t,!0):Z0(t)}function Dm(t,n){var a={};return n=_e(n,3),ii(t,function(u,d,y){yi(a,n(u,d,y),u)}),a}function Sm(t,n){var a={};return n=_e(n,3),ii(t,function(u,d,y){yi(a,d,n(u,d,y))}),a}var Im=Fn(function(t,n,a){$o(t,n,a)}),ef=Fn(function(t,n,a,u){$o(t,n,a,u)}),xm=_i(function(t,n){var a={};if(t==null)return a;var u=!1;n=mt(n,function(y){return y=ji(y,t),u||(u=y.length>1),y}),ni(t,Ac(t),a),u&&(a=Fr(a,C|N|P,b1));for(var d=n.length;d--;)Ec(a,n[d]);return a});function Om(t,n){return tf(t,Yo(_e(n)))}var Cm=_i(function(t,n){return t==null?{}:t1(t,n)});function tf(t,n){if(t==null)return{};var a=mt(Ac(t),function(u){return[u]});return n=_e(n),Vh(t,a,function(u,d){return n(u,d[0])})}function Pm(t,n,a){n=ji(n,t);var u=-1,d=n.length;for(d||(d=1,t=r);++u<d;){var y=t==null?r:t[si(n[u])];y===r&&(u=d,y=a),t=wi(y)?y.call(t):y}return t}function Am(t,n,a){return t==null?t:gs(t,n,a)}function Tm(t,n,a,u){return u=typeof u=="function"?u:r,t==null?t:gs(t,n,a,u)}var rf=pl(Vt),nf=pl(mr);function Rm(t,n,a){var u=Re(t),d=u||Hi(t)||qn(t);if(n=_e(n,4),a==null){var y=t&&t.constructor;d?a=u?new y:[]:wt(t)?a=wi(y)?Un(Do(t)):{}:a={}}return(d?$r:ii)(t,function(D,O,M){return n(a,D,O,M)}),a}function Nm(t,n){return t==null?!0:Ec(t,n)}function $m(t,n,a){return t==null?t:Qh(t,n,Ic(a))}function Lm(t,n,a,u){return u=typeof u=="function"?u:r,t==null?t:Qh(t,n,Ic(a),u)}function Hn(t){return t==null?[]:ic(t,Vt(t))}function Um(t){return t==null?[]:ic(t,mr(t))}function Fm(t,n,a){return a===r&&(a=n,n=r),a!==r&&(a=qr(a),a=a===a?a:0),n!==r&&(n=qr(n),n=n===n?n:0),sn(qr(t),n,a)}function Mm(t,n,a){return n=Ei(n),a===r?(a=n,n=0):a=Ei(a),t=qr(t),k0(t,n,a)}function jm(t,n,a){if(a&&typeof a!="boolean"&&cr(t,n,a)&&(n=a=r),a===r&&(typeof n=="boolean"?(a=n,n=r):typeof t=="boolean"&&(a=t,t=r)),t===r&&n===r?(t=0,n=1):(t=Ei(t),n===r?(n=t,t=0):n=Ei(n)),t>n){var u=t;t=n,n=u}if(a||t%1||n%1){var d=Oh();return Xt(t+d*(n-t+at("1e-"+((d+"").length-1))),n)}return _c(t,n)}var qm=Mn(function(t,n,a){return n=n.toLowerCase(),t+(a?sf(n):n)});function sf(t){return Vc(it(t).toLowerCase())}function of(t){return t=it(t),t&&t.replace(di,Ag).replace(Ga,"")}function Hm(t,n,a){t=it(t),n=Ir(n);var u=t.length;a=a===r?u:sn(Me(a),0,u);var d=a;return a-=n.length,a>=0&&t.slice(a,d)==n}function zm(t){return t=it(t),t&&vt.test(t)?t.replace(Yi,Tg):t}function Bm(t){return t=it(t),t&&Ft.test(t)?t.replace(xt,"\\$&"):t}var km=Mn(function(t,n,a){return t+(a?"-":"")+n.toLowerCase()}),Km=Mn(function(t,n,a){return t+(a?" ":"")+n.toLowerCase()}),Vm=cl("toLowerCase");function Wm(t,n,a){t=it(t),n=Me(n);var u=n?Tn(t):0;if(!n||u>=n)return t;var d=(n-u)/2;return qo(Oo(d),a)+t+qo(xo(d),a)}function Gm(t,n,a){t=it(t),n=Me(n);var u=n?Tn(t):0;return n&&u<n?t+qo(n-u,a):t}function Ym(t,n,a){t=it(t),n=Me(n);var u=n?Tn(t):0;return n&&u<n?qo(n-u,a)+t:t}function Jm(t,n,a){return a||n==null?n=0:n&&(n=+n),i0(it(t).replace(Ot,""),n||0)}function Qm(t,n,a){return(a?cr(t,n,a):n===r)?n=1:n=Me(n),bc(it(t),n)}function Xm(){var t=arguments,n=it(t[0]);return t.length<3?n:n.replace(t[1],t[2])}var Zm=Mn(function(t,n,a){return t+(a?"_":"")+n.toLowerCase()});function e_(t,n,a){return a&&typeof a!="number"&&cr(t,n,a)&&(n=a=r),a=a===r?ne:a>>>0,a?(t=it(t),t&&(typeof n=="string"||n!=null&&!Bc(n))&&(n=Ir(n),!n&&An(t))?qi(Vr(t),0,a):t.split(n,a)):[]}var t_=Mn(function(t,n,a){return t+(a?" ":"")+Vc(n)});function r_(t,n,a){return t=it(t),a=a==null?0:sn(Me(a),0,t.length),n=Ir(n),t.slice(a,a+n.length)==n}function i_(t,n,a){var u=v.templateSettings;a&&cr(t,n,a)&&(n=r),t=it(t),n=Xo({},n,u,gl);var d=Xo({},n.imports,u.imports,gl),y=Vt(d),D=ic(d,y),O,M,Q=0,X=n.interpolate||En,te="__p += '",ue=sc((n.escape||En).source+"|"+X.source+"|"+(X===bt?Ta:En).source+"|"+(n.evaluate||En).source+"|$","g"),ve="//# sourceURL="+(nt.call(n,"sourceURL")?(n.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++Ya+"]")+`
|
|
17
|
+
`;t.replace(ue,function(Ee,We,Xe,Or,ur,Cr){return Xe||(Xe=Or),te+=t.slice(Q,Cr).replace(Fa,Rg),We&&(O=!0,te+=`' +
|
|
18
|
+
__e(`+We+`) +
|
|
19
|
+
'`),ur&&(M=!0,te+=`';
|
|
20
|
+
`+ur+`;
|
|
21
|
+
__p += '`),Xe&&(te+=`' +
|
|
22
|
+
((__t = (`+Xe+`)) == null ? '' : __t) +
|
|
23
|
+
'`),Q=Cr+Ee.length,Ee}),te+=`';
|
|
24
|
+
`;var we=nt.call(n,"variable")&&n.variable;if(!we)te=`with (obj) {
|
|
25
|
+
`+te+`
|
|
26
|
+
}
|
|
27
|
+
`;else if(Pa.test(we))throw new Ae(f);te=(M?te.replace(ei,""):te).replace(sr,"$1").replace(fi,"$1;"),te="function("+(we||"obj")+`) {
|
|
28
|
+
`+(we?"":`obj || (obj = {});
|
|
29
|
+
`)+"var __t, __p = ''"+(O?", __e = _.escape":"")+(M?`, __j = Array.prototype.join;
|
|
30
|
+
function print() { __p += __j.call(arguments, '') }
|
|
31
|
+
`:`;
|
|
32
|
+
`)+te+`return __p
|
|
33
|
+
}`;var He=cf(function(){return rt(y,ve+"return "+te).apply(r,D)});if(He.source=te,zc(He))throw He;return He}function n_(t){return it(t).toLowerCase()}function s_(t){return it(t).toUpperCase()}function o_(t,n,a){if(t=it(t),t&&(a||n===r))return vh(t);if(!t||!(n=Ir(n)))return t;var u=Vr(t),d=Vr(n),y=yh(u,d),D=mh(u,d)+1;return qi(u,y,D).join("")}function a_(t,n,a){if(t=it(t),t&&(a||n===r))return t.slice(0,bh(t)+1);if(!t||!(n=Ir(n)))return t;var u=Vr(t),d=mh(u,Vr(n))+1;return qi(u,0,d).join("")}function c_(t,n,a){if(t=it(t),t&&(a||n===r))return t.replace(Ot,"");if(!t||!(n=Ir(n)))return t;var u=Vr(t),d=yh(u,Vr(n));return qi(u,d).join("")}function u_(t,n){var a=z,u=W;if(wt(n)){var d="separator"in n?n.separator:d;a="length"in n?Me(n.length):a,u="omission"in n?Ir(n.omission):u}t=it(t);var y=t.length;if(An(t)){var D=Vr(t);y=D.length}if(a>=y)return t;var O=a-Tn(u);if(O<1)return u;var M=D?qi(D,0,O).join(""):t.slice(0,O);if(d===r)return M+u;if(D&&(O+=M.length-O),Bc(d)){if(t.slice(O).search(d)){var Q,X=M;for(d.global||(d=sc(d.source,it(Rr.exec(d))+"g")),d.lastIndex=0;Q=d.exec(X);)var te=Q.index;M=M.slice(0,te===r?O:te)}}else if(t.indexOf(Ir(d),O)!=O){var ue=M.lastIndexOf(d);ue>-1&&(M=M.slice(0,ue))}return M+u}function h_(t){return t=it(t),t&&Dt.test(t)?t.replace(Ti,jg):t}var l_=Mn(function(t,n,a){return t+(a?" ":"")+n.toUpperCase()}),Vc=cl("toUpperCase");function af(t,n,a){return t=it(t),n=a?r:n,n===r?$g(t)?zg(t):Ig(t):t.match(n)||[]}var cf=ke(function(t,n){try{return Kt(t,r,n)}catch(a){return zc(a)?a:new Ae(a)}}),f_=_i(function(t,n){return $r(n,function(a){a=si(a),yi(t,a,qc(t[a],t))}),t});function d_(t){var n=t==null?0:t.length,a=_e();return t=n?mt(t,function(u){if(typeof u[1]!="function")throw new Lr(p);return[a(u[0]),u[1]]}):[],ke(function(u){for(var d=-1;++d<n;){var y=t[d];if(Kt(y[0],this,u))return Kt(y[1],this,u)}})}function p_(t){return j0(Fr(t,C))}function Wc(t){return function(){return t}}function g_(t,n){return t==null||t!==t?n:t}var v_=hl(),y_=hl(!0);function _r(t){return t}function Gc(t){return qh(typeof t=="function"?t:Fr(t,C))}function m_(t){return zh(Fr(t,C))}function __(t,n){return Bh(t,Fr(n,C))}var b_=ke(function(t,n){return function(a){return ds(a,t,n)}}),w_=ke(function(t,n){return function(a){return ds(t,a,n)}});function Yc(t,n,a){var u=Vt(n),d=No(n,u);a==null&&!(wt(n)&&(d.length||!u.length))&&(a=n,n=t,t=this,d=No(n,Vt(n)));var y=!(wt(a)&&"chain"in a)||!!a.chain,D=wi(t);return $r(d,function(O){var M=n[O];t[O]=M,D&&(t.prototype[O]=function(){var Q=this.__chain__;if(y||Q){var X=t(this.__wrapped__),te=X.__actions__=vr(this.__actions__);return te.push({func:M,args:arguments,thisArg:t}),X.__chain__=Q,X}return M.apply(t,$i([this.value()],arguments))})}),t}function E_(){return Qe._===this&&(Qe._=Gg),this}function Jc(){}function D_(t){return t=Me(t),ke(function(n){return kh(n,t)})}var S_=Oc(mt),I_=Oc(lh),x_=Oc(Xa);function uf(t){return $c(t)?Za(si(t)):r1(t)}function O_(t){return function(n){return t==null?r:on(t,n)}}var C_=fl(),P_=fl(!0);function Qc(){return[]}function Xc(){return!1}function A_(){return{}}function T_(){return""}function R_(){return!0}function N_(t,n){if(t=Me(t),t<1||t>Y)return[];var a=ne,u=Xt(t,ne);n=_e(n),t-=ne;for(var d=rc(u,n);++a<t;)n(a);return d}function $_(t){return Re(t)?mt(t,si):xr(t)?[t]:vr(Cl(it(t)))}function L_(t){var n=++Vg;return it(t)+n}var U_=jo(function(t,n){return t+n},0),F_=Cc("ceil"),M_=jo(function(t,n){return t/n},1),j_=Cc("floor");function q_(t){return t&&t.length?Ro(t,_r,dc):r}function H_(t,n){return t&&t.length?Ro(t,_e(n,2),dc):r}function z_(t){return ph(t,_r)}function B_(t,n){return ph(t,_e(n,2))}function k_(t){return t&&t.length?Ro(t,_r,yc):r}function K_(t,n){return t&&t.length?Ro(t,_e(n,2),yc):r}var V_=jo(function(t,n){return t*n},1),W_=Cc("round"),G_=jo(function(t,n){return t-n},0);function Y_(t){return t&&t.length?tc(t,_r):0}function J_(t,n){return t&&t.length?tc(t,_e(n,2)):0}return v.after=my,v.ary=jl,v.assign=sm,v.assignIn=Zl,v.assignInWith=Xo,v.assignWith=om,v.at=am,v.before=ql,v.bind=qc,v.bindAll=f_,v.bindKey=Hl,v.castArray=Ay,v.chain=Ul,v.chunk=j1,v.compact=q1,v.concat=H1,v.cond=d_,v.conforms=p_,v.constant=Wc,v.countBy=Yv,v.create=cm,v.curry=zl,v.curryRight=Bl,v.debounce=kl,v.defaults=um,v.defaultsDeep=hm,v.defer=_y,v.delay=by,v.difference=z1,v.differenceBy=B1,v.differenceWith=k1,v.drop=K1,v.dropRight=V1,v.dropRightWhile=W1,v.dropWhile=G1,v.fill=Y1,v.filter=Qv,v.flatMap=ey,v.flatMapDeep=ty,v.flatMapDepth=ry,v.flatten=Rl,v.flattenDeep=J1,v.flattenDepth=Q1,v.flip=wy,v.flow=v_,v.flowRight=y_,v.fromPairs=X1,v.functions=ym,v.functionsIn=mm,v.groupBy=iy,v.initial=ev,v.intersection=tv,v.intersectionBy=rv,v.intersectionWith=iv,v.invert=bm,v.invertBy=wm,v.invokeMap=sy,v.iteratee=Gc,v.keyBy=oy,v.keys=Vt,v.keysIn=mr,v.map=Vo,v.mapKeys=Dm,v.mapValues=Sm,v.matches=m_,v.matchesProperty=__,v.memoize=Go,v.merge=Im,v.mergeWith=ef,v.method=b_,v.methodOf=w_,v.mixin=Yc,v.negate=Yo,v.nthArg=D_,v.omit=xm,v.omitBy=Om,v.once=Ey,v.orderBy=ay,v.over=S_,v.overArgs=Dy,v.overEvery=I_,v.overSome=x_,v.partial=Hc,v.partialRight=Kl,v.partition=cy,v.pick=Cm,v.pickBy=tf,v.property=uf,v.propertyOf=O_,v.pull=av,v.pullAll=$l,v.pullAllBy=cv,v.pullAllWith=uv,v.pullAt=hv,v.range=C_,v.rangeRight=P_,v.rearg=Sy,v.reject=ly,v.remove=lv,v.rest=Iy,v.reverse=Mc,v.sampleSize=dy,v.set=Am,v.setWith=Tm,v.shuffle=py,v.slice=fv,v.sortBy=yy,v.sortedUniq=_v,v.sortedUniqBy=bv,v.split=e_,v.spread=xy,v.tail=wv,v.take=Ev,v.takeRight=Dv,v.takeRightWhile=Sv,v.takeWhile=Iv,v.tap=qv,v.throttle=Oy,v.thru=Ko,v.toArray=Jl,v.toPairs=rf,v.toPairsIn=nf,v.toPath=$_,v.toPlainObject=Xl,v.transform=Rm,v.unary=Cy,v.union=xv,v.unionBy=Ov,v.unionWith=Cv,v.uniq=Pv,v.uniqBy=Av,v.uniqWith=Tv,v.unset=Nm,v.unzip=jc,v.unzipWith=Ll,v.update=$m,v.updateWith=Lm,v.values=Hn,v.valuesIn=Um,v.without=Rv,v.words=af,v.wrap=Py,v.xor=Nv,v.xorBy=$v,v.xorWith=Lv,v.zip=Uv,v.zipObject=Fv,v.zipObjectDeep=Mv,v.zipWith=jv,v.entries=rf,v.entriesIn=nf,v.extend=Zl,v.extendWith=Xo,Yc(v,v),v.add=U_,v.attempt=cf,v.camelCase=qm,v.capitalize=sf,v.ceil=F_,v.clamp=Fm,v.clone=Ty,v.cloneDeep=Ny,v.cloneDeepWith=$y,v.cloneWith=Ry,v.conformsTo=Ly,v.deburr=of,v.defaultTo=g_,v.divide=M_,v.endsWith=Hm,v.eq=Gr,v.escape=zm,v.escapeRegExp=Bm,v.every=Jv,v.find=Xv,v.findIndex=Al,v.findKey=lm,v.findLast=Zv,v.findLastIndex=Tl,v.findLastKey=fm,v.floor=j_,v.forEach=Fl,v.forEachRight=Ml,v.forIn=dm,v.forInRight=pm,v.forOwn=gm,v.forOwnRight=vm,v.get=kc,v.gt=Uy,v.gte=Fy,v.has=_m,v.hasIn=Kc,v.head=Nl,v.identity=_r,v.includes=ny,v.indexOf=Z1,v.inRange=Mm,v.invoke=Em,v.isArguments=un,v.isArray=Re,v.isArrayBuffer=My,v.isArrayLike=yr,v.isArrayLikeObject=Rt,v.isBoolean=jy,v.isBuffer=Hi,v.isDate=qy,v.isElement=Hy,v.isEmpty=zy,v.isEqual=By,v.isEqualWith=ky,v.isError=zc,v.isFinite=Ky,v.isFunction=wi,v.isInteger=Vl,v.isLength=Jo,v.isMap=Wl,v.isMatch=Vy,v.isMatchWith=Wy,v.isNaN=Gy,v.isNative=Yy,v.isNil=Qy,v.isNull=Jy,v.isNumber=Gl,v.isObject=wt,v.isObjectLike=Pt,v.isPlainObject=_s,v.isRegExp=Bc,v.isSafeInteger=Xy,v.isSet=Yl,v.isString=Qo,v.isSymbol=xr,v.isTypedArray=qn,v.isUndefined=Zy,v.isWeakMap=em,v.isWeakSet=tm,v.join=nv,v.kebabCase=km,v.last=jr,v.lastIndexOf=sv,v.lowerCase=Km,v.lowerFirst=Vm,v.lt=rm,v.lte=im,v.max=q_,v.maxBy=H_,v.mean=z_,v.meanBy=B_,v.min=k_,v.minBy=K_,v.stubArray=Qc,v.stubFalse=Xc,v.stubObject=A_,v.stubString=T_,v.stubTrue=R_,v.multiply=V_,v.nth=ov,v.noConflict=E_,v.noop=Jc,v.now=Wo,v.pad=Wm,v.padEnd=Gm,v.padStart=Ym,v.parseInt=Jm,v.random=jm,v.reduce=uy,v.reduceRight=hy,v.repeat=Qm,v.replace=Xm,v.result=Pm,v.round=W_,v.runInContext=U,v.sample=fy,v.size=gy,v.snakeCase=Zm,v.some=vy,v.sortedIndex=dv,v.sortedIndexBy=pv,v.sortedIndexOf=gv,v.sortedLastIndex=vv,v.sortedLastIndexBy=yv,v.sortedLastIndexOf=mv,v.startCase=t_,v.startsWith=r_,v.subtract=G_,v.sum=Y_,v.sumBy=J_,v.template=i_,v.times=N_,v.toFinite=Ei,v.toInteger=Me,v.toLength=Ql,v.toLower=n_,v.toNumber=qr,v.toSafeInteger=nm,v.toString=it,v.toUpper=s_,v.trim=o_,v.trimEnd=a_,v.trimStart=c_,v.truncate=u_,v.unescape=h_,v.uniqueId=L_,v.upperCase=l_,v.upperFirst=Vc,v.each=Fl,v.eachRight=Ml,v.first=Nl,Yc(v,function(){var t={};return ii(v,function(n,a){nt.call(v.prototype,a)||(t[a]=n)}),t}(),{chain:!1}),v.VERSION=s,$r(["bind","bindKey","curry","curryRight","partial","partialRight"],function(t){v[t].placeholder=v}),$r(["drop","take"],function(t,n){Ye.prototype[t]=function(a){a=a===r?1:kt(Me(a),0);var u=this.__filtered__&&!n?new Ye(this):this.clone();return u.__filtered__?u.__takeCount__=Xt(a,u.__takeCount__):u.__views__.push({size:Xt(a,ne),type:t+(u.__dir__<0?"Right":"")}),u},Ye.prototype[t+"Right"]=function(a){return this.reverse()[t](a).reverse()}}),$r(["filter","map","takeWhile"],function(t,n){var a=n+1,u=a==T||a==ce;Ye.prototype[t]=function(d){var y=this.clone();return y.__iteratees__.push({iteratee:_e(d,3),type:a}),y.__filtered__=y.__filtered__||u,y}}),$r(["head","last"],function(t,n){var a="take"+(n?"Right":"");Ye.prototype[t]=function(){return this[a](1).value()[0]}}),$r(["initial","tail"],function(t,n){var a="drop"+(n?"":"Right");Ye.prototype[t]=function(){return this.__filtered__?new Ye(this):this[a](1)}}),Ye.prototype.compact=function(){return this.filter(_r)},Ye.prototype.find=function(t){return this.filter(t).head()},Ye.prototype.findLast=function(t){return this.reverse().find(t)},Ye.prototype.invokeMap=ke(function(t,n){return typeof t=="function"?new Ye(this):this.map(function(a){return ds(a,t,n)})}),Ye.prototype.reject=function(t){return this.filter(Yo(_e(t)))},Ye.prototype.slice=function(t,n){t=Me(t);var a=this;return a.__filtered__&&(t>0||n<0)?new Ye(a):(t<0?a=a.takeRight(-t):t&&(a=a.drop(t)),n!==r&&(n=Me(n),a=n<0?a.dropRight(-n):a.take(n-t)),a)},Ye.prototype.takeRightWhile=function(t){return this.reverse().takeWhile(t).reverse()},Ye.prototype.toArray=function(){return this.take(ne)},ii(Ye.prototype,function(t,n){var a=/^(?:filter|find|map|reject)|While$/.test(n),u=/^(?:head|last)$/.test(n),d=v[u?"take"+(n=="last"?"Right":""):n],y=u||/^find/.test(n);d&&(v.prototype[n]=function(){var D=this.__wrapped__,O=u?[1]:arguments,M=D instanceof Ye,Q=O[0],X=M||Re(D),te=function(We){var Xe=d.apply(v,$i([We],O));return u&&ue?Xe[0]:Xe};X&&a&&typeof Q=="function"&&Q.length!=1&&(M=X=!1);var ue=this.__chain__,ve=!!this.__actions__.length,we=y&&!ue,He=M&&!ve;if(!y&&X){D=He?D:new Ye(this);var Ee=t.apply(D,O);return Ee.__actions__.push({func:Ko,args:[te],thisArg:r}),new Ur(Ee,ue)}return we&&He?t.apply(this,O):(Ee=this.thru(te),we?u?Ee.value()[0]:Ee.value():Ee)})}),$r(["pop","push","shift","sort","splice","unshift"],function(t){var n=yo[t],a=/^(?:push|sort|unshift)$/.test(t)?"tap":"thru",u=/^(?:pop|shift)$/.test(t);v.prototype[t]=function(){var d=arguments;if(u&&!this.__chain__){var y=this.value();return n.apply(Re(y)?y:[],d)}return this[a](function(D){return n.apply(Re(D)?D:[],d)})}}),ii(Ye.prototype,function(t,n){var a=v[n];if(a){var u=a.name+"";nt.call(Ln,u)||(Ln[u]=[]),Ln[u].push({name:n,func:a})}}),Ln[Mo(r,ee).name]=[{name:"wrapper",func:r}],Ye.prototype.clone=h0,Ye.prototype.reverse=l0,Ye.prototype.value=f0,v.prototype.at=Hv,v.prototype.chain=zv,v.prototype.commit=Bv,v.prototype.next=kv,v.prototype.plant=Vv,v.prototype.reverse=Wv,v.prototype.toJSON=v.prototype.valueOf=v.prototype.value=Gv,v.prototype.first=v.prototype.head,os&&(v.prototype[os]=Kv),v},Rn=Bg();Tt?((Tt.exports=Rn)._=Rn,ct._=Rn):Qe._=Rn}).call(Rs)})(Hu,Hu.exports);var y5=Object.defineProperty,m5=Object.defineProperties,_5=Object.getOwnPropertyDescriptors,Jd=Object.getOwnPropertySymbols,b5=Object.prototype.hasOwnProperty,w5=Object.prototype.propertyIsEnumerable,Qd=(i,e,r)=>e in i?y5(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,na=(i,e)=>{for(var r in e||(e={}))b5.call(e,r)&&Qd(i,r,e[r]);if(Jd)for(var r of Jd(e))w5.call(e,r)&&Qd(i,r,e[r]);return i},E5=(i,e)=>m5(i,_5(e));function Ki(i,e,r){var s;const o=GE(i);return((s=e.rpcMap)==null?void 0:s[o.reference])||`${v5}?chainId=${o.namespace}:${o.reference}&projectId=${r}`}function wn(i){return i.includes(":")?i.split(":")[1]:i}function vg(i){return i.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function D5(i,e){const r=Object.keys(e.namespaces).filter(o=>o.includes(i));if(!r.length)return[];const s=[];return r.forEach(o=>{const h=e.namespaces[o].accounts;s.push(...h)}),s}function S5(i={},e={}){const r=Xd(i),s=Xd(e);return Hu.exports.merge(r,s)}function Xd(i){var e,r,s,o;const h={};if(!Gn(i))return h;for(const[p,f]of Object.entries(i)){const g=Zu(p)?[p]:f.chains,b=f.methods||[],E=f.events||[],C=f.rpcMap||{},N=Ns(p);h[N]=E5(na(na({},h[N]),f),{chains:ou(g,(e=h[N])==null?void 0:e.chains),methods:ou(b,(r=h[N])==null?void 0:r.methods),events:ou(E,(s=h[N])==null?void 0:s.events),rpcMap:na(na({},C),(o=h[N])==null?void 0:o.rpcMap)})}return h}function I5(i){return i.includes(":")?i.split(":")[2]:i}function x5(i){const e={};for(const[r,s]of Object.entries(i)){const o=s.methods||[],h=s.events||[],p=s.accounts||[],f=Zu(r)?[r]:s.chains?s.chains:vg(s.accounts);e[r]={chains:f,methods:o,events:h,accounts:p}}return e}function _u(i){return typeof i=="number"?i:i.includes("0x")?parseInt(i,16):i.includes(":")?Number(i.split(":")[1]):Number(i)}const yg={},_t=i=>yg[i],bu=(i,e)=>{yg[i]=e};class O5{constructor(e){this.name="polkadot",this.namespace=e.namespace,this.events=_t("events"),this.client=_t("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Ai.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var s;const o=wn(r);e[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const s=this.createHttpProvider(e,r);s&&(this.httpProviders[e]=s)}createHttpProvider(e,r){const s=r||Ki(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new Pi(new Gi(s,_t("disableProviderPing")))}}class C5{constructor(e){this.name="eip155",this.namespace=e.namespace,this.events=_t("events"),this.client=_t("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain())}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(parseInt(e),r),this.chainId=parseInt(e),this.events.emit(Ai.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,r){const s=r||Ki(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new Pi(new Gi(s,_t("disableProviderPing")))}setHttpProvider(e,r){const s=this.createHttpProvider(e,r);s&&(this.httpProviders[e]=s)}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var s;const o=parseInt(wn(r));e[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}async handleSwitchChain(e){var r,s;let o=e.request.params?(r=e.request.params[0])==null?void 0:r.chainId:"0x0";o=o.startsWith("0x")?o:`0x${o}`;const h=parseInt(o,16);if(this.isChainApproved(h))this.setDefaultChain(`${h}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:o}]},chainId:(s=this.namespace.chains)==null?void 0:s[0]}),this.setDefaultChain(`${h}`);else throw new Error(`Failed to switch to chain 'eip155:${h}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}}class P5{constructor(e){this.name="solana",this.namespace=e.namespace,this.events=_t("events"),this.client=_t("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Ai.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var s;const o=wn(r);e[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const s=this.createHttpProvider(e,r);s&&(this.httpProviders[e]=s)}createHttpProvider(e,r){const s=r||Ki(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new Pi(new Gi(s,_t("disableProviderPing")))}}class A5{constructor(e){this.name="cosmos",this.namespace=e.namespace,this.events=_t("events"),this.client=_t("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Ai.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var s;const o=wn(r);e[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const s=this.createHttpProvider(e,r);s&&(this.httpProviders[e]=s)}createHttpProvider(e,r){const s=r||Ki(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new Pi(new Gi(s,_t("disableProviderPing")))}}class T5{constructor(e){this.name="cip34",this.namespace=e.namespace,this.events=_t("events"),this.client=_t("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Ai.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{const s=this.getCardanoRPCUrl(r),o=wn(r);e[o]=this.createHttpProvider(o,s)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}getCardanoRPCUrl(e){const r=this.namespace.rpcMap;if(r)return r[e]}setHttpProvider(e,r){const s=this.createHttpProvider(e,r);s&&(this.httpProviders[e]=s)}createHttpProvider(e,r){const s=r||this.getCardanoRPCUrl(e);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new Pi(new Gi(s,_t("disableProviderPing")))}}class R5{constructor(e){this.name="elrond",this.namespace=e.namespace,this.events=_t("events"),this.client=_t("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Ai.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var s;const o=wn(r);e[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const s=this.createHttpProvider(e,r);s&&(this.httpProviders[e]=s)}createHttpProvider(e,r){const s=r||Ki(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new Pi(new Gi(s,_t("disableProviderPing")))}}class N5{constructor(e){this.name="multiversx",this.namespace=e.namespace,this.events=_t("events"),this.client=_t("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){this.httpProviders[e]||this.setHttpProvider(e,r),this.chainId=e,this.events.emit(Ai.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var s;const o=wn(r);e[o]=this.createHttpProvider(o,(s=this.namespace.rpcMap)==null?void 0:s[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const s=this.createHttpProvider(e,r);s&&(this.httpProviders[e]=s)}createHttpProvider(e,r){const s=r||Ki(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new Pi(new Gi(s,_t("disableProviderPing")))}}class $5{constructor(e){this.name="near",this.namespace=e.namespace,this.events=_t("events"),this.client=_t("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,r){if(this.chainId=e,!this.httpProviders[e]){const s=r||Ki(`${this.name}:${e}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,s)}this.events.emit(Ai.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(r=>r.split(":")[1]===this.chainId.toString()).map(r=>r.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(r=>{var s;e[r]=this.createHttpProvider(r,(s=this.namespace.rpcMap)==null?void 0:s[r])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,r=this.httpProviders[e];if(typeof r>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return r}setHttpProvider(e,r){const s=this.createHttpProvider(e,r);s&&(this.httpProviders[e]=s)}createHttpProvider(e,r){const s=r||Ki(e,this.namespace);return typeof s>"u"?void 0:new Pi(new Gi(s,_t("disableProviderPing")))}}var L5=Object.defineProperty,U5=Object.defineProperties,F5=Object.getOwnPropertyDescriptors,Zd=Object.getOwnPropertySymbols,M5=Object.prototype.hasOwnProperty,j5=Object.prototype.propertyIsEnumerable,ep=(i,e,r)=>e in i?L5(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,sa=(i,e)=>{for(var r in e||(e={}))M5.call(e,r)&&ep(i,r,e[r]);if(Zd)for(var r of Zd(e))j5.call(e,r)&&ep(i,r,e[r]);return i},wu=(i,e)=>U5(i,F5(e));class hh{constructor(e){this.events=new Bu,this.rpcProviders={},this.shouldAbortPairingAttempt=!1,this.maxPairingAttempts=10,this.disableProviderPing=!1,this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:Ze.pino(Ze.getDefaultLoggerOptions({level:(e==null?void 0:e.logger)||Gd})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const r=new hh(e);return await r.initialize(),r}async request(e,r){const[s,o]=this.validateChain(r);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:sa({},e),chainId:`${s}:${o}`,topic:this.session.topic})}sendAsync(e,r,s){this.request(e,s).then(o=>r(null,o)).catch(o=>r(o,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:$t("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}on(e,r){this.events.on(e,r)}once(e,r){this.events.once(e,r)}removeListener(e,r){this.events.removeListener(e,r)}off(e,r){this.events.off(e,r)}get isWalletConnect(){return!0}async pair(e){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:s,approval:o}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});s&&(this.uri=s,this.events.emit("display_uri",s)),await o().then(h=>{this.session=h,this.namespaces||(this.namespaces=x5(h.namespaces),this.persist("namespaces",this.namespaces))}).catch(h=>{if(h.message!==pg)throw h;r++})}while(!this.session);return this.onConnect(),this.session}setDefaultChain(e,r){try{if(!this.session)return;const[s,o]=this.validateChain(e);this.getProvider(s).setDefaultChain(o,r)}catch(s){if(!/Please call connect/.test(s.message))throw s}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const r=this.client.pairing.getAll();if(li(r)){for(const s of r)e.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.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 e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await h5.init({logger:this.providerOpts.logger||Gd,relayUrl:this.providerOpts.relayUrl||d5,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 e=[...new Set(Object.keys(this.session.namespaces).map(r=>Ns(r)))];bu("client",this.client),bu("events",this.events),bu("disableProviderPing",this.disableProviderPing),e.forEach(r=>{if(!this.session)return;const s=D5(r,this.session),o=vg(s),h=S5(this.namespaces,this.optionalNamespaces),p=wu(sa({},h[r]),{accounts:s,chains:o});switch(r){case"eip155":this.rpcProviders[r]=new C5({namespace:p});break;case"solana":this.rpcProviders[r]=new P5({namespace:p});break;case"cosmos":this.rpcProviders[r]=new A5({namespace:p});break;case"polkadot":this.rpcProviders[r]=new O5({namespace:p});break;case"cip34":this.rpcProviders[r]=new T5({namespace:p});break;case"elrond":this.rpcProviders[r]=new R5({namespace:p});break;case"multiversx":this.rpcProviders[r]=new N5({namespace:p});break;case"near":this.rpcProviders[r]=new $5({namespace:p});break}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:r}=e,{event:s}=r;if(s.name==="accountsChanged"){const o=s.data;o&&li(o)&&this.events.emit("accountsChanged",o.map(I5))}else if(s.name==="chainChanged"){const o=r.chainId,h=r.event.data,p=Ns(o),f=_u(o)!==_u(h)?`${p}:${_u(h)}`:o;this.onChainChanged(f)}else this.events.emit(s.name,s.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:r})=>{var s;const{namespaces:o}=r,h=(s=this.client)==null?void 0:s.session.get(e);this.session=wu(sa({},h),{namespaces:o}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:r})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",wu(sa({},$t("USER_DISCONNECTED")),{data:e.topic}))}),this.on(Ai.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){if(!this.rpcProviders[e])throw new Error(`Provider not found: ${e}`);return this.rpcProviders[e]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var r;this.getProvider(e).updateNamespace((r=this.session)==null?void 0:r.namespaces[e])})}setNamespaces(e){const{namespaces:r,optionalNamespaces:s,sessionProperties:o}=e;r&&Object.keys(r).length&&(this.namespaces=r),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=o,this.persist("namespaces",r),this.persist("optionalNamespaces",s)}validateChain(e){const[r,s]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[r,s];if(r&&!Object.keys(this.namespaces||{}).map(p=>Ns(p)).includes(r))throw new Error(`Namespace '${r}' is not configured. Please call connect() first with namespace config.`);if(r&&s)return[r,s];const o=Ns(Object.keys(this.namespaces)[0]),h=this.rpcProviders[o].getDefaultChain();return[o,h]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,r=!1){var s;if(!this.namespaces)return;const[o,h]=this.validateChain(e);r||this.getProvider(o).setDefaultChain(h),((s=this.namespaces[o])!=null?s:this.namespaces[`${o}:${h}`]).defaultChain=h,this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",h)}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(e,r){this.client.core.storage.setItem(`${Yd}/${e}`,r)}async getFromStore(e){return await this.client.core.storage.getItem(`${Yd}/${e}`)}}const q5=hh,H5="wc",z5="ethereum_provider",B5=`${H5}@2:${z5}:`,k5="https://rpc.walletconnect.com/v1/",pa=["eth_sendTransaction","personal_sign"],mg=["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"],ga=["chainChanged","accountsChanged"],_g=["chainChanged","accountsChanged","message","disconnect","connect"];var K5=Object.defineProperty,V5=Object.defineProperties,W5=Object.getOwnPropertyDescriptors,tp=Object.getOwnPropertySymbols,G5=Object.prototype.hasOwnProperty,Y5=Object.prototype.propertyIsEnumerable,rp=(i,e,r)=>e in i?K5(i,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):i[e]=r,Ls=(i,e)=>{for(var r in e||(e={}))G5.call(e,r)&&rp(i,r,e[r]);if(tp)for(var r of tp(e))Y5.call(e,r)&&rp(i,r,e[r]);return i},ip=(i,e)=>V5(i,W5(e));function va(i){return Number(i[0].split(":")[1])}function Eu(i){return`0x${i.toString(16)}`}function J5(i){const{chains:e,optionalChains:r,methods:s,optionalMethods:o,events:h,optionalEvents:p,rpcMap:f}=i;if(!li(e))throw new Error("Invalid chains");const g={chains:e,methods:s||pa,events:h||ga,rpcMap:Ls({},e.length?{[va(e)]:f[va(e)]}:{})},b=h==null?void 0:h.filter(P=>!ga.includes(P)),E=s==null?void 0:s.filter(P=>!pa.includes(P));if(!r&&!p&&!o&&!(b!=null&&b.length)&&!(E!=null&&E.length))return{required:e.length?g:void 0};const C=(b==null?void 0:b.length)&&(E==null?void 0:E.length)||!r,N={chains:[...new Set(C?g.chains.concat(r||[]):r)],methods:[...new Set(g.methods.concat(o!=null&&o.length?o:mg))],events:[...new Set(g.events.concat(p!=null&&p.length?p:_g))],rpcMap:f};return{required:e.length?g:void 0,optional:r.length?N:void 0}}class Ca{constructor(){this.events=new zr.EventEmitter,this.namespace="eip155",this.accounts=[],this.chainId=1,this.STORAGE_KEY=B5,this.on=(e,r)=>(this.events.on(e,r),this),this.once=(e,r)=>(this.events.once(e,r),this),this.removeListener=(e,r)=>(this.events.removeListener(e,r),this),this.off=(e,r)=>(this.events.off(e,r),this),this.parseAccount=e=>this.isCompatibleChainId(e)?this.parseAccountId(e).address:e,this.signer={},this.rpc={}}static async init(e){const r=new Ca;return await r.initialize(e),r}async request(e){return await this.signer.request(e,this.formatChainId(this.chainId))}sendAsync(e,r){this.signer.sendAsync(e,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(e){if(!this.signer.client)throw new Error("Provider not initialized. Call init() first");this.loadConnectOpts(e);const{required:r,optional:s}=J5(this.rpc);try{const o=await new Promise(async(p,f)=>{var g;this.rpc.showQrModal&&((g=this.modal)==null||g.subscribeModal(b=>{!b.open&&!this.signer.session&&(this.signer.abortPairingAttempt(),f(new Error("Connection request reset. Please try again.")))})),await this.signer.connect(ip(Ls({namespaces:Ls({},r&&{[this.namespace]:r})},s&&{optionalNamespaces:{[this.namespace]:s}}),{pairingTopic:e==null?void 0:e.pairingTopic})).then(b=>{p(b)}).catch(b=>{f(new Error(b.message))})});if(!o)return;const h=YE(o.namespaces,[this.namespace]);this.setChainIds(this.rpc.chains.length?this.rpc.chains:h),this.setAccounts(h),this.events.emit("connect",{chainId:Eu(this.chainId)})}catch(o){throw this.signer.logger.error(o),o}finally{this.modal&&this.modal.closeModal()}}async disconnect(){this.session&&await this.signer.disconnect(),this.reset()}get isWalletConnect(){return!0}get session(){return this.signer.session}registerEventListeners(){this.signer.on("session_event",e=>{const{params:r}=e,{event:s}=r;s.name==="accountsChanged"?(this.accounts=this.parseAccounts(s.data),this.events.emit("accountsChanged",this.accounts)):s.name==="chainChanged"?this.setChainId(this.formatChainId(s.data)):this.events.emit(s.name,s.data),this.events.emit("session_event",e)}),this.signer.on("chainChanged",e=>{const r=parseInt(e);this.chainId=r,this.events.emit("chainChanged",Eu(this.chainId)),this.persist()}),this.signer.on("session_update",e=>{this.events.emit("session_update",e)}),this.signer.on("session_delete",e=>{this.reset(),this.events.emit("session_delete",e),this.events.emit("disconnect",ip(Ls({},$t("USER_DISCONNECTED")),{data:e.topic,name:"USER_DISCONNECTED"}))}),this.signer.on("display_uri",e=>{var r,s;this.rpc.showQrModal&&((r=this.modal)==null||r.closeModal(),(s=this.modal)==null||s.openModal({uri:e})),this.events.emit("display_uri",e)})}switchEthereumChain(e){this.request({method:"wallet_switchEthereumChain",params:[{chainId:e.toString(16)}]})}isCompatibleChainId(e){return typeof e=="string"?e.startsWith(`${this.namespace}:`):!1}formatChainId(e){return`${this.namespace}:${e}`}parseChainId(e){return Number(e.split(":")[1])}setChainIds(e){const r=e.filter(s=>this.isCompatibleChainId(s)).map(s=>this.parseChainId(s));r.length&&(this.chainId=r[0],this.events.emit("chainChanged",Eu(this.chainId)),this.persist())}setChainId(e){if(this.isCompatibleChainId(e)){const r=this.parseChainId(e);this.chainId=r,this.switchEthereumChain(r)}}parseAccountId(e){const[r,s,o]=e.split(":");return{chainId:`${r}:${s}`,address:o}}setAccounts(e){this.accounts=e.filter(r=>this.parseChainId(this.parseAccountId(r).chainId)===this.chainId).map(r=>this.parseAccountId(r).address),this.events.emit("accountsChanged",this.accounts)}getRpcConfig(e){var r,s;const o=(r=e==null?void 0:e.chains)!=null?r:[],h=(s=e==null?void 0:e.optionalChains)!=null?s:[],p=o.concat(h);if(!p.length)throw new Error("No chains specified in either `chains` or `optionalChains`");const f=o.length?(e==null?void 0:e.methods)||pa:[],g=o.length?(e==null?void 0:e.events)||ga:[],b=(e==null?void 0:e.optionalMethods)||[],E=(e==null?void 0:e.optionalEvents)||[],C=(e==null?void 0:e.rpcMap)||this.buildRpcMap(p,e.projectId),N=(e==null?void 0:e.qrModalOptions)||void 0;return{chains:o==null?void 0:o.map(P=>this.formatChainId(P)),optionalChains:h.map(P=>this.formatChainId(P)),methods:f,events:g,optionalMethods:b,optionalEvents:E,rpcMap:C,showQrModal:!!(e!=null&&e.showQrModal),qrModalOptions:N,projectId:e.projectId,metadata:e.metadata}}buildRpcMap(e,r){const s={};return e.forEach(o=>{s[o]=this.getRpcUrl(o,r)}),s}async initialize(e){if(this.rpc=this.getRpcConfig(e),this.chainId=this.rpc.chains.length?va(this.rpc.chains):va(this.rpc.optionalChains),this.signer=await q5.init({projectId:this.rpc.projectId,metadata:this.rpc.metadata,disableProviderPing:e.disableProviderPing,relayUrl:e.relayUrl,storageOptions:e.storageOptions}),this.registerEventListeners(),await this.loadPersistedSession(),this.rpc.showQrModal){let r;try{r=Ib.WalletConnectModal}catch{throw new Error("To use QR modal, please install @walletconnect/modal package")}if(r)try{this.modal=new r(Ls({walletConnectVersion:2,projectId:this.rpc.projectId,standaloneChains:this.rpc.chains},this.rpc.qrModalOptions))}catch(s){throw this.signer.logger.error(s),new Error("Could not generate WalletConnectModal Instance")}}}loadConnectOpts(e){if(!e)return;const{chains:r,optionalChains:s,rpcMap:o}=e;r&&li(r)&&(this.rpc.chains=r.map(h=>this.formatChainId(h)),r.forEach(h=>{this.rpc.rpcMap[h]=(o==null?void 0:o[h])||this.getRpcUrl(h)})),s&&li(s)&&(this.rpc.optionalChains=[],this.rpc.optionalChains=s==null?void 0:s.map(h=>this.formatChainId(h)),s.forEach(h=>{this.rpc.rpcMap[h]=(o==null?void 0:o[h])||this.getRpcUrl(h)}))}getRpcUrl(e,r){var s;return((s=this.rpc.rpcMap)==null?void 0:s[e])||`${k5}?chainId=eip155:${e}&projectId=${r||this.rpc.projectId}`}async loadPersistedSession(){if(!this.session)return;const e=await this.signer.client.core.storage.getItem(`${this.STORAGE_KEY}/chainId`),r=this.session.namespaces[`${this.namespace}:${e}`]?this.session.namespaces[`${this.namespace}:${e}`]:this.session.namespaces[this.namespace];this.setChainIds(e?[this.formatChainId(e)]: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(e){return typeof e=="string"||e instanceof String?[this.parseAccount(e)]:e.map(r=>this.parseAccount(r))}}const Q5=Ca,dI=Object.freeze(Object.defineProperty({__proto__:null,EthereumProvider:Q5,OPTIONAL_EVENTS:_g,OPTIONAL_METHODS:mg,REQUIRED_EVENTS:ga,REQUIRED_METHODS:pa,default:Ca},Symbol.toStringTag,{value:"Module"}));export{ub as R,np as T,rr as a,dI as i,wf as n,tI as o,Zr as p,eu as s,eI as t,Jn as y};
|
|
34
|
+
//# sourceMappingURL=index.es-76c7d42b.js.map
|