graz 0.1.21 → 0.1.23

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
@@ -21,10 +21,10 @@ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
21
21
 
22
22
  var sn__default = /*#__PURE__*/_interopDefault(sn);
23
23
 
24
- var Ft=Object.defineProperty,qt=Object.defineProperties;var Gt=Object.getOwnPropertyDescriptors;var se=Object.getOwnPropertySymbols;var Ge=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable;var qe=(e,t,n)=>t in e?Ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))Ge.call(t,n)&&qe(e,n,t[n]);if(se)for(var n of se(t))ze.call(t,n)&&qe(e,n,t[n]);return e},F=(e,t)=>qt(e,Gt(t));var Qe=(e,t)=>{var n={};for(var o in e)Ge.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&se)for(var o of se(e))t.indexOf(o)<0&&ze.call(e,o)&&(n[o]=e[o]);return n};var c=(e,t,n)=>new Promise((o,r)=>{var i=l=>{try{a(n.next(l));}catch(m){r(m);}},s=l=>{try{a(n.throw(l));}catch(m){r(m);}},a=l=>l.done?o(l.value):Promise.resolve(l.value).then(i,s);a((n=n.apply(e,t)).next());});var V="graz-reconnect-session";var je=(O=>(O.KEPLR="keplr",O.LEAP="leap",O.VECTIS="vectis",O.COSMOSTATION="cosmostation",O.WALLETCONNECT="walletconnect",O.WC_KEPLR_MOBILE="wc_keplr_mobile",O.WC_LEAP_MOBILE="wc_leap_mobile",O.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",O.WC_CLOT_MOBILE="wc_clot_mobile",O.METAMASK_SNAP_LEAP="metamask_snap_leap",O.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",O.STATION="station",O.XDEFI="xdefi",O.CAPSULE="capsule",O.COSMIFRAME="cosmiframe",O.COMPASS="compass",O.INITIA="initia",O))(je||{}),$e=["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"];var Qt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,web3Modal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},te={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},jt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},$t={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},d=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>te,jt))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>Qt,$t)));var ae=()=>{var C,g;if(!((C=u.getState().capsuleConfig)!=null&&C.apiKey)||!((g=u.getState().capsuleConfig)!=null&&g.env))throw new Error("Capsule configuration is not set");let e=()=>c(void 0,null,function*(){var h,O;let p=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,S=new p({apiKey:(h=u.getState().capsuleConfig)==null?void 0:h.apiKey,env:(O=u.getState().capsuleConfig)==null?void 0:O.env});return d.setState({capsuleClient:S}),S});return {init:e,enable:p=>c(void 0,null,function*(){let S=typeof p=="string"?[p]:p,h=d.getState().capsuleClient;h||(h=yield e()),u.setState({capsuleState:{showModal:!0,chainId:S}});}),onAfterLoginSuccessful:()=>c(void 0,null,function*(){var y;let p=d.getState().capsuleClient,{chains:S}=u.getState();if(!p)throw new Error("Capsule client is not initialized");if(!S)throw new Error("Chains are not set");yield p.enable();let h=(y=u.getState().capsuleState)==null?void 0:y.chainId;if(!h)throw new Error("Chain ids are not set");let O=Object.fromEntries(yield Promise.all(h.map(A=>c(void 0,null,function*(){let T=yield p.getAccount(A);return [A,{address:encoding.fromBech32(T.address).data,bech32Address:T.address,algo:T.algo,name:T.username||"",pubKey:T.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));d.setState(A=>({accounts:x(x({},A.accounts||{}),O)})),u.setState(A=>({recentChainIds:[...A.recentChainIds||[],...h].filter((T,P,D)=>D.indexOf(T)===P)})),d.setState(A=>({activeChainIds:[...A.activeChainIds||[],...h].filter((T,P,D)=>D.indexOf(T)===P)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),d.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active"),u.setState({capsuleState:null});}),getKey:p=>c(void 0,null,function*(){let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");let h=yield S.getAccount(p);return {address:encoding.fromBech32(h.address).data,bech32Address:h.address,algo:h.algo,name:h.username||"",pubKey:h.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:p=>c(void 0,null,function*(){let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(p)}),getOfflineSignerDirect:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(p)},signDirect:(...p)=>c(void 0,null,function*(){let[S,h,O]=p,y=d.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.signDirect(S,h,{bodyBytes:O.bodyBytes,authInfoBytes:O.authInfoBytes,chainId:O.chainId,accountNumber:O.accountNumber})}),signAmino:(...p)=>c(void 0,null,function*(){let[S,h,O,y]=p,A=d.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");return A.signAmino(S,h,O,y)}),signArbitrary:(p,S,h)=>c(void 0,null,function*(){let O=d.getState().capsuleClient;if(!O)throw new Error("Capsule client is not initialized");let y=yield O.getAccount(p);if(!y)throw new Error(`Wallet not connected to account ${S}`);let A=(()=>{switch(y.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(y.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(y.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield O.signArbitrary(p,S,h),pub_key:{type:y.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:A.value}}}),experimentalSuggestChain:(...p)=>c(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSigner(p)},getOfflineSignerAmino:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerAmino(p)}}};var ce=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let i=()=>{N(),r();};return window.addEventListener("leap_keystorechange",i),()=>{window.removeEventListener("leap_keystorechange",i);}},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 tt={},nt=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>c(void 0,null,function*(){var I;let i=yield e.request({method:"web3_clientVersion"});if(!i.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=(I=i.split("MetaMask/v")[1])==null?void 0:I.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:i=>c(void 0,null,function*(){(yield snapper.isSnapInstalled())||(yield snapper.installSnap());}),getOfflineSigner:i=>t.getOfflineSigner(i),experimentalSuggestChain:i=>c(void 0,null,function*(){yield t.experimentalSuggestChain(i);}),signAmino:(i,s,a)=>c(void 0,null,function*(){return t.signAmino(i,s,a)}),getKey:i=>c(void 0,null,function*(){return typeof tt[i]!="undefined"?tt[i]:t.getKey(i)}),getOfflineSignerAuto:i=>c(void 0,null,function*(){return (yield t.getKey(i)).isNanoLedger?t.getOfflineSignerOnlyAmino(i):t.getOfflineSigner(i)}),getOfflineSignerOnlyAmino:i=>t.getOfflineSignerOnlyAmino(i),signDirect:(i,s,a)=>c(void 0,null,function*(){return t.signDirect(i,s,a)}),signArbitrary:(i,s,a)=>c(void 0,null,function*(){return t.signArbitrary(i,s,a)}),disable:i=>c(void 0,null,function*(){i&&(yield t.deleteChain(i));})};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:i=>{let s=()=>{N(),i();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:i=>{t.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var on=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:o,accountNumber:r}=e;if(!t||!n||!o||!r)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:o,accountNumber:r}},rn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,ot=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>c(void 0,null,function*(){yield e.getAddress();}),getKey:f=>c(void 0,null,function*(){let C=e.getOfflineSigner(f),[g]=yield C.getAccounts();if(!g)throw new Error("Wallet connection failed");let p=(()=>{switch(g.algo){case"secp256k1":return amino.rawSecp256k1PubkeyToRawAddress(g.pubkey);case"ed25519":return amino.rawEd25519PubkeyToRawAddress(g.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:rn(g.address),algo:g.algo,pubKey:g.pubkey,bech32Address:g.address,address:p,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:f=>{let C=e.getOfflineSigner(f),g=e.getOfflineSignerOnlyAmino(f);return {getAccounts:C.getAccounts.bind(C),signDirect:C.signDirect.bind(C),signAmino:g.signAmino.bind(g)}},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(C=>{var g,p,S;return {denom:C.coinDenom,amount:C.coinMinimalDenom,low_gas_price:(g=C.gasPriceStep)==null?void 0:g.low,average_gas_price:(p=C.gasPriceStep)==null?void 0:p.average,high_gas_price:(S=C.gasPriceStep)==null?void 0:S.high}})},apis:{rpc:[{address:f.rpc}],rest:[{address:f.rest}]}}),signDirect:(...f)=>{let[C,g,p]=f;return e.getOfflineSigner(C).signDirect(g,on(p))},signAmino:(...f)=>{let[C,g,p]=f;return e.getOfflineSignerOnlyAmino(C).signAmino(g,p)},signArbitrary:(f,C,g)=>c(void 0,null,function*(){let h=(yield e.getOfflineSigner(f).getAccounts()).find(A=>A.address===C);if(!h)throw new Error(`Wallet not connected to account ${C}`);let O=(()=>{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(g),pub_key:{type:h.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:O.value}}}),subscription:f=>{let C=()=>{N(),f();};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 i=()=>{N(),r();};return window.addEventListener("keplr_keystorechange",i),()=>{window.removeEventListener("keplr_keystorechange",i);}},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 i=()=>{N(),r();};return window.addEventListener("leap_keystorechange",i),()=>{window.removeEventListener("leap_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var de={},rt=e=>{let t=window.ethereum;if(t&&e){let n=()=>c(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),o=y=>c(void 0,null,function*(){try{let A=yield n();return Object.values(A).find(T=>T.id===e.id&&(!y||T.version===y))}catch(A){return}}),r=()=>c(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),i=()=>c(void 0,null,function*(){var _;let y=yield t.request({method:"web3_clientVersion"});if(!y.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 T=(_=y.split("MetaMask/v")[1])==null?void 0:_.split(".")[0];if(!(Number(T)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield o())||(yield r()),!0}),s=y=>c(void 0,null,function*(){(yield o())||(yield r());}),a=(y,A,T)=>c(void 0,null,function*(){let P=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:y,signerAddress:A,signDoc:T}}}}),D=T.accountNumber,_=new sn__default.default(D.low,D.high,D.unsigned);return {signature:P.signature,signed:F(x({},P.signed),{accountNumber:`${_.toString()}`,authInfoBytes:new Uint8Array(Object.values(P.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(P.signed.bodyBytes))})}}),l=(y,A,T)=>c(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:y,signerAddress:A,signDoc:T}}}})}),m=y=>c(void 0,null,function*(){if(typeof de[y]!="undefined")return de[y];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:y}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,de[y]=A,de[y]}),I=y=>c(void 0,null,function*(){let A=yield m(y);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),f=(...y)=>c(void 0,null,function*(){let[A,T,P,D]=y;return yield l(A,T,P)}),C=(...y)=>c(void 0,null,function*(){let[A,T,P]=y;return yield a(A,T,P)}),p=y=>({getAccounts:()=>c(void 0,null,function*(){return [yield I(y)]}),signAmino:(A,T)=>f(y,A,T)});return {enable:s,experimentalSuggestChain:(...y)=>c(void 0,null,function*(){yield i(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:y[0]}}}});}),getKey:m,getOfflineSigner:y=>({getAccounts:()=>c(void 0,null,function*(){return [yield I(y)]}),signDirect:(A,T)=>C(y,A,T),signAmino:(A,T)=>f(y,A,T)}),getOfflineSignerAuto:y=>c(void 0,null,function*(){return p(y)}),getOfflineSignerOnlyAmino:p,init:i,signAmino:f,signDirect:C}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var st=()=>rt({id:"npm:@leapwallet/metamask-cosmos-snap"});var fe=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:i=>{let s=()=>{N(),i();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:i=>c(void 0,null,function*(){let s=yield e.getKey(i);return x({isKeystone:!1},s)}),getOfflineSigner:i=>{try{let s=e.getOfflineSignerOnlyAmino(i);return Object.assign(s,{signDirect:(m,I)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:i=>c(void 0,null,function*(){try{let s=Object.assign(i,{chainSymbolImageUrl:i.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:i.stakeCurrency.coinDecimals,coinDenom:i.stakeCurrency.coinDenom,coinImageUrl:i.stakeCurrency.coinImageUrl||"",coinMinimalDenom:i.stakeCurrency.coinMinimalDenom},currencies:i.currencies.map(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:i.feeCurrencies.map(a=>{var l,m,I;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((l=a.gasPriceStep)==null?void 0:l.average)||0,high:((m=a.gasPriceStep)==null?void 0:m.high)||0,low:((I=a.gasPriceStep)==null?void 0:I.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),enable:i=>e.enable(i),disable:i=>e.disable(i),getOfflineSignerAuto:i=>e.getOfflineSignerAuto(i),getOfflineSignerOnlyAmino:i=>e.getOfflineSignerOnlyAmino(i),signDirect:()=>e.signDirect(),signAmino:(i,s,a,l)=>e.signAmino(i,s,a)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var ge=()=>{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=>c(void 0,null,function*(){let l=yield e.getKey(a);return {address:encoding.fromBech32(l.address).data,algo:l.algo,bech32Address:l.address,name:l.name,pubKey:l.pubKey,isKeystone:!1,isNanoLedger:l.isNanoLedger}}),subscription:a=>{let l=()=>{N(),a();};return window.addEventListener("vectis_accountChanged",l),()=>{window.removeEventListener("vectis_accountChanged",l);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>c(void 0,null,function*(){let[l]=a,m=F(x({},l),{rpcUrl:l.rpc,restUrl:l.rest,prettyName:l.chainName.replace(" ",""),bech32Prefix:l.bech32Config.bech32PrefixAccAddr});return e.suggestChains([m])}),signDirect:(...a)=>c(void 0,null,function*(){var I;let{1:l,2:m}=a;return e.signDirect(l,{bodyBytes:m.bodyBytes||Uint8Array.from([]),authInfoBytes:m.authInfoBytes||Uint8Array.from([]),accountNumber:sn__default.default.fromString(((I=m.accountNumber)==null?void 0:I.toString())||"",!1),chainId:m.chainId||""})}),signAmino:(...a)=>c(void 0,null,function*(){let{1:l,2:m}=a;return e.signAmino(l,m)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var z=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,at=()=>z()&&navigator.userAgent.toLowerCase().includes("android"),ct=()=>z()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Me=(e,t,n=new Error("Promise timed out"))=>{let o=new Promise((r,i)=>{setTimeout(()=>{i(n);},t);});return Promise.race([e,o])};var Q=e=>{var _,X,ne;if(!((ne=(X=(_=u.getState().walletConnect)==null?void 0:_.options)==null?void 0:X.projectId)!=null&&ne.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",o=w=>{if(!e)return;let{appUrl:E,formatNativeUrl:b}=e;if(z()){if(at())if(!w)window.open(E.mobile.android,"_self","noreferrer noopener");else {let k=b(E.mobile.android,w,"android");window.open(k,"_self","noreferrer noopener");}if(ct())if(!w)window.open(E.mobile.ios,"_self","noreferrer noopener");else {let k=b(E.mobile.ios,w,"ios");window.open(k,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:w}=d.getState();if(!w.get(t))throw new Error("walletConnect.signClient is not defined");w.delete(t),d.setState({wcSignClients:w}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},i=w=>c(void 0,null,function*(){let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");if(!w)throw new Error("No wallet connect session");yield b.disconnect({topic:w,reason:utils.getSdkError("USER_DISCONNECTED")}),yield l(b);}),s=w=>{try{let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");let k=b.session.getAll().at(-1);if(!k)return;if(!(k.expiry*1e3>Date.now()+1e3))throw i(k.topic),new Error("invalid session");try{let v=b.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:w.map(L=>`cosmos:${L}`),events:["chainChanged","accountsChanged"]}}});if(!v.length)throw new Error("no session");return v.at(-1)}catch(v){if(!v.message.toLowerCase().includes("no matching key"))throw v}return k}catch(E){if(!E.message.toLowerCase().includes("no matching key"))throw E}},a=w=>{try{return s(w)}catch(E){return}},l=w=>c(void 0,null,function*(){try{let E=w.core.pairing.pairings.getAll({active:!1});if(!E.length)return;yield Promise.all(E.map(b=>c(void 0,null,function*(){yield w.core.pairing.pairings.delete(b.topic,{code:7001,message:"clear pairing"});})));}catch(E){if(!E.message.toLowerCase().includes("no matching key"))throw E}}),m=()=>c(void 0,null,function*(){let{walletConnect:w}=u.getState();if(!(w!=null&&w.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:E}=d.getState(),b=E.get(t);if(b)return b;let k=yield signClient.SignClient.init(w.options);return E.set(t,k),d.setState({wcSignClients:E}),k}),I=w=>{let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)return ()=>{};let k=W=>{let v=d.getState().accounts;if(W.params.event.name==="accountsChanged"&&v&&!Object.values(v).map(L=>L.bech32Address).includes(W.params.event.data[0])){let L=W.params.chainId.split(":")[1];L&&f([L]);}else w();};return b.events.on("session_delete",r),b.events.on("session_expire",r),b.events.on("session_event",k),()=>{b.events.off("session_delete",r),b.events.off("session_expire",r),b.events.off("session_event",k);}},f=w=>c(void 0,null,function*(){var oe;let E=typeof w=="string"?[w]:w,{wcSignClients:b}=d.getState(),k=b.get(t);if(!k)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:W,chains:v}=u.getState();if(!((oe=W==null?void 0:W.options)!=null&&oe.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:L}=yield import('@web3modal/standalone'),$=new L(x({projectId:W.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},W.web3Modal)),J=a(E);if(!J){let{uri:U,approval:Z}=yield Me(k.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:E.map(j=>`cosmos:${j}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!U)throw new Error("No wallet connect uri");e?o(U):yield $.openModal({uri:U});let Lt=j=>c(void 0,null,function*(){return j.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((be,ee)=>{Z().then(Be=>{let Le=Be.sessionProperties;if(!Le)return ee(new Error("No session properties"));let Te=JSON.parse(String(Le.keys));if(Te.length===0)return ee(new Error("No accounts"));let Ue=Te[0];if(!Ue)return ee(new Error("No accounts"));let Fe={};return E.forEach(re=>{Fe[re]=F(x({},Ue),{bech32Address:encoding.toBech32(v.find(Ut=>Ut.chainId===re).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(Te[0].bech32Address).data)});}),d.setState(re=>({accounts:x(x({},re.accounts||{}),Fe)})),be(Be)}).catch(ee),j.addEventListener("abort",()=>{ee(new Error("User closed wallet connect"));},{once:!0});})});try{let j=new AbortController,be=j.signal;$.subscribeModal(ee=>{ee.open||j.abort();}),yield Lt(be);}catch(j){if($.closeModal(),!j.message.toLowerCase().includes("no matching key"))return Promise.reject(j)}return e||$.closeModal(),Promise.resolve()}try{yield Me((()=>c(void 0,null,function*(){let U=Object.fromEntries(yield Promise.all(E.map(Z=>c(void 0,null,function*(){return [Z,yield g(Z)]}))));d.setState({accounts:U});}))(),15e3,new Error("Connection timeout"));}catch(U){if(i(J.topic),!U.message.toLowerCase().includes("no matching key"))throw U}}),C=w=>c(void 0,null,function*(){var v;let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");let k=(v=s([w]))==null?void 0:v.topic;if(!k)throw new Error("No wallet connect session");let W=yield b.request({topic:k,chainId:`cosmos:${w}`,request:{method:"cosmos_getAccounts",params:{}}});if(!W[0])throw new Error("No wallet connect account");return {address:W[0].address,algo:W[0].algo,pubkey:new Uint8Array(Buffer.from(W[0].pubkey,n))}}),g=w=>c(void 0,null,function*(){let E=s([w]);if(!(E!=null&&E.topic))throw new Error("No wallet connect session");let b=E.sessionProperties&&JSON.parse(String(E.sessionProperties.keys))[0];if(!b)throw new Error("No wallet connect key");return b}),p=(...w)=>c(void 0,null,function*(){var U,Z;let[E,b,k]=w,{accounts:W,wcSignClients:v}=d.getState(),L=v.get(t);if(!L)throw new Error("walletConnect.signClient is not defined");if(!W)throw new Error("account is not defined");let $=(U=s([E]))==null?void 0:U.topic;if(!$)throw new Error("No wallet connect session");if(!k.bodyBytes)throw new Error("No bodyBytes");if(!k.authInfoBytes)throw new Error("No authInfoBytes");let J={topic:$,chainId:`cosmos:${E}`,request:{method:"cosmos_signDirect",params:{signerAddress:b,signDoc:F(x({},k),{bodyBytes:Buffer.from(k.bodyBytes).toString(n),authInfoBytes:Buffer.from(k.authInfoBytes).toString(n),accountNumber:(Z=k.accountNumber)==null?void 0:Z.toString()})}}};return o(),yield L.request(J)}),S=(...w)=>c(void 0,null,function*(){let[E,b,k]=w,{signature:W,signed:v}=yield p(E,b,k);return {signed:{chainId:v.chainId,accountNumber:sn__default.default.fromString(v.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(v.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(v.bodyBytes,n))},signature:W}}),h=(...w)=>c(void 0,null,function*(){var U;let[E,b,k,W]=w,{wcSignClients:v}=d.getState(),L=v.get(t),{accounts:$}=d.getState();if(!L)throw new Error("walletConnect.signClient is not defined");if(!$)throw new Error("account is not defined");let J=(U=s([E]))==null?void 0:U.topic;if(!J)throw new Error("No wallet connect session");return o(),yield L.request({topic:J,chainId:`cosmos:${E}`,request:{method:"cosmos_signDirect",params:{signerAddress:b,signDoc:k}}})}),O=(...w)=>c(void 0,null,function*(){let[E,b,k,W]=w;return yield h(E,b,k)}),y=w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signDirect:(E,b)=>S(w,E,b)}),A=w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signAmino:(E,b)=>O(w,E,b)});return {enable:f,disable:w=>c(void 0,null,function*(){var k;let{wcSignClients:E}=d.getState(),b=E.get(t);if(w===void 0){let W=b==null?void 0:b.session.getAll();W!==void 0&&(yield Promise.all(W.map(v=>i(v.topic))));}else typeof w=="string"?yield i((k=s([w]))==null?void 0:k.topic):yield Promise.all(w.map(W=>{var v;return i((v=s([W]))==null?void 0:v.topic)}));(b==null?void 0:b.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...w)=>c(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:g,getOfflineSigner:w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signDirect:(E,b)=>S(w,E,b),signAmino:(E,b)=>O(w,E,b)}),getOfflineSignerAuto:w=>c(void 0,null,function*(){return (yield g(w)).isNanoLedger?A(w):y(w)}),getOfflineSignerOnlyAmino:A,signAmino:O,signDirect:S,subscription:I,init:m}};var lt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())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,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;default:return `${a}://wc?uri=${l}`}}};return Q(e)};var ut=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())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,i,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${i}`};return Q(e)};var pt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())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,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return Q(e)};var mt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())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,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return Q(e)};var ye=()=>{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 i=()=>{N(),r();};return window.addEventListener("keplr_keystorechange",i),()=>{window.removeEventListener("keplr_keystorechange",i);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var K=(e=u.getState().walletType)=>{try{return R(e),!0}catch(t){return !1}},N=()=>{window.sessionStorage.removeItem(V),d.setState(te);},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 ge();case"walletconnect":return Q();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 st();case"metamask_snap_cosmos":return nt();case"station":return fe();case"xdefi":return ye();case"capsule":return ae();case"cosmiframe":return le();case"compass":return ce();case"initia":return ot();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((o=t.setDefaultOptions)==null||o.call(t,n)),t},Zo=()=>Object.fromEntries($e.map(e=>[e,K(e)])),xe=e=>e==="capsule",dt=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var H=e=>c(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:o,walletType:r}=u.getState(),i=(e==null?void 0:e.walletType)||r;if(!K(i))throw new Error(`${i} is not available`);let a=R(i),l=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!l)throw new Error("No last known connected chain, connect action requires chain ids");let m=o==null?void 0:o.map(g=>g.chainId);l.forEach(g=>{if(!(m!=null&&m.includes(g)))throw new Error(`Chain ${g} is not provided in GrazProvider`)}),d.setState(g=>{let p=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!l;return g.activeChainIds&&l.filter(h=>{var O;return !((O=g.activeChainIds)!=null&&O.includes(h))}).length>0?{status:"connecting"}:p?{status:"reconnecting"}:{status:"connecting"}});let{accounts:I}=d.getState();if(yield (t=a.init)==null?void 0:t.call(a),xe(i)&&d.getState().capsuleClient&&Object.values(d.getState().accounts||[]).length>0){let g=l.map(h=>o.find(O=>O.chainId===h)),p=d.getState().accounts;d.setState({status:"connecting"});let S=Object.fromEntries(yield Promise.all(l.map(h=>c(void 0,null,function*(){return [h,yield a.getKey(h)]}))));return d.setState(h=>({accounts:x(x({},h.accounts||{}),S)})),u.setState(h=>({recentChainIds:[...h.recentChainIds||[],...l].filter((O,y,A)=>A.indexOf(O)===y)})),d.setState(h=>({activeChainIds:[...h.activeChainIds||[],...l].filter((O,y,A)=>A.indexOf(O)===y)})),d.setState({status:"connected"}),{accounts:p,walletType:i,chains:g}}if(yield a.enable(l),xe(i)){let g=l.map(S=>o.find(h=>h.chainId===S)),p=d.getState().accounts;return d.setState({status:"connecting"}),{accounts:p,walletType:i,chains:g}}if(!dt(i)){let g=Object.fromEntries(yield Promise.all(l.map(p=>c(void 0,null,function*(){return [p,yield a.getKey(p)]}))));d.setState(p=>({accounts:x(x({},p.accounts||{}),g)}));}u.setState(g=>({recentChainIds:[...g.recentChainIds||[],...l].filter((p,S,h)=>h.indexOf(p)===S)})),d.setState(g=>({activeChainIds:[...g.activeChainIds||[],...l].filter((p,S,h)=>h.indexOf(p)===S)})),u.setState({walletType:i,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:i}),d.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active");let f=l.map(g=>o.find(p=>p.chainId===g));return {accounts:d.getState().accounts,walletType:i,chains:f}}catch(n){throw console.error("connect ",n),d.getState().accounts===null&&d.setState({status:"disconnected"}),d.getState().accounts&&d.getState().activeChainIds&&d.setState({status:"connected"}),n}}),ie=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(V);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=d.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(d.setState(te),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(d.setState(r=>{var i;return {activeChainIds:(i=r.activeChainIds)==null?void 0:i.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var i;return {recentChainIds:(i=r.recentChainIds)==null?void 0:i.filter(s=>!t.includes(s))}}));}else d.setState(te),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},q=e=>c(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:o}=u.getState();try{let i=K(n||void 0);if(t&&i&&n)return yield H({chainId:t,walletType:n,autoReconnect:o})}catch(i){(r=e==null?void 0:e.onError)==null||r.call(e,i),ie();}}),ft=e=>c(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!K(n))throw new Error(`${n} is not available`);let r=R(n),i=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:i,offlineSignerAmino:s,offlineSignerAuto:a}});var ke=()=>{u.setState({recentChainIds:null});},pr=()=>u.getState().recentChainIds,mr=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(o=>t.find(r=>r.chainId===o)))!=null?n:null},dr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},fr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},ve=n=>c(void 0,[n],function*({chainInfo:e,walletType:t}){let o=R(t);return t==="capsule"?yield H({chainId:e.chainId,walletType:t}):yield o.experimentalSuggestChain(e),e}),gt=e=>c(void 0,null,function*(){var o;let t=u.getState().walletType;return yield ve({chainInfo:e.chainInfo,walletType:(o=e.walletType)!=null?o:t}),yield H({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var yt=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 St=s=>c(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:o,fee:r,memo:i}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,o,r,i)}),Ct=I=>c(void 0,[I],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:o,sourcePort:r,sourceChannel:i,timeoutHeight:s,timeoutTimestamp:a,fee:l,memo:m}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,o,r,i,s,a,l,m)}),ht=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:o,options:r,label:i,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,i,o,r)}),wt=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:o,contractAddress:r,funds:i,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,o,s,i)}),At=(e,t,n)=>c(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),It=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let o=new TextEncoder().encode(t);return n.queryContractRaw(e,o)};var Er=e=>e,br=e=>e;var Se=e=>e?Object.keys(e).length===0:!0;var We=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Ot=e=>globalThis.DOMException===void 0?new We(e):new DOMException(e),Et=e=>{let t=e.reason===void 0?Ot("This operation was aborted."):e.reason;return t instanceof Error?t:Ot(t)};function Pe(i,s){return c(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:o=!0,signal:r}={}){return new Promise((a,l)=>{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(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let m=[],I=[],f=new Map,C=!1,g=!1,p=!1,S=0,h=0,O=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),y=T=>{C=!0,g=!0,l(T);};r&&(r.aborted&&y(Et(r)),r.addEventListener("abort",()=>{y(Et(r));}));let A=()=>c(this,null,function*(){if(g)return;let T=yield O.next(),P=h;if(h++,T.done){if(p=!0,S===0&&!g){if(!o&&I.length>0){y(new AggregateError(I));return}if(g=!0,f.size===0){a(m);return}let D=[];for(let[_,X]of m.entries())f.get(_)!==bt&&D.push(X);a(D);}return}S++,c(this,null,function*(){try{let D=yield T.value;if(g)return;let _=yield t(D,P);_===bt&&f.set(P,_),m[P]=_,S--,yield A();}catch(D){if(o)y(D);else {I.push(D),S--;try{yield A();}catch(_){y(_);}}}});});c(this,null,function*(){for(let T=0;T<n;T++){try{yield A();}catch(P){y(P);break}if(p||C)break}});})})}var bt=Symbol("skip");var B=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let o=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!o):return o.map(r=>n.find(i=>i.chainId===r)).filter(Boolean);case(!t&&!!o):return [o.map(r=>n.find(i=>i.chainId===r)).filter(Boolean)[0]];case(!!t&&!o):return n;default:return [n[0]]}},G=(e,t,n)=>c(void 0,null,function*(){let o=u.getState().multiChainFetchConcurrency;if(e){let i=yield Pe(t,n,{concurrency:o});return Object.fromEntries(i.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),Tt=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((i,s)=>[t[s].chainId,i]))}return n(t[0])};var _e=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,s=>c(void 0,null,function*(){var I;let a=(I=u.getState().chainsConfig)==null?void 0:I[s.chainId],l={url:s.rpc,headers:x({},(a==null?void 0:a.rpcHeaders)||{})};return yield stargate.StargateClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ne=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,s=>c(void 0,null,function*(){var I;let a=(I=u.getState().chainsConfig)==null?void 0:I[s.chainId],l={url:s.rpc,headers:x({},(a==null?void 0:a.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ce=({type:e,chainId:t,multiChain:n,enabled:o})=>{let r=B({chainId:t,multiChain:n}),i=react.useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return reactQuery.useQuery({queryKey:i,queryFn:l=>c(void 0,[l],function*({queryKey:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield G(!!n,a,I=>c(void 0,null,function*(){var S;let f=(S=u.getState().chainsConfig)==null?void 0:S[I.chainId],C={url:I.rpc,headers:x({},(f==null?void 0:f.rpcHeaders)||{})};return yield (s==="tm37"?tendermintRpc.Tendermint37Client:tendermintRpc.Tendermint34Client).connect(C)}))}),enabled:!!r&&r.length>0&&(o!==void 0?!!o:!0),refetchOnWindowFocus:!1})};var Jr=()=>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),he=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return reactQuery.useQuery(n,({queryKey:[,r]})=>K(r))};var Y=e=>{let t=u(a=>a.walletType),n=d(a=>a.activeChainIds),o=B({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=d(a=>a.accounts),i=d(a=>a.status);return react.useEffect(()=>d.subscribe(a=>a.status,(a,l)=>{var m,I,f;if(a==="connected"){let{accounts:C,activeChainIds:g}=d.getState(),{chains:p}=u.getState(),{walletType:S}=u.getState();if(!C||!g||!p)return (m=e==null?void 0:e.onDisconnect)==null?void 0:m.call(e);(I=e==null?void 0:e.onConnect)==null||I.call(e,{accounts:C,chains:g.map(h=>p.find(O=>O.chainId===h)),walletType:S,isReconnect:l==="reconnecting"});}a==="disconnected"&&((f=e==null?void 0:e.onDisconnect)==null||f.call(e));}),[e]),{data:react.useMemo(()=>r?Tt(!!(e!=null&&e.multiChain),o,a=>r[a.chainId]):void 0,[r,o,e==null?void 0:e.multiChain]),isConnected:i==="connected",isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",isLoading:i==="connecting"||i==="reconnecting",walletType:i==="connected"?t:void 0,reconnect:q,status:i}},An=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),o=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=_e({chainId:t.map(s=>s.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!o}),i=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(i,m=>c(void 0,[m],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,f=>c(void 0,null,function*(){let C=s==null?void 0:s[f.chainId];if(!C)throw new Error(`Client is not ready ${f.chainId}`);return yield C.getAllBalances(encoding.toBech32(f.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(l).data))}))}),{enabled:!!o&&!!t&&t.length>0&&!Se(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},ps=e=>{let t=B({chainId:e.chainId}),{data:n}=Y({chainId:e.chainId}),o=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:i}=An({chainId:t.map(l=>l.chainId),bech32Address:o,enabled:!!o&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,o,e.chainId],a=reactQuery.useQuery(s,({queryKey:[,l,m]})=>m==null?void 0:m.find(I=>I.denom===l),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return F(x({},a),{refetch:l=>c(void 0,null,function*(){return yield i(),a.refetch(l)})})},ms=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_CONNECT",e,t,n],H,{onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=he();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status}},ds=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_DISCONNECT",e,t,n],ie,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:i=>r.mutate(i),disconnectAsync:i=>r.mutateAsync(i),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},fs=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),o=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return reactQuery.useQuery({queryKey:o,queryFn:s=>c(void 0,[s],function*({queryKey:[,r,i]}){if(r.length<1)throw new Error("No chain found");if(!K(i))throw new Error(`${i} is not available`);return yield G(!!(e!=null&&e.multiChain),r,m=>c(void 0,null,function*(){return yield ft({chainId:m.chainId,walletType:i})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},gs=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),{data:o}=_e({chainId:t.map(s=>s.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),i=react.useMemo(()=>["USE_BALANCE_STAKED",o,t,r],[t,r,o]);return reactQuery.useQuery(i,m=>c(void 0,[m],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,f=>c(void 0,null,function*(){var g;if(!s)throw new Error("Client is not ready");return yield (g=s[f.chainId])==null?void 0:g.getBalanceStaked(encoding.toBech32(f.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(l).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!o,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Is=()=>{let e=u(o=>o.capsuleState),t=d(o=>o.capsuleClient),n=ae();return {setModalState:o=>{u.setState(r=>{var i;return {capsuleState:{showModal:o,chainId:(i=r.capsuleState)==null?void 0:i.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{ie();}}};var ks=()=>d(e=>e.activeChainIds),In=()=>{var e;return (e=d(t=>t.activeChainIds))==null?void 0:e.map(t=>{var o;let n=(o=u.getState().chains)==null?void 0:o.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},vs=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Ws=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Ps=({denom:e})=>{let t=In();return reactQuery.useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var i;return (i=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:i.currencies.find(s=>s)})},Rs=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery(n,a=>c(void 0,[a],function*({queryKey:[,i,s]}){if(!i)throw new Error("Query client is not defined");return yield i.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},Ds=()=>({data:u(t=>t.recentChainIds),clear:ke}),_s=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let o=(r=u.getState().chains)==null?void 0:r.find(i=>i.chainId===n);if(o)return o}).filter(Boolean),clear:ke}},Ns=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN",e,t,n],ve,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s.chainInfo)),onMutate:i=>t==null?void 0:t(i.chainInfo),onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Ks=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],gt,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=he();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Qs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=Y(),r=o==null?void 0:o.bech32Address,i=reactQuery.useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>St(x({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendTokens:i.mutate,sendTokensAsync:i.mutateAsync,status:i.status}},js=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=Y(),r=o==null?void 0:o.bech32Address,i=reactQuery.useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>Ct(x({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendIbcTokens:i.mutate,sendIbcTokensAsync:i.mutateAsync,status:i.status}},$s=({codeId:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=Y(),i=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_INSTANTIATE_CONTRACT",t,n,o,e,i],l=>{var I;if(!i)throw new Error("senderAddress is undefined");let m=F(x({},l),{fee:(I=l.fee)!=null?I:"auto",senderAddress:i,codeId:e});return ht(m)},{onError:(l,m)=>Promise.resolve(t==null?void 0:t(l,m)),onMutate:n,onSuccess:l=>Promise.resolve(o==null?void 0:o(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Vs=({contractAddress:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=Y(),i=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_EXECUTE_CONTRACT",t,n,o,e,i],l=>{var I,f,C;if(!i)throw new Error("senderAddress is undefined");let m=F(x({},l),{fee:(I=l.fee)!=null?I:"auto",senderAddress:i,contractAddress:e,memo:(f=l.memo)!=null?f:"",funds:(C=l.funds)!=null?C:[]});return wt(m)},{onError:(l,m)=>Promise.resolve(t==null?void 0:t(l,m)),onMutate:n,onSuccess:l=>Promise.resolve(o==null?void 0:o(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},Hs=e=>{let{data:t}=Ne();return reactQuery.useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,o]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return At(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Ys=e=>{let{data:t}=Ne(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return It(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function la(e){let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=d(i=>i.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,m=>c(this,null,function*(){var S,h;if(!(o!=null&&o.includes(m.chainId)))return null;if(!K(s))throw new Error(`${s} is not available`);let f=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(m.chainId);default:return R(s).getOfflineSignerAuto(m.chainId)}}))(),C=(S=u.getState().chainsConfig)==null?void 0:S[m.chainId],g={url:m.rpc,headers:x({},(C==null?void 0:C.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(g,f,e!=null&&e.multiChain?(h=e.opts)==null?void 0:h[m.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ua(e){let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=d(i=>i.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,m=>c(this,null,function*(){var h,O;if(!(o!=null&&o.includes(m.chainId)))return null;if(!K(s))throw new Error(`${s} is not available`);let f=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(m.chainId);default:return R(s).getOfflineSignerAuto(m.chainId)}}))(),C=(h=u.getState().chainsConfig)==null?void 0:h[m.chainId],g={url:m.rpc,headers:x({},(C==null?void 0:C.rpcHeaders)||{})},p=C!=null&&C.gas?stargate.GasPrice.fromString(`${C.gas.price}${C.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(g,f,x({gasPrice:p},e!=null&&e.multiChain?(O=e.opts)==null?void 0:O[m.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function pa(e){let t=B({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),o=d(s=>s.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]),{data:i}=Ce({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:l=>c(this,[l],function*({queryKey:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,s,I=>c(this,null,function*(){var S;if(!(o!=null&&o.includes(I.chainId)))return null;if(!K(a))throw new Error(`${a} is not available`);if(!i)throw new Error("No tendermint client found");let C=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(I.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(I.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(I.chainId);default:return R(a).getOfflineSignerAuto(I.chainId)}}))(),g=e.multiChain?i[I.chainId]:i;return yield stargate.SigningStargateClient.createWithSigner(g,C,e.multiChain?(S=e.opts)==null?void 0:S[I.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!i&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ma(e){let t=B({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),o=d(a=>a.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]),{data:i}=Ce({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:s}=Ce({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:m=>c(this,[m],function*({queryKey:[,a,l]}){if(a.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,a,f=>c(this,null,function*(){var y,A;if(!(o!=null&&o.includes(f.chainId)))return null;if(!K(l))throw new Error(`${l} is not available`);let g=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(l).getOfflineSigner(f.chainId);case"offlineSignerAuto":return R(l).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return R(l).getOfflineSignerOnlyAmino(f.chainId);default:return R(l).getOfflineSignerAuto(f.chainId)}}))(),p=(y=u.getState().chainsConfig)==null?void 0:y[f.chainId],S=p!=null&&p.gas?stargate.GasPrice.fromString(`${p.gas.price}${p.gas.denom}`):void 0,h=e.multiChain?s==null?void 0:s[f.chainId]:i;if(!h)throw new Error("No tendermint client found");return yield cosmwasmStargate.SigningCosmWasmClient.createWithSigner(h,g,x({gasPrice:S},e.multiChain?(A=e.opts)==null?void 0:A[f.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!i||!Se(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Nt=({children:e})=>{let[t,n]=react.useState(!1);return react.useEffect(()=>{n(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var xn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(V)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:o,iframeOptions:r,chains:i}=u(),{activeChainIds:s,wcSignClients:a}=d(),l=K(o||void 0);return react.useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!i)return;new cosmiframe.Cosmiframe(r.allowedIframeParentOrigins).isReady().then(I=>{if(I)return H({chainId:i.map(f=>f.chainId),walletType:"cosmiframe"})});},[r]),react.useEffect(()=>{if(o){if(!l)return;e&&s?q({onError:n}):!e&&t&&q({onError:n});}},[l]),react.useEffect(()=>{var m,I,f,C,g,p,S,h,O,y,A,T,P,D,_,X,ne,w;if(o){if(!l)return;o==="cosmostation"&&((I=(m=ue()).subscription)==null||I.call(m,()=>{q({onError:n});})),o==="keplr"&&((C=(f=pe()).subscription)==null||C.call(f,()=>{q({onError:n});})),o==="leap"&&((p=(g=me()).subscription)==null||p.call(g,()=>{q({onError:n});})),o==="compass"&&((h=(S=ce()).subscription)==null||h.call(S,()=>{q({onError:n});})),o==="vectis"&&((y=(O=ge()).subscription)==null||y.call(O,()=>{q({onError:n});})),o==="walletconnect"&&a.has("walletconnect")&&((T=(A=Q()).subscription)==null||T.call(A,()=>{q({onError:n});})),o==="station"&&((D=(P=fe()).subscription)==null||D.call(P,()=>{q({onError:n});})),o==="xdefi"&&((X=(_=ye()).subscription)==null||X.call(_,()=>{q({onError:n});})),o==="cosmiframe"&&((w=(ne=le()).subscription)==null||w.call(ne,()=>{q({onError:n});}));}},[o,a,l]),null},Kt=()=>(xn(),null);var Wn=new reactQuery.QueryClient({}),Fa=o=>{var r=o,{children:e,grazOptions:t}=r,n=Qe(r,["children","grazOptions"]);return yt(t),jsxRuntime.jsxs(reactQuery.QueryClientProvider,F(x({client:Wn},n),{children:[e,jsxRuntime.jsx(Nt,{children:jsxRuntime.jsx(Kt,{})})]}),"graz-provider")};
24
+ var Ft=Object.defineProperty,qt=Object.defineProperties;var Gt=Object.getOwnPropertyDescriptors;var se=Object.getOwnPropertySymbols;var Ge=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable;var qe=(e,t,n)=>t in e?Ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,x=(e,t)=>{for(var n in t||(t={}))Ge.call(t,n)&&qe(e,n,t[n]);if(se)for(var n of se(t))ze.call(t,n)&&qe(e,n,t[n]);return e},F=(e,t)=>qt(e,Gt(t));var Qe=(e,t)=>{var n={};for(var o in e)Ge.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&se)for(var o of se(e))t.indexOf(o)<0&&ze.call(e,o)&&(n[o]=e[o]);return n};var c=(e,t,n)=>new Promise((o,r)=>{var i=l=>{try{a(n.next(l));}catch(m){r(m);}},s=l=>{try{a(n.throw(l));}catch(m){r(m);}},a=l=>l.done?o(l.value):Promise.resolve(l.value).then(i,s);a((n=n.apply(e,t)).next());});var V="graz-reconnect-session";var je=(O=>(O.KEPLR="keplr",O.LEAP="leap",O.VECTIS="vectis",O.COSMOSTATION="cosmostation",O.WALLETCONNECT="walletconnect",O.WC_KEPLR_MOBILE="wc_keplr_mobile",O.WC_LEAP_MOBILE="wc_leap_mobile",O.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",O.WC_CLOT_MOBILE="wc_clot_mobile",O.METAMASK_SNAP_LEAP="metamask_snap_leap",O.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",O.STATION="station",O.XDEFI="xdefi",O.CAPSULE="capsule",O.COSMIFRAME="cosmiframe",O.COMPASS="compass",O.INITIA="initia",O))(je||{}),$e=["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"];var Qt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,web3Modal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},te={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},jt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},$t={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},d=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>te,jt))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>Qt,$t)));var ae=()=>{var C,g;if(!((C=u.getState().capsuleConfig)!=null&&C.apiKey)||!((g=u.getState().capsuleConfig)!=null&&g.env))throw new Error("Capsule configuration is not set");let e=()=>c(void 0,null,function*(){var h,O;let p=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,S=new p({apiKey:(h=u.getState().capsuleConfig)==null?void 0:h.apiKey,env:(O=u.getState().capsuleConfig)==null?void 0:O.env});return d.setState({capsuleClient:S}),S});return {init:e,enable:p=>c(void 0,null,function*(){let S=typeof p=="string"?[p]:p,h=d.getState().capsuleClient;h||(h=yield e()),u.setState({capsuleState:{showModal:!0,chainId:S}});}),onAfterLoginSuccessful:()=>c(void 0,null,function*(){var y;let p=d.getState().capsuleClient,{chains:S}=u.getState();if(!p)throw new Error("Capsule client is not initialized");if(!S)throw new Error("Chains are not set");yield p.enable();let h=(y=u.getState().capsuleState)==null?void 0:y.chainId;if(!h)throw new Error("Chain ids are not set");let O=Object.fromEntries(yield Promise.all(h.map(A=>c(void 0,null,function*(){let T=yield p.getAccount(A);return [A,{address:encoding.fromBech32(T.address).data,bech32Address:T.address,algo:T.algo,name:T.username||"",pubKey:T.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));d.setState(A=>({accounts:x(x({},A.accounts||{}),O)})),u.setState(A=>({recentChainIds:[...A.recentChainIds||[],...h].filter((T,P,D)=>D.indexOf(T)===P)})),d.setState(A=>({activeChainIds:[...A.activeChainIds||[],...h].filter((T,P,D)=>D.indexOf(T)===P)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),d.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active"),u.setState({capsuleState:null});}),getKey:p=>c(void 0,null,function*(){let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");let h=yield S.getAccount(p);return {address:encoding.fromBech32(h.address).data,bech32Address:h.address,algo:h.algo,name:h.username||"",pubKey:h.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:p=>c(void 0,null,function*(){let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(p)}),getOfflineSignerDirect:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(p)},signDirect:(...p)=>c(void 0,null,function*(){let[S,h,O]=p,y=d.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.signDirect(S,h,{bodyBytes:O.bodyBytes,authInfoBytes:O.authInfoBytes,chainId:O.chainId,accountNumber:O.accountNumber})}),signAmino:(...p)=>c(void 0,null,function*(){let[S,h,O,y]=p,A=d.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");return A.signAmino(S,h,O,y)}),signArbitrary:(p,S,h)=>c(void 0,null,function*(){let O=d.getState().capsuleClient;if(!O)throw new Error("Capsule client is not initialized");let y=yield O.getAccount(p);if(!y)throw new Error(`Wallet not connected to account ${S}`);let A=(()=>{switch(y.algo){case"secp256k1":return amino.encodeSecp256k1Pubkey(y.pubkey);case"ed25519":return amino.encodeEd25519Pubkey(y.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield O.signArbitrary(p,S,h),pub_key:{type:y.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:A.value}}}),experimentalSuggestChain:(...p)=>c(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSigner(p)},getOfflineSignerAmino:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerAmino(p)}}};var ce=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let i=()=>{N(),r();};return window.addEventListener("leap_keystorechange",i),()=>{window.removeEventListener("leap_keystorechange",i);}},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 tt={},nt=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>c(void 0,null,function*(){var I;let i=yield e.request({method:"web3_clientVersion"});if(!i.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=(I=i.split("MetaMask/v")[1])==null?void 0:I.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:i=>c(void 0,null,function*(){(yield snapper.isSnapInstalled())||(yield snapper.installSnap());}),getOfflineSigner:i=>t.getOfflineSigner(i),experimentalSuggestChain:i=>c(void 0,null,function*(){yield t.experimentalSuggestChain(i);}),signAmino:(i,s,a)=>c(void 0,null,function*(){return t.signAmino(i,s,a)}),getKey:i=>c(void 0,null,function*(){return typeof tt[i]!="undefined"?tt[i]:t.getKey(i)}),getOfflineSignerAuto:i=>c(void 0,null,function*(){return (yield t.getKey(i)).isNanoLedger?t.getOfflineSignerOnlyAmino(i):t.getOfflineSigner(i)}),getOfflineSignerOnlyAmino:i=>t.getOfflineSignerOnlyAmino(i),signDirect:(i,s,a)=>c(void 0,null,function*(){return t.signDirect(i,s,a)}),signArbitrary:(i,s,a)=>c(void 0,null,function*(){return t.signArbitrary(i,s,a)}),disable:i=>c(void 0,null,function*(){i&&(yield t.deleteChain(i));})};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:i=>{let s=()=>{N(),i();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:i=>{t.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var on=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:o,accountNumber:r}=e;if(!t||!n||!o||!r)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:o,accountNumber:r}},rn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,ot=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>c(void 0,null,function*(){yield e.getAddress();}),getKey:f=>c(void 0,null,function*(){let C=e.getOfflineSigner(f),[g]=yield C.getAccounts();if(!g)throw new Error("Wallet connection failed");let p=(()=>{switch(g.algo){case"secp256k1":return amino.rawSecp256k1PubkeyToRawAddress(g.pubkey);case"ed25519":return amino.rawEd25519PubkeyToRawAddress(g.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:rn(g.address),algo:g.algo,pubKey:g.pubkey,bech32Address:g.address,address:p,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:f=>{let C=e.getOfflineSigner(f),g=e.getOfflineSignerOnlyAmino(f);return {getAccounts:C.getAccounts.bind(C),signDirect:C.signDirect.bind(C),signAmino:g.signAmino.bind(g)}},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(C=>{var g,p,S;return {denom:C.coinDenom,amount:C.coinMinimalDenom,low_gas_price:(g=C.gasPriceStep)==null?void 0:g.low,average_gas_price:(p=C.gasPriceStep)==null?void 0:p.average,high_gas_price:(S=C.gasPriceStep)==null?void 0:S.high}})},apis:{rpc:[{address:f.rpc}],rest:[{address:f.rest}]}}),signDirect:(...f)=>{let[C,g,p]=f;return e.getOfflineSigner(C).signDirect(g,on(p))},signAmino:(...f)=>{let[C,g,p]=f;return e.getOfflineSignerOnlyAmino(C).signAmino(g,p)},signArbitrary:(f,C,g)=>c(void 0,null,function*(){let h=(yield e.getOfflineSigner(f).getAccounts()).find(A=>A.address===C);if(!h)throw new Error(`Wallet not connected to account ${C}`);let O=(()=>{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(g),pub_key:{type:h.algo==="secp256k1"?amino.pubkeyType.secp256k1:amino.pubkeyType.ed25519,value:O.value}}}),subscription:f=>{let C=()=>{N(),f();};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 i=()=>{N(),r();};return window.addEventListener("keplr_keystorechange",i),()=>{window.removeEventListener("keplr_keystorechange",i);}},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 i=()=>{N(),r();};return window.addEventListener("leap_keystorechange",i),()=>{window.removeEventListener("leap_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var de={},rt=e=>{let t=window.ethereum;if(t&&e){let n=()=>c(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),o=y=>c(void 0,null,function*(){try{let A=yield n();return Object.values(A).find(T=>T.id===e.id&&(!y||T.version===y))}catch(A){return}}),r=()=>c(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),i=()=>c(void 0,null,function*(){var _;let y=yield t.request({method:"web3_clientVersion"});if(!y.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 T=(_=y.split("MetaMask/v")[1])==null?void 0:_.split(".")[0];if(!(Number(T)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield o())||(yield r()),!0}),s=y=>c(void 0,null,function*(){(yield o())||(yield r());}),a=(y,A,T)=>c(void 0,null,function*(){let P=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:y,signerAddress:A,signDoc:T}}}}),D=T.accountNumber,_=new sn__default.default(D.low,D.high,D.unsigned);return {signature:P.signature,signed:F(x({},P.signed),{accountNumber:`${_.toString()}`,authInfoBytes:new Uint8Array(Object.values(P.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(P.signed.bodyBytes))})}}),l=(y,A,T)=>c(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:y,signerAddress:A,signDoc:T}}}})}),m=y=>c(void 0,null,function*(){if(typeof de[y]!="undefined")return de[y];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:y}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,de[y]=A,de[y]}),I=y=>c(void 0,null,function*(){let A=yield m(y);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),f=(...y)=>c(void 0,null,function*(){let[A,T,P,D]=y;return yield l(A,T,P)}),C=(...y)=>c(void 0,null,function*(){let[A,T,P]=y;return yield a(A,T,P)}),p=y=>({getAccounts:()=>c(void 0,null,function*(){return [yield I(y)]}),signAmino:(A,T)=>f(y,A,T)});return {enable:s,experimentalSuggestChain:(...y)=>c(void 0,null,function*(){yield i(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:y[0]}}}});}),getKey:m,getOfflineSigner:y=>({getAccounts:()=>c(void 0,null,function*(){return [yield I(y)]}),signDirect:(A,T)=>C(y,A,T),signAmino:(A,T)=>f(y,A,T)}),getOfflineSignerAuto:y=>c(void 0,null,function*(){return p(y)}),getOfflineSignerOnlyAmino:p,init:i,signAmino:f,signDirect:C}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var st=()=>rt({id:"npm:@leapwallet/metamask-cosmos-snap"});var fe=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:i=>{let s=()=>{N(),i();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:i=>c(void 0,null,function*(){let s=yield e.getKey(i);return x({isKeystone:!1},s)}),getOfflineSigner:i=>{try{let s=e.getOfflineSignerOnlyAmino(i);return Object.assign(s,{signDirect:(m,I)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:i=>c(void 0,null,function*(){try{let s=Object.assign(i,{chainSymbolImageUrl:i.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:i.stakeCurrency.coinDecimals,coinDenom:i.stakeCurrency.coinDenom,coinImageUrl:i.stakeCurrency.coinImageUrl||"",coinMinimalDenom:i.stakeCurrency.coinMinimalDenom},currencies:i.currencies.map(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:i.feeCurrencies.map(a=>{var l,m,I;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((l=a.gasPriceStep)==null?void 0:l.average)||0,high:((m=a.gasPriceStep)==null?void 0:m.high)||0,low:((I=a.gasPriceStep)==null?void 0:I.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),enable:i=>e.enable(i),disable:i=>e.disable(i),getOfflineSignerAuto:i=>e.getOfflineSignerAuto(i),getOfflineSignerOnlyAmino:i=>e.getOfflineSignerOnlyAmino(i),signDirect:()=>e.signDirect(),signAmino:(i,s,a,l)=>e.signAmino(i,s,a)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var ge=()=>{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=>c(void 0,null,function*(){let l=yield e.getKey(a);return {address:encoding.fromBech32(l.address).data,algo:l.algo,bech32Address:l.address,name:l.name,pubKey:l.pubKey,isKeystone:!1,isNanoLedger:l.isNanoLedger}}),subscription:a=>{let l=()=>{N(),a();};return window.addEventListener("vectis_accountChanged",l),()=>{window.removeEventListener("vectis_accountChanged",l);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>c(void 0,null,function*(){let[l]=a,m=F(x({},l),{rpcUrl:l.rpc,restUrl:l.rest,prettyName:l.chainName.replace(" ",""),bech32Prefix:l.bech32Config.bech32PrefixAccAddr});return e.suggestChains([m])}),signDirect:(...a)=>c(void 0,null,function*(){var I;let{1:l,2:m}=a;return e.signDirect(l,{bodyBytes:m.bodyBytes||Uint8Array.from([]),authInfoBytes:m.authInfoBytes||Uint8Array.from([]),accountNumber:sn__default.default.fromString(((I=m.accountNumber)==null?void 0:I.toString())||"",!1),chainId:m.chainId||""})}),signAmino:(...a)=>c(void 0,null,function*(){let{1:l,2:m}=a;return e.signAmino(l,m)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var z=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,at=()=>z()&&navigator.userAgent.toLowerCase().includes("android"),ct=()=>z()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Me=(e,t,n=new Error("Promise timed out"))=>{let o=new Promise((r,i)=>{setTimeout(()=>{i(n);},t);});return Promise.race([e,o])};var Q=e=>{var _,X,ne;if(!((ne=(X=(_=u.getState().walletConnect)==null?void 0:_.options)==null?void 0:X.projectId)!=null&&ne.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",o=w=>{if(!e)return;let{appUrl:E,formatNativeUrl:b}=e;if(z()){if(at())if(!w)window.open(E.mobile.android,"_self","noreferrer noopener");else {let k=b(E.mobile.android,w,"android");window.open(k,"_self","noreferrer noopener");}if(ct())if(!w)window.open(E.mobile.ios,"_self","noreferrer noopener");else {let k=b(E.mobile.ios,w,"ios");window.open(k,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:w}=d.getState();if(!w.get(t))throw new Error("walletConnect.signClient is not defined");w.delete(t),d.setState({wcSignClients:w}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},i=w=>c(void 0,null,function*(){let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");if(!w)throw new Error("No wallet connect session");yield b.disconnect({topic:w,reason:utils.getSdkError("USER_DISCONNECTED")}),yield l(b);}),s=w=>{try{let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");let k=b.session.getAll().at(-1);if(!k)return;if(!(k.expiry*1e3>Date.now()+1e3))throw i(k.topic),new Error("invalid session");try{let v=b.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:w.map(L=>`cosmos:${L}`),events:["chainChanged","accountsChanged"]}}});if(!v.length)throw new Error("no session");return v.at(-1)}catch(v){if(!v.message.toLowerCase().includes("no matching key"))throw v}return k}catch(E){if(!E.message.toLowerCase().includes("no matching key"))throw E}},a=w=>{try{return s(w)}catch(E){return}},l=w=>c(void 0,null,function*(){try{let E=w.core.pairing.pairings.getAll({active:!1});if(!E.length)return;yield Promise.all(E.map(b=>c(void 0,null,function*(){yield w.core.pairing.pairings.delete(b.topic,{code:7001,message:"clear pairing"});})));}catch(E){if(!E.message.toLowerCase().includes("no matching key"))throw E}}),m=()=>c(void 0,null,function*(){let{walletConnect:w}=u.getState();if(!(w!=null&&w.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:E}=d.getState(),b=E.get(t);if(b)return b;let k=yield signClient.SignClient.init(w.options);return E.set(t,k),d.setState({wcSignClients:E}),k}),I=w=>{let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)return ()=>{};let k=W=>{let v=d.getState().accounts;if(W.params.event.name==="accountsChanged"&&v&&!Object.values(v).map(L=>L.bech32Address).includes(W.params.event.data[0])){let L=W.params.chainId.split(":")[1];L&&f([L]);}else w();};return b.events.on("session_delete",r),b.events.on("session_expire",r),b.events.on("session_event",k),()=>{b.events.off("session_delete",r),b.events.off("session_expire",r),b.events.off("session_event",k);}},f=w=>c(void 0,null,function*(){var oe;let E=typeof w=="string"?[w]:w,{wcSignClients:b}=d.getState(),k=b.get(t);if(!k)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:W,chains:v}=u.getState();if(!((oe=W==null?void 0:W.options)!=null&&oe.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:L}=yield import('@web3modal/standalone'),$=new L(x({projectId:W.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},W.web3Modal)),J=a(E);if(!J){let{uri:U,approval:Z}=yield Me(k.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:E.map(j=>`cosmos:${j}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!U)throw new Error("No wallet connect uri");e?o(U):yield $.openModal({uri:U});let Lt=j=>c(void 0,null,function*(){return j.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((be,ee)=>{Z().then(Be=>{let Le=Be.sessionProperties;if(!Le)return ee(new Error("No session properties"));let Te=JSON.parse(String(Le.keys));if(Te.length===0)return ee(new Error("No accounts"));let Ue=Te[0];if(!Ue)return ee(new Error("No accounts"));let Fe={};return E.forEach(re=>{Fe[re]=F(x({},Ue),{bech32Address:encoding.toBech32(v.find(Ut=>Ut.chainId===re).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(Te[0].bech32Address).data)});}),d.setState(re=>({accounts:x(x({},re.accounts||{}),Fe)})),be(Be)}).catch(ee),j.addEventListener("abort",()=>{ee(new Error("User closed wallet connect"));},{once:!0});})});try{let j=new AbortController,be=j.signal;$.subscribeModal(ee=>{ee.open||j.abort();}),yield Lt(be);}catch(j){if($.closeModal(),!j.message.toLowerCase().includes("no matching key"))return Promise.reject(j)}return e||$.closeModal(),Promise.resolve()}try{yield Me((()=>c(void 0,null,function*(){let U=Object.fromEntries(yield Promise.all(E.map(Z=>c(void 0,null,function*(){return [Z,yield g(Z)]}))));d.setState({accounts:U});}))(),15e3,new Error("Connection timeout"));}catch(U){if(i(J.topic),!U.message.toLowerCase().includes("no matching key"))throw U}}),C=w=>c(void 0,null,function*(){var v;let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");let k=(v=s([w]))==null?void 0:v.topic;if(!k)throw new Error("No wallet connect session");let W=yield b.request({topic:k,chainId:`cosmos:${w}`,request:{method:"cosmos_getAccounts",params:{}}});if(!W[0])throw new Error("No wallet connect account");return {address:W[0].address,algo:W[0].algo,pubkey:new Uint8Array(Buffer.from(W[0].pubkey,n))}}),g=w=>c(void 0,null,function*(){let E=s([w]);if(!(E!=null&&E.topic))throw new Error("No wallet connect session");let b=E.sessionProperties&&JSON.parse(String(E.sessionProperties.keys))[0];if(!b)throw new Error("No wallet connect key");return b}),p=(...w)=>c(void 0,null,function*(){var U,Z;let[E,b,k]=w,{accounts:W,wcSignClients:v}=d.getState(),L=v.get(t);if(!L)throw new Error("walletConnect.signClient is not defined");if(!W)throw new Error("account is not defined");let $=(U=s([E]))==null?void 0:U.topic;if(!$)throw new Error("No wallet connect session");if(!k.bodyBytes)throw new Error("No bodyBytes");if(!k.authInfoBytes)throw new Error("No authInfoBytes");let J={topic:$,chainId:`cosmos:${E}`,request:{method:"cosmos_signDirect",params:{signerAddress:b,signDoc:F(x({},k),{bodyBytes:Buffer.from(k.bodyBytes).toString(n),authInfoBytes:Buffer.from(k.authInfoBytes).toString(n),accountNumber:(Z=k.accountNumber)==null?void 0:Z.toString()})}}};return o(),yield L.request(J)}),S=(...w)=>c(void 0,null,function*(){let[E,b,k]=w,{signature:W,signed:v}=yield p(E,b,k);return {signed:{chainId:v.chainId,accountNumber:sn__default.default.fromString(v.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(v.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(v.bodyBytes,n))},signature:W}}),h=(...w)=>c(void 0,null,function*(){var U;let[E,b,k,W]=w,{wcSignClients:v}=d.getState(),L=v.get(t),{accounts:$}=d.getState();if(!L)throw new Error("walletConnect.signClient is not defined");if(!$)throw new Error("account is not defined");let J=(U=s([E]))==null?void 0:U.topic;if(!J)throw new Error("No wallet connect session");return o(),yield L.request({topic:J,chainId:`cosmos:${E}`,request:{method:"cosmos_signDirect",params:{signerAddress:b,signDoc:k}}})}),O=(...w)=>c(void 0,null,function*(){let[E,b,k,W]=w;return yield h(E,b,k)}),y=w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signDirect:(E,b)=>S(w,E,b)}),A=w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signAmino:(E,b)=>O(w,E,b)});return {enable:f,disable:w=>c(void 0,null,function*(){var k;let{wcSignClients:E}=d.getState(),b=E.get(t);if(w===void 0){let W=b==null?void 0:b.session.getAll();W!==void 0&&(yield Promise.all(W.map(v=>i(v.topic))));}else typeof w=="string"?yield i((k=s([w]))==null?void 0:k.topic):yield Promise.all(w.map(W=>{var v;return i((v=s([W]))==null?void 0:v.topic)}));(b==null?void 0:b.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...w)=>c(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:g,getOfflineSigner:w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signDirect:(E,b)=>S(w,E,b),signAmino:(E,b)=>O(w,E,b)}),getOfflineSignerAuto:w=>c(void 0,null,function*(){return (yield g(w)).isNanoLedger?A(w):y(w)}),getOfflineSignerOnlyAmino:A,signAmino:O,signDirect:S,subscription:I,init:m}};var lt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())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,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;default:return `${a}://wc?uri=${l}`}}};return Q(e)};var ut=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())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,i,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${i}`};return Q(e)};var pt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())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,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return Q(e)};var mt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!z())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,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return Q(e)};var ye=()=>{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 i=()=>{N(),r();};return window.addEventListener("keplr_keystorechange",i),()=>{window.removeEventListener("keplr_keystorechange",i);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var K=(e=u.getState().walletType)=>{try{return R(e),!0}catch(t){return !1}},N=()=>{window.sessionStorage.removeItem(V),d.setState(te);},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 ge();case"walletconnect":return Q();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 st();case"metamask_snap_cosmos":return nt();case"station":return fe();case"xdefi":return ye();case"capsule":return ae();case"cosmiframe":return le();case"compass":return ce();case"initia":return ot();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((o=t.setDefaultOptions)==null||o.call(t,n)),t},er=()=>Object.fromEntries($e.map(e=>[e,K(e)])),xe=e=>e==="capsule",dt=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var H=e=>c(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:o,walletType:r}=u.getState(),i=(e==null?void 0:e.walletType)||r;if(!K(i))throw new Error(`${i} is not available`);let a=R(i),l=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!l)throw new Error("No last known connected chain, connect action requires chain ids");let m=o==null?void 0:o.map(g=>g.chainId);l.forEach(g=>{if(!(m!=null&&m.includes(g)))throw new Error(`Chain ${g} is not provided in GrazProvider`)}),d.setState(g=>{let p=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!l;return g.activeChainIds&&l.filter(h=>{var O;return !((O=g.activeChainIds)!=null&&O.includes(h))}).length>0?{status:"connecting"}:p?{status:"reconnecting"}:{status:"connecting"}});let{accounts:I}=d.getState();if(yield (t=a.init)==null?void 0:t.call(a),xe(i)&&d.getState().capsuleClient&&Object.values(d.getState().accounts||[]).length>0){let g=l.map(h=>o.find(O=>O.chainId===h)),p=d.getState().accounts;d.setState({status:"connecting"});let S=Object.fromEntries(yield Promise.all(l.map(h=>c(void 0,null,function*(){return [h,yield a.getKey(h)]}))));return d.setState(h=>({accounts:x(x({},h.accounts||{}),S)})),u.setState(h=>({recentChainIds:[...h.recentChainIds||[],...l].filter((O,y,A)=>A.indexOf(O)===y)})),d.setState(h=>({activeChainIds:[...h.activeChainIds||[],...l].filter((O,y,A)=>A.indexOf(O)===y)})),d.setState({status:"connected"}),{accounts:p,walletType:i,chains:g}}if(yield a.enable(l),xe(i)){let g=l.map(S=>o.find(h=>h.chainId===S)),p=d.getState().accounts;return d.setState({status:"connecting"}),{accounts:p,walletType:i,chains:g}}if(!dt(i)){let g=Object.fromEntries(yield Promise.all(l.map(p=>c(void 0,null,function*(){return [p,yield a.getKey(p)]}))));d.setState(p=>({accounts:x(x({},p.accounts||{}),g)}));}u.setState(g=>({recentChainIds:[...g.recentChainIds||[],...l].filter((p,S,h)=>h.indexOf(p)===S)})),d.setState(g=>({activeChainIds:[...g.activeChainIds||[],...l].filter((p,S,h)=>h.indexOf(p)===S)})),u.setState({walletType:i,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:i}),d.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active");let f=l.map(g=>o.find(p=>p.chainId===g));return {accounts:d.getState().accounts,walletType:i,chains:f}}catch(n){throw console.error("connect ",n),d.getState().accounts===null&&d.setState({status:"disconnected"}),d.getState().accounts&&d.getState().activeChainIds&&d.setState({status:"connected"}),n}}),ie=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(V);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=d.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(d.setState(te),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(d.setState(r=>{var i;return {activeChainIds:(i=r.activeChainIds)==null?void 0:i.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var i;return {recentChainIds:(i=r.recentChainIds)==null?void 0:i.filter(s=>!t.includes(s))}}));}else d.setState(te),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},q=e=>c(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:o}=u.getState();try{let i=K(n||void 0);if(t&&i&&n)return yield H({chainId:t,walletType:n,autoReconnect:o})}catch(i){(r=e==null?void 0:e.onError)==null||r.call(e,i),ie();}}),ft=e=>c(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!K(n))throw new Error(`${n} is not available`);let r=R(n),i=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:i,offlineSignerAmino:s,offlineSignerAuto:a}});var ke=()=>{u.setState({recentChainIds:null});},mr=()=>u.getState().recentChainIds,dr=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(o=>t.find(r=>r.chainId===o)))!=null?n:null},fr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},gr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},ve=n=>c(void 0,[n],function*({chainInfo:e,walletType:t}){let o=R(t);return t==="capsule"?yield H({chainId:e.chainId,walletType:t}):yield o.experimentalSuggestChain(e),e}),gt=e=>c(void 0,null,function*(){var o;let t=u.getState().walletType;return yield ve({chainInfo:e.chainInfo,walletType:(o=e.walletType)!=null?o:t}),yield H({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var yt=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 St=s=>c(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:o,fee:r,memo:i}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,o,r,i)}),Ct=I=>c(void 0,[I],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:o,sourcePort:r,sourceChannel:i,timeoutHeight:s,timeoutTimestamp:a,fee:l,memo:m}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,o,r,i,s,a,l,m)}),ht=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:o,options:r,label:i,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,i,o,r)}),wt=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:o,contractAddress:r,funds:i,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,o,s,i)}),At=(e,t,n)=>c(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),It=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let o=new TextEncoder().encode(t);return n.queryContractRaw(e,o)};var br=e=>e,Tr=e=>e;var Se=e=>e?Object.keys(e).length===0:!0;var We=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Ot=e=>globalThis.DOMException===void 0?new We(e):new DOMException(e),Et=e=>{let t=e.reason===void 0?Ot("This operation was aborted."):e.reason;return t instanceof Error?t:Ot(t)};function Pe(i,s){return c(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:o=!0,signal:r}={}){return new Promise((a,l)=>{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(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let m=[],I=[],f=new Map,C=!1,g=!1,p=!1,S=0,h=0,O=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),y=T=>{C=!0,g=!0,l(T);};r&&(r.aborted&&y(Et(r)),r.addEventListener("abort",()=>{y(Et(r));}));let A=()=>c(this,null,function*(){if(g)return;let T=yield O.next(),P=h;if(h++,T.done){if(p=!0,S===0&&!g){if(!o&&I.length>0){y(new AggregateError(I));return}if(g=!0,f.size===0){a(m);return}let D=[];for(let[_,X]of m.entries())f.get(_)!==bt&&D.push(X);a(D);}return}S++,c(this,null,function*(){try{let D=yield T.value;if(g)return;let _=yield t(D,P);_===bt&&f.set(P,_),m[P]=_,S--,yield A();}catch(D){if(o)y(D);else {I.push(D),S--;try{yield A();}catch(_){y(_);}}}});});c(this,null,function*(){for(let T=0;T<n;T++){try{yield A();}catch(P){y(P);break}if(p||C)break}});})})}var bt=Symbol("skip");var B=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let o=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!o):return o.map(r=>n.find(i=>i.chainId===r)).filter(Boolean);case(!t&&!!o):return [o.map(r=>n.find(i=>i.chainId===r)).filter(Boolean)[0]];case(!!t&&!o):return n;default:return [n[0]]}},G=(e,t,n)=>c(void 0,null,function*(){let o=u.getState().multiChainFetchConcurrency;if(e){let i=yield Pe(t,n,{concurrency:o});return Object.fromEntries(i.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),Tt=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((i,s)=>[t[s].chainId,i]))}return n(t[0])};var _e=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,s=>c(void 0,null,function*(){var I;let a=(I=u.getState().chainsConfig)==null?void 0:I[s.chainId],l={url:s.rpc,headers:x({},(a==null?void 0:a.rpcHeaders)||{})};return yield stargate.StargateClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ne=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,s=>c(void 0,null,function*(){var I;let a=(I=u.getState().chainsConfig)==null?void 0:I[s.chainId],l={url:s.rpc,headers:x({},(a==null?void 0:a.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ce=({type:e,chainId:t,multiChain:n,enabled:o})=>{let r=B({chainId:t,multiChain:n}),i=react.useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return reactQuery.useQuery({queryKey:i,queryFn:l=>c(void 0,[l],function*({queryKey:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield G(!!n,a,I=>c(void 0,null,function*(){var S;let f=(S=u.getState().chainsConfig)==null?void 0:S[I.chainId],C={url:I.rpc,headers:x({},(f==null?void 0:f.rpcHeaders)||{})};return yield (s==="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),he=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return reactQuery.useQuery(n,({queryKey:[,r]})=>K(r))};var Y=e=>{let t=u(a=>a.walletType),n=d(a=>a.activeChainIds),o=B({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=d(a=>a.accounts),i=d(a=>a.status);return react.useEffect(()=>d.subscribe(a=>a.status,(a,l)=>{var m,I,f;if(a==="connected"){let{accounts:C,activeChainIds:g}=d.getState(),{chains:p}=u.getState(),{walletType:S}=u.getState();if(!C||!g||!p)return (m=e==null?void 0:e.onDisconnect)==null?void 0:m.call(e);(I=e==null?void 0:e.onConnect)==null||I.call(e,{accounts:C,chains:g.map(h=>p.find(O=>O.chainId===h)),walletType:S,isReconnect:l==="reconnecting"});}a==="disconnected"&&((f=e==null?void 0:e.onDisconnect)==null||f.call(e));}),[e]),{data:react.useMemo(()=>r?Tt(!!(e!=null&&e.multiChain),o,a=>r[a.chainId]):void 0,[r,o,e==null?void 0:e.multiChain]),isConnected:i==="connected",isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",isLoading:i==="connecting"||i==="reconnecting",walletType:i==="connected"?t:void 0,reconnect:q,status:i}},An=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),o=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=_e({chainId:t.map(s=>s.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!o}),i=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(i,m=>c(void 0,[m],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,f=>c(void 0,null,function*(){let C=s==null?void 0:s[f.chainId];if(!C)throw new Error(`Client is not ready ${f.chainId}`);return yield C.getAllBalances(encoding.toBech32(f.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(l).data))}))}),{enabled:!!o&&!!t&&t.length>0&&!Se(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},ms=e=>{let t=B({chainId:e.chainId}),{data:n}=Y({chainId:e.chainId}),o=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:i}=An({chainId:t.map(l=>l.chainId),bech32Address:o,enabled:!!o&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,o,e.chainId],a=reactQuery.useQuery(s,({queryKey:[,l,m]})=>m==null?void 0:m.find(I=>I.denom===l),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return F(x({},a),{refetch:l=>c(void 0,null,function*(){return yield i(),a.refetch(l)})})},ds=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_CONNECT",e,t,n],H,{onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=he();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status}},fs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_DISCONNECT",e,t,n],ie,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:i=>r.mutate(i),disconnectAsync:i=>r.mutateAsync(i),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},gs=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),o=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return reactQuery.useQuery({queryKey:o,queryFn:s=>c(void 0,[s],function*({queryKey:[,r,i]}){if(r.length<1)throw new Error("No chain found");if(!K(i))throw new Error(`${i} is not available`);return yield G(!!(e!=null&&e.multiChain),r,m=>c(void 0,null,function*(){return yield ft({chainId:m.chainId,walletType:i})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},ys=e=>{let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),{data:o}=_e({chainId:t.map(s=>s.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),i=react.useMemo(()=>["USE_BALANCE_STAKED",o,t,r],[t,r,o]);return reactQuery.useQuery(i,m=>c(void 0,[m],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,f=>c(void 0,null,function*(){var g;if(!s)throw new Error("Client is not ready");return yield (g=s[f.chainId])==null?void 0:g.getBalanceStaked(encoding.toBech32(f.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(l).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!o,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Os=()=>{let e=u(o=>o.capsuleState),t=d(o=>o.capsuleClient),n=ae();return {setModalState:o=>{u.setState(r=>{var i;return {capsuleState:{showModal:o,chainId:(i=r.capsuleState)==null?void 0:i.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{ie();}}};var vs=()=>d(e=>e.activeChainIds),In=()=>{var e;return (e=d(t=>t.activeChainIds))==null?void 0:e.map(t=>{var o;let n=(o=u.getState().chains)==null?void 0:o.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},Ws=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Ps=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Rs=({denom:e})=>{let t=In();return reactQuery.useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var i;return (i=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:i.currencies.find(s=>s)})},Ds=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery(n,a=>c(void 0,[a],function*({queryKey:[,i,s]}){if(!i)throw new Error("Query client is not defined");return yield i.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},_s=()=>({data:u(t=>t.recentChainIds),clear:ke}),Ns=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let o=(r=u.getState().chains)==null?void 0:r.find(i=>i.chainId===n);if(o)return o}).filter(Boolean),clear:ke}},Ks=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN",e,t,n],ve,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s.chainInfo)),onMutate:i=>t==null?void 0:t(i.chainInfo),onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Bs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],gt,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=he();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var js=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=Y(),r=o==null?void 0:o.bech32Address,i=reactQuery.useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>St(x({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendTokens:i.mutate,sendTokensAsync:i.mutateAsync,status:i.status}},$s=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=Y(),r=o==null?void 0:o.bech32Address,i=reactQuery.useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>Ct(x({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendIbcTokens:i.mutate,sendIbcTokensAsync:i.mutateAsync,status:i.status}},Vs=({codeId:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=Y(),i=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_INSTANTIATE_CONTRACT",t,n,o,e,i],l=>{var I;if(!i)throw new Error("senderAddress is undefined");let m=F(x({},l),{fee:(I=l.fee)!=null?I:"auto",senderAddress:i,codeId:e});return ht(m)},{onError:(l,m)=>Promise.resolve(t==null?void 0:t(l,m)),onMutate:n,onSuccess:l=>Promise.resolve(o==null?void 0:o(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Hs=({contractAddress:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=Y(),i=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_EXECUTE_CONTRACT",t,n,o,e,i],l=>{var I,f,C;if(!i)throw new Error("senderAddress is undefined");let m=F(x({},l),{fee:(I=l.fee)!=null?I:"auto",senderAddress:i,contractAddress:e,memo:(f=l.memo)!=null?f:"",funds:(C=l.funds)!=null?C:[]});return wt(m)},{onError:(l,m)=>Promise.resolve(t==null?void 0:t(l,m)),onMutate:n,onSuccess:l=>Promise.resolve(o==null?void 0:o(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},Ys=e=>{let{data:t}=Ne();return reactQuery.useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,o]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return At(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Xs=e=>{let{data:t}=Ne(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return It(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function ua(e){let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=d(i=>i.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,m=>c(this,null,function*(){var S,h;if(!(o!=null&&o.includes(m.chainId)))return null;if(!K(s))throw new Error(`${s} is not available`);let f=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(m.chainId);default:return R(s).getOfflineSignerAuto(m.chainId)}}))(),C=(S=u.getState().chainsConfig)==null?void 0:S[m.chainId],g={url:m.rpc,headers:x({},(C==null?void 0:C.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(g,f,e!=null&&e.multiChain?(h=e.opts)==null?void 0:h[m.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function pa(e){let t=B({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=d(i=>i.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,m=>c(this,null,function*(){var h,O;if(!(o!=null&&o.includes(m.chainId)))return null;if(!K(s))throw new Error(`${s} is not available`);let f=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(m.chainId);default:return R(s).getOfflineSignerAuto(m.chainId)}}))(),C=(h=u.getState().chainsConfig)==null?void 0:h[m.chainId],g={url:m.rpc,headers:x({},(C==null?void 0:C.rpcHeaders)||{})},p=C!=null&&C.gas?stargate.GasPrice.fromString(`${C.gas.price}${C.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(g,f,x({gasPrice:p},e!=null&&e.multiChain?(O=e.opts)==null?void 0:O[m.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ma(e){let t=B({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),o=d(s=>s.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]),{data:i}=Ce({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:l=>c(this,[l],function*({queryKey:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,s,I=>c(this,null,function*(){var S;if(!(o!=null&&o.includes(I.chainId)))return null;if(!K(a))throw new Error(`${a} is not available`);if(!i)throw new Error("No tendermint client found");let C=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(I.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(I.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(I.chainId);default:return R(a).getOfflineSignerAuto(I.chainId)}}))(),g=e.multiChain?i[I.chainId]:i;return yield stargate.SigningStargateClient.createWithSigner(g,C,e.multiChain?(S=e.opts)==null?void 0:S[I.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!i&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function da(e){let t=B({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),o=d(a=>a.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]),{data:i}=Ce({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:s}=Ce({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:m=>c(this,[m],function*({queryKey:[,a,l]}){if(a.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,a,f=>c(this,null,function*(){var y,A;if(!(o!=null&&o.includes(f.chainId)))return null;if(!K(l))throw new Error(`${l} is not available`);let g=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(l).getOfflineSigner(f.chainId);case"offlineSignerAuto":return R(l).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return R(l).getOfflineSignerOnlyAmino(f.chainId);default:return R(l).getOfflineSignerAuto(f.chainId)}}))(),p=(y=u.getState().chainsConfig)==null?void 0:y[f.chainId],S=p!=null&&p.gas?stargate.GasPrice.fromString(`${p.gas.price}${p.gas.denom}`):void 0,h=e.multiChain?s==null?void 0:s[f.chainId]:i;if(!h)throw new Error("No tendermint client found");return yield cosmwasmStargate.SigningCosmWasmClient.createWithSigner(h,g,x({gasPrice:S},e.multiChain?(A=e.opts)==null?void 0:A[f.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!i||!Se(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Nt=({children:e})=>{let[t,n]=react.useState(!1);return react.useEffect(()=>{n(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var xn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(V)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:o,iframeOptions:r,chains:i}=u(),{activeChainIds:s,wcSignClients:a}=d(),l=K(o||void 0);return react.useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!i)return;new cosmiframe.Cosmiframe(r.allowedIframeParentOrigins).isReady().then(I=>{if(I)return H({chainId:i.map(f=>f.chainId),walletType:"cosmiframe"})});},[r]),react.useEffect(()=>{if(o){if(!l)return;e&&s?q({onError:n}):!e&&t&&q({onError:n});}},[l]),react.useEffect(()=>{var m,I,f,C,g,p,S,h,O,y,A,T,P,D,_,X,ne,w;if(o){if(!l)return;o==="cosmostation"&&((I=(m=ue()).subscription)==null||I.call(m,()=>{q({onError:n});})),o==="keplr"&&((C=(f=pe()).subscription)==null||C.call(f,()=>{q({onError:n});})),o==="leap"&&((p=(g=me()).subscription)==null||p.call(g,()=>{q({onError:n});})),o==="compass"&&((h=(S=ce()).subscription)==null||h.call(S,()=>{q({onError:n});})),o==="vectis"&&((y=(O=ge()).subscription)==null||y.call(O,()=>{q({onError:n});})),o==="walletconnect"&&a.has("walletconnect")&&((T=(A=Q()).subscription)==null||T.call(A,()=>{q({onError:n});})),o==="station"&&((D=(P=fe()).subscription)==null||D.call(P,()=>{q({onError:n});})),o==="xdefi"&&((X=(_=ye()).subscription)==null||X.call(_,()=>{q({onError:n});})),o==="cosmiframe"&&((w=(ne=le()).subscription)==null||w.call(ne,()=>{q({onError:n});}));}},[o,a,l]),null},Kt=()=>(xn(),null);var Pn=new reactQuery.QueryClient({}),Ga=o=>{var r=o,{children:e,grazOptions:t}=r,n=Qe(r,["children","grazOptions"]);return react.useEffect(()=>{yt(t);},[t]),jsxRuntime.jsx(reactQuery.QueryClientProvider,F(x({client:Pn},n),{children:jsxRuntime.jsxs(Nt,{children:[e,jsxRuntime.jsx(Kt,{})]})}),"graz-provider")};
25
25
 
26
26
  exports.GrazEvents = Kt;
27
- exports.GrazProvider = Fa;
27
+ exports.GrazProvider = Ga;
28
28
  exports.WALLET_TYPES = $e;
29
29
  exports.WalletType = je;
30
30
  exports.checkWallet = K;
@@ -32,13 +32,13 @@ exports.clearRecentChain = ke;
32
32
  exports.clearSession = N;
33
33
  exports.configureGraz = yt;
34
34
  exports.connect = H;
35
- exports.defineChainInfo = br;
36
- exports.defineChains = Er;
35
+ exports.defineChainInfo = Tr;
36
+ exports.defineChains = br;
37
37
  exports.disconnect = ie;
38
38
  exports.executeContract = wt;
39
- exports.getAvailableWallets = Zo;
40
- exports.getChainInfo = dr;
41
- exports.getChainInfos = fr;
39
+ exports.getAvailableWallets = er;
40
+ exports.getChainInfo = fr;
41
+ exports.getChainInfos = gr;
42
42
  exports.getCosmostation = ue;
43
43
  exports.getKeplr = pe;
44
44
  exports.getLeap = me;
@@ -46,8 +46,8 @@ exports.getMetamaskSnapLeap = st;
46
46
  exports.getOfflineSigners = ft;
47
47
  exports.getQueryRaw = It;
48
48
  exports.getQuerySmart = At;
49
- exports.getRecentChainIds = pr;
50
- exports.getRecentChains = mr;
49
+ exports.getRecentChainIds = mr;
50
+ exports.getRecentChains = dr;
51
51
  exports.getVectis = ge;
52
52
  exports.getWCCosmostation = ut;
53
53
  exports.getWCKeplr = pt;
@@ -63,36 +63,36 @@ exports.sendTokens = St;
63
63
  exports.suggestChain = ve;
64
64
  exports.suggestChainAndConnect = gt;
65
65
  exports.useAccount = Y;
66
- exports.useActiveChainCurrency = Ps;
67
- exports.useActiveChainIds = ks;
66
+ exports.useActiveChainCurrency = Rs;
67
+ exports.useActiveChainIds = vs;
68
68
  exports.useActiveChains = In;
69
- exports.useActiveWalletType = Jr;
70
- exports.useBalance = ps;
71
- exports.useBalanceStaked = gs;
69
+ exports.useActiveWalletType = Zr;
70
+ exports.useBalance = ms;
71
+ exports.useBalanceStaked = ys;
72
72
  exports.useBalances = An;
73
- exports.useCapsule = Is;
74
- exports.useChainInfo = vs;
75
- exports.useChainInfos = Ws;
73
+ exports.useCapsule = Os;
74
+ exports.useChainInfo = Ws;
75
+ exports.useChainInfos = Ps;
76
76
  exports.useCheckWallet = he;
77
- exports.useConnect = ms;
77
+ exports.useConnect = ds;
78
78
  exports.useCosmWasmClient = Ne;
79
- exports.useCosmWasmSigningClient = ua;
80
- exports.useCosmWasmTmSigningClient = ma;
81
- exports.useDisconnect = ds;
82
- exports.useExecuteContract = Vs;
79
+ exports.useCosmWasmSigningClient = pa;
80
+ exports.useCosmWasmTmSigningClient = da;
81
+ exports.useDisconnect = fs;
82
+ exports.useExecuteContract = Hs;
83
83
  exports.useGrazEvents = xn;
84
- exports.useInstantiateContract = $s;
85
- exports.useOfflineSigners = fs;
86
- exports.useQueryClientValidators = Rs;
87
- exports.useQueryRaw = Ys;
88
- exports.useQuerySmart = Hs;
89
- exports.useRecentChainIds = Ds;
90
- exports.useRecentChains = _s;
91
- exports.useSendIbcTokens = js;
92
- exports.useSendTokens = Qs;
84
+ exports.useInstantiateContract = Vs;
85
+ exports.useOfflineSigners = gs;
86
+ exports.useQueryClientValidators = Ds;
87
+ exports.useQueryRaw = Xs;
88
+ exports.useQuerySmart = Ys;
89
+ exports.useRecentChainIds = _s;
90
+ exports.useRecentChains = Ns;
91
+ exports.useSendIbcTokens = $s;
92
+ exports.useSendTokens = js;
93
93
  exports.useStargateClient = _e;
94
- exports.useStargateSigningClient = la;
95
- exports.useStargateTmSigningClient = pa;
96
- exports.useSuggestChain = Ns;
97
- exports.useSuggestChainAndConnect = Ks;
94
+ exports.useStargateSigningClient = ua;
95
+ exports.useStargateTmSigningClient = ma;
96
+ exports.useSuggestChain = Ks;
97
+ exports.useSuggestChainAndConnect = Bs;
98
98
  exports.useTendermintClient = Ce;
package/dist/index.mjs CHANGED
@@ -13,8 +13,8 @@ import { CosmWasmClient, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate
13
13
  import { StargateClient, SigningStargateClient, GasPrice } from '@cosmjs/stargate';
14
14
  import { Tendermint37Client, Tendermint34Client } from '@cosmjs/tendermint-rpc';
15
15
  import { shallow } from 'zustand/shallow';
16
- import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
16
+ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
17
17
 
18
- var qt=Object.defineProperty,Gt=Object.defineProperties;var zt=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var ze=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable;var Ge=(e,t,n)=>t in e?qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,k=(e,t)=>{for(var n in t||(t={}))ze.call(t,n)&&Ge(e,n,t[n]);if(ae)for(var n of ae(t))Qe.call(t,n)&&Ge(e,n,t[n]);return e},q=(e,t)=>Gt(e,zt(t));var je=(e,t)=>{var n={};for(var o in e)ze.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&ae)for(var o of ae(e))t.indexOf(o)<0&&Qe.call(e,o)&&(n[o]=e[o]);return n};var c=(e,t,n)=>new Promise((o,r)=>{var i=l=>{try{a(n.next(l));}catch(m){r(m);}},s=l=>{try{a(n.throw(l));}catch(m){r(m);}},a=l=>l.done?o(l.value):Promise.resolve(l.value).then(i,s);a((n=n.apply(e,t)).next());});var H="graz-reconnect-session";var $e=(O=>(O.KEPLR="keplr",O.LEAP="leap",O.VECTIS="vectis",O.COSMOSTATION="cosmostation",O.WALLETCONNECT="walletconnect",O.WC_KEPLR_MOBILE="wc_keplr_mobile",O.WC_LEAP_MOBILE="wc_leap_mobile",O.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",O.WC_CLOT_MOBILE="wc_clot_mobile",O.METAMASK_SNAP_LEAP="metamask_snap_leap",O.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",O.STATION="station",O.XDEFI="xdefi",O.CAPSULE="capsule",O.COSMIFRAME="cosmiframe",O.COMPASS="compass",O.INITIA="initia",O))($e||{}),Ve=["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"];var jt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,web3Modal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ne={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},$t={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},Vt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},d=create(subscribeWithSelector(persist(()=>ne,$t))),u=create(subscribeWithSelector(persist(()=>jt,Vt)));var ce=()=>{var C,g;if(!((C=u.getState().capsuleConfig)!=null&&C.apiKey)||!((g=u.getState().capsuleConfig)!=null&&g.env))throw new Error("Capsule configuration is not set");let e=()=>c(void 0,null,function*(){var h,O;let p=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,S=new p({apiKey:(h=u.getState().capsuleConfig)==null?void 0:h.apiKey,env:(O=u.getState().capsuleConfig)==null?void 0:O.env});return d.setState({capsuleClient:S}),S});return {init:e,enable:p=>c(void 0,null,function*(){let S=typeof p=="string"?[p]:p,h=d.getState().capsuleClient;h||(h=yield e()),u.setState({capsuleState:{showModal:!0,chainId:S}});}),onAfterLoginSuccessful:()=>c(void 0,null,function*(){var y;let p=d.getState().capsuleClient,{chains:S}=u.getState();if(!p)throw new Error("Capsule client is not initialized");if(!S)throw new Error("Chains are not set");yield p.enable();let h=(y=u.getState().capsuleState)==null?void 0:y.chainId;if(!h)throw new Error("Chain ids are not set");let O=Object.fromEntries(yield Promise.all(h.map(A=>c(void 0,null,function*(){let T=yield p.getAccount(A);return [A,{address:fromBech32(T.address).data,bech32Address:T.address,algo:T.algo,name:T.username||"",pubKey:T.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));d.setState(A=>({accounts:k(k({},A.accounts||{}),O)})),u.setState(A=>({recentChainIds:[...A.recentChainIds||[],...h].filter((T,R,_)=>_.indexOf(T)===R)})),d.setState(A=>({activeChainIds:[...A.activeChainIds||[],...h].filter((T,R,_)=>_.indexOf(T)===R)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),d.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active"),u.setState({capsuleState:null});}),getKey:p=>c(void 0,null,function*(){let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");let h=yield S.getAccount(p);return {address:fromBech32(h.address).data,bech32Address:h.address,algo:h.algo,name:h.username||"",pubKey:h.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:p=>c(void 0,null,function*(){let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(p)}),getOfflineSignerDirect:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(p)},signDirect:(...p)=>c(void 0,null,function*(){let[S,h,O]=p,y=d.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.signDirect(S,h,{bodyBytes:O.bodyBytes,authInfoBytes:O.authInfoBytes,chainId:O.chainId,accountNumber:O.accountNumber})}),signAmino:(...p)=>c(void 0,null,function*(){let[S,h,O,y]=p,A=d.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");return A.signAmino(S,h,O,y)}),signArbitrary:(p,S,h)=>c(void 0,null,function*(){let O=d.getState().capsuleClient;if(!O)throw new Error("Capsule client is not initialized");let y=yield O.getAccount(p);if(!y)throw new Error(`Wallet not connected to account ${S}`);let A=(()=>{switch(y.algo){case"secp256k1":return encodeSecp256k1Pubkey(y.pubkey);case"ed25519":return encodeEd25519Pubkey(y.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield O.signArbitrary(p,S,h),pub_key:{type:y.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:A.value}}}),experimentalSuggestChain:(...p)=>c(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSigner(p)},getOfflineSignerAmino:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerAmino(p)}}};var le=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let i=()=>{K(),r();};return window.addEventListener("leap_keystorechange",i),()=>{window.removeEventListener("leap_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var ue=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!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(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 nt={},it=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>c(void 0,null,function*(){var I;let i=yield e.request({method:"web3_clientVersion"});if(!i.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=(I=i.split("MetaMask/v")[1])==null?void 0:I.split(".")[0];if(!(Number(a)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield isSnapInstalled())||(yield installSnap()),window.cosmos=new CosmosSnap,t=window.cosmos,!0}),enable:i=>c(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:i=>t.getOfflineSigner(i),experimentalSuggestChain:i=>c(void 0,null,function*(){yield t.experimentalSuggestChain(i);}),signAmino:(i,s,a)=>c(void 0,null,function*(){return t.signAmino(i,s,a)}),getKey:i=>c(void 0,null,function*(){return typeof nt[i]!="undefined"?nt[i]:t.getKey(i)}),getOfflineSignerAuto:i=>c(void 0,null,function*(){return (yield t.getKey(i)).isNanoLedger?t.getOfflineSignerOnlyAmino(i):t.getOfflineSigner(i)}),getOfflineSignerOnlyAmino:i=>t.getOfflineSignerOnlyAmino(i),signDirect:(i,s,a)=>c(void 0,null,function*(){return t.signDirect(i,s,a)}),signArbitrary:(i,s,a)=>c(void 0,null,function*(){return t.signArbitrary(i,s,a)}),disable:i=>c(void 0,null,function*(){i&&(yield t.deleteChain(i));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var pe=()=>{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:i=>{let s=()=>{K(),i();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:i=>{t.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var rn=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:o,accountNumber:r}=e;if(!t||!n||!o||!r)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:o,accountNumber:r}},sn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,rt=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>c(void 0,null,function*(){yield e.getAddress();}),getKey:f=>c(void 0,null,function*(){let C=e.getOfflineSigner(f),[g]=yield C.getAccounts();if(!g)throw new Error("Wallet connection failed");let p=(()=>{switch(g.algo){case"secp256k1":return rawSecp256k1PubkeyToRawAddress(g.pubkey);case"ed25519":return rawEd25519PubkeyToRawAddress(g.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:sn(g.address),algo:g.algo,pubKey:g.pubkey,bech32Address:g.address,address:p,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:f=>{let C=e.getOfflineSigner(f),g=e.getOfflineSignerOnlyAmino(f);return {getAccounts:C.getAccounts.bind(C),signDirect:C.signDirect.bind(C),signAmino:g.signAmino.bind(g)}},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(C=>{var g,p,S;return {denom:C.coinDenom,amount:C.coinMinimalDenom,low_gas_price:(g=C.gasPriceStep)==null?void 0:g.low,average_gas_price:(p=C.gasPriceStep)==null?void 0:p.average,high_gas_price:(S=C.gasPriceStep)==null?void 0:S.high}})},apis:{rpc:[{address:f.rpc}],rest:[{address:f.rest}]}}),signDirect:(...f)=>{let[C,g,p]=f;return e.getOfflineSigner(C).signDirect(g,rn(p))},signAmino:(...f)=>{let[C,g,p]=f;return e.getOfflineSignerOnlyAmino(C).signAmino(g,p)},signArbitrary:(f,C,g)=>c(void 0,null,function*(){let h=(yield e.getOfflineSigner(f).getAccounts()).find(A=>A.address===C);if(!h)throw new Error(`Wallet not connected to account ${C}`);let O=(()=>{switch(h.algo){case"secp256k1":return encodeSecp256k1Pubkey(h.pubkey);case"ed25519":return encodeEd25519Pubkey(h.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(g),pub_key:{type:h.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:O.value}}}),subscription:f=>{let C=()=>{K(),f();};return window.addEventListener("initia_keystorechange",C),()=>{window.removeEventListener("initia_keystorechange",C);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var me=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let i=()=>{K(),r();};return window.addEventListener("keplr_keystorechange",i),()=>{window.removeEventListener("keplr_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var de=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let i=()=>{K(),r();};return window.addEventListener("leap_keystorechange",i),()=>{window.removeEventListener("leap_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var fe={},st=e=>{let t=window.ethereum;if(t&&e){let n=()=>c(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),o=y=>c(void 0,null,function*(){try{let A=yield n();return Object.values(A).find(T=>T.id===e.id&&(!y||T.version===y))}catch(A){return}}),r=()=>c(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),i=()=>c(void 0,null,function*(){var N;let y=yield t.request({method:"web3_clientVersion"});if(!y.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 T=(N=y.split("MetaMask/v")[1])==null?void 0:N.split(".")[0];if(!(Number(T)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield o())||(yield r()),!0}),s=y=>c(void 0,null,function*(){(yield o())||(yield r());}),a=(y,A,T)=>c(void 0,null,function*(){let R=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:y,signerAddress:A,signDoc:T}}}}),_=T.accountNumber,N=new an(_.low,_.high,_.unsigned);return {signature:R.signature,signed:q(k({},R.signed),{accountNumber:`${N.toString()}`,authInfoBytes:new Uint8Array(Object.values(R.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(R.signed.bodyBytes))})}}),l=(y,A,T)=>c(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:y,signerAddress:A,signDoc:T}}}})}),m=y=>c(void 0,null,function*(){if(typeof fe[y]!="undefined")return fe[y];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:y}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,fe[y]=A,fe[y]}),I=y=>c(void 0,null,function*(){let A=yield m(y);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),f=(...y)=>c(void 0,null,function*(){let[A,T,R,_]=y;return yield l(A,T,R)}),C=(...y)=>c(void 0,null,function*(){let[A,T,R]=y;return yield a(A,T,R)}),p=y=>({getAccounts:()=>c(void 0,null,function*(){return [yield I(y)]}),signAmino:(A,T)=>f(y,A,T)});return {enable:s,experimentalSuggestChain:(...y)=>c(void 0,null,function*(){yield i(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:y[0]}}}});}),getKey:m,getOfflineSigner:y=>({getAccounts:()=>c(void 0,null,function*(){return [yield I(y)]}),signDirect:(A,T)=>C(y,A,T),signAmino:(A,T)=>f(y,A,T)}),getOfflineSignerAuto:y=>c(void 0,null,function*(){return p(y)}),getOfflineSignerOnlyAmino:p,init:i,signAmino:f,signDirect:C}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var at=()=>st({id:"npm:@leapwallet/metamask-cosmos-snap"});var ge=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:i=>{let s=()=>{K(),i();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:i=>c(void 0,null,function*(){let s=yield e.getKey(i);return k({isKeystone:!1},s)}),getOfflineSigner:i=>{try{let s=e.getOfflineSignerOnlyAmino(i);return Object.assign(s,{signDirect:(m,I)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:i=>c(void 0,null,function*(){try{let s=Object.assign(i,{chainSymbolImageUrl:i.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:i.stakeCurrency.coinDecimals,coinDenom:i.stakeCurrency.coinDenom,coinImageUrl:i.stakeCurrency.coinImageUrl||"",coinMinimalDenom:i.stakeCurrency.coinMinimalDenom},currencies:i.currencies.map(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:i.feeCurrencies.map(a=>{var l,m,I;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((l=a.gasPriceStep)==null?void 0:l.average)||0,high:((m=a.gasPriceStep)==null?void 0:m.high)||0,low:((I=a.gasPriceStep)==null?void 0:I.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),enable:i=>e.enable(i),disable:i=>e.disable(i),getOfflineSignerAuto:i=>e.getOfflineSignerAuto(i),getOfflineSignerOnlyAmino:i=>e.getOfflineSignerOnlyAmino(i),signDirect:()=>e.signDirect(),signAmino:(i,s,a,l)=>e.signAmino(i,s,a)}}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:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>c(void 0,null,function*(){let l=yield e.getKey(a);return {address:fromBech32(l.address).data,algo:l.algo,bech32Address:l.address,name:l.name,pubKey:l.pubKey,isKeystone:!1,isNanoLedger:l.isNanoLedger}}),subscription:a=>{let l=()=>{K(),a();};return window.addEventListener("vectis_accountChanged",l),()=>{window.removeEventListener("vectis_accountChanged",l);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>c(void 0,null,function*(){let[l]=a,m=q(k({},l),{rpcUrl:l.rpc,restUrl:l.rest,prettyName:l.chainName.replace(" ",""),bech32Prefix:l.bech32Config.bech32PrefixAccAddr});return e.suggestChains([m])}),signDirect:(...a)=>c(void 0,null,function*(){var I;let{1:l,2:m}=a;return e.signDirect(l,{bodyBytes:m.bodyBytes||Uint8Array.from([]),authInfoBytes:m.authInfoBytes||Uint8Array.from([]),accountNumber:an.fromString(((I=m.accountNumber)==null?void 0:I.toString())||"",!1),chainId:m.chainId||""})}),signAmino:(...a)=>c(void 0,null,function*(){let{1:l,2:m}=a;return e.signAmino(l,m)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var Q=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,ct=()=>Q()&&navigator.userAgent.toLowerCase().includes("android"),lt=()=>Q()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var xe=(e,t,n=new Error("Promise timed out"))=>{let o=new Promise((r,i)=>{setTimeout(()=>{i(n);},t);});return Promise.race([e,o])};var j=e=>{var N,J,ie;if(!((ie=(J=(N=u.getState().walletConnect)==null?void 0:N.options)==null?void 0:J.projectId)!=null&&ie.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",o=w=>{if(!e)return;let{appUrl:E,formatNativeUrl:b}=e;if(Q()){if(ct())if(!w)window.open(E.mobile.android,"_self","noreferrer noopener");else {let v=b(E.mobile.android,w,"android");window.open(v,"_self","noreferrer noopener");}if(lt())if(!w)window.open(E.mobile.ios,"_self","noreferrer noopener");else {let v=b(E.mobile.ios,w,"ios");window.open(v,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:w}=d.getState();if(!w.get(t))throw new Error("walletConnect.signClient is not defined");w.delete(t),d.setState({wcSignClients:w}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},i=w=>c(void 0,null,function*(){let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");if(!w)throw new Error("No wallet connect session");yield b.disconnect({topic:w,reason:getSdkError("USER_DISCONNECTED")}),yield l(b);}),s=w=>{try{let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");let v=b.session.getAll().at(-1);if(!v)return;if(!(v.expiry*1e3>Date.now()+1e3))throw i(v.topic),new Error("invalid session");try{let W=b.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:w.map(U=>`cosmos:${U}`),events:["chainChanged","accountsChanged"]}}});if(!W.length)throw new Error("no session");return W.at(-1)}catch(W){if(!W.message.toLowerCase().includes("no matching key"))throw W}return v}catch(E){if(!E.message.toLowerCase().includes("no matching key"))throw E}},a=w=>{try{return s(w)}catch(E){return}},l=w=>c(void 0,null,function*(){try{let E=w.core.pairing.pairings.getAll({active:!1});if(!E.length)return;yield Promise.all(E.map(b=>c(void 0,null,function*(){yield w.core.pairing.pairings.delete(b.topic,{code:7001,message:"clear pairing"});})));}catch(E){if(!E.message.toLowerCase().includes("no matching key"))throw E}}),m=()=>c(void 0,null,function*(){let{walletConnect:w}=u.getState();if(!(w!=null&&w.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:E}=d.getState(),b=E.get(t);if(b)return b;let v=yield SignClient.init(w.options);return E.set(t,v),d.setState({wcSignClients:E}),v}),I=w=>{let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)return ()=>{};let v=P=>{let W=d.getState().accounts;if(P.params.event.name==="accountsChanged"&&W&&!Object.values(W).map(U=>U.bech32Address).includes(P.params.event.data[0])){let U=P.params.chainId.split(":")[1];U&&f([U]);}else w();};return b.events.on("session_delete",r),b.events.on("session_expire",r),b.events.on("session_event",v),()=>{b.events.off("session_delete",r),b.events.off("session_expire",r),b.events.off("session_event",v);}},f=w=>c(void 0,null,function*(){var re;let E=typeof w=="string"?[w]:w,{wcSignClients:b}=d.getState(),v=b.get(t);if(!v)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:P,chains:W}=u.getState();if(!((re=P==null?void 0:P.options)!=null&&re.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:U}=yield import('@web3modal/standalone'),V=new U(k({projectId:P.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},P.web3Modal)),Z=a(E);if(!Z){let{uri:F,approval:ee}=yield xe(v.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:E.map($=>`cosmos:${$}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!F)throw new Error("No wallet connect uri");e?o(F):yield V.openModal({uri:F});let Ut=$=>c(void 0,null,function*(){return $.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Te,te)=>{ee().then(Le=>{let Ue=Le.sessionProperties;if(!Ue)return te(new Error("No session properties"));let Me=JSON.parse(String(Ue.keys));if(Me.length===0)return te(new Error("No accounts"));let Fe=Me[0];if(!Fe)return te(new Error("No accounts"));let qe={};return E.forEach(se=>{qe[se]=q(k({},Fe),{bech32Address:toBech32(W.find(Ft=>Ft.chainId===se).bech32Config.bech32PrefixAccAddr,fromBech32(Me[0].bech32Address).data)});}),d.setState(se=>({accounts:k(k({},se.accounts||{}),qe)})),Te(Le)}).catch(te),$.addEventListener("abort",()=>{te(new Error("User closed wallet connect"));},{once:!0});})});try{let $=new AbortController,Te=$.signal;V.subscribeModal(te=>{te.open||$.abort();}),yield Ut(Te);}catch($){if(V.closeModal(),!$.message.toLowerCase().includes("no matching key"))return Promise.reject($)}return e||V.closeModal(),Promise.resolve()}try{yield xe((()=>c(void 0,null,function*(){let F=Object.fromEntries(yield Promise.all(E.map(ee=>c(void 0,null,function*(){return [ee,yield g(ee)]}))));d.setState({accounts:F});}))(),15e3,new Error("Connection timeout"));}catch(F){if(i(Z.topic),!F.message.toLowerCase().includes("no matching key"))throw F}}),C=w=>c(void 0,null,function*(){var W;let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");let v=(W=s([w]))==null?void 0:W.topic;if(!v)throw new Error("No wallet connect session");let P=yield b.request({topic:v,chainId:`cosmos:${w}`,request:{method:"cosmos_getAccounts",params:{}}});if(!P[0])throw new Error("No wallet connect account");return {address:P[0].address,algo:P[0].algo,pubkey:new Uint8Array(Buffer.from(P[0].pubkey,n))}}),g=w=>c(void 0,null,function*(){let E=s([w]);if(!(E!=null&&E.topic))throw new Error("No wallet connect session");let b=E.sessionProperties&&JSON.parse(String(E.sessionProperties.keys))[0];if(!b)throw new Error("No wallet connect key");return b}),p=(...w)=>c(void 0,null,function*(){var F,ee;let[E,b,v]=w,{accounts:P,wcSignClients:W}=d.getState(),U=W.get(t);if(!U)throw new Error("walletConnect.signClient is not defined");if(!P)throw new Error("account is not defined");let V=(F=s([E]))==null?void 0:F.topic;if(!V)throw new Error("No wallet connect session");if(!v.bodyBytes)throw new Error("No bodyBytes");if(!v.authInfoBytes)throw new Error("No authInfoBytes");let Z={topic:V,chainId:`cosmos:${E}`,request:{method:"cosmos_signDirect",params:{signerAddress:b,signDoc:q(k({},v),{bodyBytes:Buffer.from(v.bodyBytes).toString(n),authInfoBytes:Buffer.from(v.authInfoBytes).toString(n),accountNumber:(ee=v.accountNumber)==null?void 0:ee.toString()})}}};return o(),yield U.request(Z)}),S=(...w)=>c(void 0,null,function*(){let[E,b,v]=w,{signature:P,signed:W}=yield p(E,b,v);return {signed:{chainId:W.chainId,accountNumber:an.fromString(W.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(W.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(W.bodyBytes,n))},signature:P}}),h=(...w)=>c(void 0,null,function*(){var F;let[E,b,v,P]=w,{wcSignClients:W}=d.getState(),U=W.get(t),{accounts:V}=d.getState();if(!U)throw new Error("walletConnect.signClient is not defined");if(!V)throw new Error("account is not defined");let Z=(F=s([E]))==null?void 0:F.topic;if(!Z)throw new Error("No wallet connect session");return o(),yield U.request({topic:Z,chainId:`cosmos:${E}`,request:{method:"cosmos_signDirect",params:{signerAddress:b,signDoc:v}}})}),O=(...w)=>c(void 0,null,function*(){let[E,b,v,P]=w;return yield h(E,b,v)}),y=w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signDirect:(E,b)=>S(w,E,b)}),A=w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signAmino:(E,b)=>O(w,E,b)});return {enable:f,disable:w=>c(void 0,null,function*(){var v;let{wcSignClients:E}=d.getState(),b=E.get(t);if(w===void 0){let P=b==null?void 0:b.session.getAll();P!==void 0&&(yield Promise.all(P.map(W=>i(W.topic))));}else typeof w=="string"?yield i((v=s([w]))==null?void 0:v.topic):yield Promise.all(w.map(P=>{var W;return i((W=s([P]))==null?void 0:W.topic)}));(b==null?void 0:b.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...w)=>c(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:g,getOfflineSigner:w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signDirect:(E,b)=>S(w,E,b),signAmino:(E,b)=>O(w,E,b)}),getOfflineSignerAuto:w=>c(void 0,null,function*(){return (yield g(w)).isNanoLedger?A(w):y(w)}),getOfflineSignerOnlyAmino:A,signAmino:O,signDirect:S,subscription:I,init:m}};var ut=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())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,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;default:return `${a}://wc?uri=${l}`}}};return j(e)};var pt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())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,i,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${i}`};return j(e)};var mt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())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,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return j(e)};var dt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())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,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return j(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 i=()=>{K(),r();};return window.addEventListener("keplr_keystorechange",i),()=>{window.removeEventListener("keplr_keystorechange",i);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var B=(e=u.getState().walletType)=>{try{return D(e),!0}catch(t){return !1}},K=()=>{window.sessionStorage.removeItem(H),d.setState(ne);},D=(e=u.getState().walletType)=>{var o;let t=(()=>{switch(e){case"keplr":return me();case"leap":return de();case"cosmostation":return pe();case"vectis":return ye();case"walletconnect":return j();case"wc_keplr_mobile":return mt();case"wc_leap_mobile":return dt();case"wc_cosmostation_mobile":return pt();case"wc_clot_mobile":return ut();case"metamask_snap_leap":return at();case"metamask_snap_cosmos":return it();case"station":return ge();case"xdefi":return Se();case"capsule":return ce();case"cosmiframe":return ue();case"compass":return le();case"initia":return rt();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((o=t.setDefaultOptions)==null||o.call(t,n)),t},er=()=>Object.fromEntries(Ve.map(e=>[e,B(e)])),ke=e=>e==="capsule",ft=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var Y=e=>c(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:o,walletType:r}=u.getState(),i=(e==null?void 0:e.walletType)||r;if(!B(i))throw new Error(`${i} is not available`);let a=D(i),l=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!l)throw new Error("No last known connected chain, connect action requires chain ids");let m=o==null?void 0:o.map(g=>g.chainId);l.forEach(g=>{if(!(m!=null&&m.includes(g)))throw new Error(`Chain ${g} is not provided in GrazProvider`)}),d.setState(g=>{let p=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!l;return g.activeChainIds&&l.filter(h=>{var O;return !((O=g.activeChainIds)!=null&&O.includes(h))}).length>0?{status:"connecting"}:p?{status:"reconnecting"}:{status:"connecting"}});let{accounts:I}=d.getState();if(yield (t=a.init)==null?void 0:t.call(a),ke(i)&&d.getState().capsuleClient&&Object.values(d.getState().accounts||[]).length>0){let g=l.map(h=>o.find(O=>O.chainId===h)),p=d.getState().accounts;d.setState({status:"connecting"});let S=Object.fromEntries(yield Promise.all(l.map(h=>c(void 0,null,function*(){return [h,yield a.getKey(h)]}))));return d.setState(h=>({accounts:k(k({},h.accounts||{}),S)})),u.setState(h=>({recentChainIds:[...h.recentChainIds||[],...l].filter((O,y,A)=>A.indexOf(O)===y)})),d.setState(h=>({activeChainIds:[...h.activeChainIds||[],...l].filter((O,y,A)=>A.indexOf(O)===y)})),d.setState({status:"connected"}),{accounts:p,walletType:i,chains:g}}if(yield a.enable(l),ke(i)){let g=l.map(S=>o.find(h=>h.chainId===S)),p=d.getState().accounts;return d.setState({status:"connecting"}),{accounts:p,walletType:i,chains:g}}if(!ft(i)){let g=Object.fromEntries(yield Promise.all(l.map(p=>c(void 0,null,function*(){return [p,yield a.getKey(p)]}))));d.setState(p=>({accounts:k(k({},p.accounts||{}),g)}));}u.setState(g=>({recentChainIds:[...g.recentChainIds||[],...l].filter((p,S,h)=>h.indexOf(p)===S)})),d.setState(g=>({activeChainIds:[...g.activeChainIds||[],...l].filter((p,S,h)=>h.indexOf(p)===S)})),u.setState({walletType:i,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:i}),d.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active");let f=l.map(g=>o.find(p=>p.chainId===g));return {accounts:d.getState().accounts,walletType:i,chains:f}}catch(n){throw console.error("connect ",n),d.getState().accounts===null&&d.setState({status:"disconnected"}),d.getState().accounts&&d.getState().activeChainIds&&d.setState({status:"connected"}),n}}),oe=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(H);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=d.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(d.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(d.setState(r=>{var i;return {activeChainIds:(i=r.activeChainIds)==null?void 0:i.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var i;return {recentChainIds:(i=r.recentChainIds)==null?void 0:i.filter(s=>!t.includes(s))}}));}else d.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},G=e=>c(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:o}=u.getState();try{let i=B(n||void 0);if(t&&i&&n)return yield Y({chainId:t,walletType:n,autoReconnect:o})}catch(i){(r=e==null?void 0:e.onError)==null||r.call(e,i),oe();}}),gt=e=>c(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!B(n))throw new Error(`${n} is not available`);let r=D(n),i=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:i,offlineSignerAmino:s,offlineSignerAuto:a}});var ve=()=>{u.setState({recentChainIds:null});},mr=()=>u.getState().recentChainIds,dr=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(o=>t.find(r=>r.chainId===o)))!=null?n:null},fr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},gr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},We=n=>c(void 0,[n],function*({chainInfo:e,walletType:t}){let o=D(t);return t==="capsule"?yield Y({chainId:e.chainId,walletType:t}):yield o.experimentalSuggestChain(e),e}),yt=e=>c(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 Y({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var St=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 Ct=s=>c(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:o,fee:r,memo:i}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,o,r,i)}),ht=I=>c(void 0,[I],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:o,sourcePort:r,sourceChannel:i,timeoutHeight:s,timeoutTimestamp:a,fee:l,memo:m}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,o,r,i,s,a,l,m)}),wt=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:o,options:r,label:i,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,i,o,r)}),At=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:o,contractAddress:r,funds:i,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,o,s,i)}),It=(e,t,n)=>c(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),Ot=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let o=new TextEncoder().encode(t);return n.queryContractRaw(e,o)};var br=e=>e,Tr=e=>e;var Ce=e=>e?Object.keys(e).length===0:!0;var Pe=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Et=e=>globalThis.DOMException===void 0?new Pe(e):new DOMException(e),bt=e=>{let t=e.reason===void 0?Et("This operation was aborted."):e.reason;return t instanceof Error?t:Et(t)};function Re(i,s){return c(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:o=!0,signal:r}={}){return new Promise((a,l)=>{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(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let m=[],I=[],f=new Map,C=!1,g=!1,p=!1,S=0,h=0,O=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),y=T=>{C=!0,g=!0,l(T);};r&&(r.aborted&&y(bt(r)),r.addEventListener("abort",()=>{y(bt(r));}));let A=()=>c(this,null,function*(){if(g)return;let T=yield O.next(),R=h;if(h++,T.done){if(p=!0,S===0&&!g){if(!o&&I.length>0){y(new AggregateError(I));return}if(g=!0,f.size===0){a(m);return}let _=[];for(let[N,J]of m.entries())f.get(N)!==Tt&&_.push(J);a(_);}return}S++,c(this,null,function*(){try{let _=yield T.value;if(g)return;let N=yield t(_,R);N===Tt&&f.set(R,N),m[R]=N,S--,yield A();}catch(_){if(o)y(_);else {I.push(_),S--;try{yield A();}catch(N){y(N);}}}});});c(this,null,function*(){for(let T=0;T<n;T++){try{yield A();}catch(R){y(R);break}if(p||C)break}});})})}var Tt=Symbol("skip");var L=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let o=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!o):return o.map(r=>n.find(i=>i.chainId===r)).filter(Boolean);case(!t&&!!o):return [o.map(r=>n.find(i=>i.chainId===r)).filter(Boolean)[0]];case(!!t&&!o):return n;default:return [n[0]]}},z=(e,t,n)=>c(void 0,null,function*(){let o=u.getState().multiChainFetchConcurrency;if(e){let i=yield Re(t,n,{concurrency:o});return Object.fromEntries(i.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),Mt=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((i,s)=>[t[s].chainId,i]))}return n(t[0])};var Ne=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),o,s=>c(void 0,null,function*(){var I;let a=(I=u.getState().chainsConfig)==null?void 0:I[s.chainId],l={url:s.rpc,headers:k({},(a==null?void 0:a.rpcHeaders)||{})};return yield StargateClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ke=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),o,s=>c(void 0,null,function*(){var I;let a=(I=u.getState().chainsConfig)==null?void 0:I[s.chainId],l={url:s.rpc,headers:k({},(a==null?void 0:a.rpcHeaders)||{})};return yield CosmWasmClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},he=({type:e,chainId:t,multiChain:n,enabled:o})=>{let r=L({chainId:t,multiChain:n}),i=useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return useQuery({queryKey:i,queryFn:l=>c(void 0,[l],function*({queryKey:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield z(!!n,a,I=>c(void 0,null,function*(){var S;let f=(S=u.getState().chainsConfig)==null?void 0:S[I.chainId],C={url:I.rpc,headers:k({},(f==null?void 0:f.rpcHeaders)||{})};return yield (s==="tm37"?Tendermint37Client: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),we=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return useQuery(n,({queryKey:[,r]})=>B(r))};var X=e=>{let t=u(a=>a.walletType),n=d(a=>a.activeChainIds),o=L({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=d(a=>a.accounts),i=d(a=>a.status);return useEffect(()=>d.subscribe(a=>a.status,(a,l)=>{var m,I,f;if(a==="connected"){let{accounts:C,activeChainIds:g}=d.getState(),{chains:p}=u.getState(),{walletType:S}=u.getState();if(!C||!g||!p)return (m=e==null?void 0:e.onDisconnect)==null?void 0:m.call(e);(I=e==null?void 0:e.onConnect)==null||I.call(e,{accounts:C,chains:g.map(h=>p.find(O=>O.chainId===h)),walletType:S,isReconnect:l==="reconnecting"});}a==="disconnected"&&((f=e==null?void 0:e.onDisconnect)==null||f.call(e));}),[e]),{data:useMemo(()=>r?Mt(!!(e!=null&&e.multiChain),o,a=>r[a.chainId]):void 0,[r,o,e==null?void 0:e.multiChain]),isConnected:i==="connected",isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",isLoading:i==="connecting"||i==="reconnecting",walletType:i==="connected"?t:void 0,reconnect:G,status:i}},In=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=X(),o=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=Ne({chainId:t.map(s=>s.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!o}),i=useMemo(()=>["USE_ALL_BALANCES",r,t,o,e==null?void 0:e.chainId],[o,e==null?void 0:e.chainId,t,r]);return useQuery(i,m=>c(void 0,[m],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield z(!!(e!=null&&e.multiChain),a,f=>c(void 0,null,function*(){let C=s==null?void 0:s[f.chainId];if(!C)throw new Error(`Client is not ready ${f.chainId}`);return yield C.getAllBalances(toBech32(f.bech32Config.bech32PrefixAccAddr,fromBech32(l).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=L({chainId:e.chainId}),{data:n}=X({chainId:e.chainId}),o=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:i}=In({chainId:t.map(l=>l.chainId),bech32Address:o,enabled:!!o&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,o,e.chainId],a=useQuery(s,({queryKey:[,l,m]})=>m==null?void 0:m.find(I=>I.denom===l),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return q(k({},a),{refetch:l=>c(void 0,null,function*(){return yield i(),a.refetch(l)})})},ds=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_CONNECT",e,t,n],Y,{onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=we();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status}},fs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_DISCONNECT",e,t,n],oe,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:i=>r.mutate(i),disconnectAsync:i=>r.mutateAsync(i),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},gs=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),o=useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return useQuery({queryKey:o,queryFn:s=>c(void 0,[s],function*({queryKey:[,r,i]}){if(r.length<1)throw new Error("No chain found");if(!B(i))throw new Error(`${i} is not available`);return yield z(!!(e!=null&&e.multiChain),r,m=>c(void 0,null,function*(){return yield gt({chainId:m.chainId,walletType:i})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},ys=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=X(),{data:o}=Ne({chainId:t.map(s=>s.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),i=useMemo(()=>["USE_BALANCE_STAKED",o,t,r],[t,r,o]);return useQuery(i,m=>c(void 0,[m],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield z(!!(e!=null&&e.multiChain),a,f=>c(void 0,null,function*(){var g;if(!s)throw new Error("Client is not ready");return yield (g=s[f.chainId])==null?void 0:g.getBalanceStaked(toBech32(f.bech32Config.bech32PrefixAccAddr,fromBech32(l).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!o,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Os=()=>{let e=u(o=>o.capsuleState),t=d(o=>o.capsuleClient),n=ce();return {setModalState:o=>{u.setState(r=>{var i;return {capsuleState:{showModal:o,chainId:(i=r.capsuleState)==null?void 0:i.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{oe();}}};var vs=()=>d(e=>e.activeChainIds),On=()=>{var e;return (e=d(t=>t.activeChainIds))==null?void 0:e.map(t=>{var o;let n=(o=u.getState().chains)==null?void 0:o.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},Ws=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Ps=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Rs=({denom:e})=>{let t=On();return useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var i;return (i=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:i.currencies.find(s=>s)})},Ds=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery(n,a=>c(void 0,[a],function*({queryKey:[,i,s]}){if(!i)throw new Error("Query client is not defined");return yield i.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},_s=()=>({data:u(t=>t.recentChainIds),clear:ve}),Ns=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let o=(r=u.getState().chains)==null?void 0:r.find(i=>i.chainId===n);if(o)return o}).filter(Boolean),clear:ve}},Ks=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN",e,t,n],We,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s.chainInfo)),onMutate:i=>t==null?void 0:t(i.chainInfo),onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Bs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],yt,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=we();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var js=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=X(),r=o==null?void 0:o.bech32Address,i=useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>Ct(k({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendTokens:i.mutate,sendTokensAsync:i.mutateAsync,status:i.status}},$s=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=X(),r=o==null?void 0:o.bech32Address,i=useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>ht(k({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendIbcTokens:i.mutate,sendIbcTokensAsync:i.mutateAsync,status:i.status}},Vs=({codeId:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=X(),i=r==null?void 0:r.bech32Address,a=useMutation(["USE_INSTANTIATE_CONTRACT",t,n,o,e,i],l=>{var I;if(!i)throw new Error("senderAddress is undefined");let m=q(k({},l),{fee:(I=l.fee)!=null?I:"auto",senderAddress:i,codeId:e});return wt(m)},{onError:(l,m)=>Promise.resolve(t==null?void 0:t(l,m)),onMutate:n,onSuccess:l=>Promise.resolve(o==null?void 0:o(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Hs=({contractAddress:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=X(),i=r==null?void 0:r.bech32Address,a=useMutation(["USE_EXECUTE_CONTRACT",t,n,o,e,i],l=>{var I,f,C;if(!i)throw new Error("senderAddress is undefined");let m=q(k({},l),{fee:(I=l.fee)!=null?I:"auto",senderAddress:i,contractAddress:e,memo:(f=l.memo)!=null?f:"",funds:(C=l.funds)!=null?C:[]});return At(m)},{onError:(l,m)=>Promise.resolve(t==null?void 0:t(l,m)),onMutate:n,onSuccess:l=>Promise.resolve(o==null?void 0:o(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},Ys=e=>{let{data:t}=Ke();return useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,o]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return It(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Xs=e=>{let{data:t}=Ke(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return Ot(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function ua(e){let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=d(i=>i.activeChainIds),r=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),i,m=>c(this,null,function*(){var S,h;if(!(o!=null&&o.includes(m.chainId)))return null;if(!B(s))throw new Error(`${s} is not available`);let f=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return D(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return D(s).getOfflineSignerOnlyAmino(m.chainId);default:return D(s).getOfflineSignerAuto(m.chainId)}}))(),C=(S=u.getState().chainsConfig)==null?void 0:S[m.chainId],g={url:m.rpc,headers:k({},(C==null?void 0:C.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(g,f,e!=null&&e.multiChain?(h=e.opts)==null?void 0:h[m.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function pa(e){let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=d(i=>i.activeChainIds),r=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),i,m=>c(this,null,function*(){var h,O;if(!(o!=null&&o.includes(m.chainId)))return null;if(!B(s))throw new Error(`${s} is not available`);let f=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return D(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return D(s).getOfflineSignerOnlyAmino(m.chainId);default:return D(s).getOfflineSignerAuto(m.chainId)}}))(),C=(h=u.getState().chainsConfig)==null?void 0:h[m.chainId],g={url:m.rpc,headers:k({},(C==null?void 0:C.rpcHeaders)||{})},p=C!=null&&C.gas?GasPrice.fromString(`${C.gas.price}${C.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(g,f,k({gasPrice:p},e!=null&&e.multiChain?(O=e.opts)==null?void 0:O[m.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ma(e){let t=L({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),o=d(s=>s.activeChainIds),r=useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]),{data:i}=he({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return useQuery({queryKey:r,queryFn:l=>c(this,[l],function*({queryKey:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield z(!!e.multiChain,s,I=>c(this,null,function*(){var S;if(!(o!=null&&o.includes(I.chainId)))return null;if(!B(a))throw new Error(`${a} is not available`);if(!i)throw new Error("No tendermint client found");let C=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(a).getOfflineSigner(I.chainId);case"offlineSignerAuto":return D(a).getOfflineSignerAuto(I.chainId);case"offlineSignerOnlyAmino":return D(a).getOfflineSignerOnlyAmino(I.chainId);default:return D(a).getOfflineSignerAuto(I.chainId)}}))(),g=e.multiChain?i[I.chainId]:i;return yield SigningStargateClient.createWithSigner(g,C,e.multiChain?(S=e.opts)==null?void 0:S[I.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!i&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function da(e){let t=L({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),o=d(a=>a.activeChainIds),r=useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]),{data:i}=he({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:s}=he({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:r,queryFn:m=>c(this,[m],function*({queryKey:[,a,l]}){if(a.length<1)throw new Error("No chains found");return yield z(!!e.multiChain,a,f=>c(this,null,function*(){var y,A;if(!(o!=null&&o.includes(f.chainId)))return null;if(!B(l))throw new Error(`${l} is not available`);let g=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(l).getOfflineSigner(f.chainId);case"offlineSignerAuto":return D(l).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return D(l).getOfflineSignerOnlyAmino(f.chainId);default:return D(l).getOfflineSignerAuto(f.chainId)}}))(),p=(y=u.getState().chainsConfig)==null?void 0:y[f.chainId],S=p!=null&&p.gas?GasPrice.fromString(`${p.gas.price}${p.gas.denom}`):void 0,h=e.multiChain?s==null?void 0:s[f.chainId]:i;if(!h)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(h,g,k({gasPrice:S},e.multiChain?(A=e.opts)==null?void 0:A[f.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!i||!Ce(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Kt=({children:e})=>{let[t,n]=useState(!1);return useEffect(()=>{n(!0);},[]),jsx(Fragment,{children:t?e:null})};var kn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(H)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:o,iframeOptions:r,chains:i}=u(),{activeChainIds:s,wcSignClients:a}=d(),l=B(o||void 0);return useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!i)return;new Cosmiframe(r.allowedIframeParentOrigins).isReady().then(I=>{if(I)return Y({chainId:i.map(f=>f.chainId),walletType:"cosmiframe"})});},[r]),useEffect(()=>{if(o){if(!l)return;e&&s?G({onError:n}):!e&&t&&G({onError:n});}},[l]),useEffect(()=>{var m,I,f,C,g,p,S,h,O,y,A,T,R,_,N,J,ie,w;if(o){if(!l)return;o==="cosmostation"&&((I=(m=pe()).subscription)==null||I.call(m,()=>{G({onError:n});})),o==="keplr"&&((C=(f=me()).subscription)==null||C.call(f,()=>{G({onError:n});})),o==="leap"&&((p=(g=de()).subscription)==null||p.call(g,()=>{G({onError:n});})),o==="compass"&&((h=(S=le()).subscription)==null||h.call(S,()=>{G({onError:n});})),o==="vectis"&&((y=(O=ye()).subscription)==null||y.call(O,()=>{G({onError:n});})),o==="walletconnect"&&a.has("walletconnect")&&((T=(A=j()).subscription)==null||T.call(A,()=>{G({onError:n});})),o==="station"&&((_=(R=ge()).subscription)==null||_.call(R,()=>{G({onError:n});})),o==="xdefi"&&((J=(N=Se()).subscription)==null||J.call(N,()=>{G({onError:n});})),o==="cosmiframe"&&((w=(ie=ue()).subscription)==null||w.call(ie,()=>{G({onError:n});}));}},[o,a,l]),null},Bt=()=>(kn(),null);var Pn=new QueryClient({}),qa=o=>{var r=o,{children:e,grazOptions:t}=r,n=je(r,["children","grazOptions"]);return St(t),jsxs(QueryClientProvider,q(k({client:Pn},n),{children:[e,jsx(Kt,{children:jsx(Bt,{})})]}),"graz-provider")};
18
+ var qt=Object.defineProperty,Gt=Object.defineProperties;var zt=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var ze=Object.prototype.hasOwnProperty,Qe=Object.prototype.propertyIsEnumerable;var Ge=(e,t,n)=>t in e?qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,k=(e,t)=>{for(var n in t||(t={}))ze.call(t,n)&&Ge(e,n,t[n]);if(ae)for(var n of ae(t))Qe.call(t,n)&&Ge(e,n,t[n]);return e},q=(e,t)=>Gt(e,zt(t));var je=(e,t)=>{var n={};for(var o in e)ze.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&ae)for(var o of ae(e))t.indexOf(o)<0&&Qe.call(e,o)&&(n[o]=e[o]);return n};var c=(e,t,n)=>new Promise((o,r)=>{var i=l=>{try{a(n.next(l));}catch(m){r(m);}},s=l=>{try{a(n.throw(l));}catch(m){r(m);}},a=l=>l.done?o(l.value):Promise.resolve(l.value).then(i,s);a((n=n.apply(e,t)).next());});var H="graz-reconnect-session";var $e=(O=>(O.KEPLR="keplr",O.LEAP="leap",O.VECTIS="vectis",O.COSMOSTATION="cosmostation",O.WALLETCONNECT="walletconnect",O.WC_KEPLR_MOBILE="wc_keplr_mobile",O.WC_LEAP_MOBILE="wc_leap_mobile",O.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",O.WC_CLOT_MOBILE="wc_clot_mobile",O.METAMASK_SNAP_LEAP="metamask_snap_leap",O.METAMASK_SNAP_COSMOS="metamask_snap_cosmos",O.STATION="station",O.XDEFI="xdefi",O.CAPSULE="capsule",O.COSMIFRAME="cosmiframe",O.COMPASS="compass",O.INITIA="initia",O))($e||{}),Ve=["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"];var jt={iframeOptions:null,recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,web3Modal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ne={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},$t={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},Vt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},d=create(subscribeWithSelector(persist(()=>ne,$t))),u=create(subscribeWithSelector(persist(()=>jt,Vt)));var ce=()=>{var C,g;if(!((C=u.getState().capsuleConfig)!=null&&C.apiKey)||!((g=u.getState().capsuleConfig)!=null&&g.env))throw new Error("Capsule configuration is not set");let e=()=>c(void 0,null,function*(){var h,O;let p=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,S=new p({apiKey:(h=u.getState().capsuleConfig)==null?void 0:h.apiKey,env:(O=u.getState().capsuleConfig)==null?void 0:O.env});return d.setState({capsuleClient:S}),S});return {init:e,enable:p=>c(void 0,null,function*(){let S=typeof p=="string"?[p]:p,h=d.getState().capsuleClient;h||(h=yield e()),u.setState({capsuleState:{showModal:!0,chainId:S}});}),onAfterLoginSuccessful:()=>c(void 0,null,function*(){var y;let p=d.getState().capsuleClient,{chains:S}=u.getState();if(!p)throw new Error("Capsule client is not initialized");if(!S)throw new Error("Chains are not set");yield p.enable();let h=(y=u.getState().capsuleState)==null?void 0:y.chainId;if(!h)throw new Error("Chain ids are not set");let O=Object.fromEntries(yield Promise.all(h.map(A=>c(void 0,null,function*(){let T=yield p.getAccount(A);return [A,{address:fromBech32(T.address).data,bech32Address:T.address,algo:T.algo,name:T.username||"",pubKey:T.pubkey,isKeystone:!1,isNanoLedger:!1}]}))));d.setState(A=>({accounts:k(k({},A.accounts||{}),O)})),u.setState(A=>({recentChainIds:[...A.recentChainIds||[],...h].filter((T,R,_)=>_.indexOf(T)===R)})),d.setState(A=>({activeChainIds:[...A.activeChainIds||[],...h].filter((T,R,_)=>_.indexOf(T)===R)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),d.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active"),u.setState({capsuleState:null});}),getKey:p=>c(void 0,null,function*(){let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");let h=yield S.getAccount(p);return {address:fromBech32(h.address).data,bech32Address:h.address,algo:h.algo,name:h.username||"",pubKey:h.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:p=>c(void 0,null,function*(){let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(p)}),getOfflineSignerDirect:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerDirect(p)},signDirect:(...p)=>c(void 0,null,function*(){let[S,h,O]=p,y=d.getState().capsuleClient;if(!y)throw new Error("Capsule client is not initialized");return y.signDirect(S,h,{bodyBytes:O.bodyBytes,authInfoBytes:O.authInfoBytes,chainId:O.chainId,accountNumber:O.accountNumber})}),signAmino:(...p)=>c(void 0,null,function*(){let[S,h,O,y]=p,A=d.getState().capsuleClient;if(!A)throw new Error("Capsule client is not initialized");return A.signAmino(S,h,O,y)}),signArbitrary:(p,S,h)=>c(void 0,null,function*(){let O=d.getState().capsuleClient;if(!O)throw new Error("Capsule client is not initialized");let y=yield O.getAccount(p);if(!y)throw new Error(`Wallet not connected to account ${S}`);let A=(()=>{switch(y.algo){case"secp256k1":return encodeSecp256k1Pubkey(y.pubkey);case"ed25519":return encodeEd25519Pubkey(y.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield O.signArbitrary(p,S,h),pub_key:{type:y.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:A.value}}}),experimentalSuggestChain:(...p)=>c(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),getOfflineSigner:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSigner(p)},getOfflineSignerAmino:p=>{let S=d.getState().capsuleClient;if(!S)throw new Error("Capsule client is not initialized");return S.getOfflineSignerAmino(p)}}};var le=()=>{if(typeof window.compass!="undefined"){let e=window.compass;return Object.assign(e,{subscription:r=>{let i=()=>{K(),r();};return window.addEventListener("leap_keystorechange",i),()=>{window.removeEventListener("leap_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var ue=()=>{let e=u.getState();if(!e.iframeOptions)throw e._notFoundFn(),new Error("no iframe options set");if(!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(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 nt={},it=()=>{let e=window.ethereum,t=window.cosmos;if(e)return {init:()=>c(void 0,null,function*(){var I;let i=yield e.request({method:"web3_clientVersion"});if(!i.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=(I=i.split("MetaMask/v")[1])==null?void 0:I.split(".")[0];if(!(Number(a)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield isSnapInstalled())||(yield installSnap()),window.cosmos=new CosmosSnap,t=window.cosmos,!0}),enable:i=>c(void 0,null,function*(){(yield isSnapInstalled())||(yield installSnap());}),getOfflineSigner:i=>t.getOfflineSigner(i),experimentalSuggestChain:i=>c(void 0,null,function*(){yield t.experimentalSuggestChain(i);}),signAmino:(i,s,a)=>c(void 0,null,function*(){return t.signAmino(i,s,a)}),getKey:i=>c(void 0,null,function*(){return typeof nt[i]!="undefined"?nt[i]:t.getKey(i)}),getOfflineSignerAuto:i=>c(void 0,null,function*(){return (yield t.getKey(i)).isNanoLedger?t.getOfflineSignerOnlyAmino(i):t.getOfflineSigner(i)}),getOfflineSignerOnlyAmino:i=>t.getOfflineSignerOnlyAmino(i),signDirect:(i,s,a)=>c(void 0,null,function*(){return t.signDirect(i,s,a)}),signArbitrary:(i,s,a)=>c(void 0,null,function*(){return t.signArbitrary(i,s,a)}),disable:i=>c(void 0,null,function*(){i&&(yield t.deleteChain(i));})};throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var pe=()=>{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:i=>{let s=()=>{K(),i();};return window.addEventListener("cosmostation_keystorechange",s),()=>{window.removeEventListener("cosmostation_keystorechange",s);}},setDefaultOptions:i=>{t.defaultOptions=i;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var rn=e=>{let{bodyBytes:t,authInfoBytes:n,chainId:o,accountNumber:r}=e;if(!t||!n||!o||!r)throw new Error("Invalid sign doc");return {bodyBytes:t,authInfoBytes:n,chainId:o,accountNumber:r}},sn=e=>`${e.slice(0,6)}...${e.slice(-6)}`,rt=()=>{if(typeof window.initia!="undefined"){let e=window.initia;return {enable:()=>c(void 0,null,function*(){yield e.getAddress();}),getKey:f=>c(void 0,null,function*(){let C=e.getOfflineSigner(f),[g]=yield C.getAccounts();if(!g)throw new Error("Wallet connection failed");let p=(()=>{switch(g.algo){case"secp256k1":return rawSecp256k1PubkeyToRawAddress(g.pubkey);case"ed25519":return rawEd25519PubkeyToRawAddress(g.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {name:sn(g.address),algo:g.algo,pubKey:g.pubkey,bech32Address:g.address,address:p,isNanoLedger:!1,isKeystone:!1}}),getOfflineSigner:f=>{let C=e.getOfflineSigner(f),g=e.getOfflineSignerOnlyAmino(f);return {getAccounts:C.getAccounts.bind(C),signDirect:C.signDirect.bind(C),signAmino:g.signAmino.bind(g)}},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(C=>{var g,p,S;return {denom:C.coinDenom,amount:C.coinMinimalDenom,low_gas_price:(g=C.gasPriceStep)==null?void 0:g.low,average_gas_price:(p=C.gasPriceStep)==null?void 0:p.average,high_gas_price:(S=C.gasPriceStep)==null?void 0:S.high}})},apis:{rpc:[{address:f.rpc}],rest:[{address:f.rest}]}}),signDirect:(...f)=>{let[C,g,p]=f;return e.getOfflineSigner(C).signDirect(g,rn(p))},signAmino:(...f)=>{let[C,g,p]=f;return e.getOfflineSignerOnlyAmino(C).signAmino(g,p)},signArbitrary:(f,C,g)=>c(void 0,null,function*(){let h=(yield e.getOfflineSigner(f).getAccounts()).find(A=>A.address===C);if(!h)throw new Error(`Wallet not connected to account ${C}`);let O=(()=>{switch(h.algo){case"secp256k1":return encodeSecp256k1Pubkey(h.pubkey);case"ed25519":return encodeEd25519Pubkey(h.pubkey);default:throw new Error("sr25519 public key algorithm is not supported")}})();return {signature:yield e.signArbitrary(g),pub_key:{type:h.algo==="secp256k1"?pubkeyType.secp256k1:pubkeyType.ed25519,value:O.value}}}),subscription:f=>{let C=()=>{K(),f();};return window.addEventListener("initia_keystorechange",C),()=>{window.removeEventListener("initia_keystorechange",C);}}}}throw u.getState()._notFoundFn(),new Error("window.initia is not defined")};var me=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let i=()=>{K(),r();};return window.addEventListener("keplr_keystorechange",i),()=>{window.removeEventListener("keplr_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var de=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let i=()=>{K(),r();};return window.addEventListener("leap_keystorechange",i),()=>{window.removeEventListener("leap_keystorechange",i);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var fe={},st=e=>{let t=window.ethereum;if(t&&e){let n=()=>c(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),o=y=>c(void 0,null,function*(){try{let A=yield n();return Object.values(A).find(T=>T.id===e.id&&(!y||T.version===y))}catch(A){return}}),r=()=>c(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),i=()=>c(void 0,null,function*(){var N;let y=yield t.request({method:"web3_clientVersion"});if(!y.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 T=(N=y.split("MetaMask/v")[1])==null?void 0:N.split(".")[0];if(!(Number(T)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield o())||(yield r()),!0}),s=y=>c(void 0,null,function*(){(yield o())||(yield r());}),a=(y,A,T)=>c(void 0,null,function*(){let R=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:y,signerAddress:A,signDoc:T}}}}),_=T.accountNumber,N=new an(_.low,_.high,_.unsigned);return {signature:R.signature,signed:q(k({},R.signed),{accountNumber:`${N.toString()}`,authInfoBytes:new Uint8Array(Object.values(R.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(R.signed.bodyBytes))})}}),l=(y,A,T)=>c(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:y,signerAddress:A,signDoc:T}}}})}),m=y=>c(void 0,null,function*(){if(typeof fe[y]!="undefined")return fe[y];let A=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:y}}}});if(!A)throw new Error("No response from Metamask");return A.pubKey=Uint8Array.from(Object.values(A.pubkey)),delete A.pubkey,fe[y]=A,fe[y]}),I=y=>c(void 0,null,function*(){let A=yield m(y);return {address:A.bech32Address,algo:A.algo,pubkey:A.pubKey}}),f=(...y)=>c(void 0,null,function*(){let[A,T,R,_]=y;return yield l(A,T,R)}),C=(...y)=>c(void 0,null,function*(){let[A,T,R]=y;return yield a(A,T,R)}),p=y=>({getAccounts:()=>c(void 0,null,function*(){return [yield I(y)]}),signAmino:(A,T)=>f(y,A,T)});return {enable:s,experimentalSuggestChain:(...y)=>c(void 0,null,function*(){yield i(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:y[0]}}}});}),getKey:m,getOfflineSigner:y=>({getAccounts:()=>c(void 0,null,function*(){return [yield I(y)]}),signDirect:(A,T)=>C(y,A,T),signAmino:(A,T)=>f(y,A,T)}),getOfflineSignerAuto:y=>c(void 0,null,function*(){return p(y)}),getOfflineSignerOnlyAmino:p,init:i,signAmino:f,signDirect:C}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var at=()=>st({id:"npm:@leapwallet/metamask-cosmos-snap"});var ge=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:i=>{let s=()=>{K(),i();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:i=>c(void 0,null,function*(){let s=yield e.getKey(i);return k({isKeystone:!1},s)}),getOfflineSigner:i=>{try{let s=e.getOfflineSignerOnlyAmino(i);return Object.assign(s,{signDirect:(m,I)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:i=>c(void 0,null,function*(){try{let s=Object.assign(i,{chainSymbolImageUrl:i.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:i.stakeCurrency.coinDecimals,coinDenom:i.stakeCurrency.coinDenom,coinImageUrl:i.stakeCurrency.coinImageUrl||"",coinMinimalDenom:i.stakeCurrency.coinMinimalDenom},currencies:i.currencies.map(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:i.feeCurrencies.map(a=>{var l,m,I;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((l=a.gasPriceStep)==null?void 0:l.average)||0,high:((m=a.gasPriceStep)==null?void 0:m.high)||0,low:((I=a.gasPriceStep)==null?void 0:I.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),enable:i=>e.enable(i),disable:i=>e.disable(i),getOfflineSignerAuto:i=>e.getOfflineSignerAuto(i),getOfflineSignerOnlyAmino:i=>e.getOfflineSignerOnlyAmino(i),signDirect:()=>e.signDirect(),signAmino:(i,s,a,l)=>e.signAmino(i,s,a)}}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:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>c(void 0,null,function*(){let l=yield e.getKey(a);return {address:fromBech32(l.address).data,algo:l.algo,bech32Address:l.address,name:l.name,pubKey:l.pubKey,isKeystone:!1,isNanoLedger:l.isNanoLedger}}),subscription:a=>{let l=()=>{K(),a();};return window.addEventListener("vectis_accountChanged",l),()=>{window.removeEventListener("vectis_accountChanged",l);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>c(void 0,null,function*(){let[l]=a,m=q(k({},l),{rpcUrl:l.rpc,restUrl:l.rest,prettyName:l.chainName.replace(" ",""),bech32Prefix:l.bech32Config.bech32PrefixAccAddr});return e.suggestChains([m])}),signDirect:(...a)=>c(void 0,null,function*(){var I;let{1:l,2:m}=a;return e.signDirect(l,{bodyBytes:m.bodyBytes||Uint8Array.from([]),authInfoBytes:m.authInfoBytes||Uint8Array.from([]),accountNumber:an.fromString(((I=m.accountNumber)==null?void 0:I.toString())||"",!1),chainId:m.chainId||""})}),signAmino:(...a)=>c(void 0,null,function*(){let{1:l,2:m}=a;return e.signAmino(l,m)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var Q=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,ct=()=>Q()&&navigator.userAgent.toLowerCase().includes("android"),lt=()=>Q()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var xe=(e,t,n=new Error("Promise timed out"))=>{let o=new Promise((r,i)=>{setTimeout(()=>{i(n);},t);});return Promise.race([e,o])};var j=e=>{var N,J,ie;if(!((ie=(J=(N=u.getState().walletConnect)==null?void 0:N.options)==null?void 0:J.projectId)!=null&&ie.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",o=w=>{if(!e)return;let{appUrl:E,formatNativeUrl:b}=e;if(Q()){if(ct())if(!w)window.open(E.mobile.android,"_self","noreferrer noopener");else {let v=b(E.mobile.android,w,"android");window.open(v,"_self","noreferrer noopener");}if(lt())if(!w)window.open(E.mobile.ios,"_self","noreferrer noopener");else {let v=b(E.mobile.ios,w,"ios");window.open(v,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:w}=d.getState();if(!w.get(t))throw new Error("walletConnect.signClient is not defined");w.delete(t),d.setState({wcSignClients:w}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},i=w=>c(void 0,null,function*(){let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");if(!w)throw new Error("No wallet connect session");yield b.disconnect({topic:w,reason:getSdkError("USER_DISCONNECTED")}),yield l(b);}),s=w=>{try{let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");let v=b.session.getAll().at(-1);if(!v)return;if(!(v.expiry*1e3>Date.now()+1e3))throw i(v.topic),new Error("invalid session");try{let W=b.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:w.map(U=>`cosmos:${U}`),events:["chainChanged","accountsChanged"]}}});if(!W.length)throw new Error("no session");return W.at(-1)}catch(W){if(!W.message.toLowerCase().includes("no matching key"))throw W}return v}catch(E){if(!E.message.toLowerCase().includes("no matching key"))throw E}},a=w=>{try{return s(w)}catch(E){return}},l=w=>c(void 0,null,function*(){try{let E=w.core.pairing.pairings.getAll({active:!1});if(!E.length)return;yield Promise.all(E.map(b=>c(void 0,null,function*(){yield w.core.pairing.pairings.delete(b.topic,{code:7001,message:"clear pairing"});})));}catch(E){if(!E.message.toLowerCase().includes("no matching key"))throw E}}),m=()=>c(void 0,null,function*(){let{walletConnect:w}=u.getState();if(!(w!=null&&w.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:E}=d.getState(),b=E.get(t);if(b)return b;let v=yield SignClient.init(w.options);return E.set(t,v),d.setState({wcSignClients:E}),v}),I=w=>{let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)return ()=>{};let v=P=>{let W=d.getState().accounts;if(P.params.event.name==="accountsChanged"&&W&&!Object.values(W).map(U=>U.bech32Address).includes(P.params.event.data[0])){let U=P.params.chainId.split(":")[1];U&&f([U]);}else w();};return b.events.on("session_delete",r),b.events.on("session_expire",r),b.events.on("session_event",v),()=>{b.events.off("session_delete",r),b.events.off("session_expire",r),b.events.off("session_event",v);}},f=w=>c(void 0,null,function*(){var re;let E=typeof w=="string"?[w]:w,{wcSignClients:b}=d.getState(),v=b.get(t);if(!v)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:P,chains:W}=u.getState();if(!((re=P==null?void 0:P.options)!=null&&re.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:U}=yield import('@web3modal/standalone'),V=new U(k({projectId:P.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},P.web3Modal)),Z=a(E);if(!Z){let{uri:F,approval:ee}=yield xe(v.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:E.map($=>`cosmos:${$}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!F)throw new Error("No wallet connect uri");e?o(F):yield V.openModal({uri:F});let Ut=$=>c(void 0,null,function*(){return $.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Te,te)=>{ee().then(Le=>{let Ue=Le.sessionProperties;if(!Ue)return te(new Error("No session properties"));let Me=JSON.parse(String(Ue.keys));if(Me.length===0)return te(new Error("No accounts"));let Fe=Me[0];if(!Fe)return te(new Error("No accounts"));let qe={};return E.forEach(se=>{qe[se]=q(k({},Fe),{bech32Address:toBech32(W.find(Ft=>Ft.chainId===se).bech32Config.bech32PrefixAccAddr,fromBech32(Me[0].bech32Address).data)});}),d.setState(se=>({accounts:k(k({},se.accounts||{}),qe)})),Te(Le)}).catch(te),$.addEventListener("abort",()=>{te(new Error("User closed wallet connect"));},{once:!0});})});try{let $=new AbortController,Te=$.signal;V.subscribeModal(te=>{te.open||$.abort();}),yield Ut(Te);}catch($){if(V.closeModal(),!$.message.toLowerCase().includes("no matching key"))return Promise.reject($)}return e||V.closeModal(),Promise.resolve()}try{yield xe((()=>c(void 0,null,function*(){let F=Object.fromEntries(yield Promise.all(E.map(ee=>c(void 0,null,function*(){return [ee,yield g(ee)]}))));d.setState({accounts:F});}))(),15e3,new Error("Connection timeout"));}catch(F){if(i(Z.topic),!F.message.toLowerCase().includes("no matching key"))throw F}}),C=w=>c(void 0,null,function*(){var W;let{wcSignClients:E}=d.getState(),b=E.get(t);if(!b)throw new Error("walletConnect.signClient is not defined");let v=(W=s([w]))==null?void 0:W.topic;if(!v)throw new Error("No wallet connect session");let P=yield b.request({topic:v,chainId:`cosmos:${w}`,request:{method:"cosmos_getAccounts",params:{}}});if(!P[0])throw new Error("No wallet connect account");return {address:P[0].address,algo:P[0].algo,pubkey:new Uint8Array(Buffer.from(P[0].pubkey,n))}}),g=w=>c(void 0,null,function*(){let E=s([w]);if(!(E!=null&&E.topic))throw new Error("No wallet connect session");let b=E.sessionProperties&&JSON.parse(String(E.sessionProperties.keys))[0];if(!b)throw new Error("No wallet connect key");return b}),p=(...w)=>c(void 0,null,function*(){var F,ee;let[E,b,v]=w,{accounts:P,wcSignClients:W}=d.getState(),U=W.get(t);if(!U)throw new Error("walletConnect.signClient is not defined");if(!P)throw new Error("account is not defined");let V=(F=s([E]))==null?void 0:F.topic;if(!V)throw new Error("No wallet connect session");if(!v.bodyBytes)throw new Error("No bodyBytes");if(!v.authInfoBytes)throw new Error("No authInfoBytes");let Z={topic:V,chainId:`cosmos:${E}`,request:{method:"cosmos_signDirect",params:{signerAddress:b,signDoc:q(k({},v),{bodyBytes:Buffer.from(v.bodyBytes).toString(n),authInfoBytes:Buffer.from(v.authInfoBytes).toString(n),accountNumber:(ee=v.accountNumber)==null?void 0:ee.toString()})}}};return o(),yield U.request(Z)}),S=(...w)=>c(void 0,null,function*(){let[E,b,v]=w,{signature:P,signed:W}=yield p(E,b,v);return {signed:{chainId:W.chainId,accountNumber:an.fromString(W.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(W.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(W.bodyBytes,n))},signature:P}}),h=(...w)=>c(void 0,null,function*(){var F;let[E,b,v,P]=w,{wcSignClients:W}=d.getState(),U=W.get(t),{accounts:V}=d.getState();if(!U)throw new Error("walletConnect.signClient is not defined");if(!V)throw new Error("account is not defined");let Z=(F=s([E]))==null?void 0:F.topic;if(!Z)throw new Error("No wallet connect session");return o(),yield U.request({topic:Z,chainId:`cosmos:${E}`,request:{method:"cosmos_signDirect",params:{signerAddress:b,signDoc:v}}})}),O=(...w)=>c(void 0,null,function*(){let[E,b,v,P]=w;return yield h(E,b,v)}),y=w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signDirect:(E,b)=>S(w,E,b)}),A=w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signAmino:(E,b)=>O(w,E,b)});return {enable:f,disable:w=>c(void 0,null,function*(){var v;let{wcSignClients:E}=d.getState(),b=E.get(t);if(w===void 0){let P=b==null?void 0:b.session.getAll();P!==void 0&&(yield Promise.all(P.map(W=>i(W.topic))));}else typeof w=="string"?yield i((v=s([w]))==null?void 0:v.topic):yield Promise.all(w.map(P=>{var W;return i((W=s([P]))==null?void 0:W.topic)}));(b==null?void 0:b.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...w)=>c(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:g,getOfflineSigner:w=>({getAccounts:()=>c(void 0,null,function*(){return [yield C(w)]}),signDirect:(E,b)=>S(w,E,b),signAmino:(E,b)=>O(w,E,b)}),getOfflineSignerAuto:w=>c(void 0,null,function*(){return (yield g(w)).isNanoLedger?A(w):y(w)}),getOfflineSignerOnlyAmino:A,signAmino:O,signDirect:S,subscription:I,init:m}};var ut=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())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,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;default:return `${a}://wc?uri=${l}`}}};return j(e)};var pt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())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,i,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${i}`};return j(e)};var mt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())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,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return j(e)};var dt=()=>{var t,n,o;if(!((o=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&o.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())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,i,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),l=encodeURIComponent(i);switch(s){case"ios":return `${a}://wcV2?${l}`;case"android":return `${a}://wcV2?${l}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${l}`}}};return j(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 i=()=>{K(),r();};return window.addEventListener("keplr_keystorechange",i),()=>{window.removeEventListener("keplr_keystorechange",i);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var B=(e=u.getState().walletType)=>{try{return D(e),!0}catch(t){return !1}},K=()=>{window.sessionStorage.removeItem(H),d.setState(ne);},D=(e=u.getState().walletType)=>{var o;let t=(()=>{switch(e){case"keplr":return me();case"leap":return de();case"cosmostation":return pe();case"vectis":return ye();case"walletconnect":return j();case"wc_keplr_mobile":return mt();case"wc_leap_mobile":return dt();case"wc_cosmostation_mobile":return pt();case"wc_clot_mobile":return ut();case"metamask_snap_leap":return at();case"metamask_snap_cosmos":return it();case"station":return ge();case"xdefi":return Se();case"capsule":return ce();case"cosmiframe":return ue();case"compass":return le();case"initia":return rt();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((o=t.setDefaultOptions)==null||o.call(t,n)),t},tr=()=>Object.fromEntries(Ve.map(e=>[e,B(e)])),ke=e=>e==="capsule",ft=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var Y=e=>c(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:o,walletType:r}=u.getState(),i=(e==null?void 0:e.walletType)||r;if(!B(i))throw new Error(`${i} is not available`);let a=D(i),l=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!l)throw new Error("No last known connected chain, connect action requires chain ids");let m=o==null?void 0:o.map(g=>g.chainId);l.forEach(g=>{if(!(m!=null&&m.includes(g)))throw new Error(`Chain ${g} is not provided in GrazProvider`)}),d.setState(g=>{let p=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!l;return g.activeChainIds&&l.filter(h=>{var O;return !((O=g.activeChainIds)!=null&&O.includes(h))}).length>0?{status:"connecting"}:p?{status:"reconnecting"}:{status:"connecting"}});let{accounts:I}=d.getState();if(yield (t=a.init)==null?void 0:t.call(a),ke(i)&&d.getState().capsuleClient&&Object.values(d.getState().accounts||[]).length>0){let g=l.map(h=>o.find(O=>O.chainId===h)),p=d.getState().accounts;d.setState({status:"connecting"});let S=Object.fromEntries(yield Promise.all(l.map(h=>c(void 0,null,function*(){return [h,yield a.getKey(h)]}))));return d.setState(h=>({accounts:k(k({},h.accounts||{}),S)})),u.setState(h=>({recentChainIds:[...h.recentChainIds||[],...l].filter((O,y,A)=>A.indexOf(O)===y)})),d.setState(h=>({activeChainIds:[...h.activeChainIds||[],...l].filter((O,y,A)=>A.indexOf(O)===y)})),d.setState({status:"connected"}),{accounts:p,walletType:i,chains:g}}if(yield a.enable(l),ke(i)){let g=l.map(S=>o.find(h=>h.chainId===S)),p=d.getState().accounts;return d.setState({status:"connecting"}),{accounts:p,walletType:i,chains:g}}if(!ft(i)){let g=Object.fromEntries(yield Promise.all(l.map(p=>c(void 0,null,function*(){return [p,yield a.getKey(p)]}))));d.setState(p=>({accounts:k(k({},p.accounts||{}),g)}));}u.setState(g=>({recentChainIds:[...g.recentChainIds||[],...l].filter((p,S,h)=>h.indexOf(p)===S)})),d.setState(g=>({activeChainIds:[...g.activeChainIds||[],...l].filter((p,S,h)=>h.indexOf(p)===S)})),u.setState({walletType:i,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:i}),d.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active");let f=l.map(g=>o.find(p=>p.chainId===g));return {accounts:d.getState().accounts,walletType:i,chains:f}}catch(n){throw console.error("connect ",n),d.getState().accounts===null&&d.setState({status:"disconnected"}),d.getState().accounts&&d.getState().activeChainIds&&d.setState({status:"connected"}),n}}),oe=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(H);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=d.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(d.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(d.setState(r=>{var i;return {activeChainIds:(i=r.activeChainIds)==null?void 0:i.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var i;return {recentChainIds:(i=r.recentChainIds)==null?void 0:i.filter(s=>!t.includes(s))}}));}else d.setState(ne),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},G=e=>c(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:o}=u.getState();try{let i=B(n||void 0);if(t&&i&&n)return yield Y({chainId:t,walletType:n,autoReconnect:o})}catch(i){(r=e==null?void 0:e.onError)==null||r.call(e,i),oe();}}),gt=e=>c(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!B(n))throw new Error(`${n} is not available`);let r=D(n),i=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:i,offlineSignerAmino:s,offlineSignerAuto:a}});var ve=()=>{u.setState({recentChainIds:null});},dr=()=>u.getState().recentChainIds,fr=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(o=>t.find(r=>r.chainId===o)))!=null?n:null},gr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},yr=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},We=n=>c(void 0,[n],function*({chainInfo:e,walletType:t}){let o=D(t);return t==="capsule"?yield Y({chainId:e.chainId,walletType:t}):yield o.experimentalSuggestChain(e),e}),yt=e=>c(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 Y({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var St=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 Ct=s=>c(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:o,fee:r,memo:i}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,o,r,i)}),ht=I=>c(void 0,[I],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:o,sourcePort:r,sourceChannel:i,timeoutHeight:s,timeoutTimestamp:a,fee:l,memo:m}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,o,r,i,s,a,l,m)}),wt=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:o,options:r,label:i,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,i,o,r)}),At=a=>c(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:o,contractAddress:r,funds:i,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,o,s,i)}),It=(e,t,n)=>c(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),Ot=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let o=new TextEncoder().encode(t);return n.queryContractRaw(e,o)};var Tr=e=>e,Mr=e=>e;var Ce=e=>e?Object.keys(e).length===0:!0;var Pe=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},Et=e=>globalThis.DOMException===void 0?new Pe(e):new DOMException(e),bt=e=>{let t=e.reason===void 0?Et("This operation was aborted."):e.reason;return t instanceof Error?t:Et(t)};function Re(i,s){return c(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:o=!0,signal:r}={}){return new Promise((a,l)=>{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(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let m=[],I=[],f=new Map,C=!1,g=!1,p=!1,S=0,h=0,O=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),y=T=>{C=!0,g=!0,l(T);};r&&(r.aborted&&y(bt(r)),r.addEventListener("abort",()=>{y(bt(r));}));let A=()=>c(this,null,function*(){if(g)return;let T=yield O.next(),R=h;if(h++,T.done){if(p=!0,S===0&&!g){if(!o&&I.length>0){y(new AggregateError(I));return}if(g=!0,f.size===0){a(m);return}let _=[];for(let[N,J]of m.entries())f.get(N)!==Tt&&_.push(J);a(_);}return}S++,c(this,null,function*(){try{let _=yield T.value;if(g)return;let N=yield t(_,R);N===Tt&&f.set(R,N),m[R]=N,S--,yield A();}catch(_){if(o)y(_);else {I.push(_),S--;try{yield A();}catch(N){y(N);}}}});});c(this,null,function*(){for(let T=0;T<n;T++){try{yield A();}catch(R){y(R);break}if(p||C)break}});})})}var Tt=Symbol("skip");var L=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let o=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!o):return o.map(r=>n.find(i=>i.chainId===r)).filter(Boolean);case(!t&&!!o):return [o.map(r=>n.find(i=>i.chainId===r)).filter(Boolean)[0]];case(!!t&&!o):return n;default:return [n[0]]}},z=(e,t,n)=>c(void 0,null,function*(){let o=u.getState().multiChainFetchConcurrency;if(e){let i=yield Re(t,n,{concurrency:o});return Object.fromEntries(i.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),Mt=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((i,s)=>[t[s].chainId,i]))}return n(t[0])};var Ne=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),o,s=>c(void 0,null,function*(){var I;let a=(I=u.getState().chainsConfig)==null?void 0:I[s.chainId],l={url:s.rpc,headers:k({},(a==null?void 0:a.rpcHeaders)||{})};return yield StargateClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ke=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:r=>c(void 0,[r],function*({queryKey:[,o]}){if(o.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),o,s=>c(void 0,null,function*(){var I;let a=(I=u.getState().chainsConfig)==null?void 0:I[s.chainId],l={url:s.rpc,headers:k({},(a==null?void 0:a.rpcHeaders)||{})};return yield CosmWasmClient.connect(l)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},he=({type:e,chainId:t,multiChain:n,enabled:o})=>{let r=L({chainId:t,multiChain:n}),i=useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return useQuery({queryKey:i,queryFn:l=>c(void 0,[l],function*({queryKey:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield z(!!n,a,I=>c(void 0,null,function*(){var S;let f=(S=u.getState().chainsConfig)==null?void 0:S[I.chainId],C={url:I.rpc,headers:k({},(f==null?void 0:f.rpcHeaders)||{})};return yield (s==="tm37"?Tendermint37Client:Tendermint34Client).connect(C)}))}),enabled:!!r&&r.length>0&&(o!==void 0?!!o:!0),refetchOnWindowFocus:!1})};var es=()=>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),we=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return useQuery(n,({queryKey:[,r]})=>B(r))};var X=e=>{let t=u(a=>a.walletType),n=d(a=>a.activeChainIds),o=L({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=d(a=>a.accounts),i=d(a=>a.status);return useEffect(()=>d.subscribe(a=>a.status,(a,l)=>{var m,I,f;if(a==="connected"){let{accounts:C,activeChainIds:g}=d.getState(),{chains:p}=u.getState(),{walletType:S}=u.getState();if(!C||!g||!p)return (m=e==null?void 0:e.onDisconnect)==null?void 0:m.call(e);(I=e==null?void 0:e.onConnect)==null||I.call(e,{accounts:C,chains:g.map(h=>p.find(O=>O.chainId===h)),walletType:S,isReconnect:l==="reconnecting"});}a==="disconnected"&&((f=e==null?void 0:e.onDisconnect)==null||f.call(e));}),[e]),{data:useMemo(()=>r?Mt(!!(e!=null&&e.multiChain),o,a=>r[a.chainId]):void 0,[r,o,e==null?void 0:e.multiChain]),isConnected:i==="connected",isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",isLoading:i==="connecting"||i==="reconnecting",walletType:i==="connected"?t:void 0,reconnect:G,status:i}},In=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=X(),o=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=Ne({chainId:t.map(s=>s.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!o}),i=useMemo(()=>["USE_ALL_BALANCES",r,t,o,e==null?void 0:e.chainId],[o,e==null?void 0:e.chainId,t,r]);return useQuery(i,m=>c(void 0,[m],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield z(!!(e!=null&&e.multiChain),a,f=>c(void 0,null,function*(){let C=s==null?void 0:s[f.chainId];if(!C)throw new Error(`Client is not ready ${f.chainId}`);return yield C.getAllBalances(toBech32(f.bech32Config.bech32PrefixAccAddr,fromBech32(l).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})},ds=e=>{let t=L({chainId:e.chainId}),{data:n}=X({chainId:e.chainId}),o=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:i}=In({chainId:t.map(l=>l.chainId),bech32Address:o,enabled:!!o&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,o,e.chainId],a=useQuery(s,({queryKey:[,l,m]})=>m==null?void 0:m.find(I=>I.denom===l),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return q(k({},a),{refetch:l=>c(void 0,null,function*(){return yield i(),a.refetch(l)})})},fs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_CONNECT",e,t,n],Y,{onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=we();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status}},gs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_DISCONNECT",e,t,n],oe,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:i=>r.mutate(i),disconnectAsync:i=>r.mutateAsync(i),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},ys=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),o=useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return useQuery({queryKey:o,queryFn:s=>c(void 0,[s],function*({queryKey:[,r,i]}){if(r.length<1)throw new Error("No chain found");if(!B(i))throw new Error(`${i} is not available`);return yield z(!!(e!=null&&e.multiChain),r,m=>c(void 0,null,function*(){return yield gt({chainId:m.chainId,walletType:i})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},Ss=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=X(),{data:o}=Ne({chainId:t.map(s=>s.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),i=useMemo(()=>["USE_BALANCE_STAKED",o,t,r],[t,r,o]);return useQuery(i,m=>c(void 0,[m],function*({queryKey:[,s,a,l]}){if(!l)throw new Error("address is not defined");return yield z(!!(e!=null&&e.multiChain),a,f=>c(void 0,null,function*(){var g;if(!s)throw new Error("Client is not ready");return yield (g=s[f.chainId])==null?void 0:g.getBalanceStaked(toBech32(f.bech32Config.bech32PrefixAccAddr,fromBech32(l).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!o,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Es=()=>{let e=u(o=>o.capsuleState),t=d(o=>o.capsuleClient),n=ce();return {setModalState:o=>{u.setState(r=>{var i;return {capsuleState:{showModal:o,chainId:(i=r.capsuleState)==null?void 0:i.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{oe();}}};var Ws=()=>d(e=>e.activeChainIds),On=()=>{var e;return (e=d(t=>t.activeChainIds))==null?void 0:e.map(t=>{var o;let n=(o=u.getState().chains)==null?void 0:o.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},Ps=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Rs=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Ds=({denom:e})=>{let t=On();return useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var i;return (i=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:i.currencies.find(s=>s)})},_s=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery(n,a=>c(void 0,[a],function*({queryKey:[,i,s]}){if(!i)throw new Error("Query client is not defined");return yield i.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},Ns=()=>({data:u(t=>t.recentChainIds),clear:ve}),Ks=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let o=(r=u.getState().chains)==null?void 0:r.find(i=>i.chainId===n);if(o)return o}).filter(Boolean),clear:ve}},Bs=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN",e,t,n],We,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s.chainInfo)),onMutate:i=>t==null?void 0:t(i.chainInfo),onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Ls=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],yt,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=we();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!i,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var $s=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=X(),r=o==null?void 0:o.bech32Address,i=useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>Ct(k({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendTokens:i.mutate,sendTokensAsync:i.mutateAsync,status:i.status}},Vs=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:o}=X(),r=o==null?void 0:o.bech32Address,i=useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>ht(k({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:i.error,isLoading:i.isLoading,isSuccess:i.isSuccess,sendIbcTokens:i.mutate,sendIbcTokensAsync:i.mutateAsync,status:i.status}},Hs=({codeId:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=X(),i=r==null?void 0:r.bech32Address,a=useMutation(["USE_INSTANTIATE_CONTRACT",t,n,o,e,i],l=>{var I;if(!i)throw new Error("senderAddress is undefined");let m=q(k({},l),{fee:(I=l.fee)!=null?I:"auto",senderAddress:i,codeId:e});return wt(m)},{onError:(l,m)=>Promise.resolve(t==null?void 0:t(l,m)),onMutate:n,onSuccess:l=>Promise.resolve(o==null?void 0:o(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Ys=({contractAddress:e,onError:t,onLoading:n,onSuccess:o})=>{let{data:r}=X(),i=r==null?void 0:r.bech32Address,a=useMutation(["USE_EXECUTE_CONTRACT",t,n,o,e,i],l=>{var I,f,C;if(!i)throw new Error("senderAddress is undefined");let m=q(k({},l),{fee:(I=l.fee)!=null?I:"auto",senderAddress:i,contractAddress:e,memo:(f=l.memo)!=null?f:"",funds:(C=l.funds)!=null?C:[]});return At(m)},{onError:(l,m)=>Promise.resolve(t==null?void 0:t(l,m)),onMutate:n,onSuccess:l=>Promise.resolve(o==null?void 0:o(l))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},Xs=e=>{let{data:t}=Ke();return useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,o]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return It(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Js=e=>{let{data:t}=Ke(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return Ot(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function pa(e){let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=d(i=>i.activeChainIds),r=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),i,m=>c(this,null,function*(){var S,h;if(!(o!=null&&o.includes(m.chainId)))return null;if(!B(s))throw new Error(`${s} is not available`);let f=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return D(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return D(s).getOfflineSignerOnlyAmino(m.chainId);default:return D(s).getOfflineSignerAuto(m.chainId)}}))(),C=(S=u.getState().chainsConfig)==null?void 0:S[m.chainId],g={url:m.rpc,headers:k({},(C==null?void 0:C.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(g,f,e!=null&&e.multiChain?(h=e.opts)==null?void 0:h[m.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ma(e){let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(i=>i.walletType),o=d(i=>i.activeChainIds),r=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]);return useQuery({queryKey:r,queryFn:a=>c(this,[a],function*({queryKey:[,i,s]}){if(i.length<1)throw new Error("No chains found");return yield z(!!(e!=null&&e.multiChain),i,m=>c(this,null,function*(){var h,O;if(!(o!=null&&o.includes(m.chainId)))return null;if(!B(s))throw new Error(`${s} is not available`);let f=yield (()=>c(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return D(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return D(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return D(s).getOfflineSignerOnlyAmino(m.chainId);default:return D(s).getOfflineSignerAuto(m.chainId)}}))(),C=(h=u.getState().chainsConfig)==null?void 0:h[m.chainId],g={url:m.rpc,headers:k({},(C==null?void 0:C.rpcHeaders)||{})},p=C!=null&&C.gas?GasPrice.fromString(`${C.gas.price}${C.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(g,f,k({gasPrice:p},e!=null&&e.multiChain?(O=e.opts)==null?void 0:O[m.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function da(e){let t=L({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),o=d(s=>s.activeChainIds),r=useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]),{data:i}=he({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return useQuery({queryKey:r,queryFn:l=>c(this,[l],function*({queryKey:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield z(!!e.multiChain,s,I=>c(this,null,function*(){var S;if(!(o!=null&&o.includes(I.chainId)))return null;if(!B(a))throw new Error(`${a} is not available`);if(!i)throw new Error("No tendermint client found");let C=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(a).getOfflineSigner(I.chainId);case"offlineSignerAuto":return D(a).getOfflineSignerAuto(I.chainId);case"offlineSignerOnlyAmino":return D(a).getOfflineSignerOnlyAmino(I.chainId);default:return D(a).getOfflineSignerAuto(I.chainId)}}))(),g=e.multiChain?i[I.chainId]:i;return yield SigningStargateClient.createWithSigner(g,C,e.multiChain?(S=e.opts)==null?void 0:S[I.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!i&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function fa(e){let t=L({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),o=d(a=>a.activeChainIds),r=useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,o],[o,e,t,n]),{data:i}=he({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:s}=he({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:r,queryFn:m=>c(this,[m],function*({queryKey:[,a,l]}){if(a.length<1)throw new Error("No chains found");return yield z(!!e.multiChain,a,f=>c(this,null,function*(){var y,A;if(!(o!=null&&o.includes(f.chainId)))return null;if(!B(l))throw new Error(`${l} is not available`);let g=yield (()=>c(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return D(l).getOfflineSigner(f.chainId);case"offlineSignerAuto":return D(l).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return D(l).getOfflineSignerOnlyAmino(f.chainId);default:return D(l).getOfflineSignerAuto(f.chainId)}}))(),p=(y=u.getState().chainsConfig)==null?void 0:y[f.chainId],S=p!=null&&p.gas?GasPrice.fromString(`${p.gas.price}${p.gas.denom}`):void 0,h=e.multiChain?s==null?void 0:s[f.chainId]:i;if(!h)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(h,g,k({gasPrice:S},e.multiChain?(A=e.opts)==null?void 0:A[f.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!i||!Ce(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Kt=({children:e})=>{let[t,n]=useState(!1);return useEffect(()=>{n(!0);},[]),jsx(Fragment,{children:t?e:null})};var kn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(H)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:o,iframeOptions:r,chains:i}=u(),{activeChainIds:s,wcSignClients:a}=d(),l=B(o||void 0);return useEffect(()=>{if(!r||r.autoConnect===!1||!r.allowedIframeParentOrigins.length||!i)return;new Cosmiframe(r.allowedIframeParentOrigins).isReady().then(I=>{if(I)return Y({chainId:i.map(f=>f.chainId),walletType:"cosmiframe"})});},[r]),useEffect(()=>{if(o){if(!l)return;e&&s?G({onError:n}):!e&&t&&G({onError:n});}},[l]),useEffect(()=>{var m,I,f,C,g,p,S,h,O,y,A,T,R,_,N,J,ie,w;if(o){if(!l)return;o==="cosmostation"&&((I=(m=pe()).subscription)==null||I.call(m,()=>{G({onError:n});})),o==="keplr"&&((C=(f=me()).subscription)==null||C.call(f,()=>{G({onError:n});})),o==="leap"&&((p=(g=de()).subscription)==null||p.call(g,()=>{G({onError:n});})),o==="compass"&&((h=(S=le()).subscription)==null||h.call(S,()=>{G({onError:n});})),o==="vectis"&&((y=(O=ye()).subscription)==null||y.call(O,()=>{G({onError:n});})),o==="walletconnect"&&a.has("walletconnect")&&((T=(A=j()).subscription)==null||T.call(A,()=>{G({onError:n});})),o==="station"&&((_=(R=ge()).subscription)==null||_.call(R,()=>{G({onError:n});})),o==="xdefi"&&((J=(N=Se()).subscription)==null||J.call(N,()=>{G({onError:n});})),o==="cosmiframe"&&((w=(ie=ue()).subscription)==null||w.call(ie,()=>{G({onError:n});}));}},[o,a,l]),null},Bt=()=>(kn(),null);var Rn=new QueryClient({}),za=o=>{var r=o,{children:e,grazOptions:t}=r,n=je(r,["children","grazOptions"]);return useEffect(()=>{St(t);},[t]),jsx(QueryClientProvider,q(k({client:Rn},n),{children:jsxs(Kt,{children:[e,jsx(Bt,{})]})}),"graz-provider")};
19
19
 
20
- export { Bt as GrazEvents, qa as GrazProvider, Ve as WALLET_TYPES, $e as WalletType, B as checkWallet, ve as clearRecentChain, K as clearSession, St as configureGraz, Y as connect, Tr as defineChainInfo, br as defineChains, oe as disconnect, At as executeContract, er as getAvailableWallets, fr as getChainInfo, gr as getChainInfos, pe as getCosmostation, me as getKeplr, de as getLeap, at as getMetamaskSnapLeap, gt as getOfflineSigners, Ot as getQueryRaw, It as getQuerySmart, mr as getRecentChainIds, dr as getRecentChains, ye as getVectis, pt as getWCCosmostation, mt as getWCKeplr, dt as getWCLeap, D as getWallet, j as getWalletConnect, wt as instantiateContract, ke as isCapsule, ft as isWalletConnect, G as reconnect, ht as sendIbcTokens, Ct as sendTokens, We as suggestChain, yt as suggestChainAndConnect, X as useAccount, Rs as useActiveChainCurrency, vs as useActiveChainIds, On as useActiveChains, Zr as useActiveWalletType, ms as useBalance, ys as useBalanceStaked, In as useBalances, Os as useCapsule, Ws as useChainInfo, Ps as useChainInfos, we as useCheckWallet, ds as useConnect, Ke as useCosmWasmClient, pa as useCosmWasmSigningClient, da as useCosmWasmTmSigningClient, fs as useDisconnect, Hs as useExecuteContract, kn as useGrazEvents, Vs as useInstantiateContract, gs as useOfflineSigners, Ds as useQueryClientValidators, Xs as useQueryRaw, Ys as useQuerySmart, _s as useRecentChainIds, Ns as useRecentChains, $s as useSendIbcTokens, js as useSendTokens, Ne as useStargateClient, ua as useStargateSigningClient, ma as useStargateTmSigningClient, Ks as useSuggestChain, Bs as useSuggestChainAndConnect, he as useTendermintClient };
20
+ export { Bt as GrazEvents, za as GrazProvider, Ve as WALLET_TYPES, $e as WalletType, B as checkWallet, ve as clearRecentChain, K as clearSession, St as configureGraz, Y as connect, Mr as defineChainInfo, Tr as defineChains, oe as disconnect, At as executeContract, tr as getAvailableWallets, gr as getChainInfo, yr as getChainInfos, pe as getCosmostation, me as getKeplr, de as getLeap, at as getMetamaskSnapLeap, gt as getOfflineSigners, Ot as getQueryRaw, It as getQuerySmart, dr as getRecentChainIds, fr as getRecentChains, ye as getVectis, pt as getWCCosmostation, mt as getWCKeplr, dt as getWCLeap, D as getWallet, j as getWalletConnect, wt as instantiateContract, ke as isCapsule, ft as isWalletConnect, G as reconnect, ht as sendIbcTokens, Ct as sendTokens, We as suggestChain, yt as suggestChainAndConnect, X as useAccount, Ds as useActiveChainCurrency, Ws as useActiveChainIds, On as useActiveChains, es as useActiveWalletType, ds as useBalance, Ss as useBalanceStaked, In as useBalances, Es as useCapsule, Ps as useChainInfo, Rs as useChainInfos, we as useCheckWallet, fs as useConnect, Ke as useCosmWasmClient, ma as useCosmWasmSigningClient, fa as useCosmWasmTmSigningClient, gs as useDisconnect, Ys as useExecuteContract, kn as useGrazEvents, Hs as useInstantiateContract, ys as useOfflineSigners, _s as useQueryClientValidators, Js as useQueryRaw, Xs as useQuerySmart, Ns as useRecentChainIds, Ks as useRecentChains, Vs as useSendIbcTokens, $s as useSendTokens, Ne as useStargateClient, pa as useStargateSigningClient, da as useStargateTmSigningClient, Bs as useSuggestChain, Ls as useSuggestChainAndConnect, he as useTendermintClient };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "graz",
3
3
  "description": "React hooks for Cosmos",
4
- "version": "0.1.21",
4
+ "version": "0.1.23",
5
5
  "author": "Griko Nibras <griko@strange.love>",
6
6
  "repository": "https://github.com/graz-sh/graz.git",
7
7
  "homepage": "https://github.com/graz-sh/graz",