graz 0.2.0-alpha.1 → 0.2.0-alpha.2

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/dist/index.js CHANGED
@@ -6,9 +6,12 @@ var amino = require('@cosmjs/amino');
6
6
  var encoding = require('@cosmjs/encoding');
7
7
  var cosmiframe = require('@dao-dao/cosmiframe');
8
8
  var snapper = require('@cosmsnap/snapper');
9
- var ct = require('long');
9
+ var Fm = require('long');
10
10
  var signClient = require('@walletconnect/sign-client');
11
11
  var utils = require('@walletconnect/utils');
12
+ var fI = require('events');
13
+ var types = require('@walletconnect/types');
14
+ var cd = require('crypto');
12
15
  var modal = require('@walletconnect/modal');
13
16
  var reactQuery = require('@tanstack/react-query');
14
17
  var react = require('react');
@@ -20,80 +23,206 @@ var jsxRuntime = require('react/jsx-runtime');
20
23
 
21
24
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
22
25
 
23
- var ct__default = /*#__PURE__*/_interopDefault(ct);
26
+ var Fm__default = /*#__PURE__*/_interopDefault(Fm);
27
+ var fI__default = /*#__PURE__*/_interopDefault(fI);
28
+ var cd__default = /*#__PURE__*/_interopDefault(cd);
24
29
 
25
- var Nt=Object.defineProperty,Bt=Object.defineProperties;var Lt=Object.getOwnPropertyDescriptors;var Ge=Object.getOwnPropertySymbols;var Ut=Object.prototype.hasOwnProperty,Ft=Object.prototype.propertyIsEnumerable;var ze=(e,t,i)=>t in e?Nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,k=(e,t)=>{for(var i in t||(t={}))Ut.call(t,i)&&ze(e,i,t[i]);if(Ge)for(var i of Ge(t))Ft.call(t,i)&&ze(e,i,t[i]);return e},j=(e,t)=>Bt(e,Lt(t));var l=(e,t,i)=>new Promise((o,r)=>{var n=c=>{try{s(i.next(c));}catch(f){r(f);}},a=c=>{try{s(i.throw(c));}catch(f){r(f);}},s=c=>c.done?o(c.value):Promise.resolve(c.value).then(n,a);s((i=i.apply(e,t)).next());});var Y="graz-reconnect-session";var Qe=(p=>(p.KEPLR="keplr",p.LEAP="leap",p.VECTIS="vectis",p.COSMOSTATION="cosmostation",p.WALLETCONNECT="walletconnect",p.WC_KEPLR_MOBILE="wc_keplr_mobile",p.WC_LEAP_MOBILE="wc_leap_mobile",p.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",p.WC_CLOT_MOBILE="wc_clot_mobile",p.METAMASK_SNAP_LEAP="metamask_snap_leap",p.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",p.STATION="station",p.XDEFI="xdefi",p.CAPSULE="capsule",p.COSMIFRAME="cosmiframe",p.COMPASS="compass",p.INITIA="initia",p.OKX="okx",p))(Qe||{}),je=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe","compass","initia","okx"];var Gt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ne={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},zt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},Qt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},g=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>ne,zt))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>Gt,Qt)));var ae=()=>{var C,y;if(!((C=u.getState().capsuleConfig)!=null&&C.apiKey)||!((y=u.getState().capsuleConfig)!=null&&y.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var h,x;let m=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,S=new m({apiKey:(h=u.getState().capsuleConfig)==null?void 0:h.apiKey,env:(x=u.getState().capsuleConfig)==null?void 0:x.env});return g.setState({capsuleClient:S}),S});return {init:e,enable:m=>l(void 0,null,function*(){let S=typeof m=="string"?[m]:m,h=g.getState().capsuleClient;h||(h=yield e()),u.setState({capsuleState:{showModal:!0,chainId:S}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var p;let m=g.getState().capsuleClient,{chains:S}=u.getState();if(!m)throw new Error("Capsule client is not initialized");if(!S)throw new Error("Chains are not set");yield m.enable();let h=(p=u.getState().capsuleState)==null?void 0:p.chainId;if(!h)throw new Error("Chain ids are not set");let x=Object.fromEntries(yield Promise.all(h.map(I=>l(void 0,null,function*(){let b=yield m.getAccount(I);return [I,{address:encoding.fromBech32(b.address).data,bech32Address:b.address,algo:b.algo,name:b.username||"",pubKey:b.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));g.setState(I=>({accounts:k(k({},I.accounts||{}),x)})),u.setState(I=>({recentChainIds:[...I.recentChainIds||[],...h].filter((b,P,K)=>K.indexOf(b)===P)})),g.setState(I=>({activeChainIds:[...I.activeChainIds||[],...h].filter((b,P,K)=>K.indexOf(b)===P)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),g.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(Y,"Active"),u.setState({capsuleState:null});}),getKey:m=>l(void 0,null,function*(){let S=g.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");let h=yield S.getAccount(m);return {address:encoding.fromBech32(h.address).data,bech32Address:h.address,algo:h.algo,name:h.username||"",pubKey:h.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:m=>l(void 0,null,function*(){let S=g.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(m)}),getOfflineSignerDirect:m=>{let S=g.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(m)},signDirect:(...m)=>l(void 0,null,function*(){let[S,h,x]=m,p=g.getState().capsuleClient;if(!p)throw new Error("Capsule client is not initialized");return p.signDirect(S,h,{bodyBytes:x.bodyBytes,authInfoBytes:x.authInfoBytes,chainId:x.chainId,accountNumber:x.accountNumber})}),signAmino:(...m)=>l(void 0,null,function*(){let[S,h,x,p]=m,I=g.getState().capsuleClient;if(!I)throw new Error("Capsule client is not initialized");return I.signAmino(S,h,x,p)}),signArbitrary:(m,S,h)=>l(void 0,null,function*(){let x=g.getState().capsuleClient;if(!x)throw new Error("Capsule client is not initialized");let p=yield x.getAccount(m);if(!p)throw new Error(`Wallet not connected to account ${S}`);let I=(()=>{switch(p.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(p.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(p.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield x.signArbitrary(m,S,h),pub_key:{type:p.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:I.value}}}),experimentalSuggestChain:(...m)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:m=>{let S=g.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSigner(m)},getOfflineSignerAmino:m=>{let S=g.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerAmino(m)}}};var ce=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let n=()=>{N(),r();};return window.addEventListener("leap_keystorechange",n),()=>{window.removeEventListener("leap_keystorechange",n);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var le=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!cosmiframe.isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new cosmiframe.Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};var et={},tt=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>l(void 0,null,function*(){var w;let n=yield e.request({method:"web3_clientVersion"});if(!n.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let s=(w=n.split("MetaMask/v")[1])==null?void 0:w.split(".")[0];if(!(Number(s)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield snapper.isSnapInstalled())||(yield snapper.installSnap()),window.cosmos=new snapper.CosmosSnap,t=window.cosmos,!0}),enable:n=>l(void 0,null,function*(){(yield snapper.isSnapInstalled())||(yield snapper.installSnap());}),getOfflineSigner:n=>t.getOfflineSigner(n),experimentalSuggestChain:n=>l(void 0,null,function*(){if(!n.bech32Config)throw new Error("Bech32Config is required");if(!n.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain(j(k({},n),{stakeCurrency:n.stakeCurrency,bech32Config:n.bech32Config}));}),signAmino:(n,a,s)=>l(void 0,null,function*(){return t.signAmino(n,a,s)}),getKey:n=>l(void 0,null,function*(){return typeof et[n]!="undefined"?et[n]:t.getKey(n)}),getOfflineSignerAuto:n=>l(void 0,null,function*(){return (yield t.getKey(n)).isNanoLedger?t.getOfflineSignerOnlyAmino(n):t.getOfflineSigner(n)}),getOfflineSignerOnlyAmino:n=>t.getOfflineSignerOnlyAmino(n),signDirect:(n,a,s)=>l(void 0,null,function*(){return t.signDirect(n,a,s)}),signArbitrary:(n,a,s)=>l(void 0,null,function*(){return t.signArbitrary(n,a,s)}),disable:n=>l(void 0,null,function*(){n&&(yield t.deleteChain(n));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var ue=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:n=>{let a=()=>{N(),n();};return window.addEventListener("cosmostation_keystorechange",a),()=>{window.removeEventListener("cosmostation_keystorechange",a);}},setDefaultOptions:n=>{t.defaultOptions=n;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var tn=e=>{let{bodyBytes:t,authInfoBytes:i,chainId:o,accountNumber:r}=e;if(!t||!i||!o||!r)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:i,chainId:o,accountNumber:r}},nn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,it=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>l(void 0,null,function*(){yield e.getAddress();}),getKey:d=>l(void 0,null,function*(){let C=e.getOfflineSigner(d),[y]=yield C.getAccounts();if(!y)throw new Error("Wallet connection failed");let m=(()=>{switch(y.algo){case"secp256k1":return amino.rawSecp256k1PubkeyToRawAddress(y.pubkey);case"ed25519":return amino.rawEd25519PubkeyToRawAddress(y.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:nn(y.address),algo:y.algo,pubKey:y.pubkey,bech32Address:y.address,address:m,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:d=>{let C=e.getOfflineSigner(d),y=e.getOfflineSignerOnlyAmino(d);return {getAccounts:C.getAccounts.bind(C),signDirect:C.signDirect.bind(C),signAmino:y.signAmino.bind(y)}},getOfflineSignerAuto:d=>Promise.resolve(e.getOfflineSigner(d)),getOfflineSignerOnlyAmino:d=>e.getOfflineSignerOnlyAmino(d),experimentalSuggestChain:d=>e.requestAddInitiaLayer({chain_id:d.chainId,chain_name:d.chainName,bech32_prefix:"init",bech32_config:d.bech32Config,slip44:d.bip44.coinType,logo_URIs:{png:d.chainSymbolImageUrl},fees:{fee_tokens:d.feeCurrencies.map(C=>{var y,m,S;return {denom:C.coinDenom,amount:C.coinMinimalDenom,low_gas_price:(y=C.gasPriceStep)==null?void 0:y.low,average_gas_price:(m=C.gasPriceStep)==null?void 0:m.average,high_gas_price:(S=C.gasPriceStep)==null?void 0:S.high}})},apis:{rpc:[{address:d.rpc}],rest:[{address:d.rest}]}}),signDirect:(...d)=>{let[C,y,m]=d;return e.getOfflineSigner(C).signDirect(y,tn(m))},signAmino:(...d)=>{let[C,y,m]=d;return e.getOfflineSignerOnlyAmino(C).signAmino(y,m)},signArbitrary:(d,C,y)=>l(void 0,null,function*(){let h=(yield e.getOfflineSigner(d).getAccounts()).find(I=>I.address===C);if(!h)throw new Error(`Wallet not connected to account ${C}`);let x=(()=>{switch(h.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(h.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(h.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(y),pub_key:{type:h.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:x.value}}}),subscription:d=>{let C=()=>{N(),d();};return window.addEventListener("initia_keystorechange",C),()=>{window.removeEventListener("initia_keystorechange",C);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var pe=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let n=()=>{N(),r();};return window.addEventListener("keplr_keystorechange",n),()=>{window.removeEventListener("keplr_keystorechange",n);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var me=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let n=()=>{N(),r();};return window.addEventListener("leap_keystorechange",n),()=>{window.removeEventListener("leap_keystorechange",n);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var de={},ot=e=>{let t=window.ethereum;if(t&&e){let i=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),o=p=>l(void 0,null,function*(){try{let I=yield i();return Object.values(I).find(b=>b.id===e.id&&(!p||b.version===p))}catch(I){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),n=()=>l(void 0,null,function*(){var _;let p=yield t.request({method:"web3_clientVersion"});if(!p.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let b=(_=p.split("MetaMask/v")[1])==null?void 0:_.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield o())||(yield r()),!0}),a=p=>l(void 0,null,function*(){(yield o())||(yield r());}),s=(p,I,b)=>l(void 0,null,function*(){let P=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:p,signerAddress:I,signDoc:b}}}}),K=b.accountNumber,_=new ct__default.default(K.low,K.high,K.unsigned);return {signature:P.signature,signed:j(k({},P.signed),{accountNumber:`${_.toString()}`,authInfoBytes:new Uint8Array(Object.values(P.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(P.signed.bodyBytes))})}}),c=(p,I,b)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:p,signerAddress:I,signDoc:b}}}})}),f=p=>l(void 0,null,function*(){if(typeof de[p]!="undefined")return de[p];let I=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:p}}}});if(!I)throw new Error("No response from Metamask");return I.pubKey=Uint8Array.from(Object.values(I.pubkey)),delete I.pubkey,de[p]=I,de[p]}),w=p=>l(void 0,null,function*(){let I=yield f(p);return {address:I.bech32Address,algo:I.algo,pubkey:I.pubKey}}),d=(...p)=>l(void 0,null,function*(){let[I,b,P,K]=p;return yield c(I,b,P)}),C=(...p)=>l(void 0,null,function*(){let[I,b,P]=p;return yield s(I,b,P)}),m=p=>({getAccounts:()=>l(void 0,null,function*(){return [yield w(p)]}),signAmino:(I,b)=>d(p,I,b)});return {enable:a,experimentalSuggestChain:(...p)=>l(void 0,null,function*(){yield n(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:p[0]}}}});}),getKey:f,getOfflineSigner:p=>({getAccounts:()=>l(void 0,null,function*(){return [yield w(p)]}),signDirect:(I,b)=>C(p,I,b),signAmino:(I,b)=>d(p,I,b)}),getOfflineSignerAuto:p=>l(void 0,null,function*(){return m(p)}),getOfflineSignerOnlyAmino:m,init:n,signAmino:d,signDirect:C}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var rt=()=>ot({id:"npm:@leapwallet/metamask-cosmos-snap"});var fe=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:n=>{var s;let a=()=>{N(),n();};return (s=window.okxwallet)==null||s.on("accountsChanged",a),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",a);}},setDefaultOptions:n=>{t.defaultOptions=n;}})}throw u.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};var ge=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:n=>{let a=()=>{N(),n();};return window.addEventListener("station_wallet_change",a),()=>{window.removeEventListener("station_wallet_change",a);}},getKey:n=>l(void 0,null,function*(){let a=yield e.getKey(n);return k({isKeystone:!1},a)}),getOfflineSigner:n=>{try{let a=e.getOfflineSignerOnlyAmino(n);return Object.assign(a,{signDirect:(f,w)=>{throw new Error("signDirect not supported by Station")}})}catch(a){throw console.error(a),a}},experimentalSuggestChain:n=>l(void 0,null,function*(){try{if(!n.bech32Config)throw new Error("Bech32Config is required");if(!n.stakeCurrency)throw new Error("StakeCurrency is required");let a=Object.assign(n,{bech32Config:n.bech32Config,chainSymbolImageUrl:n.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:n.stakeCurrency.coinDecimals,coinDenom:n.stakeCurrency.coinDenom,coinImageUrl:n.stakeCurrency.coinImageUrl||"",coinMinimalDenom:n.stakeCurrency.coinMinimalDenom},currencies:n.currencies.map(s=>({coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom})),feeCurrencies:n.feeCurrencies.map(s=>{var c,f,w;return {coinDecimals:s.coinDecimals,coinDenom:s.coinDenom,coinImageUrl:s.coinImageUrl||"",coinMinimalDenom:s.coinMinimalDenom,gasPriceStep:{average:((c=s.gasPriceStep)==null?void 0:c.average)||0,high:((f=s.gasPriceStep)==null?void 0:f.high)||0,low:((w=s.gasPriceStep)==null?void 0:w.low)||0}}})});yield e.experimentalSuggestChain(a);}catch(a){throw console.error(a),a}}),enable:n=>e.enable(n),disable:n=>e.disable(n),getOfflineSignerAuto:n=>e.getOfflineSignerAuto(n),getOfflineSignerOnlyAmino:n=>e.getOfflineSignerOnlyAmino(n),signDirect:()=>e.signDirect(),signAmino:(n,a,s,c)=>e.signAmino(n,a,s)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var ye=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:s=>e.enable(s),getOfflineSigner:s=>e.getOfflineSigner(s),getOfflineSignerAuto:s=>e.getOfflineSignerAuto(s),getKey:s=>l(void 0,null,function*(){let c=yield e.getKey(s);return {address:encoding.fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:s=>{let c=()=>{N(),s();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...s)=>{let c=s[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...s)=>l(void 0,null,function*(){var w;let[c]=s;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let f={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(w=c.bech32Config)==null?void 0:w.bech32PrefixAccAddr,currencies:c.currencies,feeCurrencies:c.feeCurrencies,chainId:c.chainId,chainName:c.chainName,bip44:c.bip44,stakeCurrency:c.stakeCurrency,features:c.features};return e.suggestChains([f])}),signDirect:(...s)=>l(void 0,null,function*(){var w;let{1:c,2:f}=s;return e.signDirect(c,{bodyBytes:f.bodyBytes||Uint8Array.from([]),authInfoBytes:f.authInfoBytes||Uint8Array.from([]),accountNumber:ct__default.default.fromString(((w=f.accountNumber)==null?void 0:w.toString())||"",!1),chainId:f.chainId||""})}),signAmino:(...s)=>l(void 0,null,function*(){let{1:c,2:f}=s;return e.signAmino(c,f)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var G=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return !1},st=()=>G()&&navigator.userAgent.toLowerCase().includes("android"),at=()=>G()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Me=(e,t,i=new Error("Promise timed out"))=>{let o=new Promise((r,n)=>{setTimeout(()=>{n(i);},t);});return Promise.race([e,o])};var z=e=>{var _,ee,ie;if(!((ie=(ee=(_=u.getState().walletConnect)==null?void 0:_.options)==null?void 0:ee.projectId)!=null&&ie.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",i=(e==null?void 0:e.encoding)||"base64",o=A=>{if(!e)return;let{appUrl:O,formatNativeUrl:E}=e;if(G()){if(st()){let M=E(O.mobile.android,A,"android");window.open(M,"_self","noreferrer noopener");}if(at()){let M=E(O.mobile.ios,A,"ios");window.open(M,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:A}=g.getState();if(!A.get(t))throw new Error("walletConnect.signClient is not defined");A.delete(t),g.setState({wcSignClients:A}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},n=A=>l(void 0,null,function*(){let{wcSignClients:O}=g.getState(),E=O.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");if(!A)throw new Error("No wallet connect session");yield E.disconnect({topic:A,reason:utils.getSdkError("USER_DISCONNECTED")}),yield c(E);}),a=A=>{try{let{wcSignClients:O}=g.getState(),E=O.get(t);if(!E)throw new Error("walletConnect.signClient is not defined");let M=E.session.getAll(),W=M.at(-1);if(!W)return;if(!(W.expiry*1e3>Date.now()+1e3))throw n(W.topic),new Error("invalid session");try{let D=M.find(Q=>{var H,X;return (X=(H=Q.requiredNamespaces.cosmos)==null?void 0:H.chains)==null?void 0:X.includes(`cosmos:${A}`)});if(!D)throw new Error("no session");return D}catch(D){if(!D.message.toLowerCase().includes("no matching key"))throw D}return W}catch(O){if(!O.message.toLowerCase().includes("no matching key"))throw O}},s=A=>{try{return a(A)}catch(O){return}},c=A=>l(void 0,null,function*(){try{let O=A.core.pairing.pairings.getAll({active:!1});if(!O.length)return;yield Promise.all(O.map(E=>l(void 0,null,function*(){yield A.core.pairing.pairings.delete(E.topic,{code:7001,message:"clear pairing"});})));}catch(O){if(!O.message.toLowerCase().includes("no matching key"))throw O}}),f=()=>l(void 0,null,function*(){let{walletConnect:A}=u.getState();if(!(A!=null&&A.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:O}=g.getState(),E=O.get(t);if(E)return E;let M=yield signClient.SignClient.init(A.options);return O.set(t,M),g.setState({wcSignClients:O}),M}),w=A=>{let{wcSignClients:O}=g.getState(),E=O.get(t);if(!E)return ()=>{};let M=W=>{let v=g.getState().accounts;if(W.params.event.name==="accountsChanged"&&v&&!Object.values(v).map(D=>D.bech32Address).includes(W.params.event.data[0])){let D=W.params.chainId.split(":")[1];D&&d([D]);}else A();};return E.events.on("session_delete",r),E.events.on("session_expire",r),E.events.on("session_event",M),()=>{E.events.off("session_delete",r),E.events.off("session_expire",r),E.events.off("session_event",M);}},d=A=>l(void 0,null,function*(){var X;let O=typeof A=="string"?[A]:A,{wcSignClients:E,activeChainIds:M}=g.getState(),W=E.get(t);if(!W)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:v,chains:D}=u.getState();if(!((X=v==null?void 0:v.options)!=null&&X.projectId))throw new Error("walletConnect.options.projectId is not defined");let Q=new modal.WalletConnectModal(k({projectId:v.options.projectId,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},v.walletConnectModal)),H=s(O);if(!H){let{uri:F,approval:re}=yield Me(W.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:O.map($=>`cosmos:${$}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!F)throw new Error("No wallet connect uri");e?o(F):yield Q.openModal({uri:F});let se=$=>l(void 0,null,function*(){return $.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Te,te)=>{re().then(Ue=>{let Fe=Ue.sessionProperties;if(!Fe)return te(new Error("No session properties"));let xe=JSON.parse(String(Fe.keys));if(xe.length===0)return te(new Error("No accounts"));if(!xe[0])return te(new Error("No accounts"));let qe={};return xe.forEach(V=>{qe[V.chainId]={address:V.address,algo:V.algo,bech32Address:V.bech32Address,isNanoLedger:V.isNanoLedger,isKeystone:V.isKeystone,name:V.name,pubKey:V.pubKey};}),g.setState(V=>({accounts:k(k({},V.accounts||{}),qe)})),Te(Ue)}).catch(te),$.addEventListener("abort",()=>{te(new Error("User closed wallet connect"));},{once:!0});})});try{let $=new AbortController,Te=$.signal;Q.subscribeModal(te=>{te.open||$.abort();}),yield se(Te);}catch($){if(Q.closeModal(),!$.message.toLowerCase().includes("no matching key"))return Promise.reject($)}return e||Q.closeModal(),Promise.resolve()}try{yield Me((()=>l(void 0,null,function*(){var re;let F=Object.fromEntries(yield Promise.all((re=M||O)==null?void 0:re.map(se=>l(void 0,null,function*(){return [se,yield y(se)]}))));g.setState({accounts:F});}))(),15e3,new Error("Connection timeout"));}catch(F){if(n(H.topic),!F.message.toLowerCase().includes("no matching key"))throw F}}),C=A=>l(void 0,null,function*(){let O=yield y(A);return {address:O.bech32Address,algo:O.algo,pubkey:O.pubKey}}),y=A=>l(void 0,null,function*(){let O=a([A]);if(!(O!=null&&O.topic))throw new Error("No wallet connect session");let E=O.sessionProperties&&JSON.parse(String(O.sessionProperties.keys));if(!E)throw new Error("No wallet connect key");if(E.length===0)throw new Error("No wallet connect session");let M=E.find(W=>W.chainId===A);if(!M)throw new Error(`No wallet connect key for chainId ${A}`);return j(k({},M),{pubKey:Buffer.from(String(M.pubKey),i)})}),m=(...A)=>l(void 0,null,function*(){var X,F;let[O,E,M]=A,{accounts:W,wcSignClients:v}=g.getState(),D=v.get(t);if(!D)throw new Error("walletConnect.signClient is not defined");if(!W)throw new Error("account is not defined");let Q=(X=a([O]))==null?void 0:X.topic;if(!Q)throw new Error("No wallet connect session");if(!M.bodyBytes)throw new Error("No bodyBytes");if(!M.authInfoBytes)throw new Error("No authInfoBytes");return o(),yield D.request({topic:Q,chainId:`cosmos:${O}`,request:{method:"cosmos_signDirect",params:{signerAddress:E,signDoc:{chainId:M.chainId,accountNumber:(F=M.accountNumber)==null?void 0:F.toString(),bodyBytes:M.bodyBytes?Buffer.from(M.bodyBytes).toString(i):null,authInfoBytes:M.authInfoBytes?Buffer.from(M.authInfoBytes).toString(i):null}}}})}),S=(...A)=>l(void 0,null,function*(){var D;let[O,E,M]=A,{signature:W,signed:v}=yield m(O,E,M);return {signed:{chainId:(D=v.chainId)!=null?D:"",accountNumber:v.accountNumber?ct__default.default.fromString(v.accountNumber):new ct__default.default(0),authInfoBytes:v.authInfoBytes?new Uint8Array(Buffer.from(v.authInfoBytes,i)):new Uint8Array([]),bodyBytes:v.bodyBytes?new Uint8Array(Buffer.from(v.bodyBytes,i)):new Uint8Array([])},signature:W}}),h=(...A)=>l(void 0,null,function*(){var F;let[O,E,M,W]=A,{wcSignClients:v}=g.getState(),D=v.get(t),{accounts:Q}=g.getState();if(!D)throw new Error("walletConnect.signClient is not defined");if(!Q)throw new Error("account is not defined");let H=(F=a([O]))==null?void 0:F.topic;if(!H)throw new Error("No wallet connect session");return o(),yield D.request({topic:H,chainId:`cosmos:${O}`,request:{method:"cosmos_signDirect",params:{signerAddress:E,signDoc:M}}})}),x=(...A)=>l(void 0,null,function*(){let[O,E,M,W]=A;return yield h(O,E,M)}),p=A=>({getAccounts:()=>l(void 0,null,function*(){return [yield C(A)]}),signDirect:(O,E)=>S(A,O,E)}),I=A=>({getAccounts:()=>l(void 0,null,function*(){return [yield C(A)]}),signAmino:(O,E)=>x(A,O,E)});return {enable:d,disable:A=>l(void 0,null,function*(){var M;let{wcSignClients:O}=g.getState(),E=O.get(t);if(A===void 0){let W=E==null?void 0:E.session.getAll();W!==void 0&&(yield Promise.all(W.map(v=>n(v.topic))));}else typeof A=="string"?yield n((M=a([A]))==null?void 0:M.topic):yield Promise.all(A.map(W=>{var v;return n((v=a([W]))==null?void 0:v.topic)}));(E==null?void 0:E.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...A)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:y,getOfflineSigner:A=>({getAccounts:()=>l(void 0,null,function*(){return [yield C(A)]}),signDirect:(O,E)=>S(A,O,E),signAmino:(O,E)=>x(A,O,E)}),getOfflineSignerAuto:A=>l(void 0,null,function*(){return (yield y(A)).isNanoLedger?I(A):p(A)}),getOfflineSignerOnlyAmino:I,signAmino:x,signDirect:S,subscription:w,init:f}};var lt=()=>{var t,i,o;if(!((o=(i=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(r,n,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return z(e)};var ut=()=>{var t,i,o;if(!((o=(i=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,n,a)=>{let s=r.replaceAll("/","").replaceAll(":","");return n?`${s}://wc?${n}`:`${s}://wc`}};return z(e)};var pt=()=>{var t,i,o;if(!((o=(i=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,n,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;case"android":return c?`${s}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${s}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return z(e)};var mt=()=>{var t,i,o;if(!((o=(i=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:i.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!G())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,n,a)=>{let s=r.replaceAll("/","").replaceAll(":",""),c=n&&encodeURIComponent(n);switch(a){case"ios":return c?`${s}://wcV2?${c}`:`${s}://wcV2`;case"android":return c?`${s}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${s}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${s}://wc?uri=${c}`:`${s}://wc`}}};return z(e)};var Se=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let n=()=>{N(),r();};return window.addEventListener("keplr_keystorechange",n),()=>{window.removeEventListener("keplr_keystorechange",n);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var B=(e=u.getState().walletType)=>{try{return R(e),!0}catch(t){return !1}},N=()=>{window.sessionStorage.removeItem(Y),g.setState(ne);},R=(e=u.getState().walletType)=>{var o;let t=(()=>{switch(e){case"keplr":return pe();case"leap":return me();case"cosmostation":return ue();case"vectis":return ye();case"walletconnect":return z();case"wc_keplr_mobile":return pt();case"wc_leap_mobile":return mt();case"wc_cosmostation_mobile":return ut();case"wc_clot_mobile":return lt();case"metamask_snap_leap":return rt();case"metamask_snap_cosmos":return tt();case"station":return ge();case"xdefi":return Se();case"capsule":return ae();case"cosmiframe":return le();case"compass":return ce();case"initia":return it();case"okx":return fe();default:throw new Error("Unknown wallet type")}})(),i=u.getState().walletDefaultOptions;return i&&((o=t.setDefaultOptions)==null||o.call(t,i)),t},er=()=>Object.fromEntries(je.map(e=>[e,B(e)])),ke=e=>e==="capsule",ve=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var J=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:i,chains:o,walletType:r}=u.getState(),n=(e==null?void 0:e.walletType)||r;if(!B(n))throw new Error(`${n} is not available`);let s=R(n),c=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||i;if(!c)throw new Error("No last known connected chain, connect action requires chain ids");let f=o==null?void 0:o.map(y=>y.chainId);c.forEach(y=>{if(!(f!=null&&f.includes(y)))throw new Error(`Chain ${y} is not provided in GrazProvider`)}),g.setState(y=>{let m=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return y.activeChainIds&&c.filter(h=>{var x;return !((x=y.activeChainIds)!=null&&x.includes(h))}).length>0?{status:"connecting"}:m?{status:"reconnecting"}:{status:"connecting"}});let{accounts:w}=g.getState();if(yield (t=s.init)==null?void 0:t.call(s),ke(n)&&g.getState().capsuleClient&&Object.values(g.getState().accounts||[]).length>0){let y=c.map(h=>o.find(x=>x.chainId===h)),m=g.getState().accounts;g.setState({status:"connecting"});let S=Object.fromEntries(yield Promise.all(c.map(h=>l(void 0,null,function*(){return [h,yield s.getKey(h)]}))));return g.setState(h=>({accounts:k(k({},h.accounts||{}),S)})),u.setState(h=>({recentChainIds:[...h.recentChainIds||[],...c].filter((x,p,I)=>I.indexOf(x)===p)})),g.setState(h=>({activeChainIds:[...h.activeChainIds||[],...c].filter((x,p,I)=>I.indexOf(x)===p)})),g.setState({status:"connected"}),{accounts:m,walletType:n,chains:y}}if(yield s.enable(c),ke(n)){let y=c.map(S=>o.find(h=>h.chainId===S)),m=g.getState().accounts;return g.setState({status:"connecting"}),{accounts:m,walletType:n,chains:y}}if(!ve(n)){let y=Object.fromEntries(yield Promise.all(c.map(m=>l(void 0,null,function*(){return [m,yield s.getKey(m)]}))));g.setState(m=>({accounts:k(k({},m.accounts||{}),y)}));}u.setState(y=>({recentChainIds:[...y.recentChainIds||[],...c].filter((m,S,h)=>h.indexOf(m)===S)})),g.setState(y=>({activeChainIds:[...y.activeChainIds||[],...c].filter((m,S,h)=>h.indexOf(m)===S)})),u.setState({walletType:n,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:n}),g.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(Y,"Active");let d=c.map(y=>o.find(m=>m.chainId===y));return {accounts:g.getState().accounts,walletType:n,chains:d}}catch(i){throw console.error("connect ",i),g.getState().accounts===null&&g.setState({status:"disconnected"}),g.getState().accounts&&g.getState().activeChainIds&&g.setState({status:"connected"}),i}}),oe=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(Y);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let i=g.getState().accounts;t.forEach(r=>{i==null||delete i[r];}),Object.values(i||{}).length===0?(g.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(g.setState(r=>{var n;return {activeChainIds:(n=r.activeChainIds)==null?void 0:n.filter(a=>!t.includes(a)),accounts:i}}),u.setState(r=>{var n;return {recentChainIds:(n=r.recentChainIds)==null?void 0:n.filter(a=>!t.includes(a))}}));}else g.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},L=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:i,_reconnect:o}=u.getState();try{let n=B(i||void 0);if(t&&n&&i)return ve(i)?void 0:yield J({chainId:t,walletType:i,autoReconnect:o})}catch(n){(r=e==null?void 0:e.onError)==null||r.call(e,n),oe();}}),dt=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),i=e.walletType||t;if(!B(i))throw new Error(`${i} is not available`);let r=R(i),n=r.getOfflineSigner(e.chainId),a=r.getOfflineSignerOnlyAmino(e.chainId),s=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:n,offlineSignerAmino:a,offlineSignerAuto:s}});var Pe=()=>{u.setState({recentChainIds:null});},mr=()=>u.getState().recentChainIds,dr=()=>{var i;let{recentChainIds:e,chains:t}=u.getState();return (i=e==null?void 0:e.map(o=>t.find(r=>r.chainId===o)))!=null?i:null},fr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(i=>i.chainId===e)},gr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(i=>e==null?void 0:e.includes(i.chainId))},We=i=>l(void 0,[i],function*({chainInfo:e,walletType:t}){let o=R(t);return t==="capsule"?yield J({chainId:e.chainId,walletType:t}):yield o.experimentalSuggestChain(e),e}),ft=e=>l(void 0,null,function*(){var o;let t=u.getState().walletType;return yield We({chainInfo:e.chainInfo,walletType:(o=e.walletType)!=null?o:t}),yield J({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var gt=e=>(u.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var yt=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,recipientAddress:i,amount:o,fee:r,memo:n}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,i,o,r,n)}),St=w=>l(void 0,[w],function*({signingClient:e,senderAddress:t,recipientAddress:i,transferAmount:o,sourcePort:r,sourceChannel:n,timeoutHeight:a,timeoutTimestamp:s,fee:c,memo:f}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,i,o,r,n,a,s,c,f)}),Ct=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:i,fee:o,options:r,label:n,codeId:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,a,i,n,o,r)}),ht=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,msg:i,fee:o,contractAddress:r,funds:n,memo:a}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,i,o,a,n)}),wt=(e,t,i)=>l(void 0,null,function*(){if(!i)throw new Error("CosmWasm client is not ready");return yield i.queryContractSmart(e,t)}),At=(e,t,i)=>{if(!i)throw new Error("CosmWasm client is not ready");let o=new TextEncoder().encode(t);return i.queryContractRaw(e,o)};var br=e=>e,Tr=e=>e;var Ce=e=>e?Object.keys(e).length===0:!0;var Re=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},It=e=>globalThis.DOMException===void 0?new Re(e):new DOMException(e),Ot=e=>{let t=e.reason===void 0?It("This operation was aborted."):e.reason;return t instanceof Error?t:It(t)};function Ke(n,a){return l(this,arguments,function*(e,t,{concurrency:i=Number.POSITIVE_INFINITY,stopOnError:o=!0,signal:r}={}){return new Promise((s,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(i)||i===Number.POSITIVE_INFINITY)&&i>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${i}\` (${typeof i})`);let f=[],w=[],d=new Map,C=!1,y=!1,m=!1,S=0,h=0,x=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),p=b=>{C=!0,y=!0,c(b);};r&&(r.aborted&&p(Ot(r)),r.addEventListener("abort",()=>{p(Ot(r));}));let I=()=>l(this,null,function*(){if(y)return;let b=yield x.next(),P=h;if(h++,b.done){if(m=!0,S===0&&!y){if(!o&&w.length>0){p(new AggregateError(w));return}if(y=!0,d.size===0){s(f);return}let K=[];for(let[_,ee]of f.entries())d.get(_)!==Et&&K.push(ee);s(K);}return}S++,l(this,null,function*(){try{let K=yield b.value;if(y)return;let _=yield t(K,P);_===Et&&d.set(P,_),f[P]=_,S--,yield I();}catch(K){if(o)p(K);else {w.push(K),S--;try{yield I();}catch(_){p(_);}}}});});l(this,null,function*(){for(let b=0;b<i;b++){try{yield I();}catch(P){p(P);break}if(m||C)break}});})})}var Et=Symbol("skip");var U=({chainId:e,multiChain:t})=>{let i=u(r=>r.chains);if(!i)throw new Error("No chains found in GrazProvider");let o=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!o):return o.map(r=>i.find(n=>n.chainId===r)).filter(Boolean);case(!t&&!!o):return [o.map(r=>i.find(n=>n.chainId===r)).filter(Boolean)[0]];case(!!t&&!o):return i;default:return [i[0]]}},q=(e,t,i)=>l(void 0,null,function*(){let o=u.getState().multiChainFetchConcurrency;if(e){let n=yield Ke(t,i,{concurrency:o});return Object.fromEntries(n.map((a,s)=>[t[s].chainId,a]))}return yield i(t[0])}),bt=(e,t,i)=>{if(e){let r=t.map(i);return Object.fromEntries(r.map((n,a)=>[t[a].chainId,n]))}return i(t[0])};var Ne=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=react.useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:i,queryFn:r=>l(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),o,a=>l(void 0,null,function*(){var w;let s=(w=u.getState().chainsConfig)==null?void 0:w[a.chainId],c={url:a.rpc,headers:k({},(s==null?void 0:s.rpcHeaders)||{})};return yield stargate.StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Be=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=react.useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:i,queryFn:r=>l(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),o,a=>l(void 0,null,function*(){var w;let s=(w=u.getState().chainsConfig)==null?void 0:w[a.chainId],c={url:a.rpc,headers:k({},(s==null?void 0:s.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},he=({type:e,chainId:t,multiChain:i,enabled:o})=>{let r=U({chainId:t,multiChain:i}),n=react.useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return reactQuery.useQuery({queryKey:n,queryFn:c=>l(void 0,[c],function*({queryKey:[,a,s]}){if(s.length<1)throw new Error("No chains found");return yield q(!!i,s,w=>l(void 0,null,function*(){var S;let d=(S=u.getState().chainsConfig)==null?void 0:S[w.chainId],C={url:w.rpc,headers:k({},(d==null?void 0:d.rpcHeaders)||{})};return yield (a==="tm37"?tendermintRpc.Tendermint37Client:tendermintRpc.Tendermint34Client).connect(C)}))}),enabled:!!r&&r.length>0&&(o!==void 0?!!o:!0),refetchOnWindowFocus:!1})};var Zr=()=>u(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow.shallow),we=e=>{let i=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return reactQuery.useQuery({queryKey:i,queryFn:({queryKey:[,r]})=>B(r)})};var Z=e=>{let t=u(s=>s.walletType),i=g(s=>s.activeChainIds),o=U({chainId:e!=null&&e.chainId?e.chainId:i||void 0,multiChain:e==null?void 0:e.multiChain}),r=g(s=>s.accounts),n=g(s=>s.status);return react.useEffect(()=>g.subscribe(s=>s.status,(s,c)=>{var f,w,d;if(s==="connected"){let{accounts:C,activeChainIds:y}=g.getState(),{chains:m}=u.getState(),{walletType:S}=u.getState();if(!C||!y||!m)return (f=e==null?void 0:e.onDisconnect)==null?void 0:f.call(e);(w=e==null?void 0:e.onConnect)==null||w.call(e,{accounts:C,chains:y.map(h=>m.find(x=>x.chainId===h)),walletType:S,isReconnect:c==="reconnecting"});}s==="disconnected"&&((d=e==null?void 0:e.onDisconnect)==null||d.call(e));}),[e]),{data:react.useMemo(()=>r?bt(!!(e!=null&&e.multiChain),o,s=>r[s.chainId]):void 0,[r,o,e==null?void 0:e.multiChain]),isConnected:n==="connected",isConnecting:n==="connecting",isDisconnected:n==="disconnected",isReconnecting:n==="reconnecting",isLoading:n==="connecting"||n==="reconnecting",walletType:n==="connected"?t:void 0,reconnect:L,status:n}},Sn=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:i}=Z(),o=(e==null?void 0:e.bech32Address)||(i==null?void 0:i.bech32Address),{data:r}=Ne({chainId:t.map(a=>a.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!o}),n=react.useMemo(()=>["USE_ALL_BALANCES",r,t,o,e==null?void 0:e.chainId],[o,e==null?void 0:e.chainId,t,r]);return reactQuery.useQuery({queryKey:n,queryFn:f=>l(void 0,[f],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield q(!!(e!=null&&e.multiChain),s,d=>l(void 0,null,function*(){var m;let C=a==null?void 0:a[d.chainId];if(!C)throw new Error(`Client is not ready ${d.chainId}`);if(!((m=d.bech32Config)!=null&&m.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield C.getAllBalances(encoding.toBech32(d.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),enabled:!!o&&!!t&&t.length>0&&!Ce(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},ms=e=>{let t=U({chainId:e.chainId}),{data:i}=Z({chainId:e.chainId}),o=e.bech32Address||(i==null?void 0:i.bech32Address),{data:r,refetch:n}=Sn({chainId:t.map(c=>c.chainId),bech32Address:o,enabled:!!o&&(e.enabled===void 0?!0:e.enabled)}),a=["USE_BALANCE",e.denom,r,t,o,e.chainId],s=reactQuery.useQuery({queryKey:a,queryFn:({queryKey:[,c,f]})=>f==null?void 0:f.find(w=>w.denom===c),enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return j(k({},s),{refetch:c=>l(void 0,null,function*(){return yield n(),s.refetch(c)})})},ds=({onError:e,onLoading:t,onSuccess:i}={})=>{let r=reactQuery.useMutation({mutationKey:["USE_CONNECT",e,t,i],mutationFn:J,onError:(a,s)=>e==null?void 0:e(a,s),onMutate:t,onSuccess:a=>Promise.resolve(i==null?void 0:i(a))}),{data:n}=we();return {connect:a=>r.mutate(a),connectAsync:a=>r.mutateAsync(a),error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,isSupported:!!n,status:r.status}},fs=({onError:e,onLoading:t,onSuccess:i}={})=>{let r=reactQuery.useMutation({mutationKey:["USE_DISCONNECT",e,t,i],mutationFn:oe,onError:n=>Promise.resolve(e==null?void 0:e(n,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(i==null?void 0:i(void 0))});return {disconnect:n=>r.mutate(n),disconnectAsync:n=>r.mutateAsync(n),error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,status:r.status}},gs=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=u(r=>r.walletType),o=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,i],[t,i]);return reactQuery.useQuery({queryKey:o,queryFn:a=>l(void 0,[a],function*({queryKey:[,r,n]}){if(r.length<1)throw new Error("No chain found");if(!B(n))throw new Error(`${n} is not available`);return yield q(!!(e!=null&&e.multiChain),r,f=>l(void 0,null,function*(){return yield dt({chainId:f.chainId,walletType:n})}))}),enabled:!!t&&t.length>0&&!!i,refetchOnWindowFocus:!1})},ys=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:i}=Z(),{data:o}=Ne({chainId:t.map(a=>a.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(i==null?void 0:i.bech32Address),n=react.useMemo(()=>["USE_BALANCE_STAKED",o,t,r],[t,r,o]);return reactQuery.useQuery({queryKey:n,queryFn:f=>l(void 0,[f],function*({queryKey:[,a,s,c]}){if(!c)throw new Error("address is not defined");return yield q(!!(e!=null&&e.multiChain),s,d=>l(void 0,null,function*(){var y,m;if(!a)throw new Error("Client is not ready");if(!((y=d.bech32Config)!=null&&y.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${d.chainId}`);return yield (m=a[d.chainId])==null?void 0:m.getBalanceStaked(encoding.toBech32(d.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),enabled:!!r&&!!t&&t.length>0&&!!o,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Os=()=>{let e=u(o=>o.capsuleState),t=g(o=>o.capsuleClient),i=ae();return {setModalState:o=>{u.setState(r=>{var n;return {capsuleState:{showModal:o,chainId:(n=r.capsuleState)==null?void 0:n.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:i.onAfterLoginSuccessful,onLoginFailure:()=>{oe();}}};var vs=()=>g(e=>e.activeChainIds),Cn=()=>{var e;return (e=g(t=>t.activeChainIds))==null?void 0:e.map(t=>{var o;let i=(o=u.getState().chains)==null?void 0:o.find(r=>r.chainId===t);if(i)return i}).filter(Boolean)},Ps=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(i=>i.chainId===e)},Ws=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(i=>e==null?void 0:e.includes(i.chainId))},Rs=({denom:e})=>{let t=Cn();return reactQuery.useQuery({queryKey:["USE_ACTIVE_CHAIN_CURRENCY",e],queryFn:({queryKey:[,r]})=>{var n;return (n=t==null?void 0:t.find(a=>a.currencies.find(s=>s.coinMinimalDenom===r)))==null?void 0:n.currencies.find(a=>a)}})},Ks=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",i=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery({queryKey:i,queryFn:s=>l(void 0,[s],function*({queryKey:[,n,a]}){if(!n)throw new Error("Query client is not defined");return yield n.staking.validators(a)}),enabled:typeof e.queryClient!="undefined"})},Ds=()=>({data:u(t=>t.recentChainIds),clear:Pe}),_s=()=>{var t;return {data:(t=u(i=>i.recentChainIds))==null?void 0:t.map(i=>{var r;let o=(r=u.getState().chains)==null?void 0:r.find(n=>n.chainId===i);if(o)return o}).filter(Boolean),clear:Pe}},Ns=({onError:e,onLoading:t,onSuccess:i}={})=>{let r=reactQuery.useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,i],mutationFn:We,onError:(n,a)=>Promise.resolve(e==null?void 0:e(n,a.chainInfo)),onMutate:n=>t==null?void 0:t(n.chainInfo),onSuccess:n=>Promise.resolve(i==null?void 0:i(n))});return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Bs=({onError:e,onLoading:t,onSuccess:i}={})=>{let r=reactQuery.useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,i],mutationFn:ft,onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:a=>t==null?void 0:t(a),onSuccess:a=>Promise.resolve(i==null?void 0:i(a))}),{data:n}=we();return {error:r.error,isLoading:r.isPending,isSuccess:r.isSuccess,isSupported:!!n,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var js=({onError:e,onLoading:t,onSuccess:i}={})=>{let{data:o}=Z(),r=o==null?void 0:o.bech32Address,n=reactQuery.useMutation({mutationKey:["USE_SEND_TOKENS",e,t,i,r],mutationFn:a=>yt(k({senderAddress:r},a)),onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(i==null?void 0:i(a))});return {error:n.error,isLoading:n.isPending,isSuccess:n.isSuccess,sendTokens:n.mutate,sendTokensAsync:n.mutateAsync,status:n.status}},$s=({onError:e,onLoading:t,onSuccess:i}={})=>{let{data:o}=Z(),r=o==null?void 0:o.bech32Address,n=reactQuery.useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,i,r],mutationFn:a=>St(k({senderAddress:r},a)),onError:(a,s)=>Promise.resolve(e==null?void 0:e(a,s)),onMutate:t,onSuccess:a=>Promise.resolve(i==null?void 0:i(a))});return {error:n.error,isLoading:n.isPending,isSuccess:n.isSuccess,sendIbcTokens:n.mutate,sendIbcTokensAsync:n.mutateAsync,status:n.status}},Vs=({codeId:e,onError:t,onLoading:i,onSuccess:o})=>{let{data:r}=Z(),n=r==null?void 0:r.bech32Address,s=reactQuery.useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,i,o,e,n],mutationFn:c=>{var w;if(!n)throw new Error("senderAddress is undefined");let f=j(k({},c),{fee:(w=c.fee)!=null?w:"auto",senderAddress:n,codeId:e});return Ct(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:i,onSuccess:c=>Promise.resolve(o==null?void 0:o(c))});return {error:s.error,isLoading:s.isPending,isSuccess:s.isSuccess,instantiateContract:s.mutate,instantiateContractAsync:s.mutateAsync,status:s.status}},Hs=({contractAddress:e,onError:t,onLoading:i,onSuccess:o})=>{let{data:r}=Z(),n=r==null?void 0:r.bech32Address,s=reactQuery.useMutation({mutationKey:["USE_EXECUTE_CONTRACT",t,i,o,e,n],mutationFn:c=>{var w,d,C;if(!n)throw new Error("senderAddress is undefined");let f=j(k({},c),{fee:(w=c.fee)!=null?w:"auto",senderAddress:n,contractAddress:e,memo:(d=c.memo)!=null?d:"",funds:(C=c.funds)!=null?C:[]});return ht(f)},onError:(c,f)=>Promise.resolve(t==null?void 0:t(c,f)),onMutate:i,onSuccess:c=>Promise.resolve(o==null?void 0:o(c))});return {error:s.error,isLoading:s.isPending,isSuccess:s.isSuccess,executeContract:s.mutate,executeContractAsync:s.mutateAsync,status:s.status}},Xs=e=>{let{data:t}=Be();return reactQuery.useQuery({queryKey:["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],queryFn:({queryKey:[,o]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return wt(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Ys=e=>{let{data:t}=Be(),i=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery({queryKey:i,queryFn:({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return At(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function ua(e){let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=u(n=>n.walletType),o=g(n=>n.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,i,e,o],[o,e,t,i]);return reactQuery.useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,n,a]}){if(n.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),n,f=>l(this,null,function*(){var S,h;if(!(o!=null&&o.includes(f.chainId)))return null;if(!B(a))throw new Error(`${a} is not available`);let d=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(f.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(f.chainId);default:return R(a).getOfflineSignerAuto(f.chainId)}}))(),C=(S=u.getState().chainsConfig)==null?void 0:S[f.chainId],y={url:f.rpc,headers:k({},(C==null?void 0:C.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(y,d,e!=null&&e.multiChain?(h=e.opts)==null?void 0:h[f.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!i&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function pa(e){let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),i=u(n=>n.walletType),o=g(n=>n.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,i,e,o],[o,e,t,i]);return reactQuery.useQuery({queryKey:r,queryFn:s=>l(this,[s],function*({queryKey:[,n,a]}){if(n.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),n,f=>l(this,null,function*(){var h,x;if(!(o!=null&&o.includes(f.chainId)))return null;if(!B(a))throw new Error(`${a} is not available`);let d=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(f.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(f.chainId);default:return R(a).getOfflineSignerAuto(f.chainId)}}))(),C=(h=u.getState().chainsConfig)==null?void 0:h[f.chainId],y={url:f.rpc,headers:k({},(C==null?void 0:C.rpcHeaders)||{})},m=C!=null&&C.gas?stargate.GasPrice.fromString(`${C.gas.price}${C.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(y,d,k({gasPrice:m},e!=null&&e.multiChain?(x=e.opts)==null?void 0:x[f.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!i&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ma(e){let t=U({chainId:e.chainId,multiChain:e.multiChain}),i=u(a=>a.walletType),o=g(a=>a.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,i,e,o],[o,e,t,i]),{data:n}=he({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:c=>l(this,[c],function*({queryKey:[,a,s]}){if(a.length<1)throw new Error("No chains found");return yield q(!!e.multiChain,a,w=>l(this,null,function*(){var S;if(!(o!=null&&o.includes(w.chainId)))return null;if(!B(s))throw new Error(`${s} is not available`);if(!n)throw new Error("No tendermint client found");let C=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(w.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(w.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(w.chainId);default:return R(s).getOfflineSignerAuto(w.chainId)}}))(),y=e.multiChain?n[w.chainId]:n;return yield stargate.SigningStargateClient.createWithSigner(y,C,e.multiChain?(S=e.opts)==null?void 0:S[w.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!i&&!!n&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function da(e){let t=U({chainId:e.chainId,multiChain:e.multiChain}),i=u(s=>s.walletType),o=g(s=>s.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,i,e,o],[o,e,t,i]),{data:n}=he({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:a}=he({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:f=>l(this,[f],function*({queryKey:[,s,c]}){if(s.length<1)throw new Error("No chains found");return yield q(!!e.multiChain,s,d=>l(this,null,function*(){var p,I;if(!(o!=null&&o.includes(d.chainId)))return null;if(!B(c))throw new Error(`${c} is not available`);let y=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(c).getOfflineSigner(d.chainId);case"offlineSignerAuto":return R(c).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return R(c).getOfflineSignerOnlyAmino(d.chainId);default:return R(c).getOfflineSignerAuto(d.chainId)}}))(),m=(p=u.getState().chainsConfig)==null?void 0:p[d.chainId],S=m!=null&&m.gas?stargate.GasPrice.fromString(`${m.gas.price}${m.gas.denom}`):void 0,h=e.multiChain?a==null?void 0:a[d.chainId]:n;if(!h)throw new Error("No tendermint client found");return yield cosmwasmStargate.SigningCosmWasmClient.createWithSigner(h,y,k({gasPrice:S},e.multiChain?(I=e.opts)==null?void 0:I[d.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!i&&(!!n||!Ce(a))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Dt=({children:e})=>{let[t,i]=react.useState(!1);return react.useEffect(()=>{i(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var En=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(Y)==="Active",{_reconnect:t,_onReconnectFailed:i,_reconnectConnector:o,iframeOptions:r,chains:n}=u(),{activeChainIds:a,wcSignClients:s}=g(),c=B(o||void 0);return react.useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!n)return;new cosmiframe.Cosmiframe(r.allowedIframeParentOrigins).isReady().then(w=>{if(w)return J({chainId:n.map(d=>d.chainId),walletType:"cosmiframe"})});},[r]),react.useEffect(()=>{if(o){if(!c)return;e&&a?L({onError:i}):!e&&t&&L({onError:i});}},[c]),react.useEffect(()=>{var f,w,d,C,y,m,S,h,x,p,I,b,P,K,_,ee,ie,A,O,E;if(o){if(!c)return;o==="cosmostation"&&((w=(f=ue()).subscription)==null||w.call(f,()=>{L({onError:i});})),o==="keplr"&&((C=(d=pe()).subscription)==null||C.call(d,()=>{L({onError:i});})),o==="leap"&&((m=(y=me()).subscription)==null||m.call(y,()=>{L({onError:i});})),o==="compass"&&((h=(S=ce()).subscription)==null||h.call(S,()=>{L({onError:i});})),o==="vectis"&&((p=(x=ye()).subscription)==null||p.call(x,()=>{L({onError:i});})),o==="walletconnect"&&s.has("walletconnect")&&((b=(I=z()).subscription)==null||b.call(I,()=>{L({onError:i});})),o==="station"&&((K=(P=ge()).subscription)==null||K.call(P,()=>{L({onError:i});})),o==="xdefi"&&((ee=(_=Se()).subscription)==null||ee.call(_,()=>{L({onError:i});})),o==="cosmiframe"&&((A=(ie=le()).subscription)==null||A.call(ie,()=>{L({onError:i});})),o==="okx"&&((E=(O=fe()).subscription)==null||E.call(O,()=>{L({onError:i});}));}},[o,s,c]),null},_t=()=>(En(),null);var Ga=({children:e,grazOptions:t})=>(react.useEffect(()=>{gt(t);},[t]),jsxRuntime.jsxs(Dt,{children:[e,jsxRuntime.jsx(_t,{})]}));
30
+ var fy=Object.create;var Dr=Object.defineProperty,hy=Object.defineProperties,dy=Object.getOwnPropertyDescriptor,py=Object.getOwnPropertyDescriptors,gy=Object.getOwnPropertyNames,pl=Object.getOwnPropertySymbols,my=Object.getPrototypeOf,ml=Object.prototype.hasOwnProperty,yy=Object.prototype.propertyIsEnumerable;var gl=(e,t,r)=>t in e?Dr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,M=(e,t)=>{for(var r in t||(t={}))ml.call(t,r)&&gl(e,r,t[r]);if(pl)for(var r of pl(t))yy.call(t,r)&&gl(e,r,t[r]);return e},X=(e,t)=>hy(e,py(t));var z=(e=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(e,{get:(t,r)=>(typeof require!="undefined"?require:t)[r]}):e)(function(e){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+e+'" is not supported')});var yl=(e,t)=>()=>(e&&(t=e(e=0)),t);var B=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),Ae=(e,t)=>{for(var r in t)Dr(e,r,{get:t[r],enumerable:!0});},xn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of gy(t))!ml.call(e,i)&&i!==r&&Dr(e,i,{get:()=>t[i],enumerable:!(n=dy(t,i))||n.enumerable});return e},Oe=(e,t,r)=>(xn(e,t,"default"),r&&xn(r,t,"default")),Je=(e,t,r)=>(r=e!=null?fy(my(e)):{},xn(t||!e||!e.__esModule?Dr(r,"default",{value:e,enumerable:!0}):r,e)),Ar=e=>xn(Dr({},"__esModule",{value:!0}),e);var g=(e,t,r)=>new Promise((n,i)=>{var s=c=>{try{a(r.next(c));}catch(h){i(h);}},o=c=>{try{a(r.throw(c));}catch(h){i(h);}},a=c=>c.done?n(c.value):Promise.resolve(c.value).then(s,o);a((r=r.apply(e,t)).next());});var d=yl(()=>{});var Qt={};Ae(Qt,{__assign:()=>gs,__asyncDelegator:()=>Hy,__asyncGenerator:()=>Vy,__asyncValues:()=>Jy,__await:()=>Or,__awaiter:()=>Ky,__classPrivateFieldGet:()=>Zy,__classPrivateFieldSet:()=>ew,__createBinding:()=>zy,__decorate:()=>ky,__exportStar:()=>$y,__extends:()=>Fy,__generator:()=>jy,__importDefault:()=>Qy,__importStar:()=>Xy,__makeTemplateObject:()=>Yy,__metadata:()=>Wy,__param:()=>Uy,__read:()=>Nl,__rest:()=>By,__spread:()=>qy,__spreadArrays:()=>Gy,__values:()=>ms});function Fy(e,t){ps(e,t);function r(){this.constructor=e;}e.prototype=t===null?Object.create(t):(r.prototype=t.prototype,new r);}function By(e,t){var r={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(r[n]=e[n]);if(e!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(e);i<n.length;i++)t.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(e,n[i])&&(r[n[i]]=e[n[i]]);return r}function ky(e,t,r,n){var i=arguments.length,s=i<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,r):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,r,s):o(t,r))||s);return i>3&&s&&Object.defineProperty(t,r,s),s}function Uy(e,t){return function(r,n){t(r,n,e);}}function Wy(e,t){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(e,t)}function Ky(e,t,r,n){function i(s){return s instanceof r?s:new r(function(o){o(s);})}return new(r||(r=Promise))(function(s,o){function a(l){try{h(n.next(l));}catch(f){o(f);}}function c(l){try{h(n.throw(l));}catch(f){o(f);}}function h(l){l.done?s(l.value):i(l.value).then(a,c);}h((n=n.apply(e,t||[])).next());})}function jy(e,t){var r={label:0,sent:function(){if(s[0]&1)throw s[1];return s[1]},trys:[],ops:[]},n,i,s,o;return o={next:a(0),throw:a(1),return:a(2)},typeof Symbol=="function"&&(o[Symbol.iterator]=function(){return this}),o;function a(h){return function(l){return c([h,l])}}function c(h){if(n)throw new TypeError("Generator is already executing.");for(;r;)try{if(n=1,i&&(s=h[0]&2?i.return:h[0]?i.throw||((s=i.return)&&s.call(i),0):i.next)&&!(s=s.call(i,h[1])).done)return s;switch(i=0,s&&(h=[h[0]&2,s.value]),h[0]){case 0:case 1:s=h;break;case 4:return r.label++,{value:h[1],done:!1};case 5:r.label++,i=h[1],h=[0];continue;case 7:h=r.ops.pop(),r.trys.pop();continue;default:if(s=r.trys,!(s=s.length>0&&s[s.length-1])&&(h[0]===6||h[0]===2)){r=0;continue}if(h[0]===3&&(!s||h[1]>s[0]&&h[1]<s[3])){r.label=h[1];break}if(h[0]===6&&r.label<s[1]){r.label=s[1],s=h;break}if(s&&r.label<s[2]){r.label=s[2],r.ops.push(h);break}s[2]&&r.ops.pop(),r.trys.pop();continue}h=t.call(e,r);}catch(l){h=[6,l],i=0;}finally{n=s=0;}if(h[0]&5)throw h[1];return {value:h[0]?h[1]:void 0,done:!0}}}function zy(e,t,r,n){n===void 0&&(n=r),e[n]=t[r];}function $y(e,t){for(var r in e)r!=="default"&&!t.hasOwnProperty(r)&&(t[r]=e[r]);}function ms(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return {next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Nl(e,t){var r=typeof Symbol=="function"&&e[Symbol.iterator];if(!r)return e;var n=r.call(e),i,s=[],o;try{for(;(t===void 0||t-- >0)&&!(i=n.next()).done;)s.push(i.value);}catch(a){o={error:a};}finally{try{i&&!i.done&&(r=n.return)&&r.call(n);}finally{if(o)throw o.error}}return s}function qy(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(Nl(arguments[t]));return e}function Gy(){for(var e=0,t=0,r=arguments.length;t<r;t++)e+=arguments[t].length;for(var n=Array(e),i=0,t=0;t<r;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,i++)n[i]=s[o];return n}function Or(e){return this instanceof Or?(this.v=e,this):new Or(e)}function Vy(e,t,r){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var n=r.apply(e,t||[]),i,s=[];return i={},o("next"),o("throw"),o("return"),i[Symbol.asyncIterator]=function(){return this},i;function o(m){n[m]&&(i[m]=function(p){return new Promise(function(u,y){s.push([m,p,u,y])>1||a(m,p);})});}function a(m,p){try{c(n[m](p));}catch(u){f(s[0][3],u);}}function c(m){m.value instanceof Or?Promise.resolve(m.value.v).then(h,l):f(s[0][2],m);}function h(m){a("next",m);}function l(m){a("throw",m);}function f(m,p){m(p),s.shift(),s.length&&a(s[0][0],s[0][1]);}}function Hy(e){var t,r;return t={},n("next"),n("throw",function(i){throw i}),n("return"),t[Symbol.iterator]=function(){return this},t;function n(i,s){t[i]=e[i]?function(o){return (r=!r)?{value:Or(e[i](o)),done:i==="return"}:s?s(o):o}:s;}}function Jy(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t=e[Symbol.asyncIterator],r;return t?t.call(e):(e=typeof ms=="function"?ms(e):e[Symbol.iterator](),r={},n("next"),n("throw"),n("return"),r[Symbol.asyncIterator]=function(){return this},r);function n(s){r[s]=e[s]&&function(o){return new Promise(function(a,c){o=e[s](o),i(a,c,o.done,o.value);})};}function i(s,o,a,c){Promise.resolve(c).then(function(h){s({value:h,done:a});},o);}}function Yy(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function Xy(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var r in e)Object.hasOwnProperty.call(e,r)&&(t[r]=e[r]);return t.default=e,t}function Qy(e){return e&&e.__esModule?e:{default:e}}function Zy(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function ew(e,t,r){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,r),r}var ps,gs,Zt=yl(()=>{d();ps=function(e,t){return ps=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(r,n){r.__proto__=n;}||function(r,n){for(var i in n)n.hasOwnProperty(i)&&(r[i]=n[i]);},ps(e,t)};gs=function(){return gs=Object.assign||function(t){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(t[s]=r[s]);}return t},gs.apply(this,arguments)};});var Ll=B(Mn=>{d();Object.defineProperty(Mn,"__esModule",{value:!0});Mn.delay=void 0;function tw(e){return new Promise(t=>{setTimeout(()=>{t(!0);},e);})}Mn.delay=tw;});var Ml=B(er=>{d();Object.defineProperty(er,"__esModule",{value:!0});er.ONE_THOUSAND=er.ONE_HUNDRED=void 0;er.ONE_HUNDRED=100;er.ONE_THOUSAND=1e3;});var Fl=B(U=>{d();Object.defineProperty(U,"__esModule",{value:!0});U.ONE_YEAR=U.FOUR_WEEKS=U.THREE_WEEKS=U.TWO_WEEKS=U.ONE_WEEK=U.THIRTY_DAYS=U.SEVEN_DAYS=U.FIVE_DAYS=U.THREE_DAYS=U.ONE_DAY=U.TWENTY_FOUR_HOURS=U.TWELVE_HOURS=U.SIX_HOURS=U.THREE_HOURS=U.ONE_HOUR=U.SIXTY_MINUTES=U.THIRTY_MINUTES=U.TEN_MINUTES=U.FIVE_MINUTES=U.ONE_MINUTE=U.SIXTY_SECONDS=U.THIRTY_SECONDS=U.TEN_SECONDS=U.FIVE_SECONDS=U.ONE_SECOND=void 0;U.ONE_SECOND=1;U.FIVE_SECONDS=5;U.TEN_SECONDS=10;U.THIRTY_SECONDS=30;U.SIXTY_SECONDS=60;U.ONE_MINUTE=U.SIXTY_SECONDS;U.FIVE_MINUTES=U.ONE_MINUTE*5;U.TEN_MINUTES=U.ONE_MINUTE*10;U.THIRTY_MINUTES=U.ONE_MINUTE*30;U.SIXTY_MINUTES=U.ONE_MINUTE*60;U.ONE_HOUR=U.SIXTY_MINUTES;U.THREE_HOURS=U.ONE_HOUR*3;U.SIX_HOURS=U.ONE_HOUR*6;U.TWELVE_HOURS=U.ONE_HOUR*12;U.TWENTY_FOUR_HOURS=U.ONE_HOUR*24;U.ONE_DAY=U.TWENTY_FOUR_HOURS;U.THREE_DAYS=U.ONE_DAY*3;U.FIVE_DAYS=U.ONE_DAY*5;U.SEVEN_DAYS=U.ONE_DAY*7;U.THIRTY_DAYS=U.ONE_DAY*30;U.ONE_WEEK=U.SEVEN_DAYS;U.TWO_WEEKS=U.ONE_WEEK*2;U.THREE_WEEKS=U.ONE_WEEK*3;U.FOUR_WEEKS=U.ONE_WEEK*4;U.ONE_YEAR=U.ONE_DAY*365;});var ys=B(Fn=>{d();Object.defineProperty(Fn,"__esModule",{value:!0});var Bl=(Zt(),Ar(Qt));Bl.__exportStar(Ml(),Fn);Bl.__exportStar(Fl(),Fn);});var Ul=B(tr=>{d();Object.defineProperty(tr,"__esModule",{value:!0});tr.fromMiliseconds=tr.toMiliseconds=void 0;var kl=ys();function rw(e){return e*kl.ONE_THOUSAND}tr.toMiliseconds=rw;function nw(e){return Math.floor(e/kl.ONE_THOUSAND)}tr.fromMiliseconds=nw;});var Kl=B(Bn=>{d();Object.defineProperty(Bn,"__esModule",{value:!0});var Wl=(Zt(),Ar(Qt));Wl.__exportStar(Ll(),Bn);Wl.__exportStar(Ul(),Bn);});var jl=B(Tr=>{d();Object.defineProperty(Tr,"__esModule",{value:!0});Tr.Watch=void 0;var kn=class{constructor(){this.timestamps=new Map;}start(t){if(this.timestamps.has(t))throw new Error(`Watch already started for label: ${t}`);this.timestamps.set(t,{started:Date.now()});}stop(t){let r=this.get(t);if(typeof r.elapsed!="undefined")throw new Error(`Watch already stopped for label: ${t}`);let n=Date.now()-r.started;this.timestamps.set(t,{started:r.started,elapsed:n});}get(t){let r=this.timestamps.get(t);if(typeof r=="undefined")throw new Error(`No timestamp found for label: ${t}`);return r}elapsed(t){let r=this.get(t);return r.elapsed||Date.now()-r.started}};Tr.Watch=kn;Tr.default=kn;});var zl=B(Un=>{d();Object.defineProperty(Un,"__esModule",{value:!0});Un.IWatch=void 0;var ws=class{};Un.IWatch=ws;});var $l=B(bs=>{d();Object.defineProperty(bs,"__esModule",{value:!0});var iw=(Zt(),Ar(Qt));iw.__exportStar(zl(),bs);});var Kn=B(rr=>{d();Object.defineProperty(rr,"__esModule",{value:!0});var Wn=(Zt(),Ar(Qt));Wn.__exportStar(Kl(),rr);Wn.__exportStar(jl(),rr);Wn.__exportStar($l(),rr);Wn.__exportStar(ys(),rr);});var au=B((Z3,ou)=>{d();ou.exports=su;var{toString:Dw}=Object.prototype,As=Symbol("circular-ref-tag"),Os=Symbol("pino-raw-err-ref"),iu=Object.create({},{type:{enumerable:!0,writable:!0,value:void 0},message:{enumerable:!0,writable:!0,value:void 0},stack:{enumerable:!0,writable:!0,value:void 0},raw:{enumerable:!1,get:function(){return this[Os]},set:function(e){this[Os]=e;}}});Object.defineProperty(iu,Os,{writable:!0,value:{}});function su(e){if(!(e instanceof Error))return e;e[As]=void 0;let t=Object.create(iu);t.type=Dw.call(e.constructor)==="[object Function]"?e.constructor.name:e.name,t.message=e.message,t.stack=e.stack;for(let r in e)if(t[r]===void 0){let n=e[r];n instanceof Error?n.hasOwnProperty(As)||(t[r]=su(n)):t[r]=n;}return delete e[As],t.raw=e,t}});var fu=B((t2,uu)=>{d();uu.exports={mapHttpRequest:Aw,reqSerializer:lu};var Ts=Symbol("pino-raw-req-ref"),cu=Object.create({},{id:{enumerable:!0,writable:!0,value:""},method:{enumerable:!0,writable:!0,value:""},url:{enumerable:!0,writable:!0,value:""},query:{enumerable:!0,writable:!0,value:""},params:{enumerable:!0,writable:!0,value:""},headers:{enumerable:!0,writable:!0,value:{}},remoteAddress:{enumerable:!0,writable:!0,value:""},remotePort:{enumerable:!0,writable:!0,value:""},raw:{enumerable:!1,get:function(){return this[Ts]},set:function(e){this[Ts]=e;}}});Object.defineProperty(cu,Ts,{writable:!0,value:{}});function lu(e){let t=e.info||e.socket,r=Object.create(cu);return r.id=typeof e.id=="function"?e.id():e.id||(e.info?e.info.id:void 0),r.method=e.method,e.originalUrl?(r.url=e.originalUrl,r.query=e.query,r.params=e.params):r.url=e.path||(e.url?e.url.path||e.url:void 0),r.headers=e.headers,r.remoteAddress=t&&t.remoteAddress,r.remotePort=t&&t.remotePort,r.raw=e.raw||e,r}function Aw(e){return {req:lu(e)}}});var gu=B((n2,pu)=>{d();pu.exports={mapHttpResponse:Ow,resSerializer:du};var Rs=Symbol("pino-raw-res-ref"),hu=Object.create({},{statusCode:{enumerable:!0,writable:!0,value:0},headers:{enumerable:!0,writable:!0,value:""},raw:{enumerable:!1,get:function(){return this[Rs]},set:function(e){this[Rs]=e;}}});Object.defineProperty(hu,Rs,{writable:!0,value:{}});function du(e){let t=Object.create(hu);return t.statusCode=e.statusCode,t.headers=e.getHeaders?e.getHeaders():e._headers,t.raw=e,t}function Ow(e){return {res:du(e)}}});var Ns=B((s2,mu)=>{d();var Ps=au(),Vn=fu(),Hn=gu();mu.exports={err:Ps,mapHttpRequest:Vn.mapHttpRequest,mapHttpResponse:Hn.mapHttpResponse,req:Vn.reqSerializer,res:Hn.resSerializer,wrapErrorSerializer:function(t){return t===Ps?t:function(n){return t(Ps(n))}},wrapRequestSerializer:function(t){return t===Vn.reqSerializer?t:function(n){return t(Vn.reqSerializer(n))}},wrapResponseSerializer:function(t){return t===Hn.resSerializer?t:function(n){return t(Hn.resSerializer(n))}}};});var Ls=B((a2,yu)=>{d();function Tw(e,t){return t}yu.exports=function(){let t=Error.prepareStackTrace;Error.prepareStackTrace=Tw;let r=new Error().stack;if(Error.prepareStackTrace=t,!Array.isArray(r))return;let n=r.slice(2),i=[];for(let s of n)s&&i.push(s.getFileName());return i};});var bu=B((l2,wu)=>{d();wu.exports=Rw;function Rw(e={}){let{ERR_PATHS_MUST_BE_STRINGS:t=()=>"fast-redact - Paths must be (non-empty) strings",ERR_INVALID_PATH:r=n=>`fast-redact \u2013 Invalid path (${n})`}=e;return function({paths:i}){i.forEach(s=>{if(typeof s!="string")throw Error(t());try{if(/〇/.test(s))throw Error();let o=(s[0]==="["?"":".")+s.replace(/^\*/,"\u3007").replace(/\.\*/g,".\u3007").replace(/\[\*\]/g,"[\u3007]");if(/\n|\r|;/.test(o)||/\/\*/.test(o))throw Error();Function(`
31
+ 'use strict'
32
+ const o = new Proxy({}, { get: () => o, set: () => { throw Error() } });
33
+ const \u3007 = null;
34
+ o${o}
35
+ if ([o${o}].length !== 1) throw Error()`)();}catch(o){throw Error(r(s))}});}}});var Jn=B((f2,Su)=>{d();Su.exports=/[^.[\]]+|\[((?:.)*?)\]/g;});var Eu=B((d2,_u)=>{d();var Pw=Jn();_u.exports=Nw;function Nw({paths:e}){let t=[];var r=0;let n=e.reduce(function(i,s,o){var a=s.match(Pw).map(l=>l.replace(/'|"|`/g,""));let c=s[0]==="[";a=a.map(l=>l[0]==="["?l.substr(1,l.length-2):l);let h=a.indexOf("*");if(h>-1){let l=a.slice(0,h),f=l.join("."),m=a.slice(h+1,a.length),p=m.length>0;r++,t.push({before:l,beforeStr:f,after:m,nested:p});}else i[s]={path:a,val:void 0,precensored:!1,circle:"",escPath:JSON.stringify(s),leadingBracket:c};return i},{});return {wildcards:t,wcLen:r,secret:n}}});var xu=B((g2,vu)=>{d();var Lw=Jn();vu.exports=Mw;function Mw({secret:e,serialize:t,wcLen:r,strict:n,isCensorFct:i,censorFctTakesPath:s},o){let a=Function("o",`
36
+ if (typeof o !== 'object' || o == null) {
37
+ ${Uw(n,t)}
38
+ }
39
+ const { censor, secret } = this
40
+ const originalSecret = {}
41
+ const secretKeys = Object.keys(secret)
42
+ for (var i = 0; i < secretKeys.length; i++) {
43
+ originalSecret[secretKeys[i]] = secret[secretKeys[i]]
44
+ }
26
45
 
27
- exports.GrazEvents = _t;
28
- exports.GrazProvider = Ga;
29
- exports.WALLET_TYPES = je;
30
- exports.WalletType = Qe;
31
- exports.checkWallet = B;
32
- exports.clearRecentChain = Pe;
33
- exports.clearSession = N;
34
- exports.configureGraz = gt;
35
- exports.connect = J;
36
- exports.defineChainInfo = Tr;
37
- exports.defineChains = br;
38
- exports.disconnect = oe;
39
- exports.executeContract = ht;
40
- exports.getAvailableWallets = er;
41
- exports.getChainInfo = fr;
42
- exports.getChainInfos = gr;
43
- exports.getCosmostation = ue;
44
- exports.getKeplr = pe;
45
- exports.getLeap = me;
46
- exports.getMetamaskSnapLeap = rt;
47
- exports.getOfflineSigners = dt;
48
- exports.getQueryRaw = At;
49
- exports.getQuerySmart = wt;
50
- exports.getRecentChainIds = mr;
51
- exports.getRecentChains = dr;
52
- exports.getVectis = ye;
53
- exports.getWCCosmostation = ut;
54
- exports.getWCKeplr = pt;
55
- exports.getWCLeap = mt;
56
- exports.getWallet = R;
57
- exports.getWalletConnect = z;
58
- exports.instantiateContract = Ct;
59
- exports.isCapsule = ke;
60
- exports.isWalletConnect = ve;
61
- exports.reconnect = L;
62
- exports.sendIbcTokens = St;
63
- exports.sendTokens = yt;
64
- exports.suggestChain = We;
65
- exports.suggestChainAndConnect = ft;
66
- exports.useAccount = Z;
67
- exports.useActiveChainCurrency = Rs;
68
- exports.useActiveChainIds = vs;
69
- exports.useActiveChains = Cn;
70
- exports.useActiveWalletType = Zr;
71
- exports.useBalance = ms;
72
- exports.useBalanceStaked = ys;
73
- exports.useBalances = Sn;
74
- exports.useCapsule = Os;
75
- exports.useChainInfo = Ps;
76
- exports.useChainInfos = Ws;
77
- exports.useCheckWallet = we;
78
- exports.useConnect = ds;
79
- exports.useCosmWasmClient = Be;
80
- exports.useCosmWasmSigningClient = pa;
81
- exports.useCosmWasmTmSigningClient = da;
82
- exports.useDisconnect = fs;
83
- exports.useExecuteContract = Hs;
84
- exports.useGrazEvents = En;
85
- exports.useInstantiateContract = Vs;
86
- exports.useOfflineSigners = gs;
87
- exports.useQueryClientValidators = Ks;
88
- exports.useQueryRaw = Ys;
89
- exports.useQuerySmart = Xs;
90
- exports.useRecentChainIds = Ds;
91
- exports.useRecentChains = _s;
92
- exports.useSendIbcTokens = $s;
93
- exports.useSendTokens = js;
94
- exports.useStargateClient = Ne;
95
- exports.useStargateSigningClient = ua;
96
- exports.useStargateTmSigningClient = ma;
97
- exports.useSuggestChain = Ns;
98
- exports.useSuggestChainAndConnect = Bs;
99
- exports.useTendermintClient = he;
46
+ ${Fw(e,i,s)}
47
+ this.compileRestore()
48
+ ${Bw(r>0,i,s)}
49
+ this.secret = originalSecret
50
+ ${kw(t)}
51
+ `).bind(o);return a.state=o,t===!1&&(a.restore=c=>o.restore(c)),a}function Fw(e,t,r){return Object.keys(e).map(n=>{let{escPath:i,leadingBracket:s,path:o}=e[n],a=s?1:0,c=s?"":".",h=[];for(var l;(l=Lw.exec(n))!==null;){let[,u]=l,{index:y,input:w}=l;y>a&&h.push(w.substring(0,y-(u?0:1)));}var f=h.map(u=>`o${c}${u}`).join(" && ");f.length===0?f+=`o${c}${n} != null`:f+=` && o${c}${n} != null`;let m=`
52
+ switch (true) {
53
+ ${h.reverse().map(u=>`
54
+ case o${c}${u} === censor:
55
+ secret[${i}].circle = ${JSON.stringify(u)}
56
+ break
57
+ `).join(`
58
+ `)}
59
+ }
60
+ `,p=r?`val, ${JSON.stringify(o)}`:"val";return `
61
+ if (${f}) {
62
+ const val = o${c}${n}
63
+ if (val === censor) {
64
+ secret[${i}].precensored = true
65
+ } else {
66
+ secret[${i}].val = val
67
+ o${c}${n} = ${t?`censor(${p})`:"censor"}
68
+ ${m}
69
+ }
70
+ }
71
+ `}).join(`
72
+ `)}function Bw(e,t,r){return e===!0?`
73
+ {
74
+ const { wildcards, wcLen, groupRedact, nestedRedact } = this
75
+ for (var i = 0; i < wcLen; i++) {
76
+ const { before, beforeStr, after, nested } = wildcards[i]
77
+ if (nested === true) {
78
+ secret[beforeStr] = secret[beforeStr] || []
79
+ nestedRedact(secret[beforeStr], o, before, after, censor, ${t}, ${r})
80
+ } else secret[beforeStr] = groupRedact(o, before, censor, ${t}, ${r})
81
+ }
82
+ }
83
+ `:""}function kw(e){return e===!1?"return o":`
84
+ var s = this.serialize(o)
85
+ this.restore(o)
86
+ return s
87
+ `}function Uw(e,t){return e===!0?"throw Error('fast-redact: primitives cannot be redacted')":t===!1?"return o":"return this.serialize(o)"}});var Fs=B((y2,Du)=>{d();Du.exports={groupRedact:Kw,groupRestore:Ww,nestedRedact:zw,nestedRestore:jw};function Ww({keys:e,values:t,target:r}){if(r==null||typeof r=="string")return;let n=e.length;for(var i=0;i<n;i++){let s=e[i];r[s]=t[i];}}function Kw(e,t,r,n,i){let s=Cu(e,t);if(s==null||typeof s=="string")return {keys:null,values:null,target:s,flat:!0};let o=Object.keys(s),a=o.length,c=t.length,h=i?[...t]:void 0,l=new Array(a);for(var f=0;f<a;f++){let m=o[f];l[f]=s[m],i?(h[c]=m,s[m]=r(s[m],h)):n?s[m]=r(s[m]):s[m]=r;}return {keys:o,values:l,target:s,flat:!0}}function jw(e){for(let t=0;t<e.length;t++){let{target:r,path:n,value:i}=e[t],s=r;for(let o=n.length-1;o>0;o--)s=s[n[o]];s[n[0]]=i;}}function zw(e,t,r,n,i,s,o){let a=Cu(t,r);if(a==null)return;let c=Object.keys(a),h=c.length;for(var l=0;l<h;l++){let f=c[l];$w(e,a,f,r,n,i,s,o);}return e}function Ms(e,t){return e!=null?"hasOwn"in Object?Object.hasOwn(e,t):Object.prototype.hasOwnProperty.call(e,t):!1}function $w(e,t,r,n,i,s,o,a){let c=i.length,h=c-1,l=r;var f=-1,m,p,u,w=null,S,b,_=!1,x=0,O=0,L=qw();if(u=m=t[r],typeof m=="object"){for(;m!=null&&++f<c&&(O+=1,r=i[f],!(r!=="*"&&!w&&!(typeof m=="object"&&r in m)));)if(!(r==="*"&&(w==="*"&&(_=!0),w=r,f!==h))){if(w){let C=Object.keys(m);for(var E=0;E<C.length;E++){let F=C[E];if(b=m[F],S=r==="*",_)L=ct(L,F,O),x=f,u=Iu(b,x-1,r,n,i,s,o,a,l,m,p,u,S,F,f,h,L,e,t[l],O+1);else if(S||typeof b=="object"&&b!==null&&r in b){if(S?u=b:u=b[r],p=f!==h?u:o?a?s(u,[...n,l,...i]):s(u):s,S){let T=Mr(ct(L,F,O),u,t[l]);e.push(T),m[F]=p;}else if(b[r]!==p)if(p===void 0&&s!==void 0||Ms(b,r)&&p===u)L=ct(L,F,O);else {L=ct(L,F,O);let T=Mr(ct(L,r,O+1),u,t[l]);e.push(T),b[r]=p;}}}w=null;}else {if(u=m[r],L=ct(L,r,O),p=f!==h?u:o?a?s(u,[...n,l,...i]):s(u):s,!(Ms(m,r)&&p===u||p===void 0&&s!==void 0)){let C=Mr(L,u,t[l]);e.push(C),m[r]=p;}m=m[r];}if(typeof m!="object")break}}}function Cu(e,t){for(var r=-1,n=t.length,i=e;i!=null&&++r<n;)i=i[t[r]];return i}function Iu(e,t,r,n,i,s,o,a,c,h,l,f,m,p,u,y,w,S,b,_){if(t===0&&(m||typeof e=="object"&&e!==null&&r in e)){if(m?f=e:f=e[r],l=u!==y?f:o?a?s(f,[...n,c,...i]):s(f):s,m){let x=Mr(w,f,b);S.push(x),h[p]=l;}else if(e[r]!==l){if(!(l===void 0&&s!==void 0||Ms(e,r)&&l===f)){let x=Mr(ct(w,r,_+1),f,b);S.push(x),e[r]=l;}}}for(let x in e)typeof e[x]=="object"&&(w=ct(w,x,_),Iu(e[x],t-1,r,n,i,s,o,a,c,h,l,f,m,p,u,y,w,S,b,_+1));}function qw(){return {parent:null,key:null,children:[],depth:0}}function ct(e,t,r){if(e.depth===r)return ct(e.parent,t,r);var n={parent:e,key:t,depth:r,children:[]};return e.children.push(n),n}function Mr(e,t,r){let n=e,i=[];do i.push(n.key),n=n.parent;while(n.parent!=null);return {path:i,value:t,target:r}}});var Ou=B((b2,Au)=>{d();var{groupRestore:Gw,nestedRestore:Vw}=Fs();Au.exports=Hw;function Hw(){return function(){if(this.restore){this.restore.state.secret=this.secret;return}let{secret:t,wcLen:r}=this,n=Object.keys(t),i=Jw(t,n),s=r>0,o=s?{secret:t,groupRestore:Gw,nestedRestore:Vw}:{secret:t};this.restore=Function("o",Yw(i,n,s)).bind(o),this.restore.state=o;}}function Jw(e,t){return t.map(r=>{let{circle:n,escPath:i,leadingBracket:s}=e[r],a=n?`o.${n} = secret[${i}].val`:`o${s?"":"."}${r} = secret[${i}].val`,c=`secret[${i}].val = undefined`;return `
88
+ if (secret[${i}].val !== undefined) {
89
+ try { ${a} } catch (e) {}
90
+ ${c}
91
+ }
92
+ `}).join("")}function Yw(e,t,r){return `
93
+ const secret = this.secret
94
+ ${r===!0?`
95
+ const keys = Object.keys(secret)
96
+ const len = keys.length
97
+ for (var i = len - 1; i >= ${t.length}; i--) {
98
+ const k = keys[i]
99
+ const o = secret[k]
100
+ if (o) {
101
+ if (o.flat === true) this.groupRestore(o)
102
+ else this.nestedRestore(o)
103
+ secret[k] = null
104
+ }
105
+ }
106
+ `:""}
107
+ ${e}
108
+ return o
109
+ `}});var Ru=B((_2,Tu)=>{d();Tu.exports=Xw;function Xw(e){let{secret:t,censor:r,compileRestore:n,serialize:i,groupRedact:s,nestedRedact:o,wildcards:a,wcLen:c}=e,h=[{secret:t,censor:r,compileRestore:n}];return i!==!1&&h.push({serialize:i}),c>0&&h.push({groupRedact:s,nestedRedact:o,wildcards:a,wcLen:c}),Object.assign(...h)}});var Lu=B((v2,Nu)=>{d();var Pu=bu(),Qw=Eu(),Zw=xu(),eb=Ou(),{groupRedact:tb,nestedRedact:rb}=Fs(),nb=Ru(),ib=Jn(),sb=Pu(),Bs=e=>e;Bs.restore=Bs;var ob="[REDACTED]";ks.rx=ib;ks.validator=Pu;Nu.exports=ks;function ks(e={}){let t=Array.from(new Set(e.paths||[])),r="serialize"in e&&(e.serialize===!1||typeof e.serialize=="function")?e.serialize:JSON.stringify,n=e.remove;if(n===!0&&r!==JSON.stringify)throw Error("fast-redact \u2013 remove option may only be set when serializer is JSON.stringify");let i=n===!0?void 0:"censor"in e?e.censor:ob,s=typeof i=="function",o=s&&i.length>1;if(t.length===0)return r||Bs;sb({paths:t,serialize:r,censor:i});let{wildcards:a,wcLen:c,secret:h}=Qw({paths:t,censor:i}),l=eb(),f="strict"in e?e.strict:!0;return Zw({secret:h,wcLen:c,serialize:r,strict:f,isCensorFct:s,censorFctTakesPath:o},nb({secret:h,censor:i,compileRestore:l,serialize:r,groupRedact:tb,nestedRedact:rb,wildcards:a,wcLen:c}))}});var nr=B((C2,Mu)=>{d();var ab=Symbol("pino.setLevel"),cb=Symbol("pino.getLevel"),lb=Symbol("pino.levelVal"),ub=Symbol("pino.useLevelLabels"),fb=Symbol("pino.useOnlyCustomLevels"),hb=Symbol("pino.mixin"),db=Symbol("pino.lsCache"),pb=Symbol("pino.chindings"),gb=Symbol("pino.parsedChindings"),mb=Symbol("pino.asJson"),yb=Symbol("pino.write"),wb=Symbol("pino.redactFmt"),bb=Symbol("pino.time"),Sb=Symbol("pino.timeSliceIndex"),_b=Symbol("pino.stream"),Eb=Symbol("pino.stringify"),vb=Symbol("pino.stringifySafe"),xb=Symbol("pino.stringifiers"),Cb=Symbol("pino.end"),Ib=Symbol("pino.formatOpts"),Db=Symbol("pino.messageKey"),Ab=Symbol("pino.nestedKey"),Ob=Symbol("pino.nestedKeyStr"),Tb=Symbol("pino.mixinMergeStrategy"),Rb=Symbol("pino.wildcardFirst"),Pb=Symbol.for("pino.serializers"),Nb=Symbol.for("pino.formatters"),Lb=Symbol.for("pino.hooks"),Mb=Symbol.for("pino.metadata");Mu.exports={setLevelSym:ab,getLevelSym:cb,levelValSym:lb,useLevelLabelsSym:ub,mixinSym:hb,lsCacheSym:db,chindingsSym:pb,parsedChindingsSym:gb,asJsonSym:mb,writeSym:yb,serializersSym:Pb,redactFmtSym:wb,timeSym:bb,timeSliceIndexSym:Sb,streamSym:_b,stringifySym:Eb,stringifySafeSym:vb,stringifiersSym:xb,endSym:Cb,formatOptsSym:Ib,messageKeySym:Db,nestedKeySym:Ab,wildcardFirstSym:Rb,needsMetadataGsym:Mb,useOnlyCustomLevelsSym:fb,formattersSym:Nb,hooksSym:Lb,nestedKeyStrSym:Ob,mixinMergeStrategySym:Tb};});var Ks=B((D2,Uu)=>{d();var Ws=Lu(),{redactFmtSym:Fb,wildcardFirstSym:Yn}=nr(),{rx:Us,validator:Bb}=Ws,Fu=Bb({ERR_PATHS_MUST_BE_STRINGS:()=>"pino \u2013 redacted paths must be strings",ERR_INVALID_PATH:e=>`pino \u2013 redact paths array contains an invalid path (${e})`}),Bu="[Redacted]",ku=!1;function kb(e,t){let{paths:r,censor:n}=Ub(e),i=r.reduce((a,c)=>{Us.lastIndex=0;let h=Us.exec(c),l=Us.exec(c),f=h[1]!==void 0?h[1].replace(/^(?:"|'|`)(.*)(?:"|'|`)$/,"$1"):h[0];if(f==="*"&&(f=Yn),l===null)return a[f]=null,a;if(a[f]===null)return a;let{index:m}=l,p=`${c.substr(m,c.length-1)}`;return a[f]=a[f]||[],f!==Yn&&a[f].length===0&&a[f].push(...a[Yn]||[]),f===Yn&&Object.keys(a).forEach(function(u){a[u]&&a[u].push(p);}),a[f].push(p),a},{}),s={[Fb]:Ws({paths:r,censor:n,serialize:t,strict:ku})},o=(...a)=>t(typeof n=="function"?n(...a):n);return [...Object.keys(i),...Object.getOwnPropertySymbols(i)].reduce((a,c)=>{if(i[c]===null)a[c]=h=>o(h,[c]);else {let h=typeof n=="function"?(l,f)=>n(l,[c,...f]):n;a[c]=Ws({paths:i[c],censor:h,serialize:t,strict:ku});}return a},s)}function Ub(e){if(Array.isArray(e))return e={paths:e,censor:Bu},Fu(e),e;let{paths:t,censor:r=Bu,remove:n}=e;if(Array.isArray(t)===!1)throw Error("pino \u2013 redact must contain an array of strings");return n===!0&&(r=void 0),Fu({paths:t,censor:r}),{paths:t,censor:r}}Uu.exports=kb;});var Ku=B((O2,Wu)=>{d();var Wb=()=>"",Kb=()=>`,"time":${Date.now()}`,jb=()=>`,"time":${Math.round(Date.now()/1e3)}`,zb=()=>`,"time":"${new Date(Date.now()).toISOString()}"`;Wu.exports={nullTime:Wb,epochTime:Kb,unixTime:jb,isoTime:zb};});var zu=B((R2,ju)=>{d();function $b(e){try{return JSON.stringify(e)}catch(t){return '"[Circular]"'}}ju.exports=qb;function qb(e,t,r){var n=r&&r.stringify||$b,i=1;if(typeof e=="object"&&e!==null){var s=t.length+i;if(s===1)return e;var o=new Array(s);o[0]=n(e);for(var a=1;a<s;a++)o[a]=n(t[a]);return o.join(" ")}if(typeof e!="string")return e;var c=t.length;if(c===0)return e;for(var h="",l=1-i,f=-1,m=e&&e.length||0,p=0;p<m;){if(e.charCodeAt(p)===37&&p+1<m){switch(f=f>-1?f:0,e.charCodeAt(p+1)){case 100:case 102:if(l>=c||t[l]==null)break;f<p&&(h+=e.slice(f,p)),h+=Number(t[l]),f=p+2,p++;break;case 105:if(l>=c||t[l]==null)break;f<p&&(h+=e.slice(f,p)),h+=Math.floor(Number(t[l])),f=p+2,p++;break;case 79:case 111:case 106:if(l>=c||t[l]===void 0)break;f<p&&(h+=e.slice(f,p));var u=typeof t[l];if(u==="string"){h+="'"+t[l]+"'",f=p+2,p++;break}if(u==="function"){h+=t[l].name||"<anonymous>",f=p+2,p++;break}h+=n(t[l]),f=p+2,p++;break;case 115:if(l>=c)break;f<p&&(h+=e.slice(f,p)),h+=String(t[l]),f=p+2,p++;break;case 37:f<p&&(h+=e.slice(f,p)),h+="%",f=p+2,p++,l--;break}++l;}++p;}return f===-1?e:(f<m&&(h+=e.slice(f)),h)}});var zs=B((N2,js)=>{d();if(typeof SharedArrayBuffer!="undefined"&&typeof Atomics!="undefined"){let t=function(r){if((r>0&&r<1/0)===!1)throw typeof r!="number"&&typeof r!="bigint"?TypeError("sleep: ms must be a number"):RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity");Atomics.wait(e,0,0,Number(r));},e=new Int32Array(new SharedArrayBuffer(4));js.exports=t;}else {let e=function(t){if((t>0&&t<1/0)===!1)throw typeof t!="number"&&typeof t!="bigint"?TypeError("sleep: ms must be a number"):RangeError("sleep: ms must be a number that is greater than 0 but less than Infinity");};js.exports=e;}});var Hu=B((M2,Vu)=>{d();var ke=z("fs"),Gb=z("events"),Vb=z("util").inherits,$u=z("path"),qu=zs(),$s=100,Hb=16*1024;function Gu(e,t){t._opening=!0,t._writing=!0,t._asyncDrainScheduled=!1;function r(s,o){if(s){t._reopening=!1,t._writing=!1,t._opening=!1,t.sync?process.nextTick(()=>{t.listenerCount("error")>0&&t.emit("error",s);}):t.emit("error",s);return}t.fd=o,t.file=e,t._reopening=!1,t._opening=!1,t._writing=!1,t.sync?process.nextTick(()=>t.emit("ready")):t.emit("ready"),!t._reopening&&!t._writing&&t._len>t.minLength&&!t.destroyed&&ir(t);}let n=t.append?"a":"w",i=t.mode;if(t.sync)try{t.mkdir&&ke.mkdirSync($u.dirname(e),{recursive:!0});let s=ke.openSync(e,n,i);r(null,s);}catch(s){throw r(s),s}else t.mkdir?ke.mkdir($u.dirname(e),{recursive:!0},s=>{if(s)return r(s);ke.open(e,n,i,r);}):ke.open(e,n,i,r);}function Me(e){if(!(this instanceof Me))return new Me(e);let{fd:t,dest:r,minLength:n,maxLength:i,maxWrite:s,sync:o,append:a=!0,mode:c,mkdir:h,retryEAGAIN:l}=e||{};if(t=t||r,this._bufs=[],this._len=0,this.fd=-1,this._writing=!1,this._writingBuf="",this._ending=!1,this._reopening=!1,this._asyncDrainScheduled=!1,this._hwm=Math.max(n||0,16387),this.file=null,this.destroyed=!1,this.minLength=n||0,this.maxLength=i||0,this.maxWrite=s||Hb,this.sync=o||!1,this.append=a||!1,this.mode=c,this.retryEAGAIN=l||(()=>!0),this.mkdir=h||!1,typeof t=="number")this.fd=t,process.nextTick(()=>this.emit("ready"));else if(typeof t=="string")Gu(t,this);else throw new Error("SonicBoom supports only file descriptors and files");if(this.minLength>=this.maxWrite)throw new Error(`minLength should be smaller than maxWrite (${this.maxWrite})`);this.release=(f,m)=>{if(f){if(f.code==="EAGAIN"&&this.retryEAGAIN(f,this._writingBuf.length,this._len-this._writingBuf.length))if(this.sync)try{qu($s),this.release(void 0,0);}catch(u){this.release(u);}else setTimeout(()=>{ke.write(this.fd,this._writingBuf,"utf8",this.release);},$s);else this._writing=!1,this.emit("error",f);return}if(this.emit("write",m),this._len-=m,this._writingBuf=this._writingBuf.slice(m),this._writingBuf.length){if(!this.sync){ke.write(this.fd,this._writingBuf,"utf8",this.release);return}try{do{let u=ke.writeSync(this.fd,this._writingBuf,"utf8");this._len-=u,this._writingBuf=this._writingBuf.slice(u);}while(this._writingBuf)}catch(u){this.release(u);return}}let p=this._len;this._reopening?(this._writing=!1,this._reopening=!1,this.reopen()):p>this.minLength?ir(this):this._ending?p>0?ir(this):(this._writing=!1,Xn(this)):(this._writing=!1,this.sync?this._asyncDrainScheduled||(this._asyncDrainScheduled=!0,process.nextTick(Jb,this)):this.emit("drain"));},this.on("newListener",function(f){f==="drain"&&(this._asyncDrainScheduled=!1);});}function Jb(e){e.listenerCount("drain")>0&&(e._asyncDrainScheduled=!1,e.emit("drain"));}Vb(Me,Gb);Me.prototype.write=function(e){if(this.destroyed)throw new Error("SonicBoom destroyed");let t=this._len+e.length,r=this._bufs;return this.maxLength&&t>this.maxLength?(this.emit("drop",e),this._len<this._hwm):(r.length===0||r[r.length-1].length+e.length>this.maxWrite?r.push(""+e):r[r.length-1]+=e,this._len=t,!this._writing&&this._len>=this.minLength&&ir(this),this._len<this._hwm)};Me.prototype.flush=function(){if(this.destroyed)throw new Error("SonicBoom destroyed");this._writing||this.minLength<=0||(this._bufs.length===0&&this._bufs.push(""),ir(this));};Me.prototype.reopen=function(e){if(this.destroyed)throw new Error("SonicBoom destroyed");if(this._opening){this.once("ready",()=>{this.reopen(e);});return}if(this._ending)return;if(!this.file)throw new Error("Unable to reopen a file descriptor, you must pass a file to SonicBoom");if(this._reopening=!0,this._writing)return;let t=this.fd;this.once("ready",()=>{t!==this.fd&&ke.close(t,r=>{if(r)return this.emit("error",r)});}),Gu(e||this.file,this);};Me.prototype.end=function(){if(this.destroyed)throw new Error("SonicBoom destroyed");if(this._opening){this.once("ready",()=>{this.end();});return}this._ending||(this._ending=!0,!this._writing&&(this._len>0&&this.fd>=0?ir(this):Xn(this)));};Me.prototype.flushSync=function(){if(this.destroyed)throw new Error("SonicBoom destroyed");if(this.fd<0)throw new Error("sonic boom is not ready yet");for(!this._writing&&this._writingBuf.length>0&&(this._bufs.unshift(this._writingBuf),this._writingBuf="");this._bufs.length;){let e=this._bufs[0];try{this._len-=ke.writeSync(this.fd,e,"utf8"),this._bufs.shift();}catch(t){if(t.code!=="EAGAIN"||!this.retryEAGAIN(t,e.length,this._len-e.length))throw t;qu($s);}}};Me.prototype.destroy=function(){this.destroyed||Xn(this);};function ir(e){let t=e.release;if(e._writing=!0,e._writingBuf=e._writingBuf||e._bufs.shift()||"",e.sync)try{let r=ke.writeSync(e.fd,e._writingBuf,"utf8");t(null,r);}catch(r){t(r);}else ke.write(e.fd,e._writingBuf,"utf8",t);}function Xn(e){if(e.fd===-1){e.once("ready",Xn.bind(null,e));return}e.destroyed=!0,e._bufs=[],e.fd!==1&&e.fd!==2?ke.close(e.fd,t):setImmediate(t);function t(r){if(r){e.emit("error",r);return}e._ending&&!e._writing&&e.emit("finish"),e.emit("close");}}Me.SonicBoom=Me;Me.default=Me;Vu.exports=Me;});var Yu=B((B2,Ju)=>{d();var{format:qs}=z("util");function Yb(){let e={},t=new Map;function r(i,s,o){if(!i)throw new Error("Warning name must not be empty");if(!s)throw new Error("Warning code must not be empty");if(!o)throw new Error("Warning message must not be empty");if(s=s.toUpperCase(),e[s]!==void 0)throw new Error(`The code '${s}' already exist`);function a(c,h,l){let f;return c&&h&&l?f=qs(o,c,h,l):c&&h?f=qs(o,c,h):c?f=qs(o,c):f=o,{code:s,name:i,message:f}}return t.set(s,!1),e[s]=a,e[s]}function n(i,s,o,a){if(e[i]===void 0)throw new Error(`The code '${i}' does not exist`);if(t.get(i)===!0)return;t.set(i,!0);let c=e[i](s,o,a);process.emitWarning(c.message,c.name,c.code);}return {create:r,emit:n,emitted:t}}Ju.exports=Yb;});var Zu=B((U2,Qu)=>{d();var Gs=Yu()();Qu.exports=Gs;var Xu="PinoWarning";Gs.create(Xu,"PINODEP008","prettyPrint is deprecated, look at https://github.com/pinojs/pino-pretty for alternatives.");Gs.create(Xu,"PINODEP009","The use of pino.final is discouraged in Node.js v14+ and not required. It will be removed in the next major version");});var Hs=B((K2,nf)=>{d();function ef(e,t,r,n){function i(){let s=t.deref();s!==void 0&&r(s,n);}e[n]=i,process.once(n,i);}var tf=new FinalizationRegistry(rf),Vs=new WeakMap;function rf(e){process.removeListener("exit",e.exit),process.removeListener("beforeExit",e.beforeExit);}function Xb(e,t){if(e===void 0)throw new Error("the object can't be undefined");let r=new WeakRef(e),n={};Vs.set(e,n),tf.register(e,n),ef(n,r,t,"exit"),ef(n,r,t,"beforeExit");}function Qb(e){let t=Vs.get(e);Vs.delete(e),t&&rf(t),tf.unregister(e);}nf.exports={register:Xb,unregister:Qb};});var of=B((z2,sf)=>{d();function Zb(e,t,r,n,i){let s=Date.now()+n,o=Atomics.load(e,t);if(o===r){i(null,"ok");return}let a=o,c=h=>{Date.now()>s?i(null,"timed-out"):setTimeout(()=>{a=o,o=Atomics.load(e,t),o===a?c(h>=1e3?1e3:h*2):o===r?i(null,"ok"):i(null,"not-equal");},h);};c(1);}function eS(e,t,r,n,i){let s=Date.now()+n,o=Atomics.load(e,t);if(o!==r){i(null,"ok");return}let a=c=>{Date.now()>s?i(null,"timed-out"):setTimeout(()=>{o=Atomics.load(e,t),o!==r?i(null,"ok"):a(c>=1e3?1e3:c*2);},c);};a(1);}sf.exports={wait:Zb,waitDiff:eS};});var cf=B((q2,af)=>{d();af.exports={WRITE_INDEX:4,READ_INDEX:8};});var df=B((H2,hf)=>{d();var{EventEmitter:tS}=z("events"),{Worker:rS}=z("worker_threads"),{join:nS}=z("path"),{pathToFileURL:iS}=z("url"),{wait:sS}=of(),{WRITE_INDEX:Fe,READ_INDEX:et}=cf(),oS=z("buffer"),aS=z("assert"),R=Symbol("kImpl"),cS=oS.constants.MAX_STRING_LENGTH,Zn=class{constructor(t){this._value=t;}deref(){return this._value}},lS=global.FinalizationRegistry||class{register(){}unregister(){}},uS=global.WeakRef||Zn,lf=new lS(e=>{e.exited||e.terminate();});function fS(e,t){let{filename:r,workerData:n}=t,s=("__bundlerPathsOverrides"in globalThis?globalThis.__bundlerPathsOverrides:{})["thread-stream-worker"]||nS(__dirname,"lib","worker.js"),o=new rS(s,X(M({},t.workerOpts),{workerData:{filename:r.indexOf("file://")===0?r:iS(r).href,dataBuf:e[R].dataBuf,stateBuf:e[R].stateBuf,workerData:n}}));return o.stream=new Zn(e),o.on("message",hS),o.on("exit",ff),lf.register(e,o),o}function uf(e){aS(!e[R].sync),e[R].needDrain&&(e[R].needDrain=!1,e.emit("drain"));}function Qn(e){let t=Atomics.load(e[R].state,Fe),r=e[R].data.length-t;if(r>0){if(e[R].buf.length===0){e[R].flushing=!1,e[R].ending?Qs(e):e[R].needDrain&&process.nextTick(uf,e);return}let n=e[R].buf.slice(0,r),i=Buffer.byteLength(n);i<=r?(e[R].buf=e[R].buf.slice(r),ei(e,n,Qn.bind(null,e))):e.flush(()=>{if(!e.destroyed){for(Atomics.store(e[R].state,et,0),Atomics.store(e[R].state,Fe,0);i>e[R].data.length;)r=r/2,n=e[R].buf.slice(0,r),i=Buffer.byteLength(n);e[R].buf=e[R].buf.slice(r),ei(e,n,Qn.bind(null,e));}});}else if(r===0){if(t===0&&e[R].buf.length===0)return;e.flush(()=>{Atomics.store(e[R].state,et,0),Atomics.store(e[R].state,Fe,0),Qn(e);});}else throw new Error("overwritten")}function hS(e){let t=this.stream.deref();if(t===void 0){this.exited=!0,this.terminate();return}switch(e.code){case"READY":this.stream=new uS(t),t.flush(()=>{t[R].ready=!0,t.emit("ready");});break;case"ERROR":sr(t,e.err);break;default:throw new Error("this should not happen: "+e.code)}}function ff(e){let t=this.stream.deref();t!==void 0&&(lf.unregister(t),t.worker.exited=!0,t.worker.off("exit",ff),sr(t,e!==0?new Error("The worker thread exited"):null));}var Ys=class extends tS{constructor(t={}){if(super(),t.bufferSize<4)throw new Error("bufferSize must at least fit a 4-byte utf-8 char");this[R]={},this[R].stateBuf=new SharedArrayBuffer(128),this[R].state=new Int32Array(this[R].stateBuf),this[R].dataBuf=new SharedArrayBuffer(t.bufferSize||4*1024*1024),this[R].data=Buffer.from(this[R].dataBuf),this[R].sync=t.sync||!1,this[R].ending=!1,this[R].ended=!1,this[R].needDrain=!1,this[R].destroyed=!1,this[R].flushing=!1,this[R].ready=!1,this[R].finished=!1,this[R].errored=null,this[R].closed=!1,this[R].buf="",this.worker=fS(this,t);}write(t){if(this[R].destroyed)throw new Error("the worker has exited");if(this[R].ending)throw new Error("the worker is ending");if(this[R].flushing&&this[R].buf.length+t.length>=cS)try{Js(this),this[R].flushing=!0;}catch(r){return sr(this,r),!1}if(this[R].buf+=t,this[R].sync)try{return Js(this),!0}catch(r){return sr(this,r),!1}return this[R].flushing||(this[R].flushing=!0,setImmediate(Qn,this)),this[R].needDrain=this[R].data.length-this[R].buf.length-Atomics.load(this[R].state,Fe)<=0,!this[R].needDrain}end(){this[R].destroyed||(this[R].ending=!0,Qs(this));}flush(t){if(this[R].destroyed){typeof t=="function"&&process.nextTick(t,new Error("the worker has exited"));return}let r=Atomics.load(this[R].state,Fe);sS(this[R].state,et,r,1/0,(n,i)=>{if(n){sr(this,n),process.nextTick(t,n);return}if(i==="not-equal"){this.flush(t);return}process.nextTick(t);});}flushSync(){this[R].destroyed||(Js(this),Xs(this));}unref(){this.worker.unref();}ref(){this.worker.ref();}get ready(){return this[R].ready}get destroyed(){return this[R].destroyed}get closed(){return this[R].closed}get writable(){return !this[R].destroyed&&!this[R].ending}get writableEnded(){return this[R].ending}get writableFinished(){return this[R].finished}get writableNeedDrain(){return this[R].needDrain}get writableObjectMode(){return !1}get writableErrored(){return this[R].errored}};function sr(e,t){e[R].destroyed||(e[R].destroyed=!0,t&&(e[R].errored=t,e.emit("error",t)),e.worker.exited?setImmediate(()=>{e[R].closed=!0,e.emit("close");}):e.worker.terminate().catch(()=>{}).then(()=>{e[R].closed=!0,e.emit("close");}));}function ei(e,t,r){let n=Atomics.load(e[R].state,Fe),i=Buffer.byteLength(t);return e[R].data.write(t,n),Atomics.store(e[R].state,Fe,n+i),Atomics.notify(e[R].state,Fe),r(),!0}function Qs(e){if(!(e[R].ended||!e[R].ending||e[R].flushing)){e[R].ended=!0;try{e.flushSync();let t=Atomics.load(e[R].state,et);Atomics.store(e[R].state,Fe,-1),Atomics.notify(e[R].state,Fe);let r=0;for(;t!==-1;){if(Atomics.wait(e[R].state,et,t,1e3),t=Atomics.load(e[R].state,et),t===-2)throw new Error("end() failed");if(++r===10)throw new Error("end() took too long (10s)")}process.nextTick(()=>{e[R].finished=!0,e.emit("finish");});}catch(t){sr(e,t);}}}function Js(e){let t=()=>{e[R].ending?Qs(e):e[R].needDrain&&process.nextTick(uf,e);};for(e[R].flushing=!1;e[R].buf.length!==0;){let r=Atomics.load(e[R].state,Fe),n=e[R].data.length-r;if(n===0){Xs(e),Atomics.store(e[R].state,et,0),Atomics.store(e[R].state,Fe,0);continue}else if(n<0)throw new Error("overwritten");let i=e[R].buf.slice(0,n),s=Buffer.byteLength(i);if(s<=n)e[R].buf=e[R].buf.slice(n),ei(e,i,t);else {for(Xs(e),Atomics.store(e[R].state,et,0),Atomics.store(e[R].state,Fe,0);s>e[R].buf.length;)n=n/2,i=e[R].buf.slice(0,n),s=Buffer.byteLength(i);e[R].buf=e[R].buf.slice(n),ei(e,i,t);}}}function Xs(e){if(e[R].flushing)throw new Error("unable to flush while flushing");let t=Atomics.load(e[R].state,Fe),r=0;for(;;){let n=Atomics.load(e[R].state,et);if(n===-2)throw new Error("_flushSync failed");if(n!==t)Atomics.wait(e[R].state,et,n,1e3);else break;if(++r===10)throw new Error("_flushSync took too long (10s)")}}hf.exports=Ys;});var eo=B((X2,gf)=>{d();var{createRequire:dS}=z("module"),pS=Ls(),{join:Zs,isAbsolute:gS}=z("path"),mS=zs(),ti;global.WeakRef&&global.WeakMap&&global.FinalizationRegistry&&(ti=Hs());var yS=df();function wS(e){if(ti)ti.register(e,pf),e.on("close",function(){ti.unregister(e);});else {let t=pf.bind(null,e);process.once("beforeExit",t),process.once("exit",t),e.on("close",function(){process.removeListener("beforeExit",t),process.removeListener("exit",t);});}}function bS(e,t,r){let n=new yS({filename:e,workerData:t,workerOpts:r});n.on("ready",i),n.on("close",function(){process.removeListener("exit",s);}),process.on("exit",s);function i(){process.removeListener("exit",s),n.unref(),r.autoEnd!==!1&&wS(n);}function s(){n.closed||(n.flushSync(),mS(100),n.end());}return n}function pf(e){e.ref(),e.flushSync(),e.end(),e.once("close",function(){e.unref();});}function SS(e){let{pipeline:t,targets:r,levels:n,options:i={},worker:s={},caller:o=pS()}=e,a=typeof o=="string"?[o]:o,c="__bundlerPathsOverrides"in globalThis?globalThis.__bundlerPathsOverrides:{},h=e.target;if(h&&r)throw new Error("only one of target or targets can be specified");return r?(h=c["pino-worker"]||Zs(__dirname,"worker.js"),i.targets=r.map(f=>X(M({},f),{target:l(f.target)}))):t&&(h=c["pino-pipeline-worker"]||Zs(__dirname,"worker-pipeline.js"),i.targets=t.map(f=>X(M({},f),{target:l(f.target)}))),n&&(i.levels=n),bS(l(h),i,s);function l(f){if(f=c[f]||f,gS(f)||f.indexOf("file://")===0)return f;if(f==="pino/file")return Zs(__dirname,"..","file.js");let m;for(let p of a)try{m=dS(p).resolve(f);break}catch(u){continue}if(!m)throw new Error(`unable to determine transport target for "${f}"`);return m}}gf.exports=SS;});var ni=B((eR,Df)=>{d();var mf=zu(),{mapHttpRequest:_S,mapHttpResponse:ES}=Ns(),no=Hu(),_f=Zu(),{lsCacheSym:vS,chindingsSym:io,parsedChindingsSym:to,writeSym:yf,serializersSym:so,formatOptsSym:wf,endSym:xS,stringifiersSym:oo,stringifySym:Ef,stringifySafeSym:ao,wildcardFirstSym:vf,needsMetadataGsym:xf,redactFmtSym:CS,streamSym:IS,nestedKeySym:DS,formattersSym:co,messageKeySym:Cf,nestedKeyStrSym:AS}=nr(),{isMainThread:OS}=z("worker_threads"),TS=eo();function Fr(){}function RS(e,t){if(!t)return r;return function(...i){t.call(this,i,r,e);};function r(n,...i){if(typeof n=="object"){let s=n;n!==null&&(n.method&&n.headers&&n.socket?n=_S(n):typeof n.setHeader=="function"&&(n=ES(n)));let o;s===null&&i.length===0?o=[null]:(s=i.shift(),o=i),this[yf](n,mf(s,o,this[wf]),e);}else this[yf](null,mf(n,i,this[wf]),e);}}function bf(e){let t="",r=0,n=!1,i=255,s=e.length;if(s>100)return JSON.stringify(e);for(var o=0;o<s&&i>=32;o++)i=e.charCodeAt(o),(i===34||i===92)&&(t+=e.slice(r,o)+"\\",r=o,n=!0);return n?t+=e.slice(r):t=e,i<32?JSON.stringify(e):'"'+t+'"'}function PS(e,t,r,n){let i=this[Ef],s=this[ao],o=this[oo],a=this[xS],c=this[io],h=this[so],l=this[co],f=this[Cf],m=this[vS][r]+n;m=m+c;let p;l.log&&(e=l.log(e));let u=o[vf],y="";for(let S in e)if(p=e[S],Object.prototype.hasOwnProperty.call(e,S)&&p!==void 0){p=h[S]?h[S](p):p;let b=o[S]||u;switch(typeof p){case"undefined":case"function":continue;case"number":Number.isFinite(p)===!1&&(p=null);case"boolean":b&&(p=b(p));break;case"string":p=(b||bf)(p);break;default:p=(b||i)(p,s);}if(p===void 0)continue;y+=',"'+S+'":'+p;}let w="";if(t!==void 0){p=h[f]?h[f](t):t;let S=o[f]||u;switch(typeof p){case"function":break;case"number":Number.isFinite(p)===!1&&(p=null);case"boolean":S&&(p=S(p)),w=',"'+f+'":'+p;break;case"string":p=(S||bf)(p),w=',"'+f+'":'+p;break;default:p=(S||i)(p,s),w=',"'+f+'":'+p;}}return this[DS]&&y?m+this[AS]+y.slice(1)+"}"+w+a:m+y+w+a}function NS(e,t){let r,n=e[io],i=e[Ef],s=e[ao],o=e[oo],a=o[vf],c=e[so],h=e[co].bindings;t=h(t);for(let l in t)if(r=t[l],(l!=="level"&&l!=="serializers"&&l!=="formatters"&&l!=="customLevels"&&t.hasOwnProperty(l)&&r!==void 0)===!0){if(r=c[l]?c[l](r):r,r=(o[l]||a||i)(r,s),r===void 0)continue;n+=',"'+l+'":'+r;}return n}function If(e,t,r,n){if(t&&typeof t=="function")return t=t.bind(n),ro(t(e),r,e);try{let i=z("pino-pretty").prettyFactory;return i.asMetaWrapper=ro,ro(i(e),r,e)}catch(i){throw i.message.startsWith("Cannot find module 'pino-pretty'")?Error("Missing `pino-pretty` module: `pino-pretty` must be installed separately"):i}}function ro(e,t,r){r=Object.assign({suppressFlushSyncWarning:!1},r);let n=!1;return {[xf]:!0,lastLevel:0,lastMsg:null,lastObj:null,lastLogger:null,flushSync(){r.suppressFlushSyncWarning||n||(n=!0,Sf(t,this),t.write(e(Object.assign({level:40,msg:"pino.final with prettyPrint does not support flushing",time:Date.now()},this.chindings()))));},chindings(){let i=this.lastLogger,s=null;return i?(i.hasOwnProperty(to)?s=i[to]:(s=JSON.parse("{"+i[io].substr(1)+"}"),i[to]=s),s):null},write(i){let s=this.lastLogger,o=this.chindings(),a=this.lastTime;typeof a=="number"||(a.match(/^\d+/)?a=parseInt(a):a=a.slice(1,-1));let c=this.lastObj,h=this.lastMsg,l=null,f=s[co],m=f.log?f.log(c):c,p=s[Cf];h&&m&&!Object.prototype.hasOwnProperty.call(m,p)&&(m[p]=h);let u=Object.assign({level:this.lastLevel,time:a},m,l),y=s[so],w=Object.keys(y);for(var S=0;S<w.length;S++){let O=w[S];u[O]!==void 0&&(u[O]=y[O](u[O]));}for(let O in o)u.hasOwnProperty(O)||(u[O]=o[O]);let _=s[oo][CS],x=e(typeof _=="function"?_(u):u);x!==void 0&&(Sf(t,this),t.write(x));}}}function LS(e){return e.write!==e.constructor.prototype.write}function ri(e){let t=new no(e);return t.on("error",r),!e.sync&&OS&&MS(t),t;function r(n){if(n.code==="EPIPE"){t.write=Fr,t.end=Fr,t.flushSync=Fr,t.destroy=Fr;return}t.removeListener("error",r),t.emit("error",n);}}function MS(e){if(global.WeakRef&&global.WeakMap&&global.FinalizationRegistry){let t=Hs();t.register(e,FS),e.on("close",function(){t.unregister(e);});}}function FS(e,t){e.destroyed||(t==="beforeExit"?(e.flush(),e.on("drain",function(){e.end();})):e.flushSync());}function BS(e){return function(r,n,i={},s){if(typeof i=="string")s=ri({dest:i,sync:!0}),i={};else if(typeof s=="string"){if(i&&i.transport)throw Error("only one of option.transport or stream can be specified");s=ri({dest:s,sync:!0});}else if(i instanceof no||i.writable||i._writableState)s=i,i={};else if(i.transport){if(i.transport instanceof no||i.transport.writable||i.transport._writableState)throw Error("option.transport do not allow stream, please pass to option directly. e.g. pino(transport)");if(i.transport.targets&&i.transport.targets.length&&i.formatters&&typeof i.formatters.level=="function")throw Error("option.transport.targets do not allow custom level formatters");let l;i.customLevels&&(l=i.useOnlyCustomLevels?i.customLevels:Object.assign({},i.levels,i.customLevels)),s=TS(X(M({caller:n},i.transport),{levels:l}));}if(i=Object.assign({},e,i),i.serializers=Object.assign({},e.serializers,i.serializers),i.formatters=Object.assign({},e.formatters,i.formatters),"onTerminated"in i)throw Error("The onTerminated option has been removed, use pino.final instead");"changeLevelName"in i&&(process.emitWarning("The changeLevelName option is deprecated and will be removed in v7. Use levelKey instead.",{code:"changeLevelName_deprecation"}),i.levelKey=i.changeLevelName,delete i.changeLevelName);let{enabled:o,prettyPrint:a,prettifier:c,messageKey:h}=i;if(o===!1&&(i.level="silent"),s=s||process.stdout,s===process.stdout&&s.fd>=0&&!LS(s)&&(s=ri({fd:s.fd,sync:!0})),a){_f.emit("PINODEP008");let l=Object.assign({messageKey:h},a);s=If(l,c,s,r);}return {opts:i,stream:s}}}function kS(e,t){if(Number(process.versions.node.split(".")[0])>=14&&_f.emit("PINODEP009"),typeof e=="undefined"||typeof e.child!="function")throw Error("expected a pino logger instance");let n=typeof t!="undefined";if(n&&typeof t!="function")throw Error("if supplied, the handler parameter should be a function");let i=e[IS];if(typeof i.flushSync!="function")throw Error("final requires a stream that has a flushSync method, such as pino.destination");let s=new Proxy(e,{get:(o,a)=>a in o.levels.values?(...c)=>{o[a](...c),i.flushSync();}:o[a]});if(!n){try{i.flushSync();}catch(o){}return s}return (o=null,...a)=>{try{i.flushSync();}catch(c){}return t(o,s,...a)}}function US(e,t){try{return JSON.stringify(e)}catch(r){try{return (t||this[ao])(e)}catch(n){return '"[unable to serialize, circular reference is too complex to analyze]"'}}}function WS(e,t,r){return {level:e,bindings:t,log:r}}function Sf(e,t){e[xf]===!0&&(e.lastLevel=t.lastLevel,e.lastMsg=t.lastMsg,e.lastObj=t.lastObj,e.lastTime=t.lastTime,e.lastLogger=t.lastLogger);}function KS(e){let t=Number(e);return typeof e=="string"&&Number.isFinite(t)?t:e}Df.exports={noop:Fr,buildSafeSonicBoom:ri,getPrettyStream:If,asChindings:NS,asJson:PS,genLog:RS,createArgsNormalizer:BS,final:kS,stringify:US,buildFormatters:WS,normalizeDestFileDescriptor:KS};});var ii=B((nR,Of)=>{d();var{lsCacheSym:jS,levelValSym:lo,useOnlyCustomLevelsSym:zS,streamSym:$S,formattersSym:qS,hooksSym:GS}=nr(),{noop:VS,genLog:Nt}=ni(),Ye={trace:10,debug:20,info:30,warn:40,error:50,fatal:60},Af={fatal:e=>{let t=Nt(Ye.fatal,e);return function(...r){let n=this[$S];if(t.call(this,...r),typeof n.flushSync=="function")try{n.flushSync();}catch(i){}}},error:e=>Nt(Ye.error,e),warn:e=>Nt(Ye.warn,e),info:e=>Nt(Ye.info,e),debug:e=>Nt(Ye.debug,e),trace:e=>Nt(Ye.trace,e)},uo=Object.keys(Ye).reduce((e,t)=>(e[Ye[t]]=t,e),{}),HS=Object.keys(uo).reduce((e,t)=>(e[t]='{"level":'+Number(t),e),{});function JS(e){let t=e[qS].level,{labels:r}=e.levels,n={};for(let i in r){let s=t(r[i],Number(i));n[i]=JSON.stringify(s).slice(0,-1);}return e[jS]=n,e}function YS(e,t){if(t)return !1;switch(e){case"fatal":case"error":case"warn":case"info":case"debug":case"trace":return !0;default:return !1}}function XS(e){let{labels:t,values:r}=this.levels;if(typeof e=="number"){if(t[e]===void 0)throw Error("unknown level value"+e);e=t[e];}if(r[e]===void 0)throw Error("unknown level "+e);let n=this[lo],i=this[lo]=r[e],s=this[zS],o=this[GS].logMethod;for(let a in r){if(i>r[a]){this[a]=VS;continue}this[a]=YS(a,s)?Af[a](o):Nt(r[a],o);}this.emit("level-change",e,i,t[n],n);}function QS(e){let{levels:t,levelVal:r}=this;return t&&t.labels?t.labels[r]:""}function ZS(e){let{values:t}=this.levels,r=t[e];return r!==void 0&&r>=this[lo]}function e0(e=null,t=!1){let r=e?Object.keys(e).reduce((s,o)=>(s[e[o]]=o,s),{}):null,n=Object.assign(Object.create(Object.prototype,{Infinity:{value:"silent"}}),t?null:uo,r),i=Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),t?null:Ye,e);return {labels:n,values:i}}function t0(e,t,r){if(typeof e=="number"){if(![].concat(Object.keys(t||{}).map(s=>t[s]),r?[]:Object.keys(uo).map(s=>+s),1/0).includes(e))throw Error(`default level:${e} must be included in custom levels`);return}let n=Object.assign(Object.create(Object.prototype,{silent:{value:1/0}}),r?null:Ye,t);if(!(e in n))throw Error(`default level:${e} must be included in custom levels`)}function r0(e,t){let{labels:r,values:n}=e;for(let i in t){if(i in n)throw Error("levels cannot be overridden");if(t[i]in r)throw Error("pre-existing level values cannot be used for new levels")}}Of.exports={initialLsCache:HS,genLsCache:JS,levelMethods:Af,getLevel:QS,setLevel:XS,isLevelEnabled:ZS,mappings:e0,levels:Ye,assertNoLevelCollisions:r0,assertDefaultLevelFound:t0};});var Tf=B((sR,n0)=>{n0.exports={name:"pino",version:"7.11.0",description:"super fast, all natural json logger",main:"pino.js",type:"commonjs",types:"pino.d.ts",browser:"./browser.js",files:["pino.js","file.js","pino.d.ts","bin.js","browser.js","pretty.js","usage.txt","test","docs","example.js","lib"],scripts:{docs:"docsify serve","browser-test":"airtap --local 8080 test/browser*test.js",lint:"eslint .",test:"npm run lint && npm run transpile && tap --ts && jest test/jest && npm run test-types","test-ci":"npm run lint && npm run transpile && tap --ts --no-check-coverage --coverage-report=lcovonly && npm run test-types","test-ci-pnpm":"pnpm run lint && npm run transpile && tap --ts --no-coverage --no-check-coverage && pnpm run test-types","test-ci-yarn-pnp":"yarn run lint && npm run transpile && tap --ts --no-check-coverage --coverage-report=lcovonly","test-types":"tsc && tsd && ts-node test/types/pino.ts",transpile:"node ./test/fixtures/ts/transpile.cjs","cov-ui":"tap --ts --coverage-report=html",bench:"node benchmarks/utils/runbench all","bench-basic":"node benchmarks/utils/runbench basic","bench-object":"node benchmarks/utils/runbench object","bench-deep-object":"node benchmarks/utils/runbench deep-object","bench-multi-arg":"node benchmarks/utils/runbench multi-arg","bench-longs-tring":"node benchmarks/utils/runbench long-string","bench-child":"node benchmarks/utils/runbench child","bench-child-child":"node benchmarks/utils/runbench child-child","bench-child-creation":"node benchmarks/utils/runbench child-creation","bench-formatters":"node benchmarks/utils/runbench formatters","update-bench-doc":"node benchmarks/utils/generate-benchmark-doc > docs/benchmarks.md"},bin:{pino:"./bin.js"},precommit:"test",repository:{type:"git",url:"git+https://github.com/pinojs/pino.git"},keywords:["fast","logger","stream","json"],author:"Matteo Collina <hello@matteocollina.com>",contributors:["David Mark Clements <huperekchuno@googlemail.com>","James Sumners <james.sumners@gmail.com>","Thomas Watson Steen <w@tson.dk> (https://twitter.com/wa7son)"],license:"MIT",bugs:{url:"https://github.com/pinojs/pino/issues"},homepage:"http://getpino.io",devDependencies:{"@types/flush-write-stream":"^1.0.0","@types/node":"^17.0.0","@types/tap":"^15.0.6",airtap:"4.0.4",benchmark:"^2.1.4",bole:"^4.0.0",bunyan:"^1.8.14","docsify-cli":"^4.4.1",eslint:"^7.17.0","eslint-config-standard":"^16.0.3","eslint-plugin-import":"^2.22.1","eslint-plugin-node":"^11.1.0","eslint-plugin-promise":"^5.1.0",execa:"^5.0.0",fastbench:"^1.0.1","flush-write-stream":"^2.0.0","import-fresh":"^3.2.1",jest:"^27.3.1",log:"^6.0.0",loglevel:"^1.6.7","pino-pretty":"^v7.6.0","pre-commit":"^1.2.2",proxyquire:"^2.1.3",pump:"^3.0.0",rimraf:"^3.0.2",semver:"^7.0.0",split2:"^4.0.0",steed:"^1.1.3","strip-ansi":"^6.0.0",tap:"^16.0.0",tape:"^5.0.0",through2:"^4.0.0","ts-node":"^10.7.0",tsd:"^0.20.0",typescript:"^4.4.4",winston:"^3.3.3"},dependencies:{"atomic-sleep":"^1.0.0","fast-redact":"^3.0.0","on-exit-leak-free":"^0.2.0","pino-abstract-transport":"v0.5.0","pino-std-serializers":"^4.0.0","process-warning":"^1.0.0","quick-format-unescaped":"^4.0.3","real-require":"^0.1.0","safe-stable-stringify":"^2.1.0","sonic-boom":"^2.2.1","thread-stream":"^0.15.1"},tsd:{directory:"test/types"}};});var fo=B((oR,Rf)=>{d();var{version:i0}=Tf();Rf.exports={version:i0};});var Kf=B((lR,Wf)=>{d();var{EventEmitter:s0}=z("events"),{lsCacheSym:o0,levelValSym:a0,setLevelSym:po,getLevelSym:Pf,chindingsSym:go,parsedChindingsSym:c0,mixinSym:l0,asJsonSym:Ff,writeSym:u0,mixinMergeStrategySym:f0,timeSym:h0,timeSliceIndexSym:d0,streamSym:Bf,serializersSym:Lt,formattersSym:ho,useOnlyCustomLevelsSym:p0,needsMetadataGsym:g0,redactFmtSym:m0,stringifySym:y0,formatOptsSym:w0,stringifiersSym:b0}=nr(),{getLevel:S0,setLevel:_0,isLevelEnabled:E0,mappings:v0,initialLsCache:x0,genLsCache:C0,assertNoLevelCollisions:I0}=ii(),{asChindings:kf,asJson:D0,buildFormatters:Nf,stringify:Lf}=ni(),{version:A0}=fo(),O0=Ks(),T0=class{},Uf={constructor:T0,child:R0,bindings:P0,setBindings:N0,flush:B0,isLevelEnabled:E0,version:A0,get level(){return this[Pf]()},set level(e){this[po](e);},get levelVal(){return this[a0]},set levelVal(e){throw Error("levelVal is read-only")},[o0]:x0,[u0]:M0,[Ff]:D0,[Pf]:S0,[po]:_0};Object.setPrototypeOf(Uf,s0.prototype);Wf.exports=function(){return Object.create(Uf)};var Mf=e=>e;function R0(e,t){if(!e)throw Error("missing bindings for child Pino");t=t||{};let r=this[Lt],n=this[ho],i=Object.create(this);if(t.hasOwnProperty("serializers")===!0){i[Lt]=Object.create(null);for(let l in r)i[Lt][l]=r[l];let c=Object.getOwnPropertySymbols(r);for(var s=0;s<c.length;s++){let l=c[s];i[Lt][l]=r[l];}for(let l in t.serializers)i[Lt][l]=t.serializers[l];let h=Object.getOwnPropertySymbols(t.serializers);for(var o=0;o<h.length;o++){let l=h[o];i[Lt][l]=t.serializers[l];}}else i[Lt]=r;if(t.hasOwnProperty("formatters")){let{level:c,bindings:h,log:l}=t.formatters;i[ho]=Nf(c||n.level,h||Mf,l||n.log);}else i[ho]=Nf(n.level,Mf,n.log);if(t.hasOwnProperty("customLevels")===!0&&(I0(this.levels,t.customLevels),i.levels=v0(t.customLevels,i[p0]),C0(i)),typeof t.redact=="object"&&t.redact!==null||Array.isArray(t.redact)){i.redact=t.redact;let c=O0(i.redact,Lf),h={stringify:c[m0]};i[y0]=Lf,i[b0]=c,i[w0]=h;}i[go]=kf(i,e);let a=t.level||this.level;return i[po](a),i}function P0(){let t=`{${this[go].substr(1)}}`,r=JSON.parse(t);return delete r.pid,delete r.hostname,r}function N0(e){let t=kf(this,e);this[go]=t,delete this[c0];}function L0(e,t){return Object.assign(t,e)}function M0(e,t,r){let n=this[h0](),i=this[l0],s=this[f0]||L0,o;e==null?o={}:e instanceof Error?(o={err:e},t===void 0&&(t=e.message)):(o=e,t===void 0&&e.err&&(t=e.err.message)),i&&(o=s(o,i(o,r)));let a=this[Ff](o,t,r,n),c=this[Bf];c[g0]===!0&&(c.lastLevel=r,c.lastObj=o,c.lastMsg=t,c.lastTime=n.slice(this[d0]),c.lastLogger=this),c.write(a);}function F0(){}function B0(){let e=this[Bf];"flush"in e&&e.flush(F0);}});var qf=B((bo,$f)=>{d();var{hasOwnProperty:Br}=Object.prototype,Ft=wo();Ft.configure=wo;Ft.stringify=Ft;Ft.default=Ft;bo.stringify=Ft;bo.configure=wo;$f.exports=Ft;var k0=/[\u0000-\u001f\u0022\u005c\ud800-\udfff]/;function wt(e){return e.length<5e3&&!k0.test(e)?`"${e}"`:JSON.stringify(e)}function mo(e,t){if(e.length>200||t)return e.sort(t);for(let r=1;r<e.length;r++){let n=e[r],i=r;for(;i!==0&&e[i-1]>n;)e[i]=e[i-1],i--;e[i]=n;}return e}var U0=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(Object.getPrototypeOf(new Int8Array)),Symbol.toStringTag).get;function yo(e){return U0.call(e)!==void 0&&e.length!==0}function jf(e,t,r){e.length<r&&(r=e.length);let n=t===","?"":" ",i=`"0":${n}${e[0]}`;for(let s=1;s<r;s++)i+=`${t}"${s}":${n}${e[s]}`;return i}function W0(e){if(Br.call(e,"circularValue")){let t=e.circularValue;if(typeof t=="string")return `"${t}"`;if(t==null)return t;if(t===Error||t===TypeError)return {toString(){throw new TypeError("Converting circular structure to JSON")}};throw new TypeError('The "circularValue" argument must be of type string or the value null or undefined')}return '"[Circular]"'}function K0(e){let t;if(Br.call(e,"deterministic")&&(t=e.deterministic,typeof t!="boolean"&&typeof t!="function"))throw new TypeError('The "deterministic" argument must be of type boolean or comparator function');return t===void 0?!0:t}function j0(e,t){let r;if(Br.call(e,t)&&(r=e[t],typeof r!="boolean"))throw new TypeError(`The "${t}" argument must be of type boolean`);return r===void 0?!0:r}function zf(e,t){let r;if(Br.call(e,t)){if(r=e[t],typeof r!="number")throw new TypeError(`The "${t}" argument must be of type number`);if(!Number.isInteger(r))throw new TypeError(`The "${t}" argument must be an integer`);if(r<1)throw new RangeError(`The "${t}" argument must be >= 1`)}return r===void 0?1/0:r}function Mt(e){return e===1?"1 item":`${e} items`}function z0(e){let t=new Set;for(let r of e)(typeof r=="string"||typeof r=="number")&&t.add(String(r));return t}function $0(e){if(Br.call(e,"strict")){let t=e.strict;if(typeof t!="boolean")throw new TypeError('The "strict" argument must be of type boolean');if(t)return r=>{let n=`Object can not safely be stringified. Received type ${typeof r}`;throw typeof r!="function"&&(n+=` (${r.toString()})`),new Error(n)}}}function wo(e){e=M({},e);let t=$0(e);t&&(e.bigint===void 0&&(e.bigint=!1),"circularValue"in e||(e.circularValue=Error));let r=W0(e),n=j0(e,"bigint"),i=K0(e),s=typeof i=="function"?i:void 0,o=zf(e,"maximumDepth"),a=zf(e,"maximumBreadth");function c(p,u,y,w,S,b){let _=u[p];switch(typeof _=="object"&&_!==null&&typeof _.toJSON=="function"&&(_=_.toJSON(p)),_=w.call(u,p,_),typeof _){case"string":return wt(_);case"object":{if(_===null)return "null";if(y.indexOf(_)!==-1)return r;let x="",O=",",L=b;if(Array.isArray(_)){if(_.length===0)return "[]";if(o<y.length+1)return '"[Array]"';y.push(_),S!==""&&(b+=S,x+=`
110
+ ${b}`,O=`,
111
+ ${b}`);let I=Math.min(_.length,a),A=0;for(;A<I-1;A++){let W=c(String(A),_,y,w,S,b);x+=W!==void 0?W:"null",x+=O;}let N=c(String(A),_,y,w,S,b);if(x+=N!==void 0?N:"null",_.length-1>a){let W=_.length-a-1;x+=`${O}"... ${Mt(W)} not stringified"`;}return S!==""&&(x+=`
112
+ ${L}`),y.pop(),`[${x}]`}let E=Object.keys(_),C=E.length;if(C===0)return "{}";if(o<y.length+1)return '"[Object]"';let F="",T="";S!==""&&(b+=S,O=`,
113
+ ${b}`,F=" ");let D=Math.min(C,a);i&&!yo(_)&&(E=mo(E,s)),y.push(_);for(let I=0;I<D;I++){let A=E[I],N=c(A,_,y,w,S,b);N!==void 0&&(x+=`${T}${wt(A)}:${F}${N}`,T=O);}if(C>a){let I=C-a;x+=`${T}"...":${F}"${Mt(I)} not stringified"`,T=O;}return S!==""&&T.length>1&&(x=`
114
+ ${b}${x}
115
+ ${L}`),y.pop(),`{${x}}`}case"number":return isFinite(_)?String(_):t?t(_):"null";case"boolean":return _===!0?"true":"false";case"undefined":return;case"bigint":if(n)return String(_);default:return t?t(_):void 0}}function h(p,u,y,w,S,b){switch(typeof u=="object"&&u!==null&&typeof u.toJSON=="function"&&(u=u.toJSON(p)),typeof u){case"string":return wt(u);case"object":{if(u===null)return "null";if(y.indexOf(u)!==-1)return r;let _=b,x="",O=",";if(Array.isArray(u)){if(u.length===0)return "[]";if(o<y.length+1)return '"[Array]"';y.push(u),S!==""&&(b+=S,x+=`
116
+ ${b}`,O=`,
117
+ ${b}`);let C=Math.min(u.length,a),F=0;for(;F<C-1;F++){let D=h(String(F),u[F],y,w,S,b);x+=D!==void 0?D:"null",x+=O;}let T=h(String(F),u[F],y,w,S,b);if(x+=T!==void 0?T:"null",u.length-1>a){let D=u.length-a-1;x+=`${O}"... ${Mt(D)} not stringified"`;}return S!==""&&(x+=`
118
+ ${_}`),y.pop(),`[${x}]`}y.push(u);let L="";S!==""&&(b+=S,O=`,
119
+ ${b}`,L=" ");let E="";for(let C of w){let F=h(C,u[C],y,w,S,b);F!==void 0&&(x+=`${E}${wt(C)}:${L}${F}`,E=O);}return S!==""&&E.length>1&&(x=`
120
+ ${b}${x}
121
+ ${_}`),y.pop(),`{${x}}`}case"number":return isFinite(u)?String(u):t?t(u):"null";case"boolean":return u===!0?"true":"false";case"undefined":return;case"bigint":if(n)return String(u);default:return t?t(u):void 0}}function l(p,u,y,w,S){switch(typeof u){case"string":return wt(u);case"object":{if(u===null)return "null";if(typeof u.toJSON=="function"){if(u=u.toJSON(p),typeof u!="object")return l(p,u,y,w,S);if(u===null)return "null"}if(y.indexOf(u)!==-1)return r;let b=S;if(Array.isArray(u)){if(u.length===0)return "[]";if(o<y.length+1)return '"[Array]"';y.push(u),S+=w;let F=`
122
+ ${S}`,T=`,
123
+ ${S}`,D=Math.min(u.length,a),I=0;for(;I<D-1;I++){let N=l(String(I),u[I],y,w,S);F+=N!==void 0?N:"null",F+=T;}let A=l(String(I),u[I],y,w,S);if(F+=A!==void 0?A:"null",u.length-1>a){let N=u.length-a-1;F+=`${T}"... ${Mt(N)} not stringified"`;}return F+=`
124
+ ${b}`,y.pop(),`[${F}]`}let _=Object.keys(u),x=_.length;if(x===0)return "{}";if(o<y.length+1)return '"[Object]"';S+=w;let O=`,
125
+ ${S}`,L="",E="",C=Math.min(x,a);yo(u)&&(L+=jf(u,O,a),_=_.slice(u.length),C-=u.length,E=O),i&&(_=mo(_,s)),y.push(u);for(let F=0;F<C;F++){let T=_[F],D=l(T,u[T],y,w,S);D!==void 0&&(L+=`${E}${wt(T)}: ${D}`,E=O);}if(x>a){let F=x-a;L+=`${E}"...": "${Mt(F)} not stringified"`,E=O;}return E!==""&&(L=`
126
+ ${S}${L}
127
+ ${b}`),y.pop(),`{${L}}`}case"number":return isFinite(u)?String(u):t?t(u):"null";case"boolean":return u===!0?"true":"false";case"undefined":return;case"bigint":if(n)return String(u);default:return t?t(u):void 0}}function f(p,u,y){switch(typeof u){case"string":return wt(u);case"object":{if(u===null)return "null";if(typeof u.toJSON=="function"){if(u=u.toJSON(p),typeof u!="object")return f(p,u,y);if(u===null)return "null"}if(y.indexOf(u)!==-1)return r;let w="",S=u.length!==void 0;if(S&&Array.isArray(u)){if(u.length===0)return "[]";if(o<y.length+1)return '"[Array]"';y.push(u);let L=Math.min(u.length,a),E=0;for(;E<L-1;E++){let F=f(String(E),u[E],y);w+=F!==void 0?F:"null",w+=",";}let C=f(String(E),u[E],y);if(w+=C!==void 0?C:"null",u.length-1>a){let F=u.length-a-1;w+=`,"... ${Mt(F)} not stringified"`;}return y.pop(),`[${w}]`}let b=Object.keys(u),_=b.length;if(_===0)return "{}";if(o<y.length+1)return '"[Object]"';let x="",O=Math.min(_,a);S&&yo(u)&&(w+=jf(u,",",a),b=b.slice(u.length),O-=u.length,x=","),i&&(b=mo(b,s)),y.push(u);for(let L=0;L<O;L++){let E=b[L],C=f(E,u[E],y);C!==void 0&&(w+=`${x}${wt(E)}:${C}`,x=",");}if(_>a){let L=_-a;w+=`${x}"...":"${Mt(L)} not stringified"`;}return y.pop(),`{${w}}`}case"number":return isFinite(u)?String(u):t?t(u):"null";case"boolean":return u===!0?"true":"false";case"undefined":return;case"bigint":if(n)return String(u);default:return t?t(u):void 0}}function m(p,u,y){if(arguments.length>1){let w="";if(typeof y=="number"?w=" ".repeat(Math.min(y,10)):typeof y=="string"&&(w=y.slice(0,10)),u!=null){if(typeof u=="function")return c("",{"":p},[],u,w,"");if(Array.isArray(u))return h("",p,[],z0(u),w,"")}if(w.length!==0)return l("",p,[],w,"")}return f("",p,[])}return m}});var Jf=B((dR,Hf)=>{d();var So=Symbol.for("pino.metadata"),{levels:Gf}=ii(),Vf=Object.create(Gf);Vf.silent=1/0;var q0=Gf.info;function G0(e,t){let r=0;e=e||[],t=t||{dedupe:!1};let n=Vf;t.levels&&typeof t.levels=="object"&&(n=t.levels);let i={write:s,add:a,flushSync:o,end:c,minLevel:0,streams:[],clone:h,[So]:!0};return Array.isArray(e)?e.forEach(a,i):a.call(i,e),e=null,i;function s(l){let f,m=this.lastLevel,{streams:p}=this,u;for(let y=0;y<p.length&&(f=p[y],f.level<=m);y++){if(u=f.stream,u[So]){let{lastTime:w,lastMsg:S,lastObj:b,lastLogger:_}=this;u.lastLevel=m,u.lastTime=w,u.lastMsg=S,u.lastObj=b,u.lastLogger=_;}(!t.dedupe||f.level===m)&&u.write(l);}}function o(){for(let{stream:l}of this.streams)typeof l.flushSync=="function"&&l.flushSync();}function a(l){if(!l)return i;let f=typeof l.write=="function"||l.stream,m=l.write?l:l.stream;if(!f)throw Error("stream object needs to implement either StreamEntry or DestinationStream interface");let{streams:p}=this,u;typeof l.levelVal=="number"?u=l.levelVal:typeof l.level=="string"?u=n[l.level]:typeof l.level=="number"?u=l.level:u=q0;let y={stream:m,level:u,levelVal:void 0,id:r++};return p.unshift(y),p.sort(V0),this.minLevel=p[0].level,i}function c(){for(let{stream:l}of this.streams)typeof l.flushSync=="function"&&l.flushSync(),l.end();}function h(l){let f=new Array(this.streams.length);for(let m=0;m<f.length;m++)f[m]={level:l,stream:this.streams[m].stream};return {write:s,add:a,minLevel:l,streams:f,clone:h,flushSync:o,[So]:!0}}}function V0(e,t){return e.level-t.level}Hf.exports=G0;});var vo=B((gR,Ue)=>{d();var H0=z("os"),nh=Ns(),J0=Ls(),Y0=Ks(),ih=Ku(),X0=Kf(),sh=nr(),{configure:Q0}=qf(),{assertDefaultLevelFound:Z0,mappings:oh,genLsCache:e_,levels:t_}=ii(),{createArgsNormalizer:r_,asChindings:n_,final:i_,buildSafeSonicBoom:Yf,buildFormatters:s_,stringify:si,normalizeDestFileDescriptor:Xf,noop:o_}=ni(),{version:a_}=fo(),{chindingsSym:Qf,redactFmtSym:c_,serializersSym:Zf,timeSym:l_,timeSliceIndexSym:u_,streamSym:f_,stringifySym:eh,stringifySafeSym:_o,stringifiersSym:th,setLevelSym:h_,endSym:d_,formatOptsSym:p_,messageKeySym:g_,nestedKeySym:m_,mixinSym:y_,useOnlyCustomLevelsSym:w_,formattersSym:rh,hooksSym:b_,nestedKeyStrSym:S_,mixinMergeStrategySym:__}=sh,{epochTime:ah,nullTime:E_}=ih,{pid:v_}=process,x_=H0.hostname(),C_=nh.err,I_={level:"info",levels:t_,messageKey:"msg",nestedKey:null,enabled:!0,prettyPrint:!1,base:{pid:v_,hostname:x_},serializers:Object.assign(Object.create(null),{err:C_}),formatters:Object.assign(Object.create(null),{bindings(e){return e},level(e,t){return {level:t}}}),hooks:{logMethod:void 0},timestamp:ah,name:void 0,redact:null,customLevels:null,useOnlyCustomLevels:!1,depthLimit:5,edgeLimit:100},D_=r_(I_),A_=Object.assign(Object.create(null),nh);function Eo(...e){let t={},{opts:r,stream:n}=D_(t,J0(),...e),{redact:i,crlf:s,serializers:o,timestamp:a,messageKey:c,nestedKey:h,base:l,name:f,level:m,customLevels:p,mixin:u,mixinMergeStrategy:y,useOnlyCustomLevels:w,formatters:S,hooks:b,depthLimit:_,edgeLimit:x}=r,O=Q0({maximumDepth:_,maximumBreadth:x}),L=s_(S.level,S.bindings,S.log),E=i?Y0(i,si):{},C=si.bind({[_o]:O}),F=i?{stringify:E[c_]}:{stringify:C},T="}"+(s?`\r
128
+ `:`
129
+ `),D=n_.bind(null,{[Qf]:"",[Zf]:o,[th]:E,[eh]:si,[_o]:O,[rh]:L}),I="";l!==null&&(f===void 0?I=D(l):I=D(Object.assign({},l,{name:f})));let A=a instanceof Function?a:a?ah:E_,N=A().indexOf(":")+1;if(w&&!p)throw Error("customLevels is required if useOnlyCustomLevels is set true");if(u&&typeof u!="function")throw Error(`Unknown mixin type "${typeof u}" - expected "function"`);Z0(m,p,w);let W=oh(p,w);return Object.assign(t,{levels:W,[w_]:w,[f_]:n,[l_]:A,[u_]:N,[eh]:si,[_o]:O,[th]:E,[d_]:T,[p_]:F,[g_]:c,[m_]:h,[S_]:h?`,${JSON.stringify(h)}:{`:"",[Zf]:o,[y_]:u,[__]:y,[Qf]:I,[rh]:L,[b_]:b,silent:o_}),Object.setPrototypeOf(t,X0()),e_(t),t[h_](m),t}Ue.exports=Eo;Ue.exports.destination=(e=process.stdout.fd)=>typeof e=="object"?(e.dest=Xf(e.dest||process.stdout.fd),Yf(e)):Yf({dest:Xf(e),minLength:0,sync:!0});Ue.exports.transport=eo();Ue.exports.multistream=Jf();Ue.exports.final=i_;Ue.exports.levels=oh();Ue.exports.stdSerializers=A_;Ue.exports.stdTimeFunctions=Object.assign({},ih);Ue.exports.symbols=sh;Ue.exports.version=a_;Ue.exports.default=Eo;Ue.exports.pino=Eo;});var hh=B(ui=>{d();Object.defineProperty(ui,"__esModule",{value:!0});ui.BrowserRandomSource=void 0;var fh=65536,To=class{constructor(){this.isAvailable=!1,this.isInstantiated=!1;let t=typeof self!="undefined"?self.crypto||self.msCrypto:null;t&&t.getRandomValues!==void 0&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0);}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Browser random byte generator is not available.");let r=new Uint8Array(t);for(let n=0;n<r.length;n+=fh)this._crypto.getRandomValues(r.subarray(n,n+Math.min(r.length-n,fh)));return r}};ui.BrowserRandomSource=To;});var Ur=B(Ro=>{d();Object.defineProperty(Ro,"__esModule",{value:!0});function W_(e){for(var t=0;t<e.length;t++)e[t]=0;return e}Ro.wipe=W_;});var dh=B(fi=>{d();Object.defineProperty(fi,"__esModule",{value:!0});fi.NodeRandomSource=void 0;var K_=Ur(),Po=class{constructor(){if(this.isAvailable=!1,this.isInstantiated=!1,typeof z!="undefined"){let t=z("crypto");t&&t.randomBytes&&(this._crypto=t,this.isAvailable=!0,this.isInstantiated=!0);}}randomBytes(t){if(!this.isAvailable||!this._crypto)throw new Error("Node.js random byte generator is not available.");let r=this._crypto.randomBytes(t);if(r.length!==t)throw new Error("NodeRandomSource: got fewer bytes than requested");let n=new Uint8Array(t);for(let i=0;i<n.length;i++)n[i]=r[i];return (0, K_.wipe)(r),n}};fi.NodeRandomSource=Po;});var ph=B(hi=>{d();Object.defineProperty(hi,"__esModule",{value:!0});hi.SystemRandomSource=void 0;var j_=hh(),z_=dh(),No=class{constructor(){if(this.isAvailable=!1,this.name="",this._source=new j_.BrowserRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Browser";return}if(this._source=new z_.NodeRandomSource,this._source.isAvailable){this.isAvailable=!0,this.name="Node";return}}randomBytes(t){if(!this.isAvailable)throw new Error("System random byte generator is not available.");return this._source.randomBytes(t)}};hi.SystemRandomSource=No;});var gh=B(We=>{d();Object.defineProperty(We,"__esModule",{value:!0});function $_(e,t){var r=e>>>16&65535,n=e&65535,i=t>>>16&65535,s=t&65535;return n*s+(r*s+n*i<<16>>>0)|0}We.mul=Math.imul||$_;function q_(e,t){return e+t|0}We.add=q_;function G_(e,t){return e-t|0}We.sub=G_;function V_(e,t){return e<<t|e>>>32-t}We.rotl=V_;function H_(e,t){return e<<32-t|e>>>t}We.rotr=H_;function J_(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e}We.isInteger=Number.isInteger||J_;We.MAX_SAFE_INTEGER=9007199254740991;We.isSafeInteger=function(e){return We.isInteger(e)&&e>=-We.MAX_SAFE_INTEGER&&e<=We.MAX_SAFE_INTEGER};});var ko=B(q=>{d();Object.defineProperty(q,"__esModule",{value:!0});var mh=gh();function Y_(e,t){return t===void 0&&(t=0),(e[t+0]<<8|e[t+1])<<16>>16}q.readInt16BE=Y_;function X_(e,t){return t===void 0&&(t=0),(e[t+0]<<8|e[t+1])>>>0}q.readUint16BE=X_;function Q_(e,t){return t===void 0&&(t=0),(e[t+1]<<8|e[t])<<16>>16}q.readInt16LE=Q_;function Z_(e,t){return t===void 0&&(t=0),(e[t+1]<<8|e[t])>>>0}q.readUint16LE=Z_;function yh(e,t,r){return t===void 0&&(t=new Uint8Array(2)),r===void 0&&(r=0),t[r+0]=e>>>8,t[r+1]=e>>>0,t}q.writeUint16BE=yh;q.writeInt16BE=yh;function wh(e,t,r){return t===void 0&&(t=new Uint8Array(2)),r===void 0&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t}q.writeUint16LE=wh;q.writeInt16LE=wh;function Lo(e,t){return t===void 0&&(t=0),e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3]}q.readInt32BE=Lo;function Mo(e,t){return t===void 0&&(t=0),(e[t]<<24|e[t+1]<<16|e[t+2]<<8|e[t+3])>>>0}q.readUint32BE=Mo;function Fo(e,t){return t===void 0&&(t=0),e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t]}q.readInt32LE=Fo;function Bo(e,t){return t===void 0&&(t=0),(e[t+3]<<24|e[t+2]<<16|e[t+1]<<8|e[t])>>>0}q.readUint32LE=Bo;function di(e,t,r){return t===void 0&&(t=new Uint8Array(4)),r===void 0&&(r=0),t[r+0]=e>>>24,t[r+1]=e>>>16,t[r+2]=e>>>8,t[r+3]=e>>>0,t}q.writeUint32BE=di;q.writeInt32BE=di;function pi(e,t,r){return t===void 0&&(t=new Uint8Array(4)),r===void 0&&(r=0),t[r+0]=e>>>0,t[r+1]=e>>>8,t[r+2]=e>>>16,t[r+3]=e>>>24,t}q.writeUint32LE=pi;q.writeInt32LE=pi;function eE(e,t){t===void 0&&(t=0);var r=Lo(e,t),n=Lo(e,t+4);return r*4294967296+n-(n>>31)*4294967296}q.readInt64BE=eE;function tE(e,t){t===void 0&&(t=0);var r=Mo(e,t),n=Mo(e,t+4);return r*4294967296+n}q.readUint64BE=tE;function rE(e,t){t===void 0&&(t=0);var r=Fo(e,t),n=Fo(e,t+4);return n*4294967296+r-(r>>31)*4294967296}q.readInt64LE=rE;function nE(e,t){t===void 0&&(t=0);var r=Bo(e,t),n=Bo(e,t+4);return n*4294967296+r}q.readUint64LE=nE;function bh(e,t,r){return t===void 0&&(t=new Uint8Array(8)),r===void 0&&(r=0),di(e/4294967296>>>0,t,r),di(e>>>0,t,r+4),t}q.writeUint64BE=bh;q.writeInt64BE=bh;function Sh(e,t,r){return t===void 0&&(t=new Uint8Array(8)),r===void 0&&(r=0),pi(e>>>0,t,r),pi(e/4294967296>>>0,t,r+4),t}q.writeUint64LE=Sh;q.writeInt64LE=Sh;function iE(e,t,r){if(r===void 0&&(r=0),e%8!==0)throw new Error("readUintBE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintBE: array is too short for the given bitLength");for(var n=0,i=1,s=e/8+r-1;s>=r;s--)n+=t[s]*i,i*=256;return n}q.readUintBE=iE;function sE(e,t,r){if(r===void 0&&(r=0),e%8!==0)throw new Error("readUintLE supports only bitLengths divisible by 8");if(e/8>t.length-r)throw new Error("readUintLE: array is too short for the given bitLength");for(var n=0,i=1,s=r;s<r+e/8;s++)n+=t[s]*i,i*=256;return n}q.readUintLE=sE;function oE(e,t,r,n){if(r===void 0&&(r=new Uint8Array(e/8)),n===void 0&&(n=0),e%8!==0)throw new Error("writeUintBE supports only bitLengths divisible by 8");if(!mh.isSafeInteger(t))throw new Error("writeUintBE value must be an integer");for(var i=1,s=e/8+n-1;s>=n;s--)r[s]=t/i&255,i*=256;return r}q.writeUintBE=oE;function aE(e,t,r,n){if(r===void 0&&(r=new Uint8Array(e/8)),n===void 0&&(n=0),e%8!==0)throw new Error("writeUintLE supports only bitLengths divisible by 8");if(!mh.isSafeInteger(t))throw new Error("writeUintLE value must be an integer");for(var i=1,s=n;s<n+e/8;s++)r[s]=t/i&255,i*=256;return r}q.writeUintLE=aE;function cE(e,t){t===void 0&&(t=0);var r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.getFloat32(t)}q.readFloat32BE=cE;function lE(e,t){t===void 0&&(t=0);var r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.getFloat32(t,!0)}q.readFloat32LE=lE;function uE(e,t){t===void 0&&(t=0);var r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.getFloat64(t)}q.readFloat64BE=uE;function fE(e,t){t===void 0&&(t=0);var r=new DataView(e.buffer,e.byteOffset,e.byteLength);return r.getFloat64(t,!0)}q.readFloat64LE=fE;function hE(e,t,r){t===void 0&&(t=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.setFloat32(r,e),t}q.writeFloat32BE=hE;function dE(e,t,r){t===void 0&&(t=new Uint8Array(4)),r===void 0&&(r=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.setFloat32(r,e,!0),t}q.writeFloat32LE=dE;function pE(e,t,r){t===void 0&&(t=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.setFloat64(r,e),t}q.writeFloat64BE=pE;function gE(e,t,r){t===void 0&&(t=new Uint8Array(8)),r===void 0&&(r=0);var n=new DataView(t.buffer,t.byteOffset,t.byteLength);return n.setFloat64(r,e,!0),t}q.writeFloat64LE=gE;});var Wo=B(ve=>{d();Object.defineProperty(ve,"__esModule",{value:!0});ve.randomStringForEntropy=ve.randomString=ve.randomUint32=ve.randomBytes=ve.defaultRandomSource=void 0;var mE=ph(),yE=ko(),_h=Ur();ve.defaultRandomSource=new mE.SystemRandomSource;function Uo(e,t=ve.defaultRandomSource){return t.randomBytes(e)}ve.randomBytes=Uo;function wE(e=ve.defaultRandomSource){let t=Uo(4,e),r=(0, yE.readUint32LE)(t);return (0, _h.wipe)(t),r}ve.randomUint32=wE;var Eh="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";function vh(e,t=Eh,r=ve.defaultRandomSource){if(t.length<2)throw new Error("randomString charset is too short");if(t.length>256)throw new Error("randomString charset is too long");let n="",i=t.length,s=256-256%i;for(;e>0;){let o=Uo(Math.ceil(e*256/s),r);for(let a=0;a<o.length&&e>0;a++){let c=o[a];c<s&&(n+=t.charAt(c%i),e--);}(0, _h.wipe)(o);}return n}ve.randomString=vh;function bE(e,t=Eh,r=ve.defaultRandomSource){let n=Math.ceil(e/(Math.log(t.length)/Math.LN2));return vh(n,t,r)}ve.randomStringForEntropy=bE;});var Ih=B(ut=>{d();Object.defineProperty(ut,"__esModule",{value:!0});var ar=ko(),or=Ur();ut.DIGEST_LENGTH=64;ut.BLOCK_SIZE=128;var Ch=function(){function e(){this.digestLength=ut.DIGEST_LENGTH,this.blockSize=ut.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 e.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;},e.prototype.reset=function(){return this._initState(),this._bufferLength=0,this._bytesHashed=0,this._finished=!1,this},e.prototype.clean=function(){or.wipe(this._buffer),or.wipe(this._tempHi),or.wipe(this._tempLo),this.reset();},e.prototype.update=function(t,r){if(r===void 0&&(r=t.length),this._finished)throw new Error("SHA512: can't update because hash was finished.");var n=0;if(this._bytesHashed+=r,this._bufferLength>0){for(;this._bufferLength<ut.BLOCK_SIZE&&r>0;)this._buffer[this._bufferLength++]=t[n++],r--;this._bufferLength===this.blockSize&&(Ko(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,this.blockSize),this._bufferLength=0);}for(r>=this.blockSize&&(n=Ko(this._tempHi,this._tempLo,this._stateHi,this._stateLo,t,n,r),r%=this.blockSize);r>0;)this._buffer[this._bufferLength++]=t[n++],r--;return this},e.prototype.finish=function(t){if(!this._finished){var r=this._bytesHashed,n=this._bufferLength,i=r/536870912|0,s=r<<3,o=r%128<112?128:256;this._buffer[n]=128;for(var a=n+1;a<o-8;a++)this._buffer[a]=0;ar.writeUint32BE(i,this._buffer,o-8),ar.writeUint32BE(s,this._buffer,o-4),Ko(this._tempHi,this._tempLo,this._stateHi,this._stateLo,this._buffer,0,o),this._finished=!0;}for(var a=0;a<this.digestLength/8;a++)ar.writeUint32BE(this._stateHi[a],t,a*8),ar.writeUint32BE(this._stateLo[a],t,a*8+4);return this},e.prototype.digest=function(){var t=new Uint8Array(this.digestLength);return this.finish(t),t},e.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}},e.prototype.restoreState=function(t){return this._stateHi.set(t.stateHi),this._stateLo.set(t.stateLo),this._bufferLength=t.bufferLength,t.buffer&&this._buffer.set(t.buffer),this._bytesHashed=t.bytesHashed,this._finished=!1,this},e.prototype.cleanSavedState=function(t){or.wipe(t.stateHi),or.wipe(t.stateLo),t.buffer&&or.wipe(t.buffer),t.bufferLength=0,t.bytesHashed=0;},e}();ut.SHA512=Ch;var xh=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 Ko(e,t,r,n,i,s,o){for(var a=r[0],c=r[1],h=r[2],l=r[3],f=r[4],m=r[5],p=r[6],u=r[7],y=n[0],w=n[1],S=n[2],b=n[3],_=n[4],x=n[5],O=n[6],L=n[7],E,C,F,T,D,I,A,N;o>=128;){for(var W=0;W<16;W++){var $=8*W+s;e[W]=ar.readUint32BE(i,$),t[W]=ar.readUint32BE(i,$+4);}for(var W=0;W<80;W++){var me=a,De=c,Le=h,G=l,ne=f,ie=m,J=p,se=u,Z=y,ce=w,le=S,re=b,he=_,ue=x,Y=O,de=L;if(E=u,C=L,D=C&65535,I=C>>>16,A=E&65535,N=E>>>16,E=(f>>>14|_<<32-14)^(f>>>18|_<<32-18)^(_>>>41-32|f<<32-(41-32)),C=(_>>>14|f<<32-14)^(_>>>18|f<<32-18)^(f>>>41-32|_<<32-(41-32)),D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,E=f&m^~f&p,C=_&x^~_&O,D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,E=xh[W*2],C=xh[W*2+1],D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,E=e[W%16],C=t[W%16],D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,I+=D>>>16,A+=I>>>16,N+=A>>>16,F=A&65535|N<<16,T=D&65535|I<<16,E=F,C=T,D=C&65535,I=C>>>16,A=E&65535,N=E>>>16,E=(a>>>28|y<<32-28)^(y>>>34-32|a<<32-(34-32))^(y>>>39-32|a<<32-(39-32)),C=(y>>>28|a<<32-28)^(a>>>34-32|y<<32-(34-32))^(a>>>39-32|y<<32-(39-32)),D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,E=a&c^a&h^c&h,C=y&w^y&S^w&S,D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,I+=D>>>16,A+=I>>>16,N+=A>>>16,se=A&65535|N<<16,de=D&65535|I<<16,E=G,C=re,D=C&65535,I=C>>>16,A=E&65535,N=E>>>16,E=F,C=T,D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,I+=D>>>16,A+=I>>>16,N+=A>>>16,G=A&65535|N<<16,re=D&65535|I<<16,c=me,h=De,l=Le,f=G,m=ne,p=ie,u=J,a=se,w=Z,S=ce,b=le,_=re,x=he,O=ue,L=Y,y=de,W%16===15)for(var $=0;$<16;$++)E=e[$],C=t[$],D=C&65535,I=C>>>16,A=E&65535,N=E>>>16,E=e[($+9)%16],C=t[($+9)%16],D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,F=e[($+1)%16],T=t[($+1)%16],E=(F>>>1|T<<32-1)^(F>>>8|T<<32-8)^F>>>7,C=(T>>>1|F<<32-1)^(T>>>8|F<<32-8)^(T>>>7|F<<32-7),D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,F=e[($+14)%16],T=t[($+14)%16],E=(F>>>19|T<<32-19)^(T>>>61-32|F<<32-(61-32))^F>>>6,C=(T>>>19|F<<32-19)^(F>>>61-32|T<<32-(61-32))^(T>>>6|F<<32-6),D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,I+=D>>>16,A+=I>>>16,N+=A>>>16,e[$]=A&65535|N<<16,t[$]=D&65535|I<<16;}E=a,C=y,D=C&65535,I=C>>>16,A=E&65535,N=E>>>16,E=r[0],C=n[0],D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,I+=D>>>16,A+=I>>>16,N+=A>>>16,r[0]=a=A&65535|N<<16,n[0]=y=D&65535|I<<16,E=c,C=w,D=C&65535,I=C>>>16,A=E&65535,N=E>>>16,E=r[1],C=n[1],D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,I+=D>>>16,A+=I>>>16,N+=A>>>16,r[1]=c=A&65535|N<<16,n[1]=w=D&65535|I<<16,E=h,C=S,D=C&65535,I=C>>>16,A=E&65535,N=E>>>16,E=r[2],C=n[2],D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,I+=D>>>16,A+=I>>>16,N+=A>>>16,r[2]=h=A&65535|N<<16,n[2]=S=D&65535|I<<16,E=l,C=b,D=C&65535,I=C>>>16,A=E&65535,N=E>>>16,E=r[3],C=n[3],D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,I+=D>>>16,A+=I>>>16,N+=A>>>16,r[3]=l=A&65535|N<<16,n[3]=b=D&65535|I<<16,E=f,C=_,D=C&65535,I=C>>>16,A=E&65535,N=E>>>16,E=r[4],C=n[4],D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,I+=D>>>16,A+=I>>>16,N+=A>>>16,r[4]=f=A&65535|N<<16,n[4]=_=D&65535|I<<16,E=m,C=x,D=C&65535,I=C>>>16,A=E&65535,N=E>>>16,E=r[5],C=n[5],D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,I+=D>>>16,A+=I>>>16,N+=A>>>16,r[5]=m=A&65535|N<<16,n[5]=x=D&65535|I<<16,E=p,C=O,D=C&65535,I=C>>>16,A=E&65535,N=E>>>16,E=r[6],C=n[6],D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,I+=D>>>16,A+=I>>>16,N+=A>>>16,r[6]=p=A&65535|N<<16,n[6]=O=D&65535|I<<16,E=u,C=L,D=C&65535,I=C>>>16,A=E&65535,N=E>>>16,E=r[7],C=n[7],D+=C&65535,I+=C>>>16,A+=E&65535,N+=E>>>16,I+=D>>>16,A+=I>>>16,N+=A>>>16,r[7]=u=A&65535|N<<16,n[7]=L=D&65535|I<<16,s+=128,o-=128;}return s}function SE(e){var t=new Ch;t.update(e);var r=t.digest();return t.clean(),r}ut.hash=SE;});var Wh=B(V=>{d();Object.defineProperty(V,"__esModule",{value:!0});V.convertSecretKeyToX25519=V.convertPublicKeyToX25519=V.verify=V.sign=V.extractPublicKeyFromSecretKey=V.generateKeyPair=V.generateKeyPairFromSeed=V.SEED_LENGTH=V.SECRET_KEY_LENGTH=V.PUBLIC_KEY_LENGTH=V.SIGNATURE_LENGTH=void 0;var _E=Wo(),Wr=Ih(),Rh=Ur();V.SIGNATURE_LENGTH=64;V.PUBLIC_KEY_LENGTH=32;V.SECRET_KEY_LENGTH=64;V.SEED_LENGTH=32;function K(e){let t=new Float64Array(16);if(e)for(let r=0;r<e.length;r++)t[r]=e[r];return t}var EE=new Uint8Array(32);EE[0]=9;var $o=K(),cr=K([1]),vE=K([30883,4953,19914,30187,55467,16705,2637,112,59544,30585,16505,36039,65139,11119,27886,20995]),xE=K([61785,9906,39828,60374,45398,33411,5274,224,53552,61171,33010,6542,64743,22239,55772,9222]),Dh=K([54554,36645,11616,51542,42930,38181,51040,26924,56412,64982,57905,49316,21502,52590,14035,8553]),Ah=K([26200,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214,26214]),CE=K([41136,18958,6951,50414,58488,44335,6150,12099,55207,15867,153,11085,57099,20417,9344,11139]);function bt(e,t){for(let r=0;r<16;r++)e[r]=t[r]|0;}function jo(e){let t=1;for(let r=0;r<16;r++){let n=e[r]+t+65535;t=Math.floor(n/65536),e[r]=n-t*65536;}e[0]+=t-1+37*(t-1);}function Ph(e,t,r){let n=~(r-1);for(let i=0;i<16;i++){let s=n&(e[i]^t[i]);e[i]^=s,t[i]^=s;}}function Kr(e,t){let r=K(),n=K();for(let i=0;i<16;i++)n[i]=t[i];jo(n),jo(n),jo(n);for(let i=0;i<2;i++){r[0]=n[0]-65517;for(let o=1;o<15;o++)r[o]=n[o]-65535-(r[o-1]>>16&1),r[o-1]&=65535;r[15]=n[15]-32767-(r[14]>>16&1);let s=r[15]>>16&1;r[14]&=65535,Ph(n,r,1-s);}for(let i=0;i<16;i++)e[2*i]=n[i]&255,e[2*i+1]=n[i]>>8;}function Nh(e,t){let r=0;for(let n=0;n<32;n++)r|=e[n]^t[n];return (1&r-1>>>8)-1}function Oh(e,t){let r=new Uint8Array(32),n=new Uint8Array(32);return Kr(r,e),Kr(n,t),Nh(r,n)}function Lh(e){let t=new Uint8Array(32);return Kr(t,e),t[0]&1}function IE(e,t){for(let r=0;r<16;r++)e[r]=t[2*r]+(t[2*r+1]<<8);e[15]&=32767;}function Bt(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]+r[n];}function Ut(e,t,r){for(let n=0;n<16;n++)e[n]=t[n]-r[n];}function Q(e,t,r){let n,i,s=0,o=0,a=0,c=0,h=0,l=0,f=0,m=0,p=0,u=0,y=0,w=0,S=0,b=0,_=0,x=0,O=0,L=0,E=0,C=0,F=0,T=0,D=0,I=0,A=0,N=0,W=0,$=0,me=0,De=0,Le=0,G=r[0],ne=r[1],ie=r[2],J=r[3],se=r[4],Z=r[5],ce=r[6],le=r[7],re=r[8],he=r[9],ue=r[10],Y=r[11],de=r[12],Se=r[13],_e=r[14],Ee=r[15];n=t[0],s+=n*G,o+=n*ne,a+=n*ie,c+=n*J,h+=n*se,l+=n*Z,f+=n*ce,m+=n*le,p+=n*re,u+=n*he,y+=n*ue,w+=n*Y,S+=n*de,b+=n*Se,_+=n*_e,x+=n*Ee,n=t[1],o+=n*G,a+=n*ne,c+=n*ie,h+=n*J,l+=n*se,f+=n*Z,m+=n*ce,p+=n*le,u+=n*re,y+=n*he,w+=n*ue,S+=n*Y,b+=n*de,_+=n*Se,x+=n*_e,O+=n*Ee,n=t[2],a+=n*G,c+=n*ne,h+=n*ie,l+=n*J,f+=n*se,m+=n*Z,p+=n*ce,u+=n*le,y+=n*re,w+=n*he,S+=n*ue,b+=n*Y,_+=n*de,x+=n*Se,O+=n*_e,L+=n*Ee,n=t[3],c+=n*G,h+=n*ne,l+=n*ie,f+=n*J,m+=n*se,p+=n*Z,u+=n*ce,y+=n*le,w+=n*re,S+=n*he,b+=n*ue,_+=n*Y,x+=n*de,O+=n*Se,L+=n*_e,E+=n*Ee,n=t[4],h+=n*G,l+=n*ne,f+=n*ie,m+=n*J,p+=n*se,u+=n*Z,y+=n*ce,w+=n*le,S+=n*re,b+=n*he,_+=n*ue,x+=n*Y,O+=n*de,L+=n*Se,E+=n*_e,C+=n*Ee,n=t[5],l+=n*G,f+=n*ne,m+=n*ie,p+=n*J,u+=n*se,y+=n*Z,w+=n*ce,S+=n*le,b+=n*re,_+=n*he,x+=n*ue,O+=n*Y,L+=n*de,E+=n*Se,C+=n*_e,F+=n*Ee,n=t[6],f+=n*G,m+=n*ne,p+=n*ie,u+=n*J,y+=n*se,w+=n*Z,S+=n*ce,b+=n*le,_+=n*re,x+=n*he,O+=n*ue,L+=n*Y,E+=n*de,C+=n*Se,F+=n*_e,T+=n*Ee,n=t[7],m+=n*G,p+=n*ne,u+=n*ie,y+=n*J,w+=n*se,S+=n*Z,b+=n*ce,_+=n*le,x+=n*re,O+=n*he,L+=n*ue,E+=n*Y,C+=n*de,F+=n*Se,T+=n*_e,D+=n*Ee,n=t[8],p+=n*G,u+=n*ne,y+=n*ie,w+=n*J,S+=n*se,b+=n*Z,_+=n*ce,x+=n*le,O+=n*re,L+=n*he,E+=n*ue,C+=n*Y,F+=n*de,T+=n*Se,D+=n*_e,I+=n*Ee,n=t[9],u+=n*G,y+=n*ne,w+=n*ie,S+=n*J,b+=n*se,_+=n*Z,x+=n*ce,O+=n*le,L+=n*re,E+=n*he,C+=n*ue,F+=n*Y,T+=n*de,D+=n*Se,I+=n*_e,A+=n*Ee,n=t[10],y+=n*G,w+=n*ne,S+=n*ie,b+=n*J,_+=n*se,x+=n*Z,O+=n*ce,L+=n*le,E+=n*re,C+=n*he,F+=n*ue,T+=n*Y,D+=n*de,I+=n*Se,A+=n*_e,N+=n*Ee,n=t[11],w+=n*G,S+=n*ne,b+=n*ie,_+=n*J,x+=n*se,O+=n*Z,L+=n*ce,E+=n*le,C+=n*re,F+=n*he,T+=n*ue,D+=n*Y,I+=n*de,A+=n*Se,N+=n*_e,W+=n*Ee,n=t[12],S+=n*G,b+=n*ne,_+=n*ie,x+=n*J,O+=n*se,L+=n*Z,E+=n*ce,C+=n*le,F+=n*re,T+=n*he,D+=n*ue,I+=n*Y,A+=n*de,N+=n*Se,W+=n*_e,$+=n*Ee,n=t[13],b+=n*G,_+=n*ne,x+=n*ie,O+=n*J,L+=n*se,E+=n*Z,C+=n*ce,F+=n*le,T+=n*re,D+=n*he,I+=n*ue,A+=n*Y,N+=n*de,W+=n*Se,$+=n*_e,me+=n*Ee,n=t[14],_+=n*G,x+=n*ne,O+=n*ie,L+=n*J,E+=n*se,C+=n*Z,F+=n*ce,T+=n*le,D+=n*re,I+=n*he,A+=n*ue,N+=n*Y,W+=n*de,$+=n*Se,me+=n*_e,De+=n*Ee,n=t[15],x+=n*G,O+=n*ne,L+=n*ie,E+=n*J,C+=n*se,F+=n*Z,T+=n*ce,D+=n*le,I+=n*re,A+=n*he,N+=n*ue,W+=n*Y,$+=n*de,me+=n*Se,De+=n*_e,Le+=n*Ee,s+=38*O,o+=38*L,a+=38*E,c+=38*C,h+=38*F,l+=38*T,f+=38*D,m+=38*I,p+=38*A,u+=38*N,y+=38*W,w+=38*$,S+=38*me,b+=38*De,_+=38*Le,i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-i*65536,n=o+i+65535,i=Math.floor(n/65536),o=n-i*65536,n=a+i+65535,i=Math.floor(n/65536),a=n-i*65536,n=c+i+65535,i=Math.floor(n/65536),c=n-i*65536,n=h+i+65535,i=Math.floor(n/65536),h=n-i*65536,n=l+i+65535,i=Math.floor(n/65536),l=n-i*65536,n=f+i+65535,i=Math.floor(n/65536),f=n-i*65536,n=m+i+65535,i=Math.floor(n/65536),m=n-i*65536,n=p+i+65535,i=Math.floor(n/65536),p=n-i*65536,n=u+i+65535,i=Math.floor(n/65536),u=n-i*65536,n=y+i+65535,i=Math.floor(n/65536),y=n-i*65536,n=w+i+65535,i=Math.floor(n/65536),w=n-i*65536,n=S+i+65535,i=Math.floor(n/65536),S=n-i*65536,n=b+i+65535,i=Math.floor(n/65536),b=n-i*65536,n=_+i+65535,i=Math.floor(n/65536),_=n-i*65536,n=x+i+65535,i=Math.floor(n/65536),x=n-i*65536,s+=i-1+37*(i-1),i=1,n=s+i+65535,i=Math.floor(n/65536),s=n-i*65536,n=o+i+65535,i=Math.floor(n/65536),o=n-i*65536,n=a+i+65535,i=Math.floor(n/65536),a=n-i*65536,n=c+i+65535,i=Math.floor(n/65536),c=n-i*65536,n=h+i+65535,i=Math.floor(n/65536),h=n-i*65536,n=l+i+65535,i=Math.floor(n/65536),l=n-i*65536,n=f+i+65535,i=Math.floor(n/65536),f=n-i*65536,n=m+i+65535,i=Math.floor(n/65536),m=n-i*65536,n=p+i+65535,i=Math.floor(n/65536),p=n-i*65536,n=u+i+65535,i=Math.floor(n/65536),u=n-i*65536,n=y+i+65535,i=Math.floor(n/65536),y=n-i*65536,n=w+i+65535,i=Math.floor(n/65536),w=n-i*65536,n=S+i+65535,i=Math.floor(n/65536),S=n-i*65536,n=b+i+65535,i=Math.floor(n/65536),b=n-i*65536,n=_+i+65535,i=Math.floor(n/65536),_=n-i*65536,n=x+i+65535,i=Math.floor(n/65536),x=n-i*65536,s+=i-1+37*(i-1),e[0]=s,e[1]=o,e[2]=a,e[3]=c,e[4]=h,e[5]=l,e[6]=f,e[7]=m,e[8]=p,e[9]=u,e[10]=y,e[11]=w,e[12]=S,e[13]=b,e[14]=_,e[15]=x;}function kt(e,t){Q(e,t,t);}function Mh(e,t){let r=K(),n;for(n=0;n<16;n++)r[n]=t[n];for(n=253;n>=0;n--)kt(r,r),n!==2&&n!==4&&Q(r,r,t);for(n=0;n<16;n++)e[n]=r[n];}function DE(e,t){let r=K(),n;for(n=0;n<16;n++)r[n]=t[n];for(n=250;n>=0;n--)kt(r,r),n!==1&&Q(r,r,t);for(n=0;n<16;n++)e[n]=r[n];}function qo(e,t){let r=K(),n=K(),i=K(),s=K(),o=K(),a=K(),c=K(),h=K(),l=K();Ut(r,e[1],e[0]),Ut(l,t[1],t[0]),Q(r,r,l),Bt(n,e[0],e[1]),Bt(l,t[0],t[1]),Q(n,n,l),Q(i,e[3],t[3]),Q(i,i,xE),Q(s,e[2],t[2]),Bt(s,s,s),Ut(o,n,r),Ut(a,s,i),Bt(c,s,i),Bt(h,n,r),Q(e[0],o,a),Q(e[1],h,c),Q(e[2],c,a),Q(e[3],o,h);}function Th(e,t,r){for(let n=0;n<4;n++)Ph(e[n],t[n],r);}function Vo(e,t){let r=K(),n=K(),i=K();Mh(i,t[2]),Q(r,t[0],i),Q(n,t[1],i),Kr(e,n),e[31]^=Lh(r)<<7;}function Fh(e,t,r){bt(e[0],$o),bt(e[1],cr),bt(e[2],cr),bt(e[3],$o);for(let n=255;n>=0;--n){let i=r[n/8|0]>>(n&7)&1;Th(e,t,i),qo(t,e),qo(e,e),Th(e,t,i);}}function Ho(e,t){let r=[K(),K(),K(),K()];bt(r[0],Dh),bt(r[1],Ah),bt(r[2],cr),Q(r[3],Dh,Ah),Fh(e,r,t);}function Bh(e){if(e.length!==V.SEED_LENGTH)throw new Error(`ed25519: seed must be ${V.SEED_LENGTH} bytes`);let t=(0, Wr.hash)(e);t[0]&=248,t[31]&=127,t[31]|=64;let r=new Uint8Array(32),n=[K(),K(),K(),K()];Ho(n,t),Vo(r,n);let i=new Uint8Array(64);return i.set(e),i.set(r,32),{publicKey:r,secretKey:i}}V.generateKeyPairFromSeed=Bh;function AE(e){let t=(0, _E.randomBytes)(32,e),r=Bh(t);return (0, Rh.wipe)(t),r}V.generateKeyPair=AE;function OE(e){if(e.length!==V.SECRET_KEY_LENGTH)throw new Error(`ed25519: secret key must be ${V.SECRET_KEY_LENGTH} bytes`);return new Uint8Array(e.subarray(32))}V.extractPublicKeyFromSecretKey=OE;var zo=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 kh(e,t){let r,n,i,s;for(n=63;n>=32;--n){for(r=0,i=n-32,s=n-12;i<s;++i)t[i]+=r-16*t[n]*zo[i-(n-32)],r=Math.floor((t[i]+128)/256),t[i]-=r*256;t[i]+=r,t[n]=0;}for(r=0,i=0;i<32;i++)t[i]+=r-(t[31]>>4)*zo[i],r=t[i]>>8,t[i]&=255;for(i=0;i<32;i++)t[i]-=r*zo[i];for(n=0;n<32;n++)t[n+1]+=t[n]>>8,e[n]=t[n]&255;}function Go(e){let t=new Float64Array(64);for(let r=0;r<64;r++)t[r]=e[r];for(let r=0;r<64;r++)e[r]=0;kh(e,t);}function TE(e,t){let r=new Float64Array(64),n=[K(),K(),K(),K()],i=(0, Wr.hash)(e.subarray(0,32));i[0]&=248,i[31]&=127,i[31]|=64;let s=new Uint8Array(64);s.set(i.subarray(32),32);let o=new Wr.SHA512;o.update(s.subarray(32)),o.update(t);let a=o.digest();o.clean(),Go(a),Ho(n,a),Vo(s,n),o.reset(),o.update(s.subarray(0,32)),o.update(e.subarray(32)),o.update(t);let c=o.digest();Go(c);for(let h=0;h<32;h++)r[h]=a[h];for(let h=0;h<32;h++)for(let l=0;l<32;l++)r[h+l]+=c[h]*i[l];return kh(s.subarray(32),r),s}V.sign=TE;function Uh(e,t){let r=K(),n=K(),i=K(),s=K(),o=K(),a=K(),c=K();return bt(e[2],cr),IE(e[1],t),kt(i,e[1]),Q(s,i,vE),Ut(i,i,e[2]),Bt(s,e[2],s),kt(o,s),kt(a,o),Q(c,a,o),Q(r,c,i),Q(r,r,s),DE(r,r),Q(r,r,i),Q(r,r,s),Q(r,r,s),Q(e[0],r,s),kt(n,e[0]),Q(n,n,s),Oh(n,i)&&Q(e[0],e[0],CE),kt(n,e[0]),Q(n,n,s),Oh(n,i)?-1:(Lh(e[0])===t[31]>>7&&Ut(e[0],$o,e[0]),Q(e[3],e[0],e[1]),0)}function RE(e,t,r){let n=new Uint8Array(32),i=[K(),K(),K(),K()],s=[K(),K(),K(),K()];if(r.length!==V.SIGNATURE_LENGTH)throw new Error(`ed25519: signature must be ${V.SIGNATURE_LENGTH} bytes`);if(Uh(s,e))return !1;let o=new Wr.SHA512;o.update(r.subarray(0,32)),o.update(e),o.update(t);let a=o.digest();return Go(a),Fh(i,s,a),Ho(s,r.subarray(32)),qo(i,s),Vo(n,i),!Nh(r,n)}V.verify=RE;function PE(e){let t=[K(),K(),K(),K()];if(Uh(t,e))throw new Error("Ed25519: invalid public key");let r=K(),n=K(),i=t[1];Bt(r,cr,i),Ut(n,cr,i),Mh(n,n),Q(r,r,n);let s=new Uint8Array(32);return Kr(s,r),s}V.convertPublicKeyToX25519=PE;function NE(e){let t=(0, Wr.hash)(e.subarray(0,32));t[0]&=248,t[31]&=127,t[31]|=64;let r=new Uint8Array(t.subarray(0,32));return (0, Rh.wipe)(t),r}V.convertSecretKeyToX25519=NE;});var Od=B(Et=>{d();Object.defineProperty(Et,"__esModule",{value:!0});Et.isBrowserCryptoAvailable=Et.getSubtleCrypto=Et.getBrowerCrypto=void 0;function xa(){return (global==null?void 0:global.crypto)||(global==null?void 0:global.msCrypto)||{}}Et.getBrowerCrypto=xa;function Ad(){let e=xa();return e.subtle||e.webkitSubtle}Et.getSubtleCrypto=Ad;function Xv(){return !!xa()&&!!Ad()}Et.isBrowserCryptoAvailable=Xv;});var Pd=B(vt=>{d();Object.defineProperty(vt,"__esModule",{value:!0});vt.isBrowser=vt.isNode=vt.isReactNative=void 0;function Td(){return typeof document=="undefined"&&typeof navigator!="undefined"&&navigator.product==="ReactNative"}vt.isReactNative=Td;function Rd(){return typeof process!="undefined"&&typeof process.versions!="undefined"&&typeof process.versions.node!="undefined"}vt.isNode=Rd;function Qv(){return !Td()&&!Rd()}vt.isBrowser=Qv;});var Ca=B(Ti=>{d();Object.defineProperty(Ti,"__esModule",{value:!0});var Nd=(Zt(),Ar(Qt));Nd.__exportStar(Od(),Ti);Nd.__exportStar(Pd(),Ti);});var zt=B((sL,kd)=>{d();kd.exports={BINARY_TYPES:["nodebuffer","arraybuffer","fragments"],GUID:"258EAFA5-E914-47DA-95CA-C5AB0DC85B11",kStatusCode:Symbol("status-code"),kWebSocket:Symbol("websocket"),EMPTY_BUFFER:Buffer.alloc(0),NOOP:()=>{}};});var ep=B((aL,Zd)=>{d();var jd=z("fs"),ft=z("path"),zd=z("os"),$d=typeof __webpack_require__=="function"?__non_webpack_require__:z,cx=process.config&&process.config.variables||{},lx=!!process.env.PREBUILDS_ONLY,Ud=process.versions.modules,Ta=hx()?"electron":fx()?"node-webkit":"node",Ra=process.env.npm_config_arch||zd.arch(),Pa=process.env.npm_config_platform||zd.platform(),qd=process.env.LIBC||(dx(Pa)?"musl":"glibc"),Na=process.env.ARM_VERSION||(Ra==="arm64"?"8":cx.arm_version)||"",Gd=(process.versions.uv||"").split(".")[0];Zd.exports=rt;function rt(e){return $d(rt.resolve(e))}rt.resolve=rt.path=function(e){e=ft.resolve(e||".");try{var t=$d(ft.join(e,"package.json")).name.toUpperCase().replace(/-/g,"_");process.env[t+"_PREBUILD"]&&(e=process.env[t+"_PREBUILD"]);}catch(c){}if(!lx){var r=Wd(ft.join(e,"build/Release"),Kd);if(r)return r;var n=Wd(ft.join(e,"build/Debug"),Kd);if(n)return n}var i=a(e);if(i)return i;var s=a(ft.dirname(process.execPath));if(s)return s;var o=["platform="+Pa,"arch="+Ra,"runtime="+Ta,"abi="+Ud,"uv="+Gd,Na?"armv="+Na:"","libc="+qd,"node="+process.versions.node,process.versions.electron?"electron="+process.versions.electron:"",typeof __webpack_require__=="function"?"webpack=true":""].filter(Boolean).join(" ");throw new Error("No native build was found for "+o+`
130
+ loaded from: `+e+`
131
+ `);function a(c){var h=La(ft.join(c,"prebuilds")).map(Vd),l=h.filter(Hd(Pa,Ra)).sort(Jd)[0];if(l){var f=ft.join(c,"prebuilds",l.name),m=La(f).map(Yd),p=m.filter(Xd(Ta,Ud)),u=p.sort(Qd(Ta))[0];if(u)return ft.join(f,u.file)}}};function La(e){try{return jd.readdirSync(e)}catch(t){return []}}function Wd(e,t){var r=La(e).filter(t);return r[0]&&ft.join(e,r[0])}function Kd(e){return /\.node$/.test(e)}function Vd(e){var t=e.split("-");if(t.length===2){var r=t[0],n=t[1].split("+");if(r&&n.length&&n.every(Boolean))return {name:e,platform:r,architectures:n}}}function Hd(e,t){return function(r){return r==null||r.platform!==e?!1:r.architectures.includes(t)}}function Jd(e,t){return e.architectures.length-t.architectures.length}function Yd(e){var t=e.split("."),r=t.pop(),n={file:e,specificity:0};if(r==="node"){for(var i=0;i<t.length;i++){var s=t[i];if(s==="node"||s==="electron"||s==="node-webkit")n.runtime=s;else if(s==="napi")n.napi=!0;else if(s.slice(0,3)==="abi")n.abi=s.slice(3);else if(s.slice(0,2)==="uv")n.uv=s.slice(2);else if(s.slice(0,4)==="armv")n.armv=s.slice(4);else if(s==="glibc"||s==="musl")n.libc=s;else continue;n.specificity++;}return n}}function Xd(e,t){return function(r){return !(r==null||r.runtime&&r.runtime!==e&&!ux(r)||r.abi&&r.abi!==t&&!r.napi||r.uv&&r.uv!==Gd||r.armv&&r.armv!==Na||r.libc&&r.libc!==qd)}}function ux(e){return e.runtime==="node"&&e.napi}function Qd(e){return function(t,r){return t.runtime!==r.runtime?t.runtime===e?-1:1:t.abi!==r.abi?t.abi?-1:1:t.specificity!==r.specificity?t.specificity>r.specificity?-1:1:0}}function fx(){return !!(process.versions&&process.versions.nw)}function hx(){return process.versions&&process.versions.electron||process.env.ELECTRON_RUN_AS_NODE?!0:typeof window!="undefined"&&window.process&&window.process.type==="renderer"}function dx(e){return e==="linux"&&jd.existsSync("/etc/alpine-release")}rt.parseTags=Yd;rt.matchTags=Xd;rt.compareTags=Qd;rt.parseTuple=Vd;rt.matchTuple=Hd;rt.compareTuples=Jd;});var Ba=B((uL,Fa)=>{d();var Ma=typeof __webpack_require__=="function"?__non_webpack_require__:z;typeof Ma.addon=="function"?Fa.exports=Ma.addon.bind(Ma):Fa.exports=ep();});var rp=B((dL,tp)=>{d();var px=(e,t,r,n,i)=>{for(var s=0;s<i;s++)r[n+s]=e[s]^t[s&3];},gx=(e,t)=>{let r=e.length;for(var n=0;n<r;n++)e[n]^=t[n&3];};tp.exports={mask:px,unmask:gx};});var np=B((gL,ka)=>{d();try{ka.exports=Ba()(__dirname);}catch(e){ka.exports=rp();}});var tn=B((yL,Ua)=>{d();var{EMPTY_BUFFER:mx}=zt();function ip(e,t){if(e.length===0)return mx;if(e.length===1)return e[0];let r=Buffer.allocUnsafe(t),n=0;for(let i=0;i<e.length;i++){let s=e[i];r.set(s,n),n+=s.length;}return n<t?r.slice(0,n):r}function sp(e,t,r,n,i){for(let s=0;s<i;s++)r[n+s]=e[s]^t[s&3];}function op(e,t){let r=e.length;for(let n=0;n<r;n++)e[n]^=t[n&3];}function ap(e){return e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}function Ui(e){if(Ui.readOnly=!0,Buffer.isBuffer(e))return e;let t;return e instanceof ArrayBuffer?t=Buffer.from(e):ArrayBuffer.isView(e)?t=Buffer.from(e.buffer,e.byteOffset,e.byteLength):(t=Buffer.from(e),Ui.readOnly=!1),t}try{let e=np(),t=e.BufferUtil||e;Ua.exports={concat:ip,mask(r,n,i,s,o){o<48?sp(r,n,i,s,o):t.mask(r,n,i,s,o);},toArrayBuffer:ap,toBuffer:Ui,unmask(r,n){r.length<32?op(r,n):t.unmask(r,n);}};}catch(e){Ua.exports={concat:ip,mask:sp,toArrayBuffer:ap,toBuffer:Ui,unmask:op};}});var up=B((bL,lp)=>{d();var cp=Symbol("kDone"),Wa=Symbol("kRun"),Ka=class{constructor(t){this[cp]=()=>{this.pending--,this[Wa]();},this.concurrency=t||1/0,this.jobs=[],this.pending=0;}add(t){this.jobs.push(t),this[Wa]();}[Wa](){if(this.pending!==this.concurrency&&this.jobs.length){let t=this.jobs.shift();this.pending++,t(this[cp]);}}};lp.exports=Ka;});var sn=B((_L,pp)=>{d();var rn=z("zlib"),fp=tn(),yx=up(),{kStatusCode:hp,NOOP:wx}=zt(),bx=Buffer.from([0,0,255,255]),ji=Symbol("permessage-deflate"),ht=Symbol("total-length"),nn=Symbol("callback"),xt=Symbol("buffers"),Ki=Symbol("error"),Wi,ja=class{constructor(t,r,n){if(this._maxPayload=n|0,this._options=t||{},this._threshold=this._options.threshold!==void 0?this._options.threshold:1024,this._isServer=!!r,this._deflate=null,this._inflate=null,this.params=null,!Wi){let i=this._options.concurrencyLimit!==void 0?this._options.concurrencyLimit:10;Wi=new yx(i);}}static get extensionName(){return "permessage-deflate"}offer(){let t={};return this._options.serverNoContextTakeover&&(t.server_no_context_takeover=!0),this._options.clientNoContextTakeover&&(t.client_no_context_takeover=!0),this._options.serverMaxWindowBits&&(t.server_max_window_bits=this._options.serverMaxWindowBits),this._options.clientMaxWindowBits?t.client_max_window_bits=this._options.clientMaxWindowBits:this._options.clientMaxWindowBits==null&&(t.client_max_window_bits=!0),t}accept(t){return t=this.normalizeParams(t),this.params=this._isServer?this.acceptAsServer(t):this.acceptAsClient(t),this.params}cleanup(){if(this._inflate&&(this._inflate.close(),this._inflate=null),this._deflate){let t=this._deflate[nn];this._deflate.close(),this._deflate=null,t&&t(new Error("The deflate stream was closed while data was being processed"));}}acceptAsServer(t){let r=this._options,n=t.find(i=>!(r.serverNoContextTakeover===!1&&i.server_no_context_takeover||i.server_max_window_bits&&(r.serverMaxWindowBits===!1||typeof r.serverMaxWindowBits=="number"&&r.serverMaxWindowBits>i.server_max_window_bits)||typeof r.clientMaxWindowBits=="number"&&!i.client_max_window_bits));if(!n)throw new Error("None of the extension offers can be accepted");return r.serverNoContextTakeover&&(n.server_no_context_takeover=!0),r.clientNoContextTakeover&&(n.client_no_context_takeover=!0),typeof r.serverMaxWindowBits=="number"&&(n.server_max_window_bits=r.serverMaxWindowBits),typeof r.clientMaxWindowBits=="number"?n.client_max_window_bits=r.clientMaxWindowBits:(n.client_max_window_bits===!0||r.clientMaxWindowBits===!1)&&delete n.client_max_window_bits,n}acceptAsClient(t){let r=t[0];if(this._options.clientNoContextTakeover===!1&&r.client_no_context_takeover)throw new Error('Unexpected parameter "client_no_context_takeover"');if(!r.client_max_window_bits)typeof this._options.clientMaxWindowBits=="number"&&(r.client_max_window_bits=this._options.clientMaxWindowBits);else if(this._options.clientMaxWindowBits===!1||typeof this._options.clientMaxWindowBits=="number"&&r.client_max_window_bits>this._options.clientMaxWindowBits)throw new Error('Unexpected or invalid parameter "client_max_window_bits"');return r}normalizeParams(t){return t.forEach(r=>{Object.keys(r).forEach(n=>{let i=r[n];if(i.length>1)throw new Error(`Parameter "${n}" must have only a single value`);if(i=i[0],n==="client_max_window_bits"){if(i!==!0){let s=+i;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${n}": ${i}`);i=s;}else if(!this._isServer)throw new TypeError(`Invalid value for parameter "${n}": ${i}`)}else if(n==="server_max_window_bits"){let s=+i;if(!Number.isInteger(s)||s<8||s>15)throw new TypeError(`Invalid value for parameter "${n}": ${i}`);i=s;}else if(n==="client_no_context_takeover"||n==="server_no_context_takeover"){if(i!==!0)throw new TypeError(`Invalid value for parameter "${n}": ${i}`)}else throw new Error(`Unknown parameter "${n}"`);r[n]=i;});}),t}decompress(t,r,n){Wi.add(i=>{this._decompress(t,r,(s,o)=>{i(),n(s,o);});});}compress(t,r,n){Wi.add(i=>{this._compress(t,r,(s,o)=>{i(),n(s,o);});});}_decompress(t,r,n){let i=this._isServer?"client":"server";if(!this._inflate){let s=`${i}_max_window_bits`,o=typeof this.params[s]!="number"?rn.Z_DEFAULT_WINDOWBITS:this.params[s];this._inflate=rn.createInflateRaw(X(M({},this._options.zlibInflateOptions),{windowBits:o})),this._inflate[ji]=this,this._inflate[ht]=0,this._inflate[xt]=[],this._inflate.on("error",_x),this._inflate.on("data",dp);}this._inflate[nn]=n,this._inflate.write(t),r&&this._inflate.write(bx),this._inflate.flush(()=>{let s=this._inflate[Ki];if(s){this._inflate.close(),this._inflate=null,n(s);return}let o=fp.concat(this._inflate[xt],this._inflate[ht]);this._inflate._readableState.endEmitted?(this._inflate.close(),this._inflate=null):(this._inflate[ht]=0,this._inflate[xt]=[],r&&this.params[`${i}_no_context_takeover`]&&this._inflate.reset()),n(null,o);});}_compress(t,r,n){let i=this._isServer?"server":"client";if(!this._deflate){let s=`${i}_max_window_bits`,o=typeof this.params[s]!="number"?rn.Z_DEFAULT_WINDOWBITS:this.params[s];this._deflate=rn.createDeflateRaw(X(M({},this._options.zlibDeflateOptions),{windowBits:o})),this._deflate[ht]=0,this._deflate[xt]=[],this._deflate.on("error",wx),this._deflate.on("data",Sx);}this._deflate[nn]=n,this._deflate.write(t),this._deflate.flush(rn.Z_SYNC_FLUSH,()=>{if(!this._deflate)return;let s=fp.concat(this._deflate[xt],this._deflate[ht]);r&&(s=s.slice(0,s.length-4)),this._deflate[nn]=null,this._deflate[ht]=0,this._deflate[xt]=[],r&&this.params[`${i}_no_context_takeover`]&&this._deflate.reset(),n(null,s);});}};pp.exports=ja;function Sx(e){this[xt].push(e),this[ht]+=e.length;}function dp(e){if(this[ht]+=e.length,this[ji]._maxPayload<1||this[ht]<=this[ji]._maxPayload){this[xt].push(e);return}this[Ki]=new RangeError("Max payload size exceeded"),this[Ki].code="WS_ERR_UNSUPPORTED_MESSAGE_LENGTH",this[Ki][hp]=1009,this.removeListener("data",dp),this.reset();}function _x(e){this[ji]._inflate=null,e[hp]=1007,this[nn](e);}});var mp=B((xL,gp)=>{d();function Ex(e){let t=e.length,r=0;for(;r<t;)if(!(e[r]&128))r++;else if((e[r]&224)===192){if(r+1===t||(e[r+1]&192)!==128||(e[r]&254)===192)return !1;r+=2;}else if((e[r]&240)===224){if(r+2>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||e[r]===224&&(e[r+1]&224)===128||e[r]===237&&(e[r+1]&224)===160)return !1;r+=3;}else if((e[r]&248)===240){if(r+3>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||(e[r+3]&192)!==128||e[r]===240&&(e[r+1]&240)===128||e[r]===244&&e[r+1]>143||e[r]>244)return !1;r+=4;}else return !1;return !0}gp.exports=Ex;});var yp=B((IL,za)=>{d();try{za.exports=Ba()(__dirname);}catch(e){za.exports=mp();}});var qa=B((AL,$a)=>{d();function wp(e){return e>=1e3&&e<=1014&&e!==1004&&e!==1005&&e!==1006||e>=3e3&&e<=4999}function bp(e){let t=e.length,r=0;for(;r<t;)if(!(e[r]&128))r++;else if((e[r]&224)===192){if(r+1===t||(e[r+1]&192)!==128||(e[r]&254)===192)return !1;r+=2;}else if((e[r]&240)===224){if(r+2>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||e[r]===224&&(e[r+1]&224)===128||e[r]===237&&(e[r+1]&224)===160)return !1;r+=3;}else if((e[r]&248)===240){if(r+3>=t||(e[r+1]&192)!==128||(e[r+2]&192)!==128||(e[r+3]&192)!==128||e[r]===240&&(e[r+1]&240)===128||e[r]===244&&e[r+1]>143||e[r]>244)return !1;r+=4;}else return !1;return !0}try{let e=yp();typeof e=="object"&&(e=e.Validation.isValidUTF8),$a.exports={isValidStatusCode:wp,isValidUTF8(t){return t.length<150?bp(t):e(t)}};}catch(e){$a.exports={isValidStatusCode:wp,isValidUTF8:bp};}});var Ja=B((TL,Cp)=>{d();var{Writable:vx}=z("stream"),Sp=sn(),{BINARY_TYPES:xx,EMPTY_BUFFER:Cx,kStatusCode:Ix,kWebSocket:Dx}=zt(),{concat:Ga,toArrayBuffer:Ax,unmask:Ox}=tn(),{isValidStatusCode:Tx,isValidUTF8:_p}=qa(),on=0,Ep=1,vp=2,xp=3,Va=4,Rx=5,Ha=class extends vx{constructor(t,r,n,i){super(),this._binaryType=t||xx[0],this[Dx]=void 0,this._extensions=r||{},this._isServer=!!n,this._maxPayload=i|0,this._bufferedBytes=0,this._buffers=[],this._compressed=!1,this._payloadLength=0,this._mask=void 0,this._fragmented=0,this._masked=!1,this._fin=!1,this._opcode=0,this._totalPayloadLength=0,this._messageLength=0,this._fragments=[],this._state=on,this._loop=!1;}_write(t,r,n){if(this._opcode===8&&this._state==on)return n();this._bufferedBytes+=t.length,this._buffers.push(t),this.startLoop(n);}consume(t){if(this._bufferedBytes-=t,t===this._buffers[0].length)return this._buffers.shift();if(t<this._buffers[0].length){let n=this._buffers[0];return this._buffers[0]=n.slice(t),n.slice(0,t)}let r=Buffer.allocUnsafe(t);do{let n=this._buffers[0],i=r.length-t;t>=n.length?r.set(this._buffers.shift(),i):(r.set(new Uint8Array(n.buffer,n.byteOffset,t),i),this._buffers[0]=n.slice(t)),t-=n.length;}while(t>0);return r}startLoop(t){let r;this._loop=!0;do switch(this._state){case on:r=this.getInfo();break;case Ep:r=this.getPayloadLength16();break;case vp:r=this.getPayloadLength64();break;case xp:this.getMask();break;case Va:r=this.getData(t);break;default:this._loop=!1;return}while(this._loop);t(r);}getInfo(){if(this._bufferedBytes<2){this._loop=!1;return}let t=this.consume(2);if(t[0]&48)return this._loop=!1,ge(RangeError,"RSV2 and RSV3 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_2_3");let r=(t[0]&64)===64;if(r&&!this._extensions[Sp.extensionName])return this._loop=!1,ge(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._fin=(t[0]&128)===128,this._opcode=t[0]&15,this._payloadLength=t[1]&127,this._opcode===0){if(r)return this._loop=!1,ge(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(!this._fragmented)return this._loop=!1,ge(RangeError,"invalid opcode 0",!0,1002,"WS_ERR_INVALID_OPCODE");this._opcode=this._fragmented;}else if(this._opcode===1||this._opcode===2){if(this._fragmented)return this._loop=!1,ge(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");this._compressed=r;}else if(this._opcode>7&&this._opcode<11){if(!this._fin)return this._loop=!1,ge(RangeError,"FIN must be set",!0,1002,"WS_ERR_EXPECTED_FIN");if(r)return this._loop=!1,ge(RangeError,"RSV1 must be clear",!0,1002,"WS_ERR_UNEXPECTED_RSV_1");if(this._payloadLength>125)return this._loop=!1,ge(RangeError,`invalid payload length ${this._payloadLength}`,!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH")}else return this._loop=!1,ge(RangeError,`invalid opcode ${this._opcode}`,!0,1002,"WS_ERR_INVALID_OPCODE");if(!this._fin&&!this._fragmented&&(this._fragmented=this._opcode),this._masked=(t[1]&128)===128,this._isServer){if(!this._masked)return this._loop=!1,ge(RangeError,"MASK must be set",!0,1002,"WS_ERR_EXPECTED_MASK")}else if(this._masked)return this._loop=!1,ge(RangeError,"MASK must be clear",!0,1002,"WS_ERR_UNEXPECTED_MASK");if(this._payloadLength===126)this._state=Ep;else if(this._payloadLength===127)this._state=vp;else return this.haveLength()}getPayloadLength16(){if(this._bufferedBytes<2){this._loop=!1;return}return this._payloadLength=this.consume(2).readUInt16BE(0),this.haveLength()}getPayloadLength64(){if(this._bufferedBytes<8){this._loop=!1;return}let t=this.consume(8),r=t.readUInt32BE(0);return r>Math.pow(2,53-32)-1?(this._loop=!1,ge(RangeError,"Unsupported WebSocket frame: payload length > 2^53 - 1",!1,1009,"WS_ERR_UNSUPPORTED_DATA_PAYLOAD_LENGTH")):(this._payloadLength=r*Math.pow(2,32)+t.readUInt32BE(4),this.haveLength())}haveLength(){if(this._payloadLength&&this._opcode<8&&(this._totalPayloadLength+=this._payloadLength,this._totalPayloadLength>this._maxPayload&&this._maxPayload>0))return this._loop=!1,ge(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH");this._masked?this._state=xp:this._state=Va;}getMask(){if(this._bufferedBytes<4){this._loop=!1;return}this._mask=this.consume(4),this._state=Va;}getData(t){let r=Cx;if(this._payloadLength){if(this._bufferedBytes<this._payloadLength){this._loop=!1;return}r=this.consume(this._payloadLength),this._masked&&Ox(r,this._mask);}if(this._opcode>7)return this.controlMessage(r);if(this._compressed){this._state=Rx,this.decompress(r,t);return}return r.length&&(this._messageLength=this._totalPayloadLength,this._fragments.push(r)),this.dataMessage()}decompress(t,r){this._extensions[Sp.extensionName].decompress(t,this._fin,(i,s)=>{if(i)return r(i);if(s.length){if(this._messageLength+=s.length,this._messageLength>this._maxPayload&&this._maxPayload>0)return r(ge(RangeError,"Max payload size exceeded",!1,1009,"WS_ERR_UNSUPPORTED_MESSAGE_LENGTH"));this._fragments.push(s);}let o=this.dataMessage();if(o)return r(o);this.startLoop(r);});}dataMessage(){if(this._fin){let t=this._messageLength,r=this._fragments;if(this._totalPayloadLength=0,this._messageLength=0,this._fragmented=0,this._fragments=[],this._opcode===2){let n;this._binaryType==="nodebuffer"?n=Ga(r,t):this._binaryType==="arraybuffer"?n=Ax(Ga(r,t)):n=r,this.emit("message",n);}else {let n=Ga(r,t);if(!_p(n))return this._loop=!1,ge(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("message",n.toString());}}this._state=on;}controlMessage(t){if(this._opcode===8)if(this._loop=!1,t.length===0)this.emit("conclude",1005,""),this.end();else {if(t.length===1)return ge(RangeError,"invalid payload length 1",!0,1002,"WS_ERR_INVALID_CONTROL_PAYLOAD_LENGTH");{let r=t.readUInt16BE(0);if(!Tx(r))return ge(RangeError,`invalid status code ${r}`,!0,1002,"WS_ERR_INVALID_CLOSE_CODE");let n=t.slice(2);if(!_p(n))return ge(Error,"invalid UTF-8 sequence",!0,1007,"WS_ERR_INVALID_UTF8");this.emit("conclude",r,n.toString()),this.end();}}else this._opcode===9?this.emit("ping",t):this.emit("pong",t);this._state=on;}};Cp.exports=Ha;function ge(e,t,r,n,i){let s=new e(r?`Invalid WebSocket frame: ${t}`:t);return Error.captureStackTrace(s,ge),s.code=i,s[Ix]=n,s}});var Xa=B((LL,Ap)=>{d();z("net");z("tls");var {randomFillSync:Px}=z("crypto"),Ip=sn(),{EMPTY_BUFFER:Nx}=zt(),{isValidStatusCode:Lx}=qa(),{mask:Dp,toBuffer:dt}=tn(),$t=Buffer.alloc(4),Ya=class e{constructor(t,r){this._extensions=r||{},this._socket=t,this._firstFragment=!0,this._compress=!1,this._bufferedBytes=0,this._deflating=!1,this._queue=[];}static frame(t,r){let n=r.mask&&r.readOnly,i=r.mask?6:2,s=t.length;t.length>=65536?(i+=8,s=127):t.length>125&&(i+=2,s=126);let o=Buffer.allocUnsafe(n?t.length+i:i);return o[0]=r.fin?r.opcode|128:r.opcode,r.rsv1&&(o[0]|=64),o[1]=s,s===126?o.writeUInt16BE(t.length,2):s===127&&(o.writeUInt32BE(0,2),o.writeUInt32BE(t.length,6)),r.mask?(Px($t,0,4),o[1]|=128,o[i-4]=$t[0],o[i-3]=$t[1],o[i-2]=$t[2],o[i-1]=$t[3],n?(Dp(t,$t,o,i,t.length),[o]):(Dp(t,$t,t,0,t.length),[o,t])):[o,t]}close(t,r,n,i){let s;if(t===void 0)s=Nx;else {if(typeof t!="number"||!Lx(t))throw new TypeError("First argument must be a valid error code number");if(r===void 0||r==="")s=Buffer.allocUnsafe(2),s.writeUInt16BE(t,0);else {let o=Buffer.byteLength(r);if(o>123)throw new RangeError("The message must not be greater than 123 bytes");s=Buffer.allocUnsafe(2+o),s.writeUInt16BE(t,0),s.write(r,2);}}this._deflating?this.enqueue([this.doClose,s,n,i]):this.doClose(s,n,i);}doClose(t,r,n){this.sendFrame(e.frame(t,{fin:!0,rsv1:!1,opcode:8,mask:r,readOnly:!1}),n);}ping(t,r,n){let i=dt(t);if(i.length>125)throw new RangeError("The data size must not be greater than 125 bytes");this._deflating?this.enqueue([this.doPing,i,r,dt.readOnly,n]):this.doPing(i,r,dt.readOnly,n);}doPing(t,r,n,i){this.sendFrame(e.frame(t,{fin:!0,rsv1:!1,opcode:9,mask:r,readOnly:n}),i);}pong(t,r,n){let i=dt(t);if(i.length>125)throw new RangeError("The data size must not be greater than 125 bytes");this._deflating?this.enqueue([this.doPong,i,r,dt.readOnly,n]):this.doPong(i,r,dt.readOnly,n);}doPong(t,r,n,i){this.sendFrame(e.frame(t,{fin:!0,rsv1:!1,opcode:10,mask:r,readOnly:n}),i);}send(t,r,n){let i=dt(t),s=this._extensions[Ip.extensionName],o=r.binary?2:1,a=r.compress;if(this._firstFragment?(this._firstFragment=!1,a&&s&&(a=i.length>=s._threshold),this._compress=a):(a=!1,o=0),r.fin&&(this._firstFragment=!0),s){let c={fin:r.fin,rsv1:a,opcode:o,mask:r.mask,readOnly:dt.readOnly};this._deflating?this.enqueue([this.dispatch,i,this._compress,c,n]):this.dispatch(i,this._compress,c,n);}else this.sendFrame(e.frame(i,{fin:r.fin,rsv1:!1,opcode:o,mask:r.mask,readOnly:dt.readOnly}),n);}dispatch(t,r,n,i){if(!r){this.sendFrame(e.frame(t,n),i);return}let s=this._extensions[Ip.extensionName];this._bufferedBytes+=t.length,this._deflating=!0,s.compress(t,n.fin,(o,a)=>{if(this._socket.destroyed){let c=new Error("The socket was closed while data was being compressed");typeof i=="function"&&i(c);for(let h=0;h<this._queue.length;h++){let l=this._queue[h][4];typeof l=="function"&&l(c);}return}this._bufferedBytes-=t.length,this._deflating=!1,n.readOnly=!1,this.sendFrame(e.frame(a,n),i),this.dequeue();});}dequeue(){for(;!this._deflating&&this._queue.length;){let t=this._queue.shift();this._bufferedBytes-=t[1].length,Reflect.apply(t[0],this,t.slice(1));}}enqueue(t){this._bufferedBytes+=t[1].length,this._queue.push(t);}sendFrame(t,r){t.length===2?(this._socket.cork(),this._socket.write(t[0]),this._socket.write(t[1],r),this._socket.uncork()):this._socket.write(t[0],r);}};Ap.exports=Ya;});var Tp=B((FL,Op)=>{d();var br=class{constructor(t,r){this.target=r,this.type=t;}},Qa=class extends br{constructor(t,r){super("message",r),this.data=t;}},Za=class extends br{constructor(t,r,n){super("close",n),this.wasClean=n._closeFrameReceived&&n._closeFrameSent,this.reason=r,this.code=t;}},ec=class extends br{constructor(t){super("open",t);}},tc=class extends br{constructor(t,r){super("error",r),this.message=t.message,this.error=t;}},Mx={addEventListener(e,t,r){if(typeof t!="function")return;function n(c){t.call(this,new Qa(c,this));}function i(c,h){t.call(this,new Za(c,h,this));}function s(c){t.call(this,new tc(c,this));}function o(){t.call(this,new ec(this));}let a=r&&r.once?"once":"on";e==="message"?(n._listener=t,this[a](e,n)):e==="close"?(i._listener=t,this[a](e,i)):e==="error"?(s._listener=t,this[a](e,s)):e==="open"?(o._listener=t,this[a](e,o)):this[a](e,t);},removeEventListener(e,t){let r=this.listeners(e);for(let n=0;n<r.length;n++)(r[n]===t||r[n]._listener===t)&&this.removeListener(e,r[n]);}};Op.exports=Mx;});var rc=B((kL,Rp)=>{d();var an=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,1,1,1,1,1,0,0,1,1,0,1,1,0,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,0,1,0];function nt(e,t,r){e[t]===void 0?e[t]=[r]:e[t].push(r);}function Fx(e){let t=Object.create(null);if(e===void 0||e==="")return t;let r=Object.create(null),n=!1,i=!1,s=!1,o,a,c=-1,h=-1,l=0;for(;l<e.length;l++){let m=e.charCodeAt(l);if(o===void 0)if(h===-1&&an[m]===1)c===-1&&(c=l);else if(m===32||m===9)h===-1&&c!==-1&&(h=l);else if(m===59||m===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${l}`);h===-1&&(h=l);let p=e.slice(c,h);m===44?(nt(t,p,r),r=Object.create(null)):o=p,c=h=-1;}else throw new SyntaxError(`Unexpected character at index ${l}`);else if(a===void 0)if(h===-1&&an[m]===1)c===-1&&(c=l);else if(m===32||m===9)h===-1&&c!==-1&&(h=l);else if(m===59||m===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${l}`);h===-1&&(h=l),nt(r,e.slice(c,h),!0),m===44&&(nt(t,o,r),r=Object.create(null),o=void 0),c=h=-1;}else if(m===61&&c!==-1&&h===-1)a=e.slice(c,l),c=h=-1;else throw new SyntaxError(`Unexpected character at index ${l}`);else if(i){if(an[m]!==1)throw new SyntaxError(`Unexpected character at index ${l}`);c===-1?c=l:n||(n=!0),i=!1;}else if(s)if(an[m]===1)c===-1&&(c=l);else if(m===34&&c!==-1)s=!1,h=l;else if(m===92)i=!0;else throw new SyntaxError(`Unexpected character at index ${l}`);else if(m===34&&e.charCodeAt(l-1)===61)s=!0;else if(h===-1&&an[m]===1)c===-1&&(c=l);else if(c!==-1&&(m===32||m===9))h===-1&&(h=l);else if(m===59||m===44){if(c===-1)throw new SyntaxError(`Unexpected character at index ${l}`);h===-1&&(h=l);let p=e.slice(c,h);n&&(p=p.replace(/\\/g,""),n=!1),nt(r,a,p),m===44&&(nt(t,o,r),r=Object.create(null),o=void 0),a=void 0,c=h=-1;}else throw new SyntaxError(`Unexpected character at index ${l}`)}if(c===-1||s)throw new SyntaxError("Unexpected end of input");h===-1&&(h=l);let f=e.slice(c,h);return o===void 0?nt(t,f,r):(a===void 0?nt(r,f,!0):n?nt(r,a,f.replace(/\\/g,"")):nt(r,a,f),nt(t,o,r)),t}function Bx(e){return Object.keys(e).map(t=>{let r=e[t];return Array.isArray(r)||(r=[r]),r.map(n=>[t].concat(Object.keys(n).map(i=>{let s=n[i];return Array.isArray(s)||(s=[s]),s.map(o=>o===!0?i:`${i}=${o}`).join("; ")})).join("; ")).join(", ")}).join(", ")}Rp.exports={format:Bx,parse:Fx};});var cc=B((KL,Kp)=>{d();var kx=z("events"),Ux=z("https"),Wx=z("http"),Lp=z("net"),Kx=z("tls"),{randomBytes:jx,createHash:zx}=z("crypto");z("stream");var {URL:nc}=z("url"),Ct=sn(),$x=Ja(),qx=Xa(),{BINARY_TYPES:Pp,EMPTY_BUFFER:ic,GUID:Gx,kStatusCode:Vx,kWebSocket:Ce,NOOP:Mp}=zt(),{addEventListener:Hx,removeEventListener:Jx}=Tp(),{format:Yx,parse:Xx}=rc(),{toBuffer:Qx}=tn(),pt=["CONNECTING","OPEN","CLOSING","CLOSED"],sc=[8,13],Zx=30*1e3,fe=class e extends kx{constructor(t,r,n){super(),this._binaryType=Pp[0],this._closeCode=1006,this._closeFrameReceived=!1,this._closeFrameSent=!1,this._closeMessage="",this._closeTimer=null,this._extensions={},this._protocol="",this._readyState=e.CONNECTING,this._receiver=null,this._sender=null,this._socket=null,t!==null?(this._bufferedAmount=0,this._isServer=!1,this._redirects=0,Array.isArray(r)?r=r.join(", "):typeof r=="object"&&r!==null&&(n=r,r=void 0),Fp(this,t,r,n)):this._isServer=!0;}get binaryType(){return this._binaryType}set binaryType(t){Pp.includes(t)&&(this._binaryType=t,this._receiver&&(this._receiver._binaryType=t));}get bufferedAmount(){return this._socket?this._socket._writableState.length+this._sender._bufferedBytes:this._bufferedAmount}get extensions(){return Object.keys(this._extensions).join()}get onclose(){}set onclose(t){}get onerror(){}set onerror(t){}get onopen(){}set onopen(t){}get onmessage(){}set onmessage(t){}get protocol(){return this._protocol}get readyState(){return this._readyState}get url(){return this._url}setSocket(t,r,n){let i=new $x(this.binaryType,this._extensions,this._isServer,n);this._sender=new qx(t,this._extensions),this._receiver=i,this._socket=t,i[Ce]=this,t[Ce]=this,i.on("conclude",rC),i.on("drain",nC),i.on("error",iC),i.on("message",sC),i.on("ping",oC),i.on("pong",aC),t.setTimeout(0),t.setNoDelay(),r.length>0&&t.unshift(r),t.on("close",kp),t.on("data",zi),t.on("end",Up),t.on("error",Wp),this._readyState=e.OPEN,this.emit("open");}emitClose(){if(!this._socket){this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage);return}this._extensions[Ct.extensionName]&&this._extensions[Ct.extensionName].cleanup(),this._receiver.removeAllListeners(),this._readyState=e.CLOSED,this.emit("close",this._closeCode,this._closeMessage);}close(t,r){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){let n="WebSocket was closed before the connection was established";return Ke(this,this._req,n)}if(this.readyState===e.CLOSING){this._closeFrameSent&&(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end();return}this._readyState=e.CLOSING,this._sender.close(t,r,!this._isServer,n=>{n||(this._closeFrameSent=!0,(this._closeFrameReceived||this._receiver._writableState.errorEmitted)&&this._socket.end());}),this._closeTimer=setTimeout(this._socket.destroy.bind(this._socket),Zx);}}ping(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(n=t,t=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){ac(this,t,n);return}r===void 0&&(r=!this._isServer),this._sender.ping(t||ic,r,n);}pong(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof t=="function"?(n=t,t=r=void 0):typeof r=="function"&&(n=r,r=void 0),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){ac(this,t,n);return}r===void 0&&(r=!this._isServer),this._sender.pong(t||ic,r,n);}send(t,r,n){if(this.readyState===e.CONNECTING)throw new Error("WebSocket is not open: readyState 0 (CONNECTING)");if(typeof r=="function"&&(n=r,r={}),typeof t=="number"&&(t=t.toString()),this.readyState!==e.OPEN){ac(this,t,n);return}let i=M({binary:typeof t!="string",mask:!this._isServer,compress:!0,fin:!0},r);this._extensions[Ct.extensionName]||(i.compress=!1),this._sender.send(t||ic,i,n);}terminate(){if(this.readyState!==e.CLOSED){if(this.readyState===e.CONNECTING){let t="WebSocket was closed before the connection was established";return Ke(this,this._req,t)}this._socket&&(this._readyState=e.CLOSING,this._socket.destroy());}}};Object.defineProperty(fe,"CONNECTING",{enumerable:!0,value:pt.indexOf("CONNECTING")});Object.defineProperty(fe.prototype,"CONNECTING",{enumerable:!0,value:pt.indexOf("CONNECTING")});Object.defineProperty(fe,"OPEN",{enumerable:!0,value:pt.indexOf("OPEN")});Object.defineProperty(fe.prototype,"OPEN",{enumerable:!0,value:pt.indexOf("OPEN")});Object.defineProperty(fe,"CLOSING",{enumerable:!0,value:pt.indexOf("CLOSING")});Object.defineProperty(fe.prototype,"CLOSING",{enumerable:!0,value:pt.indexOf("CLOSING")});Object.defineProperty(fe,"CLOSED",{enumerable:!0,value:pt.indexOf("CLOSED")});Object.defineProperty(fe.prototype,"CLOSED",{enumerable:!0,value:pt.indexOf("CLOSED")});["binaryType","bufferedAmount","extensions","protocol","readyState","url"].forEach(e=>{Object.defineProperty(fe.prototype,e,{enumerable:!0});});["open","error","close","message"].forEach(e=>{Object.defineProperty(fe.prototype,`on${e}`,{enumerable:!0,get(){let t=this.listeners(e);for(let r=0;r<t.length;r++)if(t[r]._listener)return t[r]._listener},set(t){let r=this.listeners(e);for(let n=0;n<r.length;n++)r[n]._listener&&this.removeListener(e,r[n]);this.addEventListener(e,t);}});});fe.prototype.addEventListener=Hx;fe.prototype.removeEventListener=Jx;Kp.exports=fe;function Fp(e,t,r,n){let i=X(M({protocolVersion:sc[1],maxPayload:104857600,perMessageDeflate:!0,followRedirects:!1,maxRedirects:10},n),{createConnection:void 0,socketPath:void 0,hostname:void 0,protocol:void 0,timeout:void 0,method:void 0,host:void 0,path:void 0,port:void 0});if(!sc.includes(i.protocolVersion))throw new RangeError(`Unsupported protocol version: ${i.protocolVersion} (supported versions: ${sc.join(", ")})`);let s;t instanceof nc?(s=t,e._url=t.href):(s=new nc(t),e._url=t);let o=s.protocol==="ws+unix:";if(!s.host&&(!o||!s.pathname)){let p=new Error(`Invalid URL: ${e.url}`);if(e._redirects===0)throw p;oc(e,p);return}let a=s.protocol==="wss:"||s.protocol==="https:",c=a?443:80,h=jx(16).toString("base64"),l=a?Ux.get:Wx.get,f;if(i.createConnection=a?tC:eC,i.defaultPort=i.defaultPort||c,i.port=s.port||c,i.host=s.hostname.startsWith("[")?s.hostname.slice(1,-1):s.hostname,i.headers=M({"Sec-WebSocket-Version":i.protocolVersion,"Sec-WebSocket-Key":h,Connection:"Upgrade",Upgrade:"websocket"},i.headers),i.path=s.pathname+s.search,i.timeout=i.handshakeTimeout,i.perMessageDeflate&&(f=new Ct(i.perMessageDeflate!==!0?i.perMessageDeflate:{},!1,i.maxPayload),i.headers["Sec-WebSocket-Extensions"]=Yx({[Ct.extensionName]:f.offer()})),r&&(i.headers["Sec-WebSocket-Protocol"]=r),i.origin&&(i.protocolVersion<13?i.headers["Sec-WebSocket-Origin"]=i.origin:i.headers.Origin=i.origin),(s.username||s.password)&&(i.auth=`${s.username}:${s.password}`),o){let p=i.path.split(":");i.socketPath=p[0],i.path=p[1];}if(i.followRedirects){if(e._redirects===0){e._originalUnixSocket=o,e._originalSecure=a,e._originalHostOrSocketPath=o?i.socketPath:s.host;let p=n&&n.headers;if(n=X(M({},n),{headers:{}}),p)for(let[u,y]of Object.entries(p))n.headers[u.toLowerCase()]=y;}else {let p=o?e._originalUnixSocket?i.socketPath===e._originalHostOrSocketPath:!1:e._originalUnixSocket?!1:s.host===e._originalHostOrSocketPath;(!p||e._originalSecure&&!a)&&(delete i.headers.authorization,delete i.headers.cookie,p||delete i.headers.host,i.auth=void 0);}i.auth&&!n.headers.authorization&&(n.headers.authorization="Basic "+Buffer.from(i.auth).toString("base64"));}let m=e._req=l(i);i.timeout&&m.on("timeout",()=>{Ke(e,m,"Opening handshake has timed out");}),m.on("error",p=>{m===null||m.aborted||(m=e._req=null,oc(e,p));}),m.on("response",p=>{let u=p.headers.location,y=p.statusCode;if(u&&i.followRedirects&&y>=300&&y<400){if(++e._redirects>i.maxRedirects){Ke(e,m,"Maximum redirects exceeded");return}m.abort();let w;try{w=new nc(u,t);}catch(S){oc(e,S);return}Fp(e,w,r,n);}else e.emit("unexpected-response",m,p)||Ke(e,m,`Unexpected server response: ${p.statusCode}`);}),m.on("upgrade",(p,u,y)=>{if(e.emit("upgrade",p),e.readyState!==fe.CONNECTING)return;if(m=e._req=null,p.headers.upgrade.toLowerCase()!=="websocket"){Ke(e,u,"Invalid Upgrade header");return}let w=zx("sha1").update(h+Gx).digest("base64");if(p.headers["sec-websocket-accept"]!==w){Ke(e,u,"Invalid Sec-WebSocket-Accept header");return}let S=p.headers["sec-websocket-protocol"],b=(r||"").split(/, */),_;if(!r&&S?_="Server sent a subprotocol but none was requested":r&&!S?_="Server sent no subprotocol":S&&!b.includes(S)&&(_="Server sent an invalid subprotocol"),_){Ke(e,u,_);return}S&&(e._protocol=S);let x=p.headers["sec-websocket-extensions"];if(x!==void 0){if(!f){Ke(e,u,"Server sent a Sec-WebSocket-Extensions header but no extension was requested");return}let O;try{O=Xx(x);}catch(E){Ke(e,u,"Invalid Sec-WebSocket-Extensions header");return}let L=Object.keys(O);if(L.length){if(L.length!==1||L[0]!==Ct.extensionName){Ke(e,u,"Server indicated an extension that was not requested");return}try{f.accept(O[Ct.extensionName]);}catch(E){Ke(e,u,"Invalid Sec-WebSocket-Extensions header");return}e._extensions[Ct.extensionName]=f;}}e.setSocket(u,y,i.maxPayload);});}function oc(e,t){e._readyState=fe.CLOSING,e.emit("error",t),e.emitClose();}function eC(e){return e.path=e.socketPath,Lp.connect(e)}function tC(e){return e.path=void 0,!e.servername&&e.servername!==""&&(e.servername=Lp.isIP(e.host)?"":e.host),Kx.connect(e)}function Ke(e,t,r){e._readyState=fe.CLOSING;let n=new Error(r);Error.captureStackTrace(n,Ke),t.setHeader?(t.abort(),t.socket&&!t.socket.destroyed&&t.socket.destroy(),t.once("abort",e.emitClose.bind(e)),e.emit("error",n)):(t.destroy(n),t.once("error",e.emit.bind(e,"error")),t.once("close",e.emitClose.bind(e)));}function ac(e,t,r){if(t){let n=Qx(t).length;e._socket?e._sender._bufferedBytes+=n:e._bufferedAmount+=n;}if(r){let n=new Error(`WebSocket is not open: readyState ${e.readyState} (${pt[e.readyState]})`);r(n);}}function rC(e,t){let r=this[Ce];r._closeFrameReceived=!0,r._closeMessage=t,r._closeCode=e,r._socket[Ce]!==void 0&&(r._socket.removeListener("data",zi),process.nextTick(Bp,r._socket),e===1005?r.close():r.close(e,t));}function nC(){this[Ce]._socket.resume();}function iC(e){let t=this[Ce];t._socket[Ce]!==void 0&&(t._socket.removeListener("data",zi),process.nextTick(Bp,t._socket),t.close(e[Vx])),t.emit("error",e);}function Np(){this[Ce].emitClose();}function sC(e){this[Ce].emit("message",e);}function oC(e){let t=this[Ce];t.pong(e,!t._isServer,Mp),t.emit("ping",e);}function aC(e){this[Ce].emit("pong",e);}function Bp(e){e.resume();}function kp(){let e=this[Ce];this.removeListener("close",kp),this.removeListener("data",zi),this.removeListener("end",Up),e._readyState=fe.CLOSING;let t;!this._readableState.endEmitted&&!e._closeFrameReceived&&!e._receiver._writableState.errorEmitted&&(t=e._socket.read())!==null&&e._receiver.write(t),e._receiver.end(),this[Ce]=void 0,clearTimeout(e._closeTimer),e._receiver._writableState.finished||e._receiver._writableState.errorEmitted?e.emitClose():(e._receiver.on("error",Np),e._receiver.on("finish",Np));}function zi(e){this[Ce]._receiver.write(e)||this.pause();}function Up(){let e=this[Ce];e._readyState=fe.CLOSING,e._receiver.end(),this.end();}function Wp(){let e=this[Ce];this.removeListener("error",Wp),this.on("error",Mp),e&&(e._readyState=fe.CLOSING,this.destroy());}});var qp=B(($L,$p)=>{d();var{Duplex:cC}=z("stream");function jp(e){e.emit("close");}function lC(){!this.destroyed&&this._writableState.finished&&this.destroy();}function zp(e){this.removeListener("error",zp),this.destroy(),this.listenerCount("error")===0&&this.emit("error",e);}function uC(e,t){let r=!0,n=!0;function i(){r&&e._socket.resume();}e.readyState===e.CONNECTING?e.once("open",function(){e._receiver.removeAllListeners("drain"),e._receiver.on("drain",i);}):(e._receiver.removeAllListeners("drain"),e._receiver.on("drain",i));let s=new cC(X(M({},t),{autoDestroy:!1,emitClose:!1,objectMode:!1,writableObjectMode:!1}));return e.on("message",function(a){s.push(a)||(r=!1,e._socket.pause());}),e.once("error",function(a){s.destroyed||(n=!1,s.destroy(a));}),e.once("close",function(){s.destroyed||s.push(null);}),s._destroy=function(o,a){if(e.readyState===e.CLOSED){a(o),process.nextTick(jp,s);return}let c=!1;e.once("error",function(l){c=!0,a(l);}),e.once("close",function(){c||a(o),process.nextTick(jp,s);}),n&&e.terminate();},s._final=function(o){if(e.readyState===e.CONNECTING){e.once("open",function(){s._final(o);});return}e._socket!==null&&(e._socket._writableState.finished?(o(),s._readableState.endEmitted&&s.destroy()):(e._socket.once("finish",function(){o();}),e.close()));},s._read=function(){(e.readyState===e.OPEN||e.readyState===e.CLOSING)&&!r&&(r=!0,e._receiver._writableState.needDrain||e._socket.resume());},s._write=function(o,a,c){if(e.readyState===e.CONNECTING){e.once("open",function(){s._write(o,a,c);});return}e.send(o,c);},s.on("end",lC),s.on("error",zp),s}$p.exports=uC;});var Yp=B((YL,Jp)=>{d();var fC=z("events"),$i=z("http");z("https");z("net");z("tls");var {createHash:hC}=z("crypto"),qt=sn(),dC=cc(),{format:pC,parse:gC}=rc(),{GUID:mC,kWebSocket:yC}=zt(),wC=/^[+/0-9A-Za-z]{22}==$/,Gp=0,Vp=1,Hp=2,uc=class extends fC{constructor(t,r){if(super(),t=M({maxPayload:100*1024*1024,perMessageDeflate:!1,handleProtocols:null,clientTracking:!0,verifyClient:null,noServer:!1,backlog:null,server:null,host:null,path:null,port:null},t),t.port==null&&!t.server&&!t.noServer||t.port!=null&&(t.server||t.noServer)||t.server&&t.noServer)throw new TypeError('One and only one of the "port", "server", or "noServer" options must be specified');if(t.port!=null?(this._server=$i.createServer((n,i)=>{let s=$i.STATUS_CODES[426];i.writeHead(426,{"Content-Length":s.length,"Content-Type":"text/plain"}),i.end(s);}),this._server.listen(t.port,t.host,t.backlog,r)):t.server&&(this._server=t.server),this._server){let n=this.emit.bind(this,"connection");this._removeListeners=bC(this._server,{listening:this.emit.bind(this,"listening"),error:this.emit.bind(this,"error"),upgrade:(i,s,o)=>{this.handleUpgrade(i,s,o,n);}});}t.perMessageDeflate===!0&&(t.perMessageDeflate={}),t.clientTracking&&(this.clients=new Set),this.options=t,this._state=Gp;}address(){if(this.options.noServer)throw new Error('The server is operating in "noServer" mode');return this._server?this._server.address():null}close(t){if(t&&this.once("close",t),this._state===Hp){process.nextTick(lc,this);return}if(this._state===Vp)return;if(this._state=Vp,this.clients)for(let n of this.clients)n.terminate();let r=this._server;if(r&&(this._removeListeners(),this._removeListeners=this._server=null,this.options.port!=null)){r.close(lc.bind(void 0,this));return}process.nextTick(lc,this);}shouldHandle(t){if(this.options.path){let r=t.url.indexOf("?");if((r!==-1?t.url.slice(0,r):t.url)!==this.options.path)return !1}return !0}handleUpgrade(t,r,n,i){r.on("error",fc);let s=t.headers["sec-websocket-key"]!==void 0?t.headers["sec-websocket-key"].trim():!1,o=+t.headers["sec-websocket-version"],a={};if(t.method!=="GET"||t.headers.upgrade.toLowerCase()!=="websocket"||!s||!wC.test(s)||o!==8&&o!==13||!this.shouldHandle(t))return cn(r,400);if(this.options.perMessageDeflate){let c=new qt(this.options.perMessageDeflate,!0,this.options.maxPayload);try{let h=gC(t.headers["sec-websocket-extensions"]);h[qt.extensionName]&&(c.accept(h[qt.extensionName]),a[qt.extensionName]=c);}catch(h){return cn(r,400)}}if(this.options.verifyClient){let c={origin:t.headers[`${o===8?"sec-websocket-origin":"origin"}`],secure:!!(t.socket.authorized||t.socket.encrypted),req:t};if(this.options.verifyClient.length===2){this.options.verifyClient(c,(h,l,f,m)=>{if(!h)return cn(r,l||401,f,m);this.completeUpgrade(s,a,t,r,n,i);});return}if(!this.options.verifyClient(c))return cn(r,401)}this.completeUpgrade(s,a,t,r,n,i);}completeUpgrade(t,r,n,i,s,o){if(!i.readable||!i.writable)return i.destroy();if(i[yC])throw new Error("server.handleUpgrade() was called more than once with the same socket, possibly due to a misconfiguration");if(this._state>Gp)return cn(i,503);let c=["HTTP/1.1 101 Switching Protocols","Upgrade: websocket","Connection: Upgrade",`Sec-WebSocket-Accept: ${hC("sha1").update(t+mC).digest("base64")}`],h=new dC(null),l=n.headers["sec-websocket-protocol"];if(l&&(l=l.split(",").map(SC),this.options.handleProtocols?l=this.options.handleProtocols(l,n):l=l[0],l&&(c.push(`Sec-WebSocket-Protocol: ${l}`),h._protocol=l)),r[qt.extensionName]){let f=r[qt.extensionName].params,m=pC({[qt.extensionName]:[f]});c.push(`Sec-WebSocket-Extensions: ${m}`),h._extensions=r;}this.emit("headers",c,n),i.write(c.concat(`\r
132
+ `).join(`\r
133
+ `)),i.removeListener("error",fc),h.setSocket(i,s,this.options.maxPayload),this.clients&&(this.clients.add(h),h.on("close",()=>this.clients.delete(h))),o(h,n);}};Jp.exports=uc;function bC(e,t){for(let r of Object.keys(t))e.on(r,t[r]);return function(){for(let n of Object.keys(t))e.removeListener(n,t[n]);}}function lc(e){e._state=Hp,e.emit("close");}function fc(){this.destroy();}function cn(e,t,r,n){e.writable&&(r=r||$i.STATUS_CODES[t],n=M({Connection:"close","Content-Type":"text/html","Content-Length":Buffer.byteLength(r)},n),e.write(`HTTP/1.1 ${t} ${$i.STATUS_CODES[t]}\r
134
+ `+Object.keys(n).map(i=>`${i}: ${n[i]}`).join(`\r
135
+ `)+`\r
136
+ \r
137
+ `+r)),e.removeListener("error",fc),e.destroy();}function SC(e){return e.trim()}});var Qp=B((ZL,Xp)=>{d();var ln=cc();ln.createWebSocketStream=qp();ln.Server=Yp();ln.Receiver=Ja();ln.Sender=Xa();Xp.exports=ln;});var Mg=B((un,_r)=>{d();var CC=200,Ec="__lodash_hash_undefined__",Zi=1,hg=2,dg=9007199254740991,Gi="[object Arguments]",gc="[object Array]",IC="[object AsyncFunction]",pg="[object Boolean]",gg="[object Date]",mg="[object Error]",yg="[object Function]",DC="[object GeneratorFunction]",Vi="[object Map]",wg="[object Number]",AC="[object Null]",Sr="[object Object]",tg="[object Promise]",OC="[object Proxy]",bg="[object RegExp]",Hi="[object Set]",Sg="[object String]",TC="[object Symbol]",RC="[object Undefined]",mc="[object WeakMap]",_g="[object ArrayBuffer]",Ji="[object DataView]",PC="[object Float32Array]",NC="[object Float64Array]",LC="[object Int8Array]",MC="[object Int16Array]",FC="[object Int32Array]",BC="[object Uint8Array]",kC="[object Uint8ClampedArray]",UC="[object Uint16Array]",WC="[object Uint32Array]",KC=/[\\^$.*+?()[\]{}|]/g,jC=/^\[object .+?Constructor\]$/,zC=/^(?:0|[1-9]\d*)$/,te={};te[PC]=te[NC]=te[LC]=te[MC]=te[FC]=te[BC]=te[kC]=te[UC]=te[WC]=!0;te[Gi]=te[gc]=te[_g]=te[pg]=te[Ji]=te[gg]=te[mg]=te[yg]=te[Vi]=te[wg]=te[Sr]=te[bg]=te[Hi]=te[Sg]=te[mc]=!1;var Eg=typeof global=="object"&&global&&global.Object===Object&&global,$C=typeof self=="object"&&self&&self.Object===Object&&self,gt=Eg||$C||Function("return this")(),vg=typeof un=="object"&&un&&!un.nodeType&&un,rg=vg&&typeof _r=="object"&&_r&&!_r.nodeType&&_r,xg=rg&&rg.exports===vg,hc=xg&&Eg.process,ng=function(){try{return hc&&hc.binding&&hc.binding("util")}catch(e){}}(),ig=ng&&ng.isTypedArray;function qC(e,t){for(var r=-1,n=e==null?0:e.length,i=0,s=[];++r<n;){var o=e[r];t(o,r,e)&&(s[i++]=o);}return s}function GC(e,t){for(var r=-1,n=t.length,i=e.length;++r<n;)e[i+r]=t[r];return e}function VC(e,t){for(var r=-1,n=e==null?0:e.length;++r<n;)if(t(e[r],r,e))return !0;return !1}function HC(e,t){for(var r=-1,n=Array(e);++r<e;)n[r]=t(r);return n}function JC(e){return function(t){return e(t)}}function YC(e,t){return e.has(t)}function XC(e,t){return e==null?void 0:e[t]}function QC(e){var t=-1,r=Array(e.size);return e.forEach(function(n,i){r[++t]=[i,n];}),r}function ZC(e,t){return function(r){return e(t(r))}}function e1(e){var t=-1,r=Array(e.size);return e.forEach(function(n){r[++t]=n;}),r}var t1=Array.prototype,r1=Function.prototype,es=Object.prototype,dc=gt["__core-js_shared__"],Cg=r1.toString,it=es.hasOwnProperty,sg=function(){var e=/[^.]+$/.exec(dc&&dc.keys&&dc.keys.IE_PROTO||"");return e?"Symbol(src)_1."+e:""}(),Ig=es.toString,n1=RegExp("^"+Cg.call(it).replace(KC,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),og=xg?gt.Buffer:void 0,Yi=gt.Symbol,ag=gt.Uint8Array,Dg=es.propertyIsEnumerable,i1=t1.splice,Gt=Yi?Yi.toStringTag:void 0,cg=Object.getOwnPropertySymbols,s1=og?og.isBuffer:void 0,o1=ZC(Object.keys,Object),yc=Er(gt,"DataView"),fn=Er(gt,"Map"),wc=Er(gt,"Promise"),bc=Er(gt,"Set"),Sc=Er(gt,"WeakMap"),hn=Er(Object,"create"),a1=Jt(yc),c1=Jt(fn),l1=Jt(wc),u1=Jt(bc),f1=Jt(Sc),lg=Yi?Yi.prototype:void 0,pc=lg?lg.valueOf:void 0;function Vt(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1]);}}function h1(){this.__data__=hn?hn(null):{},this.size=0;}function d1(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t}function p1(e){var t=this.__data__;if(hn){var r=t[e];return r===Ec?void 0:r}return it.call(t,e)?t[e]:void 0}function g1(e){var t=this.__data__;return hn?t[e]!==void 0:it.call(t,e)}function m1(e,t){var r=this.__data__;return this.size+=this.has(e)?0:1,r[e]=hn&&t===void 0?Ec:t,this}Vt.prototype.clear=h1;Vt.prototype.delete=d1;Vt.prototype.get=p1;Vt.prototype.has=g1;Vt.prototype.set=m1;function mt(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1]);}}function y1(){this.__data__=[],this.size=0;}function w1(e){var t=this.__data__,r=ts(t,e);if(r<0)return !1;var n=t.length-1;return r==n?t.pop():i1.call(t,r,1),--this.size,!0}function b1(e){var t=this.__data__,r=ts(t,e);return r<0?void 0:t[r][1]}function S1(e){return ts(this.__data__,e)>-1}function _1(e,t){var r=this.__data__,n=ts(r,e);return n<0?(++this.size,r.push([e,t])):r[n][1]=t,this}mt.prototype.clear=y1;mt.prototype.delete=w1;mt.prototype.get=b1;mt.prototype.has=S1;mt.prototype.set=_1;function Ht(e){var t=-1,r=e==null?0:e.length;for(this.clear();++t<r;){var n=e[t];this.set(n[0],n[1]);}}function E1(){this.size=0,this.__data__={hash:new Vt,map:new(fn||mt),string:new Vt};}function v1(e){var t=rs(this,e).delete(e);return this.size-=t?1:0,t}function x1(e){return rs(this,e).get(e)}function C1(e){return rs(this,e).has(e)}function I1(e,t){var r=rs(this,e),n=r.size;return r.set(e,t),this.size+=r.size==n?0:1,this}Ht.prototype.clear=E1;Ht.prototype.delete=v1;Ht.prototype.get=x1;Ht.prototype.has=C1;Ht.prototype.set=I1;function Xi(e){var t=-1,r=e==null?0:e.length;for(this.__data__=new Ht;++t<r;)this.add(e[t]);}function D1(e){return this.__data__.set(e,Ec),this}function A1(e){return this.__data__.has(e)}Xi.prototype.add=Xi.prototype.push=D1;Xi.prototype.has=A1;function Dt(e){var t=this.__data__=new mt(e);this.size=t.size;}function O1(){this.__data__=new mt,this.size=0;}function T1(e){var t=this.__data__,r=t.delete(e);return this.size=t.size,r}function R1(e){return this.__data__.get(e)}function P1(e){return this.__data__.has(e)}function N1(e,t){var r=this.__data__;if(r instanceof mt){var n=r.__data__;if(!fn||n.length<CC-1)return n.push([e,t]),this.size=++r.size,this;r=this.__data__=new Ht(n);}return r.set(e,t),this.size=r.size,this}Dt.prototype.clear=O1;Dt.prototype.delete=T1;Dt.prototype.get=R1;Dt.prototype.has=P1;Dt.prototype.set=N1;function L1(e,t){var r=Qi(e),n=!r&&J1(e),i=!r&&!n&&_c(e),s=!r&&!n&&!i&&Lg(e),o=r||n||i||s,a=o?HC(e.length,String):[],c=a.length;for(var h in e)(t||it.call(e,h))&&!(o&&(h=="length"||i&&(h=="offset"||h=="parent")||s&&(h=="buffer"||h=="byteLength"||h=="byteOffset")||$1(h,c)))&&a.push(h);return a}function ts(e,t){for(var r=e.length;r--;)if(Tg(e[r][0],t))return r;return -1}function M1(e,t,r){var n=t(e);return Qi(e)?n:GC(n,r(e))}function pn(e){return e==null?e===void 0?RC:AC:Gt&&Gt in Object(e)?j1(e):H1(e)}function ug(e){return dn(e)&&pn(e)==Gi}function Ag(e,t,r,n,i){return e===t?!0:e==null||t==null||!dn(e)&&!dn(t)?e!==e&&t!==t:F1(e,t,r,n,Ag,i)}function F1(e,t,r,n,i,s){var o=Qi(e),a=Qi(t),c=o?gc:It(e),h=a?gc:It(t);c=c==Gi?Sr:c,h=h==Gi?Sr:h;var l=c==Sr,f=h==Sr,m=c==h;if(m&&_c(e)){if(!_c(t))return !1;o=!0,l=!1;}if(m&&!l)return s||(s=new Dt),o||Lg(e)?Og(e,t,r,n,i,s):W1(e,t,c,r,n,i,s);if(!(r&Zi)){var p=l&&it.call(e,"__wrapped__"),u=f&&it.call(t,"__wrapped__");if(p||u){var y=p?e.value():e,w=u?t.value():t;return s||(s=new Dt),i(y,w,r,n,s)}}return m?(s||(s=new Dt),K1(e,t,r,n,i,s)):!1}function B1(e){if(!Ng(e)||G1(e))return !1;var t=Rg(e)?n1:jC;return t.test(Jt(e))}function k1(e){return dn(e)&&Pg(e.length)&&!!te[pn(e)]}function U1(e){if(!V1(e))return o1(e);var t=[];for(var r in Object(e))it.call(e,r)&&r!="constructor"&&t.push(r);return t}function Og(e,t,r,n,i,s){var o=r&Zi,a=e.length,c=t.length;if(a!=c&&!(o&&c>a))return !1;var h=s.get(e);if(h&&s.get(t))return h==t;var l=-1,f=!0,m=r&hg?new Xi:void 0;for(s.set(e,t),s.set(t,e);++l<a;){var p=e[l],u=t[l];if(n)var y=o?n(u,p,l,t,e,s):n(p,u,l,e,t,s);if(y!==void 0){if(y)continue;f=!1;break}if(m){if(!VC(t,function(w,S){if(!YC(m,S)&&(p===w||i(p,w,r,n,s)))return m.push(S)})){f=!1;break}}else if(!(p===u||i(p,u,r,n,s))){f=!1;break}}return s.delete(e),s.delete(t),f}function W1(e,t,r,n,i,s,o){switch(r){case Ji:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return !1;e=e.buffer,t=t.buffer;case _g:return !(e.byteLength!=t.byteLength||!s(new ag(e),new ag(t)));case pg:case gg:case wg:return Tg(+e,+t);case mg:return e.name==t.name&&e.message==t.message;case bg:case Sg:return e==t+"";case Vi:var a=QC;case Hi:var c=n&Zi;if(a||(a=e1),e.size!=t.size&&!c)return !1;var h=o.get(e);if(h)return h==t;n|=hg,o.set(e,t);var l=Og(a(e),a(t),n,i,s,o);return o.delete(e),l;case TC:if(pc)return pc.call(e)==pc.call(t)}return !1}function K1(e,t,r,n,i,s){var o=r&Zi,a=fg(e),c=a.length,h=fg(t),l=h.length;if(c!=l&&!o)return !1;for(var f=c;f--;){var m=a[f];if(!(o?m in t:it.call(t,m)))return !1}var p=s.get(e);if(p&&s.get(t))return p==t;var u=!0;s.set(e,t),s.set(t,e);for(var y=o;++f<c;){m=a[f];var w=e[m],S=t[m];if(n)var b=o?n(S,w,m,t,e,s):n(w,S,m,e,t,s);if(!(b===void 0?w===S||i(w,S,r,n,s):b)){u=!1;break}y||(y=m=="constructor");}if(u&&!y){var _=e.constructor,x=t.constructor;_!=x&&"constructor"in e&&"constructor"in t&&!(typeof _=="function"&&_ instanceof _&&typeof x=="function"&&x instanceof x)&&(u=!1);}return s.delete(e),s.delete(t),u}function fg(e){return M1(e,Q1,z1)}function rs(e,t){var r=e.__data__;return q1(t)?r[typeof t=="string"?"string":"hash"]:r.map}function Er(e,t){var r=XC(e,t);return B1(r)?r:void 0}function j1(e){var t=it.call(e,Gt),r=e[Gt];try{e[Gt]=void 0;var n=!0;}catch(s){}var i=Ig.call(e);return n&&(t?e[Gt]=r:delete e[Gt]),i}var z1=cg?function(e){return e==null?[]:(e=Object(e),qC(cg(e),function(t){return Dg.call(e,t)}))}:Z1,It=pn;(yc&&It(new yc(new ArrayBuffer(1)))!=Ji||fn&&It(new fn)!=Vi||wc&&It(wc.resolve())!=tg||bc&&It(new bc)!=Hi||Sc&&It(new Sc)!=mc)&&(It=function(e){var t=pn(e),r=t==Sr?e.constructor:void 0,n=r?Jt(r):"";if(n)switch(n){case a1:return Ji;case c1:return Vi;case l1:return tg;case u1:return Hi;case f1:return mc}return t});function $1(e,t){return t=t==null?dg:t,!!t&&(typeof e=="number"||zC.test(e))&&e>-1&&e%1==0&&e<t}function q1(e){var t=typeof e;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?e!=="__proto__":e===null}function G1(e){return !!sg&&sg in e}function V1(e){var t=e&&e.constructor,r=typeof t=="function"&&t.prototype||es;return e===r}function H1(e){return Ig.call(e)}function Jt(e){if(e!=null){try{return Cg.call(e)}catch(t){}try{return e+""}catch(t){}}return ""}function Tg(e,t){return e===t||e!==e&&t!==t}var J1=ug(function(){return arguments}())?ug:function(e){return dn(e)&&it.call(e,"callee")&&!Dg.call(e,"callee")},Qi=Array.isArray;function Y1(e){return e!=null&&Pg(e.length)&&!Rg(e)}var _c=s1||eI;function X1(e,t){return Ag(e,t)}function Rg(e){if(!Ng(e))return !1;var t=pn(e);return t==yg||t==DC||t==IC||t==OC}function Pg(e){return typeof e=="number"&&e>-1&&e%1==0&&e<=dg}function Ng(e){var t=typeof e;return e!=null&&(t=="object"||t=="function")}function dn(e){return e!=null&&typeof e=="object"}var Lg=ig?JC(ig):k1;function Q1(e){return Y1(e)?L1(e):U1(e)}function Z1(){return []}function eI(){return !1}_r.exports=X1;});var Fg=B(ee=>{d();Object.defineProperty(ee,"__esModule",{value:!0});ee.getLocalStorage=ee.getLocalStorageOrThrow=ee.getCrypto=ee.getCryptoOrThrow=ee.getLocation=ee.getLocationOrThrow=ee.getNavigator=ee.getNavigatorOrThrow=ee.getDocument=ee.getDocumentOrThrow=ee.getFromWindowOrThrow=ee.getFromWindow=void 0;function Yt(e){let t;return typeof window!="undefined"&&typeof window[e]!="undefined"&&(t=window[e]),t}ee.getFromWindow=Yt;function vr(e){let t=Yt(e);if(!t)throw new Error(`${e} is not defined in Window`);return t}ee.getFromWindowOrThrow=vr;function tI(){return vr("document")}ee.getDocumentOrThrow=tI;function rI(){return Yt("document")}ee.getDocument=rI;function nI(){return vr("navigator")}ee.getNavigatorOrThrow=nI;function iI(){return Yt("navigator")}ee.getNavigator=iI;function sI(){return vr("location")}ee.getLocationOrThrow=sI;function oI(){return Yt("location")}ee.getLocation=oI;function aI(){return vr("crypto")}ee.getCryptoOrThrow=aI;function cI(){return Yt("crypto")}ee.getCrypto=cI;function lI(){return vr("localStorage")}ee.getLocalStorageOrThrow=lI;function uI(){return Yt("localStorage")}ee.getLocalStorage=uI;});d();d();d();var at="graz-reconnect-session";d();d();var wl=(b=>(b.KEPLR="keplr",b.LEAP="leap",b.VECTIS="vectis",b.COSMOSTATION="cosmostation",b.WALLETCONNECT="walletconnect",b.WC_KEPLR_MOBILE="wc_keplr_mobile",b.WC_LEAP_MOBILE="wc_leap_mobile",b.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",b.WC_CLOT_MOBILE="wc_clot_mobile",b.METAMASK_SNAP_LEAP="metamask_snap_leap",b.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",b.STATION="station",b.XDEFI="xdefi",b.CAPSULE="capsule",b.COSMIFRAME="cosmiframe",b.COMPASS="compass",b.INITIA="initia",b.OKX="okx",b))(wl||{}),bl=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","wc_clot_mobile","metamask_snap_leap","station","xdefi","capsule","metamask_snap_cosmos","cosmiframe","compass","initia","okx"];var by={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,walletConnectModal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},Xt={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},Sy={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},_y={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},k=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>Xt,Sy))),P=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>by,_y)));d();d();var Cn=()=>{var m,p;if(!((m=P.getState().capsuleConfig)!=null&&m.apiKey)||!((p=P.getState().capsuleConfig)!=null&&p.env))throw new Error("Capsule configuration is not set");let e=()=>g(void 0,null,function*(){var w,S;let u=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,y=new u({apiKey:(w=P.getState().capsuleConfig)==null?void 0:w.apiKey,env:(S=P.getState().capsuleConfig)==null?void 0:S.env});return k.setState({capsuleClient:y}),y});return {init:e,enable:u=>g(void 0,null,function*(){let y=typeof u=="string"?[u]:u,w=k.getState().capsuleClient;w||(w=yield e()),P.setState({capsuleState:{showModal:!0,chainId:y}});}),onAfterLoginSuccessful:()=>g(void 0,null,function*(){var b;let u=k.getState().capsuleClient,{chains:y}=P.getState();if(!u)throw new Error("Capsule client is not initialized");if(!y)throw new Error("Chains are not set");yield u.enable();let w=(b=P.getState().capsuleState)==null?void 0:b.chainId;if(!w)throw new Error("Chain ids are not set");let S=Object.fromEntries(yield Promise.all(w.map(_=>g(void 0,null,function*(){let x=yield u.getAccount(_);return [_,{address:encoding.fromBech32(x.address).data,bech32Address:x.address,algo:x.algo,name:x.username||"",pubKey:x.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));k.setState(_=>({accounts:M(M({},_.accounts||{}),S)})),P.setState(_=>({recentChainIds:[..._.recentChainIds||[],...w].filter((x,O,L)=>L.indexOf(x)===O)})),k.setState(_=>({activeChainIds:[..._.activeChainIds||[],...w].filter((x,O,L)=>L.indexOf(x)===O)})),P.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),k.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(at,"Active"),P.setState({capsuleState:null});}),getKey:u=>g(void 0,null,function*(){let y=k.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");let w=yield y.getAccount(u);return {address:encoding.fromBech32(w.address).data,bech32Address:w.address,algo:w.algo,name:w.username||"",pubKey:w.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:u=>g(void 0,null,function*(){let y=k.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.getOfflineSignerDirect(u)}),getOfflineSignerDirect:u=>{let y=k.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.getOfflineSignerDirect(u)},signDirect:(...u)=>g(void 0,null,function*(){let[y,w,S]=u,b=k.getState().capsuleClient;if(!b)throw new Error("Capsule client is not initialized");return b.signDirect(y,w,{bodyBytes:S.bodyBytes,authInfoBytes:S.authInfoBytes,chainId:S.chainId,accountNumber:S.accountNumber})}),signAmino:(...u)=>g(void 0,null,function*(){let[y,w,S,b]=u,_=k.getState().capsuleClient;if(!_)throw new Error("Capsule client is not initialized");return _.signAmino(y,w,S,b)}),signArbitrary:(u,y,w)=>g(void 0,null,function*(){let S=k.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");let b=yield S.getAccount(u);if(!b)throw new Error(`Wallet not connected to account ${y}`);let _=(()=>{switch(b.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(b.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(b.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield S.signArbitrary(u,y,w),pub_key:{type:b.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:_.value}}}),experimentalSuggestChain:(...u)=>g(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:u=>{let y=k.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.getOfflineSigner(u)},getOfflineSignerAmino:u=>{let y=k.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.getOfflineSignerAmino(u)}}};d();var In=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:i=>{let s=()=>{ye(),i();};return window.addEventListener("leap_keystorechange",s),()=>{window.removeEventListener("leap_keystorechange",s);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw P.getState()._notFoundFn(),new Error("window.leap is not defined")};d();var Dn=()=>{let e=P.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!cosmiframe.isInIframe())throw e._notFoundFn(),new Error("not in iframe");if(!e.iframeOptions.allowedIframeParentOrigins.length)throw e._notFoundFn(),new Error("no iframe allowed origins");let t=new cosmiframe.Cosmiframe(e.iframeOptions.allowedIframeParentOrigins).getKeplrClient();return {enable:t.enable.bind(t),getKey:t.getKey.bind(t),getOfflineSigner:t.getOfflineSigner.bind(t),getOfflineSignerAuto:t.getOfflineSignerAuto.bind(t),getOfflineSignerOnlyAmino:t.getOfflineSignerOnlyAmino.bind(t),experimentalSuggestChain:t.experimentalSuggestChain.bind(t),signDirect:t.signDirect.bind(t),signAmino:t.signAmino.bind(t)}};d();var Dl={},Al=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>g(void 0,null,function*(){var l;let s=yield e.request({method:"web3_clientVersion"});if(!s.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let a=(l=s.split("MetaMask/v")[1])==null?void 0:l.split(".")[0];if(!(Number(a)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield snapper.isSnapInstalled())||(yield snapper.installSnap()),window.cosmos=new snapper.CosmosSnap,t=window.cosmos,!0}),enable:s=>g(void 0,null,function*(){(yield snapper.isSnapInstalled())||(yield snapper.installSnap());}),getOfflineSigner:s=>t.getOfflineSigner(s),experimentalSuggestChain:s=>g(void 0,null,function*(){if(!s.bech32Config)throw new Error("Bech32Config is required");if(!s.stakeCurrency)throw new Error("StakeCurrency is required");yield t.experimentalSuggestChain(X(M({},s),{stakeCurrency:s.stakeCurrency,bech32Config:s.bech32Config}));}),signAmino:(s,o,a)=>g(void 0,null,function*(){return t.signAmino(s,o,a)}),getKey:s=>g(void 0,null,function*(){return typeof Dl[s]!="undefined"?Dl[s]:t.getKey(s)}),getOfflineSignerAuto:s=>g(void 0,null,function*(){return (yield t.getKey(s)).isNanoLedger?t.getOfflineSignerOnlyAmino(s):t.getOfflineSigner(s)}),getOfflineSignerOnlyAmino:s=>t.getOfflineSignerOnlyAmino(s),signDirect:(s,o,a)=>g(void 0,null,function*(){return t.signDirect(s,o,a)}),signArbitrary:(s,o,a)=>g(void 0,null,function*(){return t.signArbitrary(s,o,a)}),disable:s=>g(void 0,null,function*(){s&&(yield t.deleteChain(s));})};throw P.getState()._notFoundFn(),new Error("window.ethereum is not defined")};d();var An=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:s=>{let o=()=>{ye(),s();};return window.addEventListener("cosmostation_keystorechange",o),()=>{window.removeEventListener("cosmostation_keystorechange",o);}},setDefaultOptions:s=>{t.defaultOptions=s;}})}throw P.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};d();var Ry=e=>{let{bodyBytes:t,authInfoBytes:r,chainId:n,accountNumber:i}=e;if(!t||!r||!n||!i)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:r,chainId:n,accountNumber:i}},Py=e=>`${e.slice(0,6)}...${e.slice(-6)}`,Tl=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>g(void 0,null,function*(){yield e.getAddress();}),getKey:f=>g(void 0,null,function*(){let m=e.getOfflineSigner(f),[p]=yield m.getAccounts();if(!p)throw new Error("Wallet connection failed");let u=(()=>{switch(p.algo){case"secp256k1":return amino.rawSecp256k1PubkeyToRawAddress(p.pubkey);case"ed25519":return amino.rawEd25519PubkeyToRawAddress(p.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:Py(p.address),algo:p.algo,pubKey:p.pubkey,bech32Address:p.address,address:u,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:f=>{let m=e.getOfflineSigner(f),p=e.getOfflineSignerOnlyAmino(f);return {getAccounts:m.getAccounts.bind(m),signDirect:m.signDirect.bind(m),signAmino:p.signAmino.bind(p)}},getOfflineSignerAuto:f=>Promise.resolve(e.getOfflineSigner(f)),getOfflineSignerOnlyAmino:f=>e.getOfflineSignerOnlyAmino(f),experimentalSuggestChain:f=>e.requestAddInitiaLayer({chain_id:f.chainId,chain_name:f.chainName,bech32_prefix:"init",bech32_config:f.bech32Config,slip44:f.bip44.coinType,logo_URIs:{png:f.chainSymbolImageUrl},fees:{fee_tokens:f.feeCurrencies.map(m=>{var p,u,y;return {denom:m.coinDenom,amount:m.coinMinimalDenom,low_gas_price:(p=m.gasPriceStep)==null?void 0:p.low,average_gas_price:(u=m.gasPriceStep)==null?void 0:u.average,high_gas_price:(y=m.gasPriceStep)==null?void 0:y.high}})},apis:{rpc:[{address:f.rpc}],rest:[{address:f.rest}]}}),signDirect:(...f)=>{let[m,p,u]=f;return e.getOfflineSigner(m).signDirect(p,Ry(u))},signAmino:(...f)=>{let[m,p,u]=f;return e.getOfflineSignerOnlyAmino(m).signAmino(p,u)},signArbitrary:(f,m,p)=>g(void 0,null,function*(){let w=(yield e.getOfflineSigner(f).getAccounts()).find(_=>_.address===m);if(!w)throw new Error(`Wallet not connected to account ${m}`);let S=(()=>{switch(w.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(w.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(w.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(p),pub_key:{type:w.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:S.value}}}),subscription:f=>{let m=()=>{ye(),f();};return window.addEventListener("initia_keystorechange",m),()=>{window.removeEventListener("initia_keystorechange",m);}}}}throw P.getState()._notFoundFn(),new Error("window.initia is not defined")};d();var On=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:i=>{let s=()=>{ye(),i();};return window.addEventListener("keplr_keystorechange",s),()=>{window.removeEventListener("keplr_keystorechange",s);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw P.getState()._notFoundFn(),new Error("window.keplr is not defined")};d();var Tn=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:i=>{let s=()=>{ye(),i();};return window.addEventListener("leap_keystorechange",s),()=>{window.removeEventListener("leap_keystorechange",s);}},setDefaultOptions:i=>{e.defaultOptions=i;}})}throw P.getState()._notFoundFn(),new Error("window.leap is not defined")};d();d();var Rn={},Rl=e=>{let t=window.ethereum;if(t&&e){let r=()=>g(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),n=b=>g(void 0,null,function*(){try{let _=yield r();return Object.values(_).find(x=>x.id===e.id&&(!b||x.version===b))}catch(_){return}}),i=()=>g(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),s=()=>g(void 0,null,function*(){var E;let b=yield t.request({method:"web3_clientVersion"});if(!b.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let x=(E=b.split("MetaMask/v")[1])==null?void 0:E.split(".")[0];if(!(Number(x)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield n())||(yield i()),!0}),o=b=>g(void 0,null,function*(){(yield n())||(yield i());}),a=(b,_,x)=>g(void 0,null,function*(){let O=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:b,signerAddress:_,signDoc:x}}}}),L=x.accountNumber,E=new Fm__default.default(L.low,L.high,L.unsigned);return {signature:O.signature,signed:X(M({},O.signed),{accountNumber:`${E.toString()}`,authInfoBytes:new Uint8Array(Object.values(O.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(O.signed.bodyBytes))})}}),c=(b,_,x)=>g(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:b,signerAddress:_,signDoc:x}}}})}),h=b=>g(void 0,null,function*(){if(typeof Rn[b]!="undefined")return Rn[b];let _=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:b}}}});if(!_)throw new Error("No response from Metamask");return _.pubKey=Uint8Array.from(Object.values(_.pubkey)),delete _.pubkey,Rn[b]=_,Rn[b]}),l=b=>g(void 0,null,function*(){let _=yield h(b);return {address:_.bech32Address,algo:_.algo,pubkey:_.pubKey}}),f=(...b)=>g(void 0,null,function*(){let[_,x,O,L]=b;return yield c(_,x,O)}),m=(...b)=>g(void 0,null,function*(){let[_,x,O]=b;return yield a(_,x,O)}),u=b=>({getAccounts:()=>g(void 0,null,function*(){return [yield l(b)]}),signAmino:(_,x)=>f(b,_,x)});return {enable:o,experimentalSuggestChain:(...b)=>g(void 0,null,function*(){yield s(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:b[0]}}}});}),getKey:h,getOfflineSigner:b=>({getAccounts:()=>g(void 0,null,function*(){return [yield l(b)]}),signDirect:(_,x)=>m(b,_,x),signAmino:(_,x)=>f(b,_,x)}),getOfflineSignerAuto:b=>g(void 0,null,function*(){return u(b)}),getOfflineSignerOnlyAmino:u,init:s,signAmino:f,signDirect:m}}throw P.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var Pl=()=>Rl({id:"npm:@leapwallet/metamask-cosmos-snap"});d();var Pn=()=>{var e;if(typeof((e=window.okxwallet)==null?void 0:e.keplr)!="undefined"){let t=window.okxwallet.keplr;return Object.assign(t,{subscription:s=>{var a;let o=()=>{ye(),s();};return (a=window.okxwallet)==null||a.on("accountsChanged",o),()=>{var c;(c=window.okxwallet)==null||c.removeListener("accountsChanged",o);}},setDefaultOptions:s=>{t.defaultOptions=s;}})}throw P.getState()._notFoundFn(),new Error("window.okxwallet.keplr is not defined")};d();var Nn=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:s=>{let o=()=>{ye(),s();};return window.addEventListener("station_wallet_change",o),()=>{window.removeEventListener("station_wallet_change",o);}},getKey:s=>g(void 0,null,function*(){let o=yield e.getKey(s);return M({isKeystone:!1},o)}),getOfflineSigner:s=>{try{let o=e.getOfflineSignerOnlyAmino(s);return Object.assign(o,{signDirect:(h,l)=>{throw new Error("signDirect not supported by Station")}})}catch(o){throw console.error(o),o}},experimentalSuggestChain:s=>g(void 0,null,function*(){try{if(!s.bech32Config)throw new Error("Bech32Config is required");if(!s.stakeCurrency)throw new Error("StakeCurrency is required");let o=Object.assign(s,{bech32Config:s.bech32Config,chainSymbolImageUrl:s.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:s.stakeCurrency.coinDecimals,coinDenom:s.stakeCurrency.coinDenom,coinImageUrl:s.stakeCurrency.coinImageUrl||"",coinMinimalDenom:s.stakeCurrency.coinMinimalDenom},currencies:s.currencies.map(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:s.feeCurrencies.map(a=>{var c,h,l;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((c=a.gasPriceStep)==null?void 0:c.average)||0,high:((h=a.gasPriceStep)==null?void 0:h.high)||0,low:((l=a.gasPriceStep)==null?void 0:l.low)||0}}})});yield e.experimentalSuggestChain(o);}catch(o){throw console.error(o),o}}),enable:s=>e.enable(s),disable:s=>e.disable(s),getOfflineSignerAuto:s=>e.getOfflineSignerAuto(s),getOfflineSignerOnlyAmino:s=>e.getOfflineSignerOnlyAmino(s),signDirect:()=>e.signDirect(),signAmino:(s,o,a,c)=>e.signAmino(s,o,a)}}throw P.getState()._notFoundFn(),new Error("window.station is not defined")};d();var Ln=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>g(void 0,null,function*(){let c=yield e.getKey(a);return {address:encoding.fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:a=>{let c=()=>{ye(),a();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...a)=>{let c=a[0];return e.getOfflineSignerAmino(c)},experimentalSuggestChain:(...a)=>g(void 0,null,function*(){var l;let[c]=a;if(!c.bech32Config)throw new Error("Bech32Config is required");if(!c.stakeCurrency)throw new Error("StakeCurrency is required");let h={rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:(l=c.bech32Config)==null?void 0:l.bech32PrefixAccAddr,currencies:c.currencies,feeCurrencies:c.feeCurrencies,chainId:c.chainId,chainName:c.chainName,bip44:c.bip44,stakeCurrency:c.stakeCurrency,features:c.features};return e.suggestChains([h])}),signDirect:(...a)=>g(void 0,null,function*(){var l;let{1:c,2:h}=a;return e.signDirect(c,{bodyBytes:h.bodyBytes||Uint8Array.from([]),authInfoBytes:h.authInfoBytes||Uint8Array.from([]),accountNumber:Fm__default.default.fromString(((l=h.accountNumber)==null?void 0:l.toString())||"",!1),chainId:h.chainId||""})}),signAmino:(...a)=>g(void 0,null,function*(){let{1:c,2:h}=a;return e.signAmino(c,h)})}}throw P.getState()._notFoundFn(),new Error("window.vectis is not defined")};d();d();d();var $n=Je(Kn());d();d();var jn=class{};var Ss=class extends jn{constructor(t){super();}},ql=$n.FIVE_SECONDS,Rt={pulse:"heartbeat_pulse"},zn=class e extends Ss{constructor(t){super(t),this.events=new fI.EventEmitter,this.interval=ql,this.interval=(t==null?void 0:t.interval)||ql;}static init(t){return g(this,null,function*(){let r=new e(t);return yield r.init(),r})}init(){return g(this,null,function*(){yield this.initialize();})}stop(){clearInterval(this.intervalRef);}on(t,r){this.events.on(t,r);}once(t,r){this.events.once(t,r);}off(t,r){this.events.off(t,r);}removeListener(t,r){this.events.removeListener(t,r);}initialize(){return g(this,null,function*(){this.intervalRef=setInterval(()=>this.pulse(),(0, $n.toMiliseconds)(this.interval));})}pulse(){this.events.emit(Rt.pulse);}};d();d();d();var ow=/"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,aw=/"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,cw=/^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/;function lw(e,t){if(e==="__proto__"||e==="constructor"&&t&&typeof t=="object"&&"prototype"in t){uw(e);return}return t}function uw(e){console.warn(`[destr] Dropping "${e}" key to prevent prototype pollution.`);}function Rr(e,t={}){if(typeof e!="string")return e;let r=e.trim();if(e[0]==='"'&&e.endsWith('"')&&!e.includes("\\"))return r.slice(1,-1);if(r.length<=9){let n=r.toLowerCase();if(n==="true")return !0;if(n==="false")return !1;if(n==="undefined")return;if(n==="null")return null;if(n==="nan")return Number.NaN;if(n==="infinity")return Number.POSITIVE_INFINITY;if(n==="-infinity")return Number.NEGATIVE_INFINITY}if(!cw.test(e)){if(t.strict)throw new SyntaxError("[destr] Invalid JSON");return e}try{if(ow.test(e)||aw.test(e)){if(t.strict)throw new Error("[destr] Possible prototype pollution");return JSON.parse(e,lw)}return JSON.parse(e)}catch(n){if(t.strict)throw n;return e}}d();function fw(e){return !e||typeof e.then!="function"?Promise.resolve(e):e}function pe(e,...t){try{return fw(e(...t))}catch(r){return Promise.reject(r)}}function hw(e){let t=typeof e;return e===null||t!=="object"&&t!=="function"}function dw(e){let t=Object.getPrototypeOf(e);return !t||t.isPrototypeOf(Object)}function Pr(e){if(hw(e))return String(e);if(dw(e)||Array.isArray(e))return JSON.stringify(e);if(typeof e.toJSON=="function")return Pr(e.toJSON());throw new Error("[unstorage] Cannot stringify value!")}function Gl(){if(typeof Buffer=="undefined")throw new TypeError("[unstorage] Buffer is not supported!")}var _s="base64:";function Vl(e){if(typeof e=="string")return e;Gl();let t=Buffer.from(e).toString("base64");return _s+t}function Hl(e){return typeof e!="string"||!e.startsWith(_s)?e:(Gl(),Buffer.from(e.slice(_s.length),"base64"))}function Te(e){return e?e.split("?")[0].replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""):""}function Jl(...e){return Te(e.join(":"))}function Nr(e){return e=Te(e),e?e+":":""}var pw="memory",gw=()=>{let e=new Map;return {name:pw,getInstance:()=>e,hasItem(t){return e.has(t)},getItem(t){var r;return (r=e.get(t))!=null?r:null},getItemRaw(t){var r;return (r=e.get(t))!=null?r:null},setItem(t,r){e.set(t,r);},setItemRaw(t,r){e.set(t,r);},removeItem(t){e.delete(t);},getKeys(){return [...e.keys()]},clear(){e.clear();},dispose(){e.clear();}}};function Ql(e={}){let t={mounts:{"":e.driver||gw()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},r=l=>{for(let f of t.mountpoints)if(l.startsWith(f))return {base:f,relativeKey:l.slice(f.length),driver:t.mounts[f]};return {base:"",relativeKey:l,driver:t.mounts[""]}},n=(l,f)=>t.mountpoints.filter(m=>m.startsWith(l)||f&&l.startsWith(m)).map(m=>({relativeBase:l.length>m.length?l.slice(m.length):void 0,mountpoint:m,driver:t.mounts[m]})),i=(l,f)=>{if(t.watching){f=Te(f);for(let m of t.watchListeners)m(l,f);}},s=()=>g(this,null,function*(){if(!t.watching){t.watching=!0;for(let l in t.mounts)t.unwatch[l]=yield Yl(t.mounts[l],i,l);}}),o=()=>g(this,null,function*(){if(t.watching){for(let l in t.unwatch)yield t.unwatch[l]();t.unwatch={},t.watching=!1;}}),a=(l,f,m)=>{let p=new Map,u=y=>{let w=p.get(y.base);return w||(w={driver:y.driver,base:y.base,items:[]},p.set(y.base,w)),w};for(let y of l){let w=typeof y=="string",S=Te(w?y:y.key),b=w?void 0:y.value,_=w||!y.options?f:M(M({},f),y.options),x=r(S);u(x).items.push({key:S,value:b,relativeKey:x.relativeKey,options:_});}return Promise.all([...p.values()].map(y=>m(y))).then(y=>y.flat())},c={hasItem(l,f={}){l=Te(l);let{relativeKey:m,driver:p}=r(l);return pe(p.hasItem,m,f)},getItem(l,f={}){l=Te(l);let{relativeKey:m,driver:p}=r(l);return pe(p.getItem,m,f).then(u=>Rr(u))},getItems(l,f){return a(l,f,m=>m.driver.getItems?pe(m.driver.getItems,m.items.map(p=>({key:p.relativeKey,options:p.options})),f).then(p=>p.map(u=>({key:Jl(m.base,u.key),value:Rr(u.value)}))):Promise.all(m.items.map(p=>pe(m.driver.getItem,p.relativeKey,p.options).then(u=>({key:p.key,value:Rr(u)})))))},getItemRaw(l,f={}){l=Te(l);let{relativeKey:m,driver:p}=r(l);return p.getItemRaw?pe(p.getItemRaw,m,f):pe(p.getItem,m,f).then(u=>Hl(u))},setItem(p,u){return g(this,arguments,function*(l,f,m={}){if(f===void 0)return c.removeItem(l);l=Te(l);let{relativeKey:y,driver:w}=r(l);w.setItem&&(yield pe(w.setItem,y,Pr(f),m),w.watch||i("update",l));})},setItems(l,f){return g(this,null,function*(){yield a(l,f,m=>g(this,null,function*(){if(m.driver.setItems)return pe(m.driver.setItems,m.items.map(p=>({key:p.relativeKey,value:Pr(p.value),options:p.options})),f);m.driver.setItem&&(yield Promise.all(m.items.map(p=>pe(m.driver.setItem,p.relativeKey,Pr(p.value),p.options))));}));})},setItemRaw(p,u){return g(this,arguments,function*(l,f,m={}){if(f===void 0)return c.removeItem(l,m);l=Te(l);let{relativeKey:y,driver:w}=r(l);if(w.setItemRaw)yield pe(w.setItemRaw,y,f,m);else if(w.setItem)yield pe(w.setItem,y,Vl(f),m);else return;w.watch||i("update",l);})},removeItem(m){return g(this,arguments,function*(l,f={}){typeof f=="boolean"&&(f={removeMeta:f}),l=Te(l);let{relativeKey:p,driver:u}=r(l);u.removeItem&&(yield pe(u.removeItem,p,f),(f.removeMeta||f.removeMata)&&(yield pe(u.removeItem,p+"$",f)),u.watch||i("remove",l));})},getMeta(m){return g(this,arguments,function*(l,f={}){typeof f=="boolean"&&(f={nativeOnly:f}),l=Te(l);let{relativeKey:p,driver:u}=r(l),y=Object.create(null);if(u.getMeta&&Object.assign(y,yield pe(u.getMeta,p,f)),!f.nativeOnly){let w=yield pe(u.getItem,p+"$",f).then(S=>Rr(S));w&&typeof w=="object"&&(typeof w.atime=="string"&&(w.atime=new Date(w.atime)),typeof w.mtime=="string"&&(w.mtime=new Date(w.mtime)),Object.assign(y,w));}return y})},setMeta(l,f,m={}){return this.setItem(l+"$",f,m)},removeMeta(l,f={}){return this.removeItem(l+"$",f)},getKeys(m){return g(this,arguments,function*(l,f={}){l=Nr(l);let p=n(l,!0),u=[],y=[];for(let w of p){let S=yield pe(w.driver.getKeys,w.relativeBase,f);for(let b of S){let _=w.mountpoint+Te(b);u.some(x=>_.startsWith(x))||y.push(_);}u=[w.mountpoint,...u.filter(b=>!b.startsWith(w.mountpoint))];}return l?y.filter(w=>w.startsWith(l)&&w[w.length-1]!=="$"):y.filter(w=>w[w.length-1]!=="$")})},clear(m){return g(this,arguments,function*(l,f={}){l=Nr(l),yield Promise.all(n(l,!1).map(p=>g(this,null,function*(){if(p.driver.clear)return pe(p.driver.clear,p.relativeBase,f);if(p.driver.removeItem){let u=yield p.driver.getKeys(p.relativeBase||"",f);return Promise.all(u.map(y=>p.driver.removeItem(y,f)))}})));})},dispose(){return g(this,null,function*(){yield Promise.all(Object.values(t.mounts).map(l=>Xl(l)));})},watch(l){return g(this,null,function*(){return yield s(),t.watchListeners.push(l),()=>g(this,null,function*(){t.watchListeners=t.watchListeners.filter(f=>f!==l),t.watchListeners.length===0&&(yield o());})})},unwatch(){return g(this,null,function*(){t.watchListeners=[],yield o();})},mount(l,f){if(l=Nr(l),l&&t.mounts[l])throw new Error(`already mounted at ${l}`);return l&&(t.mountpoints.push(l),t.mountpoints.sort((m,p)=>p.length-m.length)),t.mounts[l]=f,t.watching&&Promise.resolve(Yl(f,i,l)).then(m=>{t.unwatch[l]=m;}).catch(console.error),c},unmount(l,f=!0){return g(this,null,function*(){l=Nr(l),!(!l||!t.mounts[l])&&(t.watching&&l in t.unwatch&&(t.unwatch[l](),delete t.unwatch[l]),f&&(yield Xl(t.mounts[l])),t.mountpoints=t.mountpoints.filter(m=>m!==l),delete t.mounts[l]);})},getMount(l=""){l=Te(l)+":";let f=r(l);return {driver:f.driver,base:f.base}},getMounts(l="",f={}){return l=Te(l),n(l,f.parents).map(p=>({driver:p.driver,base:p.mountpoint}))},keys:(l,f={})=>c.getKeys(l,f),get:(l,f={})=>c.getItem(l,f),set:(l,f,m={})=>c.setItem(l,f,m),has:(l,f={})=>c.hasItem(l,f),del:(l,f={})=>c.removeItem(l,f),remove:(l,f={})=>c.removeItem(l,f)};return c}function Yl(e,t,r){return e.watch?e.watch((n,i)=>t(n,r+i)):()=>{}}function Xl(e){return g(this,null,function*(){typeof e.dispose=="function"&&(yield pe(e.dispose));})}d();function Pt(e){return new Promise((t,r)=>{e.oncomplete=e.onsuccess=()=>t(e.result),e.onabort=e.onerror=()=>r(e.error);})}function vs(e,t){let r=indexedDB.open(e);r.onupgradeneeded=()=>r.result.createObjectStore(t);let n=Pt(r);return (i,s)=>n.then(o=>s(o.transaction(t,i).objectStore(t)))}var Es;function Lr(){return Es||(Es=vs("keyval-store","keyval")),Es}function xs(e,t=Lr()){return t("readonly",r=>Pt(r.get(e)))}function Zl(e,t,r=Lr()){return r("readwrite",n=>(n.put(t,e),Pt(n.transaction)))}function eu(e,t=Lr()){return t("readwrite",r=>(r.delete(e),Pt(r.transaction)))}function tu(e=Lr()){return e("readwrite",t=>(t.clear(),Pt(t.transaction)))}function mw(e,t){return e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue());},Pt(e.transaction)}function ru(e=Lr()){return e("readonly",t=>{if(t.getAllKeys)return Pt(t.getAllKeys());let r=[];return mw(t,n=>r.push(n.key)).then(()=>r)})}d();var yw=e=>JSON.stringify(e,(t,r)=>typeof r=="bigint"?r.toString()+"n":r),ww=e=>{let t=/([\[:])?(\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=e.replace(t,'$1"$2n"$3');return JSON.parse(r,(n,i)=>typeof i=="string"&&i.match(/^\d+n$/)?BigInt(i.substring(0,i.length-1)):i)};function Ze(e){if(typeof e!="string")throw new Error(`Cannot safe json parse value of type ${typeof e}`);try{return ww(e)}catch(t){return e}}function $e(e){return typeof e=="string"?e:yw(e)||""}var bw="idb-keyval",Sw=(e={})=>{let t=e.base&&e.base.length>0?`${e.base}:`:"",r=s=>t+s,n;return e.dbName&&e.storeName&&(n=vs(e.dbName,e.storeName)),{name:bw,options:e,hasItem(s){return g(this,null,function*(){return !(typeof(yield xs(r(s),n))>"u")})},getItem(s){return g(this,null,function*(){var o;return (o=yield xs(r(s),n))!=null?o:null})},setItem(s,o){return Zl(r(s),o,n)},removeItem(s){return eu(r(s),n)},getKeys(){return ru(n)},clear(){return tu(n)}}},_w="WALLET_CONNECT_V2_INDEXED_DB",Ew="keyvaluestorage",Is=class{constructor(){this.indexedDb=Ql({driver:Sw({dbName:_w,storeName:Ew})});}getKeys(){return g(this,null,function*(){return this.indexedDb.getKeys()})}getEntries(){return g(this,null,function*(){return (yield this.indexedDb.getItems(yield this.indexedDb.getKeys())).map(t=>[t.key,t.value])})}getItem(t){return g(this,null,function*(){let r=yield this.indexedDb.getItem(t);if(r!==null)return r})}setItem(t,r){return g(this,null,function*(){yield this.indexedDb.setItem(t,$e(r));})}removeItem(t){return g(this,null,function*(){yield this.indexedDb.removeItem(t);})}},Cs=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},qn={exports:{}};(function(){let e;function t(){}e=t,e.prototype.getItem=function(r){return this.hasOwnProperty(r)?String(this[r]):null},e.prototype.setItem=function(r,n){this[r]=String(n);},e.prototype.removeItem=function(r){delete this[r];},e.prototype.clear=function(){let r=this;Object.keys(r).forEach(function(n){r[n]=void 0,delete r[n];});},e.prototype.key=function(r){return r=r||0,Object.keys(this)[r]},e.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Cs<"u"&&Cs.localStorage?qn.exports=Cs.localStorage:typeof window<"u"&&window.localStorage?qn.exports=window.localStorage:qn.exports=new t;})();function vw(e){var t;return [e[0],Ze((t=e[1])!=null?t:"")]}var Ds=class{constructor(){this.localStorage=qn.exports;}getKeys(){return g(this,null,function*(){return Object.keys(this.localStorage)})}getEntries(){return g(this,null,function*(){return Object.entries(this.localStorage).map(vw)})}getItem(t){return g(this,null,function*(){let r=this.localStorage.getItem(t);if(r!==null)return Ze(r)})}setItem(t,r){return g(this,null,function*(){this.localStorage.setItem(t,$e(r));})}removeItem(t){return g(this,null,function*(){this.localStorage.removeItem(t);})}},xw="wc_storage_version",nu=1,Cw=(e,t,r)=>g(void 0,null,function*(){let n=xw,i=yield t.getItem(n);if(i&&i>=nu){r(t);return}let s=yield e.getKeys();if(!s.length){r(t);return}let o=[];for(;s.length;){let a=s.shift();if(!a)continue;let c=a.toLowerCase();if(c.includes("wc@")||c.includes("walletconnect")||c.includes("wc_")||c.includes("wallet_connect")){let h=yield e.getItem(a);yield t.setItem(a,h),o.push(a);}}yield t.setItem(n,nu),r(t),Iw(e,o);}),Iw=(e,t)=>g(void 0,null,function*(){t.length&&t.forEach(r=>g(void 0,null,function*(){yield e.removeItem(r);}));}),Gn=class{constructor(){this.initialized=!1,this.setInitialized=r=>{this.storage=r,this.initialized=!0;};let t=new Ds;this.storage=t;try{let r=new Is;Cw(t,r,this.setInitialized);}catch(r){this.initialized=!0;}}getKeys(){return g(this,null,function*(){return yield this.initialize(),this.storage.getKeys()})}getEntries(){return g(this,null,function*(){return yield this.initialize(),this.storage.getEntries()})}getItem(t){return g(this,null,function*(){return yield this.initialize(),this.storage.getItem(t)})}setItem(t,r){return g(this,null,function*(){return yield this.initialize(),this.storage.setItem(t,r)})}removeItem(t){return g(this,null,function*(){return yield this.initialize(),this.storage.removeItem(t)})}initialize(){return g(this,null,function*(){this.initialized||(yield new Promise(t=>{let r=setInterval(()=>{this.initialized&&(clearInterval(r),t());},20);}));})}};d();var lt=Je(vo()),Do=Je(vo());var O_={level:"info"},kr="custom_context",Ao=1e3*1024,xo=class{constructor(t){this.nodeValue=t,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null;}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},oi=class{constructor(t){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=t,this.sizeInBytes=0;}append(t){let r=new xo(t);if(r.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${t} with size ${r.size}`);for(;this.size+r.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=r),this.tail=r):(this.head=r,this.tail=r),this.lengthInNodes++,this.sizeInBytes+=r.size;}shift(){if(!this.head)return;let t=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=t.size;}toArray(){let t=[],r=this.head;for(;r!==null;)t.push(r.value),r=r.next;return t}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let t=this.head;return {next:()=>{if(!t)return {done:!0,value:null};let r=t.value;return t=t.next,{done:!1,value:r}}}}},ai=class{constructor(t,r=Ao){this.level=t!=null?t:"error",this.levelValue=lt.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=r,this.logs=new oi(this.MAX_LOG_SIZE_IN_BYTES);}forwardToConsole(t,r){r===lt.levels.values.error?console.error(t):r===lt.levels.values.warn?console.warn(t):r===lt.levels.values.debug?console.debug(t):r===lt.levels.values.trace?console.trace(t):console.log(t);}appendToLogs(t){this.logs.append($e({timestamp:new Date().toISOString(),log:t}));let r=typeof t=="string"?JSON.parse(t).level:t.level;r>=this.levelValue&&this.forwardToConsole(t,r);}getLogs(){return this.logs}clearLogs(){this.logs=new oi(this.MAX_LOG_SIZE_IN_BYTES);}getLogArray(){return Array.from(this.logs)}logsToBlob(t){let r=this.getLogArray();return r.push($e({extraMetadata:t})),new Blob(r,{type:"application/json"})}},Co=class{constructor(t,r=Ao){this.baseChunkLogger=new ai(t,r);}write(t){this.baseChunkLogger.appendToLogs(t);}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs();}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(t){return this.baseChunkLogger.logsToBlob(t)}downloadLogsBlobInBrowser(t){let r=URL.createObjectURL(this.logsToBlob(t)),n=document.createElement("a");n.href=r,n.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(r);}},Io=class{constructor(t,r=Ao){this.baseChunkLogger=new ai(t,r);}write(t){this.baseChunkLogger.appendToLogs(t);}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs();}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(t){return this.baseChunkLogger.logsToBlob(t)}},T_=Object.defineProperty,R_=Object.defineProperties,P_=Object.getOwnPropertyDescriptors,ch=Object.getOwnPropertySymbols,N_=Object.prototype.hasOwnProperty,L_=Object.prototype.propertyIsEnumerable,lh=(e,t,r)=>t in e?T_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ci=(e,t)=>{for(var r in t||(t={}))N_.call(t,r)&&lh(e,r,t[r]);if(ch)for(var r of ch(t))L_.call(t,r)&&lh(e,r,t[r]);return e},li=(e,t)=>R_(e,P_(t));function Oo(e){return li(ci({},e),{level:(e==null?void 0:e.level)||O_.level})}function M_(e,t=kr){return e[t]||""}function F_(e,t,r=kr){return e[r]=t,e}function Be(e,t=kr){let r="";return typeof e.bindings>"u"?r=M_(e,t):r=e.bindings().context||"",r}function B_(e,t,r=kr){let n=Be(e,r);return n.trim()?`${n}/${t}`:t}function Re(e,t,r=kr){let n=B_(e,t,r),i=e.child({context:n});return F_(i,n,r)}function k_(e){var t,r;let n=new Co((t=e.opts)==null?void 0:t.level,e.maxSizeInBytes);return {logger:(0, lt.default)(li(ci({},e.opts),{level:"trace",browser:li(ci({},(r=e.opts)==null?void 0:r.browser),{write:i=>n.write(i)})})),chunkLoggerController:n}}function U_(e){var t;let r=new Io((t=e.opts)==null?void 0:t.level,e.maxSizeInBytes);return {logger:(0, lt.default)(li(ci({},e.opts),{level:"trace"}),r),chunkLoggerController:r}}function uh(e){return typeof e.loggerOverride<"u"&&typeof e.loggerOverride!="string"?{logger:e.loggerOverride,chunkLoggerController:null}:typeof window<"u"?k_(e):U_(e)}var j=Je(Kn());d();d();var Jr=Je(Wh()),wd=Je(Wo()),bd=Je(Kn());d();var Kh="EdDSA",jh="JWT",jr=".",zr="base64url",Jo="utf8",Yo="utf8",zh=":",$h="did",qh="key",Xo="base58btc",Gh="z",Vh="K36";d();d();d();d();function lr(e){return globalThis.Buffer!=null?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function gi(e=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?lr(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function Hh(e,t){t||(t=e.reduce((i,s)=>i+s.length,0));let r=gi(t),n=0;for(let i of e)r.set(i,n),n+=i.length;return lr(r)}d();d();d();var ra={};Ae(ra,{identity:()=>UE});d();d();d();function LE(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i;}var a=e.length,c=e.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function f(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return "";for(var y=0,w=0,S=0,b=u.length;S!==b&&u[S]===0;)S++,y++;for(var _=(b-S)*l+1>>>0,x=new Uint8Array(_);S!==b;){for(var O=u[S],L=0,E=_-1;(O!==0||L<w)&&E!==-1;E--,L++)O+=256*x[E]>>>0,x[E]=O%a>>>0,O=O/a>>>0;if(O!==0)throw new Error("Non-zero carry");w=L,S++;}for(var C=_-w;C!==_&&x[C]===0;)C++;for(var F=c.repeat(y);C<_;++C)F+=e.charAt(x[C]);return F}function m(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var y=0;if(u[y]!==" "){for(var w=0,S=0;u[y]===c;)w++,y++;for(var b=(u.length-y)*h+1>>>0,_=new Uint8Array(b);u[y];){var x=r[u.charCodeAt(y)];if(x===255)return;for(var O=0,L=b-1;(x!==0||O<S)&&L!==-1;L--,O++)x+=a*_[L]>>>0,_[L]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");S=O,y++;}if(u[y]!==" "){for(var E=b-S;E!==b&&_[E]===0;)E++;for(var C=new Uint8Array(w+(b-E)),F=w;E!==b;)C[F++]=_[E++];return C}}}function p(u){var y=m(u);if(y)return y;throw new Error(`Non-${t} character`)}return {encode:f,decodeUnsafe:m,decode:p}}var ME=LE,FE=ME,Jh=FE;d();var qe=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};var Xh=e=>new TextEncoder().encode(e),Qh=e=>new TextDecoder().decode(e);var Qo=class{constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n;}encode(t){if(t instanceof Uint8Array)return `${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Zo=class{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n;}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return ed(this,t)}},ea=class{constructor(t){this.decoders=t;}or(t){return ed(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},ed=(e,t)=>new ea(M(M({},e.decoders||{[e.prefix]:e}),t.decoders||{[t.prefix]:t})),ta=class{constructor(t,r,n,i){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Qo(t,r,n),this.decoder=new Zo(t,r,i);}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},ur=({name:e,prefix:t,encode:r,decode:n})=>new ta(e,t,r,n),St=({prefix:e,name:t,alphabet:r})=>{let{encode:n,decode:i}=Jh(r,t);return ur({prefix:e,name:t,encode:n,decode:s=>qe(i(s))})},BE=(e,t,r,n)=>{let i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;e[s-1]==="=";)--s;let o=new Uint8Array(s*r/8|0),a=0,c=0,h=0;for(let l=0;l<s;++l){let f=i[e[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|f,a+=r,a>=8&&(a-=8,o[h++]=255&c>>a);}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},kE=(e,t,r)=>{let n=t[t.length-1]==="=",i=(1<<r)-1,s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(o&&(s+=t[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s},ae=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>ur({prefix:t,name:e,encode(i){return kE(i,n,r)},decode(i){return BE(i,n,r,e)}});var UE=ur({prefix:"\0",name:"identity",encode:e=>Qh(e),decode:e=>Xh(e)});var na={};Ae(na,{base2:()=>WE});d();var WE=ae({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ia={};Ae(ia,{base8:()=>KE});d();var KE=ae({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var sa={};Ae(sa,{base10:()=>jE});d();var jE=St({prefix:"9",name:"base10",alphabet:"0123456789"});var oa={};Ae(oa,{base16:()=>zE,base16upper:()=>$E});d();var zE=ae({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),$E=ae({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var aa={};Ae(aa,{base32:()=>fr,base32hex:()=>HE,base32hexpad:()=>YE,base32hexpadupper:()=>XE,base32hexupper:()=>JE,base32pad:()=>GE,base32padupper:()=>VE,base32upper:()=>qE,base32z:()=>QE});d();var fr=ae({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),qE=ae({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),GE=ae({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),VE=ae({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),HE=ae({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),JE=ae({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),YE=ae({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),XE=ae({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),QE=ae({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var ca={};Ae(ca,{base36:()=>ZE,base36upper:()=>ev});d();var ZE=St({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ev=St({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var la={};Ae(la,{base58btc:()=>tt,base58flickr:()=>tv});d();var tt=St({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),tv=St({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ua={};Ae(ua,{base64:()=>rv,base64pad:()=>nv,base64url:()=>iv,base64urlpad:()=>sv});d();var rv=ae({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),nv=ae({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),iv=ae({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),sv=ae({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var fa={};Ae(fa,{base256emoji:()=>uv});d();var td=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),ov=td.reduce((e,t,r)=>(e[r]=t,e),[]),av=td.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]);function cv(e){return e.reduce((t,r)=>(t+=ov[r],t),"")}function lv(e){let t=[];for(let r of e){let n=av[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(n);}return new Uint8Array(t)}var uv=ur({prefix:"\u{1F680}",name:"base256emoji",encode:cv,decode:lv});var ga={};Ae(ga,{sha256:()=>Ov,sha512:()=>Tv});d();d();d();d();d();var fv=id,rd=128,hv=127,dv=~hv,pv=Math.pow(2,31);function id(e,t,r){t=t||[],r=r||0;for(var n=r;e>=pv;)t[r++]=e&255|rd,e/=128;for(;e&dv;)t[r++]=e&255|rd,e>>>=7;return t[r]=e|0,id.bytes=r-n+1,t}var gv=ha,mv=128,nd=127;function ha(e,n){var r=0,n=n||0,i=0,s=n,o,a=e.length;do{if(s>=a)throw ha.bytes=0,new RangeError("Could not decode varint");o=e[s++],r+=i<28?(o&nd)<<i:(o&nd)*Math.pow(2,i),i+=7;}while(o>=mv);return ha.bytes=s-n,r}var yv=Math.pow(2,7),wv=Math.pow(2,14),bv=Math.pow(2,21),Sv=Math.pow(2,28),_v=Math.pow(2,35),Ev=Math.pow(2,42),vv=Math.pow(2,49),xv=Math.pow(2,56),Cv=Math.pow(2,63),Iv=function(e){return e<yv?1:e<wv?2:e<bv?3:e<Sv?4:e<_v?5:e<Ev?6:e<vv?7:e<xv?8:e<Cv?9:10},Dv={encode:fv,decode:gv,encodingLength:Iv},Av=Dv,$r=Av;var hr=(e,t,r=0)=>($r.encode(e,t,r),t),dr=e=>$r.encodingLength(e);var Wt=(e,t)=>{let r=t.byteLength,n=dr(e),i=n+dr(r),s=new Uint8Array(i+r);return hr(e,s,0),hr(r,s,n),s.set(t,i),new pr(e,r,t,s)},pr=class{constructor(t,r,n,i){this.code=t,this.size=r,this.digest=n,this.bytes=i;}};var pa=({name:e,code:t,encode:r})=>new da(e,t,r),da=class{constructor(t,r,n){this.name=t,this.code=r,this.encode=n;}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?Wt(this.code,r):r.then(n=>Wt(this.code,n))}else throw Error("Unknown type, must be binary type")}};var Ov=pa({name:"sha2-256",code:18,encode:e=>qe(cd__default.default.createHash("sha256").update(e).digest())}),Tv=pa({name:"sha2-512",code:19,encode:e=>qe(cd__default.default.createHash("sha512").update(e).digest())});var ma={};Ae(ma,{identity:()=>Nv});d();var ld=0,Rv="identity",ud=qe,Pv=e=>Wt(ld,ud(e)),Nv={code:ld,name:Rv,encode:ud,digest:Pv};d();d();new TextEncoder;new TextDecoder;d();d();var gr=M(M(M(M(M(M(M(M(M(M({},ra),na),ia),sa),oa),aa),ca),la),ua),fa);M(M({},ga),ma);function pd(e,t,r,n){return {name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var dd=pd("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),ya=pd("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=gi(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),zv=M({utf8:dd,"utf-8":dd,hex:gr.base16,latin1:ya,ascii:ya,binary:ya},gr),Si=zv;function Hr(e,t="utf8"){let r=Si[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return (t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):r.encoder.encode(e).substring(1)}d();function Kt(e,t="utf8"){let r=Si[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return (t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?lr(globalThis.Buffer.from(e,"utf-8")):r.decoder.decode(`${r.prefix}${e}`)}function gd(e){return Ze(Hr(Kt(e,zr),Jo))}function _i(e){return Hr(Kt($e(e),Jo),zr)}function Ei(e){let t=Kt(Vh,Xo),r=Gh+Hr(Hh([t,e]),Xo);return [$h,qh,r].join(zh)}function $v(e){return Hr(e,zr)}function qv(e){return Kt(e,zr)}function md(e){return Kt([_i(e.header),_i(e.payload)].join(jr),Yo)}function yd(e){return [_i(e.header),_i(e.payload),$v(e.signature)].join(jr)}function vi(e){let t=e.split(jr),r=gd(t[0]),n=gd(t[1]),i=qv(t[2]),s=Kt(t.slice(0,2).join(jr),Yo);return {header:r,payload:n,signature:i,data:s}}function wa(e=(0, wd.randomBytes)(32)){return Jr.generateKeyPairFromSeed(e)}function Sd(s,o,a,c){return g(this,arguments,function*(e,t,r,n,i=(0, bd.fromMiliseconds)(Date.now())){let h={alg:Kh,typ:jh},l=Ei(n.publicKey),f=i+r,m={iss:l,sub:e,aud:t,iat:i,exp:f},p=md({header:h,payload:m}),u=Jr.sign(n.secretKey,p);return yd({header:h,payload:m,signature:u})})}d();d();d();d();d();function xi(e=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}d();d();d();function Ed(e,t,r,n){return {name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var _d=Ed("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),ba=Ed("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=xi(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),Hv=M({utf8:_d,"utf-8":_d,hex:gr.base16,latin1:ba,ascii:ba,binary:ba},gr),Sa=Hv;d();function _a(e,t="utf8"){let r=Sa[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return (t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):r.encoder.encode(e).substring(1)}d();d();var xe={};Ae(xe,{DEFAULT_ERROR:()=>Xr,IBaseJsonRpcProvider:()=>Li,IEvents:()=>Zr,IJsonRpcConnection:()=>Da,IJsonRpcProvider:()=>en,INTERNAL_ERROR:()=>Ci,INVALID_PARAMS:()=>Id,INVALID_REQUEST:()=>xd,METHOD_NOT_FOUND:()=>Cd,PARSE_ERROR:()=>vd,RESERVED_ERROR_CODES:()=>Ea,SERVER_ERROR:()=>Yr,SERVER_ERROR_CODE_RANGE:()=>Ii,STANDARD_ERROR_MAP:()=>_t,formatErrorMessage:()=>Fd,formatJsonRpcError:()=>Qr,formatJsonRpcRequest:()=>yr,formatJsonRpcResult:()=>Ri,getBigIntRpcId:()=>mr,getError:()=>Ai,getErrorByCode:()=>Oi,isHttpUrl:()=>sx,isJsonRpcError:()=>jt,isJsonRpcPayload:()=>Oa,isJsonRpcRequest:()=>Fi,isJsonRpcResponse:()=>wr,isJsonRpcResult:()=>Bi,isJsonRpcValidationInvalid:()=>ox,isLocalhostUrl:()=>Aa,isNodeJs:()=>Md,isReservedErrorCode:()=>Di,isServerErrorCode:()=>Jv,isValidDefaultRoute:()=>Pi,isValidErrorCode:()=>Dd,isValidLeadingWildcardRoute:()=>ex,isValidRoute:()=>Zv,isValidTrailingWildcardRoute:()=>tx,isValidWildcardRoute:()=>Ni,isWsUrl:()=>Mi,parseConnectionError:()=>va,payloadId:()=>Ia,validateJsonRpcError:()=>Yv});d();d();var vd="PARSE_ERROR",xd="INVALID_REQUEST",Cd="METHOD_NOT_FOUND",Id="INVALID_PARAMS",Ci="INTERNAL_ERROR",Yr="SERVER_ERROR",Ea=[-32700,-32600,-32601,-32602,-32603],Ii=[-32e3,-32099],_t={[vd]:{code:-32700,message:"Parse error"},[xd]:{code:-32600,message:"Invalid Request"},[Cd]:{code:-32601,message:"Method not found"},[Id]:{code:-32602,message:"Invalid params"},[Ci]:{code:-32603,message:"Internal error"},[Yr]:{code:-32e3,message:"Server error"}},Xr=Yr;d();function Jv(e){return e<=Ii[0]&&e>=Ii[1]}function Di(e){return Ea.includes(e)}function Dd(e){return typeof e=="number"}function Ai(e){return Object.keys(_t).includes(e)?_t[e]:_t[Xr]}function Oi(e){let t=Object.values(_t).find(r=>r.code===e);return t||_t[Xr]}function Yv(e){if(typeof e.error.code=="undefined")return {valid:!1,error:"Missing code for JSON-RPC error"};if(typeof e.error.message=="undefined")return {valid:!1,error:"Missing message for JSON-RPC error"};if(!Dd(e.error.code))return {valid:!1,error:`Invalid error code type for JSON-RPC: ${e.error.code}`};if(Di(e.error.code)){let t=Oi(e.error.code);if(t.message!==_t[Xr].message&&e.error.message===t.message)return {valid:!1,error:`Invalid error code message for JSON-RPC: ${e.error.code}`}}return {valid:!0}}function va(e,t,r){return e.message.includes("getaddrinfo ENOTFOUND")||e.message.includes("connect ECONNREFUSED")?new Error(`Unavailable ${r} RPC url at ${t}`):e}var we={};Ae(we,{isNodeJs:()=>Md});d();var Ld=Je(Ca());Oe(we,Je(Ca()));var Md=Ld.isNode;Oe(xe,we);d();function Ia(e=3){let t=Date.now()*Math.pow(10,e),r=Math.floor(Math.random()*Math.pow(10,e));return t+r}function mr(e=6){return BigInt(Ia(e))}function yr(e,t,r){return {id:r||Ia(),jsonrpc:"2.0",method:e,params:t}}function Ri(e,t){return {id:e,jsonrpc:"2.0",result:t}}function Qr(e,t,r){return {id:e,jsonrpc:"2.0",error:Fd(t,r)}}function Fd(e,t){return typeof e=="undefined"?Ai(Ci):(typeof e=="string"&&(e=Object.assign(Object.assign({},Ai(Yr)),{message:e})),typeof t!="undefined"&&(e.data=t),Di(e.code)&&(e=Oi(e.code)),e)}d();function Zv(e){return e.includes("*")?Ni(e):!/\W/g.test(e)}function Pi(e){return e==="*"}function Ni(e){return Pi(e)?!0:!(!e.includes("*")||e.split("*").length!==2||e.split("*").filter(t=>t.trim()==="").length!==1)}function ex(e){return !Pi(e)&&Ni(e)&&!e.split("*")[0].trim()}function tx(e){return !Pi(e)&&Ni(e)&&!e.split("*")[1].trim()}d();d();var Zr=class{},Da=class extends Zr{constructor(t){super();}},Li=class extends Zr{constructor(){super();}},en=class extends Li{constructor(t){super();}};d();var rx="^https?:",nx="^wss?:";function ix(e){let t=e.match(new RegExp(/^\w+:/,"gi"));if(!(!t||!t.length))return t[0]}function Bd(e,t){let r=ix(e);return typeof r=="undefined"?!1:new RegExp(t).test(r)}function sx(e){return Bd(e,rx)}function Mi(e){return Bd(e,nx)}function Aa(e){return new RegExp("wss?://localhost(:d{2,5})?").test(e)}d();function Oa(e){return typeof e=="object"&&"id"in e&&"jsonrpc"in e&&e.jsonrpc==="2.0"}function Fi(e){return Oa(e)&&"method"in e}function wr(e){return Oa(e)&&(Bi(e)||jt(e))}function Bi(e){return "result"in e}function jt(e){return "error"in e}function ox(e){return "error"in e&&e.valid===!1}var ki=class extends en{constructor(t){super(t),this.events=new fI.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(t),this.connection.connected&&this.registerEventListeners();}connect(){return g(this,arguments,function*(t=this.connection){yield this.open(t);})}disconnect(){return g(this,null,function*(){yield this.close();})}on(t,r){this.events.on(t,r);}once(t,r){this.events.once(t,r);}off(t,r){this.events.off(t,r);}removeListener(t,r){this.events.removeListener(t,r);}request(t,r){return g(this,null,function*(){return this.requestStrict(yr(t.method,t.params||[],t.id||mr().toString()),r)})}requestStrict(t,r){return g(this,null,function*(){return new Promise((n,i)=>g(this,null,function*(){if(!this.connection.connected)try{yield this.open();}catch(s){i(s);}this.events.on(`${t.id}`,s=>{jt(s)?i(s.error):n(s.result);});try{yield this.connection.send(t,r);}catch(s){i(s);}}))})}setConnection(t=this.connection){return t}onPayload(t){this.events.emit("payload",t),wr(t)?this.events.emit(`${t.id}`,t):this.events.emit("message",{type:t.method,data:t.params});}onClose(t){t&&t.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${t.code} ${t.reason?`(${t.reason})`:""}`)),this.events.emit("disconnect");}open(){return g(this,arguments,function*(t=this.connection){this.connection===t&&this.connection.connected||(this.connection.connected&&this.close(),typeof t=="string"&&(yield this.connection.open(t),t=this.connection),this.connection=this.setConnection(t),yield this.connection.open(),this.registerEventListeners(),this.events.emit("connect"));})}close(){return g(this,null,function*(){yield this.connection.close();})}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",t=>this.onPayload(t)),this.connection.on("close",t=>this.onClose(t)),this.connection.on("error",t=>this.events.emit("error",t)),this.connection.on("register_error",t=>this.onClose()),this.hasRegisteredEventListeners=!0);}};d();var EC=()=>typeof WebSocket<"u"?WebSocket:typeof global<"u"&&typeof global.WebSocket<"u"?global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:Qp(),vC=()=>typeof WebSocket<"u"||typeof global<"u"&&typeof global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",Zp=e=>e.split("?")[0],eg=10,xC=EC(),qi=class{constructor(t){if(this.url=t,this.events=new fI.EventEmitter,this.registering=!1,!Mi(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);this.url=t;}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(t,r){this.events.on(t,r);}once(t,r){this.events.once(t,r);}off(t,r){this.events.off(t,r);}removeListener(t,r){this.events.removeListener(t,r);}open(){return g(this,arguments,function*(t=this.url){yield this.register(t);})}close(){return g(this,null,function*(){return new Promise((t,r)=>{if(typeof this.socket>"u"){r(new Error("Connection already closed"));return}this.socket.onclose=n=>{this.onClose(n),t();},this.socket.close();})})}send(t){return g(this,null,function*(){typeof this.socket>"u"&&(this.socket=yield this.register());try{this.socket.send($e(t));}catch(r){this.onError(t.id,r);}})}register(t=this.url){if(!Mi(t))throw new Error(`Provided URL is not compatible with WebSocket connection: ${t}`);if(this.registering){let r=this.events.getMaxListeners();return (this.events.listenerCount("register_error")>=r||this.events.listenerCount("open")>=r)&&this.events.setMaxListeners(r+1),new Promise((n,i)=>{this.events.once("register_error",s=>{this.resetMaxListeners(),i(s);}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return i(new Error("WebSocket connection is missing or invalid"));n(this.socket);});})}return this.url=t,this.registering=!0,new Promise((r,n)=>{let i=new URLSearchParams(t).get("origin"),s=(0, xe.isReactNative)()?{headers:{origin:i}}:{rejectUnauthorized:!Aa(t)},o=new xC(t,[],s);vC()?o.onerror=a=>{let c=a;n(this.emitError(c.error));}:o.on("error",a=>{n(this.emitError(a));}),o.onopen=()=>{this.onOpen(o),r(o);};})}onOpen(t){t.onmessage=r=>this.onPayload(r),t.onclose=r=>this.onClose(r),this.socket=t,this.registering=!1,this.events.emit("open");}onClose(t){this.socket=void 0,this.registering=!1,this.events.emit("close",t);}onPayload(t){if(typeof t.data>"u")return;let r=typeof t.data=="string"?Ze(t.data):t.data;this.events.emit("payload",r);}onError(t,r){let n=this.parseError(r),i=n.message||n.toString(),s=Qr(t,i);this.events.emit("payload",s);}parseError(t,r=this.url){return va(t,Zp(r),"WS")}resetMaxListeners(){this.events.getMaxListeners()>eg&&this.events.setMaxListeners(eg);}emitError(t){let r=this.parseError(new Error((t==null?void 0:t.message)||`WebSocket connection failed for host: ${Zp(this.url)}`));return this.events.emit("register_error",r),r}};var ym=Je(Mg()),wm=Je(Fg());var bm="wc",Sm=2,tl="core",ot=`${bm}@2:${tl}:`,XI={name:tl,logger:"error"},QI={database:":memory:"},ZI="crypto",Vg="client_ed25519_seed",eD=j.ONE_DAY,tD="keychain",rD="0.3",nD="messages",iD="0.3",sD=j.SIX_HOURS,oD="publisher",aD="irn",cD="error",_m="wss://relay.walletconnect.org",lD="relayer",je={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"},uD="_subscription",Ge={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},fD=.1;var Rc="2.17.2";var Cr={link_mode:"link_mode",relay:"relay"},hD="0.3",dD="WALLETCONNECT_CLIENT_ID",Hg="WALLETCONNECT_LINK_MODE_APPS",st={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"};var pD="subscription",gD="0.3",mD=j.FIVE_SECONDS*1e3,yD="pairing",wD="0.3";var gn={wc_pairingDelete:{req:{ttl:j.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:j.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:j.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:j.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:j.ONE_DAY,prompt:!1,tag:0},res:{ttl:j.ONE_DAY,prompt:!1,tag:0}}},mn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Xe={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},bD="history",SD="0.3",_D="expirer",Qe={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},ED="0.3";var vD="verify-api",xD="https://verify.walletconnect.com",Em="https://verify.walletconnect.org",ns=Em,CD=`${ns}/v3`,ID=[xD,Em],DD="echo",AD="https://echo.walletconnect.com";var yt={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},At={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"};var OD=.1,TD="event-client",RD=86400,PD="https://pulse.walletconnect.org/batch";function ND(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var i=0;i<e.length;i++){var s=e.charAt(i),o=s.charCodeAt(0);if(r[o]!==255)throw new TypeError(s+" is ambiguous");r[o]=i;}var a=e.length,c=e.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function f(u){if(u instanceof Uint8Array||(ArrayBuffer.isView(u)?u=new Uint8Array(u.buffer,u.byteOffset,u.byteLength):Array.isArray(u)&&(u=Uint8Array.from(u))),!(u instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(u.length===0)return "";for(var y=0,w=0,S=0,b=u.length;S!==b&&u[S]===0;)S++,y++;for(var _=(b-S)*l+1>>>0,x=new Uint8Array(_);S!==b;){for(var O=u[S],L=0,E=_-1;(O!==0||L<w)&&E!==-1;E--,L++)O+=256*x[E]>>>0,x[E]=O%a>>>0,O=O/a>>>0;if(O!==0)throw new Error("Non-zero carry");w=L,S++;}for(var C=_-w;C!==_&&x[C]===0;)C++;for(var F=c.repeat(y);C<_;++C)F+=e.charAt(x[C]);return F}function m(u){if(typeof u!="string")throw new TypeError("Expected String");if(u.length===0)return new Uint8Array;var y=0;if(u[y]!==" "){for(var w=0,S=0;u[y]===c;)w++,y++;for(var b=(u.length-y)*h+1>>>0,_=new Uint8Array(b);u[y];){var x=r[u.charCodeAt(y)];if(x===255)return;for(var O=0,L=b-1;(x!==0||O<S)&&L!==-1;L--,O++)x+=a*_[L]>>>0,_[L]=x%256>>>0,x=x/256>>>0;if(x!==0)throw new Error("Non-zero carry");S=O,y++;}if(u[y]!==" "){for(var E=b-S;E!==b&&_[E]===0;)E++;for(var C=new Uint8Array(w+(b-E)),F=w;E!==b;)C[F++]=_[E++];return C}}}function p(u){var y=m(u);if(y)return y;throw new Error(`Non-${t} character`)}return {encode:f,decodeUnsafe:m,decode:p}}var LD=ND,MD=LD,vm=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")},FD=e=>new TextEncoder().encode(e),BD=e=>new TextDecoder().decode(e),Pc=class{constructor(t,r,n){this.name=t,this.prefix=r,this.baseEncode=n;}encode(t){if(t instanceof Uint8Array)return `${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Nc=class{constructor(t,r,n){if(this.name=t,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n;}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return xm(this,t)}},Lc=class{constructor(t){this.decoders=t;}or(t){return xm(this,t)}decode(t){let r=t[0],n=this.decoders[r];if(n)return n.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}},xm=(e,t)=>new Lc(M(M({},e.decoders||{[e.prefix]:e}),t.decoders||{[t.prefix]:t})),Mc=class{constructor(t,r,n,i){this.name=t,this.prefix=r,this.baseEncode=n,this.baseDecode=i,this.encoder=new Pc(t,r,n),this.decoder=new Nc(t,r,i);}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}},is=({name:e,prefix:t,encode:r,decode:n})=>new Mc(e,t,r,n),En=({prefix:e,name:t,alphabet:r})=>{let{encode:n,decode:i}=MD(r,t);return is({prefix:e,name:t,encode:n,decode:s=>vm(i(s))})},kD=(e,t,r,n)=>{let i={};for(let l=0;l<t.length;++l)i[t[l]]=l;let s=e.length;for(;e[s-1]==="=";)--s;let o=new Uint8Array(s*r/8|0),a=0,c=0,h=0;for(let l=0;l<s;++l){let f=i[e[l]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<r|f,a+=r,a>=8&&(a-=8,o[h++]=255&c>>a);}if(a>=r||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},UD=(e,t,r)=>{let n=t[t.length-1]==="=",i=(1<<r)-1,s="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>r;)o-=r,s+=t[i&a>>o];if(o&&(s+=t[i&a<<r-o]),n)for(;s.length*r&7;)s+="=";return s},be=({name:e,prefix:t,bitsPerChar:r,alphabet:n})=>is({prefix:t,name:e,encode(i){return UD(i,n,r)},decode(i){return kD(i,n,r,e)}}),WD=is({prefix:"\0",name:"identity",encode:e=>BD(e),decode:e=>FD(e)}),KD=Object.freeze({__proto__:null,identity:WD}),jD=be({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),zD=Object.freeze({__proto__:null,base2:jD}),$D=be({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),qD=Object.freeze({__proto__:null,base8:$D}),GD=En({prefix:"9",name:"base10",alphabet:"0123456789"}),VD=Object.freeze({__proto__:null,base10:GD}),HD=be({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),JD=be({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),YD=Object.freeze({__proto__:null,base16:HD,base16upper:JD}),XD=be({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),QD=be({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),ZD=be({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),eA=be({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),tA=be({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),rA=be({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),nA=be({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),iA=be({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),sA=be({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),oA=Object.freeze({__proto__:null,base32:XD,base32upper:QD,base32pad:ZD,base32padupper:eA,base32hex:tA,base32hexupper:rA,base32hexpad:nA,base32hexpadupper:iA,base32z:sA}),aA=En({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),cA=En({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),lA=Object.freeze({__proto__:null,base36:aA,base36upper:cA}),uA=En({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),fA=En({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),hA=Object.freeze({__proto__:null,base58btc:uA,base58flickr:fA}),dA=be({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),pA=be({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),gA=be({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),mA=be({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),yA=Object.freeze({__proto__:null,base64:dA,base64pad:pA,base64url:gA,base64urlpad:mA}),Cm=Array.from("\u{1F680}\u{1FA90}\u2604\u{1F6F0}\u{1F30C}\u{1F311}\u{1F312}\u{1F313}\u{1F314}\u{1F315}\u{1F316}\u{1F317}\u{1F318}\u{1F30D}\u{1F30F}\u{1F30E}\u{1F409}\u2600\u{1F4BB}\u{1F5A5}\u{1F4BE}\u{1F4BF}\u{1F602}\u2764\u{1F60D}\u{1F923}\u{1F60A}\u{1F64F}\u{1F495}\u{1F62D}\u{1F618}\u{1F44D}\u{1F605}\u{1F44F}\u{1F601}\u{1F525}\u{1F970}\u{1F494}\u{1F496}\u{1F499}\u{1F622}\u{1F914}\u{1F606}\u{1F644}\u{1F4AA}\u{1F609}\u263A\u{1F44C}\u{1F917}\u{1F49C}\u{1F614}\u{1F60E}\u{1F607}\u{1F339}\u{1F926}\u{1F389}\u{1F49E}\u270C\u2728\u{1F937}\u{1F631}\u{1F60C}\u{1F338}\u{1F64C}\u{1F60B}\u{1F497}\u{1F49A}\u{1F60F}\u{1F49B}\u{1F642}\u{1F493}\u{1F929}\u{1F604}\u{1F600}\u{1F5A4}\u{1F603}\u{1F4AF}\u{1F648}\u{1F447}\u{1F3B6}\u{1F612}\u{1F92D}\u2763\u{1F61C}\u{1F48B}\u{1F440}\u{1F62A}\u{1F611}\u{1F4A5}\u{1F64B}\u{1F61E}\u{1F629}\u{1F621}\u{1F92A}\u{1F44A}\u{1F973}\u{1F625}\u{1F924}\u{1F449}\u{1F483}\u{1F633}\u270B\u{1F61A}\u{1F61D}\u{1F634}\u{1F31F}\u{1F62C}\u{1F643}\u{1F340}\u{1F337}\u{1F63B}\u{1F613}\u2B50\u2705\u{1F97A}\u{1F308}\u{1F608}\u{1F918}\u{1F4A6}\u2714\u{1F623}\u{1F3C3}\u{1F490}\u2639\u{1F38A}\u{1F498}\u{1F620}\u261D\u{1F615}\u{1F33A}\u{1F382}\u{1F33B}\u{1F610}\u{1F595}\u{1F49D}\u{1F64A}\u{1F639}\u{1F5E3}\u{1F4AB}\u{1F480}\u{1F451}\u{1F3B5}\u{1F91E}\u{1F61B}\u{1F534}\u{1F624}\u{1F33C}\u{1F62B}\u26BD\u{1F919}\u2615\u{1F3C6}\u{1F92B}\u{1F448}\u{1F62E}\u{1F646}\u{1F37B}\u{1F343}\u{1F436}\u{1F481}\u{1F632}\u{1F33F}\u{1F9E1}\u{1F381}\u26A1\u{1F31E}\u{1F388}\u274C\u270A\u{1F44B}\u{1F630}\u{1F928}\u{1F636}\u{1F91D}\u{1F6B6}\u{1F4B0}\u{1F353}\u{1F4A2}\u{1F91F}\u{1F641}\u{1F6A8}\u{1F4A8}\u{1F92C}\u2708\u{1F380}\u{1F37A}\u{1F913}\u{1F619}\u{1F49F}\u{1F331}\u{1F616}\u{1F476}\u{1F974}\u25B6\u27A1\u2753\u{1F48E}\u{1F4B8}\u2B07\u{1F628}\u{1F31A}\u{1F98B}\u{1F637}\u{1F57A}\u26A0\u{1F645}\u{1F61F}\u{1F635}\u{1F44E}\u{1F932}\u{1F920}\u{1F927}\u{1F4CC}\u{1F535}\u{1F485}\u{1F9D0}\u{1F43E}\u{1F352}\u{1F617}\u{1F911}\u{1F30A}\u{1F92F}\u{1F437}\u260E\u{1F4A7}\u{1F62F}\u{1F486}\u{1F446}\u{1F3A4}\u{1F647}\u{1F351}\u2744\u{1F334}\u{1F4A3}\u{1F438}\u{1F48C}\u{1F4CD}\u{1F940}\u{1F922}\u{1F445}\u{1F4A1}\u{1F4A9}\u{1F450}\u{1F4F8}\u{1F47B}\u{1F910}\u{1F92E}\u{1F3BC}\u{1F975}\u{1F6A9}\u{1F34E}\u{1F34A}\u{1F47C}\u{1F48D}\u{1F4E3}\u{1F942}"),wA=Cm.reduce((e,t,r)=>(e[r]=t,e),[]),bA=Cm.reduce((e,t,r)=>(e[t.codePointAt(0)]=r,e),[]);function SA(e){return e.reduce((t,r)=>(t+=wA[r],t),"")}function _A(e){let t=[];for(let r of e){let n=bA[r.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${r}`);t.push(n);}return new Uint8Array(t)}var EA=is({prefix:"\u{1F680}",name:"base256emoji",encode:SA,decode:_A}),vA=Object.freeze({__proto__:null,base256emoji:EA}),xA=Im,Jg=128,CA=127,IA=~CA,DA=Math.pow(2,31);function Im(e,t,r){t=t||[],r=r||0;for(var n=r;e>=DA;)t[r++]=e&255|Jg,e/=128;for(;e&IA;)t[r++]=e&255|Jg,e>>>=7;return t[r]=e|0,Im.bytes=r-n+1,t}var AA=Fc,OA=128,Yg=127;function Fc(e,n){var r=0,n=n||0,i=0,s=n,o,a=e.length;do{if(s>=a)throw Fc.bytes=0,new RangeError("Could not decode varint");o=e[s++],r+=i<28?(o&Yg)<<i:(o&Yg)*Math.pow(2,i),i+=7;}while(o>=OA);return Fc.bytes=s-n,r}var TA=Math.pow(2,7),RA=Math.pow(2,14),PA=Math.pow(2,21),NA=Math.pow(2,28),LA=Math.pow(2,35),MA=Math.pow(2,42),FA=Math.pow(2,49),BA=Math.pow(2,56),kA=Math.pow(2,63),UA=function(e){return e<TA?1:e<RA?2:e<PA?3:e<NA?4:e<LA?5:e<MA?6:e<FA?7:e<BA?8:e<kA?9:10},WA={encode:xA,decode:AA,encodingLength:UA},Dm=WA,Xg=(e,t,r=0)=>(Dm.encode(e,t,r),t),Qg=e=>Dm.encodingLength(e),Bc=(e,t)=>{let r=t.byteLength,n=Qg(e),i=n+Qg(r),s=new Uint8Array(i+r);return Xg(e,s,0),Xg(r,s,n),s.set(t,i),new kc(e,r,t,s)},kc=class{constructor(t,r,n,i){this.code=t,this.size=r,this.digest=n,this.bytes=i;}},Am=({name:e,code:t,encode:r})=>new Uc(e,t,r),Uc=class{constructor(t,r,n){this.name=t,this.code=r,this.encode=n;}digest(t){if(t instanceof Uint8Array){let r=this.encode(t);return r instanceof Uint8Array?Bc(this.code,r):r.then(n=>Bc(this.code,n))}else throw Error("Unknown type, must be binary type")}},Om=e=>t=>g(void 0,null,function*(){return new Uint8Array(yield crypto.subtle.digest(e,t))}),KA=Am({name:"sha2-256",code:18,encode:Om("SHA-256")}),jA=Am({name:"sha2-512",code:19,encode:Om("SHA-512")}),zA=Object.freeze({__proto__:null,sha256:KA,sha512:jA}),Tm=0,$A="identity",Rm=vm,qA=e=>Bc(Tm,Rm(e)),GA={code:Tm,name:$A,encode:Rm,digest:qA},VA=Object.freeze({__proto__:null,identity:GA});new TextEncoder,new TextDecoder;var Zg=M(M(M(M(M(M(M(M(M(M({},KD),zD),qD),VD),YD),oA),lA),hA),yA),vA);M(M({},zA),VA);function HA(e=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}function Pm(e,t,r,n){return {name:e,prefix:t,encoder:{name:e,prefix:t,encode:r},decoder:{decode:n}}}var em=Pm("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Cc=Pm("ascii","a",e=>{let t="a";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return t},e=>{e=e.substring(1);let t=HA(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t}),JA=M({utf8:em,"utf-8":em,hex:Zg.base16,latin1:Cc,ascii:Cc,binary:Cc},Zg);function YA(e,t="utf8"){let r=JA[t];if(!r)throw new Error(`Unsupported encoding "${t}"`);return (t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(e,"utf8"):r.decoder.decode(`${r.prefix}${e}`)}var Wc=class{constructor(t,r){this.core=t,this.logger=r,this.keychain=new Map,this.name=tD,this.version=rD,this.initialized=!1,this.storagePrefix=ot,this.init=()=>g(this,null,function*(){if(!this.initialized){let n=yield this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0;}}),this.has=n=>(this.isInitialized(),this.keychain.has(n)),this.set=(n,i)=>g(this,null,function*(){this.isInitialized(),this.keychain.set(n,i),yield this.persist();}),this.get=n=>{this.isInitialized();let i=this.keychain.get(n);if(typeof i>"u"){let{message:s}=utils.getInternalError("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(s)}return i},this.del=n=>g(this,null,function*(){this.isInitialized(),this.keychain.delete(n),yield this.persist();}),this.core=t,this.logger=Re(r,this.name);}get context(){return Be(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}setKeyChain(t){return g(this,null,function*(){yield this.core.storage.setItem(this.storageKey,utils.mapToObj(t));})}getKeyChain(){return g(this,null,function*(){let t=yield this.core.storage.getItem(this.storageKey);return typeof t<"u"?utils.objToMap(t):void 0})}persist(){return g(this,null,function*(){yield this.setKeyChain(this.keychain);})}isInitialized(){if(!this.initialized){let{message:t}=utils.getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}},Kc=class{constructor(t,r,n){this.core=t,this.logger=r,this.name=ZI,this.randomSessionIdentifier=utils.generateRandomBytes32(),this.initialized=!1,this.init=()=>g(this,null,function*(){this.initialized||(yield this.keychain.init(),this.initialized=!0);}),this.hasKeys=i=>(this.isInitialized(),this.keychain.has(i)),this.getClientId=()=>g(this,null,function*(){this.isInitialized();let i=yield this.getClientSeed(),s=wa(i);return Ei(s.publicKey)}),this.generateKeyPair=()=>{this.isInitialized();let i=utils.generateKeyPair();return this.setPrivateKey(i.publicKey,i.privateKey)},this.signJWT=i=>g(this,null,function*(){this.isInitialized();let s=yield this.getClientSeed(),o=wa(s),a=this.randomSessionIdentifier;return yield Sd(a,i,eD,o)}),this.generateSharedKey=(i,s,o)=>{this.isInitialized();let a=this.getPrivateKey(i),c=utils.deriveSymKey(a,s);return this.setSymKey(c,o)},this.setSymKey=(i,s)=>g(this,null,function*(){this.isInitialized();let o=s||utils.hashKey(i);return yield this.keychain.set(o,i),o}),this.deleteKeyPair=i=>g(this,null,function*(){this.isInitialized(),yield this.keychain.del(i);}),this.deleteSymKey=i=>g(this,null,function*(){this.isInitialized(),yield this.keychain.del(i);}),this.encode=(i,s,o)=>g(this,null,function*(){this.isInitialized();let a=utils.validateEncoding(o),c=$e(s);if(utils.isTypeTwoEnvelope(a))return utils.encodeTypeTwoEnvelope(c,o==null?void 0:o.encoding);if(utils.isTypeOneEnvelope(a)){let m=a.senderPublicKey,p=a.receiverPublicKey;i=yield this.generateSharedKey(m,p);}let h=this.getSymKey(i),{type:l,senderPublicKey:f}=a;return utils.encrypt({type:l,symKey:h,message:c,senderPublicKey:f,encoding:o==null?void 0:o.encoding})}),this.decode=(i,s,o)=>g(this,null,function*(){this.isInitialized();let a=utils.validateDecoding(s,o);if(utils.isTypeTwoEnvelope(a)){let c=utils.decodeTypeTwoEnvelope(s,o==null?void 0:o.encoding);return Ze(c)}if(utils.isTypeOneEnvelope(a)){let c=a.receiverPublicKey,h=a.senderPublicKey;i=yield this.generateSharedKey(c,h);}try{let c=this.getSymKey(i),h=utils.decrypt({symKey:c,encoded:s,encoding:o==null?void 0:o.encoding});return Ze(h)}catch(c){this.logger.error(`Failed to decode message from topic: '${i}', clientId: '${yield this.getClientId()}'`),this.logger.error(c);}}),this.getPayloadType=(i,s=utils.BASE64)=>{let o=utils.deserialize({encoded:i,encoding:s});return utils.decodeTypeByte(o.type)},this.getPayloadSenderPublicKey=(i,s=utils.BASE64)=>{let o=utils.deserialize({encoded:i,encoding:s});return o.senderPublicKey?_a(o.senderPublicKey,utils.BASE16):void 0},this.core=t,this.logger=Re(r,this.name),this.keychain=n||new Wc(this.core,this.logger);}get context(){return Be(this.logger)}setPrivateKey(t,r){return g(this,null,function*(){return yield this.keychain.set(t,r),t})}getPrivateKey(t){return this.keychain.get(t)}getClientSeed(){return g(this,null,function*(){let t="";try{t=this.keychain.get(Vg);}catch(r){t=utils.generateRandomBytes32(),yield this.keychain.set(Vg,t);}return YA(t,"base16")})}getSymKey(t){return this.keychain.get(t)}isInitialized(){if(!this.initialized){let{message:t}=utils.getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}},jc=class extends types.IMessageTracker{constructor(t,r){super(t,r),this.logger=t,this.core=r,this.messages=new Map,this.name=nD,this.version=iD,this.initialized=!1,this.storagePrefix=ot,this.init=()=>g(this,null,function*(){if(!this.initialized){this.logger.trace("Initialized");try{let n=yield this.getRelayerMessages();typeof n<"u"&&(this.messages=n),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size});}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n);}finally{this.initialized=!0;}}}),this.set=(n,i)=>g(this,null,function*(){this.isInitialized();let s=utils.hashMessage(i),o=this.messages.get(n);return typeof o>"u"&&(o={}),typeof o[s]<"u"||(o[s]=i,this.messages.set(n,o),yield this.persist()),s}),this.get=n=>{this.isInitialized();let i=this.messages.get(n);return typeof i>"u"&&(i={}),i},this.has=(n,i)=>{this.isInitialized();let s=this.get(n),o=utils.hashMessage(i);return typeof s[o]<"u"},this.del=n=>g(this,null,function*(){this.isInitialized(),this.messages.delete(n),yield this.persist();}),this.logger=Re(t,this.name),this.core=r;}get context(){return Be(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}setRelayerMessages(t){return g(this,null,function*(){yield this.core.storage.setItem(this.storageKey,utils.mapToObj(t));})}getRelayerMessages(){return g(this,null,function*(){let t=yield this.core.storage.getItem(this.storageKey);return typeof t<"u"?utils.objToMap(t):void 0})}persist(){return g(this,null,function*(){yield this.setRelayerMessages(this.messages);})}isInitialized(){if(!this.initialized){let{message:t}=utils.getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}},zc=class extends types.IPublisher{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.events=new fI.EventEmitter,this.name=oD,this.queue=new Map,this.publishTimeout=(0, j.toMiliseconds)(j.ONE_MINUTE),this.failedPublishTimeout=(0, j.toMiliseconds)(j.ONE_SECOND),this.needsTransportRestart=!1,this.publish=(n,i,s)=>g(this,null,function*(){var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:i,opts:s}});let a=(s==null?void 0:s.ttl)||sD,c=utils.getRelayProtocolName(s),h=(s==null?void 0:s.prompt)||!1,l=(s==null?void 0:s.tag)||0,f=(s==null?void 0:s.id)||mr().toString(),m={topic:n,message:i,opts:{ttl:a,relay:c,prompt:h,tag:l,id:f,attestation:s==null?void 0:s.attestation}},p=`Failed to publish payload, please try again. id:${f} tag:${l}`,u=Date.now(),y,w=1;try{for(;y===void 0;){if(Date.now()-u>this.publishTimeout)throw new Error(p);this.logger.trace({id:f,attempts:w},`publisher.publish - attempt ${w}`),y=yield yield utils.createExpiringPromise(this.rpcPublish(n,i,a,c,h,l,f,s==null?void 0:s.attestation).catch(S=>this.logger.warn(S)),this.publishTimeout,p),w++,y||(yield new Promise(S=>setTimeout(S,this.failedPublishTimeout)));}this.relayer.events.emit(je.publish,m),this.logger.debug("Successfully Published Payload"),this.logger.trace({type:"method",method:"publish",params:{id:f,topic:n,message:i,opts:s}});}catch(S){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(S),(o=s==null?void 0:s.internal)!=null&&o.throwOnFailedPublish)throw S;this.queue.set(f,m);}}),this.on=(n,i)=>{this.events.on(n,i);},this.once=(n,i)=>{this.events.once(n,i);},this.off=(n,i)=>{this.events.off(n,i);},this.removeListener=(n,i)=>{this.events.removeListener(n,i);},this.relayer=t,this.logger=Re(r,this.name),this.registerEventListeners();}get context(){return Be(this.logger)}rpcPublish(t,r,n,i,s,o,a,c){var h,l,f,m;let p={method:utils.getRelayProtocolApi(i.protocol).publish,params:{topic:t,message:r,ttl:n,prompt:s,tag:o,attestation:c},id:a};return utils.isUndefined((h=p.params)==null?void 0:h.prompt)&&((l=p.params)==null||delete l.prompt),utils.isUndefined((f=p.params)==null?void 0:f.tag)&&((m=p.params)==null||delete m.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:p}),this.relayer.request(p)}removeRequestFromQueue(t){this.queue.delete(t);}checkQueue(){this.queue.forEach(t=>g(this,null,function*(){let{topic:r,message:n,opts:i}=t;yield this.publish(r,n,i);}));}registerEventListeners(){this.relayer.core.heartbeat.on(Rt.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(je.connection_stalled);return}this.checkQueue();}),this.relayer.on(je.message_ack,t=>{this.removeRequestFromQueue(t.id.toString());});}},$c=class{constructor(){this.map=new Map,this.set=(t,r)=>{let n=this.get(t);this.exists(t,r)||this.map.set(t,[...n,r]);},this.get=t=>this.map.get(t)||[],this.exists=(t,r)=>this.get(t).includes(r),this.delete=(t,r)=>{if(typeof r>"u"){this.map.delete(t);return}if(!this.map.has(t))return;let n=this.get(t);if(!this.exists(t,r))return;let i=n.filter(s=>s!==r);if(!i.length){this.map.delete(t);return}this.map.set(t,i);},this.clear=()=>{this.map.clear();};}get topics(){return Array.from(this.map.keys())}},XA=Object.defineProperty,QA=Object.defineProperties,ZA=Object.getOwnPropertyDescriptors,tm=Object.getOwnPropertySymbols,eO=Object.prototype.hasOwnProperty,tO=Object.prototype.propertyIsEnumerable,rm=(e,t,r)=>t in e?XA(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,yn=(e,t)=>{for(var r in t||(t={}))eO.call(t,r)&&rm(e,r,t[r]);if(tm)for(var r of tm(t))tO.call(t,r)&&rm(e,r,t[r]);return e},Ic=(e,t)=>QA(e,ZA(t)),qc=class extends types.ISubscriber{constructor(t,r){super(t,r),this.relayer=t,this.logger=r,this.subscriptions=new Map,this.topicMap=new $c,this.events=new fI.EventEmitter,this.name=pD,this.version=gD,this.pending=new Map,this.cached=[],this.initialized=!1,this.pendingSubscriptionWatchLabel="pending_sub_watch_label",this.pollingInterval=20,this.storagePrefix=ot,this.subscribeTimeout=(0, j.toMiliseconds)(j.ONE_MINUTE),this.restartInProgress=!1,this.batchSubscribeTopicsLimit=500,this.pendingBatchMessages=[],this.init=()=>g(this,null,function*(){this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),this.clientId=yield this.relayer.core.crypto.getClientId(),yield this.restore()),this.initialized=!0;}),this.subscribe=(n,i)=>g(this,null,function*(){this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}});try{let s=utils.getRelayProtocolName(i),o={topic:n,relay:s,transportType:i==null?void 0:i.transportType};this.pending.set(n,o);let a=yield this.rpcSubscribe(n,s,i);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:i}})),a}catch(s){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(s),s}}),this.unsubscribe=(n,i)=>g(this,null,function*(){yield this.restartToComplete(),this.isInitialized(),typeof(i==null?void 0:i.id)<"u"?yield this.unsubscribeById(n,i.id,i):yield this.unsubscribeByTopic(n,i);}),this.isSubscribed=n=>g(this,null,function*(){if(this.topics.includes(n))return !0;let i=`${this.pendingSubscriptionWatchLabel}_${n}`;return yield new Promise((s,o)=>{let a=new j.Watch;a.start(i);let c=setInterval(()=>{!this.pending.has(n)&&this.topics.includes(n)&&(clearInterval(c),a.stop(i),s(!0)),a.elapsed(i)>=mD&&(clearInterval(c),a.stop(i),o(new Error("Subscription resolution timeout")));},this.pollingInterval);}).catch(()=>!1)}),this.on=(n,i)=>{this.events.on(n,i);},this.once=(n,i)=>{this.events.once(n,i);},this.off=(n,i)=>{this.events.off(n,i);},this.removeListener=(n,i)=>{this.events.removeListener(n,i);},this.start=()=>g(this,null,function*(){yield this.onConnect();}),this.stop=()=>g(this,null,function*(){yield this.onDisconnect();}),this.restart=()=>g(this,null,function*(){this.restartInProgress=!0,yield this.restore(),yield this.reset(),this.restartInProgress=!1;}),this.relayer=t,this.logger=Re(r,this.name),this.clientId="";}get context(){return Be(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}hasSubscription(t,r){let n=!1;try{n=this.getSubscription(t).topic===r;}catch(i){}return n}onEnable(){this.cached=[],this.initialized=!0;}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear();}unsubscribeByTopic(t,r){return g(this,null,function*(){let n=this.topicMap.get(t);yield Promise.all(n.map(i=>g(this,null,function*(){return yield this.unsubscribeById(t,i,r)})));})}unsubscribeById(t,r,n){return g(this,null,function*(){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:r,opts:n}});try{let i=utils.getRelayProtocolName(n);yield this.rpcUnsubscribe(t,r,i);let s=utils.getSdkError("USER_DISCONNECTED",`${this.name}, ${t}`);yield this.onUnsubscribe(t,r,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:t,id:r,opts:n}});}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}})}rpcSubscribe(t,r,n){return g(this,null,function*(){var i;(n==null?void 0:n.transportType)===Cr.relay&&(yield this.restartToComplete());let s={method:utils.getRelayProtocolApi(r.protocol).subscribe,params:{topic:t}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});let o=(i=n==null?void 0:n.internal)==null?void 0:i.throwOnFailedPublish;try{let a=utils.hashMessage(t+this.clientId);if((n==null?void 0:n.transportType)===Cr.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(s).catch(h=>this.logger.warn(h));},(0,j.toMiliseconds)(j.ONE_SECOND)),a;let c=yield utils.createExpiringPromise(this.relayer.request(s).catch(h=>this.logger.warn(h)),this.subscribeTimeout,`Subscribing to ${t} failed, please try again`);if(!c&&o)throw new Error(`Subscribing to ${t} failed, please try again`);return c?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(je.connection_stalled),o)throw a}return null})}rpcBatchSubscribe(t){return g(this,null,function*(){if(!t.length)return;let r=t[0].relay,n={method:utils.getRelayProtocolApi(r.protocol).batchSubscribe,params:{topics:t.map(i=>i.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{return yield yield utils.createExpiringPromise(this.relayer.request(n).catch(i=>this.logger.warn(i)),this.subscribeTimeout)}catch(i){this.relayer.events.emit(je.connection_stalled);}})}rpcBatchFetchMessages(t){return g(this,null,function*(){if(!t.length)return;let r=t[0].relay,n={method:utils.getRelayProtocolApi(r.protocol).batchFetchMessages,params:{topics:t.map(s=>s.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});let i;try{i=yield yield utils.createExpiringPromise(this.relayer.request(n).catch(s=>this.logger.warn(s)),this.subscribeTimeout);}catch(s){this.relayer.events.emit(je.connection_stalled);}return i})}rpcUnsubscribe(t,r,n){let i={method:utils.getRelayProtocolApi(n.protocol).unsubscribe,params:{topic:t,id:r}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(t,r){this.setSubscription(t,Ic(yn({},r),{id:t})),this.pending.delete(r.topic);}onBatchSubscribe(t){t.length&&t.forEach(r=>{this.setSubscription(r.id,yn({},r)),this.pending.delete(r.topic);});}onUnsubscribe(t,r,n){return g(this,null,function*(){this.events.removeAllListeners(r),this.hasSubscription(r,t)&&this.deleteSubscription(r,n),yield this.relayer.messages.del(t);})}setRelayerSubscriptions(t){return g(this,null,function*(){yield this.relayer.core.storage.setItem(this.storageKey,t);})}getRelayerSubscriptions(){return g(this,null,function*(){return yield this.relayer.core.storage.getItem(this.storageKey)})}setSubscription(t,r){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:t,subscription:r}),this.addSubscription(t,r);}addSubscription(t,r){this.subscriptions.set(t,yn({},r)),this.topicMap.set(r.topic,t),this.events.emit(st.created,r);}getSubscription(t){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:t});let r=this.subscriptions.get(t);if(!r){let{message:n}=utils.getInternalError("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(n)}return r}deleteSubscription(t,r){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:t,reason:r});let n=this.getSubscription(t);this.subscriptions.delete(t),this.topicMap.delete(n.topic,t),this.events.emit(st.deleted,Ic(yn({},n),{reason:r}));}persist(){return g(this,null,function*(){yield this.setRelayerSubscriptions(this.values),this.events.emit(st.sync);})}reset(){return g(this,null,function*(){if(this.cached.length){let t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let r=0;r<t;r++){let n=this.cached.splice(0,this.batchSubscribeTopicsLimit);yield this.batchFetchMessages(n),yield this.batchSubscribe(n);}}this.events.emit(st.resubscribed);})}restore(){return g(this,null,function*(){try{let t=yield this.getRelayerSubscriptions();if(typeof t>"u"||!t.length)return;if(this.subscriptions.size){let{message:r}=utils.getInternalError("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values});}catch(t){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(t);}})}batchSubscribe(t){return g(this,null,function*(){if(!t.length)return;let r=yield this.rpcBatchSubscribe(t);utils.isValidArray(r)&&this.onBatchSubscribe(r.map((n,i)=>Ic(yn({},t[i]),{id:n})));})}batchFetchMessages(t){return g(this,null,function*(){if(!t.length)return;this.logger.trace(`Fetching batch messages for ${t.length} subscriptions`);let r=yield this.rpcBatchFetchMessages(t);r&&r.messages&&(this.pendingBatchMessages=this.pendingBatchMessages.concat(r.messages));})}onConnect(){return g(this,null,function*(){yield this.restart(),this.onEnable();})}onDisconnect(){this.onDisable();}checkPending(){return g(this,null,function*(){if(!this.initialized||!this.relayer.connected)return;let t=[];this.pending.forEach(r=>{t.push(r);}),yield this.batchSubscribe(t),this.pendingBatchMessages.length&&(yield this.relayer.handleBatchMessageEvents(this.pendingBatchMessages),this.pendingBatchMessages=[]);})}registerEventListeners(){this.relayer.core.heartbeat.on(Rt.pulse,()=>g(this,null,function*(){yield this.checkPending();})),this.events.on(st.created,t=>g(this,null,function*(){let r=st.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),yield this.persist();})),this.events.on(st.deleted,t=>g(this,null,function*(){let r=st.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),yield this.persist();}));}isInitialized(){if(!this.initialized){let{message:t}=utils.getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}restartToComplete(){return g(this,null,function*(){!this.relayer.connected&&!this.relayer.connecting&&(yield this.relayer.transportOpen()),this.restartInProgress&&(yield new Promise(t=>{let r=setInterval(()=>{this.restartInProgress||(clearInterval(r),t());},this.pollingInterval);}));})}},rO=Object.defineProperty,nm=Object.getOwnPropertySymbols,nO=Object.prototype.hasOwnProperty,iO=Object.prototype.propertyIsEnumerable,im=(e,t,r)=>t in e?rO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,sm=(e,t)=>{for(var r in t||(t={}))nO.call(t,r)&&im(e,r,t[r]);if(nm)for(var r of nm(t))iO.call(t,r)&&im(e,r,t[r]);return e},Gc=class extends types.IRelayer{constructor(t){super(t),this.protocol="wc",this.version=2,this.events=new fI.EventEmitter,this.name=lD,this.transportExplicitlyClosed=!1,this.initialized=!1,this.connectionAttemptInProgress=!1,this.connectionStatusPollingInterval=20,this.staleConnectionErrors=["socket hang up","stalled","interrupted"],this.hasExperiencedNetworkDisruption=!1,this.requestsInFlight=new Map,this.heartBeatTimeout=(0, j.toMiliseconds)(j.THIRTY_SECONDS+j.ONE_SECOND),this.request=r=>g(this,null,function*(){var n,i;this.logger.debug("Publishing Request Payload");let s=r.id||mr().toString();yield this.toEstablishConnection();try{let o=this.provider.request(r);this.requestsInFlight.set(s,{promise:o,request:r}),this.logger.trace({id:s,method:r.method,topic:(n=r.params)==null?void 0:n.topic},"relayer.request - attempt to publish...");let a=yield new Promise((c,h)=>g(this,null,function*(){let l=()=>{h(new Error(`relayer.request - publish interrupted, id: ${s}`));};this.provider.on(Ge.disconnect,l);let f=yield o;this.provider.off(Ge.disconnect,l),c(f);}));return this.logger.trace({id:s,method:r.method,topic:(i=r.params)==null?void 0:i.topic},"relayer.request - published"),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${s}`),o}finally{this.requestsInFlight.delete(s);}}),this.resetPingTimeout=()=>{if(utils.isNode())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var r,n,i;(i=(n=(r=this.provider)==null?void 0:r.connection)==null?void 0:n.socket)==null||i.terminate();},this.heartBeatTimeout);}catch(r){this.logger.warn(r);}},this.onPayloadHandler=r=>{this.onProviderPayload(r),this.resetPingTimeout();},this.onConnectHandler=()=>{this.logger.trace("relayer connected"),this.startPingTimeout(),this.events.emit(je.connect);},this.onDisconnectHandler=()=>{this.logger.trace("relayer disconnected"),this.onProviderDisconnect();},this.onProviderErrorHandler=r=>{this.logger.error(r),this.events.emit(je.error,r),this.logger.info("Fatal socket error received, closing transport"),this.transportClose();},this.registerProviderListeners=()=>{this.provider.on(Ge.payload,this.onPayloadHandler),this.provider.on(Ge.connect,this.onConnectHandler),this.provider.on(Ge.disconnect,this.onDisconnectHandler),this.provider.on(Ge.error,this.onProviderErrorHandler);},this.core=t.core,this.logger=typeof t.logger<"u"&&typeof t.logger!="string"?Re(t.logger,this.name):(0, Do.default)(Oo({level:t.logger||cD})),this.messages=new jc(this.logger,t.core),this.subscriber=new qc(this,this.logger),this.publisher=new zc(this,this.logger),this.relayUrl=(t==null?void 0:t.relayUrl)||_m,this.projectId=t.projectId,this.bundleId=utils.getBundleId(),this.provider={};}init(){return g(this,null,function*(){if(this.logger.trace("Initialized"),this.registerEventListeners(),yield Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.cached.length>0)try{yield this.transportOpen();}catch(t){this.logger.warn(t);}})}get context(){return Be(this.logger)}get connected(){var t,r,n;return ((n=(r=(t=this.provider)==null?void 0:t.connection)==null?void 0:r.socket)==null?void 0:n.readyState)===1}get connecting(){var t,r,n;return ((n=(r=(t=this.provider)==null?void 0:t.connection)==null?void 0:r.socket)==null?void 0:n.readyState)===0}publish(t,r,n){return g(this,null,function*(){this.isInitialized(),yield this.publisher.publish(t,r,n),yield this.recordMessageEvent({topic:t,message:r,publishedAt:Date.now(),transportType:Cr.relay});})}subscribe(t,r){return g(this,null,function*(){var n,i,s;this.isInitialized(),(r==null?void 0:r.transportType)==="relay"&&(yield this.toEstablishConnection());let o=typeof((n=r==null?void 0:r.internal)==null?void 0:n.throwOnFailedPublish)>"u"?!0:(i=r==null?void 0:r.internal)==null?void 0:i.throwOnFailedPublish,a=((s=this.subscriber.topicMap.get(t))==null?void 0:s[0])||"",c,h=l=>{l.topic===t&&(this.subscriber.off(st.created,h),c());};return yield Promise.all([new Promise(l=>{c=l,this.subscriber.on(st.created,h);}),new Promise((l,f)=>g(this,null,function*(){a=(yield this.subscriber.subscribe(t,sm({internal:{throwOnFailedPublish:o}},r)).catch(m=>{o&&f(m);}))||a,l();}))]),a})}unsubscribe(t,r){return g(this,null,function*(){this.isInitialized(),yield this.subscriber.unsubscribe(t,r);})}on(t,r){this.events.on(t,r);}once(t,r){this.events.once(t,r);}off(t,r){this.events.off(t,r);}removeListener(t,r){this.events.removeListener(t,r);}transportDisconnect(){return g(this,null,function*(){if(!this.hasExperiencedNetworkDisruption&&this.connected&&this.requestsInFlight.size>0)try{yield Promise.all(Array.from(this.requestsInFlight.values()).map(t=>t.promise));}catch(t){this.logger.warn(t);}this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?yield utils.createExpiringPromise(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect();})}transportClose(){return g(this,null,function*(){this.transportExplicitlyClosed=!0,yield this.transportDisconnect();})}transportOpen(t){return g(this,null,function*(){yield this.confirmOnlineStateOrThrow(),t&&t!==this.relayUrl&&(this.relayUrl=t,yield this.transportDisconnect()),yield this.createProvider(),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;try{yield new Promise((r,n)=>g(this,null,function*(){let i=()=>{this.provider.off(Ge.disconnect,i),n(new Error("Connection interrupted while trying to subscribe"));};this.provider.on(Ge.disconnect,i),yield utils.createExpiringPromise(this.provider.connect(),(0,j.toMiliseconds)(j.ONE_MINUTE),`Socket stalled when trying to connect to ${this.relayUrl}`).catch(s=>{n(s);}).finally(()=>{clearTimeout(this.reconnectTimeout),this.reconnectTimeout=void 0;}),this.subscriber.start().catch(s=>{this.logger.error(s),this.onDisconnectHandler();}),this.hasExperiencedNetworkDisruption=!1,r();}));}catch(r){this.logger.error(r);let n=r;if(this.hasExperiencedNetworkDisruption=!0,!this.isConnectionStalled(n.message))throw r}finally{this.connectionAttemptInProgress=!1;}})}restartTransport(t){return g(this,null,function*(){this.connectionAttemptInProgress||(this.relayUrl=t||this.relayUrl,yield this.confirmOnlineStateOrThrow(),yield this.transportClose(),yield this.transportOpen());})}confirmOnlineStateOrThrow(){return g(this,null,function*(){if(!(yield utils.isOnline()))throw new Error("No internet connection detected. Please restart your network and try again.")})}handleBatchMessageEvents(t){return g(this,null,function*(){if((t==null?void 0:t.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}let r=t.sort((n,i)=>n.publishedAt-i.publishedAt);this.logger.trace(`Batch of ${r.length} message events sorted`);for(let n of r)try{yield this.onMessageEvent(n);}catch(i){this.logger.warn(i);}this.logger.trace(`Batch of ${r.length} message events processed`);})}onLinkMessageEvent(t,r){return g(this,null,function*(){let{topic:n}=t;if(!r.sessionExists){let i=utils.calcExpiry(j.FIVE_MINUTES),s={topic:n,expiry:i,relay:{protocol:"irn"},active:!1};yield this.core.pairing.pairings.set(n,s);}this.events.emit(je.message,t),yield this.recordMessageEvent(t);})}startPingTimeout(){var t,r,n,i,s;if(utils.isNode())try{(r=(t=this.provider)==null?void 0:t.connection)!=null&&r.socket&&((s=(i=(n=this.provider)==null?void 0:n.connection)==null?void 0:i.socket)==null||s.once("ping",()=>{this.resetPingTimeout();})),this.resetPingTimeout();}catch(o){this.logger.warn(o);}}isConnectionStalled(t){return this.staleConnectionErrors.some(r=>t.includes(r))}createProvider(){return g(this,null,function*(){this.provider.connection&&this.unregisterProviderListeners();let t=yield this.core.crypto.signJWT(this.relayUrl);this.provider=new ki(new qi(utils.formatRelayRpcUrl({sdkVersion:Rc,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:t,useOnCloseEvent:!0,bundleId:this.bundleId}))),this.registerProviderListeners();})}recordMessageEvent(t){return g(this,null,function*(){let{topic:r,message:n}=t;yield this.messages.set(r,n);})}shouldIgnoreMessageEvent(t){return g(this,null,function*(){let{topic:r,message:n}=t;if(!n||n.length===0)return this.logger.debug(`Ignoring invalid/empty message: ${n}`),!0;if(!(yield this.subscriber.isSubscribed(r)))return this.logger.debug(`Ignoring message for non-subscribed topic ${r}`),!0;let i=this.messages.has(r,n);return i&&this.logger.debug(`Ignoring duplicate message: ${n}`),i})}onProviderPayload(t){return g(this,null,function*(){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:t}),Fi(t)){if(!t.method.endsWith(uD))return;let r=t.params,{topic:n,message:i,publishedAt:s,attestation:o}=r.data,a={topic:n,message:i,publishedAt:s,transportType:Cr.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(sm({type:"event",event:r.id},a)),this.events.emit(r.id,a),yield this.acknowledgePayload(t),yield this.onMessageEvent(a);}else wr(t)&&this.events.emit(je.message_ack,t);})}onMessageEvent(t){return g(this,null,function*(){(yield this.shouldIgnoreMessageEvent(t))||(this.events.emit(je.message,t),yield this.recordMessageEvent(t));})}acknowledgePayload(t){return g(this,null,function*(){let r=Ri(t.id,!0);yield this.provider.connection.send(r);})}unregisterProviderListeners(){this.provider.off(Ge.payload,this.onPayloadHandler),this.provider.off(Ge.connect,this.onConnectHandler),this.provider.off(Ge.disconnect,this.onDisconnectHandler),this.provider.off(Ge.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout);}registerEventListeners(){return g(this,null,function*(){let t=yield utils.isOnline();utils.subscribeToNetworkChange(r=>g(this,null,function*(){t!==r&&(t=r,r?yield this.restartTransport().catch(n=>this.logger.error(n)):(this.hasExperiencedNetworkDisruption=!0,yield this.transportDisconnect(),this.transportExplicitlyClosed=!1));}));})}onProviderDisconnect(){return g(this,null,function*(){yield this.subscriber.stop(),this.requestsInFlight.clear(),clearTimeout(this.pingTimeout),this.events.emit(je.disconnect),this.connectionAttemptInProgress=!1,!this.transportExplicitlyClosed&&(this.reconnectTimeout||(this.reconnectTimeout=setTimeout(()=>g(this,null,function*(){yield this.transportOpen().catch(t=>this.logger.error(t));}),(0, j.toMiliseconds)(fD))));})}isInitialized(){if(!this.initialized){let{message:t}=utils.getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}toEstablishConnection(){return g(this,null,function*(){yield this.confirmOnlineStateOrThrow(),!this.connected&&(this.connectionAttemptInProgress&&(yield new Promise(t=>{let r=setInterval(()=>{this.connected&&(clearInterval(r),t());},this.connectionStatusPollingInterval);})),yield this.transportOpen());})}},sO=Object.defineProperty,om=Object.getOwnPropertySymbols,oO=Object.prototype.hasOwnProperty,aO=Object.prototype.propertyIsEnumerable,am=(e,t,r)=>t in e?sO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,cm=(e,t)=>{for(var r in t||(t={}))oO.call(t,r)&&am(e,r,t[r]);if(om)for(var r of om(t))aO.call(t,r)&&am(e,r,t[r]);return e},Vc=class extends types.IStore{constructor(t,r,n,i=ot,s=void 0){super(t,r,n,i),this.core=t,this.logger=r,this.name=n,this.map=new Map,this.version=hD,this.cached=[],this.initialized=!1,this.storagePrefix=ot,this.recentlyDeleted=[],this.recentlyDeletedLimit=200,this.init=()=>g(this,null,function*(){this.initialized||(this.logger.trace("Initialized"),yield this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!utils.isUndefined(o)?this.map.set(this.getKey(o),o):utils.isProposalStruct(o)?this.map.set(o.id,o):utils.isSessionStruct(o)&&this.map.set(o.topic,o);}),this.cached=[],this.initialized=!0);}),this.set=(o,a)=>g(this,null,function*(){this.isInitialized(),this.map.has(o)?yield this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),yield this.persist());}),this.get=o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o)),this.getAll=o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>(0, ym.default)(a[c],o[c]))):this.values),this.update=(o,a)=>g(this,null,function*(){this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});let c=cm(cm({},this.getData(o)),a);this.map.set(o,c),yield this.persist();}),this.delete=(o,a)=>g(this,null,function*(){this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),yield this.persist());}),this.logger=Re(r,this.name),this.storagePrefix=i,this.getKey=s;}get context(){return Be(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(t){this.recentlyDeleted.push(t),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2);}setDataStore(t){return g(this,null,function*(){yield this.core.storage.setItem(this.storageKey,t);})}getDataStore(){return g(this,null,function*(){return yield this.core.storage.getItem(this.storageKey)})}getData(t){let r=this.map.get(t);if(!r){if(this.recentlyDeleted.includes(t)){let{message:i}=utils.getInternalError("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${t}`);throw this.logger.error(i),new Error(i)}let{message:n}=utils.getInternalError("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.error(n),new Error(n)}return r}persist(){return g(this,null,function*(){yield this.setDataStore(this.values);})}restore(){return g(this,null,function*(){try{let t=yield this.getDataStore();if(typeof t>"u"||!t.length)return;if(this.map.size){let{message:r}=utils.getInternalError("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values});}catch(t){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(t);}})}isInitialized(){if(!this.initialized){let{message:t}=utils.getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}},Hc=class{constructor(t,r){this.core=t,this.logger=r,this.name=yD,this.version=wD,this.events=new fI__default.default,this.initialized=!1,this.storagePrefix=ot,this.ignoredPayloadTypes=[utils.TYPE_1],this.registeredMethods=[],this.init=()=>g(this,null,function*(){this.initialized||(yield this.pairings.init(),yield this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"));}),this.register=({methods:n})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...n])];},this.create=n=>g(this,null,function*(){this.isInitialized();let i=utils.generateRandomBytes32(),s=yield this.core.crypto.setSymKey(i),o=utils.calcExpiry(j.FIVE_MINUTES),a={protocol:aD},c={topic:s,expiry:o,relay:a,active:!1,methods:n==null?void 0:n.methods},h=utils.formatUri({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:i,relay:a,expiryTimestamp:o,methods:n==null?void 0:n.methods});return this.events.emit(mn.create,c),this.core.expirer.set(s,o),yield this.pairings.set(s,c),yield this.core.relayer.subscribe(s,{transportType:n==null?void 0:n.transportType}),{topic:s,uri:h}}),this.pair=n=>g(this,null,function*(){this.isInitialized();let i=this.core.eventClient.createEvent({properties:{topic:n==null?void 0:n.uri,trace:[yt.pairing_started]}});this.isValidPair(n,i);let{topic:s,symKey:o,relay:a,expiryTimestamp:c,methods:h}=utils.parseUri(n.uri);i.props.properties.topic=s,i.addTrace(yt.pairing_uri_validation_success),i.addTrace(yt.pairing_uri_not_expired);let l;if(this.pairings.keys.includes(s)){if(l=this.pairings.get(s),i.addTrace(yt.existing_pairing),l.active)throw i.setError(At.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);i.addTrace(yt.pairing_not_expired);}let f=c||utils.calcExpiry(j.FIVE_MINUTES),m={topic:s,relay:a,expiry:f,active:!1,methods:h};this.core.expirer.set(s,f),yield this.pairings.set(s,m),i.addTrace(yt.store_new_pairing),n.activatePairing&&(yield this.activate({topic:s})),this.events.emit(mn.create,m),i.addTrace(yt.emit_inactive_pairing),this.core.crypto.keychain.has(s)||(yield this.core.crypto.setSymKey(o,s)),i.addTrace(yt.subscribing_pairing_topic);try{yield this.core.relayer.confirmOnlineStateOrThrow();}catch(p){i.setError(At.no_internet_connection);}try{yield this.core.relayer.subscribe(s,{relay:a});}catch(p){throw i.setError(At.subscribe_pairing_topic_failure),p}return i.addTrace(yt.subscribe_pairing_topic_success),m}),this.activate=i=>g(this,[i],function*({topic:n}){this.isInitialized();let s=utils.calcExpiry(j.THIRTY_DAYS);this.core.expirer.set(n,s),yield this.pairings.update(n,{active:!0,expiry:s});}),this.ping=n=>g(this,null,function*(){this.isInitialized(),yield this.isValidPing(n);let{topic:i}=n;if(this.pairings.keys.includes(i)){let s=yield this.sendRequest(i,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=utils.createDelayedPromise();this.events.once(utils.engineEvent("pairing_ping",s),({error:h})=>{h?c(h):a();}),yield o();}}),this.updateExpiry=s=>g(this,[s],function*({topic:n,expiry:i}){this.isInitialized(),yield this.pairings.update(n,{expiry:i});}),this.updateMetadata=s=>g(this,[s],function*({topic:n,metadata:i}){this.isInitialized(),yield this.pairings.update(n,{peerMetadata:i});}),this.getPairings=()=>(this.isInitialized(),this.pairings.values),this.disconnect=n=>g(this,null,function*(){this.isInitialized(),yield this.isValidDisconnect(n);let{topic:i}=n;this.pairings.keys.includes(i)&&(yield this.sendRequest(i,"wc_pairingDelete",utils.getSdkError("USER_DISCONNECTED")),yield this.deletePairing(i));}),this.formatUriFromPairing=n=>{this.isInitialized();let{topic:i,relay:s,expiry:o,methods:a}=n,c=this.core.crypto.keychain.get(i);return utils.formatUri({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:c,relay:s,expiryTimestamp:o,methods:a})},this.sendRequest=(n,i,s)=>g(this,null,function*(){let o=yr(i,s),a=yield this.core.crypto.encode(n,o),c=gn[i].req;return this.core.history.set(n,o),this.core.relayer.publish(n,a,c),o.id}),this.sendResult=(n,i,s)=>g(this,null,function*(){let o=Ri(n,s),a=yield this.core.crypto.encode(i,o),c=yield this.core.history.get(i,n),h=gn[c.request.method].res;yield this.core.relayer.publish(i,a,h),yield this.core.history.resolve(o);}),this.sendError=(n,i,s)=>g(this,null,function*(){let o=Qr(n,s),a=yield this.core.crypto.encode(i,o),c=yield this.core.history.get(i,n),h=gn[c.request.method]?gn[c.request.method].res:gn.unregistered_method.res;yield this.core.relayer.publish(i,a,h),yield this.core.history.resolve(o);}),this.deletePairing=(n,i)=>g(this,null,function*(){yield this.core.relayer.unsubscribe(n),yield Promise.all([this.pairings.delete(n,utils.getSdkError("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(n),i?Promise.resolve():this.core.expirer.del(n)]);}),this.cleanup=()=>g(this,null,function*(){let n=this.pairings.getAll().filter(i=>utils.isExpired(i.expiry));yield Promise.all(n.map(i=>this.deletePairing(i.topic)));}),this.onRelayEventRequest=n=>{let{topic:i,payload:s}=n;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(i,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(i,s);default:return this.onUnknownRpcMethodRequest(i,s)}},this.onRelayEventResponse=n=>g(this,null,function*(){let{topic:i,payload:s}=n,o=(yield this.core.history.get(i,s.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(i,s);default:return this.onUnknownRpcMethodResponse(o)}}),this.onPairingPingRequest=(n,i)=>g(this,null,function*(){let{id:s}=i;try{this.isValidPing({topic:n}),yield this.sendResult(s,n,!0),this.events.emit(mn.ping,{id:s,topic:n});}catch(o){yield this.sendError(s,n,o),this.logger.error(o);}}),this.onPairingPingResponse=(n,i)=>{let{id:s}=i;setTimeout(()=>{Bi(i)?this.events.emit(utils.engineEvent("pairing_ping",s),{}):jt(i)&&this.events.emit(utils.engineEvent("pairing_ping",s),{error:i.error});},500);},this.onPairingDeleteRequest=(n,i)=>g(this,null,function*(){let{id:s}=i;try{this.isValidDisconnect({topic:n}),yield this.deletePairing(n),this.events.emit(mn.delete,{id:s,topic:n});}catch(o){yield this.sendError(s,n,o),this.logger.error(o);}}),this.onUnknownRpcMethodRequest=(n,i)=>g(this,null,function*(){let{id:s,method:o}=i;try{if(this.registeredMethods.includes(o))return;let a=utils.getSdkError("WC_METHOD_UNSUPPORTED",o);yield this.sendError(s,n,a),this.logger.error(a);}catch(a){yield this.sendError(s,n,a),this.logger.error(a);}}),this.onUnknownRpcMethodResponse=n=>{this.registeredMethods.includes(n)||this.logger.error(utils.getSdkError("WC_METHOD_UNSUPPORTED",n));},this.isValidPair=(n,i)=>{var s;if(!utils.isValidParams(n)){let{message:a}=utils.getInternalError("MISSING_OR_INVALID",`pair() params: ${n}`);throw i.setError(At.malformed_pairing_uri),new Error(a)}if(!utils.isValidUrl(n.uri)){let{message:a}=utils.getInternalError("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw i.setError(At.malformed_pairing_uri),new Error(a)}let o=utils.parseUri(n==null?void 0:n.uri);if(!((s=o==null?void 0:o.relay)!=null&&s.protocol)){let{message:a}=utils.getInternalError("MISSING_OR_INVALID","pair() uri#relay-protocol");throw i.setError(At.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){let{message:a}=utils.getInternalError("MISSING_OR_INVALID","pair() uri#symKey");throw i.setError(At.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&(0, j.toMiliseconds)(o==null?void 0:o.expiryTimestamp)<Date.now()){i.setError(At.pairing_expired);let{message:a}=utils.getInternalError("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}},this.isValidPing=n=>g(this,null,function*(){if(!utils.isValidParams(n)){let{message:s}=utils.getInternalError("MISSING_OR_INVALID",`ping() params: ${n}`);throw new Error(s)}let{topic:i}=n;yield this.isValidPairingTopic(i);}),this.isValidDisconnect=n=>g(this,null,function*(){if(!utils.isValidParams(n)){let{message:s}=utils.getInternalError("MISSING_OR_INVALID",`disconnect() params: ${n}`);throw new Error(s)}let{topic:i}=n;yield this.isValidPairingTopic(i);}),this.isValidPairingTopic=n=>g(this,null,function*(){if(!utils.isValidString(n,!1)){let{message:i}=utils.getInternalError("MISSING_OR_INVALID",`pairing topic should be a string: ${n}`);throw new Error(i)}if(!this.pairings.keys.includes(n)){let{message:i}=utils.getInternalError("NO_MATCHING_KEY",`pairing topic doesn't exist: ${n}`);throw new Error(i)}if(utils.isExpired(this.pairings.get(n).expiry)){yield this.deletePairing(n);let{message:i}=utils.getInternalError("EXPIRED",`pairing topic: ${n}`);throw new Error(i)}}),this.core=t,this.logger=Re(r,this.name),this.pairings=new Vc(this.core,this.logger,this.name,this.storagePrefix);}get context(){return Be(this.logger)}isInitialized(){if(!this.initialized){let{message:t}=utils.getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}registerRelayerEvents(){this.core.relayer.on(je.message,t=>g(this,null,function*(){let{topic:r,message:n,transportType:i}=t;if(!this.pairings.keys.includes(r)||i===Cr.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))return;let s=yield this.core.crypto.decode(r,n);try{Fi(s)?(this.core.history.set(r,s),this.onRelayEventRequest({topic:r,payload:s})):wr(s)&&(yield this.core.history.resolve(s),yield this.onRelayEventResponse({topic:r,payload:s}),this.core.history.delete(r,s.id));}catch(o){this.logger.error(o);}}));}registerExpirerEvents(){this.core.expirer.on(Qe.expired,t=>g(this,null,function*(){let{topic:r}=utils.parseExpirerTarget(t.target);r&&this.pairings.keys.includes(r)&&(yield this.deletePairing(r,!0),this.events.emit(mn.expire,{topic:r}));}));}},Jc=class extends types.IJsonRpcHistory{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.records=new Map,this.events=new fI.EventEmitter,this.name=bD,this.version=SD,this.cached=[],this.initialized=!1,this.storagePrefix=ot,this.init=()=>g(this,null,function*(){this.initialized||(this.logger.trace("Initialized"),yield this.restore(),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0);}),this.set=(n,i,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:n,request:i,chainId:s}),this.records.has(i.id))return;let o={id:i.id,topic:n,request:{method:i.method,params:i.params||null},chainId:s,expiry:utils.calcExpiry(j.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Xe.created,o);},this.resolve=n=>g(this,null,function*(){if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:n}),!this.records.has(n.id))return;let i=yield this.getRecord(n.id);typeof i.response>"u"&&(i.response=jt(n)?{error:n.error}:{result:n.result},this.records.set(i.id,i),this.persist(),this.events.emit(Xe.updated,i));}),this.get=(n,i)=>g(this,null,function*(){return this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:i}),yield this.getRecord(i)}),this.delete=(n,i)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:i}),this.values.forEach(s=>{if(s.topic===n){if(typeof i<"u"&&s.id!==i)return;this.records.delete(s.id),this.events.emit(Xe.deleted,s);}}),this.persist();},this.exists=(n,i)=>g(this,null,function*(){return this.isInitialized(),this.records.has(i)?(yield this.getRecord(i)).topic===n:!1}),this.on=(n,i)=>{this.events.on(n,i);},this.once=(n,i)=>{this.events.once(n,i);},this.off=(n,i)=>{this.events.off(n,i);},this.removeListener=(n,i)=>{this.events.removeListener(n,i);},this.logger=Re(r,this.name);}get context(){return Be(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(){let t=[];return this.values.forEach(r=>{if(typeof r.response<"u")return;let n={topic:r.topic,request:yr(r.request.method,r.request.params,r.id),chainId:r.chainId};return t.push(n)}),t}setJsonRpcRecords(t){return g(this,null,function*(){yield this.core.storage.setItem(this.storageKey,t);})}getJsonRpcRecords(){return g(this,null,function*(){return yield this.core.storage.getItem(this.storageKey)})}getRecord(t){this.isInitialized();let r=this.records.get(t);if(!r){let{message:n}=utils.getInternalError("NO_MATCHING_KEY",`${this.name}: ${t}`);throw new Error(n)}return r}persist(){return g(this,null,function*(){yield this.setJsonRpcRecords(this.values),this.events.emit(Xe.sync);})}restore(){return g(this,null,function*(){try{let t=yield this.getJsonRpcRecords();if(typeof t>"u"||!t.length)return;if(this.records.size){let{message:r}=utils.getInternalError("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values});}catch(t){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(t);}})}registerEventListeners(){this.events.on(Xe.created,t=>{let r=Xe.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t});}),this.events.on(Xe.updated,t=>{let r=Xe.updated;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t});}),this.events.on(Xe.deleted,t=>{let r=Xe.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,record:t});}),this.core.heartbeat.on(Rt.pulse,()=>{this.cleanup();});}cleanup(){try{this.isInitialized();let t=!1;this.records.forEach(r=>{(0,j.toMiliseconds)(r.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${r.id}`),this.records.delete(r.id),this.events.emit(Xe.deleted,r,!1),t=!0);}),t&&this.persist();}catch(t){this.logger.warn(t);}}isInitialized(){if(!this.initialized){let{message:t}=utils.getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}},Yc=class extends types.IExpirer{constructor(t,r){super(t,r),this.core=t,this.logger=r,this.expirations=new Map,this.events=new fI.EventEmitter,this.name=_D,this.version=ED,this.cached=[],this.initialized=!1,this.storagePrefix=ot,this.init=()=>g(this,null,function*(){this.initialized||(this.logger.trace("Initialized"),yield this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0);}),this.has=n=>{try{let i=this.formatTarget(n);return typeof this.getExpiration(i)<"u"}catch(i){return !1}},this.set=(n,i)=>{this.isInitialized();let s=this.formatTarget(n),o={target:s,expiry:i};this.expirations.set(s,o),this.checkExpiry(s,o),this.events.emit(Qe.created,{target:s,expiration:o});},this.get=n=>{this.isInitialized();let i=this.formatTarget(n);return this.getExpiration(i)},this.del=n=>{if(this.isInitialized(),this.has(n)){let i=this.formatTarget(n),s=this.getExpiration(i);this.expirations.delete(i),this.events.emit(Qe.deleted,{target:i,expiration:s});}},this.on=(n,i)=>{this.events.on(n,i);},this.once=(n,i)=>{this.events.once(n,i);},this.off=(n,i)=>{this.events.off(n,i);},this.removeListener=(n,i)=>{this.events.removeListener(n,i);},this.logger=Re(r,this.name);}get context(){return Be(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(t){if(typeof t=="string")return utils.formatTopicTarget(t);if(typeof t=="number")return utils.formatIdTarget(t);let{message:r}=utils.getInternalError("UNKNOWN_TYPE",`Target type: ${typeof t}`);throw new Error(r)}setExpirations(t){return g(this,null,function*(){yield this.core.storage.setItem(this.storageKey,t);})}getExpirations(){return g(this,null,function*(){return yield this.core.storage.getItem(this.storageKey)})}persist(){return g(this,null,function*(){yield this.setExpirations(this.values),this.events.emit(Qe.sync);})}restore(){return g(this,null,function*(){try{let t=yield this.getExpirations();if(typeof t>"u"||!t.length)return;if(this.expirations.size){let{message:r}=utils.getInternalError("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(r),new Error(r)}this.cached=t,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values});}catch(t){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(t);}})}getExpiration(t){let r=this.expirations.get(t);if(!r){let{message:n}=utils.getInternalError("NO_MATCHING_KEY",`${this.name}: ${t}`);throw this.logger.warn(n),new Error(n)}return r}checkExpiry(t,r){let{expiry:n}=r;(0, j.toMiliseconds)(n)-Date.now()<=0&&this.expire(t,r);}expire(t,r){this.expirations.delete(t),this.events.emit(Qe.expired,{target:t,expiration:r});}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((t,r)=>this.checkExpiry(r,t));}registerEventListeners(){this.core.heartbeat.on(Rt.pulse,()=>this.checkExpirations()),this.events.on(Qe.created,t=>{let r=Qe.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist();}),this.events.on(Qe.expired,t=>{let r=Qe.expired;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist();}),this.events.on(Qe.deleted,t=>{let r=Qe.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:t}),this.persist();});}isInitialized(){if(!this.initialized){let{message:t}=utils.getInternalError("NOT_INITIALIZED",this.name);throw new Error(t)}}},Xc=class extends types.IVerify{constructor(t,r,n){super(t,r,n),this.core=t,this.logger=r,this.store=n,this.name=vD,this.verifyUrlV3=CD,this.storagePrefix=ot,this.version=Sm,this.init=()=>g(this,null,function*(){var i;this.isDevEnv||(this.publicKey=yield this.store.getItem(this.storeKey),this.publicKey&&(0, j.toMiliseconds)((i=this.publicKey)==null?void 0:i.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),yield this.removePublicKey()));}),this.register=i=>g(this,null,function*(){if(!utils.isBrowser()||this.isDevEnv)return;let s=window.location.origin,{id:o,decryptedId:a}=i,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${s}&id=${o}&decryptedId=${a}`;try{let h=(0,wm.getDocument)(),l=this.startAbortTimer(j.ONE_SECOND*5),f=yield new Promise((m,p)=>{let u=()=>{window.removeEventListener("message",w),h.body.removeChild(y),p("attestation aborted");};this.abortController.signal.addEventListener("abort",u);let y=h.createElement("iframe");y.src=c,y.style.display="none",y.addEventListener("error",u,{signal:this.abortController.signal});let w=S=>{if(S.data&&typeof S.data=="string")try{let b=JSON.parse(S.data);if(b.type==="verify_attestation"){if(vi(b.attestation).payload.id!==o)return;clearInterval(l),h.body.removeChild(y),this.abortController.signal.removeEventListener("abort",u),window.removeEventListener("message",w),m(b.attestation===null?"":b.attestation);}}catch(b){this.logger.warn(b);}};h.body.appendChild(y),window.addEventListener("message",w,{signal:this.abortController.signal});});return this.logger.debug("jwt attestation",f),f}catch(h){this.logger.warn(h);}return ""}),this.resolve=i=>g(this,null,function*(){if(this.isDevEnv)return "";let{attestationId:s,hash:o,encryptedId:a}=i;if(s===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(s){if(vi(s).payload.id!==a)return;let h=yield this.isValidJwtAttestation(s);if(h){if(!h.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return h}}if(!o)return;let c=this.getVerifyUrl(i==null?void 0:i.verifyUrl);return this.fetchAttestation(o,c)}),this.fetchAttestation=(i,s)=>g(this,null,function*(){this.logger.debug(`resolving attestation: ${i} from url: ${s}`);let o=this.startAbortTimer(j.ONE_SECOND*5),a=yield fetch(`${s}/attestation/${i}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?yield a.json():void 0}),this.getVerifyUrl=i=>{let s=i||ns;return ID.includes(s)||(this.logger.info(`verify url: ${s}, not included in trusted list, assigning default: ${ns}`),s=ns),s},this.fetchPublicKey=()=>g(this,null,function*(){try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);let i=this.startAbortTimer(j.FIVE_SECONDS),s=yield fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(i),yield s.json()}catch(i){this.logger.warn(i);}}),this.persistPublicKey=i=>g(this,null,function*(){this.logger.debug("persisting public key to local storage",i),yield this.store.setItem(this.storeKey,i),this.publicKey=i;}),this.removePublicKey=()=>g(this,null,function*(){this.logger.debug("removing verify v2 public key from storage"),yield this.store.removeItem(this.storeKey),this.publicKey=void 0;}),this.isValidJwtAttestation=i=>g(this,null,function*(){let s=yield this.getPublicKey();try{if(s)return this.validateAttestation(i,s)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation");}let o=yield this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(i,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation");}}),this.getPublicKey=()=>g(this,null,function*(){return this.publicKey?this.publicKey:yield this.fetchAndPersistPublicKey()}),this.fetchAndPersistPublicKey=()=>g(this,null,function*(){if(this.fetchPromise)return yield this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(s=>g(this,null,function*(){let o=yield this.fetchPublicKey();o&&(yield this.persistPublicKey(o),s(o));}));let i=yield this.fetchPromise;return this.fetchPromise=void 0,i}),this.validateAttestation=(i,s)=>{let o=utils.verifyP256Jwt(i,s.publicKey),a={hasExpired:(0, j.toMiliseconds)(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return {origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}},this.logger=Re(r,this.name),this.abortController=new AbortController,this.isDevEnv=utils.isTestRun(),this.init();}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return Be(this.logger)}startAbortTimer(t){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),(0, j.toMiliseconds)(t))}},Qc=class extends types.IEchoClient{constructor(t,r){super(t,r),this.projectId=t,this.logger=r,this.context=DD,this.registerDeviceToken=n=>g(this,null,function*(){let{clientId:i,token:s,notificationType:o,enableEncrypted:a=!1}=n,c=`${AD}/${this.projectId}/clients`;yield fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:i,type:o,token:s,always_raw:a})});}),this.logger=Re(r,this.context);}},cO=Object.defineProperty,lm=Object.getOwnPropertySymbols,lO=Object.prototype.hasOwnProperty,uO=Object.prototype.propertyIsEnumerable,um=(e,t,r)=>t in e?cO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,wn=(e,t)=>{for(var r in t||(t={}))lO.call(t,r)&&um(e,r,t[r]);if(lm)for(var r of lm(t))uO.call(t,r)&&um(e,r,t[r]);return e},Zc=class extends types.IEventClient{constructor(t,r,n=!0){super(t,r,n),this.core=t,this.logger=r,this.context=TD,this.storagePrefix=ot,this.storageVersion=OD,this.events=new Map,this.shouldPersist=!1,this.init=()=>g(this,null,function*(){if(!utils.isTestRun())try{let i={eventId:utils.uuidv4(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:yield this.core.crypto.getClientId(),user_agent:utils.formatUA(this.core.relayer.protocol,this.core.relayer.version,Rc)}}};yield this.sendEvent([i]);}catch(i){this.logger.warn(i);}}),this.createEvent=i=>{let{event:s="ERROR",type:o="",properties:{topic:a,trace:c}}=i,h=utils.uuidv4(),l=this.core.projectId||"",f=Date.now(),m=wn({eventId:h,timestamp:f,props:{event:s,type:o,properties:{topic:a,trace:c}},bundleId:l,domain:this.getAppDomain()},this.setMethods(h));return this.telemetryEnabled&&(this.events.set(h,m),this.shouldPersist=!0),m},this.getEvent=i=>{let{eventId:s,topic:o}=i;if(s)return this.events.get(s);let a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return wn(wn({},a),this.setMethods(a.eventId))},this.deleteEvent=i=>{let{eventId:s}=i;this.events.delete(s),this.shouldPersist=!0;},this.setEventListeners=()=>{this.core.heartbeat.on(Rt.pulse,()=>g(this,null,function*(){this.shouldPersist&&(yield this.persist()),this.events.forEach(i=>{(0, j.fromMiliseconds)(Date.now())-(0, j.fromMiliseconds)(i.timestamp)>RD&&(this.events.delete(i.eventId),this.shouldPersist=!0);});}));},this.setMethods=i=>({addTrace:s=>this.addTrace(i,s),setError:s=>this.setError(i,s)}),this.addTrace=(i,s)=>{let o=this.events.get(i);o&&(o.props.properties.trace.push(s),this.events.set(i,o),this.shouldPersist=!0);},this.setError=(i,s)=>{let o=this.events.get(i);o&&(o.props.type=s,o.timestamp=Date.now(),this.events.set(i,o),this.shouldPersist=!0);},this.persist=()=>g(this,null,function*(){yield this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1;}),this.restore=()=>g(this,null,function*(){try{let i=(yield this.core.storage.getItem(this.storageKey))||[];if(!i.length)return;i.forEach(s=>{this.events.set(s.eventId,wn(wn({},s),this.setMethods(s.eventId)));});}catch(i){this.logger.warn(i);}}),this.submit=()=>g(this,null,function*(){if(!this.telemetryEnabled||this.events.size===0)return;let i=[];for(let[s,o]of this.events)o.props.type&&i.push(o);if(i.length!==0)try{if((yield this.sendEvent(i)).ok)for(let s of i)this.events.delete(s.eventId),this.shouldPersist=!0;}catch(s){this.logger.warn(s);}}),this.sendEvent=i=>g(this,null,function*(){let s=this.getAppDomain()?"":"&sp=desktop";return yield fetch(`${PD}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Rc}${s}`,{method:"POST",body:JSON.stringify(i)})}),this.getAppDomain=()=>utils.getAppMetadata().url,this.logger=Re(r,this.context),this.telemetryEnabled=n,n?this.restore().then(()=>g(this,null,function*(){yield this.submit(),this.setEventListeners();})):this.persist();}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}},fO=Object.defineProperty,fm=Object.getOwnPropertySymbols,hO=Object.prototype.hasOwnProperty,dO=Object.prototype.propertyIsEnumerable,hm=(e,t,r)=>t in e?fO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,dm=(e,t)=>{for(var r in t||(t={}))hO.call(t,r)&&hm(e,r,t[r]);if(fm)for(var r of fm(t))dO.call(t,r)&&hm(e,r,t[r]);return e},el=class e extends types.ICore{constructor(t){var r;super(t),this.protocol=bm,this.version=Sm,this.name=tl,this.events=new fI.EventEmitter,this.initialized=!1,this.on=(o,a)=>this.events.on(o,a),this.once=(o,a)=>this.events.once(o,a),this.off=(o,a)=>this.events.off(o,a),this.removeListener=(o,a)=>this.events.removeListener(o,a),this.dispatchEnvelope=({topic:o,message:a,sessionExists:c})=>{if(!o||!a)return;let h={topic:o,message:a,publishedAt:Date.now(),transportType:Cr.link_mode};this.relayer.onLinkMessageEvent(h,{sessionExists:c});},this.projectId=t==null?void 0:t.projectId,this.relayUrl=(t==null?void 0:t.relayUrl)||_m,this.customStoragePrefix=t!=null&&t.customStoragePrefix?`:${t.customStoragePrefix}`:"";let n=Oo({level:typeof(t==null?void 0:t.logger)=="string"&&t.logger?t.logger:XI.logger}),{logger:i,chunkLoggerController:s}=uh({opts:n,maxSizeInBytes:t==null?void 0:t.maxLogBlobSizeInBytes,loggerOverride:t==null?void 0:t.logger});this.logChunkController=s,(r=this.logChunkController)!=null&&r.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=()=>g(this,null,function*(){var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:yield this.crypto.getClientId()}));})),this.logger=Re(i,this.name),this.heartbeat=new zn,this.crypto=new Kc(this,this.logger,t==null?void 0:t.keychain),this.history=new Jc(this,this.logger),this.expirer=new Yc(this,this.logger),this.storage=t!=null&&t.storage?t.storage:new Gn(dm(dm({},QI),t==null?void 0:t.storageOptions)),this.relayer=new Gc({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Hc(this,this.logger),this.verify=new Xc(this,this.logger,this.storage),this.echoClient=new Qc(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new Zc(this,this.logger,t==null?void 0:t.telemetryEnabled);}static init(t){return g(this,null,function*(){let r=new e(t);yield r.initialize();let n=yield r.crypto.getClientId();return yield r.storage.setItem(dD,n),r})}get context(){return Be(this.logger)}start(){return g(this,null,function*(){this.initialized||(yield this.initialize());})}getLogsBlob(){return g(this,null,function*(){var t;return (t=this.logChunkController)==null?void 0:t.logsToBlob({clientId:yield this.crypto.getClientId()})})}addLinkModeSupportedApp(t){return g(this,null,function*(){this.linkModeSupportedApps.includes(t)||(this.linkModeSupportedApps.push(t),yield this.storage.setItem(Hg,this.linkModeSupportedApps));})}initialize(){return g(this,null,function*(){this.logger.trace("Initialized");try{yield this.crypto.init(),yield this.history.init(),yield this.expirer.init(),yield this.relayer.init(),yield this.heartbeat.init(),yield this.pairing.init(),this.eventClient.init(),this.linkModeSupportedApps=(yield this.storage.getItem(Hg))||[],this.initialized=!0,this.logger.info("Core Initialization Success");}catch(t){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,t),this.logger.error(t.message),t}})}},Nm=el;d();var Ve=()=>{if(typeof window!="undefined"){let e=navigator.userAgent;return !!(/android/i.test(e)||/iPad|iPhone|iPod/.test(e))}return !1},Lm=()=>Ve()&&navigator.userAgent.toLowerCase().includes("android"),Mm=()=>Ve()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));d();var rl=(e,t,r=new Error("Promise timed out"))=>{let n=new Promise((i,s)=>{setTimeout(()=>{s(r);},t);});return Promise.race([e,n])};var He=e=>{var E,C,F;if(!((F=(C=(E=P.getState().walletConnect)==null?void 0:E.options)==null?void 0:C.projectId)!=null&&F.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",r=(e==null?void 0:e.encoding)||"base64",n=T=>{if(!e)return;let{appUrl:D,formatNativeUrl:I}=e;if(Ve()){if(Lm()){let A=I(D.mobile.android,T,"android");window.open(A,"_self","noreferrer noopener");}if(Mm()){let A=I(D.mobile.ios,T,"ios");window.open(A,"_self","noreferrer noopener");}}},i=()=>{let{wcSignClients:T}=k.getState();if(!T.get(t))throw new Error("walletConnect.signClient is not defined");T.delete(t),k.setState({wcSignClients:T}),P.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},s=T=>g(void 0,null,function*(){let{wcSignClients:D}=k.getState(),I=D.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");if(!T)throw new Error("No wallet connect session");yield I.disconnect({topic:T,reason:utils.getSdkError("USER_DISCONNECTED")}),yield c(I);}),o=T=>{try{let{wcSignClients:D}=k.getState(),I=D.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let A=I.session.getAll(),N=A.at(-1);if(!N)return;if(!(N.expiry*1e3>Date.now()+1e3))throw s(N.topic),new Error("invalid session");try{let $=A.find(me=>{var De,Le;return (Le=(De=me.requiredNamespaces.cosmos)==null?void 0:De.chains)==null?void 0:Le.includes(`cosmos:${T}`)});if(!$)throw new Error("no session");return $}catch($){if(!$.message.toLowerCase().includes("no matching key"))throw $}return N}catch(D){if(!D.message.toLowerCase().includes("no matching key"))throw D}},a=T=>{try{return o(T)}catch(D){return}},c=T=>g(void 0,null,function*(){try{let D=T.core.pairing.pairings.getAll({active:!1});if(!D.length)return;yield Promise.all(D.map(I=>g(void 0,null,function*(){yield T.core.pairing.pairings.delete(I.topic,{code:7001,message:"clear pairing"});})));}catch(D){if(!D.message.toLowerCase().includes("no matching key"))throw D}}),h=()=>g(void 0,null,function*(){let{walletConnect:T}=P.getState();if(!(T!=null&&T.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:D}=k.getState(),I=D.get(t);if(I)return I;let A=new Nm({projectId:T.options.projectId}),N=yield signClient.SignClient.init(X(M({},T.options),{core:A}));return D.set(t,N),k.setState({wcSignClients:D}),N}),l=T=>{let{wcSignClients:D}=k.getState(),I=D.get(t);if(!I)return ()=>{};let A=N=>{let W=k.getState().accounts;if(N.params.event.name==="accountsChanged"&&W&&!Object.values(W).map($=>$.bech32Address).includes(N.params.event.data[0])){let $=N.params.chainId.split(":")[1];$&&f([$]);}else T();};return I.events.on("session_delete",i),I.events.on("session_expire",i),I.events.on("session_event",A),()=>{I.events.off("session_delete",i),I.events.off("session_expire",i),I.events.off("session_event",A);}},f=T=>g(void 0,null,function*(){var Le;let D=typeof T=="string"?[T]:T,{wcSignClients:I,activeChainIds:A}=k.getState(),N=I.get(t);if(!N)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:W,chains:$}=P.getState();if(!((Le=W==null?void 0:W.options)!=null&&Le.projectId))throw new Error("walletConnect.options.projectId is not defined");let me=new modal.WalletConnectModal(M({projectId:W.options.projectId,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},W.walletConnectModal)),De=a(D);if(!De){let{uri:G,approval:ne}=yield rl(N.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:D.map(J=>`cosmos:${J}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!G)throw new Error("No wallet connect uri");e?n(G):yield me.openModal({uri:G});let ie=J=>g(void 0,null,function*(){return J.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((se,Z)=>{ne().then(ce=>{let le=ce.sessionProperties;if(!le)return Z(new Error("No session properties"));let re=JSON.parse(String(le.keys));if(re.length===0)return Z(new Error("No accounts"));if(!re[0])return Z(new Error("No accounts"));let ue={};return re.forEach(Y=>{ue[Y.chainId]={address:Y.address,algo:Y.algo,bech32Address:Y.bech32Address,isNanoLedger:Y.isNanoLedger,isKeystone:Y.isKeystone,name:Y.name,pubKey:Y.pubKey};}),k.setState(Y=>({accounts:M(M({},Y.accounts||{}),ue)})),se(ce)}).catch(Z),J.addEventListener("abort",()=>{Z(new Error("User closed wallet connect"));},{once:!0});})});try{let J=new AbortController,se=J.signal;me.subscribeModal(Z=>{Z.open||J.abort();}),yield ie(se);}catch(J){if(me.closeModal(),!J.message.toLowerCase().includes("no matching key"))return Promise.reject(J)}return e||me.closeModal(),Promise.resolve()}try{yield rl((()=>g(void 0,null,function*(){var ne;let G=Object.fromEntries(yield Promise.all((ne=A||D)==null?void 0:ne.map(ie=>g(void 0,null,function*(){return [ie,yield p(ie)]}))));k.setState({accounts:G});}))(),15e3,new Error("Connection timeout"));}catch(G){if(s(De.topic),!G.message.toLowerCase().includes("no matching key"))throw G}}),m=T=>g(void 0,null,function*(){let D=yield p(T);return {address:D.bech32Address,algo:D.algo,pubkey:D.pubKey}}),p=T=>g(void 0,null,function*(){var N;let D=o([T]);if(!(D!=null&&D.topic))throw new Error("No wallet connect session");(N=D.sessionConfig)==null||N.disableDeepLink;let I=D.sessionProperties&&JSON.parse(String(D.sessionProperties.keys));if(!I)throw new Error("No wallet connect key");if(I.length===0)throw new Error("No wallet connect session");let A=I.find(W=>W.chainId===T);if(!A)throw new Error(`No wallet connect key for chainId ${T}`);return X(M({},A),{pubKey:Buffer.from(String(A.pubKey),r)})}),u=(...T)=>g(void 0,null,function*(){var Le,G;let[D,I,A]=T,{accounts:N,wcSignClients:W}=k.getState(),$=W.get(t);if(!$)throw new Error("walletConnect.signClient is not defined");if(!N)throw new Error("account is not defined");let me=(Le=o([D]))==null?void 0:Le.topic;if(!me)throw new Error("No wallet connect session");if(!A.bodyBytes)throw new Error("No bodyBytes");if(!A.authInfoBytes)throw new Error("No authInfoBytes");return n(),yield $.request({topic:me,chainId:`cosmos:${D}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:{chainId:A.chainId,accountNumber:(G=A.accountNumber)==null?void 0:G.toString(),bodyBytes:A.bodyBytes?Buffer.from(A.bodyBytes).toString(r):null,authInfoBytes:A.authInfoBytes?Buffer.from(A.authInfoBytes).toString(r):null}}}})}),y=(...T)=>g(void 0,null,function*(){var $;let[D,I,A]=T,{signature:N,signed:W}=yield u(D,I,A);return {signed:{chainId:($=W.chainId)!=null?$:"",accountNumber:W.accountNumber?Fm__default.default.fromString(W.accountNumber):new Fm__default.default(0),authInfoBytes:W.authInfoBytes?new Uint8Array(Buffer.from(W.authInfoBytes,r)):new Uint8Array([]),bodyBytes:W.bodyBytes?new Uint8Array(Buffer.from(W.bodyBytes,r)):new Uint8Array([])},signature:N}}),w=(...T)=>g(void 0,null,function*(){var G;let[D,I,A,N]=T,{wcSignClients:W}=k.getState(),$=W.get(t),{accounts:me}=k.getState();if(!$)throw new Error("walletConnect.signClient is not defined");if(!me)throw new Error("account is not defined");let De=(G=o([D]))==null?void 0:G.topic;if(!De)throw new Error("No wallet connect session");return n(),yield $.request({topic:De,chainId:`cosmos:${D}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:A}}})}),S=(...T)=>g(void 0,null,function*(){let[D,I,A,N]=T;return yield w(D,I,A)}),b=T=>({getAccounts:()=>g(void 0,null,function*(){return [yield m(T)]}),signDirect:(D,I)=>y(T,D,I)}),_=T=>({getAccounts:()=>g(void 0,null,function*(){return [yield m(T)]}),signAmino:(D,I)=>S(T,D,I)});return {enable:f,disable:T=>g(void 0,null,function*(){var A;let{wcSignClients:D}=k.getState(),I=D.get(t);if(T===void 0){let N=I==null?void 0:I.session.getAll();N!==void 0&&(yield Promise.all(N.map(W=>s(W.topic))));}else typeof T=="string"?yield s((A=o([T]))==null?void 0:A.topic):yield Promise.all(T.map(N=>{var W;return s((W=o([N]))==null?void 0:W.topic)}));(I==null?void 0:I.session.getAll().length)===0&&i();}),experimentalSuggestChain:(...T)=>g(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:p,getOfflineSigner:T=>({getAccounts:()=>g(void 0,null,function*(){return [yield m(T)]}),signDirect:(D,I)=>y(T,D,I),signAmino:(D,I)=>S(T,D,I)}),getOfflineSignerAuto:T=>g(void 0,null,function*(){return (yield p(T)).isNanoLedger?_(T):b(T)}),getOfflineSignerOnlyAmino:_,signAmino:S,signDirect:y,subscription:l,init:h}};d();var Bm=()=>{var t,r,n;if(!((n=(r=(t=P.getState().walletConnect)==null?void 0:t.options)==null?void 0:r.projectId)!=null&&n.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Ve())throw new Error("WalletConnect Clot mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{android:"clot://",ios:"clot://"}},walletType:"wc_clot_mobile",formatNativeUrl:(i,s,o)=>{let a=i.replaceAll("/","").replaceAll(":",""),c=s&&encodeURIComponent(s);switch(o){case"ios":return c?`${a}://wcV2?${c}`:`${a}://wcV2`;default:return c?`${a}://wc?uri=${c}`:`${a}://wc`}}};return He(e)};d();var km=()=>{var t,r,n;if(!((n=(r=(t=P.getState().walletConnect)==null?void 0:t.options)==null?void 0:r.projectId)!=null&&n.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Ve())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(i,s,o)=>{let a=i.replaceAll("/","").replaceAll(":","");return s?`${a}://wc?${s}`:`${a}://wc`}};return He(e)};d();var Um=()=>{var t,r,n;if(!((n=(r=(t=P.getState().walletConnect)==null?void 0:t.options)==null?void 0:r.projectId)!=null&&n.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Ve())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(i,s,o)=>{let a=i.replaceAll("/","").replaceAll(":",""),c=s&&encodeURIComponent(s);switch(o){case"ios":return c?`${a}://wcV2?${c}`:`${a}://wcV2`;case"android":return c?`${a}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`:`${a}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return c?`${a}://wc?uri=${c}`:`${a}://wc`}}};return He(e)};d();var Wm=()=>{var t,r,n;if(!((n=(r=(t=P.getState().walletConnect)==null?void 0:t.options)==null?void 0:r.projectId)!=null&&n.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Ve())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(i,s,o)=>{let a=i.replaceAll("/","").replaceAll(":",""),c=s&&encodeURIComponent(s);switch(o){case"ios":return c?`${a}://wcV2?${c}`:`${a}://wcV2`;case"android":return c?`${a}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`:`${a}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return c?`${a}://wc?uri=${c}`:`${a}://wc`}}};return He(e)};d();var ss=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:i=>{let s=()=>{ye(),i();};return window.addEventListener("keplr_keystorechange",s),()=>{window.removeEventListener("keplr_keystorechange",s);}}})}throw P.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var Ie=(e=P.getState().walletType)=>{try{return oe(e),!0}catch(t){return !1}},ye=()=>{window.sessionStorage.removeItem(at),k.setState(Xt);},oe=(e=P.getState().walletType)=>{var n;let t=(()=>{switch(e){case"keplr":return On();case"leap":return Tn();case"cosmostation":return An();case"vectis":return Ln();case"walletconnect":return He();case"wc_keplr_mobile":return Um();case"wc_leap_mobile":return Wm();case"wc_cosmostation_mobile":return km();case"wc_clot_mobile":return Bm();case"metamask_snap_leap":return Pl();case"metamask_snap_cosmos":return Al();case"station":return Nn();case"xdefi":return ss();case"capsule":return Cn();case"cosmiframe":return Dn();case"compass":return In();case"initia":return Tl();case"okx":return Pn();default:throw new Error("Unknown wallet type")}})(),r=P.getState().walletDefaultOptions;return r&&((n=t.setDefaultOptions)==null||n.call(t,r)),t},RM=()=>Object.fromEntries(bl.map(e=>[e,Ie(e)])),nl=e=>e==="capsule",il=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var Ot=e=>g(void 0,null,function*(){var t;try{let{recentChainIds:r,chains:n,walletType:i}=P.getState(),s=(e==null?void 0:e.walletType)||i;if(!Ie(s))throw new Error(`${s} is not available`);let a=oe(s),c=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||r;if(!c)throw new Error("No last known connected chain, connect action requires chain ids");let h=n==null?void 0:n.map(p=>p.chainId);c.forEach(p=>{if(!(h!=null&&h.includes(p)))throw new Error(`Chain ${p} is not provided in GrazProvider`)}),k.setState(p=>{let u=P.getState()._reconnect||!!P.getState()._reconnectConnector||!!c;return p.activeChainIds&&c.filter(w=>{var S;return !((S=p.activeChainIds)!=null&&S.includes(w))}).length>0?{status:"connecting"}:u?{status:"reconnecting"}:{status:"connecting"}});let{accounts:l}=k.getState();if(yield (t=a.init)==null?void 0:t.call(a),nl(s)&&k.getState().capsuleClient&&Object.values(k.getState().accounts||[]).length>0){let p=c.map(w=>n.find(S=>S.chainId===w)),u=k.getState().accounts;k.setState({status:"connecting"});let y=Object.fromEntries(yield Promise.all(c.map(w=>g(void 0,null,function*(){return [w,yield a.getKey(w)]}))));return k.setState(w=>({accounts:M(M({},w.accounts||{}),y)})),P.setState(w=>({recentChainIds:[...w.recentChainIds||[],...c].filter((S,b,_)=>_.indexOf(S)===b)})),k.setState(w=>({activeChainIds:[...w.activeChainIds||[],...c].filter((S,b,_)=>_.indexOf(S)===b)})),k.setState({status:"connected"}),{accounts:u,walletType:s,chains:p}}if(yield a.enable(c),nl(s)){let p=c.map(y=>n.find(w=>w.chainId===y)),u=k.getState().accounts;return k.setState({status:"connecting"}),{accounts:u,walletType:s,chains:p}}if(!il(s)){let p=Object.fromEntries(yield Promise.all(c.map(u=>g(void 0,null,function*(){return [u,yield a.getKey(u)]}))));k.setState(u=>({accounts:M(M({},u.accounts||{}),p)}));}P.setState(p=>({recentChainIds:[...p.recentChainIds||[],...c].filter((u,y,w)=>w.indexOf(u)===y)})),k.setState(p=>({activeChainIds:[...p.activeChainIds||[],...c].filter((u,y,w)=>w.indexOf(u)===y)})),P.setState({walletType:s,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:s}),k.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(at,"Active");let f=c.map(p=>n.find(u=>u.chainId===p));return {accounts:k.getState().accounts,walletType:s,chains:f}}catch(r){throw console.error("connect ",r),k.getState().accounts===null&&k.setState({status:"disconnected"}),k.getState().accounts&&k.getState().activeChainIds&&k.setState({status:"connected"}),r}}),vn=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(at);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let r=k.getState().accounts;t.forEach(i=>{r==null||delete r[i];}),Object.values(r||{}).length===0?(k.setState(Xt),P.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(k.setState(i=>{var s;return {activeChainIds:(s=i.activeChainIds)==null?void 0:s.filter(o=>!t.includes(o)),accounts:r}}),P.setState(i=>{var s;return {recentChainIds:(s=i.recentChainIds)==null?void 0:s.filter(o=>!t.includes(o))}}));}else k.setState(Xt),P.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},Pe=e=>g(void 0,null,function*(){var i;let{recentChainIds:t,_reconnectConnector:r,_reconnect:n}=P.getState();try{let s=Ie(r||void 0);if(t&&s&&r)return il(r)?void 0:yield Ot({chainId:t,walletType:r,autoReconnect:n})}catch(s){(i=e==null?void 0:e.onError)==null||i.call(e,s),vn();}}),Km=e=>g(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=P.getState(),r=e.walletType||t;if(!Ie(r))throw new Error(`${r} is not available`);let i=oe(r),s=i.getOfflineSigner(e.chainId),o=i.getOfflineSignerOnlyAmino(e.chainId),a=yield i.getOfflineSignerAuto(e.chainId);return {offlineSigner:s,offlineSignerAmino:o,offlineSignerAuto:a}});d();var sl=()=>{P.setState({recentChainIds:null});},zM=()=>P.getState().recentChainIds,$M=()=>{var r;let{recentChainIds:e,chains:t}=P.getState();return (r=e==null?void 0:e.map(n=>t.find(i=>i.chainId===n)))!=null?r:null},qM=({chainId:e})=>{var t;return (t=P.getState().chains)==null?void 0:t.find(r=>r.chainId===e)},GM=({chainId:e})=>{var t;return (t=P.getState().chains)==null?void 0:t.filter(r=>e==null?void 0:e.includes(r.chainId))},ol=r=>g(void 0,[r],function*({chainInfo:e,walletType:t}){let n=oe(t);return t==="capsule"?yield Ot({chainId:e.chainId,walletType:t}):yield n.experimentalSuggestChain(e),e}),jm=e=>g(void 0,null,function*(){var n;let t=P.getState().walletType;return yield ol({chainInfo:e.chainInfo,walletType:(n=e.walletType)!=null?n:t}),yield Ot({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});d();var zm=e=>(P.setState(t=>({iframeOptions:e.iframeOptions||t.iframeOptions,walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);d();var $m=o=>g(void 0,[o],function*({signingClient:e,senderAddress:t,recipientAddress:r,amount:n,fee:i,memo:s}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,r,n,i,s)}),qm=l=>g(void 0,[l],function*({signingClient:e,senderAddress:t,recipientAddress:r,transferAmount:n,sourcePort:i,sourceChannel:s,timeoutHeight:o,timeoutTimestamp:a,fee:c,memo:h}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,r,n,i,s,o,a,c,h)}),Gm=a=>g(void 0,[a],function*({signingClient:e,senderAddress:t,msg:r,fee:n,options:i,label:s,codeId:o}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,o,r,s,n,i)}),Vm=a=>g(void 0,[a],function*({signingClient:e,senderAddress:t,msg:r,fee:n,contractAddress:i,funds:s,memo:o}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,i,r,n,o,s)}),Hm=(e,t,r)=>g(void 0,null,function*(){if(!r)throw new Error("CosmWasm client is not ready");return yield r.queryContractSmart(e,t)}),Jm=(e,t,r)=>{if(!r)throw new Error("CosmWasm client is not ready");let n=new TextEncoder().encode(t);return r.queryContractRaw(e,n)};d();var r5=e=>e,n5=e=>e;d();d();var os=e=>e?Object.keys(e).length===0:!0;d();d();var al=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Ym=e=>globalThis.DOMException===void 0?new al(e):new DOMException(e),Xm=e=>{let t=e.reason===void 0?Ym("This operation was aborted."):e.reason;return t instanceof Error?t:Ym(t)};function cl(s,o){return g(this,arguments,function*(e,t,{concurrency:r=Number.POSITIVE_INFINITY,stopOnError:n=!0,signal:i}={}){return new Promise((a,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(r)||r===Number.POSITIVE_INFINITY)&&r>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${r}\` (${typeof r})`);let h=[],l=[],f=new Map,m=!1,p=!1,u=!1,y=0,w=0,S=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),b=x=>{m=!0,p=!0,c(x);};i&&(i.aborted&&b(Xm(i)),i.addEventListener("abort",()=>{b(Xm(i));}));let _=()=>g(this,null,function*(){if(p)return;let x=yield S.next(),O=w;if(w++,x.done){if(u=!0,y===0&&!p){if(!n&&l.length>0){b(new AggregateError(l));return}if(p=!0,f.size===0){a(h);return}let L=[];for(let[E,C]of h.entries())f.get(E)!==Qm&&L.push(C);a(L);}return}y++,g(this,null,function*(){try{let L=yield x.value;if(p)return;let E=yield t(L,O);E===Qm&&f.set(O,E),h[O]=E,y--,yield _();}catch(L){if(n)b(L);else {l.push(L),y--;try{yield _();}catch(E){b(E);}}}});});g(this,null,function*(){for(let x=0;x<r;x++){try{yield _();}catch(O){b(O);break}if(u||m)break}});})})}var Qm=Symbol("skip");var Ne=({chainId:e,multiChain:t})=>{let r=P(i=>i.chains);if(!r)throw new Error("No chains found in GrazProvider");let n=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!n):return n.map(i=>r.find(s=>s.chainId===i)).filter(Boolean);case(!t&&!!n):return [n.map(i=>r.find(s=>s.chainId===i)).filter(Boolean)[0]];case(!!t&&!n):return r;default:return [r[0]]}},ze=(e,t,r)=>g(void 0,null,function*(){let n=P.getState().multiChainFetchConcurrency;if(e){let s=yield cl(t,r,{concurrency:n});return Object.fromEntries(s.map((o,a)=>[t[a].chainId,o]))}return yield r(t[0])}),Zm=(e,t,r)=>{if(e){let i=t.map(r);return Object.fromEntries(i.map((s,o)=>[t[o].chainId,s]))}return r(t[0])};d();var fl=e=>{let t=Ne({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),r=react.useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:r,queryFn:i=>g(void 0,[i],function*({queryKey:[,n]}){if(n.length<1)throw new Error("No chains found");return yield ze(!!(e!=null&&e.multiChain),n,o=>g(void 0,null,function*(){var l;let a=(l=P.getState().chainsConfig)==null?void 0:l[o.chainId],c={url:o.rpc,headers:M({},(a==null?void 0:a.rpcHeaders)||{})};return yield stargate.StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},hl=e=>{let t=Ne({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),r=react.useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:r,queryFn:i=>g(void 0,[i],function*({queryKey:[,n]}){if(n.length<1)throw new Error("No chains found");return yield ze(!!(e!=null&&e.multiChain),n,o=>g(void 0,null,function*(){var l;let a=(l=P.getState().chainsConfig)==null?void 0:l[o.chainId],c={url:o.rpc,headers:M({},(a==null?void 0:a.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},as=({type:e,chainId:t,multiChain:r,enabled:n})=>{let i=Ne({chainId:t,multiChain:r}),s=react.useMemo(()=>["USE_TENDERMINT_CLIENT",e,i],[e,i]);return reactQuery.useQuery({queryKey:s,queryFn:c=>g(void 0,[c],function*({queryKey:[,o,a]}){if(a.length<1)throw new Error("No chains found");return yield ze(!!r,a,l=>g(void 0,null,function*(){var y;let f=(y=P.getState().chainsConfig)==null?void 0:y[l.chainId],m={url:l.rpc,headers:M({},(f==null?void 0:f.rpcHeaders)||{})};return yield (o==="tm37"?tendermintRpc.Tendermint37Client:tendermintRpc.Tendermint34Client).connect(m)}))}),enabled:!!i&&i.length>0&&(n!==void 0?!!n:!0),refetchOnWindowFocus:!1})};d();var T5=()=>P(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCapsule:e.walletType==="capsule",isCosmiframe:e.walletType==="cosmiframe"}),shallow.shallow),cs=e=>{let r=["USE_CHECK_WALLET",P(i=>e||i.walletType)];return reactQuery.useQuery({queryKey:r,queryFn:({queryKey:[,i]})=>Ie(i)})};var Tt=e=>{let t=P(a=>a.walletType),r=k(a=>a.activeChainIds),n=Ne({chainId:e!=null&&e.chainId?e.chainId:r||void 0,multiChain:e==null?void 0:e.multiChain}),i=k(a=>a.accounts),s=k(a=>a.status);return react.useEffect(()=>k.subscribe(a=>a.status,(a,c)=>{var h,l,f;if(a==="connected"){let{accounts:m,activeChainIds:p}=k.getState(),{chains:u}=P.getState(),{walletType:y}=P.getState();if(!m||!p||!u)return (h=e==null?void 0:e.onDisconnect)==null?void 0:h.call(e);(l=e==null?void 0:e.onConnect)==null||l.call(e,{accounts:m,chains:p.map(w=>u.find(S=>S.chainId===w)),walletType:y,isReconnect:c==="reconnecting"});}a==="disconnected"&&((f=e==null?void 0:e.onDisconnect)==null||f.call(e));}),[e]),{data:react.useMemo(()=>i?Zm(!!(e!=null&&e.multiChain),n,a=>i[a.chainId]):void 0,[i,n,e==null?void 0:e.multiChain]),isConnected:s==="connected",isConnecting:s==="connecting",isDisconnected:s==="disconnected",isReconnecting:s==="reconnecting",isLoading:s==="connecting"||s==="reconnecting",walletType:s==="connected"?t:void 0,reconnect:Pe,status:s}},xO=e=>{let t=Ne({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:r}=Tt(),n=(e==null?void 0:e.bech32Address)||(r==null?void 0:r.bech32Address),{data:i}=fl({chainId:t.map(o=>o.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!n}),s=react.useMemo(()=>["USE_ALL_BALANCES",i,t,n,e==null?void 0:e.chainId],[n,e==null?void 0:e.chainId,t,i]);return reactQuery.useQuery({queryKey:s,queryFn:h=>g(void 0,[h],function*({queryKey:[,o,a,c]}){if(!c)throw new Error("address is not defined");return yield ze(!!(e!=null&&e.multiChain),a,f=>g(void 0,null,function*(){var u;let m=o==null?void 0:o[f.chainId];if(!m)throw new Error(`Client is not ready ${f.chainId}`);if(!((u=f.bech32Config)!=null&&u.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${f.chainId}`);return yield m.getAllBalances(encoding.toBech32(f.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),enabled:!!n&&!!t&&t.length>0&&!os(i)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},z5=e=>{let t=Ne({chainId:e.chainId}),{data:r}=Tt({chainId:e.chainId}),n=e.bech32Address||(r==null?void 0:r.bech32Address),{data:i,refetch:s}=xO({chainId:t.map(c=>c.chainId),bech32Address:n,enabled:!!n&&(e.enabled===void 0?!0:e.enabled)}),o=["USE_BALANCE",e.denom,i,t,n,e.chainId],a=reactQuery.useQuery({queryKey:o,queryFn:({queryKey:[,c,h]})=>h==null?void 0:h.find(l=>l.denom===c),enabled:!!e.denom&&!!i&&!!(i!=null&&i.length)&&(e.enabled===void 0?!0:e.enabled)});return X(M({},a),{refetch:c=>g(void 0,null,function*(){return yield s(),a.refetch(c)})})},$5=({onError:e,onLoading:t,onSuccess:r}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_CONNECT",e,t,r],mutationFn:Ot,onError:(o,a)=>e==null?void 0:e(o,a),onMutate:t,onSuccess:o=>Promise.resolve(r==null?void 0:r(o))}),{data:s}=cs();return {connect:o=>i.mutate(o),connectAsync:o=>i.mutateAsync(o),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!s,status:i.status}},q5=({onError:e,onLoading:t,onSuccess:r}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_DISCONNECT",e,t,r],mutationFn:vn,onError:s=>Promise.resolve(e==null?void 0:e(s,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(r==null?void 0:r(void 0))});return {disconnect:s=>i.mutate(s),disconnectAsync:s=>i.mutateAsync(s),error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,status:i.status}},G5=e=>{let t=Ne({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),r=P(i=>i.walletType),n=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,r],[t,r]);return reactQuery.useQuery({queryKey:n,queryFn:o=>g(void 0,[o],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chain found");if(!Ie(s))throw new Error(`${s} is not available`);return yield ze(!!(e!=null&&e.multiChain),i,h=>g(void 0,null,function*(){return yield Km({chainId:h.chainId,walletType:s})}))}),enabled:!!t&&t.length>0&&!!r,refetchOnWindowFocus:!1})},V5=e=>{let t=Ne({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:r}=Tt(),{data:n}=fl({chainId:t.map(o=>o.chainId),multiChain:!0}),i=(e==null?void 0:e.bech32Address)||(r==null?void 0:r.bech32Address),s=react.useMemo(()=>["USE_BALANCE_STAKED",n,t,i],[t,i,n]);return reactQuery.useQuery({queryKey:s,queryFn:h=>g(void 0,[h],function*({queryKey:[,o,a,c]}){if(!c)throw new Error("address is not defined");return yield ze(!!(e!=null&&e.multiChain),a,f=>g(void 0,null,function*(){var p,u;if(!o)throw new Error("Client is not ready");if(!((p=f.bech32Config)!=null&&p.bech32PrefixAccAddr))throw new Error(`Bech32Config is missing ${f.chainId}`);return yield (u=o[f.chainId])==null?void 0:u.getBalanceStaked(encoding.toBech32(f.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),enabled:!!i&&!!t&&t.length>0&&!!n,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};d();var eF=()=>{let e=P(n=>n.capsuleState),t=k(n=>n.capsuleClient),r=Cn();return {setModalState:n=>{P.setState(i=>{var s;return {capsuleState:{showModal:n,chainId:(s=i.capsuleState)==null?void 0:s.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:r.onAfterLoginSuccessful,onLoginFailure:()=>{vn();}}};d();var aF=()=>k(e=>e.activeChainIds),CO=()=>{var e;return (e=k(t=>t.activeChainIds))==null?void 0:e.map(t=>{var n;let r=(n=P.getState().chains)==null?void 0:n.find(i=>i.chainId===t);if(r)return r}).filter(Boolean)},cF=({chainId:e})=>{var t;return (t=P().chains)==null?void 0:t.find(r=>r.chainId===e)},lF=({chainId:e})=>{var t;return (t=P().chains)==null?void 0:t.filter(r=>e==null?void 0:e.includes(r.chainId))},uF=({denom:e})=>{let t=CO();return reactQuery.useQuery({queryKey:["USE_ACTIVE_CHAIN_CURRENCY",e],queryFn:({queryKey:[,i]})=>{var s;return (s=t==null?void 0:t.find(o=>o.currencies.find(a=>a.coinMinimalDenom===i)))==null?void 0:s.currencies.find(o=>o)}})},fF=e=>{var i;let t=(i=e.status)!=null?i:"BOND_STATUS_BONDED",r=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery({queryKey:r,queryFn:a=>g(void 0,[a],function*({queryKey:[,s,o]}){if(!s)throw new Error("Query client is not defined");return yield s.staking.validators(o)}),enabled:typeof e.queryClient!="undefined"})},hF=()=>({data:P(t=>t.recentChainIds),clear:sl}),dF=()=>{var t;return {data:(t=P(r=>r.recentChainIds))==null?void 0:t.map(r=>{var i;let n=(i=P.getState().chains)==null?void 0:i.find(s=>s.chainId===r);if(n)return n}).filter(Boolean),clear:sl}},pF=({onError:e,onLoading:t,onSuccess:r}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_SUGGEST_CHAIN",e,t,r],mutationFn:ol,onError:(s,o)=>Promise.resolve(e==null?void 0:e(s,o.chainInfo)),onMutate:s=>t==null?void 0:t(s.chainInfo),onSuccess:s=>Promise.resolve(r==null?void 0:r(s))});return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,suggest:i.mutate,suggestAsync:i.mutateAsync,status:i.status}},gF=({onError:e,onLoading:t,onSuccess:r}={})=>{let i=reactQuery.useMutation({mutationKey:["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,r],mutationFn:jm,onError:(o,a)=>Promise.resolve(e==null?void 0:e(o,a)),onMutate:o=>t==null?void 0:t(o),onSuccess:o=>Promise.resolve(r==null?void 0:r(o))}),{data:s}=cs();return {error:i.error,isLoading:i.isPending,isSuccess:i.isSuccess,isSupported:!!s,status:i.status,suggestAndConnect:i.mutate,suggestAndConnectAsync:i.mutateAsync}};d();var vF=({onError:e,onLoading:t,onSuccess:r}={})=>{let{data:n}=Tt(),i=n==null?void 0:n.bech32Address,s=reactQuery.useMutation({mutationKey:["USE_SEND_TOKENS",e,t,r,i],mutationFn:o=>$m(M({senderAddress:i},o)),onError:(o,a)=>Promise.resolve(e==null?void 0:e(o,a)),onMutate:t,onSuccess:o=>Promise.resolve(r==null?void 0:r(o))});return {error:s.error,isLoading:s.isPending,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},xF=({onError:e,onLoading:t,onSuccess:r}={})=>{let{data:n}=Tt(),i=n==null?void 0:n.bech32Address,s=reactQuery.useMutation({mutationKey:["USE_SEND_IBC_TOKENS",e,t,r,i],mutationFn:o=>qm(M({senderAddress:i},o)),onError:(o,a)=>Promise.resolve(e==null?void 0:e(o,a)),onMutate:t,onSuccess:o=>Promise.resolve(r==null?void 0:r(o))});return {error:s.error,isLoading:s.isPending,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},CF=({codeId:e,onError:t,onLoading:r,onSuccess:n})=>{let{data:i}=Tt(),s=i==null?void 0:i.bech32Address,a=reactQuery.useMutation({mutationKey:["USE_INSTANTIATE_CONTRACT",t,r,n,e,s],mutationFn:c=>{var l;if(!s)throw new Error("senderAddress is undefined");let h=X(M({},c),{fee:(l=c.fee)!=null?l:"auto",senderAddress:s,codeId:e});return Gm(h)},onError:(c,h)=>Promise.resolve(t==null?void 0:t(c,h)),onMutate:r,onSuccess:c=>Promise.resolve(n==null?void 0:n(c))});return {error:a.error,isLoading:a.isPending,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},IF=({contractAddress:e,onError:t,onLoading:r,onSuccess:n})=>{let{data:i}=Tt(),s=i==null?void 0:i.bech32Address,a=reactQuery.useMutation({mutationKey:["USE_EXECUTE_CONTRACT",t,r,n,e,s],mutationFn:c=>{var l,f,m;if(!s)throw new Error("senderAddress is undefined");let h=X(M({},c),{fee:(l=c.fee)!=null?l:"auto",senderAddress:s,contractAddress:e,memo:(f=c.memo)!=null?f:"",funds:(m=c.funds)!=null?m:[]});return Vm(h)},onError:(c,h)=>Promise.resolve(t==null?void 0:t(c,h)),onMutate:r,onSuccess:c=>Promise.resolve(n==null?void 0:n(c))});return {error:a.error,isLoading:a.isPending,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},DF=e=>{let{data:t}=hl();return reactQuery.useQuery({queryKey:["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],queryFn:({queryKey:[,n]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return Hm(e.address,e.queryMsg,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},AF=e=>{let{data:t}=hl(),r=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery({queryKey:r,queryFn:({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return Jm(e.address,e.key,t)},enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};d();function KF(e){let t=Ne({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),r=P(s=>s.walletType),n=k(s=>s.activeChainIds),i=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,r,e,n],[n,e,t,r]);return reactQuery.useQuery({queryKey:i,queryFn:a=>g(this,[a],function*({queryKey:[,s,o]}){if(s.length<1)throw new Error("No chains found");return yield ze(!!(e!=null&&e.multiChain),s,h=>g(this,null,function*(){var y,w;if(!(n!=null&&n.includes(h.chainId)))return null;if(!Ie(o))throw new Error(`${o} is not available`);let f=yield (()=>g(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return oe(o).getOfflineSigner(h.chainId);case"offlineSignerAuto":return oe(o).getOfflineSignerAuto(h.chainId);case"offlineSignerOnlyAmino":return oe(o).getOfflineSignerOnlyAmino(h.chainId);default:return oe(o).getOfflineSignerAuto(h.chainId)}}))(),m=(y=P.getState().chainsConfig)==null?void 0:y[h.chainId],p={url:h.rpc,headers:M({},(m==null?void 0:m.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(p,f,e!=null&&e.multiChain?(w=e.opts)==null?void 0:w[h.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!r&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function jF(e){let t=Ne({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),r=P(s=>s.walletType),n=k(s=>s.activeChainIds),i=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,r,e,n],[n,e,t,r]);return reactQuery.useQuery({queryKey:i,queryFn:a=>g(this,[a],function*({queryKey:[,s,o]}){if(s.length<1)throw new Error("No chains found");return yield ze(!!(e!=null&&e.multiChain),s,h=>g(this,null,function*(){var w,S;if(!(n!=null&&n.includes(h.chainId)))return null;if(!Ie(o))throw new Error(`${o} is not available`);let f=yield (()=>g(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return oe(o).getOfflineSigner(h.chainId);case"offlineSignerAuto":return oe(o).getOfflineSignerAuto(h.chainId);case"offlineSignerOnlyAmino":return oe(o).getOfflineSignerOnlyAmino(h.chainId);default:return oe(o).getOfflineSignerAuto(h.chainId)}}))(),m=(w=P.getState().chainsConfig)==null?void 0:w[h.chainId],p={url:h.rpc,headers:M({},(m==null?void 0:m.rpcHeaders)||{})},u=m!=null&&m.gas?stargate.GasPrice.fromString(`${m.gas.price}${m.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(p,f,M({gasPrice:u},e!=null&&e.multiChain?(S=e.opts)==null?void 0:S[h.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!r&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function zF(e){let t=Ne({chainId:e.chainId,multiChain:e.multiChain}),r=P(o=>o.walletType),n=k(o=>o.activeChainIds),i=react.useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,r,e,n],[n,e,t,r]),{data:s}=as({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return reactQuery.useQuery({queryKey:i,queryFn:c=>g(this,[c],function*({queryKey:[,o,a]}){if(o.length<1)throw new Error("No chains found");return yield ze(!!e.multiChain,o,l=>g(this,null,function*(){var y;if(!(n!=null&&n.includes(l.chainId)))return null;if(!Ie(a))throw new Error(`${a} is not available`);if(!s)throw new Error("No tendermint client found");let m=yield (()=>g(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return oe(a).getOfflineSigner(l.chainId);case"offlineSignerAuto":return oe(a).getOfflineSignerAuto(l.chainId);case"offlineSignerOnlyAmino":return oe(a).getOfflineSignerOnlyAmino(l.chainId);default:return oe(a).getOfflineSignerAuto(l.chainId)}}))(),p=e.multiChain?s[l.chainId]:s;return yield stargate.SigningStargateClient.createWithSigner(p,m,e.multiChain?(y=e.opts)==null?void 0:y[l.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!r&&!!s&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function $F(e){let t=Ne({chainId:e.chainId,multiChain:e.multiChain}),r=P(a=>a.walletType),n=k(a=>a.activeChainIds),i=react.useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,r,e,n],[n,e,t,r]),{data:s}=as({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:o}=as({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return reactQuery.useQuery({queryKey:i,queryFn:h=>g(this,[h],function*({queryKey:[,a,c]}){if(a.length<1)throw new Error("No chains found");return yield ze(!!e.multiChain,a,f=>g(this,null,function*(){var b,_;if(!(n!=null&&n.includes(f.chainId)))return null;if(!Ie(c))throw new Error(`${c} is not available`);let p=yield (()=>g(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return oe(c).getOfflineSigner(f.chainId);case"offlineSignerAuto":return oe(c).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return oe(c).getOfflineSignerOnlyAmino(f.chainId);default:return oe(c).getOfflineSignerAuto(f.chainId)}}))(),u=(b=P.getState().chainsConfig)==null?void 0:b[f.chainId],y=u!=null&&u.gas?stargate.GasPrice.fromString(`${u.gas.price}${u.gas.denom}`):void 0,w=e.multiChain?o==null?void 0:o[f.chainId]:s;if(!w)throw new Error("No tendermint client found");return yield cosmwasmStargate.SigningCosmWasmClient.createWithSigner(w,p,M({gasPrice:y},e.multiChain?(_=e.opts)==null?void 0:_[f.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!r&&(!!s||!os(o))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}d();d();var ly=({children:e})=>{let[t,r]=react.useState(!1);return react.useEffect(()=>{r(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};d();var RO=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(at)==="Active",{_reconnect:t,_onReconnectFailed:r,_reconnectConnector:n,iframeOptions:i,chains:s}=P(),{activeChainIds:o,wcSignClients:a}=k(),c=Ie(n||void 0);return react.useEffect(()=>{if(!i||i.autoConnect===!1||!i.allowedIframeParentOrigins.length||!s)return;new cosmiframe.Cosmiframe(i.allowedIframeParentOrigins).isReady().then(l=>{if(l)return Ot({chainId:s.map(f=>f.chainId),walletType:"cosmiframe"})});},[i]),react.useEffect(()=>{if(n){if(!c)return;e&&o?Pe({onError:r}):!e&&t&&Pe({onError:r});}},[c]),react.useEffect(()=>{var h,l,f,m,p,u,y,w,S,b,_,x,O,L,E,C,F,T,D,I;if(n){if(!c)return;n==="cosmostation"&&((l=(h=An()).subscription)==null||l.call(h,()=>{Pe({onError:r});})),n==="keplr"&&((m=(f=On()).subscription)==null||m.call(f,()=>{Pe({onError:r});})),n==="leap"&&((u=(p=Tn()).subscription)==null||u.call(p,()=>{Pe({onError:r});})),n==="compass"&&((w=(y=In()).subscription)==null||w.call(y,()=>{Pe({onError:r});})),n==="vectis"&&((b=(S=Ln()).subscription)==null||b.call(S,()=>{Pe({onError:r});})),n==="walletconnect"&&a.has("walletconnect")&&((x=(_=He()).subscription)==null||x.call(_,()=>{Pe({onError:r});})),n==="station"&&((L=(O=Nn()).subscription)==null||L.call(O,()=>{Pe({onError:r});})),n==="xdefi"&&((C=(E=ss()).subscription)==null||C.call(E,()=>{Pe({onError:r});})),n==="cosmiframe"&&((T=(F=Dn()).subscription)==null||T.call(F,()=>{Pe({onError:r});})),n==="okx"&&((I=(D=Pn()).subscription)==null||I.call(D,()=>{Pe({onError:r});}));}},[n,a,c]),null},uy=()=>(RO(),null);var SB=({children:e,grazOptions:t})=>(react.useEffect(()=>{zm(t);},[t]),jsxRuntime.jsxs(ly,{children:[e,jsxRuntime.jsx(uy,{})]}));/*! Bundled license information:
138
+
139
+ tslib/tslib.es6.js:
140
+ (*! *****************************************************************************
141
+ Copyright (c) Microsoft Corporation.
142
+
143
+ Permission to use, copy, modify, and/or distribute this software for any
144
+ purpose with or without fee is hereby granted.
145
+
146
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
147
+ REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
148
+ AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
149
+ INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
150
+ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
151
+ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
152
+ PERFORMANCE OF THIS SOFTWARE.
153
+ ***************************************************************************** *)
154
+ */
155
+
156
+ exports.GrazEvents = uy;
157
+ exports.GrazProvider = SB;
158
+ exports.WALLET_TYPES = bl;
159
+ exports.WalletType = wl;
160
+ exports.checkWallet = Ie;
161
+ exports.clearRecentChain = sl;
162
+ exports.clearSession = ye;
163
+ exports.configureGraz = zm;
164
+ exports.connect = Ot;
165
+ exports.defineChainInfo = n5;
166
+ exports.defineChains = r5;
167
+ exports.disconnect = vn;
168
+ exports.executeContract = Vm;
169
+ exports.getAvailableWallets = RM;
170
+ exports.getChainInfo = qM;
171
+ exports.getChainInfos = GM;
172
+ exports.getCosmostation = An;
173
+ exports.getKeplr = On;
174
+ exports.getLeap = Tn;
175
+ exports.getMetamaskSnapLeap = Pl;
176
+ exports.getOfflineSigners = Km;
177
+ exports.getQueryRaw = Jm;
178
+ exports.getQuerySmart = Hm;
179
+ exports.getRecentChainIds = zM;
180
+ exports.getRecentChains = $M;
181
+ exports.getVectis = Ln;
182
+ exports.getWCCosmostation = km;
183
+ exports.getWCKeplr = Um;
184
+ exports.getWCLeap = Wm;
185
+ exports.getWallet = oe;
186
+ exports.getWalletConnect = He;
187
+ exports.instantiateContract = Gm;
188
+ exports.isCapsule = nl;
189
+ exports.isWalletConnect = il;
190
+ exports.reconnect = Pe;
191
+ exports.sendIbcTokens = qm;
192
+ exports.sendTokens = $m;
193
+ exports.suggestChain = ol;
194
+ exports.suggestChainAndConnect = jm;
195
+ exports.useAccount = Tt;
196
+ exports.useActiveChainCurrency = uF;
197
+ exports.useActiveChainIds = aF;
198
+ exports.useActiveChains = CO;
199
+ exports.useActiveWalletType = T5;
200
+ exports.useBalance = z5;
201
+ exports.useBalanceStaked = V5;
202
+ exports.useBalances = xO;
203
+ exports.useCapsule = eF;
204
+ exports.useChainInfo = cF;
205
+ exports.useChainInfos = lF;
206
+ exports.useCheckWallet = cs;
207
+ exports.useConnect = $5;
208
+ exports.useCosmWasmClient = hl;
209
+ exports.useCosmWasmSigningClient = jF;
210
+ exports.useCosmWasmTmSigningClient = $F;
211
+ exports.useDisconnect = q5;
212
+ exports.useExecuteContract = IF;
213
+ exports.useGrazEvents = RO;
214
+ exports.useInstantiateContract = CF;
215
+ exports.useOfflineSigners = G5;
216
+ exports.useQueryClientValidators = fF;
217
+ exports.useQueryRaw = AF;
218
+ exports.useQuerySmart = DF;
219
+ exports.useRecentChainIds = hF;
220
+ exports.useRecentChains = dF;
221
+ exports.useSendIbcTokens = xF;
222
+ exports.useSendTokens = vF;
223
+ exports.useStargateClient = fl;
224
+ exports.useStargateSigningClient = KF;
225
+ exports.useStargateTmSigningClient = zF;
226
+ exports.useSuggestChain = pF;
227
+ exports.useSuggestChainAndConnect = gF;
228
+ exports.useTendermintClient = as;