@skip-go/widget-web-component 3.18.5 → 3.19.0
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/build/4150.index.js +1 -1
- package/build/4194.index.js +1 -1
- package/build/4379.index.js +2 -2
- package/build/4549.index.js +1 -0
- package/build/5972.index.js +11 -11
- package/build/6484.index.js +1 -1
- package/build/7201.index.js +18 -18
- package/build/8373.index.js +46 -46
- package/build/913.index.js +1 -1
- package/build/9194.index.js +2 -2
- package/build/index.js +101 -101
- package/build/index.js.LICENSE.txt +12 -2
- package/package.json +1 -1
package/build/7201.index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*! For license information please see 7201.index.js.LICENSE.txt */
|
|
2
|
-
export const __webpack_esm_id__=7201;export const __webpack_esm_ids__=[7201];export const __webpack_esm_modules__={1057:(e,t,s)=>{s.d(t,{A:()=>Xe});var i=s(37876),r=s(47431),n=s(70255),o=s(64264),a=s(93786),c=s(14350),h=s(50046),l=s.n(h),p=s(48526).hp;const d="error",u="wc@2:universal_provider:",g="https://rpc.walletconnect.org/v1/",f="generic",m=`${g}bundler`,w="default_chain_changed";function y(){}function b(e){return null==e||"object"!=typeof e&&"function"!=typeof e}function v(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function E(e){return"object"==typeof e&&null!==e}function I(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function _(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const N="[object String]",A="[object Number]",C="[object Boolean]",P="[object Arguments]";function S(e,t,s,i=new Map,r=void 0){const n=r?.(e,t,s,i);if(null!=n)return n;if(b(e))return e;if(i.has(e))return i.get(e);if(Array.isArray(e)){const t=new Array(e.length);i.set(e,t);for(let n=0;n<e.length;n++)t[n]=S(e[n],n,s,i,r);return Object.hasOwn(e,"index")&&(t.index=e.index),Object.hasOwn(e,"input")&&(t.input=e.input),t}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){const t=new RegExp(e.source,e.flags);return t.lastIndex=e.lastIndex,t}if(e instanceof Map){const t=new Map;i.set(e,t);for(const[n,o]of e)t.set(n,S(o,n,s,i,r));return t}if(e instanceof Set){const t=new Set;i.set(e,t);for(const n of e)t.add(S(n,void 0,s,i,r));return t}if(typeof p<"u"&&p.isBuffer(e))return e.subarray();if(v(e)){const t=new(Object.getPrototypeOf(e).constructor)(e.length);i.set(e,t);for(let n=0;n<e.length;n++)t[n]=S(e[n],n,s,i,r);return t}if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){const t=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return i.set(e,t),O(t,e,s,i,r),t}if(typeof File<"u"&&e instanceof File){const t=new File([e],e.name,{type:e.type});return i.set(e,t),O(t,e,s,i,r),t}if(e instanceof Blob){const t=new Blob([e],{type:e.type});return i.set(e,t),O(t,e,s,i,r),t}if(e instanceof Error){const t=new e.constructor;return i.set(e,t),t.message=e.message,t.name=e.name,t.stack=e.stack,t.cause=e.cause,O(t,e,s,i,r),t}if("object"==typeof e&&function(e){switch(_(e)){case P:case"[object Array]":case"[object ArrayBuffer]":case"[object DataView]":case C:case"[object Date]":case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Map]":case A:case"[object Object]":case"[object RegExp]":case"[object Set]":case N:case"[object Symbol]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return!0;default:return!1}}(e)){const t=Object.create(Object.getPrototypeOf(e));return i.set(e,t),O(t,e,s,i,r),t}return e}function O(e,t,s=e,i,r){const n=[...Object.keys(t),...I(t)];for(let o=0;o<n.length;o++){const a=n[o],c=Object.getOwnPropertyDescriptor(e,a);(null==c||c.writable)&&(e[a]=S(t[a],a,s,i,r))}}function T(e){return function(e,t){return function(e,t){return S(e,void 0,e,new Map,t)}(e,(s,i,r,n)=>{const o=t?.(s,i,r,n);if(null!=o)return o;if("object"==typeof e)switch(Object.prototype.toString.call(e)){case A:case N:case C:{const t=new e.constructor(e?.valueOf());return O(t,e),t}case P:{const t={};return O(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}})}(e)}function k(e){return null!==e&&"object"==typeof e&&"[object Arguments]"===_(e)}function x(e){return v(e)}function R(e){if("object"!=typeof e||null==e)return!1;if(null===Object.getPrototypeOf(e))return!0;if("[object Object]"!==Object.prototype.toString.call(e)){const t=e[Symbol.toStringTag];return!(null==t||!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable)&&e.toString()===`[object ${t}]`}let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function U(e,t,s,i){if(b(e)&&(e=Object(e)),null==t||"object"!=typeof t)return e;if(i.has(t))return function(e){if(b(e))return e;if(Array.isArray(e)||v(e)||e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);const t=Object.getPrototypeOf(e),s=t.constructor;if(e instanceof Date||e instanceof Map||e instanceof Set)return new s(e);if(e instanceof RegExp){const t=new s(e);return t.lastIndex=e.lastIndex,t}if(e instanceof DataView)return new s(e.buffer.slice(0));if(e instanceof Error){const t=new s(e.message);return t.stack=e.stack,t.name=e.name,t.cause=e.cause,t}if(typeof File<"u"&&e instanceof File)return new s([e],e.name,{type:e.type,lastModified:e.lastModified});if("object"==typeof e){const s=Object.create(t);return Object.assign(s,e)}return e}(i.get(t));if(i.set(t,e),Array.isArray(t)){t=t.slice();for(let e=0;e<t.length;e++)t[e]=t[e]??void 0}const r=[...Object.keys(t),...I(t)];for(let n=0;n<r.length;n++){const o=r[n];let a=t[o],c=e[o];if(k(a)&&(a={...a}),k(c)&&(c={...c}),typeof p<"u"&&p.isBuffer(a)&&(a=T(a)),Array.isArray(a))if("object"==typeof c&&null!=c){const e=[],t=Reflect.ownKeys(c);for(let s=0;s<t.length;s++){const i=t[s];e[i]=c[i]}c=e}else c=[];const h=s(c,a,o,e,t,i);null!=h?e[o]=h:Array.isArray(a)||E(c)&&E(a)?e[o]=U(c,a,s,i):null==c&&R(a)?e[o]=U({},a,s,i):null==c&&x(a)?e[o]=T(a):(void 0===c||void 0!==a)&&(e[o]=a)}return e}var D=Object.defineProperty,j=Object.defineProperties,M=Object.getOwnPropertyDescriptors,L=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,B=(e,t,s)=>t in e?D(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,H=(e,t)=>{for(var s in t||(t={}))q.call(t,s)&&B(e,s,t[s]);if(L)for(var s of L(t))$.call(t,s)&&B(e,s,t[s]);return e},W=(e,t)=>j(e,M(t));function z(e,t,s){var i;const n=(0,r._Yb)(e);return(null==(i=t.rpcMap)?void 0:i[n.reference])||`${g}?chainId=${n.namespace}:${n.reference}&projectId=${s}`}function V(e){return e.includes(":")?e.split(":")[1]:e}function F(e){return e.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function K(e={},t={}){return function(e,...t){return function(e,...t){const s=t.slice(0,-1),i=t[t.length-1];let r=e;for(let e=0;e<s.length;e++)r=U(r,s[e],i,new Map);return r}(e,...t,y)}(G(e),G(t))}function G(e){var t,s,i,n;const o={};if(!(0,r.aF0)(e))return o;for(const[a,c]of Object.entries(e)){const e=(0,r.nWe)(a)?[a]:c.chains,h=c.methods||[],l=c.events||[],p=c.rpcMap||{},d=(0,r.kob)(a);o[d]=W(H(H({},o[d]),c),{chains:(0,r.TRk)(e,null==(t=o[d])?void 0:t.chains),methods:(0,r.TRk)(h,null==(s=o[d])?void 0:s.methods),events:(0,r.TRk)(l,null==(i=o[d])?void 0:i.events),rpcMap:H(H({},p),null==(n=o[d])?void 0:n.rpcMap)})}return o}function J(e){return e.includes(":")?e.split(":")[2]:e}function Y(e){const t={};for(const[s,i]of Object.entries(e)){const e=i.methods||[],n=i.events||[],o=i.accounts||[],a=(0,r.nWe)(s)?[s]:i.chains?i.chains:F(i.accounts);t[s]={chains:a,methods:e,events:n,accounts:o}}return t}function Q(e){return"number"==typeof e?e:e.includes("0x")?parseInt(e,16):(e=e.includes(":")?e.split(":")[1]:e,isNaN(Number(e))?e:Number(e))}const X={},Z=e=>X[e],ee=(e,t)=>{X[e]=t};var te=Object.defineProperty,se=(e,t,s)=>((e,t,s)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class ie{constructor(e){se(this,"name","polkadot"),se(this,"client"),se(this,"httpProviders"),se(this,"events"),se(this,"namespace"),se(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(w,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=V(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Z("disableProviderPing")))}}var re=Object.defineProperty,ne=Object.defineProperties,oe=Object.getOwnPropertyDescriptors,ae=Object.getOwnPropertySymbols,ce=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable,le=(e,t,s)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,pe=(e,t)=>{for(var s in t||(t={}))ce.call(t,s)&&le(e,s,t[s]);if(ae)for(var s of ae(t))he.call(t,s)&&le(e,s,t[s]);return e},de=(e,t)=>ne(e,oe(t)),ue=(e,t,s)=>le(e,"symbol"!=typeof t?t+"":t,s);class ge{constructor(e){ue(this,"name","eip155"),ue(this,"client"),ue(this,"chainId"),ue(this,"namespace"),ue(this,"httpProviders"),ue(this,"events"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(w,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const s=t||z(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.V(s,Z("disableProviderPing")))}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=parseInt(V(t));e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,s;let i=e.request.params?null==(t=e.request.params[0])?void 0:t.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const r=parseInt(i,16);if(this.isChainApproved(r))this.setDefaultChain(`${r}`);else{if(!this.namespace.methods.includes("wallet_switchEthereumChain"))throw new Error(`Failed to switch to chain 'eip155:${r}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:null==(s=this.namespace.chains)?void 0:s[0]}),this.setDefaultChain(`${r}`)}return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,s,i;const r=null==(s=null==(t=e.request)?void 0:t.params)?void 0:s[0];if(!r)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const n=this.client.session.get(e.topic),o=(null==(i=n?.sessionProperties)?void 0:i.capabilities)||{};if(null!=o&&o[r])return o?.[r];const a=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:de(pe({},n.sessionProperties||{}),{capabilities:de(pe({},o||{}),{[r]:a})})})}catch(e){console.warn("Failed to update session with capabilities",e)}return a}async getCallStatus(e){var t,s;const i=this.client.session.get(e.topic),r=null==(t=i.sessionProperties)?void 0:t.bundler_name;if(r){const t=this.getBundlerUrl(e.chainId,r);try{return await this.getUserOperationReceipt(t,e)}catch(e){console.warn("Failed to fetch call status from bundler",e,t)}}const n=null==(s=i.sessionProperties)?void 0:s.bundler_url;if(n)try{return await this.getUserOperationReceipt(n,e)}catch(e){console.warn("Failed to fetch call status from custom bundler",e,n)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var s;const i=new URL(e),r=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,c.formatJsonRpcRequest)("eth_getUserOperationReceipt",[null==(s=t.request.params)?void 0:s[0]]))});if(!r.ok)throw new Error(`Failed to fetch user operation receipt - ${r.status}`);return await r.json()}getBundlerUrl(e,t){return`${m}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}var fe=Object.defineProperty,me=(e,t,s)=>((e,t,s)=>t in e?fe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class we{constructor(e){me(this,"name","solana"),me(this,"client"),me(this,"httpProviders"),me(this,"events"),me(this,"namespace"),me(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(w,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=V(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Z("disableProviderPing")))}}var ye=Object.defineProperty,be=(e,t,s)=>((e,t,s)=>t in e?ye(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class ve{constructor(e){be(this,"name","cosmos"),be(this,"client"),be(this,"httpProviders"),be(this,"events"),be(this,"namespace"),be(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(w,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=V(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Z("disableProviderPing")))}}var Ee=Object.defineProperty,Ie=(e,t,s)=>((e,t,s)=>t in e?Ee(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class _e{constructor(e){Ie(this,"name","algorand"),Ie(this,"client"),Ie(this,"httpProviders"),Ie(this,"events"),Ie(this,"namespace"),Ie(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const s=t||z(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,s)}this.chainId=e,this.events.emit(w,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;e[t]=this.createHttpProvider(t,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace,this.client.core.projectId);return typeof s>"u"?void 0:new a.F(new o.A(s,Z("disableProviderPing")))}}var Ne=Object.defineProperty,Ae=(e,t,s)=>((e,t,s)=>t in e?Ne(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Ce{constructor(e){Ae(this,"name","cip34"),Ae(this,"client"),Ae(this,"httpProviders"),Ae(this,"events"),Ae(this,"namespace"),Ae(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(w,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const s=this.getCardanoRPCUrl(t),i=V(t);e[i]=this.createHttpProvider(i,s)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||this.getCardanoRPCUrl(e);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Z("disableProviderPing")))}}var Pe=Object.defineProperty,Se=(e,t,s)=>((e,t,s)=>t in e?Pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Oe{constructor(e){Se(this,"name","elrond"),Se(this,"client"),Se(this,"httpProviders"),Se(this,"events"),Se(this,"namespace"),Se(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(w,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=V(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Z("disableProviderPing")))}}var Te=Object.defineProperty,ke=(e,t,s)=>((e,t,s)=>t in e?Te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class xe{constructor(e){ke(this,"name","multiversx"),ke(this,"client"),ke(this,"httpProviders"),ke(this,"events"),ke(this,"namespace"),ke(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(w,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=V(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Z("disableProviderPing")))}}var Re=Object.defineProperty,Ue=(e,t,s)=>((e,t,s)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class De{constructor(e){Ue(this,"name","near"),Ue(this,"client"),Ue(this,"httpProviders"),Ue(this,"events"),Ue(this,"namespace"),Ue(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const s=t||z(`${this.name}:${e}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,s)}this.events.emit(w,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;e[t]=this.createHttpProvider(t,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace);return typeof s>"u"?void 0:new a.F(new o.A(s,Z("disableProviderPing")))}}var je=Object.defineProperty,Me=(e,t,s)=>((e,t,s)=>t in e?je(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Le{constructor(e){Me(this,"name","tezos"),Me(this,"client"),Me(this,"httpProviders"),Me(this,"events"),Me(this,"namespace"),Me(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const s=t||z(`${this.name}:${e}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,s)}this.events.emit(w,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{e[t]=this.createHttpProvider(t)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace);return typeof s>"u"?void 0:new a.F(new o.A(s))}}var qe=Object.defineProperty,$e=(e,t,s)=>((e,t,s)=>t in e?qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Be{constructor(e){$e(this,"name",f),$e(this,"client"),$e(this,"httpProviders"),$e(this,"events"),$e(this,"namespace"),$e(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(w,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){var e,t;const s={};return null==(t=null==(e=this.namespace)?void 0:e.accounts)||t.forEach(e=>{const t=(0,r._Yb)(e);s[`${t.namespace}:${t.reference}`]=this.createHttpProvider(e)}),s}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||z(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Z("disableProviderPing")))}}var He=Object.defineProperty,We=Object.defineProperties,ze=Object.getOwnPropertyDescriptors,Ve=Object.getOwnPropertySymbols,Fe=Object.prototype.hasOwnProperty,Ke=Object.prototype.propertyIsEnumerable,Ge=(e,t,s)=>t in e?He(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Je=(e,t)=>{for(var s in t||(t={}))Fe.call(t,s)&&Ge(e,s,t[s]);if(Ve)for(var s of Ve(t))Ke.call(t,s)&&Ge(e,s,t[s]);return e},Ye=(e,t)=>We(e,ze(t)),Qe=(e,t,s)=>Ge(e,"symbol"!=typeof t?t+"":t,s);class Xe{constructor(e){Qe(this,"client"),Qe(this,"namespaces"),Qe(this,"optionalNamespaces"),Qe(this,"sessionProperties"),Qe(this,"scopedProperties"),Qe(this,"events",new(l())),Qe(this,"rpcProviders",{}),Qe(this,"session"),Qe(this,"providerOpts"),Qe(this,"logger"),Qe(this,"uri"),Qe(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,n.h6)((0,n.iP)({level:e?.logger||d})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const t=new Xe(e);return await t.initialize(),t}async request(e,t,s){const[i,r]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:Je({},e),chainId:`${i}:${r}`,topic:this.session.topic,expiry:s})}sendAsync(e,t,s,i){const r=(new Date).getTime();this.request(e,s,i).then(e=>t(null,(0,c.formatJsonRpcResult)(r,e))).catch(e=>t(e,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:null==(e=this.session)?void 0:e.topic,reason:(0,r.Hjj)("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:s,response:i}=await this.client.authenticate(e,t);s&&(this.uri=s,this.events.emit("display_uri",s));const r=await i();if(this.session=r.session,this.session){const e=Y(this.session.namespaces);this.namespaces=K(this.namespaces,e),await this.persist("namespaces",this.namespaces),this.onConnect()}return r}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){const{uri:t,approval:s}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});t&&(this.uri=t,this.events.emit("display_uri",t));const i=await s();this.session=i;const r=Y(i.namespaces);return this.namespaces=K(this.namespaces,r),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[s,i]=this.validateChain(e),r=this.getProvider(s);r.name===f?r.setDefaultChain(`${s}:${i}`,t):r.setDefaultChain(i,t)}catch(e){if(!/Please call connect/.test(e.message))throw e}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if((0,r.OP1)(t)){for(const s of t)e.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var e,t;if(this.client=this.providerOpts.client||await i.Ay.init({core:this.providerOpts.core,logger:this.providerOpts.logger||d,relayUrl:this.providerOpts.relayUrl||"wss://relay.walletconnect.org",projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(s){throw this.logger.error("Failed to get session",s),new Error(`The provided session: ${null==(t=null==(e=this.providerOpts)?void 0:e.session)?void 0:t.topic} doesn't exist in the Sign client`)}else{const e=this.client.session.getAll();this.session=e[0]}this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(e=>(0,r.kob)(e)))];ee("client",this.client),ee("events",this.events),ee("disableProviderPing",this.disableProviderPing),e.forEach(e=>{if(!this.session)return;const t=function(e,t){const s=Object.keys(t.namespaces).filter(t=>t.includes(e));if(!s.length)return[];const i=[];return s.forEach(e=>{const s=t.namespaces[e].accounts;i.push(...s)}),i}(e,this.session),s=F(t),i=K(this.namespaces,this.optionalNamespaces),r=Ye(Je({},i[e]),{accounts:t,chains:s});switch(e){case"eip155":this.rpcProviders[e]=new ge({namespace:r});break;case"algorand":this.rpcProviders[e]=new _e({namespace:r});break;case"solana":this.rpcProviders[e]=new we({namespace:r});break;case"cosmos":this.rpcProviders[e]=new ve({namespace:r});break;case"polkadot":this.rpcProviders[e]=new ie({namespace:r});break;case"cip34":this.rpcProviders[e]=new Ce({namespace:r});break;case"elrond":this.rpcProviders[e]=new Oe({namespace:r});break;case"multiversx":this.rpcProviders[e]=new xe({namespace:r});break;case"near":this.rpcProviders[e]=new De({namespace:r});break;case"tezos":this.rpcProviders[e]=new Le({namespace:r});break;default:this.rpcProviders[f]?this.rpcProviders[f].updateNamespace(r):this.rpcProviders[f]=new Be({namespace:r})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var t;const{topic:s}=e;s===(null==(t=this.session)?void 0:t.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var t;const{params:s,topic:i}=e;if(i!==(null==(t=this.session)?void 0:t.topic))return;const{event:n}=s;if("accountsChanged"===n.name){const e=n.data;e&&(0,r.OP1)(e)&&this.events.emit("accountsChanged",e.map(J))}else if("chainChanged"===n.name){const e=s.chainId,t=s.event.data,i=(0,r.kob)(e),n=Q(e)!==Q(t)?`${i}:${Q(t)}`:e;this.onChainChanged(n)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var s,i;if(e!==(null==(s=this.session)?void 0:s.topic))return;const{namespaces:r}=t,n=null==(i=this.client)?void 0:i.session.get(e);this.session=Ye(Je({},n),{namespaces:r}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{var t;e.topic===(null==(t=this.session)?void 0:t.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Ye(Je({},(0,r.Hjj)("USER_DISCONNECTED")),{data:e.topic})))}),this.on(w,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[f]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace(null==(t=this.session)?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:s,sessionProperties:i,scopedProperties:r}=e;t&&Object.keys(t).length&&(this.namespaces=t),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=i,this.scopedProperties=r}validateChain(e){const[t,s]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,s];if(t&&!Object.keys(this.namespaces||{}).map(e=>(0,r.kob)(e)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&s)return[t,s];const i=(0,r.kob)(Object.keys(this.namespaces)[0]);return[i,this.rpcProviders[i].getDefaultChain()]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged(e,t=!1){if(!this.namespaces)return;const[s,i]=this.validateChain(e);i&&(t||this.getProvider(s).setDefaultChain(i),this.namespaces[s]?this.namespaces[s].defaultChain=i:this.namespaces[`${s}:${i}`]?this.namespaces[`${s}:${i}`].defaultChain=i:this.namespaces[`${s}:${i}`]={defaultChain:i},this.events.emit("chainChanged",i),await this.persist("namespaces",this.namespaces))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,await this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,t){var s;const i=(null==(s=this.session)?void 0:s.topic)||"";await this.client.core.storage.setItem(`${u}/${e}${i}`,t)}async getFromStore(e){var t;const s=(null==(t=this.session)?void 0:t.topic)||"";return await this.client.core.storage.getItem(`${u}/${e}${s}`)}async deleteFromStore(e){var t;const s=(null==(t=this.session)?void 0:t.topic)||"";await this.client.core.storage.removeItem(`${u}/${e}${s}`)}async cleanupStorage(){var e;try{if((null==(e=this.client)?void 0:e.session.length)>0)return;const t=await this.client.core.storage.getKeys();for(const e of t)e.startsWith(u)&&await this.client.core.storage.removeItem(e)}catch(e){this.logger.warn("Failed to cleanup storage",e)}}}},3496:(e,t,s)=>{s.d(t,{r:()=>h});var i=s(23464),r=s(38851),n=s(25562),o=s(93384);i.extend(n),i.extend(o);const a={...r,name:"en-web3-modal",relativeTime:{future:"in %s",past:"%s ago",s:"%d sec",m:"1 min",mm:"%d min",h:"1 hr",hh:"%d hrs",d:"1 d",dd:"%d d",M:"1 mo",MM:"%d mo",y:"1 yr",yy:"%d yr"}},c=["January","February","March","April","May","June","July","August","September","October","November","December"];i.locale("en-web3-modal",a);const h={getMonthNameByIndex:e=>c[e],getYear:(e=(new Date).toISOString())=>i(e).year(),getRelativeDateFromNow:e=>i(e).locale("en-web3-modal").fromNow(!0),formatDate:(e,t="DD MMM")=>i(e).format(t)}},3665:(e,t,s)=>{s.d(t,{$Q:()=>b,GF:()=>y,S9:()=>I,Vx:()=>m,ZP:()=>c,dQ:()=>p,lZ:()=>l,m5:()=>u,mF:()=>f,pi:()=>g,qE:()=>d,yJ:()=>_,zl:()=>w});var i=s(94549),r=s(50046),n=s.n(r),o=Object.defineProperty,a=(e,t,s)=>((e,t,s)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class c extends i.H{constructor(e){super(),this.opts=e,a(this,"protocol","wc"),a(this,"version",2)}}var h=Object.defineProperty;class l extends i.H{constructor(e,t){super(),this.core=e,this.logger=t,((e,t,s)=>{((e,t,s)=>{t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s})(e,"symbol"!=typeof t?t+"":t,s)})(this,"records",new Map)}}class p{constructor(e,t){this.logger=e,this.core=t}}class d extends i.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class u extends i.H{constructor(e){super()}}class g{constructor(e,t,s,i){this.core=e,this.logger=t,this.name=s}}Object.defineProperty;class f extends i.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class m extends i.H{constructor(e,t){super(),this.core=e,this.logger=t}}class w{constructor(e,t,s){this.core=e,this.logger=t,this.store=s}}class y{constructor(e,t){this.projectId=e,this.logger=t}}class b{constructor(e,t,s){this.core=e,this.logger=t,this.telemetryEnabled=s}}var v=Object.defineProperty,E=(e,t,s)=>((e,t,s)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);n();class I{constructor(e){this.opts=e,E(this,"protocol","wc"),E(this,"version",2)}}r.EventEmitter;class _{constructor(e){this.client=e}}},5813:(e,t,s)=>{s.d(t,{w:()=>o});var i=s(95191),r=s(84253),n=s(11553);const o={isMobile(){return!!this.isClient()&&Boolean(window?.matchMedia("(pointer:coarse)")?.matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent))},checkCaipNetwork:(e,t="")=>e?.caipNetworkId.toLocaleLowerCase().includes(t.toLowerCase()),isAndroid(){if(!this.isMobile())return!1;const e=window?.navigator.userAgent.toLowerCase();return o.isMobile()&&e.includes("android")},isIos(){if(!this.isMobile())return!1;const e=window?.navigator.userAgent.toLowerCase();return e.includes("iphone")||e.includes("ipad")},isSafari(){if(!this.isClient())return!1;const e=window?.navigator.userAgent.toLowerCase();return e.includes("safari")},isClient:()=>"undefined"!=typeof window,isPairingExpired:e=>!e||e-Date.now()<=r.oU.TEN_SEC_MS,isAllowedRetry:(e,t=r.oU.ONE_SEC_MS)=>Date.now()-e>=t,copyToClopboard(e){navigator.clipboard.writeText(e)},isIframe(){try{return window?.self!==window?.top}catch(e){return!1}},getPairingExpiry:()=>Date.now()+r.oU.FOUR_MINUTES_MS,getNetworkId:e=>e?.split(":")[1],getPlainAddress:e=>e?.split(":")[2],wait:async e=>new Promise(t=>{setTimeout(t,e)}),debounce(e,t=500){let s;return(...i)=>{s&&clearTimeout(s),s=setTimeout(function(){e(...i)},t)}},isHttpUrl:e=>e.startsWith("http://")||e.startsWith("https://"),formatNativeUrl(e,t){if(o.isHttpUrl(e))return this.formatUniversalUrl(e,t);let s=e;return s.includes("://")||(s=e.replaceAll("/","").replaceAll(":",""),s=`${s}://`),s.endsWith("/")||(s=`${s}/`),this.isTelegram()&&this.isAndroid()&&(t=encodeURIComponent(t)),{redirect:`${s}wc?uri=${encodeURIComponent(t)}`,href:s}},formatUniversalUrl(e,t){if(!o.isHttpUrl(e))return this.formatNativeUrl(e,t);let s=e;return s.endsWith("/")||(s=`${s}/`),{redirect:`${s}wc?uri=${encodeURIComponent(t)}`,href:s}},getOpenTargetForPlatform(e){return"popupWindow"===e?e:this.isTelegram()?n.i.getTelegramSocialProvider()?"_top":"_blank":e},openHref(e,t,s){window?.open(e,this.getOpenTargetForPlatform(t),s||"noreferrer noopener")},returnOpenHref(e,t,s){return window?.open(e,this.getOpenTargetForPlatform(t),s||"noreferrer noopener")},isTelegram:()=>"undefined"!=typeof window&&(Boolean(window.TelegramWebviewProxy)||Boolean(window.Telegram)||Boolean(window.TelegramWebviewProxyProto)),async preloadImage(e){const t=new Promise((t,s)=>{const i=new Image;i.onload=t,i.onerror=s,i.crossOrigin="anonymous",i.src=e});return Promise.race([t,o.wait(2e3)])},formatBalance(e,t){let s="0.000";if("string"==typeof e){const t=Number(e);if(t){const e=Math.floor(1e3*t)/1e3;e&&(s=e.toString())}}return`${s}${t?` ${t}`:""}`},formatBalance2(e,t){let s;if("0"===e)s="0";else if("string"==typeof e){const t=Number(e);t&&(s=t.toString().match(/^-?\d+(?:\.\d{0,3})?/u)?.[0])}return{value:s??"0",rest:"0"===s?"000":"",symbol:t}},getApiUrl:()=>i.o.W3M_API_URL,getBlockchainApiUrl:()=>i.o.BLOCKCHAIN_API_RPC_URL,getAnalyticsUrl:()=>i.o.PULSE_API_URL,getUUID:()=>crypto?.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),parseError:e=>"string"==typeof e?e:"string"==typeof e?.issues?.[0]?.message?e.issues[0].message:e instanceof Error?e.message:"Unknown error",sortRequestedNetworks(e,t=[]){const s={};return t&&e&&(e.forEach((e,t)=>{s[e]=t}),t.sort((e,t)=>{const i=s[e.id],r=s[t.id];return void 0!==i&&void 0!==r?i-r:void 0!==i?-1:void 0!==r?1:0})),t},calculateBalance(e){let t=0;for(const s of e)t+=s.value??0;return t},formatTokenBalance(e){const t=e.toFixed(2),[s,i]=t.split(".");return{dollars:s,pennies:i}},isAddress(e,t="eip155"){switch(t){case"eip155":return!(!/^(?:0x)?[0-9a-f]{40}$/iu.test(e)||!/^(?:0x)?[0-9a-f]{40}$/iu.test(e)&&!/^(?:0x)?[0-9A-F]{40}$/iu.test(e));case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(e);default:return!1}},uniqueBy(e,t){const s=new Set;return e.filter(e=>{const i=e[t];return!s.has(i)&&(s.add(i),!0)})},generateSdkVersion:(e,t,s)=>`${t}-${0===e.length?r.oU.ADAPTER_TYPES.UNIVERSAL:e.map(e=>e.adapterType).join(",")}-${s}`,createAccount:(e,t,s,i,r)=>({namespace:e,address:t,type:s,publicKey:i,path:r}),isCaipAddress(e){if("string"!=typeof e)return!1;const t=e.split(":"),s=t[0];return 3===t.filter(Boolean).length&&s in i.o.CHAIN_NAME_MAP},isMac(){const e=window?.navigator.userAgent.toLowerCase();return e.includes("macintosh")&&!e.includes("safari")},formatTelegramSocialLoginUrl(e){const t=`--${encodeURIComponent(window?.location.href)}`,s="state=";if("auth.magic.link"===new URL(e).host){const i="provider_authorization_url=",r=e.substring(e.indexOf(i)+i.length),n=this.injectIntoUrl(decodeURIComponent(r),s,t);return e.replace(r,encodeURIComponent(n))}return this.injectIntoUrl(e,s,t)},injectIntoUrl(e,t,s){const i=e.indexOf(t);if(-1===i)throw new Error(`${t} parameter not found in the URL: ${e}`);const r=e.indexOf("&",i),n=t.length,o=-1!==r?r:e.length;return e.substring(0,i+n)+(e.substring(i+n,o)+s)+e.substring(r)}}},8834:(e,t,s)=>{s.d(t,{v:()=>a});var i=s(10550),r=s(49009),n=s(55770),o=s(95191);const a={getERC20Abi:e=>o.o.USDT_CONTRACT_ADDRESSES.includes(e)?n.r:i.F,getSwapAbi:()=>r.Q}},9663:(e,t,s)=>{s.d(t,{Vl:()=>r});var i=s(39907);void 0!==i&&void 0!==i.env&&i.env.NEXT_PUBLIC_SECURE_SITE_SDK_URL,void 0!==i&&void 0!==i.env&&i.env.NEXT_PUBLIC_DEFAULT_LOG_LEVEL,void 0!==i&&void 0!==i.env&&i.env.NEXT_PUBLIC_SECURE_SITE_SDK_VERSION;const r={SAFE_RPC_METHODS:["eth_accounts","eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","eth_feeHistory","eth_gasPrice","eth_getAccount","eth_getBalance","eth_getBlockByHash","eth_getBlockByNumber","eth_getBlockReceipts","eth_getBlockTransactionCountByHash","eth_getBlockTransactionCountByNumber","eth_getCode","eth_getFilterChanges","eth_getFilterLogs","eth_getLogs","eth_getProof","eth_getStorageAt","eth_getTransactionByBlockHashAndIndex","eth_getTransactionByBlockNumberAndIndex","eth_getTransactionByHash","eth_getTransactionCount","eth_getTransactionReceipt","eth_getUncleCountByBlockHash","eth_getUncleCountByBlockNumber","eth_maxPriorityFeePerGas","eth_newBlockFilter","eth_newFilter","eth_newPendingTransactionFilter","eth_sendRawTransaction","eth_syncing","eth_uninstallFilter","wallet_getCapabilities","wallet_getCallsStatus","eth_getUserOperationReceipt","eth_estimateUserOperationGas","eth_getUserOperationByHash","eth_supportedEntryPoints","wallet_getAssets"],NOT_SAFE_RPC_METHODS:["personal_sign","eth_signTypedData_v4","eth_sendTransaction","solana_signMessage","solana_signTransaction","solana_signAllTransactions","solana_signAndSendTransaction","wallet_sendCalls","wallet_grantPermissions","wallet_revokePermissions","eth_sendUserOperation"],GET_CHAIN_ID:"eth_chainId",RPC_METHOD_NOT_ALLOWED_MESSAGE:"Requested RPC call is not allowed",RPC_METHOD_NOT_ALLOWED_UI_MESSAGE:"Action not allowed",ACCOUNT_TYPES:{EOA:"eoa",SMART_ACCOUNT:"smartAccount"}}},10550:(e,t,s)=>{s.d(t,{F:()=>i});const i=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]}]},11553:(e,t,s)=>{s.d(t,{i:()=>r});var i=s(32681);const r={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5},isCacheExpired:(e,t)=>Date.now()-e>t,getActiveNetworkProps(){const e=r.getActiveNamespace(),t=r.getActiveCaipNetworkId(),s=t?t.split(":")[1]:void 0;return{namespace:e,caipNetworkId:t,chainId:s?isNaN(Number(s))?s:Number(s):void 0}},setWalletConnectDeepLink({name:e,href:t}){try{i.Ud.setItem(i.Ws.DEEPLINK_CHOICE,JSON.stringify({href:t,name:e}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const e=i.Ud.getItem(i.Ws.DEEPLINK_CHOICE);if(e)return JSON.parse(e)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{i.Ud.removeItem(i.Ws.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(e){try{i.Ud.setItem(i.Ws.ACTIVE_NAMESPACE,e)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(e){try{i.Ud.setItem(i.Ws.ACTIVE_CAIP_NETWORK_ID,e),r.setActiveNamespace(e.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return i.Ud.getItem(i.Ws.ACTIVE_CAIP_NETWORK_ID)}catch{return void console.info("Unable to get active caip network id")}},deleteActiveCaipNetworkId(){try{i.Ud.removeItem(i.Ws.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(e){try{const t=(0,i.T8)(e);i.Ud.removeItem(t)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(e){try{const t=r.getRecentWallets();t.find(t=>t.id===e.id)||(t.unshift(e),t.length>2&&t.pop(),i.Ud.setItem(i.Ws.RECENT_WALLETS,JSON.stringify(t)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const e=i.Ud.getItem(i.Ws.RECENT_WALLETS);return e?JSON.parse(e):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(e,t){try{const s=(0,i.T8)(e);i.Ud.setItem(s,t)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return i.Ud.getItem(i.Ws.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(e){if(e)try{const t=(0,i.T8)(e);return i.Ud.getItem(t)}catch(t){console.info("Unable to get connected connector id in namespace ",e)}},setConnectedSocialProvider(e){try{i.Ud.setItem(i.Ws.CONNECTED_SOCIAL,e)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return i.Ud.getItem(i.Ws.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{i.Ud.removeItem(i.Ws.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return i.Ud.getItem(i.Ws.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){const e=i.Ud.getItem(i.Ws.ACTIVE_CAIP_NETWORK_ID),t=e?.split(":")?.[1];return t},setConnectionStatus(e){try{i.Ud.setItem(i.Ws.CONNECTION_STATUS,e)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return i.Ud.getItem(i.Ws.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const e=i.Ud.getItem(i.Ws.CONNECTED_NAMESPACES);return e?.length?e.split(","):[]}catch{return[]}},setConnectedNamespaces(e){try{const t=Array.from(new Set(e));i.Ud.setItem(i.Ws.CONNECTED_NAMESPACES,t.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(e){try{const t=r.getConnectedNamespaces();t.includes(e)||(t.push(e),r.setConnectedNamespaces(t))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(e){try{const t=r.getConnectedNamespaces(),s=t.indexOf(e);s>-1&&(t.splice(s,1),r.setConnectedNamespaces(t))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return i.Ud.getItem(i.Ws.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(e){try{i.Ud.setItem(i.Ws.TELEGRAM_SOCIAL_PROVIDER,e)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{i.Ud.removeItem(i.Ws.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let e={};try{const t=i.Ud.getItem(i.Ws.PORTFOLIO_CACHE);e=t?JSON.parse(t):{}}catch{console.info("Unable to get balance cache")}return e},removeAddressFromBalanceCache(e){try{const t=r.getBalanceCache();i.Ud.setItem(i.Ws.PORTFOLIO_CACHE,JSON.stringify({...t,[e]:void 0}))}catch{console.info("Unable to remove address from balance cache",e)}},getBalanceCacheForCaipAddress(e){try{const t=r.getBalanceCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.portfolio))return t.balance;r.removeAddressFromBalanceCache(e)}catch{console.info("Unable to get balance cache for address",e)}},updateBalanceCache(e){try{const t=r.getBalanceCache();t[e.caipAddress]=e,i.Ud.setItem(i.Ws.PORTFOLIO_CACHE,JSON.stringify(t))}catch{console.info("Unable to update balance cache",e)}},getNativeBalanceCache(){let e={};try{const t=i.Ud.getItem(i.Ws.NATIVE_BALANCE_CACHE);e=t?JSON.parse(t):{}}catch{console.info("Unable to get balance cache")}return e},removeAddressFromNativeBalanceCache(e){try{const t=r.getBalanceCache();i.Ud.setItem(i.Ws.NATIVE_BALANCE_CACHE,JSON.stringify({...t,[e]:void 0}))}catch{console.info("Unable to remove address from balance cache",e)}},getNativeBalanceCacheForCaipAddress(e){try{const t=r.getNativeBalanceCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.nativeBalance))return t;console.info("Discarding cache for address",e),r.removeAddressFromBalanceCache(e)}catch{console.info("Unable to get balance cache for address",e)}},updateNativeBalanceCache(e){try{const t=r.getNativeBalanceCache();t[e.caipAddress]=e,i.Ud.setItem(i.Ws.NATIVE_BALANCE_CACHE,JSON.stringify(t))}catch{console.info("Unable to update balance cache",e)}},getEnsCache(){let e={};try{const t=i.Ud.getItem(i.Ws.ENS_CACHE);e=t?JSON.parse(t):{}}catch{console.info("Unable to get ens name cache")}return e},getEnsFromCacheForAddress(e){try{const t=r.getEnsCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.ens))return t.ens;r.removeEnsFromCache(e)}catch{console.info("Unable to get ens name from cache",e)}},updateEnsCache(e){try{const t=r.getEnsCache();t[e.address]=e,i.Ud.setItem(i.Ws.ENS_CACHE,JSON.stringify(t))}catch{console.info("Unable to update ens name cache",e)}},removeEnsFromCache(e){try{const t=r.getEnsCache();i.Ud.setItem(i.Ws.ENS_CACHE,JSON.stringify({...t,[e]:void 0}))}catch{console.info("Unable to remove ens name from cache",e)}},getIdentityCache(){let e={};try{const t=i.Ud.getItem(i.Ws.IDENTITY_CACHE);e=t?JSON.parse(t):{}}catch{console.info("Unable to get identity cache")}return e},getIdentityFromCacheForAddress(e){try{const t=r.getIdentityCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.identity))return t.identity;r.removeIdentityFromCache(e)}catch{console.info("Unable to get identity from cache",e)}},updateIdentityCache(e){try{const t=r.getIdentityCache();t[e.address]={identity:e.identity,timestamp:e.timestamp},i.Ud.setItem(i.Ws.IDENTITY_CACHE,JSON.stringify(t))}catch{console.info("Unable to update identity cache",e)}},removeIdentityFromCache(e){try{const t=r.getIdentityCache();i.Ud.setItem(i.Ws.IDENTITY_CACHE,JSON.stringify({...t,[e]:void 0}))}catch{console.info("Unable to remove identity from cache",e)}},clearAddressCache(){try{i.Ud.removeItem(i.Ws.PORTFOLIO_CACHE),i.Ud.removeItem(i.Ws.NATIVE_BALANCE_CACHE),i.Ud.removeItem(i.Ws.ENS_CACHE),i.Ud.removeItem(i.Ws.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}}}},11629:(e,t,s)=>{s.d(t,{$I:()=>Q,$w:()=>J,Jf:()=>S,S$:()=>Y,Tn:()=>ee,U:()=>X,U$:()=>Z,WB:()=>F,cV:()=>U,iJ:()=>Ys,il:()=>ys,sD:()=>C,wn:()=>z,zN:()=>$});var i=s(50046),r=s.n(i),n=s(37147),o=s(81030),a=s(70255),c=s(3665),h=s(91315),l=s(25607),p=s(97353),d=s(76754),u=s(1030),g=s(93786),f=s(14350),m=s(63342),w=s(18677),y=s.n(w),b=s(20635);const v="core",E=`wc@2:${v}:`,I={database:":memory:"},_="client_ed25519_seed",N=h.ONE_DAY,A=h.SIX_HOURS,C="irn",P="wss://relay.walletconnect.org",S={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},O="payload",T="connect",k="disconnect",x="error",R="2.19.0",U={link_mode:"link_mode",relay:"relay"},D="WALLETCONNECT_LINK_MODE_APPS",j="subscription_created",M="subscription_deleted",L=1e3*h.FIVE_SECONDS,q={wc_pairingDelete:{req:{ttl:h.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:h.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:h.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:h.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:h.ONE_DAY,prompt:!1,tag:0},res:{ttl:h.ONE_DAY,prompt:!1,tag:0}}},$={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},B="history_created",H="history_updated",W="history_deleted",z={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},V="https://verify.walletconnect.org",F=V,K=`${F}/v3`,G=["https://verify.walletconnect.com",V],J={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},Y={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},Q={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},X={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Z={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},ee={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"};const te=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class se{constructor(e,t,s){this.name=e,this.prefix=t,this.baseEncode=s}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class ie{constructor(e,t,s){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=s}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return ne(this,e)}}class re{constructor(e){this.decoders=e}or(e){return ne(this,e)}decode(e){const t=e[0],s=this.decoders[t];if(s)return s.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const ne=(e,t)=>new re({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class oe{constructor(e,t,s,i){this.name=e,this.prefix=t,this.baseEncode=s,this.baseDecode=i,this.encoder=new se(e,t,s),this.decoder=new ie(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const ae=({name:e,prefix:t,encode:s,decode:i})=>new oe(e,t,s,i),ce=({prefix:e,name:t,alphabet:s})=>{const{encode:i,decode:r}=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),i=0;i<s.length;i++)s[i]=255;for(var r=0;r<e.length;r++){var n=e.charAt(r),o=n.charCodeAt(0);if(255!==s[o])throw new TypeError(n+" is ambiguous");s[o]=r}var a=e.length,c=e.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function p(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var i=0,r=0;e[t]===c;)i++,t++;for(var n=(e.length-t)*h+1>>>0,o=new Uint8Array(n);e[t];){var l=s[e.charCodeAt(t)];if(255===l)return;for(var p=0,d=n-1;(0!==l||p<r)&&-1!==d;d--,p++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");r=p,t++}if(" "!==e[t]){for(var u=n-r;u!==n&&0===o[u];)u++;for(var g=new Uint8Array(i+(n-u)),f=i;u!==n;)g[f++]=o[u++];return g}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var s=0,i=0,r=0,n=t.length;r!==n&&0===t[r];)r++,s++;for(var o=(n-r)*l+1>>>0,h=new Uint8Array(o);r!==n;){for(var p=t[r],d=0,u=o-1;(0!==p||d<i)&&-1!==u;u--,d++)p+=256*h[u]>>>0,h[u]=p%a>>>0,p=p/a>>>0;if(0!==p)throw new Error("Non-zero carry");i=d,r++}for(var g=o-i;g!==o&&0===h[g];)g++;for(var f=c.repeat(s);g<o;++g)f+=e.charAt(h[g]);return f},decodeUnsafe:p,decode:function(e){var s=p(e);if(s)return s;throw new Error(`Non-${t} character`)}}}(s,t);return ae({prefix:e,name:t,encode:i,decode:e=>te(r(e))})},he=({name:e,prefix:t,bitsPerChar:s,alphabet:i})=>ae({prefix:t,name:e,encode:e=>((e,t,s)=>{const i="="===t[t.length-1],r=(1<<s)-1;let n="",o=0,a=0;for(let i=0;i<e.length;++i)for(a=a<<8|e[i],o+=8;o>s;)o-=s,n+=t[r&a>>o];if(o&&(n+=t[r&a<<s-o]),i)for(;n.length*s&7;)n+="=";return n})(e,i,s),decode:t=>((e,t,s,i)=>{const r={};for(let e=0;e<t.length;++e)r[t[e]]=e;let n=e.length;for(;"="===e[n-1];)--n;const o=new Uint8Array(n*s/8|0);let a=0,c=0,h=0;for(let t=0;t<n;++t){const n=r[e[t]];if(void 0===n)throw new SyntaxError(`Non-${i} character`);c=c<<s|n,a+=s,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=s||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,i,s,e)}),le=ae({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var pe=Object.freeze({__proto__:null,identity:le});const de=he({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ue=Object.freeze({__proto__:null,base2:de});const ge=he({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var fe=Object.freeze({__proto__:null,base8:ge});const me=ce({prefix:"9",name:"base10",alphabet:"0123456789"});var we=Object.freeze({__proto__:null,base10:me});const ye=he({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),be=he({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ve=Object.freeze({__proto__:null,base16:ye,base16upper:be});const Ee=he({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ie=he({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),_e=he({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ne=he({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ae=he({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ce=he({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Pe=he({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Se=he({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Oe=he({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Te=Object.freeze({__proto__:null,base32:Ee,base32upper:Ie,base32pad:_e,base32padupper:Ne,base32hex:Ae,base32hexupper:Ce,base32hexpad:Pe,base32hexpadupper:Se,base32z:Oe});const ke=ce({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),xe=ce({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Re=Object.freeze({__proto__:null,base36:ke,base36upper:xe});const Ue=ce({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),De=ce({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var je=Object.freeze({__proto__:null,base58btc:Ue,base58flickr:De});const Me=he({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Le=he({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),qe=he({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$e=he({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Be=Object.freeze({__proto__:null,base64:Me,base64pad:Le,base64url:qe,base64urlpad:$e});const He=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),We=He.reduce((e,t,s)=>(e[s]=t,e),[]),ze=He.reduce((e,t,s)=>(e[t.codePointAt(0)]=s,e),[]),Ve=ae({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce((e,t)=>e+We[t],"")},decode:function(e){const t=[];for(const s of e){const e=ze[s.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${s}`);t.push(e)}return new Uint8Array(t)}});var Fe=Object.freeze({__proto__:null,base256emoji:Ve}),Ke=128,Ge=-128,Je=Math.pow(2,31),Ye=Math.pow(2,7),Qe=Math.pow(2,14),Xe=Math.pow(2,21),Ze=Math.pow(2,28),et=Math.pow(2,35),tt=Math.pow(2,42),st=Math.pow(2,49),it=Math.pow(2,56),rt=Math.pow(2,63),nt=function e(t,s,i){s=s||[];for(var r=i=i||0;t>=Je;)s[i++]=255&t|Ke,t/=128;for(;t&Ge;)s[i++]=255&t|Ke,t>>>=7;return s[i]=0|t,e.bytes=i-r+1,s},ot=function(e){return e<Ye?1:e<Qe?2:e<Xe?3:e<Ze?4:e<et?5:e<tt?6:e<st?7:e<it?8:e<rt?9:10};const at=(e,t,s=0)=>(nt(e,t,s),t),ct=e=>ot(e),ht=(e,t)=>{const s=t.byteLength,i=ct(e),r=i+ct(s),n=new Uint8Array(r+s);return at(e,n,0),at(s,n,i),n.set(t,r),new lt(e,s,t,n)};class lt{constructor(e,t,s,i){this.code=e,this.size=t,this.digest=s,this.bytes=i}}const pt=({name:e,code:t,encode:s})=>new dt(e,t,s);class dt{constructor(e,t,s){this.name=e,this.code=t,this.encode=s}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ht(this.code,t):t.then(e=>ht(this.code,e))}throw Error("Unknown type, must be binary type")}}const ut=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),gt=pt({name:"sha2-256",code:18,encode:ut("SHA-256")}),ft=pt({name:"sha2-512",code:19,encode:ut("SHA-512")});Object.freeze({__proto__:null,sha256:gt,sha512:ft});const mt=te,wt={code:0,name:"identity",encode:mt,digest:e=>ht(0,mt(e))};Object.freeze({__proto__:null,identity:wt}),new TextEncoder,new TextDecoder;const yt={...pe,...ue,...fe,...we,...ve,...Te,...Re,...je,...Be,...Fe};function bt(e,t,s,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:s},decoder:{decode:i}}}const vt=bt("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>(new TextEncoder).encode(e.substring(1))),Et=bt("ascii","a",e=>{let t="a";for(let s=0;s<e.length;s++)t+=String.fromCharCode(e[s]);return t},e=>{const t=function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}((e=e.substring(1)).length);for(let s=0;s<e.length;s++)t[s]=e.charCodeAt(s);return t}),It={utf8:vt,"utf-8":vt,hex:yt.base16,latin1:Et,ascii:Et,binary:Et,...yt};var _t=Object.defineProperty,Nt=(e,t,s)=>((e,t,s)=>t in e?_t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class At{constructor(e,t){this.core=e,this.logger=t,Nt(this,"keychain",new Map),Nt(this,"name","keychain"),Nt(this,"version","0.3"),Nt(this,"initialized",!1),Nt(this,"storagePrefix",E),Nt(this,"init",async()=>{if(!this.initialized){const e=await this.getKeyChain();typeof e<"u"&&(this.keychain=e),this.initialized=!0}}),Nt(this,"has",e=>(this.isInitialized(),this.keychain.has(e))),Nt(this,"set",async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()}),Nt(this,"get",e=>{this.isInitialized();const t=this.keychain.get(e);if(typeof t>"u"){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}),Nt(this,"del",async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()}),this.core=e,this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,(0,d.h0Y)(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?(0,d.PUk)(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Ct=Object.defineProperty,Pt=(e,t,s)=>((e,t,s)=>t in e?Ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class St{constructor(e,t,s){this.core=e,this.logger=t,Pt(this,"name","crypto"),Pt(this,"keychain"),Pt(this,"randomSessionIdentifier",(0,d.two)()),Pt(this,"initialized",!1),Pt(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Pt(this,"hasKeys",e=>(this.isInitialized(),this.keychain.has(e))),Pt(this,"getClientId",async()=>{this.isInitialized();const e=await this.getClientSeed(),t=p.TZ(e);return p.UF(t.publicKey)}),Pt(this,"generateKeyPair",()=>{this.isInitialized();const e=(0,d.TZl)();return this.setPrivateKey(e.publicKey,e.privateKey)}),Pt(this,"signJWT",async e=>{this.isInitialized();const t=await this.getClientSeed(),s=p.TZ(t),i=this.randomSessionIdentifier,r=N;return await p.FA(i,e,r,s)}),Pt(this,"generateSharedKey",(e,t,s)=>{this.isInitialized();const i=this.getPrivateKey(e),r=(0,d.ovp)(i,t);return this.setSymKey(r,s)}),Pt(this,"setSymKey",async(e,t)=>{this.isInitialized();const s=t||(0,d.EN$)(e);return await this.keychain.set(s,e),s}),Pt(this,"deleteKeyPair",async e=>{this.isInitialized(),await this.keychain.del(e)}),Pt(this,"deleteSymKey",async e=>{this.isInitialized(),await this.keychain.del(e)}),Pt(this,"encode",async(e,t,s)=>{this.isInitialized();const i=(0,d.AwN)(s),r=(0,l.h)(t);if((0,d.ps1)(i))return(0,d.Tw2)(r,s?.encoding);if((0,d.V7m)(i)){const t=i.senderPublicKey,s=i.receiverPublicKey;e=await this.generateSharedKey(t,s)}const n=this.getSymKey(e),{type:o,senderPublicKey:a}=i;return(0,d.wa2)({type:o,symKey:n,message:r,senderPublicKey:a,encoding:s?.encoding})}),Pt(this,"decode",async(e,t,s)=>{this.isInitialized();const i=(0,d.C5G)(t,s);if((0,d.ps1)(i)){const e=(0,d.F$L)(t,s?.encoding);return(0,l.j)(e)}if((0,d.V7m)(i)){const t=i.receiverPublicKey,s=i.senderPublicKey;e=await this.generateSharedKey(t,s)}try{const i=this.getSymKey(e),r=(0,d.YcA)({symKey:i,encoded:t,encoding:s?.encoding});return(0,l.j)(r)}catch(t){this.logger.error(`Failed to decode message from topic: '${e}', clientId: '${await this.getClientId()}'`),this.logger.error(t)}}),Pt(this,"getPayloadType",(e,t=d.EWt)=>{const s=(0,d.iui)({encoded:e,encoding:t});return(0,d.x0t)(s.type)}),Pt(this,"getPayloadSenderPublicKey",(e,t=d.EWt)=>{const s=(0,d.iui)({encoded:e,encoding:t});return s.senderPublicKey?(0,u.dI)(s.senderPublicKey,d.bEt):void 0}),this.core=e,this.logger=(0,a.U5)(t,this.name),this.keychain=s||new At(this.core,this.logger)}get context(){return(0,a.oI)(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(_)}catch{e=(0,d.two)(),await this.keychain.set(_,e)}return function(e,t="utf8"){const s=It[t];if(!s)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?s.decoder.decode(`${s.prefix}${e}`):globalThis.Buffer.from(e,"utf8")}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Ot=Object.defineProperty,Tt=(e,t,s)=>((e,t,s)=>t in e?Ot(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class kt extends c.dQ{constructor(e,t){super(e,t),this.logger=e,this.core=t,Tt(this,"messages",new Map),Tt(this,"name","messages"),Tt(this,"version","0.3"),Tt(this,"initialized",!1),Tt(this,"storagePrefix",E),Tt(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const e=await this.getRelayerMessages();typeof e<"u"&&(this.messages=e),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}}),Tt(this,"set",async(e,t)=>{this.isInitialized();const s=(0,d.ALl)(t);let i=this.messages.get(e);return typeof i>"u"&&(i={}),typeof i[s]<"u"||(i[s]=t,this.messages.set(e,i),await this.persist()),s}),Tt(this,"get",e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t}),Tt(this,"has",(e,t)=>(this.isInitialized(),typeof this.get(e)[(0,d.ALl)(t)]<"u")),Tt(this,"del",async e=>{this.isInitialized(),this.messages.delete(e),await this.persist()}),this.logger=(0,a.U5)(e,this.name),this.core=t}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,(0,d.h0Y)(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?(0,d.PUk)(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var xt=Object.defineProperty,Rt=Object.defineProperties,Ut=Object.getOwnPropertyDescriptors,Dt=Object.getOwnPropertySymbols,jt=Object.prototype.hasOwnProperty,Mt=Object.prototype.propertyIsEnumerable,Lt=(e,t,s)=>t in e?xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,qt=(e,t)=>{for(var s in t||(t={}))jt.call(t,s)&&Lt(e,s,t[s]);if(Dt)for(var s of Dt(t))Mt.call(t,s)&&Lt(e,s,t[s]);return e},$t=(e,t)=>Rt(e,Ut(t)),Bt=(e,t,s)=>Lt(e,"symbol"!=typeof t?t+"":t,s);class Ht extends c.qE{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,Bt(this,"events",new i.EventEmitter),Bt(this,"name","publisher"),Bt(this,"queue",new Map),Bt(this,"publishTimeout",(0,h.toMiliseconds)(h.ONE_MINUTE)),Bt(this,"initialPublishTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),Bt(this,"needsTransportRestart",!1),Bt(this,"publish",async(e,t,s)=>{var i;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:s}});const r=s?.ttl||A,n=(0,d.n6V)(s),o=s?.prompt||!1,a=s?.tag||0,c=s?.id||(0,f.getBigIntRpcId)().toString(),h={topic:e,message:t,opts:{ttl:r,relay:n,prompt:o,tag:a,id:c,attestation:s?.attestation,tvf:s?.tvf}},l=`Failed to publish payload, please try again. id:${c} tag:${a}`;try{const i=new Promise(async i=>{const n=({id:e})=>{h.opts.id===e&&(this.removeRequestFromQueue(e),this.relayer.events.removeListener(S.publish,n),i(h))};this.relayer.events.on(S.publish,n);const l=(0,d.K3g)(new Promise((i,n)=>{this.rpcPublish({topic:e,message:t,ttl:r,prompt:o,tag:a,id:c,attestation:s?.attestation,tvf:s?.tvf}).then(i).catch(e=>{this.logger.warn(e,e?.message),n(e)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${c} tag:${a}`);try{await l,this.events.removeListener(S.publish,n)}catch(e){this.queue.set(c,$t(qt({},h),{attempt:1})),this.logger.warn(e,e?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:c,topic:e,message:t,opts:s}}),await(0,d.K3g)(i,this.publishTimeout,l)}catch(e){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(e),null!=(i=s?.internal)&&i.throwOnFailedPublish)throw e}finally{this.queue.delete(c)}}),Bt(this,"on",(e,t)=>{this.events.on(e,t)}),Bt(this,"once",(e,t)=>{this.events.once(e,t)}),Bt(this,"off",(e,t)=>{this.events.off(e,t)}),Bt(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.relayer=e,this.logger=(0,a.U5)(t,this.name),this.registerEventListeners()}get context(){return(0,a.oI)(this.logger)}async rpcPublish(e){var t,s,i,r;const{topic:n,message:o,ttl:a=A,prompt:c,tag:h,id:l,attestation:p,tvf:u}=e,g={method:(0,d.aa1)((0,d.n6V)().protocol).publish,params:qt({topic:n,message:o,ttl:a,prompt:c,tag:h,attestation:p},u),id:l};(0,d.b07)(null==(t=g.params)?void 0:t.prompt)&&(null==(s=g.params)||delete s.prompt),(0,d.b07)(null==(i=g.params)?void 0:i.tag)&&(null==(r=g.params)||delete r.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:g});const f=await this.relayer.request(g);return this.relayer.events.emit(S.publish,e),this.logger.debug("Successfully Published Payload"),f}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{const s=e.attempt+1;this.queue.set(t,$t(qt({},e),{attempt:s}));const{topic:i,message:r,opts:n,attestation:o}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${s}`),await this.rpcPublish($t(qt({},e),{topic:i,message:r,ttl:n.ttl,prompt:n.prompt,tag:n.tag,id:n.id,attestation:o,tvf:n.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(n.li.pulse,()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(S.connection_stalled);this.checkQueue()}),this.relayer.on(S.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var Wt=Object.defineProperty,zt=(e,t,s)=>((e,t,s)=>t in e?Wt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Vt{constructor(){zt(this,"map",new Map),zt(this,"set",(e,t)=>{const s=this.get(e);this.exists(e,t)||this.map.set(e,[...s,t])}),zt(this,"get",e=>this.map.get(e)||[]),zt(this,"exists",(e,t)=>this.get(e).includes(t)),zt(this,"delete",(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const s=this.get(e);if(!this.exists(e,t))return;const i=s.filter(e=>e!==t);i.length?this.map.set(e,i):this.map.delete(e)}),zt(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var Ft=Object.defineProperty,Kt=Object.defineProperties,Gt=Object.getOwnPropertyDescriptors,Jt=Object.getOwnPropertySymbols,Yt=Object.prototype.hasOwnProperty,Qt=Object.prototype.propertyIsEnumerable,Xt=(e,t,s)=>t in e?Ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Zt=(e,t)=>{for(var s in t||(t={}))Yt.call(t,s)&&Xt(e,s,t[s]);if(Jt)for(var s of Jt(t))Qt.call(t,s)&&Xt(e,s,t[s]);return e},es=(e,t)=>Kt(e,Gt(t)),ts=(e,t,s)=>Xt(e,"symbol"!=typeof t?t+"":t,s);class ss extends c.mF{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,ts(this,"subscriptions",new Map),ts(this,"topicMap",new Vt),ts(this,"events",new i.EventEmitter),ts(this,"name","subscription"),ts(this,"version","0.3"),ts(this,"pending",new Map),ts(this,"cached",[]),ts(this,"initialized",!1),ts(this,"pendingSubscriptionWatchLabel","pending_sub_watch_label"),ts(this,"pollingInterval",20),ts(this,"storagePrefix",E),ts(this,"subscribeTimeout",(0,h.toMiliseconds)(h.ONE_MINUTE)),ts(this,"initialSubscribeTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),ts(this,"clientId"),ts(this,"batchSubscribeTopicsLimit",500),ts(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),ts(this,"subscribe",async(e,t)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const s=(0,d.n6V)(t),i={topic:e,relay:s,transportType:t?.transportType};this.pending.set(e,i);const r=await this.rpcSubscribe(e,s,t);return"string"==typeof r&&(this.onSubscribe(r,i),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}})),r}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}}),ts(this,"unsubscribe",async(e,t)=>{this.isInitialized(),typeof t?.id<"u"?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)}),ts(this,"isSubscribed",async e=>{if(this.topics.includes(e))return!0;const t=`${this.pendingSubscriptionWatchLabel}_${e}`;return await new Promise((s,i)=>{const r=new h.Watch;r.start(t);const n=setInterval(()=>{(!this.pending.has(e)&&this.topics.includes(e)||this.cached.some(t=>t.topic===e))&&(clearInterval(n),r.stop(t),s(!0)),r.elapsed(t)>=L&&(clearInterval(n),r.stop(t),i(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)}),ts(this,"on",(e,t)=>{this.events.on(e,t)}),ts(this,"once",(e,t)=>{this.events.once(e,t)}),ts(this,"off",(e,t)=>{this.events.off(e,t)}),ts(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),ts(this,"start",async()=>{await this.onConnect()}),ts(this,"stop",async()=>{await this.onDisconnect()}),ts(this,"restart",async()=>{await this.restore(),await this.onRestart()}),ts(this,"checkPending",async()=>{if(!(0!==this.pending.size||this.initialized&&this.relayer.connected))return;const e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e)}),ts(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(n.li.pulse,async()=>{await this.checkPending()}),this.events.on(j,async e=>{const t=j;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(M,async e=>{const t=M;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}),this.relayer=e,this.logger=(0,a.U5)(t,this.name),this.clientId=""}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,t){let s=!1;try{s=this.getSubscription(e).topic===t}catch{}return s}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const s=this.topicMap.get(e);await Promise.all(s.map(async s=>await this.unsubscribeById(e,s,t)))}async unsubscribeById(e,t,s){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:s}});try{const i=(0,d.n6V)(s);await this.restartToComplete({topic:e,id:t,relay:i}),await this.rpcUnsubscribe(e,t,i);const r=(0,d.Hjj)("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,r),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:s}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t,s){var i;(!s||s?.transportType===U.relay)&&await this.restartToComplete({topic:e,id:e,relay:t});const r={method:(0,d.aa1)(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});const n=null==(i=s?.internal)?void 0:i.throwOnFailedPublish;try{const t=await this.getSubscriptionId(e);if(s?.transportType===U.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(r).catch(e=>this.logger.warn(e))},(0,h.toMiliseconds)(h.ONE_SECOND)),t;const i=new Promise(async t=>{const s=i=>{i.topic===e&&(this.events.removeListener(j,s),t(i.id))};this.events.on(j,s);try{const i=await(0,d.K3g)(new Promise((e,t)=>{this.relayer.request(r).catch(e=>{this.logger.warn(e,e?.message),t(e)}).then(e)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(j,s),t(i)}catch{}}),o=await(0,d.K3g)(i,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!o&&n)throw new Error(`Subscribing to ${e} failed, please try again`);return o?t:null}catch(e){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(S.connection_stalled),n)throw e}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,s={method:(0,d.aa1)(t.protocol).batchSubscribe,params:{topics:e.map(e=>e.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{await await(0,d.K3g)(new Promise(e=>{this.relayer.request(s).catch(e=>this.logger.warn(e)).then(e)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(S.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,s={method:(0,d.aa1)(t.protocol).batchFetchMessages,params:{topics:e.map(e=>e.topic)}};let i;this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{i=await await(0,d.K3g)(new Promise((e,t)=>{this.relayer.request(s).catch(e=>{this.logger.warn(e),t(e)}).then(e)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(S.connection_stalled)}return i}rpcUnsubscribe(e,t,s){const i={method:(0,d.aa1)(s.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(e,t){this.setSubscription(e,es(Zt({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(e=>{this.setSubscription(e.id,Zt({},e)),this.pending.delete(e.topic)})}async onUnsubscribe(e,t,s){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,s),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,Zt({},t)),this.topicMap.set(t.topic,e),this.events.emit(j,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const s=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(s.topic,e),this.events.emit(M,es(Zt({},s),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit("subscription_sync")}async onRestart(){if(this.cached.length){const e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let s=0;s<t;s++){const t=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(t)}}this.events.emit("subscription_resubscribed")}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:e}=(0,d.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async e=>es(Zt({},e),{id:await this.getSubscriptionId(e.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await(0,d.yy4)((0,h.toMiliseconds)(h.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(t.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return(0,d.ALl)(e+await this.getClientId())}}var is=Object.defineProperty,rs=Object.getOwnPropertySymbols,ns=Object.prototype.hasOwnProperty,os=Object.prototype.propertyIsEnumerable,as=(e,t,s)=>t in e?is(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,cs=(e,t)=>{for(var s in t||(t={}))ns.call(t,s)&&as(e,s,t[s]);if(rs)for(var s of rs(t))os.call(t,s)&&as(e,s,t[s]);return e},hs=(e,t,s)=>as(e,"symbol"!=typeof t?t+"":t,s);class ls extends c.m5{constructor(e){super(e),hs(this,"protocol","wc"),hs(this,"version",2),hs(this,"core"),hs(this,"logger"),hs(this,"events",new i.EventEmitter),hs(this,"provider"),hs(this,"messages"),hs(this,"subscriber"),hs(this,"publisher"),hs(this,"name","relayer"),hs(this,"transportExplicitlyClosed",!1),hs(this,"initialized",!1),hs(this,"connectionAttemptInProgress",!1),hs(this,"relayUrl"),hs(this,"projectId"),hs(this,"packageName"),hs(this,"bundleId"),hs(this,"hasExperiencedNetworkDisruption",!1),hs(this,"pingTimeout"),hs(this,"heartBeatTimeout",(0,h.toMiliseconds)(h.THIRTY_SECONDS+h.FIVE_SECONDS)),hs(this,"reconnectTimeout"),hs(this,"connectPromise"),hs(this,"reconnectInProgress",!1),hs(this,"requestsInFlight",[]),hs(this,"connectTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),hs(this,"request",async e=>{var t,s;this.logger.debug("Publishing Request Payload");const i=e.id||(0,f.getBigIntRpcId)().toString();await this.toEstablishConnection();try{this.logger.trace({id:i,method:e.method,topic:null==(t=e.params)?void 0:t.topic},"relayer.request - publishing...");const r=`${i}:${(null==(s=e.params)?void 0:s.tag)||""}`;this.requestsInFlight.push(r);const n=await this.provider.request(e);return this.requestsInFlight=this.requestsInFlight.filter(e=>e!==r),n}catch(e){throw this.logger.debug(`Failed to Publish Request: ${i}`),e}}),hs(this,"resetPingTimeout",()=>{if((0,d.Lln)())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var e,t,s;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),null==(s=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)||s.terminate()},this.heartBeatTimeout)}catch(e){this.logger.warn(e,e?.message)}}),hs(this,"onPayloadHandler",e=>{this.onProviderPayload(e),this.resetPingTimeout()}),hs(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(S.connect)}),hs(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),hs(this,"onProviderErrorHandler",e=>{this.logger.fatal(`Fatal socket error: ${e.message}`),this.events.emit(S.error,e),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),hs(this,"registerProviderListeners",()=>{this.provider.on(O,this.onPayloadHandler),this.provider.on(T,this.onConnectHandler),this.provider.on(k,this.onDisconnectHandler),this.provider.on(x,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&"string"!=typeof e.logger?(0,a.U5)(e.logger,this.name):(0,a.h6)((0,a.iP)({level:e.logger||"error"})),this.messages=new kt(this.logger,e.core),this.subscriber=new ss(this,this.logger),this.publisher=new Ht(this,this.logger),this.relayUrl=e?.relayUrl||P,this.projectId=e.projectId,(0,d.m01)()?this.packageName=(0,d.R7U)():(0,d.aRZ)()&&(this.bundleId=(0,d.R7U)()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return(0,a.oI)(this.logger)}get connected(){var e,t,s;return 1===(null==(s=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:s.readyState)||!1}get connecting(){var e,t,s;return 0===(null==(s=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:s.readyState)||void 0!==this.connectPromise||!1}async publish(e,t,s){this.isInitialized(),await this.publisher.publish(e,t,s),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:U.relay})}async subscribe(e,t){var s,i,r;this.isInitialized(),(null==t||!t.transportType||"relay"===t?.transportType)&&await this.toEstablishConnection();const n=typeof(null==(s=t?.internal)?void 0:s.throwOnFailedPublish)>"u"||(null==(i=t?.internal)?void 0:i.throwOnFailedPublish);let o,a=(null==(r=this.subscriber.topicMap.get(e))?void 0:r[0])||"";const c=t=>{t.topic===e&&(this.subscriber.off(j,c),o())};return await Promise.all([new Promise(e=>{o=e,this.subscriber.on(j,c)}),new Promise(async(s,i)=>{a=await this.subscriber.subscribe(e,cs({internal:{throwOnFailedPublish:n}},t)).catch(e=>{n&&i(e)})||a,s()})]),a}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await(0,d.K3g)(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(this.subscriber.hasAnyTopics){if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(t,s)=>{await this.connect(e).then(t).catch(s).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}else this.logger.warn("Starting WS connection skipped because the client has no topics to work with.")}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await(0,d.sc7)())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(0===e?.length)return void this.logger.trace("Batch message events is empty. Ignoring...");const t=e.sort((e,t)=>e.publishedAt-t.publishedAt);this.logger.debug(`Batch of ${t.length} message events sorted`);for(const e of t)try{await this.onMessageEvent(e)}catch(e){this.logger.warn(e,"Error while processing batch message event: "+e?.message)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:s}=e;if(!t.sessionExists){const e={topic:s,expiry:(0,d.Xw0)(h.FIVE_MINUTES),relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(s,e)}this.events.emit(S.message,e),await this.recordMessageEvent(e)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let t=1;for(;t<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(e,t)=>{const s=()=>{t(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(k,s),await(0,d.K3g)(new Promise((e,t)=>{this.provider.connect().then(e).catch(t)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(e=>{t(e)}).finally(()=>{this.provider.off(k,s),clearTimeout(this.reconnectTimeout)}),await new Promise(async(e,t)=>{const s=()=>{t(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(k,s),await this.subscriber.start().then(e).catch(t).finally(()=>{this.provider.off(k,s)})}),this.hasExperiencedNetworkDisruption=!1,e()})}catch(e){await this.subscriber.stop();const t=e;this.logger.warn({},t.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(e=>setTimeout(e,(0,h.toMiliseconds)(1*t))),t++}}startPingTimeout(){var e,t,s,i,r;if((0,d.Lln)())try{null!=(t=null==(e=this.provider)?void 0:e.connection)&&t.socket&&(null==(r=null==(i=null==(s=this.provider)?void 0:s.connection)?void 0:i.socket)||r.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(e){this.logger.warn(e,e?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new g.F(new m.A((0,d.jUZ)({sdkVersion:R,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:s}=e;await this.messages.set(t,s)}async shouldIgnoreMessageEvent(e){const{topic:t,message:s}=e;if(!s||0===s.length)return this.logger.warn(`Ignoring invalid/empty message: ${s}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.warn(`Ignoring message for non-subscribed topic ${t}`),!0;const i=this.messages.has(t,s);return i&&this.logger.warn(`Ignoring duplicate message: ${s}`),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),(0,f.isJsonRpcRequest)(e)){if(!e.method.endsWith("_subscription"))return;const t=e.params,{topic:s,message:i,publishedAt:r,attestation:n}=t.data,o={topic:s,message:i,publishedAt:r,transportType:U.relay,attestation:n};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(cs({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o)}else(0,f.isJsonRpcResponse)(e)&&this.events.emit(S.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(S.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=(0,f.formatJsonRpcResult)(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(O,this.onPayloadHandler),this.provider.off(T,this.onConnectHandler),this.provider.off(k,this.onDisconnectHandler),this.provider.off(x,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await(0,d.sc7)();(0,d.uym)(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(e=>this.logger.error(e,e?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(S.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},(0,h.toMiliseconds)(.1)))))}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.connect()}}var ps=Object.defineProperty,ds=Object.getOwnPropertySymbols,us=Object.prototype.hasOwnProperty,gs=Object.prototype.propertyIsEnumerable,fs=(e,t,s)=>t in e?ps(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,ms=(e,t)=>{for(var s in t||(t={}))us.call(t,s)&&fs(e,s,t[s]);if(ds)for(var s of ds(t))gs.call(t,s)&&fs(e,s,t[s]);return e},ws=(e,t,s)=>fs(e,"symbol"!=typeof t?t+"":t,s);class ys extends c.pi{constructor(e,t,s,i=E,r=void 0){super(e,t,s,i),this.core=e,this.logger=t,this.name=s,ws(this,"map",new Map),ws(this,"version","0.3"),ws(this,"cached",[]),ws(this,"initialized",!1),ws(this,"getKey"),ws(this,"storagePrefix",E),ws(this,"recentlyDeleted",[]),ws(this,"recentlyDeletedLimit",200),ws(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>{this.getKey&&null!==e&&!(0,d.b07)(e)?this.map.set(this.getKey(e),e):(0,d.CTo)(e)?this.map.set(e.id,e):(0,d.mr0)(e)&&this.map.set(e.topic,e)}),this.cached=[],this.initialized=!0)}),ws(this,"set",async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())}),ws(this,"get",e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e))),ws(this,"getAll",e=>(this.isInitialized(),e?this.values.filter(t=>Object.keys(e).every(s=>y()(t[s],e[s]))):this.values)),ws(this,"update",async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});const s=ms(ms({},this.getData(e)),t);this.map.set(e,s),await this.persist()}),ws(this,"delete",async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:e,reason:t}),this.map.delete(e),this.addToRecentlyDeleted(e),await this.persist())}),this.logger=(0,a.U5)(t,this.name),this.storagePrefix=i,this.getKey=r}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:t}=(0,d.GuA)("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:e}=(0,d.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var bs=Object.defineProperty,vs=(e,t,s)=>((e,t,s)=>t in e?bs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Es{constructor(e,t){this.core=e,this.logger=t,vs(this,"name","pairing"),vs(this,"version","0.3"),vs(this,"events",new(r())),vs(this,"pairings"),vs(this,"initialized",!1),vs(this,"storagePrefix",E),vs(this,"ignoredPayloadTypes",[d.Lp_]),vs(this,"registeredMethods",[]),vs(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),vs(this,"register",({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]}),vs(this,"create",async e=>{this.isInitialized();const t=(0,d.two)(),s=await this.core.crypto.setSymKey(t),i=(0,d.Xw0)(h.FIVE_MINUTES),r={protocol:C},n={topic:s,expiry:i,relay:r,active:!1,methods:e?.methods},o=(0,d.QJh)({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:t,relay:r,expiryTimestamp:i,methods:e?.methods});return this.events.emit($.create,n),this.core.expirer.set(s,i),await this.pairings.set(s,n),await this.core.relayer.subscribe(s,{transportType:e?.transportType}),{topic:s,uri:o}}),vs(this,"pair",async e=>{this.isInitialized();const t=this.core.eventClient.createEvent({properties:{topic:e?.uri,trace:[J.pairing_started]}});this.isValidPair(e,t);const{topic:s,symKey:i,relay:r,expiryTimestamp:n,methods:o}=(0,d.wYp)(e.uri);let a;if(t.props.properties.topic=s,t.addTrace(J.pairing_uri_validation_success),t.addTrace(J.pairing_uri_not_expired),this.pairings.keys.includes(s)){if(a=this.pairings.get(s),t.addTrace(J.existing_pairing),a.active)throw t.setError(Y.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);t.addTrace(J.pairing_not_expired)}const c=n||(0,d.Xw0)(h.FIVE_MINUTES),l={topic:s,relay:r,expiry:c,active:!1,methods:o};this.core.expirer.set(s,c),await this.pairings.set(s,l),t.addTrace(J.store_new_pairing),e.activatePairing&&await this.activate({topic:s}),this.events.emit($.create,l),t.addTrace(J.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(i,s),t.addTrace(J.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{t.setError(Y.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:r})}catch(e){throw t.setError(Y.subscribe_pairing_topic_failure),e}return t.addTrace(J.subscribe_pairing_topic_success),l}),vs(this,"activate",async({topic:e})=>{this.isInitialized();const t=(0,d.Xw0)(h.FIVE_MINUTES);this.core.expirer.set(e,t),await this.pairings.update(e,{active:!0,expiry:t})}),vs(this,"ping",async e=>{this.isInitialized(),await this.isValidPing(e),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:t}=e;if(this.pairings.keys.includes(t)){const e=await this.sendRequest(t,"wc_pairingPing",{}),{done:s,resolve:i,reject:r}=(0,d.Wx8)();this.events.once((0,d.hEn)("pairing_ping",e),({error:e})=>{e?r(e):i()}),await s()}}),vs(this,"updateExpiry",async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})}),vs(this,"updateMetadata",async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})}),vs(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),vs(this,"disconnect",async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",(0,d.Hjj)("USER_DISCONNECTED")),await this.deletePairing(t))}),vs(this,"formatUriFromPairing",e=>{this.isInitialized();const{topic:t,relay:s,expiry:i,methods:r}=e,n=this.core.crypto.keychain.get(t);return(0,d.QJh)({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:n,relay:s,expiryTimestamp:i,methods:r})}),vs(this,"sendRequest",async(e,t,s)=>{const i=(0,f.formatJsonRpcRequest)(t,s),r=await this.core.crypto.encode(e,i),n=q[t].req;return this.core.history.set(e,i),this.core.relayer.publish(e,r,n),i.id}),vs(this,"sendResult",async(e,t,s)=>{const i=(0,f.formatJsonRpcResult)(e,s),r=await this.core.crypto.encode(t,i),n=(await this.core.history.get(t,e)).request.method,o=q[n].res;await this.core.relayer.publish(t,r,o),await this.core.history.resolve(i)}),vs(this,"sendError",async(e,t,s)=>{const i=(0,f.formatJsonRpcError)(e,s),r=await this.core.crypto.encode(t,i),n=(await this.core.history.get(t,e)).request.method,o=q[n]?q[n].res:q.unregistered_method.res;await this.core.relayer.publish(t,r,o),await this.core.history.resolve(i)}),vs(this,"deletePairing",async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,(0,d.Hjj)("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])}),vs(this,"cleanup",async()=>{const e=this.pairings.getAll().filter(e=>(0,d._dF)(e.expiry));await Promise.all(e.map(e=>this.deletePairing(e.topic)))}),vs(this,"onRelayEventRequest",e=>{const{topic:t,payload:s}=e;switch(s.method){case"wc_pairingPing":return this.onPairingPingRequest(t,s);case"wc_pairingDelete":return this.onPairingDeleteRequest(t,s);default:return this.onUnknownRpcMethodRequest(t,s)}}),vs(this,"onRelayEventResponse",async e=>{const{topic:t,payload:s}=e,i=(await this.core.history.get(t,s.id)).request.method;return"wc_pairingPing"===i?this.onPairingPingResponse(t,s):this.onUnknownRpcMethodResponse(i)}),vs(this,"onPairingPingRequest",async(e,t)=>{const{id:s}=t;try{this.isValidPing({topic:e}),await this.sendResult(s,e,!0),this.events.emit($.ping,{id:s,topic:e})}catch(t){await this.sendError(s,e,t),this.logger.error(t)}}),vs(this,"onPairingPingResponse",(e,t)=>{const{id:s}=t;setTimeout(()=>{(0,f.isJsonRpcResult)(t)?this.events.emit((0,d.hEn)("pairing_ping",s),{}):(0,f.isJsonRpcError)(t)&&this.events.emit((0,d.hEn)("pairing_ping",s),{error:t.error})},500)}),vs(this,"onPairingDeleteRequest",async(e,t)=>{const{id:s}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit($.delete,{id:s,topic:e})}catch(t){await this.sendError(s,e,t),this.logger.error(t)}}),vs(this,"onUnknownRpcMethodRequest",async(e,t)=>{const{id:s,method:i}=t;try{if(this.registeredMethods.includes(i))return;const t=(0,d.Hjj)("WC_METHOD_UNSUPPORTED",i);await this.sendError(s,e,t),this.logger.error(t)}catch(t){await this.sendError(s,e,t),this.logger.error(t)}}),vs(this,"onUnknownRpcMethodResponse",e=>{this.registeredMethods.includes(e)||this.logger.error((0,d.Hjj)("WC_METHOD_UNSUPPORTED",e))}),vs(this,"isValidPair",(e,t)=>{var s;if(!(0,d.TeY)(e)){const{message:s}=(0,d.GuA)("MISSING_OR_INVALID",`pair() params: ${e}`);throw t.setError(Y.malformed_pairing_uri),new Error(s)}if(!(0,d.AYU)(e.uri)){const{message:s}=(0,d.GuA)("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw t.setError(Y.malformed_pairing_uri),new Error(s)}const i=(0,d.wYp)(e?.uri);if(null==(s=i?.relay)||!s.protocol){const{message:e}=(0,d.GuA)("MISSING_OR_INVALID","pair() uri#relay-protocol");throw t.setError(Y.malformed_pairing_uri),new Error(e)}if(null==i||!i.symKey){const{message:e}=(0,d.GuA)("MISSING_OR_INVALID","pair() uri#symKey");throw t.setError(Y.malformed_pairing_uri),new Error(e)}if(null!=i&&i.expiryTimestamp&&(0,h.toMiliseconds)(i?.expiryTimestamp)<Date.now()){t.setError(Y.pairing_expired);const{message:e}=(0,d.GuA)("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(e)}}),vs(this,"isValidPing",async e=>{if(!(0,d.TeY)(e)){const{message:t}=(0,d.GuA)("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)}),vs(this,"isValidDisconnect",async e=>{if(!(0,d.TeY)(e)){const{message:t}=(0,d.GuA)("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)}),vs(this,"isValidPairingTopic",async e=>{if(!(0,d.Qhg)(e,!1)){const{message:t}=(0,d.GuA)("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.pairings.keys.includes(e)){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if((0,d._dF)(this.pairings.get(e).expiry)){await this.deletePairing(e);const{message:t}=(0,d.GuA)("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}),this.core=e,this.logger=(0,a.U5)(t,this.name),this.pairings=new ys(this.core,this.logger,this.name,this.storagePrefix)}get context(){return(0,a.oI)(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(S.message,async e=>{const{topic:t,message:s,transportType:i}=e;if(!this.pairings.keys.includes(t)||i===U.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(s)))return;const r=await this.core.crypto.decode(t,s);try{(0,f.isJsonRpcRequest)(r)?(this.core.history.set(t,r),this.onRelayEventRequest({topic:t,payload:r})):(0,f.isJsonRpcResponse)(r)&&(await this.core.history.resolve(r),await this.onRelayEventResponse({topic:t,payload:r}),this.core.history.delete(t,r.id))}catch(e){this.logger.error(e)}})}registerExpirerEvents(){this.core.expirer.on(z.expired,async e=>{const{topic:t}=(0,d.c82)(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit($.expire,{topic:t}))})}}var Is=Object.defineProperty,_s=(e,t,s)=>((e,t,s)=>t in e?Is(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Ns extends c.lZ{constructor(e,t){super(e,t),this.core=e,this.logger=t,_s(this,"records",new Map),_s(this,"events",new i.EventEmitter),_s(this,"name","history"),_s(this,"version","0.3"),_s(this,"cached",[]),_s(this,"initialized",!1),_s(this,"storagePrefix",E),_s(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.records.set(e.id,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),_s(this,"set",(e,t,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:s}),this.records.has(t.id))return;const i={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:s,expiry:(0,d.Xw0)(h.THIRTY_DAYS)};this.records.set(i.id,i),this.persist(),this.events.emit(B,i)}),_s(this,"resolve",async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;const t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=(0,f.isJsonRpcError)(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.persist(),this.events.emit(H,t))}),_s(this,"get",async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t))),_s(this,"delete",(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach(s=>{if(s.topic===e){if(typeof t<"u"&&s.id!==t)return;this.records.delete(s.id),this.events.emit(W,s)}}),this.persist()}),_s(this,"exists",async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e)),_s(this,"on",(e,t)=>{this.events.on(e,t)}),_s(this,"once",(e,t)=>{this.events.once(e,t)}),_s(this,"off",(e,t)=>{this.events.off(e,t)}),_s(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const s={topic:t.topic,request:(0,f.formatJsonRpcRequest)(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(s)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit("history_sync")}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:e}=(0,d.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(B,e=>{const t=B;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(H,e=>{const t=H;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(W,e=>{const t=W;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(n.li.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,h.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(W,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var As=Object.defineProperty,Cs=(e,t,s)=>((e,t,s)=>t in e?As(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Ps extends c.Vx{constructor(e,t){super(e,t),this.core=e,this.logger=t,Cs(this,"expirations",new Map),Cs(this,"events",new i.EventEmitter),Cs(this,"name","expirer"),Cs(this,"version","0.3"),Cs(this,"cached",[]),Cs(this,"initialized",!1),Cs(this,"storagePrefix",E),Cs(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.expirations.set(e.target,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Cs(this,"has",e=>{try{const t=this.formatTarget(e);return typeof this.getExpiration(t)<"u"}catch{return!1}}),Cs(this,"set",(e,t)=>{this.isInitialized();const s=this.formatTarget(e),i={target:s,expiry:t};this.expirations.set(s,i),this.checkExpiry(s,i),this.events.emit(z.created,{target:s,expiration:i})}),Cs(this,"get",e=>{this.isInitialized();const t=this.formatTarget(e);return this.getExpiration(t)}),Cs(this,"del",e=>{if(this.isInitialized(),this.has(e)){const t=this.formatTarget(e),s=this.getExpiration(t);this.expirations.delete(t),this.events.emit(z.deleted,{target:t,expiration:s})}}),Cs(this,"on",(e,t)=>{this.events.on(e,t)}),Cs(this,"once",(e,t)=>{this.events.once(e,t)}),Cs(this,"off",(e,t)=>{this.events.off(e,t)}),Cs(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if("string"==typeof e)return(0,d.ADD)(e);if("number"==typeof e)return(0,d.gOF)(e);const{message:t}=(0,d.GuA)("UNKNOWN_TYPE","Target type: "+typeof e);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(z.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:e}=(0,d.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(t),new Error(t)}return t}checkExpiry(e,t){const{expiry:s}=t;(0,h.toMiliseconds)(s)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(z.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(n.li.pulse,()=>this.checkExpirations()),this.events.on(z.created,e=>{const t=z.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(z.expired,e=>{const t=z.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(z.deleted,e=>{const t=z.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Ss=Object.defineProperty,Os=(e,t,s)=>((e,t,s)=>t in e?Ss(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Ts extends c.zl{constructor(e,t,s){super(e,t,s),this.core=e,this.logger=t,this.store=s,Os(this,"name","verify-api"),Os(this,"abortController"),Os(this,"isDevEnv"),Os(this,"verifyUrlV3",K),Os(this,"storagePrefix",E),Os(this,"version",2),Os(this,"publicKey"),Os(this,"fetchPromise"),Os(this,"init",async()=>{var e;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,h.toMiliseconds)(null==(e=this.publicKey)?void 0:e.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),Os(this,"register",async e=>{if(!(0,d.BdH)()||this.isDevEnv)return;const t=window.location.origin,{id:s,decryptedId:i}=e,r=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${t}&id=${s}&decryptedId=${i}`;try{const e=(0,b.getDocument)(),t=this.startAbortTimer(5*h.ONE_SECOND),i=await new Promise((i,n)=>{const o=()=>{window.removeEventListener("message",c),e.body.removeChild(a),n("attestation aborted")};this.abortController.signal.addEventListener("abort",o);const a=e.createElement("iframe");a.src=r,a.style.display="none",a.addEventListener("error",o,{signal:this.abortController.signal});const c=r=>{if(r.data&&"string"==typeof r.data)try{const n=JSON.parse(r.data);if("verify_attestation"===n.type){if((0,p.Cq)(n.attestation).payload.id!==s)return;clearInterval(t),e.body.removeChild(a),this.abortController.signal.removeEventListener("abort",o),window.removeEventListener("message",c),i(null===n.attestation?"":n.attestation)}}catch(e){this.logger.warn(e)}};e.body.appendChild(a),window.addEventListener("message",c,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",i),i}catch(e){this.logger.warn(e)}return""}),Os(this,"resolve",async e=>{if(this.isDevEnv)return"";const{attestationId:t,hash:s,encryptedId:i}=e;if(""===t)return void this.logger.debug("resolve: attestationId is empty, skipping");if(t){if((0,p.Cq)(t).payload.id!==i)return;const e=await this.isValidJwtAttestation(t);if(e)return e.isVerified?e:void this.logger.warn("resolve: jwt attestation: origin url not verified")}if(!s)return;const r=this.getVerifyUrl(e?.verifyUrl);return this.fetchAttestation(s,r)}),Os(this,"fetchAttestation",async(e,t)=>{this.logger.debug(`resolving attestation: ${e} from url: ${t}`);const s=this.startAbortTimer(5*h.ONE_SECOND),i=await fetch(`${t}/attestation/${e}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(s),200===i.status?await i.json():void 0}),Os(this,"getVerifyUrl",e=>{let t=e||F;return G.includes(t)||(this.logger.info(`verify url: ${t}, not included in trusted list, assigning default: ${F}`),t=F),t}),Os(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const e=this.startAbortTimer(h.FIVE_SECONDS),t=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(e),await t.json()}catch(e){this.logger.warn(e)}}),Os(this,"persistPublicKey",async e=>{this.logger.debug("persisting public key to local storage",e),await this.store.setItem(this.storeKey,e),this.publicKey=e}),Os(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),Os(this,"isValidJwtAttestation",async e=>{const t=await this.getPublicKey();try{if(t)return this.validateAttestation(e,t)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}const s=await this.fetchAndPersistPublicKey();try{if(s)return this.validateAttestation(e,s)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}}),Os(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),Os(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async e=>{const t=await this.fetchPublicKey();t&&(await this.persistPublicKey(t),e(t))});const e=await this.fetchPromise;return this.fetchPromise=void 0,e}),Os(this,"validateAttestation",(e,t)=>{const s=(0,d.U0i)(e,t.publicKey),i={hasExpired:(0,h.toMiliseconds)(s.exp)<Date.now(),payload:s};if(i.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:i.payload.origin,isScam:i.payload.isScam,isVerified:i.payload.isVerified}}),this.logger=(0,a.U5)(t,this.name),this.abortController=new AbortController,this.isDevEnv=(0,d.w8K)(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return(0,a.oI)(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),(0,h.toMiliseconds)(e))}}var ks=Object.defineProperty,xs=(e,t,s)=>((e,t,s)=>t in e?ks(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Rs extends c.GF{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,xs(this,"context","echo"),xs(this,"registerDeviceToken",async e=>{const{clientId:t,token:s,notificationType:i,enableEncrypted:r=!1}=e,n=`https://echo.walletconnect.com/${this.projectId}/clients`;await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:t,type:i,token:s,always_raw:r})})}),this.logger=(0,a.U5)(t,this.context)}}var Us=Object.defineProperty,Ds=Object.getOwnPropertySymbols,js=Object.prototype.hasOwnProperty,Ms=Object.prototype.propertyIsEnumerable,Ls=(e,t,s)=>t in e?Us(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,qs=(e,t)=>{for(var s in t||(t={}))js.call(t,s)&&Ls(e,s,t[s]);if(Ds)for(var s of Ds(t))Ms.call(t,s)&&Ls(e,s,t[s]);return e},$s=(e,t,s)=>Ls(e,"symbol"!=typeof t?t+"":t,s);class Bs extends c.$Q{constructor(e,t,s=!0){super(e,t,s),this.core=e,this.logger=t,$s(this,"context","event-client"),$s(this,"storagePrefix",E),$s(this,"storageVersion",.1),$s(this,"events",new Map),$s(this,"shouldPersist",!1),$s(this,"init",async()=>{if(!(0,d.w8K)())try{const e={eventId:(0,d.gZm)(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:(0,d.ojD)(this.core.relayer.protocol,this.core.relayer.version,R)}}};await this.sendEvent([e])}catch(e){this.logger.warn(e)}}),$s(this,"createEvent",e=>{const{event:t="ERROR",type:s="",properties:{topic:i,trace:r}}=e,n=(0,d.gZm)(),o=this.core.projectId||"",a=Date.now(),c=qs({eventId:n,timestamp:a,props:{event:t,type:s,properties:{topic:i,trace:r}},bundleId:o,domain:this.getAppDomain()},this.setMethods(n));return this.telemetryEnabled&&(this.events.set(n,c),this.shouldPersist=!0),c}),$s(this,"getEvent",e=>{const{eventId:t,topic:s}=e;if(t)return this.events.get(t);const i=Array.from(this.events.values()).find(e=>e.props.properties.topic===s);return i?qs(qs({},i),this.setMethods(i.eventId)):void 0}),$s(this,"deleteEvent",e=>{const{eventId:t}=e;this.events.delete(t),this.shouldPersist=!0}),$s(this,"setEventListeners",()=>{this.core.heartbeat.on(n.li.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(e=>{(0,h.fromMiliseconds)(Date.now())-(0,h.fromMiliseconds)(e.timestamp)>86400&&(this.events.delete(e.eventId),this.shouldPersist=!0)})})}),$s(this,"setMethods",e=>({addTrace:t=>this.addTrace(e,t),setError:t=>this.setError(e,t)})),$s(this,"addTrace",(e,t)=>{const s=this.events.get(e);s&&(s.props.properties.trace.push(t),this.events.set(e,s),this.shouldPersist=!0)}),$s(this,"setError",(e,t)=>{const s=this.events.get(e);s&&(s.props.type=t,s.timestamp=Date.now(),this.events.set(e,s),this.shouldPersist=!0)}),$s(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),$s(this,"restore",async()=>{try{const e=await this.core.storage.getItem(this.storageKey)||[];if(!e.length)return;e.forEach(e=>{this.events.set(e.eventId,qs(qs({},e),this.setMethods(e.eventId)))})}catch(e){this.logger.warn(e)}}),$s(this,"submit",async()=>{if(!this.telemetryEnabled||0===this.events.size)return;const e=[];for(const[t,s]of this.events)s.props.type&&e.push(s);if(0!==e.length)try{if((await this.sendEvent(e)).ok)for(const t of e)this.events.delete(t.eventId),this.shouldPersist=!0}catch(e){this.logger.warn(e)}}),$s(this,"sendEvent",async e=>{const t=this.getAppDomain()?"":"&sp=desktop";return await fetch(`https://pulse.walletconnect.org/batch?projectId=${this.core.projectId}&st=events_sdk&sv=js-${R}${t}`,{method:"POST",body:JSON.stringify(e)})}),$s(this,"getAppDomain",()=>(0,d.lFF)().url),this.logger=(0,a.U5)(t,this.context),this.telemetryEnabled=s,s?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var Hs=Object.defineProperty,Ws=Object.getOwnPropertySymbols,zs=Object.prototype.hasOwnProperty,Vs=Object.prototype.propertyIsEnumerable,Fs=(e,t,s)=>t in e?Hs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ks=(e,t)=>{for(var s in t||(t={}))zs.call(t,s)&&Fs(e,s,t[s]);if(Ws)for(var s of Ws(t))Vs.call(t,s)&&Fs(e,s,t[s]);return e},Gs=(e,t,s)=>Fs(e,"symbol"!=typeof t?t+"":t,s);class Js extends c.ZP{constructor(e){var t;super(e),Gs(this,"protocol","wc"),Gs(this,"version",2),Gs(this,"name",v),Gs(this,"relayUrl"),Gs(this,"projectId"),Gs(this,"customStoragePrefix"),Gs(this,"events",new i.EventEmitter),Gs(this,"logger"),Gs(this,"heartbeat"),Gs(this,"relayer"),Gs(this,"crypto"),Gs(this,"storage"),Gs(this,"history"),Gs(this,"expirer"),Gs(this,"pairing"),Gs(this,"verify"),Gs(this,"echoClient"),Gs(this,"linkModeSupportedApps"),Gs(this,"eventClient"),Gs(this,"initialized",!1),Gs(this,"logChunkController"),Gs(this,"on",(e,t)=>this.events.on(e,t)),Gs(this,"once",(e,t)=>this.events.once(e,t)),Gs(this,"off",(e,t)=>this.events.off(e,t)),Gs(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),Gs(this,"dispatchEnvelope",({topic:e,message:t,sessionExists:s})=>{if(!e||!t)return;const i={topic:e,message:t,publishedAt:Date.now(),transportType:U.link_mode};this.relayer.onLinkMessageEvent(i,{sessionExists:s})}),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||P,this.customStoragePrefix=null!=e&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const s=(0,a.iP)({level:"string"==typeof e?.logger&&e.logger?e.logger:"error",name:v}),{logger:r,chunkLoggerController:c}=(0,a.D5)({opts:s,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=c,null!=(t=this.logChunkController)&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var e,t;null!=(e=this.logChunkController)&&e.downloadLogsBlobInBrowser&&(null==(t=this.logChunkController)||t.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=(0,a.U5)(r,this.name),this.heartbeat=new n.VH,this.crypto=new St(this,this.logger,e?.keychain),this.history=new Ns(this,this.logger),this.expirer=new Ps(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new o.A(Ks(Ks({},I),e?.storageOptions)),this.relayer=new ls({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Es(this,this.logger),this.verify=new Ts(this,this.logger,this.storage),this.echoClient=new Rs(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new Bs(this,this.logger,e?.telemetryEnabled)}static async init(e){const t=new Js(e);await t.initialize();const s=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",s),t}get context(){return(0,a.oI)(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return null==(e=this.logChunkController)?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(D,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(D)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const Ys=Js},11807:(e,t,s)=>{function i(e,t){return"light"===t?{"--w3m-accent":e?.["--w3m-accent"]||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":e?.["--w3m-accent"]||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}s.d(t,{o:()=>i})},12472:(e,t,s)=>{s.d(t,{j:()=>o});var i=s(89168),r=s(39150);const n=(0,i.BX)({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),o={state:n,subscribeNetworkImages:e=>(0,i.B1)(n.networkImages,()=>e(n.networkImages)),subscribeKey:(e,t)=>(0,r.u$)(n,e,t),subscribe:e=>(0,i.B1)(n,()=>e(n)),setWalletImage(e,t){n.walletImages[e]=t},setNetworkImage(e,t){n.networkImages[e]=t},setChainImage(e,t){n.chainImages[e]=t},setConnectorImage(e,t){n.connectorImages={...n.connectorImages,[e]:t}},setTokenImage(e,t){n.tokenImages[e]=t},setCurrencyImage(e,t){n.currencyImages[e]=t}}},14133:(e,t,s)=>{s.d(t,{Rn:()=>r.R,gT:()=>n.g,tW:()=>i.t});var i=s(33937),r=s(50047),n=s(18354)},14479:(e,t,s)=>{s.d(t,{E:()=>f});var i=s(89168),r=s(95191),n=s(32681),o=s(5813),a=s(19760),c=s(16279),h=s(27938),l=s(16158);const p=o.w.getAnalyticsUrl(),d=new a.Z({baseUrl:p,clientId:null}),u=["MODAL_CREATED"],g=(0,i.BX)({timestamp:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"}}),f={state:g,subscribe:e=>(0,i.B1)(g,()=>e(g)),getSdkProperties(){const{projectId:e,sdkType:t,sdkVersion:s}=l.H.state;return{projectId:e,st:t,sv:s||"html-wagmi-4.2.2"}},async _sendAnalyticsEvent(e){try{const t=c.U.state.address;if(u.includes(e.data.event)||"undefined"==typeof window)return;await d.post({path:"/e",params:f.getSdkProperties(),body:{eventId:o.w.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:e.timestamp,props:{...e.data,address:t}}}),g.reportedErrors.FORBIDDEN=!1}catch(e){e instanceof Error&&e.cause instanceof Response&&e.cause.status===r.o.HTTP_STATUS_CODES.FORBIDDEN&&!g.reportedErrors.FORBIDDEN&&(h.h.open({shortMessage:"Invalid App Configuration",longMessage:`Origin ${(0,n.IP)()?window.origin:"uknown"} not found on Allowlist - update configuration on cloud.reown.com`},"error"),g.reportedErrors.FORBIDDEN=!0)}},sendEvent(e){g.timestamp=Date.now(),g.data=e,l.H.state.features?.analytics&&f._sendAnalyticsEvent(g)}}},15406:(e,t,s)=>{s.d(t,{t:()=>c});var i=s(16279),r=s(27006),n=s(99013),o=s(89058),a=s(36641);const c={async getMyTokensWithBalance(e){const t=i.U.state.address,s=n.W.state.activeCaipNetwork;if(!t||!s)return[];if("eip155"===s.chainNamespace){const e=await this.getEIP155Balances(t,s);if(e)return this.filterLowQualityTokens(e)}const o=await r.T.getBalance(t,s.caipNetworkId,e);return this.filterLowQualityTokens(o.balances)},async getEIP155Balances(e,t){try{const s=a.T.getChainIdHexFromCAIP2ChainId(t.caipNetworkId),i=await o.x.getCapabilities(e);if(!i?.[s]?.assetDiscovery?.supported)return null;const r=await o.x.walletGetAssets({account:e,chainFilter:[s]});return a.T.isWalletGetAssetsResponse(r)?(r[s]||[]).map(e=>a.T.createBalance(e,t.caipNetworkId)):null}catch(e){return null}},filterLowQualityTokens:e=>e.filter(e=>"0"!==e.quantity.decimals),mapBalancesToSwapTokens:e=>e?.map(e=>({...e,address:e?.address?e.address:n.W.getActiveNetworkTokenAddress(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1}))||[]}},15579:(e,t,s)=>{s.d(t,{R:()=>l});var i=s(4443),r=s(30393),n=s(95191),o=s(99013),a=s(11553),c=s(40770);const h=["near:mainnet","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp","eip155:1101","eip155:56","eip155:42161","eip155:7777777","eip155:59144","eip155:324","solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1","eip155:5000","solana:4sgjmw1sunhzsxgspuhpqldx6wiyjntz","eip155:80084","eip155:5003","eip155:100","eip155:8453","eip155:42220","eip155:1313161555","eip155:17000","eip155:1","eip155:300","eip155:1313161554","eip155:1329","eip155:84532","eip155:421614","eip155:11155111","eip155:8217","eip155:43114","solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z","eip155:999999999","eip155:11155420","eip155:80002","eip155:97","eip155:43113","eip155:137","eip155:10","eip155:1301","bip122:000000000019d6689c085ae165831e93","bip122:000000000933ea01ad0ee984209779ba"],l={extendRpcUrlWithProjectId(e,t){let s=!1;try{s="rpc.walletconnect.org"===new URL(e).host}catch(e){s=!1}if(s){const s=new URL(e);return s.searchParams.has("projectId")||s.searchParams.set("projectId",t),s.toString()}return e},isCaipNetwork:e=>"chainNamespace"in e&&"caipNetworkId"in e,getChainNamespace(e){return this.isCaipNetwork(e)?e.chainNamespace:n.o.CHAIN.EVM},getCaipNetworkId(e){return this.isCaipNetwork(e)?e.caipNetworkId:`${n.o.CHAIN.EVM}:${e.id}`},getDefaultRpcUrl(e,t,s){const i=e.rpcUrls?.default?.http?.[0];return h.includes(t)?function(e,t){const s=new URL("https://rpc.walletconnect.org/v1/");return s.searchParams.set("chainId",e),s.searchParams.set("projectId",t),s.toString()}(t,s):i||""},extendCaipNetwork(e,{customNetworkImageUrls:t,projectId:s,customRpcUrls:i}){const r=this.getChainNamespace(e),n=this.getCaipNetworkId(e),o=e.rpcUrls.default.http?.[0],a=this.getDefaultRpcUrl(e,n,s),h=e?.rpcUrls?.chainDefault?.http?.[0]||o,l=i?.[n]?.map(e=>e.url)||[],p=[...l,a],d=[...l];return h&&!d.includes(h)&&d.push(h),{...e,chainNamespace:r,caipNetworkId:n,assets:{imageId:c.L.NetworkImageIds[e.id],imageUrl:t?.[e.id]},rpcUrls:{...e.rpcUrls,default:{http:p},chainDefault:{http:d}}}},extendCaipNetworks:(e,{customNetworkImageUrls:t,projectId:s,customRpcUrls:i})=>e.map(e=>l.extendCaipNetwork(e,{customNetworkImageUrls:t,customRpcUrls:i,projectId:s})),getViemTransport(e,t,s){const n=[];if(s?.forEach(e=>{n.push((0,r.L)(e.url,e.config))}),h.includes(e.caipNetworkId)){const s=this.getDefaultRpcUrl(e,e.caipNetworkId,t);n.push((0,r.L)(s,{fetchOptions:{headers:{"Content-Type":"text/plain"}}}))}return(0,i.Np)(n)},extendWagmiTransports(e,t,s){if(h.includes(e.caipNetworkId)){const n=this.getDefaultRpcUrl(e,e.caipNetworkId,t);return(0,i.Np)([s,(0,r.L)(n)])}return s},getUnsupportedNetwork:e=>({id:e.split(":")[1],caipNetworkId:e,name:n.o.UNSUPPORTED_NETWORK_NAME,chainNamespace:e.split(":")[0],nativeCurrency:{name:"",decimals:0,symbol:""},rpcUrls:{default:{http:[]}}}),getCaipNetworkFromStorage(e){const t=a.i.getActiveCaipNetworkId(),s=o.W.getAllRequestedCaipNetworks(),i=Array.from(o.W.state.chains?.keys()||[]),r=t?.split(":")[0],n=!!r&&i.includes(r),c=s?.find(e=>e.caipNetworkId===t);return n&&!c&&t?this.getUnsupportedNetwork(t):c||e||s?.[0]}}},16158:(e,t,s)=>{s.d(t,{H:()=>c});var i=s(89168),r=s(39150),n=s(84253),o=s(91310);const a=(0,i.BX)({features:n.oU.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:n.oU.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0}),c={state:a,subscribeKey:(e,t)=>(0,r.u$)(a,e,t),setOptions(e){Object.assign(a,e)},setFeatures(e){if(!e)return;a.features||(a.features=n.oU.DEFAULT_FEATURES);const t={...a.features,...e};a.features=t,a.features.socials&&(a.features.socials=o.D.filterSocialsByPlatform(a.features.socials))},setProjectId(e){a.projectId=e},setCustomRpcUrls(e){a.customRpcUrls=e},setAllWallets(e){a.allWallets=e},setIncludeWalletIds(e){a.includeWalletIds=e},setExcludeWalletIds(e){a.excludeWalletIds=e},setFeaturedWalletIds(e){a.featuredWalletIds=e},setTokens(e){a.tokens=e},setTermsConditionsUrl(e){a.termsConditionsUrl=e},setPrivacyPolicyUrl(e){a.privacyPolicyUrl=e},setCustomWallets(e){a.customWallets=e},setIsSiweEnabled(e){a.isSiweEnabled=e},setIsUniversalProvider(e){a.isUniversalProvider=e},setSdkVersion(e){a.sdkVersion=e},setMetadata(e){a.metadata=e},setDisableAppend(e){a.disableAppend=e},setEIP6963Enabled(e){a.enableEIP6963=e},setDebug(e){a.debug=e},setEnableWalletConnect(e){a.enableWalletConnect=e},setEnableWalletGuide(e){a.enableWalletGuide=e},setEnableAuthLogger(e){a.enableAuthLogger=e},setEnableWallets(e){a.enableWallets=e},setHasMultipleAddresses(e){a.hasMultipleAddresses=e},setSIWX(e){a.siwx=e},setConnectMethodsOrder(e){a.features={...a.features,connectMethodsOrder:e}},setWalletFeaturesOrder(e){a.features={...a.features,walletFeaturesOrder:e}},setSocialsOrder(e){a.features={...a.features,socials:e}},setCollapseWallets(e){a.features={...a.features,collapseWallets:e}},setEnableEmbedded(e){a.enableEmbedded=e},setAllowUnsupportedChain(e){a.allowUnsupportedChain=e},setManualWCControl(e){a.manualWCControl=e},setEnableNetworkSwitch(e){a.enableNetworkSwitch=e},setDefaultAccountTypes(e={}){Object.entries(e).forEach(([e,t])=>{t&&(a.defaultAccountTypes[e]=t)})},setUniversalProviderConfigOverride(e){a.universalProviderConfigOverride=e},getUniversalProviderConfigOverride:()=>a.universalProviderConfigOverride,getSnapshot:()=>(0,i.P9)(a)}},16279:(e,t,s)=>{s.d(t,{U:()=>l});var i=s(89168),r=s(84253),n=s(5813),o=s(27006),a=s(99013),c=s(41430);const h=(0,i.BX)({currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[]}),l={state:h,replaceState(e){e&&Object.assign(h,(0,i.KR)(e))},subscribe:e=>a.W.subscribeChainProp("accountState",t=>{if(t)return e(t)}),subscribeKey(e,t,s){let i;return a.W.subscribeChainProp("accountState",s=>{if(s){const r=s[e];i!==r&&(i=r,t(r))}},s)},setStatus(e,t){a.W.setAccountProp("status",e,t)},getCaipAddress:e=>a.W.getAccountProp("caipAddress",e),setCaipAddress(e,t){const s=e?n.w.getPlainAddress(e):void 0;t===a.W.state.activeChain&&(a.W.state.activeCaipAddress=e),a.W.setAccountProp("caipAddress",e,t),a.W.setAccountProp("address",s,t)},setBalance(e,t,s){a.W.setAccountProp("balance",e,s),a.W.setAccountProp("balanceSymbol",t,s)},setProfileName(e,t){a.W.setAccountProp("profileName",e,t)},setProfileImage(e,t){a.W.setAccountProp("profileImage",e,t)},setUser(e,t){a.W.setAccountProp("user",e,t)},setAddressExplorerUrl(e,t){a.W.setAccountProp("addressExplorerUrl",e,t)},setSmartAccountDeployed(e,t){a.W.setAccountProp("smartAccountDeployed",e,t)},setCurrentTab(e){a.W.setAccountProp("currentTab",e,a.W.state.activeChain)},setTokenBalance(e,t){e&&a.W.setAccountProp("tokenBalance",e,t)},setShouldUpdateToAddress(e,t){a.W.setAccountProp("shouldUpdateToAddress",e,t)},setAllAccounts(e,t){a.W.setAccountProp("allAccounts",e,t)},addAddressLabel(e,t,s){const i=a.W.getAccountProp("addressLabels",s)||new Map;i.set(e,t),a.W.setAccountProp("addressLabels",i,s)},removeAddressLabel(e,t){const s=a.W.getAccountProp("addressLabels",t)||new Map;s.delete(e),a.W.setAccountProp("addressLabels",s,t)},setConnectedWalletInfo(e,t){a.W.setAccountProp("connectedWalletInfo",e,t,!1)},setPreferredAccountType(e,t){a.W.setAccountProp("preferredAccountType",e,t)},setSocialProvider(e,t){e&&a.W.setAccountProp("socialProvider",e,t)},setSocialWindow(e,t){a.W.setAccountProp("socialWindow",e?(0,i.KR)(e):void 0,t)},setFarcasterUrl(e,t){a.W.setAccountProp("farcasterUrl",e,t)},async fetchTokenBalance(e){h.balanceLoading=!0;const t=a.W.state.activeCaipNetwork?.caipNetworkId,s=a.W.state.activeCaipNetwork?.chainNamespace,i=a.W.state.activeCaipAddress,l=i?n.w.getPlainAddress(i):void 0;if(h.lastRetry&&!n.w.isAllowedRetry(h.lastRetry,30*r.oU.ONE_SEC_MS))return h.balanceLoading=!1,[];try{if(l&&t&&s){const e=(await o.T.getBalance(l,t)).balances.filter(e=>"0"!==e.quantity.decimals);return this.setTokenBalance(e,s),h.lastRetry=void 0,h.balanceLoading=!1,e}}catch(t){h.lastRetry=Date.now(),e?.(t),c.P.showError("Token Balance Unavailable")}finally{h.balanceLoading=!1}return[]},resetAccount(e){a.W.resetAccount(e)}}},16652:(e,t,s)=>{s.d(t,{R:()=>y});var i=s(89168),r=s(39150),n=s(22233),o=s(8834),a=s(9663),c=s(84253),h=s(5813),l=s(15406),p=s(16279),d=s(99013),u=s(89058),g=s(14479),f=s(42831),m=s(41430);const w=(0,i.BX)({tokenBalances:[],loading:!1}),y={state:w,subscribe:e=>(0,i.B1)(w,()=>e(w)),subscribeKey:(e,t)=>(0,r.u$)(w,e,t),setToken(e){e&&(w.token=(0,i.KR)(e))},setTokenAmount(e){w.sendTokenAmount=e},setReceiverAddress(e){w.receiverAddress=e},setReceiverProfileImageUrl(e){w.receiverProfileImageUrl=e},setReceiverProfileName(e){w.receiverProfileName=e},setGasPrice(e){w.gasPrice=e},setGasPriceInUsd(e){w.gasPriceInUSD=e},setNetworkBalanceInUsd(e){w.networkBalanceInUSD=e},setLoading(e){w.loading=e},sendToken(){switch(d.W.state.activeCaipNetwork?.chainNamespace){case"eip155":return void this.sendEvmToken();case"solana":return void this.sendSolanaToken();default:throw new Error("Unsupported chain")}},sendEvmToken(){this.state.token?.address&&this.state.sendTokenAmount&&this.state.receiverAddress?(g.E.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:p.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token.address,amount:this.state.sendTokenAmount,network:d.W.state.activeCaipNetwork?.caipNetworkId||""}}),this.sendERC20Token({receiverAddress:this.state.receiverAddress,tokenAddress:this.state.token.address,sendTokenAmount:this.state.sendTokenAmount,decimals:this.state.token.quantity.decimals})):this.state.receiverAddress&&this.state.sendTokenAmount&&this.state.gasPrice&&this.state.token?.quantity.decimals&&(g.E.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:p.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token?.symbol,amount:this.state.sendTokenAmount,network:d.W.state.activeCaipNetwork?.caipNetworkId||""}}),this.sendNativeToken({receiverAddress:this.state.receiverAddress,sendTokenAmount:this.state.sendTokenAmount,gasPrice:this.state.gasPrice,decimals:this.state.token.quantity.decimals}))},async fetchTokenBalance(e){w.loading=!0;const t=d.W.state.activeCaipNetwork?.caipNetworkId,s=d.W.state.activeCaipNetwork?.chainNamespace,i=d.W.state.activeCaipAddress,r=i?h.w.getPlainAddress(i):void 0;if(w.lastRetry&&!h.w.isAllowedRetry(w.lastRetry,30*c.oU.ONE_SEC_MS))return w.loading=!1,[];try{if(r&&t&&s){const e=await l.t.getMyTokensWithBalance();return w.tokenBalances=e,w.lastRetry=void 0,e}}catch(t){w.lastRetry=Date.now(),e?.(t),m.P.showError("Token Balance Unavailable")}finally{w.loading=!1}return[]},fetchNetworkBalance(){if(0===w.tokenBalances.length)return;const e=l.t.mapBalancesToSwapTokens(w.tokenBalances);if(!e)return;const t=e.find(e=>e.address===d.W.getActiveNetworkTokenAddress());t&&(w.networkBalanceInUSD=t?n.S.multiply(t.quantity.numeric,t.price).toString():"0")},isInsufficientNetworkTokenForGas(e,t){const s=t||"0";return!!n.S.bigNumber(e).eq(0)||n.S.bigNumber(n.S.bigNumber(s)).gt(e)},hasInsufficientGasFunds(){let e=!0;return p.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT?e=!1:w.networkBalanceInUSD&&(e=this.isInsufficientNetworkTokenForGas(w.networkBalanceInUSD,w.gasPriceInUSD)),e},async sendNativeToken(e){f.I.pushTransactionStack({view:"Account",goBack:!1});const t=e.receiverAddress,s=p.U.state.address,i=u.x.parseUnits(e.sendTokenAmount.toString(),Number(e.decimals));try{await u.x.sendTransaction({chainNamespace:"eip155",to:t,address:s,data:"0x",value:i??BigInt(0),gasPrice:e.gasPrice}),m.P.showSuccess("Transaction started"),g.E.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:p.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token?.symbol||"",amount:e.sendTokenAmount,network:d.W.state.activeCaipNetwork?.caipNetworkId||""}}),this.resetSend()}catch(t){console.error("SendController:sendERC20Token - failed to send native token",t);const s=t instanceof Error?t.message:"Unknown error";g.E.sendEvent({type:"track",event:"SEND_ERROR",properties:{message:s,isSmartAccount:p.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token?.symbol||"",amount:e.sendTokenAmount,network:d.W.state.activeCaipNetwork?.caipNetworkId||""}}),m.P.showError("Something went wrong")}},async sendERC20Token(e){f.I.pushTransactionStack({view:"Account",goBack:!1});const t=u.x.parseUnits(e.sendTokenAmount.toString(),Number(e.decimals));try{if(p.U.state.address&&e.sendTokenAmount&&e.receiverAddress&&e.tokenAddress){const s=h.w.getPlainAddress(e.tokenAddress);await u.x.writeContract({fromAddress:p.U.state.address,tokenAddress:s,args:[e.receiverAddress,t??BigInt(0)],method:"transfer",abi:o.v.getERC20Abi(s),chainNamespace:"eip155"}),m.P.showSuccess("Transaction started"),this.resetSend()}}catch(t){console.error("SendController:sendERC20Token - failed to send erc20 token",t);const s=t instanceof Error?t.message:"Unknown error";g.E.sendEvent({type:"track",event:"SEND_ERROR",properties:{message:s,isSmartAccount:p.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token?.symbol||"",amount:e.sendTokenAmount,network:d.W.state.activeCaipNetwork?.caipNetworkId||""}}),m.P.showError("Something went wrong")}},sendSolanaToken(){this.state.sendTokenAmount&&this.state.receiverAddress?(f.I.pushTransactionStack({view:"Account",goBack:!1}),u.x.sendTransaction({chainNamespace:"solana",to:this.state.receiverAddress,value:this.state.sendTokenAmount}).then(()=>{this.resetSend(),p.U.fetchTokenBalance()}).catch(e=>{m.P.showError("Failed to send transaction. Please try again."),console.error("SendController:sendToken - failed to send solana transaction",e)})):m.P.showError("Please enter a valid amount and receiver address")},resetSend(){w.token=void 0,w.sendTokenAmount=void 0,w.receiverAddress=void 0,w.receiverProfileImageUrl=void 0,w.receiverProfileName=void 0,w.loading=!1,w.tokenBalances=[]}}},18354:(e,t,s)=>{s.d(t,{g:()=>i});const i=(0,s(40149).x)({id:"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",name:"Solana Testnet",network:"solana-testnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"})},18677:(e,t,s)=>{e=s.nmd(e);var i="__lodash_hash_undefined__",r=9007199254740991,n="[object Arguments]",o="[object Array]",a="[object Boolean]",c="[object Date]",h="[object Error]",l="[object Function]",p="[object Map]",d="[object Number]",u="[object Object]",g="[object Promise]",f="[object RegExp]",m="[object Set]",w="[object String]",y="[object WeakMap]",b="[object ArrayBuffer]",v="[object DataView]",E=/^\[object .+?Constructor\]$/,I=/^(?:0|[1-9]\d*)$/,_={};_["[object Float32Array]"]=_["[object Float64Array]"]=_["[object Int8Array]"]=_["[object Int16Array]"]=_["[object Int32Array]"]=_["[object Uint8Array]"]=_["[object Uint8ClampedArray]"]=_["[object Uint16Array]"]=_["[object Uint32Array]"]=!0,_[n]=_[o]=_[b]=_[a]=_[v]=_[c]=_[h]=_[l]=_[p]=_[d]=_[u]=_[f]=_[m]=_[w]=_[y]=!1;var N="object"==typeof s.g&&s.g&&s.g.Object===Object&&s.g,A="object"==typeof self&&self&&self.Object===Object&&self,C=N||A||Function("return this")(),P=t&&!t.nodeType&&t,S=P&&e&&!e.nodeType&&e,O=S&&S.exports===P,T=O&&N.process,k=function(){try{return T&&T.binding&&T.binding("util")}catch(e){}}(),x=k&&k.isTypedArray;function R(e,t){for(var s=-1,i=null==e?0:e.length;++s<i;)if(t(e[s],s,e))return!0;return!1}function U(e){var t=-1,s=Array(e.size);return e.forEach(function(e,i){s[++t]=[i,e]}),s}function D(e){var t=-1,s=Array(e.size);return e.forEach(function(e){s[++t]=e}),s}var j,M,L,q=Array.prototype,$=Function.prototype,B=Object.prototype,H=C["__core-js_shared__"],W=$.toString,z=B.hasOwnProperty,V=(j=/[^.]+$/.exec(H&&H.keys&&H.keys.IE_PROTO||""))?"Symbol(src)_1."+j:"",F=B.toString,K=RegExp("^"+W.call(z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),G=O?C.Buffer:void 0,J=C.Symbol,Y=C.Uint8Array,Q=B.propertyIsEnumerable,X=q.splice,Z=J?J.toStringTag:void 0,ee=Object.getOwnPropertySymbols,te=G?G.isBuffer:void 0,se=(M=Object.keys,L=Object,function(e){return M(L(e))}),ie=Se(C,"DataView"),re=Se(C,"Map"),ne=Se(C,"Promise"),oe=Se(C,"Set"),ae=Se(C,"WeakMap"),ce=Se(Object,"create"),he=xe(ie),le=xe(re),pe=xe(ne),de=xe(oe),ue=xe(ae),ge=J?J.prototype:void 0,fe=ge?ge.valueOf:void 0;function me(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var i=e[t];this.set(i[0],i[1])}}function we(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var i=e[t];this.set(i[0],i[1])}}function ye(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var i=e[t];this.set(i[0],i[1])}}function be(e){var t=-1,s=null==e?0:e.length;for(this.__data__=new ye;++t<s;)this.add(e[t])}function ve(e){var t=this.__data__=new we(e);this.size=t.size}function Ee(e,t){for(var s=e.length;s--;)if(Re(e[s][0],t))return s;return-1}function Ie(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Z&&Z in Object(e)?function(e){var t=z.call(e,Z),s=e[Z];try{e[Z]=void 0;var i=!0}catch(e){}var r=F.call(e);return i&&(t?e[Z]=s:delete e[Z]),r}(e):function(e){return F.call(e)}(e)}function _e(e){return $e(e)&&Ie(e)==n}function Ne(e,t,s,i,r){return e===t||(null==e||null==t||!$e(e)&&!$e(t)?e!=e&&t!=t:function(e,t,s,i,r,l){var g=De(e),y=De(t),E=g?o:Te(e),I=y?o:Te(t),_=(E=E==n?u:E)==u,N=(I=I==n?u:I)==u,A=E==I;if(A&&je(e)){if(!je(t))return!1;g=!0,_=!1}if(A&&!_)return l||(l=new ve),g||Be(e)?Ae(e,t,s,i,r,l):function(e,t,s,i,r,n,o){switch(s){case v:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case b:return!(e.byteLength!=t.byteLength||!n(new Y(e),new Y(t)));case a:case c:case d:return Re(+e,+t);case h:return e.name==t.name&&e.message==t.message;case f:case w:return e==t+"";case p:var l=U;case m:var u=1&i;if(l||(l=D),e.size!=t.size&&!u)return!1;var g=o.get(e);if(g)return g==t;i|=2,o.set(e,t);var y=Ae(l(e),l(t),i,r,n,o);return o.delete(e),y;case"[object Symbol]":if(fe)return fe.call(e)==fe.call(t)}return!1}(e,t,E,s,i,r,l);if(!(1&s)){var C=_&&z.call(e,"__wrapped__"),P=N&&z.call(t,"__wrapped__");if(C||P){var S=C?e.value():e,O=P?t.value():t;return l||(l=new ve),r(S,O,s,i,l)}}return!!A&&(l||(l=new ve),function(e,t,s,i,r,n){var o=1&s,a=Ce(e),c=a.length;if(c!=Ce(t).length&&!o)return!1;for(var h=c;h--;){var l=a[h];if(!(o?l in t:z.call(t,l)))return!1}var p=n.get(e);if(p&&n.get(t))return p==t;var d=!0;n.set(e,t),n.set(t,e);for(var u=o;++h<c;){var g=e[l=a[h]],f=t[l];if(i)var m=o?i(f,g,l,t,e,n):i(g,f,l,e,t,n);if(!(void 0===m?g===f||r(g,f,s,i,n):m)){d=!1;break}u||(u="constructor"==l)}if(d&&!u){var w=e.constructor,y=t.constructor;w==y||!("constructor"in e)||!("constructor"in t)||"function"==typeof w&&w instanceof w&&"function"==typeof y&&y instanceof y||(d=!1)}return n.delete(e),n.delete(t),d}(e,t,s,i,r,l))}(e,t,s,i,Ne,r))}function Ae(e,t,s,i,r,n){var o=1&s,a=e.length,c=t.length;if(a!=c&&!(o&&c>a))return!1;var h=n.get(e);if(h&&n.get(t))return h==t;var l=-1,p=!0,d=2&s?new be:void 0;for(n.set(e,t),n.set(t,e);++l<a;){var u=e[l],g=t[l];if(i)var f=o?i(g,u,l,t,e,n):i(u,g,l,e,t,n);if(void 0!==f){if(f)continue;p=!1;break}if(d){if(!R(t,function(e,t){if(o=t,!d.has(o)&&(u===e||r(u,e,s,i,n)))return d.push(t);var o})){p=!1;break}}else if(u!==g&&!r(u,g,s,i,n)){p=!1;break}}return n.delete(e),n.delete(t),p}function Ce(e){return function(e,t,s){var i=t(e);return De(e)?i:function(e,t){for(var s=-1,i=t.length,r=e.length;++s<i;)e[r+s]=t[s];return e}(i,s(e))}(e,He,Oe)}function Pe(e,t){var s,i,r=e.__data__;return("string"==(i=typeof(s=t))||"number"==i||"symbol"==i||"boolean"==i?"__proto__"!==s:null===s)?r["string"==typeof t?"string":"hash"]:r.map}function Se(e,t){var s=function(e,t){return null==e?void 0:e[t]}(e,t);return function(e){return!(!qe(e)||function(e){return!!V&&V in e}(e))&&(Me(e)?K:E).test(xe(e))}(s)?s:void 0}me.prototype.clear=function(){this.__data__=ce?ce(null):{},this.size=0},me.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},me.prototype.get=function(e){var t=this.__data__;if(ce){var s=t[e];return s===i?void 0:s}return z.call(t,e)?t[e]:void 0},me.prototype.has=function(e){var t=this.__data__;return ce?void 0!==t[e]:z.call(t,e)},me.prototype.set=function(e,t){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=ce&&void 0===t?i:t,this},we.prototype.clear=function(){this.__data__=[],this.size=0},we.prototype.delete=function(e){var t=this.__data__,s=Ee(t,e);return!(s<0||(s==t.length-1?t.pop():X.call(t,s,1),--this.size,0))},we.prototype.get=function(e){var t=this.__data__,s=Ee(t,e);return s<0?void 0:t[s][1]},we.prototype.has=function(e){return Ee(this.__data__,e)>-1},we.prototype.set=function(e,t){var s=this.__data__,i=Ee(s,e);return i<0?(++this.size,s.push([e,t])):s[i][1]=t,this},ye.prototype.clear=function(){this.size=0,this.__data__={hash:new me,map:new(re||we),string:new me}},ye.prototype.delete=function(e){var t=Pe(this,e).delete(e);return this.size-=t?1:0,t},ye.prototype.get=function(e){return Pe(this,e).get(e)},ye.prototype.has=function(e){return Pe(this,e).has(e)},ye.prototype.set=function(e,t){var s=Pe(this,e),i=s.size;return s.set(e,t),this.size+=s.size==i?0:1,this},be.prototype.add=be.prototype.push=function(e){return this.__data__.set(e,i),this},be.prototype.has=function(e){return this.__data__.has(e)},ve.prototype.clear=function(){this.__data__=new we,this.size=0},ve.prototype.delete=function(e){var t=this.__data__,s=t.delete(e);return this.size=t.size,s},ve.prototype.get=function(e){return this.__data__.get(e)},ve.prototype.has=function(e){return this.__data__.has(e)},ve.prototype.set=function(e,t){var s=this.__data__;if(s instanceof we){var i=s.__data__;if(!re||i.length<199)return i.push([e,t]),this.size=++s.size,this;s=this.__data__=new ye(i)}return s.set(e,t),this.size=s.size,this};var Oe=ee?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var s=-1,i=null==e?0:e.length,r=0,n=[];++s<i;){var o=e[s];t(o)&&(n[r++]=o)}return n}(ee(e),function(t){return Q.call(e,t)}))}:function(){return[]},Te=Ie;function ke(e,t){return!!(t=null==t?r:t)&&("number"==typeof e||I.test(e))&&e>-1&&e%1==0&&e<t}function xe(e){if(null!=e){try{return W.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Re(e,t){return e===t||e!=e&&t!=t}(ie&&Te(new ie(new ArrayBuffer(1)))!=v||re&&Te(new re)!=p||ne&&Te(ne.resolve())!=g||oe&&Te(new oe)!=m||ae&&Te(new ae)!=y)&&(Te=function(e){var t=Ie(e),s=t==u?e.constructor:void 0,i=s?xe(s):"";if(i)switch(i){case he:return v;case le:return p;case pe:return g;case de:return m;case ue:return y}return t});var Ue=_e(function(){return arguments}())?_e:function(e){return $e(e)&&z.call(e,"callee")&&!Q.call(e,"callee")},De=Array.isArray,je=te||function(){return!1};function Me(e){if(!qe(e))return!1;var t=Ie(e);return t==l||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Le(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=r}function qe(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function $e(e){return null!=e&&"object"==typeof e}var Be=x?function(e){return function(t){return e(t)}}(x):function(e){return $e(e)&&Le(e.length)&&!!_[Ie(e)]};function He(e){return null!=(t=e)&&Le(t.length)&&!Me(t)?function(e,t){var s=De(e),i=!s&&Ue(e),r=!s&&!i&&je(e),n=!s&&!i&&!r&&Be(e),o=s||i||r||n,a=o?function(e,t){for(var s=-1,i=Array(e);++s<e;)i[s]=t(s);return i}(e.length,String):[],c=a.length;for(var h in e)!t&&!z.call(e,h)||o&&("length"==h||r&&("offset"==h||"parent"==h)||n&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||ke(h,c))||a.push(h);return a}(e):function(e){if(s=(t=e)&&t.constructor,t!==("function"==typeof s&&s.prototype||B))return se(e);var t,s,i=[];for(var r in Object(e))z.call(e,r)&&"constructor"!=r&&i.push(r);return i}(e);var t}e.exports=function(e,t){return Ne(e,t)}},19760:(e,t,s)=>{async function i(...e){const t=await fetch(...e);if(!t.ok)throw new Error(`HTTP status code: ${t.status}`,{cause:t});return t}s.d(t,{Z:()=>r});class r{constructor({baseUrl:e,clientId:t}){this.baseUrl=e,this.clientId=t}async get({headers:e,signal:t,cache:s,...r}){const n=this.createUrl(r);return(await i(n,{method:"GET",headers:e,signal:t,cache:s})).json()}async getBlob({headers:e,signal:t,...s}){const r=this.createUrl(s);return(await i(r,{method:"GET",headers:e,signal:t})).blob()}async post({body:e,headers:t,signal:s,...r}){const n=this.createUrl(r);return(await i(n,{method:"POST",headers:t,body:e?JSON.stringify(e):void 0,signal:s})).json()}async put({body:e,headers:t,signal:s,...r}){const n=this.createUrl(r);return(await i(n,{method:"PUT",headers:t,body:e?JSON.stringify(e):void 0,signal:s})).json()}async delete({body:e,headers:t,signal:s,...r}){const n=this.createUrl(r);return(await i(n,{method:"DELETE",headers:t,body:e?JSON.stringify(e):void 0,signal:s})).json()}createUrl({path:e,params:t}){const s=new URL(e,this.baseUrl);return t&&Object.entries(t).forEach(([e,t])=>{t&&s.searchParams.append(e,t)}),this.clientId&&s.searchParams.append("clientId",this.clientId),s}}},21910:(e,t,s)=>{s.d(t,{$Q:()=>b,GF:()=>y,S9:()=>I,Vx:()=>m,ZP:()=>c,dQ:()=>p,lZ:()=>l,m5:()=>u,mF:()=>f,pi:()=>g,qE:()=>d,yJ:()=>_,zl:()=>w});var i=s(94549),r=s(50046),n=s.n(r),o=Object.defineProperty,a=(e,t,s)=>((e,t,s)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class c extends i.H{constructor(e){super(),this.opts=e,a(this,"protocol","wc"),a(this,"version",2)}}var h=Object.defineProperty;class l extends i.H{constructor(e,t){super(),this.core=e,this.logger=t,((e,t,s)=>{((e,t,s)=>{t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s})(e,"symbol"!=typeof t?t+"":t,s)})(this,"records",new Map)}}class p{constructor(e,t){this.logger=e,this.core=t}}class d extends i.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class u extends i.H{constructor(e){super()}}class g{constructor(e,t,s,i){this.core=e,this.logger=t,this.name=s}}Object.defineProperty;class f extends i.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class m extends i.H{constructor(e,t){super(),this.core=e,this.logger=t}}class w{constructor(e,t,s){this.core=e,this.logger=t,this.store=s}}class y{constructor(e,t){this.projectId=e,this.logger=t}}class b{constructor(e,t,s){this.core=e,this.logger=t,this.telemetryEnabled=s}}var v=Object.defineProperty,E=(e,t,s)=>((e,t,s)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);n();class I{constructor(e){this.opts=e,E(this,"protocol","wc"),E(this,"version",2)}}r.EventEmitter;class _{constructor(e){this.client=e}}},22233:(e,t,s)=>{s.d(t,{S:()=>r});var i=s(66857);const r={bigNumber:e=>e?new i.A(e):new i.A(0),multiply(e,t){if(void 0===e||void 0===t)return new i.A(0);const s=new i.A(e),r=new i.A(t);return s.times(r)},formatNumberToLocalString:(e,t=2)=>void 0===e?"0.00":"number"==typeof e?e.toLocaleString("en-US",{maximumFractionDigits:t,minimumFractionDigits:t}):parseFloat(e).toLocaleString("en-US",{maximumFractionDigits:t,minimumFractionDigits:t}),parseLocalStringToNumber:e=>void 0===e?0:parseFloat(e.replace(/,/gu,""))}},24096:(e,t,s)=>{s.d(t,{Aj:()=>i.A}),s(24313),s(74091);var i=s(38753)},24210:(e,t,s)=>{s.d(t,{JX:()=>h,RF:()=>c,W5:()=>d,ck:()=>g,ds:()=>l,fD:()=>u});var i=s(35842),r=s(11807);let n,o,a;function c(e,t){n=document.createElement("style"),o=document.createElement("style"),a=document.createElement("style"),n.textContent=p(e).core.cssText,o.textContent=p(e).dark.cssText,a.textContent=p(e).light.cssText,document.head.appendChild(n),document.head.appendChild(o),document.head.appendChild(a),h(t)}function h(e){o&&a&&("light"===e?(o.removeAttribute("media"),a.media="enabled"):(a.removeAttribute("media"),o.media="enabled"))}function l(e){n&&o&&a&&(n.textContent=p(e).core.cssText,o.textContent=p(e).dark.cssText,a.textContent=p(e).light.cssText)}function p(e){return{core:i.AH`
|
|
2
|
+
export const __webpack_esm_id__=7201;export const __webpack_esm_ids__=[7201];export const __webpack_esm_modules__={600:(e,t,i)=>{var s=i(70461).rotr32;function r(e,t,i){return e&t^~e&i}function n(e,t,i){return e&t^e&i^t&i}function o(e,t,i){return e^t^i}t.ft_1=function(e,t,i,s){return 0===e?r(t,i,s):1===e||3===e?o(t,i,s):2===e?n(t,i,s):void 0},t.ch32=r,t.maj32=n,t.p32=o,t.s0_256=function(e){return s(e,2)^s(e,13)^s(e,22)},t.s1_256=function(e){return s(e,6)^s(e,11)^s(e,25)},t.g0_256=function(e){return s(e,7)^s(e,18)^e>>>3},t.g1_256=function(e){return s(e,17)^s(e,19)^e>>>10}},3496:(e,t,i)=>{i.d(t,{r:()=>h});var s=i(23464),r=i(38851),n=i(25562),o=i(93384);s.extend(n),s.extend(o);const a={...r,name:"en-web3-modal",relativeTime:{future:"in %s",past:"%s ago",s:"%d sec",m:"1 min",mm:"%d min",h:"1 hr",hh:"%d hrs",d:"1 d",dd:"%d d",M:"1 mo",MM:"%d mo",y:"1 yr",yy:"%d yr"}},c=["January","February","March","April","May","June","July","August","September","October","November","December"];s.locale("en-web3-modal",a);const h={getMonthNameByIndex:e=>c[e],getYear:(e=(new Date).toISOString())=>s(e).year(),getRelativeDateFromNow:e=>s(e).locale("en-web3-modal").fromNow(!0),formatDate:(e,t="DD MMM")=>s(e).format(t)}},3665:(e,t,i)=>{i.d(t,{$Q:()=>w,GF:()=>y,S9:()=>E,Vx:()=>m,ZP:()=>c,dQ:()=>l,lZ:()=>d,m5:()=>p,mF:()=>g,pi:()=>f,qE:()=>u,yJ:()=>_,zl:()=>b});var s=i(94549),r=i(50046),n=i.n(r),o=Object.defineProperty,a=(e,t,i)=>((e,t,i)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class c extends s.H{constructor(e){super(),this.opts=e,a(this,"protocol","wc"),a(this,"version",2)}}var h=Object.defineProperty;class d extends s.H{constructor(e,t){super(),this.core=e,this.logger=t,((e,t,i)=>{((e,t,i)=>{t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i})(e,"symbol"!=typeof t?t+"":t,i)})(this,"records",new Map)}}class l{constructor(e,t){this.logger=e,this.core=t}}class u extends s.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class p extends s.H{constructor(e){super()}}class f{constructor(e,t,i,s){this.core=e,this.logger=t,this.name=i}}Object.defineProperty;class g extends s.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class m extends s.H{constructor(e,t){super(),this.core=e,this.logger=t}}class b{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}}class y{constructor(e,t){this.projectId=e,this.logger=t}}class w{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}}var v=Object.defineProperty,I=(e,t,i)=>((e,t,i)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);n();class E{constructor(e){this.opts=e,I(this,"protocol","wc"),I(this,"version",2)}}r.EventEmitter;class _{constructor(e){this.client=e}}},5813:(e,t,i)=>{i.d(t,{w:()=>o});var s=i(95191),r=i(84253),n=i(11553);const o={isMobile(){return!!this.isClient()&&Boolean(window?.matchMedia("(pointer:coarse)")?.matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent))},checkCaipNetwork:(e,t="")=>e?.caipNetworkId.toLocaleLowerCase().includes(t.toLowerCase()),isAndroid(){if(!this.isMobile())return!1;const e=window?.navigator.userAgent.toLowerCase();return o.isMobile()&&e.includes("android")},isIos(){if(!this.isMobile())return!1;const e=window?.navigator.userAgent.toLowerCase();return e.includes("iphone")||e.includes("ipad")},isSafari(){if(!this.isClient())return!1;const e=window?.navigator.userAgent.toLowerCase();return e.includes("safari")},isClient:()=>"undefined"!=typeof window,isPairingExpired:e=>!e||e-Date.now()<=r.oU.TEN_SEC_MS,isAllowedRetry:(e,t=r.oU.ONE_SEC_MS)=>Date.now()-e>=t,copyToClopboard(e){navigator.clipboard.writeText(e)},isIframe(){try{return window?.self!==window?.top}catch(e){return!1}},getPairingExpiry:()=>Date.now()+r.oU.FOUR_MINUTES_MS,getNetworkId:e=>e?.split(":")[1],getPlainAddress:e=>e?.split(":")[2],wait:async e=>new Promise(t=>{setTimeout(t,e)}),debounce(e,t=500){let i;return(...s)=>{i&&clearTimeout(i),i=setTimeout(function(){e(...s)},t)}},isHttpUrl:e=>e.startsWith("http://")||e.startsWith("https://"),formatNativeUrl(e,t){if(o.isHttpUrl(e))return this.formatUniversalUrl(e,t);let i=e;return i.includes("://")||(i=e.replaceAll("/","").replaceAll(":",""),i=`${i}://`),i.endsWith("/")||(i=`${i}/`),this.isTelegram()&&this.isAndroid()&&(t=encodeURIComponent(t)),{redirect:`${i}wc?uri=${encodeURIComponent(t)}`,href:i}},formatUniversalUrl(e,t){if(!o.isHttpUrl(e))return this.formatNativeUrl(e,t);let i=e;return i.endsWith("/")||(i=`${i}/`),{redirect:`${i}wc?uri=${encodeURIComponent(t)}`,href:i}},getOpenTargetForPlatform(e){return"popupWindow"===e?e:this.isTelegram()?n.i.getTelegramSocialProvider()?"_top":"_blank":e},openHref(e,t,i){window?.open(e,this.getOpenTargetForPlatform(t),i||"noreferrer noopener")},returnOpenHref(e,t,i){return window?.open(e,this.getOpenTargetForPlatform(t),i||"noreferrer noopener")},isTelegram:()=>"undefined"!=typeof window&&(Boolean(window.TelegramWebviewProxy)||Boolean(window.Telegram)||Boolean(window.TelegramWebviewProxyProto)),async preloadImage(e){const t=new Promise((t,i)=>{const s=new Image;s.onload=t,s.onerror=i,s.crossOrigin="anonymous",s.src=e});return Promise.race([t,o.wait(2e3)])},formatBalance(e,t){let i="0.000";if("string"==typeof e){const t=Number(e);if(t){const e=Math.floor(1e3*t)/1e3;e&&(i=e.toString())}}return`${i}${t?` ${t}`:""}`},formatBalance2(e,t){let i;if("0"===e)i="0";else if("string"==typeof e){const t=Number(e);t&&(i=t.toString().match(/^-?\d+(?:\.\d{0,3})?/u)?.[0])}return{value:i??"0",rest:"0"===i?"000":"",symbol:t}},getApiUrl:()=>s.o.W3M_API_URL,getBlockchainApiUrl:()=>s.o.BLOCKCHAIN_API_RPC_URL,getAnalyticsUrl:()=>s.o.PULSE_API_URL,getUUID:()=>crypto?.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}),parseError:e=>"string"==typeof e?e:"string"==typeof e?.issues?.[0]?.message?e.issues[0].message:e instanceof Error?e.message:"Unknown error",sortRequestedNetworks(e,t=[]){const i={};return t&&e&&(e.forEach((e,t)=>{i[e]=t}),t.sort((e,t)=>{const s=i[e.id],r=i[t.id];return void 0!==s&&void 0!==r?s-r:void 0!==s?-1:void 0!==r?1:0})),t},calculateBalance(e){let t=0;for(const i of e)t+=i.value??0;return t},formatTokenBalance(e){const t=e.toFixed(2),[i,s]=t.split(".");return{dollars:i,pennies:s}},isAddress(e,t="eip155"){switch(t){case"eip155":return!(!/^(?:0x)?[0-9a-f]{40}$/iu.test(e)||!/^(?:0x)?[0-9a-f]{40}$/iu.test(e)&&!/^(?:0x)?[0-9A-F]{40}$/iu.test(e));case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(e);default:return!1}},uniqueBy(e,t){const i=new Set;return e.filter(e=>{const s=e[t];return!i.has(s)&&(i.add(s),!0)})},generateSdkVersion:(e,t,i)=>`${t}-${0===e.length?r.oU.ADAPTER_TYPES.UNIVERSAL:e.map(e=>e.adapterType).join(",")}-${i}`,createAccount:(e,t,i,s,r)=>({namespace:e,address:t,type:i,publicKey:s,path:r}),isCaipAddress(e){if("string"!=typeof e)return!1;const t=e.split(":"),i=t[0];return 3===t.filter(Boolean).length&&i in s.o.CHAIN_NAME_MAP},isMac(){const e=window?.navigator.userAgent.toLowerCase();return e.includes("macintosh")&&!e.includes("safari")},formatTelegramSocialLoginUrl(e){const t=`--${encodeURIComponent(window?.location.href)}`,i="state=";if("auth.magic.link"===new URL(e).host){const s="provider_authorization_url=",r=e.substring(e.indexOf(s)+s.length),n=this.injectIntoUrl(decodeURIComponent(r),i,t);return e.replace(r,encodeURIComponent(n))}return this.injectIntoUrl(e,i,t)},injectIntoUrl(e,t,i){const s=e.indexOf(t);if(-1===s)throw new Error(`${t} parameter not found in the URL: ${e}`);const r=e.indexOf("&",s),n=t.length,o=-1!==r?r:e.length;return e.substring(0,s+n)+(e.substring(s+n,o)+i)+e.substring(r)}}},7131:(e,t,i)=>{var s=t;s.base=i(85174),s.short=i(60277),s.mont=i(63245),s.edwards=i(21547)},7784:e=>{function t(e,t){if(!e)throw new Error(t||"Assertion failed")}e.exports=t,t.equal=function(e,t,i){if(e!=t)throw new Error(i||"Assertion failed: "+e+" != "+t)}},8834:(e,t,i)=>{i.d(t,{v:()=>a});var s=i(10550),r=i(49009),n=i(55770),o=i(95191);const a={getERC20Abi:e=>o.o.USDT_CONTRACT_ADDRESSES.includes(e)?n.r:s.F,getSwapAbi:()=>r.Q}},9663:(e,t,i)=>{i.d(t,{Vl:()=>r});var s=i(39907);void 0!==s&&void 0!==s.env&&s.env.NEXT_PUBLIC_SECURE_SITE_SDK_URL,void 0!==s&&void 0!==s.env&&s.env.NEXT_PUBLIC_DEFAULT_LOG_LEVEL,void 0!==s&&void 0!==s.env&&s.env.NEXT_PUBLIC_SECURE_SITE_SDK_VERSION;const r={SAFE_RPC_METHODS:["eth_accounts","eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","eth_feeHistory","eth_gasPrice","eth_getAccount","eth_getBalance","eth_getBlockByHash","eth_getBlockByNumber","eth_getBlockReceipts","eth_getBlockTransactionCountByHash","eth_getBlockTransactionCountByNumber","eth_getCode","eth_getFilterChanges","eth_getFilterLogs","eth_getLogs","eth_getProof","eth_getStorageAt","eth_getTransactionByBlockHashAndIndex","eth_getTransactionByBlockNumberAndIndex","eth_getTransactionByHash","eth_getTransactionCount","eth_getTransactionReceipt","eth_getUncleCountByBlockHash","eth_getUncleCountByBlockNumber","eth_maxPriorityFeePerGas","eth_newBlockFilter","eth_newFilter","eth_newPendingTransactionFilter","eth_sendRawTransaction","eth_syncing","eth_uninstallFilter","wallet_getCapabilities","wallet_getCallsStatus","eth_getUserOperationReceipt","eth_estimateUserOperationGas","eth_getUserOperationByHash","eth_supportedEntryPoints","wallet_getAssets"],NOT_SAFE_RPC_METHODS:["personal_sign","eth_signTypedData_v4","eth_sendTransaction","solana_signMessage","solana_signTransaction","solana_signAllTransactions","solana_signAndSendTransaction","wallet_sendCalls","wallet_grantPermissions","wallet_revokePermissions","eth_sendUserOperation"],GET_CHAIN_ID:"eth_chainId",RPC_METHOD_NOT_ALLOWED_MESSAGE:"Requested RPC call is not allowed",RPC_METHOD_NOT_ALLOWED_UI_MESSAGE:"Action not allowed",ACCOUNT_TYPES:{EOA:"eoa",SMART_ACCOUNT:"smartAccount"}}},10550:(e,t,i)=>{i.d(t,{F:()=>s});const s=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]}]},11553:(e,t,i)=>{i.d(t,{i:()=>r});var s=i(32681);const r={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5},isCacheExpired:(e,t)=>Date.now()-e>t,getActiveNetworkProps(){const e=r.getActiveNamespace(),t=r.getActiveCaipNetworkId(),i=t?t.split(":")[1]:void 0;return{namespace:e,caipNetworkId:t,chainId:i?isNaN(Number(i))?i:Number(i):void 0}},setWalletConnectDeepLink({name:e,href:t}){try{s.Ud.setItem(s.Ws.DEEPLINK_CHOICE,JSON.stringify({href:t,name:e}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const e=s.Ud.getItem(s.Ws.DEEPLINK_CHOICE);if(e)return JSON.parse(e)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{s.Ud.removeItem(s.Ws.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(e){try{s.Ud.setItem(s.Ws.ACTIVE_NAMESPACE,e)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(e){try{s.Ud.setItem(s.Ws.ACTIVE_CAIP_NETWORK_ID,e),r.setActiveNamespace(e.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return s.Ud.getItem(s.Ws.ACTIVE_CAIP_NETWORK_ID)}catch{return void console.info("Unable to get active caip network id")}},deleteActiveCaipNetworkId(){try{s.Ud.removeItem(s.Ws.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(e){try{const t=(0,s.T8)(e);s.Ud.removeItem(t)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(e){try{const t=r.getRecentWallets();t.find(t=>t.id===e.id)||(t.unshift(e),t.length>2&&t.pop(),s.Ud.setItem(s.Ws.RECENT_WALLETS,JSON.stringify(t)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const e=s.Ud.getItem(s.Ws.RECENT_WALLETS);return e?JSON.parse(e):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(e,t){try{const i=(0,s.T8)(e);s.Ud.setItem(i,t)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return s.Ud.getItem(s.Ws.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(e){if(e)try{const t=(0,s.T8)(e);return s.Ud.getItem(t)}catch(t){console.info("Unable to get connected connector id in namespace ",e)}},setConnectedSocialProvider(e){try{s.Ud.setItem(s.Ws.CONNECTED_SOCIAL,e)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return s.Ud.getItem(s.Ws.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{s.Ud.removeItem(s.Ws.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return s.Ud.getItem(s.Ws.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){const e=s.Ud.getItem(s.Ws.ACTIVE_CAIP_NETWORK_ID),t=e?.split(":")?.[1];return t},setConnectionStatus(e){try{s.Ud.setItem(s.Ws.CONNECTION_STATUS,e)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return s.Ud.getItem(s.Ws.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const e=s.Ud.getItem(s.Ws.CONNECTED_NAMESPACES);return e?.length?e.split(","):[]}catch{return[]}},setConnectedNamespaces(e){try{const t=Array.from(new Set(e));s.Ud.setItem(s.Ws.CONNECTED_NAMESPACES,t.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(e){try{const t=r.getConnectedNamespaces();t.includes(e)||(t.push(e),r.setConnectedNamespaces(t))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(e){try{const t=r.getConnectedNamespaces(),i=t.indexOf(e);i>-1&&(t.splice(i,1),r.setConnectedNamespaces(t))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return s.Ud.getItem(s.Ws.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(e){try{s.Ud.setItem(s.Ws.TELEGRAM_SOCIAL_PROVIDER,e)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{s.Ud.removeItem(s.Ws.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let e={};try{const t=s.Ud.getItem(s.Ws.PORTFOLIO_CACHE);e=t?JSON.parse(t):{}}catch{console.info("Unable to get balance cache")}return e},removeAddressFromBalanceCache(e){try{const t=r.getBalanceCache();s.Ud.setItem(s.Ws.PORTFOLIO_CACHE,JSON.stringify({...t,[e]:void 0}))}catch{console.info("Unable to remove address from balance cache",e)}},getBalanceCacheForCaipAddress(e){try{const t=r.getBalanceCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.portfolio))return t.balance;r.removeAddressFromBalanceCache(e)}catch{console.info("Unable to get balance cache for address",e)}},updateBalanceCache(e){try{const t=r.getBalanceCache();t[e.caipAddress]=e,s.Ud.setItem(s.Ws.PORTFOLIO_CACHE,JSON.stringify(t))}catch{console.info("Unable to update balance cache",e)}},getNativeBalanceCache(){let e={};try{const t=s.Ud.getItem(s.Ws.NATIVE_BALANCE_CACHE);e=t?JSON.parse(t):{}}catch{console.info("Unable to get balance cache")}return e},removeAddressFromNativeBalanceCache(e){try{const t=r.getBalanceCache();s.Ud.setItem(s.Ws.NATIVE_BALANCE_CACHE,JSON.stringify({...t,[e]:void 0}))}catch{console.info("Unable to remove address from balance cache",e)}},getNativeBalanceCacheForCaipAddress(e){try{const t=r.getNativeBalanceCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.nativeBalance))return t;console.info("Discarding cache for address",e),r.removeAddressFromBalanceCache(e)}catch{console.info("Unable to get balance cache for address",e)}},updateNativeBalanceCache(e){try{const t=r.getNativeBalanceCache();t[e.caipAddress]=e,s.Ud.setItem(s.Ws.NATIVE_BALANCE_CACHE,JSON.stringify(t))}catch{console.info("Unable to update balance cache",e)}},getEnsCache(){let e={};try{const t=s.Ud.getItem(s.Ws.ENS_CACHE);e=t?JSON.parse(t):{}}catch{console.info("Unable to get ens name cache")}return e},getEnsFromCacheForAddress(e){try{const t=r.getEnsCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.ens))return t.ens;r.removeEnsFromCache(e)}catch{console.info("Unable to get ens name from cache",e)}},updateEnsCache(e){try{const t=r.getEnsCache();t[e.address]=e,s.Ud.setItem(s.Ws.ENS_CACHE,JSON.stringify(t))}catch{console.info("Unable to update ens name cache",e)}},removeEnsFromCache(e){try{const t=r.getEnsCache();s.Ud.setItem(s.Ws.ENS_CACHE,JSON.stringify({...t,[e]:void 0}))}catch{console.info("Unable to remove ens name from cache",e)}},getIdentityCache(){let e={};try{const t=s.Ud.getItem(s.Ws.IDENTITY_CACHE);e=t?JSON.parse(t):{}}catch{console.info("Unable to get identity cache")}return e},getIdentityFromCacheForAddress(e){try{const t=r.getIdentityCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.identity))return t.identity;r.removeIdentityFromCache(e)}catch{console.info("Unable to get identity from cache",e)}},updateIdentityCache(e){try{const t=r.getIdentityCache();t[e.address]={identity:e.identity,timestamp:e.timestamp},s.Ud.setItem(s.Ws.IDENTITY_CACHE,JSON.stringify(t))}catch{console.info("Unable to update identity cache",e)}},removeIdentityFromCache(e){try{const t=r.getIdentityCache();s.Ud.setItem(s.Ws.IDENTITY_CACHE,JSON.stringify({...t,[e]:void 0}))}catch{console.info("Unable to remove identity from cache",e)}},clearAddressCache(){try{s.Ud.removeItem(s.Ws.PORTFOLIO_CACHE),s.Ud.removeItem(s.Ws.NATIVE_BALANCE_CACHE),s.Ud.removeItem(s.Ws.ENS_CACHE),s.Ud.removeItem(s.Ws.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}}}},11629:(e,t,i)=>{i.d(t,{$I:()=>X,$w:()=>J,Jf:()=>P,S$:()=>Y,Tn:()=>ee,U:()=>Q,U$:()=>Z,WB:()=>F,cV:()=>M,iJ:()=>Yi,il:()=>yi,sD:()=>C,wn:()=>W,zN:()=>$});var s=i(50046),r=i.n(s),n=i(37147),o=i(81030),a=i(70255),c=i(3665),h=i(91315),d=i(25607),l=i(97353),u=i(76754),p=i(1030),f=i(93786),g=i(14350),m=i(63342),b=i(18677),y=i.n(b),w=i(20635);const v="core",I=`wc@2:${v}:`,E={database:":memory:"},_="client_ed25519_seed",A=h.ONE_DAY,N=h.SIX_HOURS,C="irn",S="wss://relay.walletconnect.org",P={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},O="payload",T="connect",x="disconnect",k="error",R="2.19.0",M={link_mode:"link_mode",relay:"relay"},U="WALLETCONNECT_LINK_MODE_APPS",D="subscription_created",j="subscription_deleted",L=1e3*h.FIVE_SECONDS,q={wc_pairingDelete:{req:{ttl:h.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:h.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:h.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:h.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:h.ONE_DAY,prompt:!1,tag:0},res:{ttl:h.ONE_DAY,prompt:!1,tag:0}}},$={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},B="history_created",z="history_updated",H="history_deleted",W={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},V="https://verify.walletconnect.org",F=V,K=`${F}/v3`,G=["https://verify.walletconnect.com",V],J={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},Y={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},X={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Q={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Z={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},ee={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"};const te=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class ie{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class se{constructor(e,t,i){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return ne(this,e)}}class re{constructor(e){this.decoders=e}or(e){return ne(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const ne=(e,t)=>new re({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class oe{constructor(e,t,i,s){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=s,this.encoder=new ie(e,t,i),this.decoder=new se(e,t,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const ae=({name:e,prefix:t,encode:i,decode:s})=>new oe(e,t,i,s),ce=({prefix:e,name:t,alphabet:i})=>{const{encode:s,decode:r}=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var i=new Uint8Array(256),s=0;s<i.length;s++)i[s]=255;for(var r=0;r<e.length;r++){var n=e.charAt(r),o=n.charCodeAt(0);if(255!==i[o])throw new TypeError(n+" is ambiguous");i[o]=r}var a=e.length,c=e.charAt(0),h=Math.log(a)/Math.log(256),d=Math.log(256)/Math.log(a);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var s=0,r=0;e[t]===c;)s++,t++;for(var n=(e.length-t)*h+1>>>0,o=new Uint8Array(n);e[t];){var d=i[e.charCodeAt(t)];if(255===d)return;for(var l=0,u=n-1;(0!==d||l<r)&&-1!==u;u--,l++)d+=a*o[u]>>>0,o[u]=d%256>>>0,d=d/256>>>0;if(0!==d)throw new Error("Non-zero carry");r=l,t++}if(" "!==e[t]){for(var p=n-r;p!==n&&0===o[p];)p++;for(var f=new Uint8Array(s+(n-p)),g=s;p!==n;)f[g++]=o[p++];return f}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var i=0,s=0,r=0,n=t.length;r!==n&&0===t[r];)r++,i++;for(var o=(n-r)*d+1>>>0,h=new Uint8Array(o);r!==n;){for(var l=t[r],u=0,p=o-1;(0!==l||u<s)&&-1!==p;p--,u++)l+=256*h[p]>>>0,h[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");s=u,r++}for(var f=o-s;f!==o&&0===h[f];)f++;for(var g=c.repeat(i);f<o;++f)g+=e.charAt(h[f]);return g},decodeUnsafe:l,decode:function(e){var i=l(e);if(i)return i;throw new Error(`Non-${t} character`)}}}(i,t);return ae({prefix:e,name:t,encode:s,decode:e=>te(r(e))})},he=({name:e,prefix:t,bitsPerChar:i,alphabet:s})=>ae({prefix:t,name:e,encode:e=>((e,t,i)=>{const s="="===t[t.length-1],r=(1<<i)-1;let n="",o=0,a=0;for(let s=0;s<e.length;++s)for(a=a<<8|e[s],o+=8;o>i;)o-=i,n+=t[r&a>>o];if(o&&(n+=t[r&a<<i-o]),s)for(;n.length*i&7;)n+="=";return n})(e,s,i),decode:t=>((e,t,i,s)=>{const r={};for(let e=0;e<t.length;++e)r[t[e]]=e;let n=e.length;for(;"="===e[n-1];)--n;const o=new Uint8Array(n*i/8|0);let a=0,c=0,h=0;for(let t=0;t<n;++t){const n=r[e[t]];if(void 0===n)throw new SyntaxError(`Non-${s} character`);c=c<<i|n,a+=i,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=i||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,s,i,e)}),de=ae({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var le=Object.freeze({__proto__:null,identity:de});const ue=he({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var pe=Object.freeze({__proto__:null,base2:ue});const fe=he({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ge=Object.freeze({__proto__:null,base8:fe});const me=ce({prefix:"9",name:"base10",alphabet:"0123456789"});var be=Object.freeze({__proto__:null,base10:me});const ye=he({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),we=he({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var ve=Object.freeze({__proto__:null,base16:ye,base16upper:we});const Ie=he({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ee=he({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),_e=he({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),Ae=he({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ne=he({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ce=he({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Se=he({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Pe=he({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Oe=he({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Te=Object.freeze({__proto__:null,base32:Ie,base32upper:Ee,base32pad:_e,base32padupper:Ae,base32hex:Ne,base32hexupper:Ce,base32hexpad:Se,base32hexpadupper:Pe,base32z:Oe});const xe=ce({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ke=ce({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Re=Object.freeze({__proto__:null,base36:xe,base36upper:ke});const Me=ce({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ue=ce({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var De=Object.freeze({__proto__:null,base58btc:Me,base58flickr:Ue});const je=he({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Le=he({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),qe=he({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),$e=he({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Be=Object.freeze({__proto__:null,base64:je,base64pad:Le,base64url:qe,base64urlpad:$e});const ze=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),He=ze.reduce((e,t,i)=>(e[i]=t,e),[]),We=ze.reduce((e,t,i)=>(e[t.codePointAt(0)]=i,e),[]),Ve=ae({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce((e,t)=>e+He[t],"")},decode:function(e){const t=[];for(const i of e){const e=We[i.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${i}`);t.push(e)}return new Uint8Array(t)}});var Fe=Object.freeze({__proto__:null,base256emoji:Ve}),Ke=128,Ge=-128,Je=Math.pow(2,31),Ye=Math.pow(2,7),Xe=Math.pow(2,14),Qe=Math.pow(2,21),Ze=Math.pow(2,28),et=Math.pow(2,35),tt=Math.pow(2,42),it=Math.pow(2,49),st=Math.pow(2,56),rt=Math.pow(2,63),nt=function e(t,i,s){i=i||[];for(var r=s=s||0;t>=Je;)i[s++]=255&t|Ke,t/=128;for(;t&Ge;)i[s++]=255&t|Ke,t>>>=7;return i[s]=0|t,e.bytes=s-r+1,i},ot=function(e){return e<Ye?1:e<Xe?2:e<Qe?3:e<Ze?4:e<et?5:e<tt?6:e<it?7:e<st?8:e<rt?9:10};const at=(e,t,i=0)=>(nt(e,t,i),t),ct=e=>ot(e),ht=(e,t)=>{const i=t.byteLength,s=ct(e),r=s+ct(i),n=new Uint8Array(r+i);return at(e,n,0),at(i,n,s),n.set(t,r),new dt(e,i,t,n)};class dt{constructor(e,t,i,s){this.code=e,this.size=t,this.digest=i,this.bytes=s}}const lt=({name:e,code:t,encode:i})=>new ut(e,t,i);class ut{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ht(this.code,t):t.then(e=>ht(this.code,e))}throw Error("Unknown type, must be binary type")}}const pt=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),ft=lt({name:"sha2-256",code:18,encode:pt("SHA-256")}),gt=lt({name:"sha2-512",code:19,encode:pt("SHA-512")});Object.freeze({__proto__:null,sha256:ft,sha512:gt});const mt=te,bt={code:0,name:"identity",encode:mt,digest:e=>ht(0,mt(e))};Object.freeze({__proto__:null,identity:bt}),new TextEncoder,new TextDecoder;const yt={...le,...pe,...ge,...be,...ve,...Te,...Re,...De,...Be,...Fe};function wt(e,t,i,s){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:i},decoder:{decode:s}}}const vt=wt("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>(new TextEncoder).encode(e.substring(1))),It=wt("ascii","a",e=>{let t="a";for(let i=0;i<e.length;i++)t+=String.fromCharCode(e[i]);return t},e=>{const t=function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}((e=e.substring(1)).length);for(let i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}),Et={utf8:vt,"utf-8":vt,hex:yt.base16,latin1:It,ascii:It,binary:It,...yt};var _t=Object.defineProperty,At=(e,t,i)=>((e,t,i)=>t in e?_t(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Nt{constructor(e,t){this.core=e,this.logger=t,At(this,"keychain",new Map),At(this,"name","keychain"),At(this,"version","0.3"),At(this,"initialized",!1),At(this,"storagePrefix",I),At(this,"init",async()=>{if(!this.initialized){const e=await this.getKeyChain();typeof e<"u"&&(this.keychain=e),this.initialized=!0}}),At(this,"has",e=>(this.isInitialized(),this.keychain.has(e))),At(this,"set",async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()}),At(this,"get",e=>{this.isInitialized();const t=this.keychain.get(e);if(typeof t>"u"){const{message:t}=(0,u.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}),At(this,"del",async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()}),this.core=e,this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,(0,u.h0Y)(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?(0,u.PUk)(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Ct=Object.defineProperty,St=(e,t,i)=>((e,t,i)=>t in e?Ct(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Pt{constructor(e,t,i){this.core=e,this.logger=t,St(this,"name","crypto"),St(this,"keychain"),St(this,"randomSessionIdentifier",(0,u.two)()),St(this,"initialized",!1),St(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),St(this,"hasKeys",e=>(this.isInitialized(),this.keychain.has(e))),St(this,"getClientId",async()=>{this.isInitialized();const e=await this.getClientSeed(),t=l.TZ(e);return l.UF(t.publicKey)}),St(this,"generateKeyPair",()=>{this.isInitialized();const e=(0,u.TZl)();return this.setPrivateKey(e.publicKey,e.privateKey)}),St(this,"signJWT",async e=>{this.isInitialized();const t=await this.getClientSeed(),i=l.TZ(t),s=this.randomSessionIdentifier,r=A;return await l.FA(s,e,r,i)}),St(this,"generateSharedKey",(e,t,i)=>{this.isInitialized();const s=this.getPrivateKey(e),r=(0,u.ovp)(s,t);return this.setSymKey(r,i)}),St(this,"setSymKey",async(e,t)=>{this.isInitialized();const i=t||(0,u.EN$)(e);return await this.keychain.set(i,e),i}),St(this,"deleteKeyPair",async e=>{this.isInitialized(),await this.keychain.del(e)}),St(this,"deleteSymKey",async e=>{this.isInitialized(),await this.keychain.del(e)}),St(this,"encode",async(e,t,i)=>{this.isInitialized();const s=(0,u.AwN)(i),r=(0,d.h)(t);if((0,u.ps1)(s))return(0,u.Tw2)(r,i?.encoding);if((0,u.V7m)(s)){const t=s.senderPublicKey,i=s.receiverPublicKey;e=await this.generateSharedKey(t,i)}const n=this.getSymKey(e),{type:o,senderPublicKey:a}=s;return(0,u.wa2)({type:o,symKey:n,message:r,senderPublicKey:a,encoding:i?.encoding})}),St(this,"decode",async(e,t,i)=>{this.isInitialized();const s=(0,u.C5G)(t,i);if((0,u.ps1)(s)){const e=(0,u.F$L)(t,i?.encoding);return(0,d.j)(e)}if((0,u.V7m)(s)){const t=s.receiverPublicKey,i=s.senderPublicKey;e=await this.generateSharedKey(t,i)}try{const s=this.getSymKey(e),r=(0,u.YcA)({symKey:s,encoded:t,encoding:i?.encoding});return(0,d.j)(r)}catch(t){this.logger.error(`Failed to decode message from topic: '${e}', clientId: '${await this.getClientId()}'`),this.logger.error(t)}}),St(this,"getPayloadType",(e,t=u.EWt)=>{const i=(0,u.iui)({encoded:e,encoding:t});return(0,u.x0t)(i.type)}),St(this,"getPayloadSenderPublicKey",(e,t=u.EWt)=>{const i=(0,u.iui)({encoded:e,encoding:t});return i.senderPublicKey?(0,p.dI)(i.senderPublicKey,u.bEt):void 0}),this.core=e,this.logger=(0,a.U5)(t,this.name),this.keychain=i||new Nt(this.core,this.logger)}get context(){return(0,a.oI)(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(_)}catch{e=(0,u.two)(),await this.keychain.set(_,e)}return function(e,t="utf8"){const i=Et[t];if(!i)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?i.decoder.decode(`${i.prefix}${e}`):globalThis.Buffer.from(e,"utf8")}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Ot=Object.defineProperty,Tt=(e,t,i)=>((e,t,i)=>t in e?Ot(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class xt extends c.dQ{constructor(e,t){super(e,t),this.logger=e,this.core=t,Tt(this,"messages",new Map),Tt(this,"name","messages"),Tt(this,"version","0.3"),Tt(this,"initialized",!1),Tt(this,"storagePrefix",I),Tt(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const e=await this.getRelayerMessages();typeof e<"u"&&(this.messages=e),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}}),Tt(this,"set",async(e,t)=>{this.isInitialized();const i=(0,u.ALl)(t);let s=this.messages.get(e);return typeof s>"u"&&(s={}),typeof s[i]<"u"||(s[i]=t,this.messages.set(e,s),await this.persist()),i}),Tt(this,"get",e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t}),Tt(this,"has",(e,t)=>(this.isInitialized(),typeof this.get(e)[(0,u.ALl)(t)]<"u")),Tt(this,"del",async e=>{this.isInitialized(),this.messages.delete(e),await this.persist()}),this.logger=(0,a.U5)(e,this.name),this.core=t}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,(0,u.h0Y)(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?(0,u.PUk)(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var kt=Object.defineProperty,Rt=Object.defineProperties,Mt=Object.getOwnPropertyDescriptors,Ut=Object.getOwnPropertySymbols,Dt=Object.prototype.hasOwnProperty,jt=Object.prototype.propertyIsEnumerable,Lt=(e,t,i)=>t in e?kt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,qt=(e,t)=>{for(var i in t||(t={}))Dt.call(t,i)&&Lt(e,i,t[i]);if(Ut)for(var i of Ut(t))jt.call(t,i)&&Lt(e,i,t[i]);return e},$t=(e,t)=>Rt(e,Mt(t)),Bt=(e,t,i)=>Lt(e,"symbol"!=typeof t?t+"":t,i);class zt extends c.qE{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,Bt(this,"events",new s.EventEmitter),Bt(this,"name","publisher"),Bt(this,"queue",new Map),Bt(this,"publishTimeout",(0,h.toMiliseconds)(h.ONE_MINUTE)),Bt(this,"initialPublishTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),Bt(this,"needsTransportRestart",!1),Bt(this,"publish",async(e,t,i)=>{var s;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:i}});const r=i?.ttl||N,n=(0,u.n6V)(i),o=i?.prompt||!1,a=i?.tag||0,c=i?.id||(0,g.getBigIntRpcId)().toString(),h={topic:e,message:t,opts:{ttl:r,relay:n,prompt:o,tag:a,id:c,attestation:i?.attestation,tvf:i?.tvf}},d=`Failed to publish payload, please try again. id:${c} tag:${a}`;try{const s=new Promise(async s=>{const n=({id:e})=>{h.opts.id===e&&(this.removeRequestFromQueue(e),this.relayer.events.removeListener(P.publish,n),s(h))};this.relayer.events.on(P.publish,n);const d=(0,u.K3g)(new Promise((s,n)=>{this.rpcPublish({topic:e,message:t,ttl:r,prompt:o,tag:a,id:c,attestation:i?.attestation,tvf:i?.tvf}).then(s).catch(e=>{this.logger.warn(e,e?.message),n(e)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${c} tag:${a}`);try{await d,this.events.removeListener(P.publish,n)}catch(e){this.queue.set(c,$t(qt({},h),{attempt:1})),this.logger.warn(e,e?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:c,topic:e,message:t,opts:i}}),await(0,u.K3g)(s,this.publishTimeout,d)}catch(e){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(e),null!=(s=i?.internal)&&s.throwOnFailedPublish)throw e}finally{this.queue.delete(c)}}),Bt(this,"on",(e,t)=>{this.events.on(e,t)}),Bt(this,"once",(e,t)=>{this.events.once(e,t)}),Bt(this,"off",(e,t)=>{this.events.off(e,t)}),Bt(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.relayer=e,this.logger=(0,a.U5)(t,this.name),this.registerEventListeners()}get context(){return(0,a.oI)(this.logger)}async rpcPublish(e){var t,i,s,r;const{topic:n,message:o,ttl:a=N,prompt:c,tag:h,id:d,attestation:l,tvf:p}=e,f={method:(0,u.aa1)((0,u.n6V)().protocol).publish,params:qt({topic:n,message:o,ttl:a,prompt:c,tag:h,attestation:l},p),id:d};(0,u.b07)(null==(t=f.params)?void 0:t.prompt)&&(null==(i=f.params)||delete i.prompt),(0,u.b07)(null==(s=f.params)?void 0:s.tag)&&(null==(r=f.params)||delete r.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:f});const g=await this.relayer.request(f);return this.relayer.events.emit(P.publish,e),this.logger.debug("Successfully Published Payload"),g}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{const i=e.attempt+1;this.queue.set(t,$t(qt({},e),{attempt:i}));const{topic:s,message:r,opts:n,attestation:o}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish($t(qt({},e),{topic:s,message:r,ttl:n.ttl,prompt:n.prompt,tag:n.tag,id:n.id,attestation:o,tvf:n.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(n.li.pulse,()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(P.connection_stalled);this.checkQueue()}),this.relayer.on(P.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var Ht=Object.defineProperty,Wt=(e,t,i)=>((e,t,i)=>t in e?Ht(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Vt{constructor(){Wt(this,"map",new Map),Wt(this,"set",(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])}),Wt(this,"get",e=>this.map.get(e)||[]),Wt(this,"exists",(e,t)=>this.get(e).includes(t)),Wt(this,"delete",(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const s=i.filter(e=>e!==t);s.length?this.map.set(e,s):this.map.delete(e)}),Wt(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var Ft=Object.defineProperty,Kt=Object.defineProperties,Gt=Object.getOwnPropertyDescriptors,Jt=Object.getOwnPropertySymbols,Yt=Object.prototype.hasOwnProperty,Xt=Object.prototype.propertyIsEnumerable,Qt=(e,t,i)=>t in e?Ft(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Zt=(e,t)=>{for(var i in t||(t={}))Yt.call(t,i)&&Qt(e,i,t[i]);if(Jt)for(var i of Jt(t))Xt.call(t,i)&&Qt(e,i,t[i]);return e},ei=(e,t)=>Kt(e,Gt(t)),ti=(e,t,i)=>Qt(e,"symbol"!=typeof t?t+"":t,i);class ii extends c.mF{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,ti(this,"subscriptions",new Map),ti(this,"topicMap",new Vt),ti(this,"events",new s.EventEmitter),ti(this,"name","subscription"),ti(this,"version","0.3"),ti(this,"pending",new Map),ti(this,"cached",[]),ti(this,"initialized",!1),ti(this,"pendingSubscriptionWatchLabel","pending_sub_watch_label"),ti(this,"pollingInterval",20),ti(this,"storagePrefix",I),ti(this,"subscribeTimeout",(0,h.toMiliseconds)(h.ONE_MINUTE)),ti(this,"initialSubscribeTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),ti(this,"clientId"),ti(this,"batchSubscribeTopicsLimit",500),ti(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),ti(this,"subscribe",async(e,t)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const i=(0,u.n6V)(t),s={topic:e,relay:i,transportType:t?.transportType};this.pending.set(e,s);const r=await this.rpcSubscribe(e,i,t);return"string"==typeof r&&(this.onSubscribe(r,s),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}})),r}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}}),ti(this,"unsubscribe",async(e,t)=>{this.isInitialized(),typeof t?.id<"u"?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)}),ti(this,"isSubscribed",async e=>{if(this.topics.includes(e))return!0;const t=`${this.pendingSubscriptionWatchLabel}_${e}`;return await new Promise((i,s)=>{const r=new h.Watch;r.start(t);const n=setInterval(()=>{(!this.pending.has(e)&&this.topics.includes(e)||this.cached.some(t=>t.topic===e))&&(clearInterval(n),r.stop(t),i(!0)),r.elapsed(t)>=L&&(clearInterval(n),r.stop(t),s(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)}),ti(this,"on",(e,t)=>{this.events.on(e,t)}),ti(this,"once",(e,t)=>{this.events.once(e,t)}),ti(this,"off",(e,t)=>{this.events.off(e,t)}),ti(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),ti(this,"start",async()=>{await this.onConnect()}),ti(this,"stop",async()=>{await this.onDisconnect()}),ti(this,"restart",async()=>{await this.restore(),await this.onRestart()}),ti(this,"checkPending",async()=>{if(!(0!==this.pending.size||this.initialized&&this.relayer.connected))return;const e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e)}),ti(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(n.li.pulse,async()=>{await this.checkPending()}),this.events.on(D,async e=>{const t=D;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(j,async e=>{const t=j;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}),this.relayer=e,this.logger=(0,a.U5)(t,this.name),this.clientId=""}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async i=>await this.unsubscribeById(e,i,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const s=(0,u.n6V)(i);await this.restartToComplete({topic:e,id:t,relay:s}),await this.rpcUnsubscribe(e,t,s);const r=(0,u.Hjj)("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,r),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t,i){var s;(!i||i?.transportType===M.relay)&&await this.restartToComplete({topic:e,id:e,relay:t});const r={method:(0,u.aa1)(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});const n=null==(s=i?.internal)?void 0:s.throwOnFailedPublish;try{const t=await this.getSubscriptionId(e);if(i?.transportType===M.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(r).catch(e=>this.logger.warn(e))},(0,h.toMiliseconds)(h.ONE_SECOND)),t;const s=new Promise(async t=>{const i=s=>{s.topic===e&&(this.events.removeListener(D,i),t(s.id))};this.events.on(D,i);try{const s=await(0,u.K3g)(new Promise((e,t)=>{this.relayer.request(r).catch(e=>{this.logger.warn(e,e?.message),t(e)}).then(e)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(D,i),t(s)}catch{}}),o=await(0,u.K3g)(s,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!o&&n)throw new Error(`Subscribing to ${e} failed, please try again`);return o?t:null}catch(e){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(P.connection_stalled),n)throw e}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:(0,u.aa1)(t.protocol).batchSubscribe,params:{topics:e.map(e=>e.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await(0,u.K3g)(new Promise(e=>{this.relayer.request(i).catch(e=>this.logger.warn(e)).then(e)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(P.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,i={method:(0,u.aa1)(t.protocol).batchFetchMessages,params:{topics:e.map(e=>e.topic)}};let s;this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{s=await await(0,u.K3g)(new Promise((e,t)=>{this.relayer.request(i).catch(e=>{this.logger.warn(e),t(e)}).then(e)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(P.connection_stalled)}return s}rpcUnsubscribe(e,t,i){const s={method:(0,u.aa1)(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(e,t){this.setSubscription(e,ei(Zt({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(e=>{this.setSubscription(e.id,Zt({},e)),this.pending.delete(e.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,Zt({},t)),this.topicMap.set(t.topic,e),this.events.emit(D,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:t}=(0,u.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(j,ei(Zt({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit("subscription_sync")}async onRestart(){if(this.cached.length){const e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<t;i++){const t=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(t)}}this.events.emit("subscription_resubscribed")}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:e}=(0,u.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async e=>ei(Zt({},e),{id:await this.getSubscriptionId(e.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await(0,u.yy4)((0,h.toMiliseconds)(h.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(t.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return(0,u.ALl)(e+await this.getClientId())}}var si=Object.defineProperty,ri=Object.getOwnPropertySymbols,ni=Object.prototype.hasOwnProperty,oi=Object.prototype.propertyIsEnumerable,ai=(e,t,i)=>t in e?si(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,ci=(e,t)=>{for(var i in t||(t={}))ni.call(t,i)&&ai(e,i,t[i]);if(ri)for(var i of ri(t))oi.call(t,i)&&ai(e,i,t[i]);return e},hi=(e,t,i)=>ai(e,"symbol"!=typeof t?t+"":t,i);class di extends c.m5{constructor(e){super(e),hi(this,"protocol","wc"),hi(this,"version",2),hi(this,"core"),hi(this,"logger"),hi(this,"events",new s.EventEmitter),hi(this,"provider"),hi(this,"messages"),hi(this,"subscriber"),hi(this,"publisher"),hi(this,"name","relayer"),hi(this,"transportExplicitlyClosed",!1),hi(this,"initialized",!1),hi(this,"connectionAttemptInProgress",!1),hi(this,"relayUrl"),hi(this,"projectId"),hi(this,"packageName"),hi(this,"bundleId"),hi(this,"hasExperiencedNetworkDisruption",!1),hi(this,"pingTimeout"),hi(this,"heartBeatTimeout",(0,h.toMiliseconds)(h.THIRTY_SECONDS+h.FIVE_SECONDS)),hi(this,"reconnectTimeout"),hi(this,"connectPromise"),hi(this,"reconnectInProgress",!1),hi(this,"requestsInFlight",[]),hi(this,"connectTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),hi(this,"request",async e=>{var t,i;this.logger.debug("Publishing Request Payload");const s=e.id||(0,g.getBigIntRpcId)().toString();await this.toEstablishConnection();try{this.logger.trace({id:s,method:e.method,topic:null==(t=e.params)?void 0:t.topic},"relayer.request - publishing...");const r=`${s}:${(null==(i=e.params)?void 0:i.tag)||""}`;this.requestsInFlight.push(r);const n=await this.provider.request(e);return this.requestsInFlight=this.requestsInFlight.filter(e=>e!==r),n}catch(e){throw this.logger.debug(`Failed to Publish Request: ${s}`),e}}),hi(this,"resetPingTimeout",()=>{if((0,u.Lln)())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var e,t,i;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),null==(i=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)||i.terminate()},this.heartBeatTimeout)}catch(e){this.logger.warn(e,e?.message)}}),hi(this,"onPayloadHandler",e=>{this.onProviderPayload(e),this.resetPingTimeout()}),hi(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(P.connect)}),hi(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),hi(this,"onProviderErrorHandler",e=>{this.logger.fatal(`Fatal socket error: ${e.message}`),this.events.emit(P.error,e),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),hi(this,"registerProviderListeners",()=>{this.provider.on(O,this.onPayloadHandler),this.provider.on(T,this.onConnectHandler),this.provider.on(x,this.onDisconnectHandler),this.provider.on(k,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&"string"!=typeof e.logger?(0,a.U5)(e.logger,this.name):(0,a.h6)((0,a.iP)({level:e.logger||"error"})),this.messages=new xt(this.logger,e.core),this.subscriber=new ii(this,this.logger),this.publisher=new zt(this,this.logger),this.relayUrl=e?.relayUrl||S,this.projectId=e.projectId,(0,u.m01)()?this.packageName=(0,u.R7U)():(0,u.aRZ)()&&(this.bundleId=(0,u.R7U)()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return(0,a.oI)(this.logger)}get connected(){var e,t,i;return 1===(null==(i=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:i.readyState)||!1}get connecting(){var e,t,i;return 0===(null==(i=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:i.readyState)||void 0!==this.connectPromise||!1}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:M.relay})}async subscribe(e,t){var i,s,r;this.isInitialized(),(null==t||!t.transportType||"relay"===t?.transportType)&&await this.toEstablishConnection();const n=typeof(null==(i=t?.internal)?void 0:i.throwOnFailedPublish)>"u"||(null==(s=t?.internal)?void 0:s.throwOnFailedPublish);let o,a=(null==(r=this.subscriber.topicMap.get(e))?void 0:r[0])||"";const c=t=>{t.topic===e&&(this.subscriber.off(D,c),o())};return await Promise.all([new Promise(e=>{o=e,this.subscriber.on(D,c)}),new Promise(async(i,s)=>{a=await this.subscriber.subscribe(e,ci({internal:{throwOnFailedPublish:n}},t)).catch(e=>{n&&s(e)})||a,i()})]),a}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await(0,u.K3g)(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(this.subscriber.hasAnyTopics){if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(t,i)=>{await this.connect(e).then(t).catch(i).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}else this.logger.warn("Starting WS connection skipped because the client has no topics to work with.")}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await(0,u.sc7)())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(0===e?.length)return void this.logger.trace("Batch message events is empty. Ignoring...");const t=e.sort((e,t)=>e.publishedAt-t.publishedAt);this.logger.debug(`Batch of ${t.length} message events sorted`);for(const e of t)try{await this.onMessageEvent(e)}catch(e){this.logger.warn(e,"Error while processing batch message event: "+e?.message)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:i}=e;if(!t.sessionExists){const e={topic:i,expiry:(0,u.Xw0)(h.FIVE_MINUTES),relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,e)}this.events.emit(P.message,e),await this.recordMessageEvent(e)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let t=1;for(;t<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(e,t)=>{const i=()=>{t(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(x,i),await(0,u.K3g)(new Promise((e,t)=>{this.provider.connect().then(e).catch(t)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(e=>{t(e)}).finally(()=>{this.provider.off(x,i),clearTimeout(this.reconnectTimeout)}),await new Promise(async(e,t)=>{const i=()=>{t(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(x,i),await this.subscriber.start().then(e).catch(t).finally(()=>{this.provider.off(x,i)})}),this.hasExperiencedNetworkDisruption=!1,e()})}catch(e){await this.subscriber.stop();const t=e;this.logger.warn({},t.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(e=>setTimeout(e,(0,h.toMiliseconds)(1*t))),t++}}startPingTimeout(){var e,t,i,s,r;if((0,u.Lln)())try{null!=(t=null==(e=this.provider)?void 0:e.connection)&&t.socket&&(null==(r=null==(s=null==(i=this.provider)?void 0:i.connection)?void 0:s.socket)||r.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(e){this.logger.warn(e,e?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new f.F(new m.A((0,u.jUZ)({sdkVersion:R,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||0===i.length)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.warn(`Ignoring message for non-subscribed topic ${t}`),!0;const s=this.messages.has(t,i);return s&&this.logger.warn(`Ignoring duplicate message: ${i}`),s}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),(0,g.isJsonRpcRequest)(e)){if(!e.method.endsWith("_subscription"))return;const t=e.params,{topic:i,message:s,publishedAt:r,attestation:n}=t.data,o={topic:i,message:s,publishedAt:r,transportType:M.relay,attestation:n};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(ci({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o)}else(0,g.isJsonRpcResponse)(e)&&this.events.emit(P.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(P.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=(0,g.formatJsonRpcResult)(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(O,this.onPayloadHandler),this.provider.off(T,this.onConnectHandler),this.provider.off(x,this.onDisconnectHandler),this.provider.off(k,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await(0,u.sc7)();(0,u.uym)(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(e=>this.logger.error(e,e?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(P.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},(0,h.toMiliseconds)(.1)))))}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.connect()}}var li=Object.defineProperty,ui=Object.getOwnPropertySymbols,pi=Object.prototype.hasOwnProperty,fi=Object.prototype.propertyIsEnumerable,gi=(e,t,i)=>t in e?li(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,mi=(e,t)=>{for(var i in t||(t={}))pi.call(t,i)&&gi(e,i,t[i]);if(ui)for(var i of ui(t))fi.call(t,i)&&gi(e,i,t[i]);return e},bi=(e,t,i)=>gi(e,"symbol"!=typeof t?t+"":t,i);class yi extends c.pi{constructor(e,t,i,s=I,r=void 0){super(e,t,i,s),this.core=e,this.logger=t,this.name=i,bi(this,"map",new Map),bi(this,"version","0.3"),bi(this,"cached",[]),bi(this,"initialized",!1),bi(this,"getKey"),bi(this,"storagePrefix",I),bi(this,"recentlyDeleted",[]),bi(this,"recentlyDeletedLimit",200),bi(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>{this.getKey&&null!==e&&!(0,u.b07)(e)?this.map.set(this.getKey(e),e):(0,u.CTo)(e)?this.map.set(e.id,e):(0,u.mr0)(e)&&this.map.set(e.topic,e)}),this.cached=[],this.initialized=!0)}),bi(this,"set",async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())}),bi(this,"get",e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e))),bi(this,"getAll",e=>(this.isInitialized(),e?this.values.filter(t=>Object.keys(e).every(i=>y()(t[i],e[i]))):this.values)),bi(this,"update",async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});const i=mi(mi({},this.getData(e)),t);this.map.set(e,i),await this.persist()}),bi(this,"delete",async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:e,reason:t}),this.map.delete(e),this.addToRecentlyDeleted(e),await this.persist())}),this.logger=(0,a.U5)(t,this.name),this.storagePrefix=s,this.getKey=r}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:t}=(0,u.GuA)("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}const{message:t}=(0,u.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:e}=(0,u.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var wi=Object.defineProperty,vi=(e,t,i)=>((e,t,i)=>t in e?wi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Ii{constructor(e,t){this.core=e,this.logger=t,vi(this,"name","pairing"),vi(this,"version","0.3"),vi(this,"events",new(r())),vi(this,"pairings"),vi(this,"initialized",!1),vi(this,"storagePrefix",I),vi(this,"ignoredPayloadTypes",[u.Lp_]),vi(this,"registeredMethods",[]),vi(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),vi(this,"register",({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]}),vi(this,"create",async e=>{this.isInitialized();const t=(0,u.two)(),i=await this.core.crypto.setSymKey(t),s=(0,u.Xw0)(h.FIVE_MINUTES),r={protocol:C},n={topic:i,expiry:s,relay:r,active:!1,methods:e?.methods},o=(0,u.QJh)({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:t,relay:r,expiryTimestamp:s,methods:e?.methods});return this.events.emit($.create,n),this.core.expirer.set(i,s),await this.pairings.set(i,n),await this.core.relayer.subscribe(i,{transportType:e?.transportType}),{topic:i,uri:o}}),vi(this,"pair",async e=>{this.isInitialized();const t=this.core.eventClient.createEvent({properties:{topic:e?.uri,trace:[J.pairing_started]}});this.isValidPair(e,t);const{topic:i,symKey:s,relay:r,expiryTimestamp:n,methods:o}=(0,u.wYp)(e.uri);let a;if(t.props.properties.topic=i,t.addTrace(J.pairing_uri_validation_success),t.addTrace(J.pairing_uri_not_expired),this.pairings.keys.includes(i)){if(a=this.pairings.get(i),t.addTrace(J.existing_pairing),a.active)throw t.setError(Y.active_pairing_already_exists),new Error(`Pairing already exists: ${i}. Please try again with a new connection URI.`);t.addTrace(J.pairing_not_expired)}const c=n||(0,u.Xw0)(h.FIVE_MINUTES),d={topic:i,relay:r,expiry:c,active:!1,methods:o};this.core.expirer.set(i,c),await this.pairings.set(i,d),t.addTrace(J.store_new_pairing),e.activatePairing&&await this.activate({topic:i}),this.events.emit($.create,d),t.addTrace(J.emit_inactive_pairing),this.core.crypto.keychain.has(i)||await this.core.crypto.setSymKey(s,i),t.addTrace(J.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{t.setError(Y.no_internet_connection)}try{await this.core.relayer.subscribe(i,{relay:r})}catch(e){throw t.setError(Y.subscribe_pairing_topic_failure),e}return t.addTrace(J.subscribe_pairing_topic_success),d}),vi(this,"activate",async({topic:e})=>{this.isInitialized();const t=(0,u.Xw0)(h.FIVE_MINUTES);this.core.expirer.set(e,t),await this.pairings.update(e,{active:!0,expiry:t})}),vi(this,"ping",async e=>{this.isInitialized(),await this.isValidPing(e),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:t}=e;if(this.pairings.keys.includes(t)){const e=await this.sendRequest(t,"wc_pairingPing",{}),{done:i,resolve:s,reject:r}=(0,u.Wx8)();this.events.once((0,u.hEn)("pairing_ping",e),({error:e})=>{e?r(e):s()}),await i()}}),vi(this,"updateExpiry",async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})}),vi(this,"updateMetadata",async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})}),vi(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),vi(this,"disconnect",async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",(0,u.Hjj)("USER_DISCONNECTED")),await this.deletePairing(t))}),vi(this,"formatUriFromPairing",e=>{this.isInitialized();const{topic:t,relay:i,expiry:s,methods:r}=e,n=this.core.crypto.keychain.get(t);return(0,u.QJh)({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:n,relay:i,expiryTimestamp:s,methods:r})}),vi(this,"sendRequest",async(e,t,i)=>{const s=(0,g.formatJsonRpcRequest)(t,i),r=await this.core.crypto.encode(e,s),n=q[t].req;return this.core.history.set(e,s),this.core.relayer.publish(e,r,n),s.id}),vi(this,"sendResult",async(e,t,i)=>{const s=(0,g.formatJsonRpcResult)(e,i),r=await this.core.crypto.encode(t,s),n=(await this.core.history.get(t,e)).request.method,o=q[n].res;await this.core.relayer.publish(t,r,o),await this.core.history.resolve(s)}),vi(this,"sendError",async(e,t,i)=>{const s=(0,g.formatJsonRpcError)(e,i),r=await this.core.crypto.encode(t,s),n=(await this.core.history.get(t,e)).request.method,o=q[n]?q[n].res:q.unregistered_method.res;await this.core.relayer.publish(t,r,o),await this.core.history.resolve(s)}),vi(this,"deletePairing",async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,(0,u.Hjj)("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])}),vi(this,"cleanup",async()=>{const e=this.pairings.getAll().filter(e=>(0,u._dF)(e.expiry));await Promise.all(e.map(e=>this.deletePairing(e.topic)))}),vi(this,"onRelayEventRequest",e=>{const{topic:t,payload:i}=e;switch(i.method){case"wc_pairingPing":return this.onPairingPingRequest(t,i);case"wc_pairingDelete":return this.onPairingDeleteRequest(t,i);default:return this.onUnknownRpcMethodRequest(t,i)}}),vi(this,"onRelayEventResponse",async e=>{const{topic:t,payload:i}=e,s=(await this.core.history.get(t,i.id)).request.method;return"wc_pairingPing"===s?this.onPairingPingResponse(t,i):this.onUnknownRpcMethodResponse(s)}),vi(this,"onPairingPingRequest",async(e,t)=>{const{id:i}=t;try{this.isValidPing({topic:e}),await this.sendResult(i,e,!0),this.events.emit($.ping,{id:i,topic:e})}catch(t){await this.sendError(i,e,t),this.logger.error(t)}}),vi(this,"onPairingPingResponse",(e,t)=>{const{id:i}=t;setTimeout(()=>{(0,g.isJsonRpcResult)(t)?this.events.emit((0,u.hEn)("pairing_ping",i),{}):(0,g.isJsonRpcError)(t)&&this.events.emit((0,u.hEn)("pairing_ping",i),{error:t.error})},500)}),vi(this,"onPairingDeleteRequest",async(e,t)=>{const{id:i}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit($.delete,{id:i,topic:e})}catch(t){await this.sendError(i,e,t),this.logger.error(t)}}),vi(this,"onUnknownRpcMethodRequest",async(e,t)=>{const{id:i,method:s}=t;try{if(this.registeredMethods.includes(s))return;const t=(0,u.Hjj)("WC_METHOD_UNSUPPORTED",s);await this.sendError(i,e,t),this.logger.error(t)}catch(t){await this.sendError(i,e,t),this.logger.error(t)}}),vi(this,"onUnknownRpcMethodResponse",e=>{this.registeredMethods.includes(e)||this.logger.error((0,u.Hjj)("WC_METHOD_UNSUPPORTED",e))}),vi(this,"isValidPair",(e,t)=>{var i;if(!(0,u.TeY)(e)){const{message:i}=(0,u.GuA)("MISSING_OR_INVALID",`pair() params: ${e}`);throw t.setError(Y.malformed_pairing_uri),new Error(i)}if(!(0,u.AYU)(e.uri)){const{message:i}=(0,u.GuA)("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw t.setError(Y.malformed_pairing_uri),new Error(i)}const s=(0,u.wYp)(e?.uri);if(null==(i=s?.relay)||!i.protocol){const{message:e}=(0,u.GuA)("MISSING_OR_INVALID","pair() uri#relay-protocol");throw t.setError(Y.malformed_pairing_uri),new Error(e)}if(null==s||!s.symKey){const{message:e}=(0,u.GuA)("MISSING_OR_INVALID","pair() uri#symKey");throw t.setError(Y.malformed_pairing_uri),new Error(e)}if(null!=s&&s.expiryTimestamp&&(0,h.toMiliseconds)(s?.expiryTimestamp)<Date.now()){t.setError(Y.pairing_expired);const{message:e}=(0,u.GuA)("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(e)}}),vi(this,"isValidPing",async e=>{if(!(0,u.TeY)(e)){const{message:t}=(0,u.GuA)("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)}),vi(this,"isValidDisconnect",async e=>{if(!(0,u.TeY)(e)){const{message:t}=(0,u.GuA)("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)}),vi(this,"isValidPairingTopic",async e=>{if(!(0,u.Qhg)(e,!1)){const{message:t}=(0,u.GuA)("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.pairings.keys.includes(e)){const{message:t}=(0,u.GuA)("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if((0,u._dF)(this.pairings.get(e).expiry)){await this.deletePairing(e);const{message:t}=(0,u.GuA)("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}),this.core=e,this.logger=(0,a.U5)(t,this.name),this.pairings=new yi(this.core,this.logger,this.name,this.storagePrefix)}get context(){return(0,a.oI)(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(P.message,async e=>{const{topic:t,message:i,transportType:s}=e;if(!this.pairings.keys.includes(t)||s===M.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const r=await this.core.crypto.decode(t,i);try{(0,g.isJsonRpcRequest)(r)?(this.core.history.set(t,r),this.onRelayEventRequest({topic:t,payload:r})):(0,g.isJsonRpcResponse)(r)&&(await this.core.history.resolve(r),await this.onRelayEventResponse({topic:t,payload:r}),this.core.history.delete(t,r.id))}catch(e){this.logger.error(e)}})}registerExpirerEvents(){this.core.expirer.on(W.expired,async e=>{const{topic:t}=(0,u.c82)(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit($.expire,{topic:t}))})}}var Ei=Object.defineProperty,_i=(e,t,i)=>((e,t,i)=>t in e?Ei(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Ai extends c.lZ{constructor(e,t){super(e,t),this.core=e,this.logger=t,_i(this,"records",new Map),_i(this,"events",new s.EventEmitter),_i(this,"name","history"),_i(this,"version","0.3"),_i(this,"cached",[]),_i(this,"initialized",!1),_i(this,"storagePrefix",I),_i(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.records.set(e.id,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),_i(this,"set",(e,t,i)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:i}),this.records.has(t.id))return;const s={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:i,expiry:(0,u.Xw0)(h.THIRTY_DAYS)};this.records.set(s.id,s),this.persist(),this.events.emit(B,s)}),_i(this,"resolve",async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;const t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=(0,g.isJsonRpcError)(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.persist(),this.events.emit(z,t))}),_i(this,"get",async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t))),_i(this,"delete",(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach(i=>{if(i.topic===e){if(typeof t<"u"&&i.id!==t)return;this.records.delete(i.id),this.events.emit(H,i)}}),this.persist()}),_i(this,"exists",async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e)),_i(this,"on",(e,t)=>{this.events.on(e,t)}),_i(this,"once",(e,t)=>{this.events.once(e,t)}),_i(this,"off",(e,t)=>{this.events.off(e,t)}),_i(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:(0,g.formatJsonRpcRequest)(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:t}=(0,u.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit("history_sync")}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:e}=(0,u.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(B,e=>{const t=B;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(z,e=>{const t=z;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(H,e=>{const t=H;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(n.li.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,h.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(H,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Ni=Object.defineProperty,Ci=(e,t,i)=>((e,t,i)=>t in e?Ni(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Si extends c.Vx{constructor(e,t){super(e,t),this.core=e,this.logger=t,Ci(this,"expirations",new Map),Ci(this,"events",new s.EventEmitter),Ci(this,"name","expirer"),Ci(this,"version","0.3"),Ci(this,"cached",[]),Ci(this,"initialized",!1),Ci(this,"storagePrefix",I),Ci(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.expirations.set(e.target,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Ci(this,"has",e=>{try{const t=this.formatTarget(e);return typeof this.getExpiration(t)<"u"}catch{return!1}}),Ci(this,"set",(e,t)=>{this.isInitialized();const i=this.formatTarget(e),s={target:i,expiry:t};this.expirations.set(i,s),this.checkExpiry(i,s),this.events.emit(W.created,{target:i,expiration:s})}),Ci(this,"get",e=>{this.isInitialized();const t=this.formatTarget(e);return this.getExpiration(t)}),Ci(this,"del",e=>{if(this.isInitialized(),this.has(e)){const t=this.formatTarget(e),i=this.getExpiration(t);this.expirations.delete(t),this.events.emit(W.deleted,{target:t,expiration:i})}}),Ci(this,"on",(e,t)=>{this.events.on(e,t)}),Ci(this,"once",(e,t)=>{this.events.once(e,t)}),Ci(this,"off",(e,t)=>{this.events.off(e,t)}),Ci(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if("string"==typeof e)return(0,u.ADD)(e);if("number"==typeof e)return(0,u.gOF)(e);const{message:t}=(0,u.GuA)("UNKNOWN_TYPE","Target type: "+typeof e);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(W.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:e}=(0,u.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:t}=(0,u.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(t),new Error(t)}return t}checkExpiry(e,t){const{expiry:i}=t;(0,h.toMiliseconds)(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(W.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(n.li.pulse,()=>this.checkExpirations()),this.events.on(W.created,e=>{const t=W.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(W.expired,e=>{const t=W.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(W.deleted,e=>{const t=W.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Pi=Object.defineProperty,Oi=(e,t,i)=>((e,t,i)=>t in e?Pi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Ti extends c.zl{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,Oi(this,"name","verify-api"),Oi(this,"abortController"),Oi(this,"isDevEnv"),Oi(this,"verifyUrlV3",K),Oi(this,"storagePrefix",I),Oi(this,"version",2),Oi(this,"publicKey"),Oi(this,"fetchPromise"),Oi(this,"init",async()=>{var e;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,h.toMiliseconds)(null==(e=this.publicKey)?void 0:e.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),Oi(this,"register",async e=>{if(!(0,u.BdH)()||this.isDevEnv)return;const t=window.location.origin,{id:i,decryptedId:s}=e,r=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${t}&id=${i}&decryptedId=${s}`;try{const e=(0,w.getDocument)(),t=this.startAbortTimer(5*h.ONE_SECOND),s=await new Promise((s,n)=>{const o=()=>{window.removeEventListener("message",c),e.body.removeChild(a),n("attestation aborted")};this.abortController.signal.addEventListener("abort",o);const a=e.createElement("iframe");a.src=r,a.style.display="none",a.addEventListener("error",o,{signal:this.abortController.signal});const c=r=>{if(r.data&&"string"==typeof r.data)try{const n=JSON.parse(r.data);if("verify_attestation"===n.type){if((0,l.Cq)(n.attestation).payload.id!==i)return;clearInterval(t),e.body.removeChild(a),this.abortController.signal.removeEventListener("abort",o),window.removeEventListener("message",c),s(null===n.attestation?"":n.attestation)}}catch(e){this.logger.warn(e)}};e.body.appendChild(a),window.addEventListener("message",c,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",s),s}catch(e){this.logger.warn(e)}return""}),Oi(this,"resolve",async e=>{if(this.isDevEnv)return"";const{attestationId:t,hash:i,encryptedId:s}=e;if(""===t)return void this.logger.debug("resolve: attestationId is empty, skipping");if(t){if((0,l.Cq)(t).payload.id!==s)return;const e=await this.isValidJwtAttestation(t);if(e)return e.isVerified?e:void this.logger.warn("resolve: jwt attestation: origin url not verified")}if(!i)return;const r=this.getVerifyUrl(e?.verifyUrl);return this.fetchAttestation(i,r)}),Oi(this,"fetchAttestation",async(e,t)=>{this.logger.debug(`resolving attestation: ${e} from url: ${t}`);const i=this.startAbortTimer(5*h.ONE_SECOND),s=await fetch(`${t}/attestation/${e}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(i),200===s.status?await s.json():void 0}),Oi(this,"getVerifyUrl",e=>{let t=e||F;return G.includes(t)||(this.logger.info(`verify url: ${t}, not included in trusted list, assigning default: ${F}`),t=F),t}),Oi(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const e=this.startAbortTimer(h.FIVE_SECONDS),t=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(e),await t.json()}catch(e){this.logger.warn(e)}}),Oi(this,"persistPublicKey",async e=>{this.logger.debug("persisting public key to local storage",e),await this.store.setItem(this.storeKey,e),this.publicKey=e}),Oi(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),Oi(this,"isValidJwtAttestation",async e=>{const t=await this.getPublicKey();try{if(t)return this.validateAttestation(e,t)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}const i=await this.fetchAndPersistPublicKey();try{if(i)return this.validateAttestation(e,i)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}}),Oi(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),Oi(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async e=>{const t=await this.fetchPublicKey();t&&(await this.persistPublicKey(t),e(t))});const e=await this.fetchPromise;return this.fetchPromise=void 0,e}),Oi(this,"validateAttestation",(e,t)=>{const i=(0,u.U0i)(e,t.publicKey),s={hasExpired:(0,h.toMiliseconds)(i.exp)<Date.now(),payload:i};if(s.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:s.payload.origin,isScam:s.payload.isScam,isVerified:s.payload.isVerified}}),this.logger=(0,a.U5)(t,this.name),this.abortController=new AbortController,this.isDevEnv=(0,u.w8K)(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return(0,a.oI)(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),(0,h.toMiliseconds)(e))}}var xi=Object.defineProperty,ki=(e,t,i)=>((e,t,i)=>t in e?xi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Ri extends c.GF{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,ki(this,"context","echo"),ki(this,"registerDeviceToken",async e=>{const{clientId:t,token:i,notificationType:s,enableEncrypted:r=!1}=e,n=`https://echo.walletconnect.com/${this.projectId}/clients`;await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:t,type:s,token:i,always_raw:r})})}),this.logger=(0,a.U5)(t,this.context)}}var Mi=Object.defineProperty,Ui=Object.getOwnPropertySymbols,Di=Object.prototype.hasOwnProperty,ji=Object.prototype.propertyIsEnumerable,Li=(e,t,i)=>t in e?Mi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,qi=(e,t)=>{for(var i in t||(t={}))Di.call(t,i)&&Li(e,i,t[i]);if(Ui)for(var i of Ui(t))ji.call(t,i)&&Li(e,i,t[i]);return e},$i=(e,t,i)=>Li(e,"symbol"!=typeof t?t+"":t,i);class Bi extends c.$Q{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,$i(this,"context","event-client"),$i(this,"storagePrefix",I),$i(this,"storageVersion",.1),$i(this,"events",new Map),$i(this,"shouldPersist",!1),$i(this,"init",async()=>{if(!(0,u.w8K)())try{const e={eventId:(0,u.gZm)(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:(0,u.ojD)(this.core.relayer.protocol,this.core.relayer.version,R)}}};await this.sendEvent([e])}catch(e){this.logger.warn(e)}}),$i(this,"createEvent",e=>{const{event:t="ERROR",type:i="",properties:{topic:s,trace:r}}=e,n=(0,u.gZm)(),o=this.core.projectId||"",a=Date.now(),c=qi({eventId:n,timestamp:a,props:{event:t,type:i,properties:{topic:s,trace:r}},bundleId:o,domain:this.getAppDomain()},this.setMethods(n));return this.telemetryEnabled&&(this.events.set(n,c),this.shouldPersist=!0),c}),$i(this,"getEvent",e=>{const{eventId:t,topic:i}=e;if(t)return this.events.get(t);const s=Array.from(this.events.values()).find(e=>e.props.properties.topic===i);return s?qi(qi({},s),this.setMethods(s.eventId)):void 0}),$i(this,"deleteEvent",e=>{const{eventId:t}=e;this.events.delete(t),this.shouldPersist=!0}),$i(this,"setEventListeners",()=>{this.core.heartbeat.on(n.li.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(e=>{(0,h.fromMiliseconds)(Date.now())-(0,h.fromMiliseconds)(e.timestamp)>86400&&(this.events.delete(e.eventId),this.shouldPersist=!0)})})}),$i(this,"setMethods",e=>({addTrace:t=>this.addTrace(e,t),setError:t=>this.setError(e,t)})),$i(this,"addTrace",(e,t)=>{const i=this.events.get(e);i&&(i.props.properties.trace.push(t),this.events.set(e,i),this.shouldPersist=!0)}),$i(this,"setError",(e,t)=>{const i=this.events.get(e);i&&(i.props.type=t,i.timestamp=Date.now(),this.events.set(e,i),this.shouldPersist=!0)}),$i(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),$i(this,"restore",async()=>{try{const e=await this.core.storage.getItem(this.storageKey)||[];if(!e.length)return;e.forEach(e=>{this.events.set(e.eventId,qi(qi({},e),this.setMethods(e.eventId)))})}catch(e){this.logger.warn(e)}}),$i(this,"submit",async()=>{if(!this.telemetryEnabled||0===this.events.size)return;const e=[];for(const[t,i]of this.events)i.props.type&&e.push(i);if(0!==e.length)try{if((await this.sendEvent(e)).ok)for(const t of e)this.events.delete(t.eventId),this.shouldPersist=!0}catch(e){this.logger.warn(e)}}),$i(this,"sendEvent",async e=>{const t=this.getAppDomain()?"":"&sp=desktop";return await fetch(`https://pulse.walletconnect.org/batch?projectId=${this.core.projectId}&st=events_sdk&sv=js-${R}${t}`,{method:"POST",body:JSON.stringify(e)})}),$i(this,"getAppDomain",()=>(0,u.lFF)().url),this.logger=(0,a.U5)(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var zi=Object.defineProperty,Hi=Object.getOwnPropertySymbols,Wi=Object.prototype.hasOwnProperty,Vi=Object.prototype.propertyIsEnumerable,Fi=(e,t,i)=>t in e?zi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Ki=(e,t)=>{for(var i in t||(t={}))Wi.call(t,i)&&Fi(e,i,t[i]);if(Hi)for(var i of Hi(t))Vi.call(t,i)&&Fi(e,i,t[i]);return e},Gi=(e,t,i)=>Fi(e,"symbol"!=typeof t?t+"":t,i);class Ji extends c.ZP{constructor(e){var t;super(e),Gi(this,"protocol","wc"),Gi(this,"version",2),Gi(this,"name",v),Gi(this,"relayUrl"),Gi(this,"projectId"),Gi(this,"customStoragePrefix"),Gi(this,"events",new s.EventEmitter),Gi(this,"logger"),Gi(this,"heartbeat"),Gi(this,"relayer"),Gi(this,"crypto"),Gi(this,"storage"),Gi(this,"history"),Gi(this,"expirer"),Gi(this,"pairing"),Gi(this,"verify"),Gi(this,"echoClient"),Gi(this,"linkModeSupportedApps"),Gi(this,"eventClient"),Gi(this,"initialized",!1),Gi(this,"logChunkController"),Gi(this,"on",(e,t)=>this.events.on(e,t)),Gi(this,"once",(e,t)=>this.events.once(e,t)),Gi(this,"off",(e,t)=>this.events.off(e,t)),Gi(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),Gi(this,"dispatchEnvelope",({topic:e,message:t,sessionExists:i})=>{if(!e||!t)return;const s={topic:e,message:t,publishedAt:Date.now(),transportType:M.link_mode};this.relayer.onLinkMessageEvent(s,{sessionExists:i})}),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||S,this.customStoragePrefix=null!=e&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=(0,a.iP)({level:"string"==typeof e?.logger&&e.logger?e.logger:"error",name:v}),{logger:r,chunkLoggerController:c}=(0,a.D5)({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=c,null!=(t=this.logChunkController)&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var e,t;null!=(e=this.logChunkController)&&e.downloadLogsBlobInBrowser&&(null==(t=this.logChunkController)||t.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=(0,a.U5)(r,this.name),this.heartbeat=new n.VH,this.crypto=new Pt(this,this.logger,e?.keychain),this.history=new Ai(this,this.logger),this.expirer=new Si(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new o.A(Ki(Ki({},E),e?.storageOptions)),this.relayer=new di({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Ii(this,this.logger),this.verify=new Ti(this,this.logger,this.storage),this.echoClient=new Ri(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new Bi(this,this.logger,e?.telemetryEnabled)}static async init(e){const t=new Ji(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",i),t}get context(){return(0,a.oI)(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return null==(e=this.logChunkController)?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(U,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(U)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const Yi=Ji},11807:(e,t,i)=>{function s(e,t){return"light"===t?{"--w3m-accent":e?.["--w3m-accent"]||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":e?.["--w3m-accent"]||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}i.d(t,{o:()=>s})},11825:(e,t,i)=>{var s=i(70461),r=i(7784);function n(e,t,i){if(!(this instanceof n))return new n(e,t,i);this.Hash=e,this.blockSize=e.blockSize/8,this.outSize=e.outSize/8,this.inner=null,this.outer=null,this._init(s.toArray(t,i))}e.exports=n,n.prototype._init=function(e){e.length>this.blockSize&&(e=(new this.Hash).update(e).digest()),r(e.length<=this.blockSize);for(var t=e.length;t<this.blockSize;t++)e.push(0);for(t=0;t<e.length;t++)e[t]^=54;for(this.inner=(new this.Hash).update(e),t=0;t<e.length;t++)e[t]^=106;this.outer=(new this.Hash).update(e)},n.prototype.update=function(e,t){return this.inner.update(e,t),this},n.prototype.digest=function(e){return this.outer.update(this.inner.digest()),this.outer.digest(e)}},12472:(e,t,i)=>{i.d(t,{j:()=>o});var s=i(89168),r=i(39150);const n=(0,s.BX)({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),o={state:n,subscribeNetworkImages:e=>(0,s.B1)(n.networkImages,()=>e(n.networkImages)),subscribeKey:(e,t)=>(0,r.u$)(n,e,t),subscribe:e=>(0,s.B1)(n,()=>e(n)),setWalletImage(e,t){n.walletImages[e]=t},setNetworkImage(e,t){n.networkImages[e]=t},setChainImage(e,t){n.chainImages[e]=t},setConnectorImage(e,t){n.connectorImages={...n.connectorImages,[e]:t}},setTokenImage(e,t){n.tokenImages[e]=t},setCurrencyImage(e,t){n.currencyImages[e]=t}}},12986:(e,t,i)=>{var s=i(70461),r=i(32191),n=i(600),o=s.rotl32,a=s.sum32,c=s.sum32_5,h=n.ft_1,d=r.BlockHash,l=[1518500249,1859775393,2400959708,3395469782];function u(){if(!(this instanceof u))return new u;d.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.W=new Array(80)}s.inherits(u,d),e.exports=u,u.blockSize=512,u.outSize=160,u.hmacStrength=80,u.padLength=64,u.prototype._update=function(e,t){for(var i=this.W,s=0;s<16;s++)i[s]=e[t+s];for(;s<i.length;s++)i[s]=o(i[s-3]^i[s-8]^i[s-14]^i[s-16],1);var r=this.h[0],n=this.h[1],d=this.h[2],u=this.h[3],p=this.h[4];for(s=0;s<i.length;s++){var f=~~(s/20),g=c(o(r,5),h(f,n,d,u),p,i[s],l[f]);p=u,u=d,d=o(n,30),n=r,r=g}this.h[0]=a(this.h[0],r),this.h[1]=a(this.h[1],n),this.h[2]=a(this.h[2],d),this.h[3]=a(this.h[3],u),this.h[4]=a(this.h[4],p)},u.prototype._digest=function(e){return"hex"===e?s.toHex32(this.h,"big"):s.split32(this.h,"big")}},13360:(e,t,i)=>{var s=t;s.version=i(30183).rE,s.utils=i(41874),s.rand=i(47048),s.curve=i(7131),s.curves=i(86443),s.ec=i(15064),s.eddsa=i(84807)},14133:(e,t,i)=>{i.d(t,{Rn:()=>r.R,gT:()=>n.g,tW:()=>s.t});var s=i(33937),r=i(50047),n=i(18354)},14479:(e,t,i)=>{i.d(t,{E:()=>g});var s=i(89168),r=i(95191),n=i(32681),o=i(5813),a=i(19760),c=i(16279),h=i(27938),d=i(16158);const l=o.w.getAnalyticsUrl(),u=new a.Z({baseUrl:l,clientId:null}),p=["MODAL_CREATED"],f=(0,s.BX)({timestamp:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"}}),g={state:f,subscribe:e=>(0,s.B1)(f,()=>e(f)),getSdkProperties(){const{projectId:e,sdkType:t,sdkVersion:i}=d.H.state;return{projectId:e,st:t,sv:i||"html-wagmi-4.2.2"}},async _sendAnalyticsEvent(e){try{const t=c.U.state.address;if(p.includes(e.data.event)||"undefined"==typeof window)return;await u.post({path:"/e",params:g.getSdkProperties(),body:{eventId:o.w.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:e.timestamp,props:{...e.data,address:t}}}),f.reportedErrors.FORBIDDEN=!1}catch(e){e instanceof Error&&e.cause instanceof Response&&e.cause.status===r.o.HTTP_STATUS_CODES.FORBIDDEN&&!f.reportedErrors.FORBIDDEN&&(h.h.open({shortMessage:"Invalid App Configuration",longMessage:`Origin ${(0,n.IP)()?window.origin:"uknown"} not found on Allowlist - update configuration on cloud.reown.com`},"error"),f.reportedErrors.FORBIDDEN=!0)}},sendEvent(e){f.timestamp=Date.now(),f.data=e,d.H.state.features?.analytics&&g._sendAnalyticsEvent(f)}}},15064:(e,t,i)=>{var s=i(64845),r=i(84742),n=i(41874),o=i(86443),a=i(47048),c=n.assert,h=i(47531),d=i(57782);function l(e){if(!(this instanceof l))return new l(e);"string"==typeof e&&(c(Object.prototype.hasOwnProperty.call(o,e),"Unknown curve "+e),e=o[e]),e instanceof o.PresetCurve&&(e={curve:e}),this.curve=e.curve.curve,this.n=this.curve.n,this.nh=this.n.ushrn(1),this.g=this.curve.g,this.g=e.curve.g,this.g.precompute(e.curve.n.bitLength()+1),this.hash=e.hash||e.curve.hash}e.exports=l,l.prototype.keyPair=function(e){return new h(this,e)},l.prototype.keyFromPrivate=function(e,t){return h.fromPrivate(this,e,t)},l.prototype.keyFromPublic=function(e,t){return h.fromPublic(this,e,t)},l.prototype.genKeyPair=function(e){e||(e={});for(var t=new r({hash:this.hash,pers:e.pers,persEnc:e.persEnc||"utf8",entropy:e.entropy||a(this.hash.hmacStrength),entropyEnc:e.entropy&&e.entropyEnc||"utf8",nonce:this.n.toArray()}),i=this.n.byteLength(),n=this.n.sub(new s(2));;){var o=new s(t.generate(i));if(!(o.cmp(n)>0))return o.iaddn(1),this.keyFromPrivate(o)}},l.prototype._truncateToN=function(e,t,i){var r;if(s.isBN(e)||"number"==typeof e)r=(e=new s(e,16)).byteLength();else if("object"==typeof e)r=e.length,e=new s(e,16);else{var n=e.toString();r=n.length+1>>>1,e=new s(n,16)}"number"!=typeof i&&(i=8*r);var o=i-this.n.bitLength();return o>0&&(e=e.ushrn(o)),!t&&e.cmp(this.n)>=0?e.sub(this.n):e},l.prototype.sign=function(e,t,i,n){if("object"==typeof i&&(n=i,i=null),n||(n={}),"string"!=typeof e&&"number"!=typeof e&&!s.isBN(e)){c("object"==typeof e&&e&&"number"==typeof e.length,"Expected message to be an array-like, a hex string, or a BN instance"),c(e.length>>>0===e.length);for(var o=0;o<e.length;o++)c((255&e[o])===e[o])}t=this.keyFromPrivate(t,i),e=this._truncateToN(e,!1,n.msgBitLength),c(!e.isNeg(),"Can not sign a negative message");var a=this.n.byteLength(),h=t.getPrivate().toArray("be",a),l=e.toArray("be",a);c(new s(l).eq(e),"Can not sign message");for(var u=new r({hash:this.hash,entropy:h,nonce:l,pers:n.pers,persEnc:n.persEnc||"utf8"}),p=this.n.sub(new s(1)),f=0;;f++){var g=n.k?n.k(f):new s(u.generate(this.n.byteLength()));if(!((g=this._truncateToN(g,!0)).cmpn(1)<=0||g.cmp(p)>=0)){var m=this.g.mul(g);if(!m.isInfinity()){var b=m.getX(),y=b.umod(this.n);if(0!==y.cmpn(0)){var w=g.invm(this.n).mul(y.mul(t.getPrivate()).iadd(e));if(0!==(w=w.umod(this.n)).cmpn(0)){var v=(m.getY().isOdd()?1:0)|(0!==b.cmp(y)?2:0);return n.canonical&&w.cmp(this.nh)>0&&(w=this.n.sub(w),v^=1),new d({r:y,s:w,recoveryParam:v})}}}}}},l.prototype.verify=function(e,t,i,s,r){r||(r={}),e=this._truncateToN(e,!1,r.msgBitLength),i=this.keyFromPublic(i,s);var n=(t=new d(t,"hex")).r,o=t.s;if(n.cmpn(1)<0||n.cmp(this.n)>=0)return!1;if(o.cmpn(1)<0||o.cmp(this.n)>=0)return!1;var a,c=o.invm(this.n),h=c.mul(e).umod(this.n),l=c.mul(n).umod(this.n);return this.curve._maxwellTrick?!(a=this.g.jmulAdd(h,i.getPublic(),l)).isInfinity()&&a.eqXToP(n):!(a=this.g.mulAdd(h,i.getPublic(),l)).isInfinity()&&0===a.getX().umod(this.n).cmp(n)},l.prototype.recoverPubKey=function(e,t,i,r){c((3&i)===i,"The recovery param is more than two bits"),t=new d(t,r);var n=this.n,o=new s(e),a=t.r,h=t.s,l=1&i,u=i>>1;if(a.cmp(this.curve.p.umod(this.curve.n))>=0&&u)throw new Error("Unable to find sencond key candinate");a=u?this.curve.pointFromX(a.add(this.curve.n),l):this.curve.pointFromX(a,l);var p=t.r.invm(n),f=n.sub(o).mul(p).umod(n),g=h.mul(p).umod(n);return this.g.mulAdd(f,a,g)},l.prototype.getKeyRecoveryParam=function(e,t,i,s){if(null!==(t=new d(t,s)).recoveryParam)return t.recoveryParam;for(var r=0;r<4;r++){var n;try{n=this.recoverPubKey(e,t,r)}catch(e){continue}if(n.eq(i))return r}throw new Error("Unable to find valid recovery factor")}},15406:(e,t,i)=>{i.d(t,{t:()=>c});var s=i(16279),r=i(27006),n=i(99013),o=i(89058),a=i(36641);const c={async getMyTokensWithBalance(e){const t=s.U.state.address,i=n.W.state.activeCaipNetwork;if(!t||!i)return[];if("eip155"===i.chainNamespace){const e=await this.getEIP155Balances(t,i);if(e)return this.filterLowQualityTokens(e)}const o=await r.T.getBalance(t,i.caipNetworkId,e);return this.filterLowQualityTokens(o.balances)},async getEIP155Balances(e,t){try{const i=a.T.getChainIdHexFromCAIP2ChainId(t.caipNetworkId),s=await o.x.getCapabilities(e);if(!s?.[i]?.assetDiscovery?.supported)return null;const r=await o.x.walletGetAssets({account:e,chainFilter:[i]});return a.T.isWalletGetAssetsResponse(r)?(r[i]||[]).map(e=>a.T.createBalance(e,t.caipNetworkId)):null}catch(e){return null}},filterLowQualityTokens:e=>e.filter(e=>"0"!==e.quantity.decimals),mapBalancesToSwapTokens:e=>e?.map(e=>({...e,address:e?.address?e.address:n.W.getActiveNetworkTokenAddress(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1}))||[]}},15579:(e,t,i)=>{i.d(t,{R:()=>d});var s=i(4443),r=i(30393),n=i(95191),o=i(99013),a=i(11553),c=i(40770);const h=["near:mainnet","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp","eip155:1101","eip155:56","eip155:42161","eip155:7777777","eip155:59144","eip155:324","solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1","eip155:5000","solana:4sgjmw1sunhzsxgspuhpqldx6wiyjntz","eip155:80084","eip155:5003","eip155:100","eip155:8453","eip155:42220","eip155:1313161555","eip155:17000","eip155:1","eip155:300","eip155:1313161554","eip155:1329","eip155:84532","eip155:421614","eip155:11155111","eip155:8217","eip155:43114","solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z","eip155:999999999","eip155:11155420","eip155:80002","eip155:97","eip155:43113","eip155:137","eip155:10","eip155:1301","bip122:000000000019d6689c085ae165831e93","bip122:000000000933ea01ad0ee984209779ba"],d={extendRpcUrlWithProjectId(e,t){let i=!1;try{i="rpc.walletconnect.org"===new URL(e).host}catch(e){i=!1}if(i){const i=new URL(e);return i.searchParams.has("projectId")||i.searchParams.set("projectId",t),i.toString()}return e},isCaipNetwork:e=>"chainNamespace"in e&&"caipNetworkId"in e,getChainNamespace(e){return this.isCaipNetwork(e)?e.chainNamespace:n.o.CHAIN.EVM},getCaipNetworkId(e){return this.isCaipNetwork(e)?e.caipNetworkId:`${n.o.CHAIN.EVM}:${e.id}`},getDefaultRpcUrl(e,t,i){const s=e.rpcUrls?.default?.http?.[0];return h.includes(t)?function(e,t){const i=new URL("https://rpc.walletconnect.org/v1/");return i.searchParams.set("chainId",e),i.searchParams.set("projectId",t),i.toString()}(t,i):s||""},extendCaipNetwork(e,{customNetworkImageUrls:t,projectId:i,customRpcUrls:s}){const r=this.getChainNamespace(e),n=this.getCaipNetworkId(e),o=e.rpcUrls.default.http?.[0],a=this.getDefaultRpcUrl(e,n,i),h=e?.rpcUrls?.chainDefault?.http?.[0]||o,d=s?.[n]?.map(e=>e.url)||[],l=[...d,a],u=[...d];return h&&!u.includes(h)&&u.push(h),{...e,chainNamespace:r,caipNetworkId:n,assets:{imageId:c.L.NetworkImageIds[e.id],imageUrl:t?.[e.id]},rpcUrls:{...e.rpcUrls,default:{http:l},chainDefault:{http:u}}}},extendCaipNetworks:(e,{customNetworkImageUrls:t,projectId:i,customRpcUrls:s})=>e.map(e=>d.extendCaipNetwork(e,{customNetworkImageUrls:t,customRpcUrls:s,projectId:i})),getViemTransport(e,t,i){const n=[];if(i?.forEach(e=>{n.push((0,r.L)(e.url,e.config))}),h.includes(e.caipNetworkId)){const i=this.getDefaultRpcUrl(e,e.caipNetworkId,t);n.push((0,r.L)(i,{fetchOptions:{headers:{"Content-Type":"text/plain"}}}))}return(0,s.Np)(n)},extendWagmiTransports(e,t,i){if(h.includes(e.caipNetworkId)){const n=this.getDefaultRpcUrl(e,e.caipNetworkId,t);return(0,s.Np)([i,(0,r.L)(n)])}return i},getUnsupportedNetwork:e=>({id:e.split(":")[1],caipNetworkId:e,name:n.o.UNSUPPORTED_NETWORK_NAME,chainNamespace:e.split(":")[0],nativeCurrency:{name:"",decimals:0,symbol:""},rpcUrls:{default:{http:[]}}}),getCaipNetworkFromStorage(e){const t=a.i.getActiveCaipNetworkId(),i=o.W.getAllRequestedCaipNetworks(),s=Array.from(o.W.state.chains?.keys()||[]),r=t?.split(":")[0],n=!!r&&s.includes(r),c=i?.find(e=>e.caipNetworkId===t);return n&&!c&&t?this.getUnsupportedNetwork(t):c||e||i?.[0]}}},16158:(e,t,i)=>{i.d(t,{H:()=>c});var s=i(89168),r=i(39150),n=i(84253),o=i(91310);const a=(0,s.BX)({features:n.oU.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:n.oU.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0}),c={state:a,subscribeKey:(e,t)=>(0,r.u$)(a,e,t),setOptions(e){Object.assign(a,e)},setFeatures(e){if(!e)return;a.features||(a.features=n.oU.DEFAULT_FEATURES);const t={...a.features,...e};a.features=t,a.features.socials&&(a.features.socials=o.D.filterSocialsByPlatform(a.features.socials))},setProjectId(e){a.projectId=e},setCustomRpcUrls(e){a.customRpcUrls=e},setAllWallets(e){a.allWallets=e},setIncludeWalletIds(e){a.includeWalletIds=e},setExcludeWalletIds(e){a.excludeWalletIds=e},setFeaturedWalletIds(e){a.featuredWalletIds=e},setTokens(e){a.tokens=e},setTermsConditionsUrl(e){a.termsConditionsUrl=e},setPrivacyPolicyUrl(e){a.privacyPolicyUrl=e},setCustomWallets(e){a.customWallets=e},setIsSiweEnabled(e){a.isSiweEnabled=e},setIsUniversalProvider(e){a.isUniversalProvider=e},setSdkVersion(e){a.sdkVersion=e},setMetadata(e){a.metadata=e},setDisableAppend(e){a.disableAppend=e},setEIP6963Enabled(e){a.enableEIP6963=e},setDebug(e){a.debug=e},setEnableWalletConnect(e){a.enableWalletConnect=e},setEnableWalletGuide(e){a.enableWalletGuide=e},setEnableAuthLogger(e){a.enableAuthLogger=e},setEnableWallets(e){a.enableWallets=e},setHasMultipleAddresses(e){a.hasMultipleAddresses=e},setSIWX(e){a.siwx=e},setConnectMethodsOrder(e){a.features={...a.features,connectMethodsOrder:e}},setWalletFeaturesOrder(e){a.features={...a.features,walletFeaturesOrder:e}},setSocialsOrder(e){a.features={...a.features,socials:e}},setCollapseWallets(e){a.features={...a.features,collapseWallets:e}},setEnableEmbedded(e){a.enableEmbedded=e},setAllowUnsupportedChain(e){a.allowUnsupportedChain=e},setManualWCControl(e){a.manualWCControl=e},setEnableNetworkSwitch(e){a.enableNetworkSwitch=e},setDefaultAccountTypes(e={}){Object.entries(e).forEach(([e,t])=>{t&&(a.defaultAccountTypes[e]=t)})},setUniversalProviderConfigOverride(e){a.universalProviderConfigOverride=e},getUniversalProviderConfigOverride:()=>a.universalProviderConfigOverride,getSnapshot:()=>(0,s.P9)(a)}},16279:(e,t,i)=>{i.d(t,{U:()=>d});var s=i(89168),r=i(84253),n=i(5813),o=i(27006),a=i(99013),c=i(41430);const h=(0,s.BX)({currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[]}),d={state:h,replaceState(e){e&&Object.assign(h,(0,s.KR)(e))},subscribe:e=>a.W.subscribeChainProp("accountState",t=>{if(t)return e(t)}),subscribeKey(e,t,i){let s;return a.W.subscribeChainProp("accountState",i=>{if(i){const r=i[e];s!==r&&(s=r,t(r))}},i)},setStatus(e,t){a.W.setAccountProp("status",e,t)},getCaipAddress:e=>a.W.getAccountProp("caipAddress",e),setCaipAddress(e,t){const i=e?n.w.getPlainAddress(e):void 0;t===a.W.state.activeChain&&(a.W.state.activeCaipAddress=e),a.W.setAccountProp("caipAddress",e,t),a.W.setAccountProp("address",i,t)},setBalance(e,t,i){a.W.setAccountProp("balance",e,i),a.W.setAccountProp("balanceSymbol",t,i)},setProfileName(e,t){a.W.setAccountProp("profileName",e,t)},setProfileImage(e,t){a.W.setAccountProp("profileImage",e,t)},setUser(e,t){a.W.setAccountProp("user",e,t)},setAddressExplorerUrl(e,t){a.W.setAccountProp("addressExplorerUrl",e,t)},setSmartAccountDeployed(e,t){a.W.setAccountProp("smartAccountDeployed",e,t)},setCurrentTab(e){a.W.setAccountProp("currentTab",e,a.W.state.activeChain)},setTokenBalance(e,t){e&&a.W.setAccountProp("tokenBalance",e,t)},setShouldUpdateToAddress(e,t){a.W.setAccountProp("shouldUpdateToAddress",e,t)},setAllAccounts(e,t){a.W.setAccountProp("allAccounts",e,t)},addAddressLabel(e,t,i){const s=a.W.getAccountProp("addressLabels",i)||new Map;s.set(e,t),a.W.setAccountProp("addressLabels",s,i)},removeAddressLabel(e,t){const i=a.W.getAccountProp("addressLabels",t)||new Map;i.delete(e),a.W.setAccountProp("addressLabels",i,t)},setConnectedWalletInfo(e,t){a.W.setAccountProp("connectedWalletInfo",e,t,!1)},setPreferredAccountType(e,t){a.W.setAccountProp("preferredAccountType",e,t)},setSocialProvider(e,t){e&&a.W.setAccountProp("socialProvider",e,t)},setSocialWindow(e,t){a.W.setAccountProp("socialWindow",e?(0,s.KR)(e):void 0,t)},setFarcasterUrl(e,t){a.W.setAccountProp("farcasterUrl",e,t)},async fetchTokenBalance(e){h.balanceLoading=!0;const t=a.W.state.activeCaipNetwork?.caipNetworkId,i=a.W.state.activeCaipNetwork?.chainNamespace,s=a.W.state.activeCaipAddress,d=s?n.w.getPlainAddress(s):void 0;if(h.lastRetry&&!n.w.isAllowedRetry(h.lastRetry,30*r.oU.ONE_SEC_MS))return h.balanceLoading=!1,[];try{if(d&&t&&i){const e=(await o.T.getBalance(d,t)).balances.filter(e=>"0"!==e.quantity.decimals);return this.setTokenBalance(e,i),h.lastRetry=void 0,h.balanceLoading=!1,e}}catch(t){h.lastRetry=Date.now(),e?.(t),c.P.showError("Token Balance Unavailable")}finally{h.balanceLoading=!1}return[]},resetAccount(e){a.W.resetAccount(e)}}},16652:(e,t,i)=>{i.d(t,{R:()=>y});var s=i(89168),r=i(39150),n=i(22233),o=i(8834),a=i(9663),c=i(84253),h=i(5813),d=i(15406),l=i(16279),u=i(99013),p=i(89058),f=i(14479),g=i(42831),m=i(41430);const b=(0,s.BX)({tokenBalances:[],loading:!1}),y={state:b,subscribe:e=>(0,s.B1)(b,()=>e(b)),subscribeKey:(e,t)=>(0,r.u$)(b,e,t),setToken(e){e&&(b.token=(0,s.KR)(e))},setTokenAmount(e){b.sendTokenAmount=e},setReceiverAddress(e){b.receiverAddress=e},setReceiverProfileImageUrl(e){b.receiverProfileImageUrl=e},setReceiverProfileName(e){b.receiverProfileName=e},setGasPrice(e){b.gasPrice=e},setGasPriceInUsd(e){b.gasPriceInUSD=e},setNetworkBalanceInUsd(e){b.networkBalanceInUSD=e},setLoading(e){b.loading=e},sendToken(){switch(u.W.state.activeCaipNetwork?.chainNamespace){case"eip155":return void this.sendEvmToken();case"solana":return void this.sendSolanaToken();default:throw new Error("Unsupported chain")}},sendEvmToken(){this.state.token?.address&&this.state.sendTokenAmount&&this.state.receiverAddress?(f.E.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:l.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token.address,amount:this.state.sendTokenAmount,network:u.W.state.activeCaipNetwork?.caipNetworkId||""}}),this.sendERC20Token({receiverAddress:this.state.receiverAddress,tokenAddress:this.state.token.address,sendTokenAmount:this.state.sendTokenAmount,decimals:this.state.token.quantity.decimals})):this.state.receiverAddress&&this.state.sendTokenAmount&&this.state.gasPrice&&this.state.token?.quantity.decimals&&(f.E.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:l.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token?.symbol,amount:this.state.sendTokenAmount,network:u.W.state.activeCaipNetwork?.caipNetworkId||""}}),this.sendNativeToken({receiverAddress:this.state.receiverAddress,sendTokenAmount:this.state.sendTokenAmount,gasPrice:this.state.gasPrice,decimals:this.state.token.quantity.decimals}))},async fetchTokenBalance(e){b.loading=!0;const t=u.W.state.activeCaipNetwork?.caipNetworkId,i=u.W.state.activeCaipNetwork?.chainNamespace,s=u.W.state.activeCaipAddress,r=s?h.w.getPlainAddress(s):void 0;if(b.lastRetry&&!h.w.isAllowedRetry(b.lastRetry,30*c.oU.ONE_SEC_MS))return b.loading=!1,[];try{if(r&&t&&i){const e=await d.t.getMyTokensWithBalance();return b.tokenBalances=e,b.lastRetry=void 0,e}}catch(t){b.lastRetry=Date.now(),e?.(t),m.P.showError("Token Balance Unavailable")}finally{b.loading=!1}return[]},fetchNetworkBalance(){if(0===b.tokenBalances.length)return;const e=d.t.mapBalancesToSwapTokens(b.tokenBalances);if(!e)return;const t=e.find(e=>e.address===u.W.getActiveNetworkTokenAddress());t&&(b.networkBalanceInUSD=t?n.S.multiply(t.quantity.numeric,t.price).toString():"0")},isInsufficientNetworkTokenForGas(e,t){const i=t||"0";return!!n.S.bigNumber(e).eq(0)||n.S.bigNumber(n.S.bigNumber(i)).gt(e)},hasInsufficientGasFunds(){let e=!0;return l.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT?e=!1:b.networkBalanceInUSD&&(e=this.isInsufficientNetworkTokenForGas(b.networkBalanceInUSD,b.gasPriceInUSD)),e},async sendNativeToken(e){g.I.pushTransactionStack({view:"Account",goBack:!1});const t=e.receiverAddress,i=l.U.state.address,s=p.x.parseUnits(e.sendTokenAmount.toString(),Number(e.decimals));try{await p.x.sendTransaction({chainNamespace:"eip155",to:t,address:i,data:"0x",value:s??BigInt(0),gasPrice:e.gasPrice}),m.P.showSuccess("Transaction started"),f.E.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:l.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token?.symbol||"",amount:e.sendTokenAmount,network:u.W.state.activeCaipNetwork?.caipNetworkId||""}}),this.resetSend()}catch(t){console.error("SendController:sendERC20Token - failed to send native token",t);const i=t instanceof Error?t.message:"Unknown error";f.E.sendEvent({type:"track",event:"SEND_ERROR",properties:{message:i,isSmartAccount:l.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token?.symbol||"",amount:e.sendTokenAmount,network:u.W.state.activeCaipNetwork?.caipNetworkId||""}}),m.P.showError("Something went wrong")}},async sendERC20Token(e){g.I.pushTransactionStack({view:"Account",goBack:!1});const t=p.x.parseUnits(e.sendTokenAmount.toString(),Number(e.decimals));try{if(l.U.state.address&&e.sendTokenAmount&&e.receiverAddress&&e.tokenAddress){const i=h.w.getPlainAddress(e.tokenAddress);await p.x.writeContract({fromAddress:l.U.state.address,tokenAddress:i,args:[e.receiverAddress,t??BigInt(0)],method:"transfer",abi:o.v.getERC20Abi(i),chainNamespace:"eip155"}),m.P.showSuccess("Transaction started"),this.resetSend()}}catch(t){console.error("SendController:sendERC20Token - failed to send erc20 token",t);const i=t instanceof Error?t.message:"Unknown error";f.E.sendEvent({type:"track",event:"SEND_ERROR",properties:{message:i,isSmartAccount:l.U.state.preferredAccountType===a.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token?.symbol||"",amount:e.sendTokenAmount,network:u.W.state.activeCaipNetwork?.caipNetworkId||""}}),m.P.showError("Something went wrong")}},sendSolanaToken(){this.state.sendTokenAmount&&this.state.receiverAddress?(g.I.pushTransactionStack({view:"Account",goBack:!1}),p.x.sendTransaction({chainNamespace:"solana",to:this.state.receiverAddress,value:this.state.sendTokenAmount}).then(()=>{this.resetSend(),l.U.fetchTokenBalance()}).catch(e=>{m.P.showError("Failed to send transaction. Please try again."),console.error("SendController:sendToken - failed to send solana transaction",e)})):m.P.showError("Please enter a valid amount and receiver address")},resetSend(){b.token=void 0,b.sendTokenAmount=void 0,b.receiverAddress=void 0,b.receiverProfileImageUrl=void 0,b.receiverProfileName=void 0,b.loading=!1,b.tokenBalances=[]}}},18354:(e,t,i)=>{i.d(t,{g:()=>s});const s=(0,i(40149).x)({id:"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",name:"Solana Testnet",network:"solana-testnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"})},18401:(e,t,i)=>{var s=i(64845),r=i(41874),n=r.assert,o=r.cachedProperty,a=r.parseBytes;function c(e,t){this.eddsa=e,"object"!=typeof t&&(t=a(t)),Array.isArray(t)&&(n(t.length===2*e.encodingLength,"Signature has invalid size"),t={R:t.slice(0,e.encodingLength),S:t.slice(e.encodingLength)}),n(t.R&&t.S,"Signature without R or S"),e.isPoint(t.R)&&(this._R=t.R),t.S instanceof s&&(this._S=t.S),this._Rencoded=Array.isArray(t.R)?t.R:t.Rencoded,this._Sencoded=Array.isArray(t.S)?t.S:t.Sencoded}o(c,"S",function(){return this.eddsa.decodeInt(this.Sencoded())}),o(c,"R",function(){return this.eddsa.decodePoint(this.Rencoded())}),o(c,"Rencoded",function(){return this.eddsa.encodePoint(this.R())}),o(c,"Sencoded",function(){return this.eddsa.encodeInt(this.S())}),c.prototype.toBytes=function(){return this.Rencoded().concat(this.Sencoded())},c.prototype.toHex=function(){return r.encode(this.toBytes(),"hex").toUpperCase()},e.exports=c},18677:(e,t,i)=>{e=i.nmd(e);var s="__lodash_hash_undefined__",r=9007199254740991,n="[object Arguments]",o="[object Array]",a="[object Boolean]",c="[object Date]",h="[object Error]",d="[object Function]",l="[object Map]",u="[object Number]",p="[object Object]",f="[object Promise]",g="[object RegExp]",m="[object Set]",b="[object String]",y="[object WeakMap]",w="[object ArrayBuffer]",v="[object DataView]",I=/^\[object .+?Constructor\]$/,E=/^(?:0|[1-9]\d*)$/,_={};_["[object Float32Array]"]=_["[object Float64Array]"]=_["[object Int8Array]"]=_["[object Int16Array]"]=_["[object Int32Array]"]=_["[object Uint8Array]"]=_["[object Uint8ClampedArray]"]=_["[object Uint16Array]"]=_["[object Uint32Array]"]=!0,_[n]=_[o]=_[w]=_[a]=_[v]=_[c]=_[h]=_[d]=_[l]=_[u]=_[p]=_[g]=_[m]=_[b]=_[y]=!1;var A="object"==typeof i.g&&i.g&&i.g.Object===Object&&i.g,N="object"==typeof self&&self&&self.Object===Object&&self,C=A||N||Function("return this")(),S=t&&!t.nodeType&&t,P=S&&e&&!e.nodeType&&e,O=P&&P.exports===S,T=O&&A.process,x=function(){try{return T&&T.binding&&T.binding("util")}catch(e){}}(),k=x&&x.isTypedArray;function R(e,t){for(var i=-1,s=null==e?0:e.length;++i<s;)if(t(e[i],i,e))return!0;return!1}function M(e){var t=-1,i=Array(e.size);return e.forEach(function(e,s){i[++t]=[s,e]}),i}function U(e){var t=-1,i=Array(e.size);return e.forEach(function(e){i[++t]=e}),i}var D,j,L,q=Array.prototype,$=Function.prototype,B=Object.prototype,z=C["__core-js_shared__"],H=$.toString,W=B.hasOwnProperty,V=(D=/[^.]+$/.exec(z&&z.keys&&z.keys.IE_PROTO||""))?"Symbol(src)_1."+D:"",F=B.toString,K=RegExp("^"+H.call(W).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),G=O?C.Buffer:void 0,J=C.Symbol,Y=C.Uint8Array,X=B.propertyIsEnumerable,Q=q.splice,Z=J?J.toStringTag:void 0,ee=Object.getOwnPropertySymbols,te=G?G.isBuffer:void 0,ie=(j=Object.keys,L=Object,function(e){return j(L(e))}),se=Pe(C,"DataView"),re=Pe(C,"Map"),ne=Pe(C,"Promise"),oe=Pe(C,"Set"),ae=Pe(C,"WeakMap"),ce=Pe(Object,"create"),he=ke(se),de=ke(re),le=ke(ne),ue=ke(oe),pe=ke(ae),fe=J?J.prototype:void 0,ge=fe?fe.valueOf:void 0;function me(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var s=e[t];this.set(s[0],s[1])}}function be(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var s=e[t];this.set(s[0],s[1])}}function ye(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var s=e[t];this.set(s[0],s[1])}}function we(e){var t=-1,i=null==e?0:e.length;for(this.__data__=new ye;++t<i;)this.add(e[t])}function ve(e){var t=this.__data__=new be(e);this.size=t.size}function Ie(e,t){for(var i=e.length;i--;)if(Re(e[i][0],t))return i;return-1}function Ee(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Z&&Z in Object(e)?function(e){var t=W.call(e,Z),i=e[Z];try{e[Z]=void 0;var s=!0}catch(e){}var r=F.call(e);return s&&(t?e[Z]=i:delete e[Z]),r}(e):function(e){return F.call(e)}(e)}function _e(e){return $e(e)&&Ee(e)==n}function Ae(e,t,i,s,r){return e===t||(null==e||null==t||!$e(e)&&!$e(t)?e!=e&&t!=t:function(e,t,i,s,r,d){var f=Ue(e),y=Ue(t),I=f?o:Te(e),E=y?o:Te(t),_=(I=I==n?p:I)==p,A=(E=E==n?p:E)==p,N=I==E;if(N&&De(e)){if(!De(t))return!1;f=!0,_=!1}if(N&&!_)return d||(d=new ve),f||Be(e)?Ne(e,t,i,s,r,d):function(e,t,i,s,r,n,o){switch(i){case v:if(e.byteLength!=t.byteLength||e.byteOffset!=t.byteOffset)return!1;e=e.buffer,t=t.buffer;case w:return!(e.byteLength!=t.byteLength||!n(new Y(e),new Y(t)));case a:case c:case u:return Re(+e,+t);case h:return e.name==t.name&&e.message==t.message;case g:case b:return e==t+"";case l:var d=M;case m:var p=1&s;if(d||(d=U),e.size!=t.size&&!p)return!1;var f=o.get(e);if(f)return f==t;s|=2,o.set(e,t);var y=Ne(d(e),d(t),s,r,n,o);return o.delete(e),y;case"[object Symbol]":if(ge)return ge.call(e)==ge.call(t)}return!1}(e,t,I,i,s,r,d);if(!(1&i)){var C=_&&W.call(e,"__wrapped__"),S=A&&W.call(t,"__wrapped__");if(C||S){var P=C?e.value():e,O=S?t.value():t;return d||(d=new ve),r(P,O,i,s,d)}}return!!N&&(d||(d=new ve),function(e,t,i,s,r,n){var o=1&i,a=Ce(e),c=a.length;if(c!=Ce(t).length&&!o)return!1;for(var h=c;h--;){var d=a[h];if(!(o?d in t:W.call(t,d)))return!1}var l=n.get(e);if(l&&n.get(t))return l==t;var u=!0;n.set(e,t),n.set(t,e);for(var p=o;++h<c;){var f=e[d=a[h]],g=t[d];if(s)var m=o?s(g,f,d,t,e,n):s(f,g,d,e,t,n);if(!(void 0===m?f===g||r(f,g,i,s,n):m)){u=!1;break}p||(p="constructor"==d)}if(u&&!p){var b=e.constructor,y=t.constructor;b==y||!("constructor"in e)||!("constructor"in t)||"function"==typeof b&&b instanceof b&&"function"==typeof y&&y instanceof y||(u=!1)}return n.delete(e),n.delete(t),u}(e,t,i,s,r,d))}(e,t,i,s,Ae,r))}function Ne(e,t,i,s,r,n){var o=1&i,a=e.length,c=t.length;if(a!=c&&!(o&&c>a))return!1;var h=n.get(e);if(h&&n.get(t))return h==t;var d=-1,l=!0,u=2&i?new we:void 0;for(n.set(e,t),n.set(t,e);++d<a;){var p=e[d],f=t[d];if(s)var g=o?s(f,p,d,t,e,n):s(p,f,d,e,t,n);if(void 0!==g){if(g)continue;l=!1;break}if(u){if(!R(t,function(e,t){if(o=t,!u.has(o)&&(p===e||r(p,e,i,s,n)))return u.push(t);var o})){l=!1;break}}else if(p!==f&&!r(p,f,i,s,n)){l=!1;break}}return n.delete(e),n.delete(t),l}function Ce(e){return function(e,t,i){var s=t(e);return Ue(e)?s:function(e,t){for(var i=-1,s=t.length,r=e.length;++i<s;)e[r+i]=t[i];return e}(s,i(e))}(e,ze,Oe)}function Se(e,t){var i,s,r=e.__data__;return("string"==(s=typeof(i=t))||"number"==s||"symbol"==s||"boolean"==s?"__proto__"!==i:null===i)?r["string"==typeof t?"string":"hash"]:r.map}function Pe(e,t){var i=function(e,t){return null==e?void 0:e[t]}(e,t);return function(e){return!(!qe(e)||function(e){return!!V&&V in e}(e))&&(je(e)?K:I).test(ke(e))}(i)?i:void 0}me.prototype.clear=function(){this.__data__=ce?ce(null):{},this.size=0},me.prototype.delete=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},me.prototype.get=function(e){var t=this.__data__;if(ce){var i=t[e];return i===s?void 0:i}return W.call(t,e)?t[e]:void 0},me.prototype.has=function(e){var t=this.__data__;return ce?void 0!==t[e]:W.call(t,e)},me.prototype.set=function(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=ce&&void 0===t?s:t,this},be.prototype.clear=function(){this.__data__=[],this.size=0},be.prototype.delete=function(e){var t=this.__data__,i=Ie(t,e);return!(i<0||(i==t.length-1?t.pop():Q.call(t,i,1),--this.size,0))},be.prototype.get=function(e){var t=this.__data__,i=Ie(t,e);return i<0?void 0:t[i][1]},be.prototype.has=function(e){return Ie(this.__data__,e)>-1},be.prototype.set=function(e,t){var i=this.__data__,s=Ie(i,e);return s<0?(++this.size,i.push([e,t])):i[s][1]=t,this},ye.prototype.clear=function(){this.size=0,this.__data__={hash:new me,map:new(re||be),string:new me}},ye.prototype.delete=function(e){var t=Se(this,e).delete(e);return this.size-=t?1:0,t},ye.prototype.get=function(e){return Se(this,e).get(e)},ye.prototype.has=function(e){return Se(this,e).has(e)},ye.prototype.set=function(e,t){var i=Se(this,e),s=i.size;return i.set(e,t),this.size+=i.size==s?0:1,this},we.prototype.add=we.prototype.push=function(e){return this.__data__.set(e,s),this},we.prototype.has=function(e){return this.__data__.has(e)},ve.prototype.clear=function(){this.__data__=new be,this.size=0},ve.prototype.delete=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},ve.prototype.get=function(e){return this.__data__.get(e)},ve.prototype.has=function(e){return this.__data__.has(e)},ve.prototype.set=function(e,t){var i=this.__data__;if(i instanceof be){var s=i.__data__;if(!re||s.length<199)return s.push([e,t]),this.size=++i.size,this;i=this.__data__=new ye(s)}return i.set(e,t),this.size=i.size,this};var Oe=ee?function(e){return null==e?[]:(e=Object(e),function(e,t){for(var i=-1,s=null==e?0:e.length,r=0,n=[];++i<s;){var o=e[i];t(o)&&(n[r++]=o)}return n}(ee(e),function(t){return X.call(e,t)}))}:function(){return[]},Te=Ee;function xe(e,t){return!!(t=null==t?r:t)&&("number"==typeof e||E.test(e))&&e>-1&&e%1==0&&e<t}function ke(e){if(null!=e){try{return H.call(e)}catch(e){}try{return e+""}catch(e){}}return""}function Re(e,t){return e===t||e!=e&&t!=t}(se&&Te(new se(new ArrayBuffer(1)))!=v||re&&Te(new re)!=l||ne&&Te(ne.resolve())!=f||oe&&Te(new oe)!=m||ae&&Te(new ae)!=y)&&(Te=function(e){var t=Ee(e),i=t==p?e.constructor:void 0,s=i?ke(i):"";if(s)switch(s){case he:return v;case de:return l;case le:return f;case ue:return m;case pe:return y}return t});var Me=_e(function(){return arguments}())?_e:function(e){return $e(e)&&W.call(e,"callee")&&!X.call(e,"callee")},Ue=Array.isArray,De=te||function(){return!1};function je(e){if(!qe(e))return!1;var t=Ee(e);return t==d||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t}function Le(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=r}function qe(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)}function $e(e){return null!=e&&"object"==typeof e}var Be=k?function(e){return function(t){return e(t)}}(k):function(e){return $e(e)&&Le(e.length)&&!!_[Ee(e)]};function ze(e){return null!=(t=e)&&Le(t.length)&&!je(t)?function(e,t){var i=Ue(e),s=!i&&Me(e),r=!i&&!s&&De(e),n=!i&&!s&&!r&&Be(e),o=i||s||r||n,a=o?function(e,t){for(var i=-1,s=Array(e);++i<e;)s[i]=t(i);return s}(e.length,String):[],c=a.length;for(var h in e)!t&&!W.call(e,h)||o&&("length"==h||r&&("offset"==h||"parent"==h)||n&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||xe(h,c))||a.push(h);return a}(e):function(e){if(i=(t=e)&&t.constructor,t!==("function"==typeof i&&i.prototype||B))return ie(e);var t,i,s=[];for(var r in Object(e))W.call(e,r)&&"constructor"!=r&&s.push(r);return s}(e);var t}e.exports=function(e,t){return Ae(e,t)}},19760:(e,t,i)=>{async function s(...e){const t=await fetch(...e);if(!t.ok)throw new Error(`HTTP status code: ${t.status}`,{cause:t});return t}i.d(t,{Z:()=>r});class r{constructor({baseUrl:e,clientId:t}){this.baseUrl=e,this.clientId=t}async get({headers:e,signal:t,cache:i,...r}){const n=this.createUrl(r);return(await s(n,{method:"GET",headers:e,signal:t,cache:i})).json()}async getBlob({headers:e,signal:t,...i}){const r=this.createUrl(i);return(await s(r,{method:"GET",headers:e,signal:t})).blob()}async post({body:e,headers:t,signal:i,...r}){const n=this.createUrl(r);return(await s(n,{method:"POST",headers:t,body:e?JSON.stringify(e):void 0,signal:i})).json()}async put({body:e,headers:t,signal:i,...r}){const n=this.createUrl(r);return(await s(n,{method:"PUT",headers:t,body:e?JSON.stringify(e):void 0,signal:i})).json()}async delete({body:e,headers:t,signal:i,...r}){const n=this.createUrl(r);return(await s(n,{method:"DELETE",headers:t,body:e?JSON.stringify(e):void 0,signal:i})).json()}createUrl({path:e,params:t}){const i=new URL(e,this.baseUrl);return t&&Object.entries(t).forEach(([e,t])=>{t&&i.searchParams.append(e,t)}),this.clientId&&i.searchParams.append("clientId",this.clientId),i}}},21547:(e,t,i)=>{var s=i(41874),r=i(64845),n=i(35615),o=i(85174),a=s.assert;function c(e){this.twisted=1!=(0|e.a),this.mOneA=this.twisted&&-1==(0|e.a),this.extended=this.mOneA,o.call(this,"edwards",e),this.a=new r(e.a,16).umod(this.red.m),this.a=this.a.toRed(this.red),this.c=new r(e.c,16).toRed(this.red),this.c2=this.c.redSqr(),this.d=new r(e.d,16).toRed(this.red),this.dd=this.d.redAdd(this.d),a(!this.twisted||0===this.c.fromRed().cmpn(1)),this.oneC=1==(0|e.c)}function h(e,t,i,s,n){o.BasePoint.call(this,e,"projective"),null===t&&null===i&&null===s?(this.x=this.curve.zero,this.y=this.curve.one,this.z=this.curve.one,this.t=this.curve.zero,this.zOne=!0):(this.x=new r(t,16),this.y=new r(i,16),this.z=s?new r(s,16):this.curve.one,this.t=n&&new r(n,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.t&&!this.t.red&&(this.t=this.t.toRed(this.curve.red)),this.zOne=this.z===this.curve.one,this.curve.extended&&!this.t&&(this.t=this.x.redMul(this.y),this.zOne||(this.t=this.t.redMul(this.z.redInvm()))))}n(c,o),e.exports=c,c.prototype._mulA=function(e){return this.mOneA?e.redNeg():this.a.redMul(e)},c.prototype._mulC=function(e){return this.oneC?e:this.c.redMul(e)},c.prototype.jpoint=function(e,t,i,s){return this.point(e,t,i,s)},c.prototype.pointFromX=function(e,t){(e=new r(e,16)).red||(e=e.toRed(this.red));var i=e.redSqr(),s=this.c2.redSub(this.a.redMul(i)),n=this.one.redSub(this.c2.redMul(this.d).redMul(i)),o=s.redMul(n.redInvm()),a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error("invalid point");var c=a.fromRed().isOdd();return(t&&!c||!t&&c)&&(a=a.redNeg()),this.point(e,a)},c.prototype.pointFromY=function(e,t){(e=new r(e,16)).red||(e=e.toRed(this.red));var i=e.redSqr(),s=i.redSub(this.c2),n=i.redMul(this.d).redMul(this.c2).redSub(this.a),o=s.redMul(n.redInvm());if(0===o.cmp(this.zero)){if(t)throw new Error("invalid point");return this.point(this.zero,e)}var a=o.redSqrt();if(0!==a.redSqr().redSub(o).cmp(this.zero))throw new Error("invalid point");return a.fromRed().isOdd()!==t&&(a=a.redNeg()),this.point(a,e)},c.prototype.validate=function(e){if(e.isInfinity())return!0;e.normalize();var t=e.x.redSqr(),i=e.y.redSqr(),s=t.redMul(this.a).redAdd(i),r=this.c2.redMul(this.one.redAdd(this.d.redMul(t).redMul(i)));return 0===s.cmp(r)},n(h,o.BasePoint),c.prototype.pointFromJSON=function(e){return h.fromJSON(this,e)},c.prototype.point=function(e,t,i,s){return new h(this,e,t,i,s)},h.fromJSON=function(e,t){return new h(e,t[0],t[1],t[2])},h.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},h.prototype.isInfinity=function(){return 0===this.x.cmpn(0)&&(0===this.y.cmp(this.z)||this.zOne&&0===this.y.cmp(this.curve.c))},h.prototype._extDbl=function(){var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr();i=i.redIAdd(i);var s=this.curve._mulA(e),r=this.x.redAdd(this.y).redSqr().redISub(e).redISub(t),n=s.redAdd(t),o=n.redSub(i),a=s.redSub(t),c=r.redMul(o),h=n.redMul(a),d=r.redMul(a),l=o.redMul(n);return this.curve.point(c,h,l,d)},h.prototype._projDbl=function(){var e,t,i,s,r,n,o=this.x.redAdd(this.y).redSqr(),a=this.x.redSqr(),c=this.y.redSqr();if(this.curve.twisted){var h=(s=this.curve._mulA(a)).redAdd(c);this.zOne?(e=o.redSub(a).redSub(c).redMul(h.redSub(this.curve.two)),t=h.redMul(s.redSub(c)),i=h.redSqr().redSub(h).redSub(h)):(r=this.z.redSqr(),n=h.redSub(r).redISub(r),e=o.redSub(a).redISub(c).redMul(n),t=h.redMul(s.redSub(c)),i=h.redMul(n))}else s=a.redAdd(c),r=this.curve._mulC(this.z).redSqr(),n=s.redSub(r).redSub(r),e=this.curve._mulC(o.redISub(s)).redMul(n),t=this.curve._mulC(s).redMul(a.redISub(c)),i=s.redMul(n);return this.curve.point(e,t,i)},h.prototype.dbl=function(){return this.isInfinity()?this:this.curve.extended?this._extDbl():this._projDbl()},h.prototype._extAdd=function(e){var t=this.y.redSub(this.x).redMul(e.y.redSub(e.x)),i=this.y.redAdd(this.x).redMul(e.y.redAdd(e.x)),s=this.t.redMul(this.curve.dd).redMul(e.t),r=this.z.redMul(e.z.redAdd(e.z)),n=i.redSub(t),o=r.redSub(s),a=r.redAdd(s),c=i.redAdd(t),h=n.redMul(o),d=a.redMul(c),l=n.redMul(c),u=o.redMul(a);return this.curve.point(h,d,u,l)},h.prototype._projAdd=function(e){var t,i,s=this.z.redMul(e.z),r=s.redSqr(),n=this.x.redMul(e.x),o=this.y.redMul(e.y),a=this.curve.d.redMul(n).redMul(o),c=r.redSub(a),h=r.redAdd(a),d=this.x.redAdd(this.y).redMul(e.x.redAdd(e.y)).redISub(n).redISub(o),l=s.redMul(c).redMul(d);return this.curve.twisted?(t=s.redMul(h).redMul(o.redSub(this.curve._mulA(n))),i=c.redMul(h)):(t=s.redMul(h).redMul(o.redSub(n)),i=this.curve._mulC(c).redMul(h)),this.curve.point(l,t,i)},h.prototype.add=function(e){return this.isInfinity()?e:e.isInfinity()?this:this.curve.extended?this._extAdd(e):this._projAdd(e)},h.prototype.mul=function(e){return this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve._wnafMul(this,e)},h.prototype.mulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!1)},h.prototype.jmulAdd=function(e,t,i){return this.curve._wnafMulAdd(1,[this,t],[e,i],2,!0)},h.prototype.normalize=function(){if(this.zOne)return this;var e=this.z.redInvm();return this.x=this.x.redMul(e),this.y=this.y.redMul(e),this.t&&(this.t=this.t.redMul(e)),this.z=this.curve.one,this.zOne=!0,this},h.prototype.neg=function(){return this.curve.point(this.x.redNeg(),this.y,this.z,this.t&&this.t.redNeg())},h.prototype.getX=function(){return this.normalize(),this.x.fromRed()},h.prototype.getY=function(){return this.normalize(),this.y.fromRed()},h.prototype.eq=function(e){return this===e||0===this.getX().cmp(e.getX())&&0===this.getY().cmp(e.getY())},h.prototype.eqXToP=function(e){var t=e.toRed(this.curve.red).redMul(this.z);if(0===this.x.cmp(t))return!0;for(var i=e.clone(),s=this.curve.redN.redMul(this.z);;){if(i.iadd(this.curve.n),i.cmp(this.curve.p)>=0)return!1;if(t.redIAdd(s),0===this.x.cmp(t))return!0}},h.prototype.toP=h.prototype.normalize,h.prototype.mixedAdd=h.prototype.add},21910:(e,t,i)=>{i.d(t,{$Q:()=>w,GF:()=>y,S9:()=>E,Vx:()=>m,ZP:()=>c,dQ:()=>l,lZ:()=>d,m5:()=>p,mF:()=>g,pi:()=>f,qE:()=>u,yJ:()=>_,zl:()=>b});var s=i(94549),r=i(50046),n=i.n(r),o=Object.defineProperty,a=(e,t,i)=>((e,t,i)=>t in e?o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class c extends s.H{constructor(e){super(),this.opts=e,a(this,"protocol","wc"),a(this,"version",2)}}var h=Object.defineProperty;class d extends s.H{constructor(e,t){super(),this.core=e,this.logger=t,((e,t,i)=>{((e,t,i)=>{t in e?h(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i})(e,"symbol"!=typeof t?t+"":t,i)})(this,"records",new Map)}}class l{constructor(e,t){this.logger=e,this.core=t}}class u extends s.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class p extends s.H{constructor(e){super()}}class f{constructor(e,t,i,s){this.core=e,this.logger=t,this.name=i}}Object.defineProperty;class g extends s.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class m extends s.H{constructor(e,t){super(),this.core=e,this.logger=t}}class b{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}}class y{constructor(e,t){this.projectId=e,this.logger=t}}class w{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}}var v=Object.defineProperty,I=(e,t,i)=>((e,t,i)=>t in e?v(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);n();class E{constructor(e){this.opts=e,I(this,"protocol","wc"),I(this,"version",2)}}r.EventEmitter;class _{constructor(e){this.client=e}}},22233:(e,t,i)=>{i.d(t,{S:()=>r});var s=i(66857);const r={bigNumber:e=>e?new s.A(e):new s.A(0),multiply(e,t){if(void 0===e||void 0===t)return new s.A(0);const i=new s.A(e),r=new s.A(t);return i.times(r)},formatNumberToLocalString:(e,t=2)=>void 0===e?"0.00":"number"==typeof e?e.toLocaleString("en-US",{maximumFractionDigits:t,minimumFractionDigits:t}):parseFloat(e).toLocaleString("en-US",{maximumFractionDigits:t,minimumFractionDigits:t}),parseLocalStringToNumber:e=>void 0===e?0:parseFloat(e.replace(/,/gu,""))}},23438:(e,t,i)=>{i.d(t,{A:()=>Qe});var s=i(37876),r=i(47431),n=i(70255),o=i(64264),a=i(93786),c=i(14350),h=i(50046),d=i.n(h),l=i(48526).hp;const u="error",p="wc@2:universal_provider:",f="https://rpc.walletconnect.org/v1/",g="generic",m=`${f}bundler`,b="default_chain_changed";function y(){}function w(e){return null==e||"object"!=typeof e&&"function"!=typeof e}function v(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function I(e){return"object"==typeof e&&null!==e}function E(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function _(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const A="[object String]",N="[object Number]",C="[object Boolean]",S="[object Arguments]";function P(e,t,i,s=new Map,r=void 0){const n=r?.(e,t,i,s);if(null!=n)return n;if(w(e))return e;if(s.has(e))return s.get(e);if(Array.isArray(e)){const t=new Array(e.length);s.set(e,t);for(let n=0;n<e.length;n++)t[n]=P(e[n],n,i,s,r);return Object.hasOwn(e,"index")&&(t.index=e.index),Object.hasOwn(e,"input")&&(t.input=e.input),t}if(e instanceof Date)return new Date(e.getTime());if(e instanceof RegExp){const t=new RegExp(e.source,e.flags);return t.lastIndex=e.lastIndex,t}if(e instanceof Map){const t=new Map;s.set(e,t);for(const[n,o]of e)t.set(n,P(o,n,i,s,r));return t}if(e instanceof Set){const t=new Set;s.set(e,t);for(const n of e)t.add(P(n,void 0,i,s,r));return t}if(typeof l<"u"&&l.isBuffer(e))return e.subarray();if(v(e)){const t=new(Object.getPrototypeOf(e).constructor)(e.length);s.set(e,t);for(let n=0;n<e.length;n++)t[n]=P(e[n],n,i,s,r);return t}if(e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);if(e instanceof DataView){const t=new DataView(e.buffer.slice(0),e.byteOffset,e.byteLength);return s.set(e,t),O(t,e,i,s,r),t}if(typeof File<"u"&&e instanceof File){const t=new File([e],e.name,{type:e.type});return s.set(e,t),O(t,e,i,s,r),t}if(e instanceof Blob){const t=new Blob([e],{type:e.type});return s.set(e,t),O(t,e,i,s,r),t}if(e instanceof Error){const t=new e.constructor;return s.set(e,t),t.message=e.message,t.name=e.name,t.stack=e.stack,t.cause=e.cause,O(t,e,i,s,r),t}if("object"==typeof e&&function(e){switch(_(e)){case S:case"[object Array]":case"[object ArrayBuffer]":case"[object DataView]":case C:case"[object Date]":case"[object Float32Array]":case"[object Float64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object Map]":case N:case"[object Object]":case"[object RegExp]":case"[object Set]":case A:case"[object Symbol]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":return!0;default:return!1}}(e)){const t=Object.create(Object.getPrototypeOf(e));return s.set(e,t),O(t,e,i,s,r),t}return e}function O(e,t,i=e,s,r){const n=[...Object.keys(t),...E(t)];for(let o=0;o<n.length;o++){const a=n[o],c=Object.getOwnPropertyDescriptor(e,a);(null==c||c.writable)&&(e[a]=P(t[a],a,i,s,r))}}function T(e){return function(e,t){return function(e,t){return P(e,void 0,e,new Map,t)}(e,(i,s,r,n)=>{const o=t?.(i,s,r,n);if(null!=o)return o;if("object"==typeof e)switch(Object.prototype.toString.call(e)){case N:case A:case C:{const t=new e.constructor(e?.valueOf());return O(t,e),t}case S:{const t={};return O(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}})}(e)}function x(e){return null!==e&&"object"==typeof e&&"[object Arguments]"===_(e)}function k(e){return v(e)}function R(e){if("object"!=typeof e||null==e)return!1;if(null===Object.getPrototypeOf(e))return!0;if("[object Object]"!==Object.prototype.toString.call(e)){const t=e[Symbol.toStringTag];return!(null==t||!Object.getOwnPropertyDescriptor(e,Symbol.toStringTag)?.writable)&&e.toString()===`[object ${t}]`}let t=e;for(;null!==Object.getPrototypeOf(t);)t=Object.getPrototypeOf(t);return Object.getPrototypeOf(e)===t}function M(e,t,i,s){if(w(e)&&(e=Object(e)),null==t||"object"!=typeof t)return e;if(s.has(t))return function(e){if(w(e))return e;if(Array.isArray(e)||v(e)||e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);const t=Object.getPrototypeOf(e),i=t.constructor;if(e instanceof Date||e instanceof Map||e instanceof Set)return new i(e);if(e instanceof RegExp){const t=new i(e);return t.lastIndex=e.lastIndex,t}if(e instanceof DataView)return new i(e.buffer.slice(0));if(e instanceof Error){const t=new i(e.message);return t.stack=e.stack,t.name=e.name,t.cause=e.cause,t}if(typeof File<"u"&&e instanceof File)return new i([e],e.name,{type:e.type,lastModified:e.lastModified});if("object"==typeof e){const i=Object.create(t);return Object.assign(i,e)}return e}(s.get(t));if(s.set(t,e),Array.isArray(t)){t=t.slice();for(let e=0;e<t.length;e++)t[e]=t[e]??void 0}const r=[...Object.keys(t),...E(t)];for(let n=0;n<r.length;n++){const o=r[n];let a=t[o],c=e[o];if(x(a)&&(a={...a}),x(c)&&(c={...c}),typeof l<"u"&&l.isBuffer(a)&&(a=T(a)),Array.isArray(a))if("object"==typeof c&&null!=c){const e=[],t=Reflect.ownKeys(c);for(let i=0;i<t.length;i++){const s=t[i];e[s]=c[s]}c=e}else c=[];const h=i(c,a,o,e,t,s);null!=h?e[o]=h:Array.isArray(a)||I(c)&&I(a)?e[o]=M(c,a,i,s):null==c&&R(a)?e[o]=M({},a,i,s):null==c&&k(a)?e[o]=T(a):(void 0===c||void 0!==a)&&(e[o]=a)}return e}var U=Object.defineProperty,D=Object.defineProperties,j=Object.getOwnPropertyDescriptors,L=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,B=(e,t,i)=>t in e?U(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,z=(e,t)=>{for(var i in t||(t={}))q.call(t,i)&&B(e,i,t[i]);if(L)for(var i of L(t))$.call(t,i)&&B(e,i,t[i]);return e},H=(e,t)=>D(e,j(t));function W(e,t,i){var s;const n=(0,r._Yb)(e);return(null==(s=t.rpcMap)?void 0:s[n.reference])||`${f}?chainId=${n.namespace}:${n.reference}&projectId=${i}`}function V(e){return e.includes(":")?e.split(":")[1]:e}function F(e){return e.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function K(e={},t={}){return function(e,...t){return function(e,...t){const i=t.slice(0,-1),s=t[t.length-1];let r=e;for(let e=0;e<i.length;e++)r=M(r,i[e],s,new Map);return r}(e,...t,y)}(G(e),G(t))}function G(e){var t,i,s,n;const o={};if(!(0,r.aF0)(e))return o;for(const[a,c]of Object.entries(e)){const e=(0,r.nWe)(a)?[a]:c.chains,h=c.methods||[],d=c.events||[],l=c.rpcMap||{},u=(0,r.kob)(a);o[u]=H(z(z({},o[u]),c),{chains:(0,r.TRk)(e,null==(t=o[u])?void 0:t.chains),methods:(0,r.TRk)(h,null==(i=o[u])?void 0:i.methods),events:(0,r.TRk)(d,null==(s=o[u])?void 0:s.events),rpcMap:z(z({},l),null==(n=o[u])?void 0:n.rpcMap)})}return o}function J(e){return e.includes(":")?e.split(":")[2]:e}function Y(e){const t={};for(const[i,s]of Object.entries(e)){const e=s.methods||[],n=s.events||[],o=s.accounts||[],a=(0,r.nWe)(i)?[i]:s.chains?s.chains:F(s.accounts);t[i]={chains:a,methods:e,events:n,accounts:o}}return t}function X(e){return"number"==typeof e?e:e.includes("0x")?parseInt(e,16):(e=e.includes(":")?e.split(":")[1]:e,isNaN(Number(e))?e:Number(e))}const Q={},Z=e=>Q[e],ee=(e,t)=>{Q[e]=t};var te=Object.defineProperty,ie=(e,t,i)=>((e,t,i)=>t in e?te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class se{constructor(e){ie(this,"name","polkadot"),ie(this,"client"),ie(this,"httpProviders"),ie(this,"events"),ie(this,"namespace"),ie(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(b,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=V(t);e[s]=this.createHttpProvider(s,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||W(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(i,Z("disableProviderPing")))}}var re=Object.defineProperty,ne=Object.defineProperties,oe=Object.getOwnPropertyDescriptors,ae=Object.getOwnPropertySymbols,ce=Object.prototype.hasOwnProperty,he=Object.prototype.propertyIsEnumerable,de=(e,t,i)=>t in e?re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,le=(e,t)=>{for(var i in t||(t={}))ce.call(t,i)&&de(e,i,t[i]);if(ae)for(var i of ae(t))he.call(t,i)&&de(e,i,t[i]);return e},ue=(e,t)=>ne(e,oe(t)),pe=(e,t,i)=>de(e,"symbol"!=typeof t?t+"":t,i);class fe{constructor(e){pe(this,"name","eip155"),pe(this,"client"),pe(this,"chainId"),pe(this,"namespace"),pe(this,"httpProviders"),pe(this,"events"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(b,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const i=t||W(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.V(i,Z("disableProviderPing")))}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=parseInt(V(t));e[s]=this.createHttpProvider(s,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,i;let s=e.request.params?null==(t=e.request.params[0])?void 0:t.chainId:"0x0";s=s.startsWith("0x")?s:`0x${s}`;const r=parseInt(s,16);if(this.isChainApproved(r))this.setDefaultChain(`${r}`);else{if(!this.namespace.methods.includes("wallet_switchEthereumChain"))throw new Error(`Failed to switch to chain 'eip155:${r}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:s}]},chainId:null==(i=this.namespace.chains)?void 0:i[0]}),this.setDefaultChain(`${r}`)}return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,i,s;const r=null==(i=null==(t=e.request)?void 0:t.params)?void 0:i[0];if(!r)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const n=this.client.session.get(e.topic),o=(null==(s=n?.sessionProperties)?void 0:s.capabilities)||{};if(null!=o&&o[r])return o?.[r];const a=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:ue(le({},n.sessionProperties||{}),{capabilities:ue(le({},o||{}),{[r]:a})})})}catch(e){console.warn("Failed to update session with capabilities",e)}return a}async getCallStatus(e){var t,i;const s=this.client.session.get(e.topic),r=null==(t=s.sessionProperties)?void 0:t.bundler_name;if(r){const t=this.getBundlerUrl(e.chainId,r);try{return await this.getUserOperationReceipt(t,e)}catch(e){console.warn("Failed to fetch call status from bundler",e,t)}}const n=null==(i=s.sessionProperties)?void 0:i.bundler_url;if(n)try{return await this.getUserOperationReceipt(n,e)}catch(e){console.warn("Failed to fetch call status from custom bundler",e,n)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var i;const s=new URL(e),r=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,c.formatJsonRpcRequest)("eth_getUserOperationReceipt",[null==(i=t.request.params)?void 0:i[0]]))});if(!r.ok)throw new Error(`Failed to fetch user operation receipt - ${r.status}`);return await r.json()}getBundlerUrl(e,t){return`${m}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}var ge=Object.defineProperty,me=(e,t,i)=>((e,t,i)=>t in e?ge(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class be{constructor(e){me(this,"name","solana"),me(this,"client"),me(this,"httpProviders"),me(this,"events"),me(this,"namespace"),me(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(b,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=V(t);e[s]=this.createHttpProvider(s,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||W(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(i,Z("disableProviderPing")))}}var ye=Object.defineProperty,we=(e,t,i)=>((e,t,i)=>t in e?ye(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class ve{constructor(e){we(this,"name","cosmos"),we(this,"client"),we(this,"httpProviders"),we(this,"events"),we(this,"namespace"),we(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(b,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=V(t);e[s]=this.createHttpProvider(s,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||W(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(i,Z("disableProviderPing")))}}var Ie=Object.defineProperty,Ee=(e,t,i)=>((e,t,i)=>t in e?Ie(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class _e{constructor(e){Ee(this,"name","algorand"),Ee(this,"client"),Ee(this,"httpProviders"),Ee(this,"events"),Ee(this,"namespace"),Ee(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const i=t||W(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(b,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||W(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new a.F(new o.A(i,Z("disableProviderPing")))}}var Ae=Object.defineProperty,Ne=(e,t,i)=>((e,t,i)=>t in e?Ae(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Ce{constructor(e){Ne(this,"name","cip34"),Ne(this,"client"),Ne(this,"httpProviders"),Ne(this,"events"),Ne(this,"namespace"),Ne(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(b,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const i=this.getCardanoRPCUrl(t),s=V(t);e[s]=this.createHttpProvider(s,i)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||this.getCardanoRPCUrl(e);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(i,Z("disableProviderPing")))}}var Se=Object.defineProperty,Pe=(e,t,i)=>((e,t,i)=>t in e?Se(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Oe{constructor(e){Pe(this,"name","elrond"),Pe(this,"client"),Pe(this,"httpProviders"),Pe(this,"events"),Pe(this,"namespace"),Pe(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(b,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=V(t);e[s]=this.createHttpProvider(s,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||W(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(i,Z("disableProviderPing")))}}var Te=Object.defineProperty,xe=(e,t,i)=>((e,t,i)=>t in e?Te(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class ke{constructor(e){xe(this,"name","multiversx"),xe(this,"client"),xe(this,"httpProviders"),xe(this,"events"),xe(this,"namespace"),xe(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(b,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=V(t);e[s]=this.createHttpProvider(s,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||W(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(i,Z("disableProviderPing")))}}var Re=Object.defineProperty,Me=(e,t,i)=>((e,t,i)=>t in e?Re(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Ue{constructor(e){Me(this,"name","near"),Me(this,"client"),Me(this,"httpProviders"),Me(this,"events"),Me(this,"namespace"),Me(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||W(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(b,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||W(e,this.namespace);return typeof i>"u"?void 0:new a.F(new o.A(i,Z("disableProviderPing")))}}var De=Object.defineProperty,je=(e,t,i)=>((e,t,i)=>t in e?De(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Le{constructor(e){je(this,"name","tezos"),je(this,"client"),je(this,"httpProviders"),je(this,"events"),je(this,"namespace"),je(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||W(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(b,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{e[t]=this.createHttpProvider(t)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||W(e,this.namespace);return typeof i>"u"?void 0:new a.F(new o.A(i))}}var qe=Object.defineProperty,$e=(e,t,i)=>((e,t,i)=>t in e?qe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Be{constructor(e){$e(this,"name",g),$e(this,"client"),$e(this,"httpProviders"),$e(this,"events"),$e(this,"namespace"),$e(this,"chainId"),this.namespace=e.namespace,this.events=Z("events"),this.client=Z("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(b,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){var e,t;const i={};return null==(t=null==(e=this.namespace)?void 0:e.accounts)||t.forEach(e=>{const t=(0,r._Yb)(e);i[`${t.namespace}:${t.reference}`]=this.createHttpProvider(e)}),i}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||W(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(i,Z("disableProviderPing")))}}var ze=Object.defineProperty,He=Object.defineProperties,We=Object.getOwnPropertyDescriptors,Ve=Object.getOwnPropertySymbols,Fe=Object.prototype.hasOwnProperty,Ke=Object.prototype.propertyIsEnumerable,Ge=(e,t,i)=>t in e?ze(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Je=(e,t)=>{for(var i in t||(t={}))Fe.call(t,i)&&Ge(e,i,t[i]);if(Ve)for(var i of Ve(t))Ke.call(t,i)&&Ge(e,i,t[i]);return e},Ye=(e,t)=>He(e,We(t)),Xe=(e,t,i)=>Ge(e,"symbol"!=typeof t?t+"":t,i);class Qe{constructor(e){Xe(this,"client"),Xe(this,"namespaces"),Xe(this,"optionalNamespaces"),Xe(this,"sessionProperties"),Xe(this,"scopedProperties"),Xe(this,"events",new(d())),Xe(this,"rpcProviders",{}),Xe(this,"session"),Xe(this,"providerOpts"),Xe(this,"logger"),Xe(this,"uri"),Xe(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,n.h6)((0,n.iP)({level:e?.logger||u})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const t=new Qe(e);return await t.initialize(),t}async request(e,t,i){const[s,r]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:Je({},e),chainId:`${s}:${r}`,topic:this.session.topic,expiry:i})}sendAsync(e,t,i,s){const r=(new Date).getTime();this.request(e,i,s).then(e=>t(null,(0,c.formatJsonRpcResult)(r,e))).catch(e=>t(e,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:null==(e=this.session)?void 0:e.topic,reason:(0,r.Hjj)("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:i,response:s}=await this.client.authenticate(e,t);i&&(this.uri=i,this.events.emit("display_uri",i));const r=await s();if(this.session=r.session,this.session){const e=Y(this.session.namespaces);this.namespaces=K(this.namespaces,e),await this.persist("namespaces",this.namespaces),this.onConnect()}return r}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){const{uri:t,approval:i}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});t&&(this.uri=t,this.events.emit("display_uri",t));const s=await i();this.session=s;const r=Y(s.namespaces);return this.namespaces=K(this.namespaces,r),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[i,s]=this.validateChain(e),r=this.getProvider(i);r.name===g?r.setDefaultChain(`${i}:${s}`,t):r.setDefaultChain(s,t)}catch(e){if(!/Please call connect/.test(e.message))throw e}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if((0,r.OP1)(t)){for(const i of t)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var e,t;if(this.client=this.providerOpts.client||await s.Ay.init({core:this.providerOpts.core,logger:this.providerOpts.logger||u,relayUrl:this.providerOpts.relayUrl||"wss://relay.walletconnect.org",projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(i){throw this.logger.error("Failed to get session",i),new Error(`The provided session: ${null==(t=null==(e=this.providerOpts)?void 0:e.session)?void 0:t.topic} doesn't exist in the Sign client`)}else{const e=this.client.session.getAll();this.session=e[0]}this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(e=>(0,r.kob)(e)))];ee("client",this.client),ee("events",this.events),ee("disableProviderPing",this.disableProviderPing),e.forEach(e=>{if(!this.session)return;const t=function(e,t){const i=Object.keys(t.namespaces).filter(t=>t.includes(e));if(!i.length)return[];const s=[];return i.forEach(e=>{const i=t.namespaces[e].accounts;s.push(...i)}),s}(e,this.session),i=F(t),s=K(this.namespaces,this.optionalNamespaces),r=Ye(Je({},s[e]),{accounts:t,chains:i});switch(e){case"eip155":this.rpcProviders[e]=new fe({namespace:r});break;case"algorand":this.rpcProviders[e]=new _e({namespace:r});break;case"solana":this.rpcProviders[e]=new be({namespace:r});break;case"cosmos":this.rpcProviders[e]=new ve({namespace:r});break;case"polkadot":this.rpcProviders[e]=new se({namespace:r});break;case"cip34":this.rpcProviders[e]=new Ce({namespace:r});break;case"elrond":this.rpcProviders[e]=new Oe({namespace:r});break;case"multiversx":this.rpcProviders[e]=new ke({namespace:r});break;case"near":this.rpcProviders[e]=new Ue({namespace:r});break;case"tezos":this.rpcProviders[e]=new Le({namespace:r});break;default:this.rpcProviders[g]?this.rpcProviders[g].updateNamespace(r):this.rpcProviders[g]=new Be({namespace:r})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var t;const{topic:i}=e;i===(null==(t=this.session)?void 0:t.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var t;const{params:i,topic:s}=e;if(s!==(null==(t=this.session)?void 0:t.topic))return;const{event:n}=i;if("accountsChanged"===n.name){const e=n.data;e&&(0,r.OP1)(e)&&this.events.emit("accountsChanged",e.map(J))}else if("chainChanged"===n.name){const e=i.chainId,t=i.event.data,s=(0,r.kob)(e),n=X(e)!==X(t)?`${s}:${X(t)}`:e;this.onChainChanged(n)}else this.events.emit(n.name,n.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var i,s;if(e!==(null==(i=this.session)?void 0:i.topic))return;const{namespaces:r}=t,n=null==(s=this.client)?void 0:s.session.get(e);this.session=Ye(Je({},n),{namespaces:r}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{var t;e.topic===(null==(t=this.session)?void 0:t.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Ye(Je({},(0,r.Hjj)("USER_DISCONNECTED")),{data:e.topic})))}),this.on(b,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[g]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace(null==(t=this.session)?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:i,sessionProperties:s,scopedProperties:r}=e;t&&Object.keys(t).length&&(this.namespaces=t),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=s,this.scopedProperties=r}validateChain(e){const[t,i]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,i];if(t&&!Object.keys(this.namespaces||{}).map(e=>(0,r.kob)(e)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&i)return[t,i];const s=(0,r.kob)(Object.keys(this.namespaces)[0]);return[s,this.rpcProviders[s].getDefaultChain()]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged(e,t=!1){if(!this.namespaces)return;const[i,s]=this.validateChain(e);s&&(t||this.getProvider(i).setDefaultChain(s),this.namespaces[i]?this.namespaces[i].defaultChain=s:this.namespaces[`${i}:${s}`]?this.namespaces[`${i}:${s}`].defaultChain=s:this.namespaces[`${i}:${s}`]={defaultChain:s},this.events.emit("chainChanged",s),await this.persist("namespaces",this.namespaces))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,await this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,t){var i;const s=(null==(i=this.session)?void 0:i.topic)||"";await this.client.core.storage.setItem(`${p}/${e}${s}`,t)}async getFromStore(e){var t;const i=(null==(t=this.session)?void 0:t.topic)||"";return await this.client.core.storage.getItem(`${p}/${e}${i}`)}async deleteFromStore(e){var t;const i=(null==(t=this.session)?void 0:t.topic)||"";await this.client.core.storage.removeItem(`${p}/${e}${i}`)}async cleanupStorage(){var e;try{if((null==(e=this.client)?void 0:e.session.length)>0)return;const t=await this.client.core.storage.getKeys();for(const e of t)e.startsWith(p)&&await this.client.core.storage.removeItem(e)}catch(e){this.logger.warn("Failed to cleanup storage",e)}}}},24096:(e,t,i)=>{i.d(t,{Aj:()=>s.A}),i(24313),i(74091);var s=i(38753)},24210:(e,t,i)=>{i.d(t,{JX:()=>h,RF:()=>c,W5:()=>u,ck:()=>f,ds:()=>d,fD:()=>p});var s=i(35842),r=i(11807);let n,o,a;function c(e,t){n=document.createElement("style"),o=document.createElement("style"),a=document.createElement("style"),n.textContent=l(e).core.cssText,o.textContent=l(e).dark.cssText,a.textContent=l(e).light.cssText,document.head.appendChild(n),document.head.appendChild(o),document.head.appendChild(a),h(t)}function h(e){o&&a&&("light"===e?(o.removeAttribute("media"),a.media="enabled"):(a.removeAttribute("media"),o.media="enabled"))}function d(e){n&&o&&a&&(n.textContent=l(e).core.cssText,o.textContent=l(e).dark.cssText,a.textContent=l(e).light.cssText)}function l(e){return{core:s.AH`
|
|
3
3
|
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');
|
|
4
4
|
@keyframes w3m-shake {
|
|
5
5
|
0% {
|
|
@@ -51,11 +51,11 @@ export const __webpack_esm_id__=7201;export const __webpack_esm_ids__=[7201];exp
|
|
|
51
51
|
}
|
|
52
52
|
:root {
|
|
53
53
|
--w3m-modal-width: 360px;
|
|
54
|
-
--w3m-color-mix-strength: ${(0,
|
|
55
|
-
--w3m-font-family: ${(0,
|
|
56
|
-
--w3m-font-size-master: ${(0,
|
|
57
|
-
--w3m-border-radius-master: ${(0,
|
|
58
|
-
--w3m-z-index: ${(0,
|
|
54
|
+
--w3m-color-mix-strength: ${(0,s.iz)(e?.["--w3m-color-mix-strength"]?`${e["--w3m-color-mix-strength"]}%`:"0%")};
|
|
55
|
+
--w3m-font-family: ${(0,s.iz)(e?.["--w3m-font-family"]||"Inter, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif;")};
|
|
56
|
+
--w3m-font-size-master: ${(0,s.iz)(e?.["--w3m-font-size-master"]||"10px")};
|
|
57
|
+
--w3m-border-radius-master: ${(0,s.iz)(e?.["--w3m-border-radius-master"]||"4px")};
|
|
58
|
+
--w3m-z-index: ${(0,s.iz)(e?.["--w3m-z-index"]||999)};
|
|
59
59
|
|
|
60
60
|
--wui-font-family: var(--w3m-font-family);
|
|
61
61
|
|
|
@@ -481,13 +481,13 @@ export const __webpack_esm_id__=7201;export const __webpack_esm_ids__=[7201];exp
|
|
|
481
481
|
);
|
|
482
482
|
}
|
|
483
483
|
}
|
|
484
|
-
`,light:
|
|
484
|
+
`,light:s.AH`
|
|
485
485
|
:root {
|
|
486
|
-
--w3m-color-mix: ${(0,
|
|
487
|
-
--w3m-accent: ${(0,
|
|
486
|
+
--w3m-color-mix: ${(0,s.iz)(e?.["--w3m-color-mix"]||"#fff")};
|
|
487
|
+
--w3m-accent: ${(0,s.iz)((0,r.o)(e,"dark")["--w3m-accent"])};
|
|
488
488
|
--w3m-default: #fff;
|
|
489
489
|
|
|
490
|
-
--wui-color-modal-bg-base: ${(0,
|
|
490
|
+
--wui-color-modal-bg-base: ${(0,s.iz)((0,r.o)(e,"dark")["--w3m-background"])};
|
|
491
491
|
--wui-color-accent-base-100: var(--w3m-accent);
|
|
492
492
|
|
|
493
493
|
--wui-color-blueberry-100: hsla(230, 100%, 67%, 1);
|
|
@@ -587,13 +587,13 @@ export const __webpack_esm_id__=7201;export const __webpack_esm_ids__=[7201];exp
|
|
|
587
587
|
|
|
588
588
|
--w3m-card-embedded-shadow-color: rgb(17 17 18 / 25%);
|
|
589
589
|
}
|
|
590
|
-
`,dark:
|
|
590
|
+
`,dark:s.AH`
|
|
591
591
|
:root {
|
|
592
|
-
--w3m-color-mix: ${(0,
|
|
593
|
-
--w3m-accent: ${(0,
|
|
592
|
+
--w3m-color-mix: ${(0,s.iz)(e?.["--w3m-color-mix"]||"#000")};
|
|
593
|
+
--w3m-accent: ${(0,s.iz)((0,r.o)(e,"light")["--w3m-accent"])};
|
|
594
594
|
--w3m-default: #000;
|
|
595
595
|
|
|
596
|
-
--wui-color-modal-bg-base: ${(0,
|
|
596
|
+
--wui-color-modal-bg-base: ${(0,s.iz)((0,r.o)(e,"light")["--w3m-background"])};
|
|
597
597
|
--wui-color-accent-base-100: var(--w3m-accent);
|
|
598
598
|
|
|
599
599
|
--wui-color-blueberry-100: hsla(231, 100%, 70%, 1);
|
|
@@ -692,7 +692,7 @@ export const __webpack_esm_id__=7201;export const __webpack_esm_ids__=[7201];exp
|
|
|
692
692
|
|
|
693
693
|
--w3m-card-embedded-shadow-color: rgb(224 225 233 / 25%);
|
|
694
694
|
}
|
|
695
|
-
`}}const
|
|
695
|
+
`}}const u=s.AH`
|
|
696
696
|
*,
|
|
697
697
|
*::after,
|
|
698
698
|
*::before,
|
|
@@ -708,7 +708,7 @@ export const __webpack_esm_id__=7201;export const __webpack_esm_ids__=[7201];exp
|
|
|
708
708
|
font-family: var(--wui-font-family);
|
|
709
709
|
backface-visibility: hidden;
|
|
710
710
|
}
|
|
711
|
-
`,
|
|
711
|
+
`,p=s.AH`
|
|
712
712
|
button,
|
|
713
713
|
a {
|
|
714
714
|
cursor: pointer;
|
|
@@ -763,7 +763,7 @@ export const __webpack_esm_id__=7201;export const __webpack_esm_ids__=[7201];exp
|
|
|
763
763
|
outline: none;
|
|
764
764
|
appearance: none;
|
|
765
765
|
}
|
|
766
|
-
`,
|
|
766
|
+
`,f=s.AH`
|
|
767
767
|
.wui-color-inherit {
|
|
768
768
|
color: var(--wui-color-inherit);
|
|
769
769
|
}
|
|
@@ -875,4 +875,4 @@ export const __webpack_esm_id__=7201;export const __webpack_esm_ids__=[7201];exp
|
|
|
875
875
|
.wui-color-fg-350 {
|
|
876
876
|
background-color: var(--wui-color-fg-350);
|
|
877
877
|
}
|
|
878
|
-
`},24313:(e,t,s)=>{s.d(t,{g:()=>u});var i=s(95191),r=s(99013),n=s(89058),o=s(50731),a=s(40868),c=s(16158),h=s(5813),l=s(11553),p=s(28127),d=s(38753);const u={getConnectorsByType(e,t,s){const{customWallets:i}=c.H.state,r=l.i.getRecentWallets(),n=d.A.filterOutDuplicateWallets(t),o=d.A.filterOutDuplicateWallets(s),a=e.filter(e=>"MULTI_CHAIN"===e.type),h=e.filter(e=>"ANNOUNCED"===e.type),p=e.filter(e=>"INJECTED"===e.type);return{custom:i,recent:r,external:e.filter(e=>"EXTERNAL"===e.type),multiChain:a,announced:h,injected:p,recommended:n,featured:o}},showConnector(e){const t=e.info?.rdns,s=Boolean(t)&&a.N.state.excludedWallets.some(e=>e.rdns===t),i=Boolean(e.name)&&a.N.state.excludedWallets.some(t=>p.y.isLowerCaseMatch(t.name,e.name));if("INJECTED"===e.type){if(!h.w.isMobile()&&"Browser Wallet"===e.name)return!1;if(!t&&!n.x.checkInstalled())return!1;if(s||i)return!1}return"ANNOUNCED"!==e.type||!s&&!i},getIsConnectedWithWC:()=>Array.from(r.W.state.chains.values()).some(e=>o.a.getConnectorId(e.namespace)===i.o.CONNECTOR_ID.WALLET_CONNECT),getConnectorTypeOrder({recommended:e,featured:t,custom:s,recent:i,announced:r,injected:n,multiChain:o,external:a,overriddenConnectors:h=c.H.state.features?.connectorTypeOrder??[]}){const l=u.getIsConnectedWithWC(),p=[{type:"walletConnect",isEnabled:c.H.state.enableWalletConnect&&!l},{type:"recent",isEnabled:i.length>0},{type:"injected",isEnabled:[...n,...r,...o].length>0},{type:"featured",isEnabled:t.length>0},{type:"custom",isEnabled:s&&s.length>0},{type:"external",isEnabled:a.length>0},{type:"recommended",isEnabled:e.length>0}].filter(e=>e.isEnabled),d=new Set(p.map(e=>e.type)),g=h.filter(e=>d.has(e)).map(e=>({type:e,isEnabled:!0})),f=p.filter(({type:e})=>!g.some(({type:t})=>t===e));return Array.from(new Set([...g,...f].map(({type:e})=>e)))}}},24529:(e,t,s)=>{s.d(t,{E:()=>i});const i={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603}},24537:(e,t,s)=>{s.d(t,{U:()=>f}),s(99057);var i=s(95191),r=s(9663),n=s(16279),o=s(99013),a=s(89058),c=s(50731),h=s(14479),l=s(67018),p=s(16158),d=s(42831),u=s(41430),g=s(5813);const f={getSIWX:()=>p.H.state.siwx,async initializeIfEnabled(){const e=p.H.state.siwx,t=o.W.getActiveCaipAddress();if(!e||!t)return;const[s,i,r]=t.split(":");if(o.W.checkIfSupportedNetwork(s))try{if((await e.getSessions(`${s}:${i}`,r)).length)return;await l.W.open({view:"SIWXSignMessage"})}catch(e){console.error("SIWXUtil:initializeIfEnabled",e),h.E.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties()}),await(a.x._getClient()?.disconnect().catch(console.error)),d.I.reset("Connect"),u.P.showError("A problem occurred while trying initialize authentication")}},async requestSignMessage(){const e=p.H.state.siwx,t=g.w.getPlainAddress(o.W.getActiveCaipAddress()),s=o.W.getActiveCaipNetwork(),r=a.x._getClient();if(!e)throw new Error("SIWX is not enabled");if(!t)throw new Error("No ActiveCaipAddress found");if(!s)throw new Error("No ActiveCaipNetwork or client found");if(!r)throw new Error("No ConnectionController client found");try{const n=await e.createMessage({chainId:s.caipNetworkId,accountAddress:t}),o=n.toString();c.a.getConnectorId(s.chainNamespace)===i.o.CONNECTOR_ID.AUTH&&d.I.pushTransactionStack({view:null,goBack:!1,replace:!0});const a=await r.signMessage(o);await e.addSession({data:n,message:o,signature:a}),l.W.close(),h.E.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:this.getSIWXEventProperties()})}catch(e){const t=this.getSIWXEventProperties();l.W.state.open&&"ApproveTransaction"!==d.I.state.view||await l.W.open({view:"SIWXSignMessage"}),t.isSmartAccount?u.P.showError("This application might not support Smart Accounts"):u.P.showError("Signature declined"),h.E.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:t}),console.error("SWIXUtil:requestSignMessage",e)}},async cancelSignMessage(){try{const e=this.getSIWX(),t=e?.getRequired?.();t?await a.x.disconnect():l.W.close(),d.I.reset("Connect"),h.E.sendEvent({event:"CLICK_CANCEL_SIWX",type:"track",properties:this.getSIWXEventProperties()})}catch(e){console.error("SIWXUtil:cancelSignMessage",e)}},async getSessions(){const e=p.H.state.siwx,t=g.w.getPlainAddress(o.W.getActiveCaipAddress()),s=o.W.getActiveCaipNetwork();return e&&t&&s?e.getSessions(s.caipNetworkId,t):[]},async isSIWXCloseDisabled(){const e=this.getSIWX();if(e){const t="ApproveTransaction"===d.I.state.view,s="SIWXSignMessage"===d.I.state.view;if(t||s)return e.getRequired?.()&&0===(await this.getSessions()).length}return!1},async universalProviderAuthenticate({universalProvider:e,chains:t,methods:s}){const i=f.getSIWX(),r=new Set(t.map(e=>e.split(":")[0]));if(!i||1!==r.size||!r.has("eip155"))return!1;const a=await i.createMessage({chainId:o.W.getActiveCaipNetwork()?.caipNetworkId||"",accountAddress:""}),c=await e.authenticate({nonce:a.nonce,domain:a.domain,uri:a.uri,exp:a.expirationTime,iat:a.issuedAt,nbf:a.notBefore,requestId:a.requestId,version:a.version,resources:a.resources,statement:a.statement,chainId:a.chainId,methods:s,chains:[a.chainId,...t.filter(e=>e!==a.chainId)]});if(u.P.showLoading("Authenticating...",{autoClose:!1}),n.U.setConnectedWalletInfo({...c.session.peer.metadata,name:c.session.peer.metadata.name,icon:c.session.peer.metadata.icons?.[0],type:"WALLET_CONNECT"},Array.from(r)[0]),c?.auths?.length){const t=c.auths.map(t=>{const s=e.client.formatAuthMessage({request:t.p,iss:t.p.iss});return{data:{...t.p,accountAddress:t.p.iss.split(":").slice(-1).join(""),chainId:t.p.iss.split(":").slice(2,4).join(":"),uri:t.p.aud,version:t.p.version||a.version,expirationTime:t.p.exp,issuedAt:t.p.iat,notBefore:t.p.nbf},message:s,signature:t.s.s,cacao:t}});try{await i.setSessions(t),h.E.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:f.getSIWXEventProperties()})}catch(t){throw console.error("SIWX:universalProviderAuth - failed to set sessions",t),h.E.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:f.getSIWXEventProperties()}),await e.disconnect().catch(console.error),t}finally{u.P.hide()}}return!0},getSIWXEventProperties:()=>({network:o.W.state.activeCaipNetwork?.caipNetworkId||"",isSmartAccount:n.U.state.preferredAccountType===r.Vl.ACCOUNT_TYPES.SMART_ACCOUNT}),async clearSessions(){const e=this.getSIWX();e&&await e.setSessions([])}}},25422:(e,t,s)=>{s.d(t,{z:()=>n});var i=s(89168);const r=(0,i.BX)({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),n={state:r,subscribe:e=>(0,i.B1)(r,()=>e(r)),set(e){Object.assign(r,{...r,...e})}}},26097:(e,t,s)=>{s.d(t,{W:()=>n});var i=s(95191),r=s(99013);const n={handleSolanaDeeplinkRedirect(e){if(r.W.state.activeChain===i.o.CHAIN.SOLANA){const t=window.location.href,s=encodeURIComponent(t);if("Phantom"===e&&!("phantom"in window)){const e=t.startsWith("https")?"https":"http",i=t.split("/")[2],r=encodeURIComponent(`${e}://${i}`);window.location.href=`https://phantom.app/ul/browse/${s}?ref=${r}`}"Coinbase Wallet"!==e||"coinbaseSolana"in window||(window.location.href=`https://go.cb-w.com/dapp?cb_url=${s}`)}}}},26545:(e,t,s)=>{s.d(t,{W:()=>a});var i=s(89168),r=s(11807),n=s(50731);const o=(0,i.BX)({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),a={state:o,subscribe:e=>(0,i.B1)(o,()=>e(o)),setThemeMode(e){o.themeMode=e;try{const t=n.a.getAuthConnector();if(t){const s=a.getSnapshot().themeVariables;t.provider.syncTheme({themeMode:e,themeVariables:s,w3mThemeVariables:(0,r.o)(s,e)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(e){o.themeVariables={...o.themeVariables,...e};try{const e=n.a.getAuthConnector();if(e){const t=a.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:t,w3mThemeVariables:(0,r.o)(o.themeVariables,o.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot:()=>(0,i.P9)(o)}},27006:(e,t,s)=>{s.d(t,{T:()=>f});var i=s(89168),r=s(84253),n=s(5813),o=s(19760),a=s(11553),c=s(16279),h=s(99013),l=s(16158),p=s(41430);const d={purchaseCurrencies:[{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"Ether",symbol:"ETH",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]}],paymentCurrencies:[{id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},{id:"EUR",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]}]},u=n.w.getBlockchainApiUrl(),g=(0,i.BX)({clientId:null,api:new o.Z({baseUrl:u,clientId:null}),supportedChains:{http:[],ws:[]}}),f={state:g,async get(e){const{st:t,sv:s}=f.getSdkProperties(),i=l.H.state.projectId,r={...e.params||{},st:t,sv:s,projectId:i};return g.api.get({...e,params:r})},getSdkProperties(){const{sdkType:e,sdkVersion:t}=l.H.state;return{st:e||"unknown",sv:t||"unknown"}},async isNetworkSupported(e){if(!e)return!1;try{g.supportedChains.http.length||await f.getSupportedNetworks()}catch(e){return!1}return g.supportedChains.http.includes(e)},async getSupportedNetworks(){const e=await f.get({path:"v1/supported-chains"});return g.supportedChains=e,e},async fetchIdentity({address:e,caipNetworkId:t}){if(!await f.isNetworkSupported(t))return{avatar:"",name:""};const s=a.i.getIdentityFromCacheForAddress(e);if(s)return s;const i=await f.get({path:`/v1/identity/${e}`,params:{sender:h.W.state.activeCaipAddress?n.w.getPlainAddress(h.W.state.activeCaipAddress):void 0}});return a.i.updateIdentityCache({address:e,identity:i,timestamp:Date.now()}),i},fetchTransactions:async({account:e,cursor:t,onramp:s,signal:i,cache:r,chainId:n})=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.get({path:`/v1/account/${e}/history`,params:{cursor:t,onramp:s,chainId:n},signal:i,cache:r}):{data:[],next:void 0},fetchSwapQuote:async({amount:e,userAddress:t,from:s,to:i,gasPrice:r})=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.get({path:"/v1/convert/quotes",headers:{"Content-Type":"application/json"},params:{amount:e,userAddress:t,from:s,to:i,gasPrice:r}}):{quotes:[]},fetchSwapTokens:async({chainId:e})=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.get({path:"/v1/convert/tokens",params:{chainId:e}}):{tokens:[]},fetchTokenPrice:async({addresses:e})=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?g.api.post({path:"/v1/fungible/price",body:{currency:"usd",addresses:e,projectId:l.H.state.projectId},headers:{"Content-Type":"application/json"}}):{fungibles:[]},fetchSwapAllowance:async({tokenAddress:e,userAddress:t})=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.get({path:"/v1/convert/allowance",params:{tokenAddress:e,userAddress:t},headers:{"Content-Type":"application/json"}}):{allowance:"0"},async fetchGasPrice({chainId:e}){const{st:t,sv:s}=f.getSdkProperties();if(!await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Gas Price");return f.get({path:"/v1/convert/gas-price",headers:{"Content-Type":"application/json"},params:{chainId:e,st:t,sv:s}})},async generateSwapCalldata({amount:e,from:t,to:s,userAddress:i,disableEstimate:n}){if(!await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Swaps");return g.api.post({path:"/v1/convert/build-transaction",headers:{"Content-Type":"application/json"},body:{amount:e,eip155:{slippage:r.oU.CONVERT_SLIPPAGE_TOLERANCE},projectId:l.H.state.projectId,from:t,to:s,userAddress:i,disableEstimate:n}})},async generateApproveCalldata({from:e,to:t,userAddress:s}){const{st:i,sv:r}=f.getSdkProperties();if(!await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Swaps");return f.get({path:"/v1/convert/build-approve",headers:{"Content-Type":"application/json"},params:{userAddress:s,from:e,to:t,st:i,sv:r}})},async getBalance(e,t,s){const{st:i,sv:r}=f.getSdkProperties();if(!await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId))return p.P.showError("Token Balance Unavailable"),{balances:[]};const n=`${t}:${e}`,o=a.i.getBalanceCacheForCaipAddress(n);if(o)return o;const c=await f.get({path:`/v1/account/${e}/balance`,params:{currency:"usd",chainId:t,forceUpdate:s,st:i,sv:r}});return a.i.updateBalanceCache({caipAddress:n,balance:c,timestamp:Date.now()}),c},lookupEnsName:async e=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.get({path:`/v1/profile/account/${e}`,params:{apiVersion:"2"}}):{addresses:{},attributes:[]},reverseLookupEnsName:async({address:e})=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.get({path:`/v1/profile/reverse/${e}`,params:{sender:c.U.state.address,apiVersion:"2"}}):[],getEnsNameSuggestions:async e=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.get({path:`/v1/profile/suggestions/${e}`,params:{zone:"reown.id"}}):{suggestions:[]},registerEnsName:async({coinType:e,address:t,message:s,signature:i})=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?g.api.post({path:"/v1/profile/account",body:{coin_type:e,address:t,message:s,signature:i},headers:{"Content-Type":"application/json"}}):{success:!1},generateOnRampURL:async({destinationWallets:e,partnerUserId:t,defaultNetwork:s,purchaseAmount:i,paymentAmount:r})=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?(await g.api.post({path:"/v1/generators/onrampurl",params:{projectId:l.H.state.projectId},body:{destinationWallets:e,defaultNetwork:s,partnerUserId:t,defaultExperience:"buy",presetCryptoAmount:i,presetFiatAmount:r}})).url:"",async getOnrampOptions(){if(!await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await f.get({path:"/v1/onramp/options"})}catch(e){return d}},async getOnrampQuote({purchaseCurrency:e,paymentCurrency:t,amount:s,network:i}){try{return await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?await g.api.post({path:"/v1/onramp/quote",params:{projectId:l.H.state.projectId},body:{purchaseCurrency:e,paymentCurrency:t,amount:s,network:i}}):null}catch(e){return{coinbaseFee:{amount:s,currency:t.id},networkFee:{amount:s,currency:t.id},paymentSubtotal:{amount:s,currency:t.id},paymentTotal:{amount:s,currency:t.id},purchaseAmount:{amount:s,currency:t.id},quoteId:"mocked-quote-id"}}},getSmartSessions:async e=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.get({path:`/v1/sessions/${e}`}):[],revokeSmartSession:async(e,t,s)=>await f.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?g.api.post({path:`/v1/sessions/${e}/revoke`,params:{projectId:l.H.state.projectId},body:{pci:t,signature:s}}):{success:!1},setClientId(e){g.clientId=e,g.api=new o.Z({baseUrl:u,clientId:e})}}},27305:(e,t,s)=>{function i(e){return function(t){return"function"==typeof t?function(e,t){return customElements.get(e)||customElements.define(e,t),t}(e,t):function(e,t){const{kind:s,elements:i}=t;return{kind:s,elements:i,finisher(t){customElements.get(e)||customElements.define(e,t)}}}(e,t)}}s.d(t,{E:()=>i})},27938:(e,t,s)=>{s.d(t,{h:()=>a});var i=s(89168),r=s(39150),n=s(16158);const o=(0,i.BX)({message:"",variant:"info",open:!1}),a={state:o,subscribeKey:(e,t)=>(0,r.u$)(o,e,t),open(e,t){const{debug:s}=n.H.state,{shortMessage:i,longMessage:r}=e;s&&(o.message=i,o.variant=t,o.open=!0),r&&console.error("function"==typeof r?r():r)},close(){o.open=!1,o.message="",o.variant="info"}}},28127:(e,t,s)=>{s.d(t,{y:()=>r});var i=s(98207);const r={getCaipTokens(e){if(!e)return;const t={};return Object.entries(e).forEach(([e,s])=>{t[`${i.o.EIP155}:${e}`]=s}),t},isLowerCaseMatch:(e,t)=>e?.toLowerCase()===t?.toLowerCase()}},29864:(e,t,s)=>{s.d(t,{f:()=>g});var i=s(89168),r=s(39150),n=s(78760),o=s(11553),a=s(16279),c=s(27006),h=s(99013),l=s(89058),p=s(50731),d=s(42831);const u=(0,i.BX)({suggestions:[],loading:!1}),g={state:u,subscribe:e=>(0,i.B1)(u,()=>e(u)),subscribeKey:(e,t)=>(0,r.u$)(u,e,t),async resolveName(e){try{return await c.T.lookupEnsName(e)}catch(e){const t=e;throw new Error(t?.reasons?.[0]?.description||"Error resolving name")}},async isNameRegistered(e){try{return await c.T.lookupEnsName(e),!0}catch{return!1}},async getSuggestions(e){try{u.loading=!0,u.suggestions=[];const t=await c.T.getEnsNameSuggestions(e);return u.suggestions=t.suggestions.map(e=>({...e,name:e.name}))||[],u.suggestions}catch(e){const t=this.parseEnsApiError(e,"Error fetching name suggestions");throw new Error(t)}finally{u.loading=!1}},async getNamesForAddress(e){try{if(!h.W.state.activeCaipNetwork)return[];const t=o.i.getEnsFromCacheForAddress(e);if(t)return t;const s=await c.T.reverseLookupEnsName({address:e});return o.i.updateEnsCache({address:e,ens:s,timestamp:Date.now()}),s}catch(e){const t=this.parseEnsApiError(e,"Error fetching names for address");throw new Error(t)}},async registerName(e){const t=h.W.state.activeCaipNetwork;if(!t)throw new Error("Network not found");const s=a.U.state.address,i=p.a.getAuthConnector();if(!s||!i)throw new Error("Address or auth connector not found");u.loading=!0;try{const i=JSON.stringify({name:e,attributes:{},timestamp:Math.floor(Date.now()/1e3)});d.I.pushTransactionStack({view:"RegisterAccountNameSuccess",goBack:!1,replace:!0,onCancel(){u.loading=!1}});const r=await l.x.signMessage(i),o=t.id;if(!o)throw new Error("Network not found");const h=n.p.convertEVMChainIdToCoinType(Number(o));await c.T.registerEnsName({coinType:h,address:s,signature:r,message:i}),a.U.setProfileName(e,t.chainNamespace),d.I.replace("RegisterAccountNameSuccess")}catch(t){const s=this.parseEnsApiError(t,`Error registering name ${e}`);throw d.I.replace("RegisterAccountName"),new Error(s)}finally{u.loading=!1}},validateName:e=>/^[a-zA-Z0-9-]{4,}$/u.test(e),parseEnsApiError(e,t){const s=e;return s?.reasons?.[0]?.description||t}}},30544:(e,t,s)=>{s.d(t,{Rn0:()=>i.Rn0,gTy:()=>i.gTy,tWt:()=>i.tWt});var i=s(55164)},31575:(e,t,s)=>{s.d(t,{Ay:()=>K});var i=s(11629),r=s(70255),n=s(3665),o=s(91315),a=s(76754),c=s(50046),h=s.n(c),l=s(14350);const p="client",d=`wc@2:${p}:`,u=p,g="WALLETCONNECT_DEEPLINK_CHOICE",f="Proposal expired",m=o.SEVEN_DAYS,w={wc_sessionPropose:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1104},res:{ttl:o.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1106},res:{ttl:o.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1112},res:{ttl:o.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1114},res:{ttl:o.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:o.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:o.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1119}}},y={min:o.FIVE_MINUTES,max:o.SEVEN_DAYS},b="IDLE",v="ACTIVE",E={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},I=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],_="wc@1.5:auth:",N=`${_}:PUB_KEY`;var A=Object.defineProperty,C=Object.defineProperties,P=Object.getOwnPropertyDescriptors,S=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,k=(e,t,s)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,x=(e,t)=>{for(var s in t||(t={}))O.call(t,s)&&k(e,s,t[s]);if(S)for(var s of S(t))T.call(t,s)&&k(e,s,t[s]);return e},R=(e,t)=>C(e,P(t)),U=(e,t,s)=>k(e,"symbol"!=typeof t?t+"":t,s);class D extends n.yJ{constructor(e){super(e),U(this,"name","engine"),U(this,"events",new(h())),U(this,"initialized",!1),U(this,"requestQueue",{state:b,queue:[]}),U(this,"sessionRequestQueue",{state:b,queue:[]}),U(this,"requestQueueDelay",o.ONE_SECOND),U(this,"expectedPairingMethodMap",new Map),U(this,"recentlyDeletedMap",new Map),U(this,"recentlyDeletedLimit",200),U(this,"relayMessageCache",[]),U(this,"pendingSessions",new Map),U(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(w)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,o.toMiliseconds)(this.requestQueueDelay)))}),U(this,"connect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const t=R(x({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);const{pairingTopic:s,requiredNamespaces:r,optionalNamespaces:n,sessionProperties:c,relays:h}=t;let p,d=s,u=!1;try{if(d){const e=this.client.core.pairing.pairings.get(d);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),u=e.active}}catch(e){throw this.client.logger.error(`connect() -> pairing.get(${d}) failed`),e}if(!d||!u){const{topic:e,uri:t}=await this.client.core.pairing.create();d=e,p=t}if(!d){const{message:e}=(0,a.GuA)("NO_MATCHING_KEY",`connect() pairing topic: ${d}`);throw new Error(e)}const g=await this.client.core.crypto.generateKeyPair(),m=w.wc_sessionPropose.req.ttl||o.FIVE_MINUTES,y=(0,a.Xw0)(m),b=R(x({requiredNamespaces:r,optionalNamespaces:n,relays:h??[{protocol:i.sD}],proposer:{publicKey:g,metadata:this.client.metadata},expiryTimestamp:y,pairingTopic:d},c&&{sessionProperties:c}),{id:(0,l.payloadId)()}),v=(0,a.hEn)("session_connect",b.id),{reject:E,resolve:I,done:_}=(0,a.Wx8)(m,f),N=({id:e})=>{e===b.id&&(this.client.events.off("proposal_expire",N),this.pendingSessions.delete(b.id),this.events.emit(v,{error:{message:f,code:0}}))};return this.client.events.on("proposal_expire",N),this.events.once(v,({error:e,session:t})=>{this.client.events.off("proposal_expire",N),e?E(e):t&&I(t)}),await this.sendRequest({topic:d,method:"wc_sessionPropose",params:b,throwOnFailedPublish:!0,clientRpcId:b.id}),await this.setProposal(b.id,b),{uri:p,approval:_}}),U(this,"pair",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(e)}catch(e){throw this.client.logger.error("pair() failed"),e}}),U(this,"approve",async e=>{var t,s,r;const n=this.client.core.eventClient.createEvent({properties:{topic:null==(t=e?.id)?void 0:t.toString(),trace:[i.$I.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(e){throw n.setError(i.U.no_internet_connection),e}try{await this.isValidProposalId(e?.id)}catch(t){throw this.client.logger.error(`approve() -> proposal.get(${e?.id}) failed`),n.setError(i.U.proposal_not_found),t}try{await this.isValidApprove(e)}catch(e){throw this.client.logger.error("approve() -> isValidApprove() failed"),n.setError(i.U.session_approve_namespace_validation_failure),e}const{id:o,relayProtocol:c,namespaces:h,sessionProperties:l,sessionConfig:p}=e,d=this.client.proposal.get(o);this.client.core.eventClient.deleteEvent({eventId:n.eventId});const{pairingTopic:u,proposer:g,requiredNamespaces:f,optionalNamespaces:w}=d;let y=null==(s=this.client.core.eventClient)?void 0:s.getEvent({topic:u});y||(y=null==(r=this.client.core.eventClient)?void 0:r.createEvent({type:i.$I.session_approve_started,properties:{topic:u,trace:[i.$I.session_approve_started,i.$I.session_namespaces_validation_success]}}));const b=await this.client.core.crypto.generateKeyPair(),v=g.publicKey,E=await this.client.core.crypto.generateSharedKey(b,v),I=x(x({relay:{protocol:c??"irn"},namespaces:h,controller:{publicKey:b,metadata:this.client.metadata},expiry:(0,a.Xw0)(m)},l&&{sessionProperties:l}),p&&{sessionConfig:p}),_=i.cV.relay;y.addTrace(i.$I.subscribing_session_topic);try{await this.client.core.relayer.subscribe(E,{transportType:_})}catch(e){throw y.setError(i.U.subscribe_session_topic_failure),e}y.addTrace(i.$I.subscribe_session_topic_success);const N=R(x({},I),{topic:E,requiredNamespaces:f,optionalNamespaces:w,pairingTopic:u,acknowledged:!1,self:I.controller,peer:{publicKey:g.publicKey,metadata:g.metadata},controller:b,transportType:i.cV.relay});await this.client.session.set(E,N),y.addTrace(i.$I.store_session);try{y.addTrace(i.$I.publishing_session_settle),await this.sendRequest({topic:E,method:"wc_sessionSettle",params:I,throwOnFailedPublish:!0}).catch(e=>{throw y?.setError(i.U.session_settle_publish_failure),e}),y.addTrace(i.$I.session_settle_publish_success),y.addTrace(i.$I.publishing_session_approve),await this.sendResult({id:o,topic:u,result:{relay:{protocol:c??"irn"},responderPublicKey:b},throwOnFailedPublish:!0}).catch(e=>{throw y?.setError(i.U.session_approve_publish_failure),e}),y.addTrace(i.$I.session_approve_publish_success)}catch(e){throw this.client.logger.error(e),this.client.session.delete(E,(0,a.Hjj)("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(E),e}return this.client.core.eventClient.deleteEvent({eventId:y.eventId}),await this.client.core.pairing.updateMetadata({topic:u,metadata:g.metadata}),await this.client.proposal.delete(o,(0,a.Hjj)("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:u}),await this.setExpiry(E,(0,a.Xw0)(m)),{topic:E,acknowledged:()=>Promise.resolve(this.client.session.get(E))}}),U(this,"reject",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(e)}catch(e){throw this.client.logger.error("reject() -> isValidReject() failed"),e}const{id:t,reason:s}=e;let i;try{i=this.client.proposal.get(t).pairingTopic}catch(e){throw this.client.logger.error(`reject() -> proposal.get(${t}) failed`),e}i&&(await this.sendError({id:t,topic:i,error:s,rpcOpts:w.wc_sessionPropose.reject}),await this.client.proposal.delete(t,(0,a.Hjj)("USER_DISCONNECTED")))}),U(this,"update",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(e)}catch(e){throw this.client.logger.error("update() -> isValidUpdate() failed"),e}const{topic:t,namespaces:s}=e,{done:i,resolve:r,reject:n}=(0,a.Wx8)(),o=(0,l.payloadId)(),c=(0,l.getBigIntRpcId)().toString(),h=this.client.session.get(t).namespaces;return this.events.once((0,a.hEn)("session_update",o),({error:e})=>{e?n(e):r()}),await this.client.session.update(t,{namespaces:s}),await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:!0,clientRpcId:o,relayRpcId:c}).catch(e=>{this.client.logger.error(e),this.client.session.update(t,{namespaces:h}),n(e)}),{acknowledged:i}}),U(this,"extend",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(e)}catch(e){throw this.client.logger.error("extend() -> isValidExtend() failed"),e}const{topic:t}=e,s=(0,l.payloadId)(),{done:i,resolve:r,reject:n}=(0,a.Wx8)();return this.events.once((0,a.hEn)("session_extend",s),({error:e})=>{e?n(e):r()}),await this.setExpiry(t,(0,a.Xw0)(m)),this.sendRequest({topic:t,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:!0}).catch(e=>{n(e)}),{acknowledged:i}}),U(this,"request",async e=>{this.isInitialized();try{await this.isValidRequest(e)}catch(e){throw this.client.logger.error("request() -> isValidRequest() failed"),e}const{chainId:t,request:s,topic:r,expiry:n=w.wc_sessionRequest.req.ttl}=e,o=this.client.session.get(r);o?.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const c=(0,l.payloadId)(),h=(0,l.getBigIntRpcId)().toString(),{done:p,resolve:d,reject:u}=(0,a.Wx8)(n,"Request expired. Please try again.");this.events.once((0,a.hEn)("session_request",c),({error:e,result:t})=>{e?u(e):d(t)});const f="wc_sessionRequest",m=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);if(m)return await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:r,method:f,params:{request:R(x({},s),{expiryTimestamp:(0,a.Xw0)(n)}),chainId:t},expiry:n,throwOnFailedPublish:!0,appLink:m}).catch(e=>u(e)),this.client.events.emit("session_request_sent",{topic:r,request:s,chainId:t,id:c}),await p();const y={request:R(x({},s),{expiryTimestamp:(0,a.Xw0)(n)}),chainId:t},b=this.shouldSetTVF(f,y);return await Promise.all([new Promise(async e=>{await this.sendRequest(x({clientRpcId:c,relayRpcId:h,topic:r,method:f,params:y,expiry:n,throwOnFailedPublish:!0},b&&{tvf:this.getTVFParams(c,y)})).catch(e=>u(e)),this.client.events.emit("session_request_sent",{topic:r,request:s,chainId:t,id:c}),e()}),new Promise(async e=>{var t;if(null==(t=o.sessionConfig)||!t.disableDeepLink){const e=await(0,a.jTh)(this.client.core.storage,g);await(0,a.n3s)({id:c,topic:r,wcDeepLink:e})}e()}),p()]).then(e=>e[2])}),U(this,"respond",async e=>{this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:s}=e,{id:r}=s,n=this.client.session.get(t);n.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const o=this.getAppLinkIfEnabled(n.peer.metadata,n.transportType);(0,l.isJsonRpcResult)(s)?await this.sendResult({id:r,topic:t,result:s.result,throwOnFailedPublish:!0,appLink:o}):(0,l.isJsonRpcError)(s)&&await this.sendError({id:r,topic:t,error:s.error,appLink:o}),this.cleanupAfterResponse(e)}),U(this,"ping",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(e)}catch(e){throw this.client.logger.error("ping() -> isValidPing() failed"),e}const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=(0,l.payloadId)(),s=(0,l.getBigIntRpcId)().toString(),{done:i,resolve:r,reject:n}=(0,a.Wx8)();this.events.once((0,a.hEn)("session_ping",e),({error:e})=>{e?n(e):r()}),await Promise.all([this.sendRequest({topic:t,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:e,relayRpcId:s}),i()])}else this.client.core.pairing.pairings.keys.includes(t)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:t}))}),U(this,"emit",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(e);const{topic:t,event:s,chainId:i}=e,r=(0,l.getBigIntRpcId)().toString(),n=(0,l.payloadId)();await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:s,chainId:i},throwOnFailedPublish:!0,relayRpcId:r,clientRpcId:n})}),U(this,"disconnect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(e);const{topic:t}=e;if(this.client.session.keys.includes(t))await this.sendRequest({topic:t,method:"wc_sessionDelete",params:(0,a.Hjj)("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:t,emitEvent:!1});else{if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=(0,a.GuA)("MISMATCHED_TOPIC",`Session or pairing topic not found: ${t}`);throw new Error(e)}await this.client.core.pairing.disconnect({topic:t})}}),U(this,"find",e=>(this.isInitialized(),this.client.session.getAll().filter(t=>(0,a.HNf)(t,e)))),U(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),U(this,"authenticate",async(e,t)=>{var s;this.isInitialized(),this.isValidAuthenticate(e);const r=t&&this.client.core.linkModeSupportedApps.includes(t)&&(null==(s=this.client.metadata.redirect)?void 0:s.linkMode),n=r?i.cV.link_mode:i.cV.relay;n===i.cV.relay&&await this.confirmOnlineStateOrThrow();const{chains:o,statement:c="",uri:h,domain:p,nonce:d,type:u,exp:g,nbf:f,methods:y=[],expiry:b}=e,v=[...e.resources||[]],{topic:E,uri:I}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:n});this.client.logger.info({message:"Generated new pairing",pairing:{topic:E,uri:I}});const _=await this.client.core.crypto.generateKeyPair(),A=(0,a.EN$)(_);if(await Promise.all([this.client.auth.authKeys.set(N,{responseTopic:A,publicKey:_}),this.client.auth.pairingTopics.set(A,{topic:A,pairingTopic:E})]),await this.client.core.relayer.subscribe(A,{transportType:n}),this.client.logger.info(`sending request to new pairing topic: ${E}`),y.length>0){const{namespace:e}=(0,a._Yb)(o[0]);let t=(0,a.e8_)(e,"request",y);(0,a.VBM)(v)&&(t=(0,a.hVC)(t,v.pop())),v.push(t)}const C=b&&b>w.wc_sessionAuthenticate.req.ttl?b:w.wc_sessionAuthenticate.req.ttl,P={authPayload:{type:u??"caip122",chains:o,statement:c,aud:h,domain:p,version:"1",nonce:d,iat:(new Date).toISOString(),exp:g,nbf:f,resources:v},requester:{publicKey:_,metadata:this.client.metadata},expiryTimestamp:(0,a.Xw0)(C)},S={requiredNamespaces:{},optionalNamespaces:{eip155:{chains:o,methods:[...new Set(["personal_sign",...y])],events:["chainChanged","accountsChanged"]}},relays:[{protocol:"irn"}],pairingTopic:E,proposer:{publicKey:_,metadata:this.client.metadata},expiryTimestamp:(0,a.Xw0)(w.wc_sessionPropose.req.ttl),id:(0,l.payloadId)()},{done:O,resolve:T,reject:k}=(0,a.Wx8)(C,"Request expired"),U=(0,l.payloadId)(),D=(0,a.hEn)("session_connect",S.id),j=(0,a.hEn)("session_request",U),M=async({error:e,session:t})=>{this.events.off(j,L),e?k(e):t&&T({session:t})},L=async e=>{var s,r,o;if(await this.deletePendingAuthRequest(U,{message:"fulfilled",code:0}),e.error){const t=(0,a.Hjj)("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return e.error.code===t.code?void 0:(this.events.off(D,M),k(e.error.message))}await this.deleteProposal(S.id),this.events.off(D,M);const{cacaos:c,responder:h}=e.result,l=[],p=[];for(const e of c){await(0,a.IjX)({cacao:e,projectId:this.client.core.projectId})||(this.client.logger.error(e,"Signature verification failed"),k((0,a.Hjj)("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:t}=e,s=(0,a.VBM)(t.resources),i=[(0,a.xkc)(t.iss)],r=(0,a.q_h)(t.iss);if(s){const e=(0,a.sc_)(s),t=(0,a.WWN)(s);l.push(...e),i.push(...t)}for(const e of i)p.push(`${e}:${r}`)}const d=await this.client.core.crypto.generateSharedKey(_,h.publicKey);let u;l.length>0&&(u={topic:d,acknowledged:!0,self:{publicKey:_,metadata:this.client.metadata},peer:h,controller:h.publicKey,expiry:(0,a.Xw0)(m),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:E,namespaces:(0,a.Van)([...new Set(l)],[...new Set(p)]),transportType:n},await this.client.core.relayer.subscribe(d,{transportType:n}),await this.client.session.set(d,u),E&&await this.client.core.pairing.updateMetadata({topic:E,metadata:h.metadata}),u=this.client.session.get(d)),null!=(s=this.client.metadata.redirect)&&s.linkMode&&null!=(r=h.metadata.redirect)&&r.linkMode&&null!=(o=h.metadata.redirect)&&o.universal&&t&&(this.client.core.addLinkModeSupportedApp(h.metadata.redirect.universal),this.client.session.update(d,{transportType:i.cV.link_mode})),T({auths:c,session:u})};let q;this.events.once(D,M),this.events.once(j,L);try{if(r){const e=(0,l.formatJsonRpcRequest)("wc_sessionAuthenticate",P,U);this.client.core.history.set(E,e);const s=await this.client.core.crypto.encode("",e,{type:a.EHS,encoding:a.Pa8});q=(0,a.$Bq)(t,E,s)}else await Promise.all([this.sendRequest({topic:E,method:"wc_sessionAuthenticate",params:P,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:U}),this.sendRequest({topic:E,method:"wc_sessionPropose",params:S,expiry:w.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:S.id})])}catch(e){throw this.events.off(D,M),this.events.off(j,L),e}return await this.setProposal(S.id,S),await this.setAuthRequest(U,{request:R(x({},P),{verifyContext:{}}),pairingTopic:E,transportType:n}),{uri:q??I,response:O}}),U(this,"approveSessionAuthenticate",async e=>{const{id:t,auths:s}=e,r=this.client.core.eventClient.createEvent({properties:{topic:t.toString(),trace:[i.U$.authenticated_session_approve_started]}});try{this.isInitialized()}catch(e){throw r.setError(i.Tn.no_internet_connection),e}const n=this.getPendingAuthRequest(t);if(!n)throw r.setError(i.Tn.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${t}`);const o=n.transportType||i.cV.relay;o===i.cV.relay&&await this.confirmOnlineStateOrThrow();const c=n.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),l=(0,a.EN$)(c),p={type:a.Lp_,receiverPublicKey:c,senderPublicKey:h},d=[],u=[];for(const e of s){if(!await(0,a.IjX)({cacao:e,projectId:this.client.core.projectId})){r.setError(i.Tn.invalid_cacao);const e=(0,a.Hjj)("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:t,topic:l,error:e,encodeOpts:p}),new Error(e.message)}r.addTrace(i.U$.cacaos_verified);const{p:s}=e,n=(0,a.VBM)(s.resources),o=[(0,a.xkc)(s.iss)],c=(0,a.q_h)(s.iss);if(n){const e=(0,a.sc_)(n),t=(0,a.WWN)(n);d.push(...e),o.push(...t)}for(const e of o)u.push(`${e}:${c}`)}const g=await this.client.core.crypto.generateSharedKey(h,c);let f;if(r.addTrace(i.U$.create_authenticated_session_topic),d?.length>0){f={topic:g,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:c,metadata:n.requester.metadata},controller:c,expiry:(0,a.Xw0)(m),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:n.pairingTopic,namespaces:(0,a.Van)([...new Set(d)],[...new Set(u)]),transportType:o},r.addTrace(i.U$.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(g,{transportType:o})}catch(e){throw r.setError(i.Tn.subscribe_authenticated_session_topic_failure),e}r.addTrace(i.U$.subscribe_authenticated_session_topic_success),await this.client.session.set(g,f),r.addTrace(i.U$.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:n.pairingTopic,metadata:n.requester.metadata})}r.addTrace(i.U$.publishing_authenticated_session_approve);try{await this.sendResult({topic:l,id:t,result:{cacaos:s,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:p,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(n.requester.metadata,o)})}catch(e){throw r.setError(i.Tn.authenticated_session_approve_publish_failure),e}return await this.client.auth.requests.delete(t,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:n.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:r.eventId}),{session:f}}),U(this,"rejectSessionAuthenticate",async e=>{this.isInitialized();const{id:t,reason:s}=e,r=this.getPendingAuthRequest(t);if(!r)throw new Error(`Could not find pending auth request with id ${t}`);r.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const n=r.requester.publicKey,o=await this.client.core.crypto.generateKeyPair(),c=(0,a.EN$)(n),h={type:a.Lp_,receiverPublicKey:n,senderPublicKey:o};await this.sendError({id:t,topic:c,error:s,encodeOpts:h,rpcOpts:w.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(r.requester.metadata,r.transportType)}),await this.client.auth.requests.delete(t,{message:"rejected",code:0}),await this.client.proposal.delete(t,(0,a.Hjj)("USER_DISCONNECTED"))}),U(this,"formatAuthMessage",e=>{this.isInitialized();const{request:t,iss:s}=e;return(0,a.hwK)(t,s)}),U(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(0!==this.relayMessageCache.length)for(;this.relayMessageCache.length>0;)try{const e=this.relayMessageCache.shift();e&&await this.onRelayMessage(e)}catch(e){this.client.logger.error(e)}},50)}),U(this,"cleanupDuplicatePairings",async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter(s=>{var i,r;return(null==(i=s.peerMetadata)?void 0:i.url)&&(null==(r=s.peerMetadata)?void 0:r.url)===e.peer.metadata.url&&s.topic&&s.topic!==t.topic});if(0===s.length)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.map(e=>this.client.core.pairing.disconnect({topic:e.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}}),U(this,"deleteSession",async e=>{var t;const{topic:s,expirerHasDeleted:i=!1,emitEvent:r=!0,id:n=0}=e,{self:o}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,(0,a.Hjj)("USER_DISCONNECTED")),this.addToRecentlyDeleted(s,"session"),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),i||this.client.core.expirer.del(s),this.client.core.storage.removeItem(g).catch(e=>this.client.logger.warn(e)),this.getPendingSessionRequests().forEach(e=>{e.topic===s&&this.deletePendingSessionRequest(e.id,(0,a.Hjj)("USER_DISCONNECTED"))}),s===(null==(t=this.sessionRequestQueue.queue[0])?void 0:t.topic)&&(this.sessionRequestQueue.state=b),r&&this.client.events.emit("session_delete",{id:n,topic:s})}),U(this,"deleteProposal",async(e,t)=>{if(t)try{const t=this.client.proposal.get(e),s=this.client.core.eventClient.getEvent({topic:t.pairingTopic});s?.setError(i.U.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(e,(0,a.Hjj)("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")}),U(this,"deletePendingSessionRequest",async(e,t,s=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,t),s?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(t=>t.id!==e),s&&(this.sessionRequestQueue.state=b,this.client.events.emit("session_request_expire",{id:e}))}),U(this,"deletePendingAuthRequest",async(e,t,s=!1)=>{await Promise.all([this.client.auth.requests.delete(e,t),s?Promise.resolve():this.client.core.expirer.del(e)])}),U(this,"setExpiry",async(e,t)=>{this.client.session.keys.includes(e)&&(this.client.core.expirer.set(e,t),await this.client.session.update(e,{expiry:t}))}),U(this,"setProposal",async(e,t)=>{this.client.core.expirer.set(e,(0,a.Xw0)(w.wc_sessionPropose.req.ttl)),await this.client.proposal.set(e,t)}),U(this,"setAuthRequest",async(e,t)=>{const{request:s,pairingTopic:r,transportType:n=i.cV.relay}=t;this.client.core.expirer.set(e,s.expiryTimestamp),await this.client.auth.requests.set(e,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:e,pairingTopic:r,verifyContext:s.verifyContext,transportType:n})}),U(this,"setPendingSessionRequest",async e=>{const{id:t,topic:s,params:i,verifyContext:r}=e,n=i.request.expiryTimestamp||(0,a.Xw0)(w.wc_sessionRequest.req.ttl);this.client.core.expirer.set(t,n),await this.client.pendingRequest.set(t,{id:t,topic:s,params:i,verifyContext:r})}),U(this,"sendRequest",async e=>{const{topic:t,method:i,params:r,expiry:n,relayRpcId:o,clientRpcId:c,throwOnFailedPublish:h,appLink:p,tvf:d}=e,u=(0,l.formatJsonRpcRequest)(i,r,c);let g;const f=!!p;try{const e=f?a.Pa8:a.EWt;g=await this.client.core.crypto.encode(t,u,{encoding:e})}catch(e){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${t} failed`),e}let m;if(I.includes(i)){const e=(0,a.ALl)(JSON.stringify(u)),t=(0,a.ALl)(g);m=await this.client.core.verify.register({id:t,decryptedId:e})}const y=w[i].req;if(y.attestation=m,n&&(y.ttl=n),o&&(y.id=o),this.client.core.history.set(t,u),f){const e=(0,a.$Bq)(p,t,g);await s.g.Linking.openURL(e,this.client.name)}else{const e=w[i].req;n&&(e.ttl=n),o&&(e.id=o),e.tvf=R(x({},d),{correlationId:u.id}),h?(e.internal=R(x({},e.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,g,e)):this.client.core.relayer.publish(t,g,e).catch(e=>this.client.logger.error(e))}return u.id}),U(this,"sendResult",async e=>{const{id:t,topic:i,result:r,throwOnFailedPublish:n,encodeOpts:o,appLink:c}=e,h=(0,l.formatJsonRpcResult)(t,r);let p;const d=c&&typeof(null==s.g?void 0:s.g.Linking)<"u";try{const e=d?a.Pa8:a.EWt;p=await this.client.core.crypto.encode(i,h,R(x({},o||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`),e}let u,g;try{u=await this.client.core.history.get(i,t);const e=u.request;try{this.shouldSetTVF(e.method,e.params)&&(g=this.getTVFParams(t,e.params,r))}catch(e){this.client.logger.warn("sendResult() -> getTVFParams() failed",e)}}catch(e){throw this.client.logger.error(`sendResult() -> history.get(${i}, ${t}) failed`),e}if(d){const e=(0,a.$Bq)(c,i,p);await s.g.Linking.openURL(e,this.client.name)}else{const e=u.request.method,s=w[e].res;s.tvf=R(x({},g),{correlationId:t}),n?(s.internal=R(x({},s.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,p,s)):this.client.core.relayer.publish(i,p,s).catch(e=>this.client.logger.error(e))}await this.client.core.history.resolve(h)}),U(this,"sendError",async e=>{const{id:t,topic:i,error:r,encodeOpts:n,rpcOpts:o,appLink:c}=e,h=(0,l.formatJsonRpcError)(t,r);let p;const d=c&&typeof(null==s.g?void 0:s.g.Linking)<"u";try{const e=d?a.Pa8:a.EWt;p=await this.client.core.crypto.encode(i,h,R(x({},n||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${i} failed`),e}let u;try{u=await this.client.core.history.get(i,t)}catch(e){throw this.client.logger.error(`sendError() -> history.get(${i}, ${t}) failed`),e}if(d){const e=(0,a.$Bq)(c,i,p);await s.g.Linking.openURL(e,this.client.name)}else{const e=u.request.method,t=o||w[e].res;this.client.core.relayer.publish(i,p,t)}await this.client.core.history.resolve(h)}),U(this,"cleanup",async()=>{const e=[],t=[];this.client.session.getAll().forEach(t=>{let s=!1;(0,a._dF)(t.expiry)&&(s=!0),this.client.core.crypto.keychain.has(t.topic)||(s=!0),s&&e.push(t.topic)}),this.client.proposal.getAll().forEach(e=>{(0,a._dF)(e.expiryTimestamp)&&t.push(e.id)}),await Promise.all([...e.map(e=>this.deleteSession({topic:e})),...t.map(e=>this.deleteProposal(e))])}),U(this,"onRelayEventRequest",async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()}),U(this,"processRequestsQueue",async()=>{if(this.requestQueue.state!==v){for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=v;const e=this.requestQueue.queue.shift();if(e)try{await this.processRequest(e)}catch(e){this.client.logger.warn(e)}}this.requestQueue.state=b}else this.client.logger.info("Request queue already active, skipping...")}),U(this,"processRequest",async e=>{const{topic:t,payload:s,attestation:i,transportType:r,encryptedId:n}=e,o=s.method;if(!this.shouldIgnorePairingRequest({topic:t,requestMethod:o}))switch(o){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:t,payload:s,attestation:i,encryptedId:n});case"wc_sessionSettle":return await this.onSessionSettleRequest(t,s);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(t,s);case"wc_sessionExtend":return await this.onSessionExtendRequest(t,s);case"wc_sessionPing":return await this.onSessionPingRequest(t,s);case"wc_sessionDelete":return await this.onSessionDeleteRequest(t,s);case"wc_sessionRequest":return await this.onSessionRequest({topic:t,payload:s,attestation:i,encryptedId:n,transportType:r});case"wc_sessionEvent":return await this.onSessionEventRequest(t,s);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:t,payload:s,attestation:i,encryptedId:n,transportType:r});default:return this.client.logger.info(`Unsupported request method ${o}`)}}),U(this,"onRelayEventResponse",async e=>{const{topic:t,payload:s,transportType:i}=e,r=(await this.client.core.history.get(t,s.id)).request.method;switch(r){case"wc_sessionPropose":return this.onSessionProposeResponse(t,s,i);case"wc_sessionSettle":return this.onSessionSettleResponse(t,s);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,s);case"wc_sessionExtend":return this.onSessionExtendResponse(t,s);case"wc_sessionPing":return this.onSessionPingResponse(t,s);case"wc_sessionRequest":return this.onSessionRequestResponse(t,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(t,s);default:return this.client.logger.info(`Unsupported response method ${r}`)}}),U(this,"onRelayEventUnknownPayload",e=>{const{topic:t}=e,{message:s}=(0,a.GuA)("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)}),U(this,"shouldIgnorePairingRequest",e=>{const{topic:t,requestMethod:s}=e,i=this.expectedPairingMethodMap.get(t);return!(!i||i.includes(s)||!(i.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0))}),U(this,"onSessionProposeRequest",async e=>{const{topic:t,payload:s,attestation:r,encryptedId:n}=e,{params:o,id:c}=s;try{const e=this.client.core.eventClient.getEvent({topic:t});0===this.client.events.listenerCount("session_proposal")&&(console.warn("No listener for session_proposal event"),e?.setError(i.S$.proposal_listener_not_found)),this.isValidConnect(x({},s.params));const h=o.expiryTimestamp||(0,a.Xw0)(w.wc_sessionPropose.req.ttl),l=x({id:c,pairingTopic:t,expiryTimestamp:h},o);await this.setProposal(c,l);const p=await this.getVerifyContext({attestationId:r,hash:(0,a.ALl)(JSON.stringify(s)),encryptedId:n,metadata:l.proposer.metadata});e?.addTrace(i.$w.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:l,verifyContext:p})}catch(e){await this.sendError({id:c,topic:t,error:e,rpcOpts:w.wc_sessionPropose.autoReject}),this.client.logger.error(e)}}),U(this,"onSessionProposeResponse",async(e,t,s)=>{const{id:i}=t;if((0,l.isJsonRpcResult)(t)){const{result:r}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:r});const n=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const o=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const a=r.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});const c=await this.client.core.crypto.generateSharedKey(o,a);this.pendingSessions.set(i,{sessionTopic:c,pairingTopic:e,proposalId:i,publicKey:o});const h=await this.client.core.relayer.subscribe(c,{transportType:s});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:e})}else if((0,l.isJsonRpcError)(t)){await this.client.proposal.delete(i,(0,a.Hjj)("USER_DISCONNECTED"));const e=(0,a.hEn)("session_connect",i);if(0===this.events.listenerCount(e))throw new Error(`emitting ${e} without any listeners, 954`);this.events.emit(e,{error:t.error})}}),U(this,"onSessionSettleRequest",async(e,t)=>{const{id:s,params:r}=t;try{this.isValidSessionSettleRequest(r);const{relay:s,controller:n,expiry:o,namespaces:c,sessionProperties:h,sessionConfig:l}=t.params,p=[...this.pendingSessions.values()].find(t=>t.sessionTopic===e);if(!p)return this.client.logger.error(`Pending session not found for topic ${e}`);const d=this.client.proposal.get(p.proposalId),u=R(x(x({topic:e,relay:s,expiry:o,namespaces:c,acknowledged:!0,pairingTopic:p.pairingTopic,requiredNamespaces:d.requiredNamespaces,optionalNamespaces:d.optionalNamespaces,controller:n.publicKey,self:{publicKey:p.publicKey,metadata:this.client.metadata},peer:{publicKey:n.publicKey,metadata:n.metadata}},h&&{sessionProperties:h}),l&&{sessionConfig:l}),{transportType:i.cV.relay});await this.client.session.set(u.topic,u),await this.setExpiry(u.topic,u.expiry),await this.client.core.pairing.updateMetadata({topic:p.pairingTopic,metadata:u.peer.metadata}),this.client.events.emit("session_connect",{session:u}),this.events.emit((0,a.hEn)("session_connect",p.proposalId),{session:u}),this.pendingSessions.delete(p.proposalId),this.deleteProposal(p.proposalId,!1),this.cleanupDuplicatePairings(u),await this.sendResult({id:t.id,topic:e,result:!0,throwOnFailedPublish:!0})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"onSessionSettleResponse",async(e,t)=>{const{id:s}=t;(0,l.isJsonRpcResult)(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit((0,a.hEn)("session_approve",s),{})):(0,l.isJsonRpcError)(t)&&(await this.client.session.delete(e,(0,a.Hjj)("USER_DISCONNECTED")),this.events.emit((0,a.hEn)("session_approve",s),{error:t.error}))}),U(this,"onSessionUpdateRequest",async(e,t)=>{const{params:s,id:i}=t;try{const t=`${e}_session_update`,r=a.nyL.get(t);if(r&&this.isRequestOutOfSync(r,i))return this.client.logger.warn(`Discarding out of sync request - ${i}`),void this.sendError({id:i,topic:e,error:(0,a.Hjj)("INVALID_UPDATE_REQUEST")});this.isValidUpdate(x({topic:e},s));try{a.nyL.set(t,i),await this.client.session.update(e,{namespaces:s.namespaces}),await this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0})}catch(e){throw a.nyL.delete(t),e}this.client.events.emit("session_update",{id:i,topic:e,params:s})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"isRequestOutOfSync",(e,t)=>t.toString().slice(0,-3)<e.toString().slice(0,-3)),U(this,"onSessionUpdateResponse",(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_update",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_update",s),{}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_update",s),{error:t.error})}),U(this,"onSessionExtendRequest",async(e,t)=>{const{id:s}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,(0,a.Xw0)(m)),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:s,topic:e})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"onSessionExtendResponse",(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_extend",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_extend",s),{}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_extend",s),{error:t.error})}),U(this,"onSessionPingRequest",async(e,t)=>{const{id:s}=t;try{this.isValidPing({topic:e}),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:e})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"onSessionPingResponse",(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_ping",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);setTimeout(()=>{(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_ping",s),{}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_ping",s),{error:t.error})},500)}),U(this,"onSessionDeleteRequest",async(e,t)=>{const{id:s}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),Promise.all([new Promise(t=>{this.client.core.relayer.once(i.Jf.publish,async()=>{t(await this.deleteSession({topic:e,id:s}))})}),this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:(0,a.Hjj)("USER_DISCONNECTED")})]).catch(e=>this.client.logger.error(e))}catch(e){this.client.logger.error(e)}}),U(this,"onSessionRequest",async e=>{var t,s,r;const{topic:n,payload:o,attestation:c,encryptedId:h,transportType:p}=e,{id:d,params:u}=o;try{await this.isValidRequest(x({topic:n},u));const e=this.client.session.get(n),o={id:d,topic:n,params:u,verifyContext:await this.getVerifyContext({attestationId:c,hash:(0,a.ALl)(JSON.stringify((0,l.formatJsonRpcRequest)("wc_sessionRequest",u,d))),encryptedId:h,metadata:e.peer.metadata,transportType:p})};await this.setPendingSessionRequest(o),p===i.cV.link_mode&&null!=(t=e.peer.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(null==(s=e.peer.metadata.redirect)?void 0:s.universal),null!=(r=this.client.signConfig)&&r.disableRequestQueue?this.emitSessionRequest(o):(this.addSessionRequestToSessionRequestQueue(o),this.processSessionRequestQueue())}catch(e){await this.sendError({id:d,topic:n,error:e}),this.client.logger.error(e)}}),U(this,"onSessionRequestResponse",(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_request",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_request",s),{result:t.result}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_request",s),{error:t.error})}),U(this,"onSessionEventRequest",async(e,t)=>{const{id:s,params:i}=t;try{const t=`${e}_session_event_${i.event.name}`,r=a.nyL.get(t);if(r&&this.isRequestOutOfSync(r,s))return void this.client.logger.info(`Discarding out of sync request - ${s}`);this.isValidEmit(x({topic:e},i)),this.client.events.emit("session_event",{id:s,topic:e,params:i}),a.nyL.set(t,s)}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"onSessionAuthenticateResponse",(e,t)=>{const{id:s}=t;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:t}),(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_request",s),{result:t.result}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_request",s),{error:t.error})}),U(this,"onSessionAuthenticateRequest",async e=>{var t;const{topic:s,payload:r,attestation:n,encryptedId:o,transportType:c}=e;try{const{requester:e,authPayload:h,expiryTimestamp:l}=r.params,p=await this.getVerifyContext({attestationId:n,hash:(0,a.ALl)(JSON.stringify(r)),encryptedId:o,metadata:e.metadata,transportType:c}),d={requester:e,pairingTopic:s,id:r.id,authPayload:h,verifyContext:p,expiryTimestamp:l};await this.setAuthRequest(r.id,{request:d,pairingTopic:s,transportType:c}),c===i.cV.link_mode&&null!=(t=e.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(e.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:s,params:r.params,id:r.id,verifyContext:p})}catch(e){this.client.logger.error(e);const t=r.params.requester.publicKey,i=await this.client.core.crypto.generateKeyPair(),n=this.getAppLinkIfEnabled(r.params.requester.metadata,c),o={type:a.Lp_,receiverPublicKey:t,senderPublicKey:i};await this.sendError({id:r.id,topic:s,error:e,encodeOpts:o,rpcOpts:w.wc_sessionAuthenticate.autoReject,appLink:n})}}),U(this,"addSessionRequestToSessionRequestQueue",e=>{this.sessionRequestQueue.queue.push(e)}),U(this,"cleanupAfterResponse",e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=b,this.processSessionRequestQueue()},(0,o.toMiliseconds)(this.requestQueueDelay))}),U(this,"cleanupPendingSentRequestsForTopic",({topic:e,error:t})=>{const s=this.client.core.history.pending;s.length>0&&s.filter(t=>t.topic===e&&"wc_sessionRequest"===t.request.method).forEach(e=>{const s=e.request.id,i=(0,a.hEn)("session_request",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);this.events.emit((0,a.hEn)("session_request",e.request.id),{error:t})})}),U(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===v)return void this.client.logger.info("session request queue is already active.");const e=this.sessionRequestQueue.queue[0];if(e)try{this.sessionRequestQueue.state=v,this.emitSessionRequest(e)}catch(e){this.client.logger.error(e)}else this.client.logger.info("session request queue is empty.")}),U(this,"emitSessionRequest",e=>{this.client.events.emit("session_request",e)}),U(this,"onPairingCreated",e=>{if(e.methods&&this.expectedPairingMethodMap.set(e.topic,e.methods),e.active)return;const t=this.client.proposal.getAll().find(t=>t.pairingTopic===e.topic);t&&this.onSessionProposeRequest({topic:e.topic,payload:(0,l.formatJsonRpcRequest)("wc_sessionPropose",{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties},t.id)})}),U(this,"isValidConnect",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(t)}const{pairingTopic:t,requiredNamespaces:s,optionalNamespaces:i,sessionProperties:r,relays:n}=e;if((0,a.b07)(t)||await this.isValidPairingTopic(t),!(0,a.V9G)(n,!0)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`connect() relays: ${n}`);throw new Error(e)}!(0,a.b07)(s)&&0!==(0,a.aF0)(s)&&this.validateNamespaces(s,"requiredNamespaces"),!(0,a.b07)(i)&&0!==(0,a.aF0)(i)&&this.validateNamespaces(i,"optionalNamespaces"),(0,a.b07)(r)||this.validateSessionProps(r,"sessionProperties")}),U(this,"validateNamespaces",(e,t)=>{const s=(0,a.esh)(e,"connect()",t);if(s)throw new Error(s.message)}),U(this,"isValidApprove",async e=>{if(!(0,a.TeY)(e))throw new Error((0,a.GuA)("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:t,namespaces:s,relayProtocol:i,sessionProperties:r}=e;this.checkRecentlyDeleted(t),await this.isValidProposalId(t);const n=this.client.proposal.get(t),o=(0,a.FiO)(s,"approve()");if(o)throw new Error(o.message);const c=(0,a.XqR)(n.requiredNamespaces,s,"approve()");if(c)throw new Error(c.message);if(!(0,a.Qhg)(i,!0)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw new Error(e)}(0,a.b07)(r)||this.validateSessionProps(r,"sessionProperties")}),U(this,"isValidReject",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(t)}const{id:t,reason:s}=e;if(this.checkRecentlyDeleted(t),await this.isValidProposalId(t),!(0,a.X3c)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(e)}}),U(this,"isValidSessionSettleRequest",e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}const{relay:t,controller:s,namespaces:i,expiry:r}=e;if(!(0,a.kuU)(t)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const n=(0,a.tk0)(s,"onSessionSettleRequest()");if(n)throw new Error(n.message);const o=(0,a.FiO)(i,"onSessionSettleRequest()");if(o)throw new Error(o.message);if((0,a._dF)(r)){const{message:e}=(0,a.GuA)("EXPIRED","onSessionSettleRequest()");throw new Error(e)}}),U(this,"isValidUpdate",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(t)}const{topic:t,namespaces:s}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const i=this.client.session.get(t),r=(0,a.FiO)(s,"update()");if(r)throw new Error(r.message);const n=(0,a.XqR)(i.requiredNamespaces,s,"update()");if(n)throw new Error(n.message)}),U(this,"isValidExtend",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:t}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t)}),U(this,"isValidRequest",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(t)}const{topic:t,request:s,chainId:i,expiry:r}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const{namespaces:n}=this.client.session.get(t);if(!(0,a.tLy)(n,i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() chainId: ${i}`);throw new Error(e)}if(!(0,a.iV1)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(e)}if(!(0,a.oKp)(n,i,s.method)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(e)}if(r&&!(0,a.Hbs)(r,y)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() expiry: ${r}. Expiry must be a number (in seconds) between ${y.min} and ${y.max}`);throw new Error(e)}}),U(this,"isValidRespond",async e=>{var t;if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:s,response:i}=e;try{await this.isValidSessionTopic(s)}catch(s){throw null!=(t=e?.response)&&t.id&&this.cleanupAfterResponse(e),s}if(!(0,a.M8n)(i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(e)}}),U(this,"isValidPing",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),U(this,"isValidEmit",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(t)}const{topic:t,event:s,chainId:i}=e;await this.isValidSessionTopic(t);const{namespaces:r}=this.client.session.get(t);if(!(0,a.tLy)(r,i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw new Error(e)}if(!(0,a.FR8)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(e)}if(!(0,a.z2N)(r,i,s.name)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(e)}}),U(this,"isValidDisconnect",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),U(this,"isValidAuthenticate",e=>{const{chains:t,uri:s,domain:i,nonce:r}=e;if(!Array.isArray(t)||0===t.length)throw new Error("chains is required and must be a non-empty array");if(!(0,a.Qhg)(s,!1))throw new Error("uri is required parameter");if(!(0,a.Qhg)(i,!1))throw new Error("domain is required parameter");if(!(0,a.Qhg)(r,!1))throw new Error("nonce is required parameter");if([...new Set(t.map(e=>(0,a._Yb)(e).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:n}=(0,a._Yb)(t[0]);if("eip155"!==n)throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),U(this,"getVerifyContext",async e=>{const{attestationId:t,hash:s,encryptedId:r,metadata:n,transportType:o}=e,a={verified:{verifyUrl:n.verifyUrl||i.WB,validation:"UNKNOWN",origin:n.url||""}};try{if(o===i.cV.link_mode){const e=this.getAppLinkIfEnabled(n,o);return a.verified.validation=e&&new URL(e).origin===new URL(n.url).origin?"VALID":"INVALID",a}const e=await this.client.core.verify.resolve({attestationId:t,hash:s,encryptedId:r,verifyUrl:n.verifyUrl});e&&(a.verified.origin=e.origin,a.verified.isScam=e.isScam,a.verified.validation=e.origin===new URL(n.url).origin?"VALID":"INVALID")}catch(e){this.client.logger.warn(e)}return this.client.logger.debug(`Verify context: ${JSON.stringify(a)}`),a}),U(this,"validateSessionProps",(e,t)=>{Object.values(e).forEach(e=>{if(!(0,a.Qhg)(e,!1)){const{message:s}=(0,a.GuA)("MISSING_OR_INVALID",`${t} must be in Record<string, string> format. Received: ${JSON.stringify(e)}`);throw new Error(s)}})}),U(this,"getPendingAuthRequest",e=>{const t=this.client.auth.requests.get(e);return"object"==typeof t?t:void 0}),U(this,"addToRecentlyDeleted",(e,t)=>{if(this.recentlyDeletedMap.set(e,t),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let e=0;const t=this.recentlyDeletedLimit/2;for(const s of this.recentlyDeletedMap.keys()){if(e++>=t)break;this.recentlyDeletedMap.delete(s)}}}),U(this,"checkRecentlyDeleted",e=>{const t=this.recentlyDeletedMap.get(e);if(t){const{message:s}=(0,a.GuA)("MISSING_OR_INVALID",`Record was recently deleted - ${t}: ${e}`);throw new Error(s)}}),U(this,"isLinkModeEnabled",(e,t)=>{var r,n,o,a,c,h,l,p,d;return!(!e||t!==i.cV.link_mode)&&!0===(null==(n=null==(r=this.client.metadata)?void 0:r.redirect)?void 0:n.linkMode)&&void 0!==(null==(a=null==(o=this.client.metadata)?void 0:o.redirect)?void 0:a.universal)&&""!==(null==(h=null==(c=this.client.metadata)?void 0:c.redirect)?void 0:h.universal)&&void 0!==(null==(l=e?.redirect)?void 0:l.universal)&&""!==(null==(p=e?.redirect)?void 0:p.universal)&&!0===(null==(d=e?.redirect)?void 0:d.linkMode)&&this.client.core.linkModeSupportedApps.includes(e.redirect.universal)&&typeof(null==s.g?void 0:s.g.Linking)<"u"}),U(this,"getAppLinkIfEnabled",(e,t)=>{var s;return this.isLinkModeEnabled(e,t)?null==(s=e?.redirect)?void 0:s.universal:void 0}),U(this,"handleLinkModeMessage",({url:e})=>{if(!e||!e.includes("wc_ev")||!e.includes("topic"))return;const t=(0,a.$hI)(e,"topic")||"",s=decodeURIComponent((0,a.$hI)(e,"wc_ev")||""),r=this.client.session.keys.includes(t);r&&this.client.session.update(t,{transportType:i.cV.link_mode}),this.client.core.dispatchEnvelope({topic:t,message:s,sessionExists:r})}),U(this,"registerLinkModeListeners",async()=>{var e;if((0,a.w8K)()||(0,a.lVv)()&&null!=(e=this.client.metadata.redirect)&&e.linkMode){const e=null==s.g?void 0:s.g.Linking;if(typeof e<"u"){e.addEventListener("url",this.handleLinkModeMessage,this.client.name);const t=await e.getInitialURL();t&&setTimeout(()=>{this.handleLinkModeMessage({url:t})},50)}}}),U(this,"shouldSetTVF",(e,t)=>{if(!t||"wc_sessionRequest"!==e)return!1;const{request:s}=t;return Object.keys(E).includes(s.method)}),U(this,"getTVFParams",(e,t,s)=>{var i,r;try{const n=t.request.method,o=this.extractTxHashesFromResult(n,s);return R(x({correlationId:e,rpcMethods:[n],chainId:t.chainId},this.isValidContractData(t.request.params)&&{contractAddresses:[null==(r=null==(i=t.request.params)?void 0:i[0])?void 0:r.to]}),{txHashes:o})}catch(e){this.client.logger.warn("Error getting TVF params",e)}return{}}),U(this,"isValidContractData",e=>{var t;if(!e)return!1;try{const s=e?.data||(null==(t=e?.[0])?void 0:t.data);if(!s.startsWith("0x"))return!1;const i=s.slice(2);return!!/^[0-9a-fA-F]*$/.test(i)&&i.length%2==0}catch{}return!1}),U(this,"extractTxHashesFromResult",(e,t)=>{try{if("string"==typeof t)return[t];const s=t[E[e].key];if((0,a.OP1)(s))return s;if("string"==typeof s)return[s]}catch(e){this.client.logger.warn("Error extracting tx hashes from result",e)}return[]})}isInitialized(){if(!this.initialized){const{message:e}=(0,a.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(i.Jf.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:t,message:s,attestation:r,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(N)?this.client.auth.authKeys.get(N):{responseTopic:void 0,publicKey:void 0},c=await this.client.core.crypto.decode(t,s,{receiverPublicKey:o,encoding:n===i.cV.link_mode?a.Pa8:a.EWt});try{(0,l.isJsonRpcRequest)(c)?(this.client.core.history.set(t,c),this.onRelayEventRequest({topic:t,payload:c,attestation:r,transportType:n,encryptedId:(0,a.ALl)(s)})):(0,l.isJsonRpcResponse)(c)?(await this.client.core.history.resolve(c),await this.onRelayEventResponse({topic:t,payload:c,transportType:n}),this.client.core.history.delete(t,c.id)):this.onRelayEventUnknownPayload({topic:t,payload:c,transportType:n})}catch(e){this.client.logger.error(e)}}registerExpirerEvents(){this.client.core.expirer.on(i.wn.expired,async e=>{const{topic:t,id:s}=(0,a.c82)(e.target);return s&&this.client.pendingRequest.keys.includes(s)?await this.deletePendingSessionRequest(s,(0,a.GuA)("EXPIRED"),!0):s&&this.client.auth.requests.keys.includes(s)?await this.deletePendingAuthRequest(s,(0,a.GuA)("EXPIRED"),!0):void(t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):s&&(await this.deleteProposal(s,!0),this.client.events.emit("proposal_expire",{id:s})))})}registerPairingEvents(){this.client.core.pairing.events.on(i.zN.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(i.zN.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!(0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=(0,a.GuA)("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!(0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=(0,a.GuA)("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else{if(!this.client.core.pairing.pairings.keys.includes(e)){if((0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if(!(0,a.Alu)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=(0,a.GuA)("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class j extends i.il{constructor(e,t){super(e,t,"proposal",d),this.core=e,this.logger=t}}class M extends i.il{constructor(e,t){super(e,t,"session",d),this.core=e,this.logger=t}}class L extends i.il{constructor(e,t){super(e,t,"request",d,e=>e.id),this.core=e,this.logger=t}}class q extends i.il{constructor(e,t){super(e,t,"authKeys",_,()=>N),this.core=e,this.logger=t}}class $ extends i.il{constructor(e,t){super(e,t,"pairingTopics",_),this.core=e,this.logger=t}}class B extends i.il{constructor(e,t){super(e,t,"requests",_,e=>e.id),this.core=e,this.logger=t}}var H=Object.defineProperty,W=(e,t,s)=>((e,t,s)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class z{constructor(e,t){this.core=e,this.logger=t,W(this,"authKeys"),W(this,"pairingTopics"),W(this,"requests"),this.authKeys=new q(this.core,this.logger),this.pairingTopics=new $(this.core,this.logger),this.requests=new B(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var V=Object.defineProperty,F=(e,t,s)=>((e,t,s)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class K extends n.S9{constructor(e){super(e),F(this,"protocol","wc"),F(this,"version",2),F(this,"name",u),F(this,"metadata"),F(this,"core"),F(this,"logger"),F(this,"events",new c.EventEmitter),F(this,"engine"),F(this,"session"),F(this,"proposal"),F(this,"pendingRequest"),F(this,"auth"),F(this,"signConfig"),F(this,"on",(e,t)=>this.events.on(e,t)),F(this,"once",(e,t)=>this.events.once(e,t)),F(this,"off",(e,t)=>this.events.off(e,t)),F(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),F(this,"removeAllListeners",e=>this.events.removeAllListeners(e)),F(this,"connect",async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"pair",async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"approve",async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"reject",async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"update",async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"extend",async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"request",async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"respond",async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"ping",async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"emit",async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"disconnect",async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"find",e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}}),F(this,"authenticate",async(e,t)=>{try{return await this.engine.authenticate(e,t)}catch(e){throw this.logger.error(e.message),e}}),F(this,"formatAuthMessage",e=>{try{return this.engine.formatAuthMessage(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"approveSessionAuthenticate",async e=>{try{return await this.engine.approveSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"rejectSessionAuthenticate",async e=>{try{return await this.engine.rejectSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),this.name=e?.name||u,this.metadata=e?.metadata||(0,a.lFF)(),this.signConfig=e?.signConfig;const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,r.h6)((0,r.iP)({level:e?.logger||"error"}));this.core=e?.core||new i.iJ(e),this.logger=(0,r.U5)(t,this.name),this.session=new M(this.core,this.logger),this.proposal=new j(this.core,this.logger),this.pendingRequest=new L(this.core,this.logger),this.engine=new D(this),this.auth=new z(this.core,this.logger)}static async init(e){const t=new K(e);return await t.initialize(),t}get context(){return(0,r.oI)(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},(0,o.toMiliseconds)(o.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}},32681:(e,t,s)=>{s.d(t,{IP:()=>o,T8:()=>r,Ud:()=>n,Ws:()=>i});const i={WALLET_ID:"@appkit/wallet_id",WALLET_NAME:"@appkit/wallet_name",SOLANA_WALLET:"@appkit/solana_wallet",SOLANA_CAIP_CHAIN:"@appkit/solana_caip_chain",ACTIVE_CAIP_NETWORK_ID:"@appkit/active_caip_network_id",CONNECTED_SOCIAL:"@appkit/connected_social",CONNECTED_SOCIAL_USERNAME:"@appkit-wallet/SOCIAL_USERNAME",RECENT_WALLETS:"@appkit/recent_wallets",DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",ACTIVE_NAMESPACE:"@appkit/active_namespace",CONNECTED_NAMESPACES:"@appkit/connected_namespaces",CONNECTION_STATUS:"@appkit/connection_status",SIWX_AUTH_TOKEN:"@appkit/siwx-auth-token",SIWX_NONCE_TOKEN:"@appkit/siwx-nonce-token",TELEGRAM_SOCIAL_PROVIDER:"@appkit/social_provider",NATIVE_BALANCE_CACHE:"@appkit/native_balance_cache",PORTFOLIO_CACHE:"@appkit/portfolio_cache",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache"};function r(e){if(!e)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${e}:connected_connector_id`}const n={setItem(e,t){o()&&void 0!==t&&localStorage.setItem(e,t)},getItem(e){if(o())return localStorage.getItem(e)||void 0},removeItem(e){o()&&localStorage.removeItem(e)},clear(){o()&&localStorage.clear()}};function o(){return"undefined"!=typeof window&&"undefined"!=typeof localStorage}},33816:(e,t,s)=>{s.d(t,{X:()=>c}),s(1057);var i=s(95191),r=s(16279),n=s(16158),o=s(40770),a=s(76663);class c{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,e&&this.construct(e)}construct(e){this.caipNetworks=e.networks,this.projectId=e.projectId,this.namespace=e.namespace,this.adapterType=e.adapterType}get connectors(){return this.availableConnectors}get networks(){return this.caipNetworks||[]}setAuthProvider(e){this.addConnector({id:i.o.CONNECTOR_ID.AUTH,type:"AUTH",name:i.o.CONNECTOR_NAMES.AUTH,provider:e,imageId:o.L.ConnectorImageIds[i.o.CONNECTOR_ID.AUTH],chain:this.namespace,chains:[]})}addConnector(...e){const t=new Set;this.availableConnectors=[...e,...this.availableConnectors].filter(e=>!t.has(e.id)&&(t.add(e.id),!0)),this.emit("connectors",this.availableConnectors)}setStatus(e,t){r.U.setStatus(e,t)}on(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e)?.add(t)}off(e,t){const s=this.eventListeners.get(e);s&&s.delete(t)}removeAllEventListeners(){this.eventListeners.forEach(e=>{e.clear()})}emit(e,t){const s=this.eventListeners.get(e);s&&s.forEach(e=>e(t))}async connectWalletConnect(e){const t=this.getWalletConnectConnector();return{clientId:(await t.connectWalletConnect()).clientId}}async switchNetwork(e){const{caipNetwork:t,providerType:s}=e;if(!e.provider)return;const i="provider"in e.provider?e.provider.provider:e.provider;if("WALLET_CONNECT"!==s){if(i&&"AUTH"===s){const e=i;await e.switchNetwork(t.caipNetworkId);const s=await e.getUser({chainId:t.caipNetworkId,preferredAccountType:n.H.state.defaultAccountTypes[t.chainNamespace]});this.emit("switchNetwork",s)}}else i.setDefaultChain(t.caipNetworkId)}getWalletConnectConnector(){const e=this.connectors.find(e=>e instanceof a.F);if(!e)throw new Error("WalletConnectConnector not found");return e}}},33937:(e,t,s)=>{s.d(t,{t:()=>i});const i=(0,s(40149).x)({id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!1,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",deprecatedCaipNetworkId:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ"})},35842:(e,t,s)=>{s.d(t,{AH:()=>i.AH,JW:()=>i.JW,WF:()=>i.WF,iz:()=>i.iz,qy:()=>i.qy}),s(58207),s(80181);var i=s(46477)},36641:(e,t,s)=>{s.d(t,{T:()=>r});var i=s(88612);const r={createBalance(e,t){const s={name:e.metadata.name||"",symbol:e.metadata.symbol||"",decimals:e.metadata.decimals||0,value:e.metadata.value||0,price:e.metadata.price||0,iconUrl:e.metadata.iconUrl||""};return{name:s.name,symbol:s.symbol,chainId:t,address:"native"===e.address?void 0:this.convertAddressToCAIP10Address(e.address,t),value:s.value,price:s.price,quantity:{decimals:s.decimals.toString(),numeric:this.convertHexToBalance({hex:e.balance,decimals:s.decimals})},iconUrl:s.iconUrl}},convertHexToBalance:({hex:e,decimals:t})=>(0,i.J)(BigInt(e),t),convertAddressToCAIP10Address:(e,t)=>`${t}:${e}`,createCAIP2ChainId:(e,t)=>`${t}:${parseInt(e,16)}`,getChainIdHexFromCAIP2ChainId(e){const t=e.split(":");if(t.length<2||!t[1])return"0x0";const s=t[1],i=parseInt(s,10);return isNaN(i)?"0x0":`0x${i.toString(16)}`},isWalletGetAssetsResponse(e){return"object"==typeof e&&null!==e&&Object.values(e).every(e=>Array.isArray(e)&&e.every(e=>this.isValidAsset(e)))},isValidAsset:e=>"object"==typeof e&&null!==e&&"string"==typeof e.address&&"string"==typeof e.balance&&("ERC20"===e.type||"NATIVE"===e.type)&&"object"==typeof e.metadata&&null!==e.metadata&&"string"==typeof e.metadata.name&&"string"==typeof e.metadata.symbol&&"number"==typeof e.metadata.decimals&&"number"==typeof e.metadata.price&&"string"==typeof e.metadata.iconUrl}},37876:(e,t,s)=>{s.d(t,{Ay:()=>K});var i=s(98752),r=s(70255),n=s(21910),o=s(91315),a=s(43039),c=s(50046),h=s.n(c),l=s(14350);const p="client",d=`wc@2:${p}:`,u=p,g="WALLETCONNECT_DEEPLINK_CHOICE",f="Proposal expired",m=o.SEVEN_DAYS,w={wc_sessionPropose:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1104},res:{ttl:o.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1106},res:{ttl:o.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1112},res:{ttl:o.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1114},res:{ttl:o.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:o.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:o.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1119}}},y={min:o.FIVE_MINUTES,max:o.SEVEN_DAYS},b="IDLE",v="ACTIVE",E={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},I=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],_="wc@1.5:auth:",N=`${_}:PUB_KEY`;var A=Object.defineProperty,C=Object.defineProperties,P=Object.getOwnPropertyDescriptors,S=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,k=(e,t,s)=>t in e?A(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,x=(e,t)=>{for(var s in t||(t={}))O.call(t,s)&&k(e,s,t[s]);if(S)for(var s of S(t))T.call(t,s)&&k(e,s,t[s]);return e},R=(e,t)=>C(e,P(t)),U=(e,t,s)=>k(e,"symbol"!=typeof t?t+"":t,s);class D extends n.yJ{constructor(e){super(e),U(this,"name","engine"),U(this,"events",new(h())),U(this,"initialized",!1),U(this,"requestQueue",{state:b,queue:[]}),U(this,"sessionRequestQueue",{state:b,queue:[]}),U(this,"requestQueueDelay",o.ONE_SECOND),U(this,"expectedPairingMethodMap",new Map),U(this,"recentlyDeletedMap",new Map),U(this,"recentlyDeletedLimit",200),U(this,"relayMessageCache",[]),U(this,"pendingSessions",new Map),U(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(w)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,o.toMiliseconds)(this.requestQueueDelay)))}),U(this,"connect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const t=R(x({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);const{pairingTopic:s,requiredNamespaces:r,optionalNamespaces:n,sessionProperties:c,scopedProperties:h,relays:p}=t;let d,u=s,g=!1;try{if(u){const e=this.client.core.pairing.pairings.get(u);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),g=e.active}}catch(e){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),e}if(!u||!g){const{topic:e,uri:t}=await this.client.core.pairing.create();u=e,d=t}if(!u){const{message:e}=(0,a.GuA)("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(e)}const m=await this.client.core.crypto.generateKeyPair(),y=w.wc_sessionPropose.req.ttl||o.FIVE_MINUTES,b=(0,a.Xw0)(y),v=R(x(x({requiredNamespaces:r,optionalNamespaces:n,relays:p??[{protocol:i.sD}],proposer:{publicKey:m,metadata:this.client.metadata},expiryTimestamp:b,pairingTopic:u},c&&{sessionProperties:c}),h&&{scopedProperties:h}),{id:(0,l.payloadId)()}),E=(0,a.hEn)("session_connect",v.id),{reject:I,resolve:_,done:N}=(0,a.Wx8)(y,f),A=({id:e})=>{e===v.id&&(this.client.events.off("proposal_expire",A),this.pendingSessions.delete(v.id),this.events.emit(E,{error:{message:f,code:0}}))};return this.client.events.on("proposal_expire",A),this.events.once(E,({error:e,session:t})=>{this.client.events.off("proposal_expire",A),e?I(e):t&&_(t)}),await this.sendRequest({topic:u,method:"wc_sessionPropose",params:v,throwOnFailedPublish:!0,clientRpcId:v.id}),await this.setProposal(v.id,v),{uri:d,approval:N}}),U(this,"pair",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(e)}catch(e){throw this.client.logger.error("pair() failed"),e}}),U(this,"approve",async e=>{var t,s,r;const n=this.client.core.eventClient.createEvent({properties:{topic:null==(t=e?.id)?void 0:t.toString(),trace:[i.$I.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(e){throw n.setError(i.U.no_internet_connection),e}try{await this.isValidProposalId(e?.id)}catch(t){throw this.client.logger.error(`approve() -> proposal.get(${e?.id}) failed`),n.setError(i.U.proposal_not_found),t}try{await this.isValidApprove(e)}catch(e){throw this.client.logger.error("approve() -> isValidApprove() failed"),n.setError(i.U.session_approve_namespace_validation_failure),e}const{id:o,relayProtocol:c,namespaces:h,sessionProperties:l,scopedProperties:p,sessionConfig:d}=e,u=this.client.proposal.get(o);this.client.core.eventClient.deleteEvent({eventId:n.eventId});const{pairingTopic:g,proposer:f,requiredNamespaces:w,optionalNamespaces:y}=u;let b=null==(s=this.client.core.eventClient)?void 0:s.getEvent({topic:g});b||(b=null==(r=this.client.core.eventClient)?void 0:r.createEvent({type:i.$I.session_approve_started,properties:{topic:g,trace:[i.$I.session_approve_started,i.$I.session_namespaces_validation_success]}}));const v=await this.client.core.crypto.generateKeyPair(),E=f.publicKey,I=await this.client.core.crypto.generateSharedKey(v,E),_=x(x(x({relay:{protocol:c??"irn"},namespaces:h,controller:{publicKey:v,metadata:this.client.metadata},expiry:(0,a.Xw0)(m)},l&&{sessionProperties:l}),p&&{scopedProperties:p}),d&&{sessionConfig:d}),N=i.cV.relay;b.addTrace(i.$I.subscribing_session_topic);try{await this.client.core.relayer.subscribe(I,{transportType:N})}catch(e){throw b.setError(i.U.subscribe_session_topic_failure),e}b.addTrace(i.$I.subscribe_session_topic_success);const A=R(x({},_),{topic:I,requiredNamespaces:w,optionalNamespaces:y,pairingTopic:g,acknowledged:!1,self:_.controller,peer:{publicKey:f.publicKey,metadata:f.metadata},controller:v,transportType:i.cV.relay});await this.client.session.set(I,A),b.addTrace(i.$I.store_session);try{b.addTrace(i.$I.publishing_session_settle),await this.sendRequest({topic:I,method:"wc_sessionSettle",params:_,throwOnFailedPublish:!0}).catch(e=>{throw b?.setError(i.U.session_settle_publish_failure),e}),b.addTrace(i.$I.session_settle_publish_success),b.addTrace(i.$I.publishing_session_approve),await this.sendResult({id:o,topic:g,result:{relay:{protocol:c??"irn"},responderPublicKey:v},throwOnFailedPublish:!0}).catch(e=>{throw b?.setError(i.U.session_approve_publish_failure),e}),b.addTrace(i.$I.session_approve_publish_success)}catch(e){throw this.client.logger.error(e),this.client.session.delete(I,(0,a.Hjj)("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(I),e}return this.client.core.eventClient.deleteEvent({eventId:b.eventId}),await this.client.core.pairing.updateMetadata({topic:g,metadata:f.metadata}),await this.client.proposal.delete(o,(0,a.Hjj)("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:g}),await this.setExpiry(I,(0,a.Xw0)(m)),{topic:I,acknowledged:()=>Promise.resolve(this.client.session.get(I))}}),U(this,"reject",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(e)}catch(e){throw this.client.logger.error("reject() -> isValidReject() failed"),e}const{id:t,reason:s}=e;let i;try{i=this.client.proposal.get(t).pairingTopic}catch(e){throw this.client.logger.error(`reject() -> proposal.get(${t}) failed`),e}i&&(await this.sendError({id:t,topic:i,error:s,rpcOpts:w.wc_sessionPropose.reject}),await this.client.proposal.delete(t,(0,a.Hjj)("USER_DISCONNECTED")))}),U(this,"update",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(e)}catch(e){throw this.client.logger.error("update() -> isValidUpdate() failed"),e}const{topic:t,namespaces:s}=e,{done:i,resolve:r,reject:n}=(0,a.Wx8)(),o=(0,l.payloadId)(),c=(0,l.getBigIntRpcId)().toString(),h=this.client.session.get(t).namespaces;return this.events.once((0,a.hEn)("session_update",o),({error:e})=>{e?n(e):r()}),await this.client.session.update(t,{namespaces:s}),await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:s},throwOnFailedPublish:!0,clientRpcId:o,relayRpcId:c}).catch(e=>{this.client.logger.error(e),this.client.session.update(t,{namespaces:h}),n(e)}),{acknowledged:i}}),U(this,"extend",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(e)}catch(e){throw this.client.logger.error("extend() -> isValidExtend() failed"),e}const{topic:t}=e,s=(0,l.payloadId)(),{done:i,resolve:r,reject:n}=(0,a.Wx8)();return this.events.once((0,a.hEn)("session_extend",s),({error:e})=>{e?n(e):r()}),await this.setExpiry(t,(0,a.Xw0)(m)),this.sendRequest({topic:t,method:"wc_sessionExtend",params:{},clientRpcId:s,throwOnFailedPublish:!0}).catch(e=>{n(e)}),{acknowledged:i}}),U(this,"request",async e=>{this.isInitialized();try{await this.isValidRequest(e)}catch(e){throw this.client.logger.error("request() -> isValidRequest() failed"),e}const{chainId:t,request:s,topic:r,expiry:n=w.wc_sessionRequest.req.ttl}=e,o=this.client.session.get(r);o?.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const c=(0,l.payloadId)(),h=(0,l.getBigIntRpcId)().toString(),{done:p,resolve:d,reject:u}=(0,a.Wx8)(n,"Request expired. Please try again.");this.events.once((0,a.hEn)("session_request",c),({error:e,result:t})=>{e?u(e):d(t)});const f="wc_sessionRequest",m=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);if(m)return await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:r,method:f,params:{request:R(x({},s),{expiryTimestamp:(0,a.Xw0)(n)}),chainId:t},expiry:n,throwOnFailedPublish:!0,appLink:m}).catch(e=>u(e)),this.client.events.emit("session_request_sent",{topic:r,request:s,chainId:t,id:c}),await p();const y={request:R(x({},s),{expiryTimestamp:(0,a.Xw0)(n)}),chainId:t},b=this.shouldSetTVF(f,y);return await Promise.all([new Promise(async e=>{await this.sendRequest(x({clientRpcId:c,relayRpcId:h,topic:r,method:f,params:y,expiry:n,throwOnFailedPublish:!0},b&&{tvf:this.getTVFParams(c,y)})).catch(e=>u(e)),this.client.events.emit("session_request_sent",{topic:r,request:s,chainId:t,id:c}),e()}),new Promise(async e=>{var t;if(null==(t=o.sessionConfig)||!t.disableDeepLink){const e=await(0,a.jTh)(this.client.core.storage,g);await(0,a.n3s)({id:c,topic:r,wcDeepLink:e})}e()}),p()]).then(e=>e[2])}),U(this,"respond",async e=>{this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:s}=e,{id:r}=s,n=this.client.session.get(t);n.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const o=this.getAppLinkIfEnabled(n.peer.metadata,n.transportType);(0,l.isJsonRpcResult)(s)?await this.sendResult({id:r,topic:t,result:s.result,throwOnFailedPublish:!0,appLink:o}):(0,l.isJsonRpcError)(s)&&await this.sendError({id:r,topic:t,error:s.error,appLink:o}),this.cleanupAfterResponse(e)}),U(this,"ping",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(e)}catch(e){throw this.client.logger.error("ping() -> isValidPing() failed"),e}const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=(0,l.payloadId)(),s=(0,l.getBigIntRpcId)().toString(),{done:i,resolve:r,reject:n}=(0,a.Wx8)();this.events.once((0,a.hEn)("session_ping",e),({error:e})=>{e?n(e):r()}),await Promise.all([this.sendRequest({topic:t,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:e,relayRpcId:s}),i()])}else this.client.core.pairing.pairings.keys.includes(t)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:t}))}),U(this,"emit",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(e);const{topic:t,event:s,chainId:i}=e,r=(0,l.getBigIntRpcId)().toString(),n=(0,l.payloadId)();await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:s,chainId:i},throwOnFailedPublish:!0,relayRpcId:r,clientRpcId:n})}),U(this,"disconnect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(e);const{topic:t}=e;if(this.client.session.keys.includes(t))await this.sendRequest({topic:t,method:"wc_sessionDelete",params:(0,a.Hjj)("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:t,emitEvent:!1});else{if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=(0,a.GuA)("MISMATCHED_TOPIC",`Session or pairing topic not found: ${t}`);throw new Error(e)}await this.client.core.pairing.disconnect({topic:t})}}),U(this,"find",e=>(this.isInitialized(),this.client.session.getAll().filter(t=>(0,a.HNf)(t,e)))),U(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),U(this,"authenticate",async(e,t)=>{var s;this.isInitialized(),this.isValidAuthenticate(e);const r=t&&this.client.core.linkModeSupportedApps.includes(t)&&(null==(s=this.client.metadata.redirect)?void 0:s.linkMode),n=r?i.cV.link_mode:i.cV.relay;n===i.cV.relay&&await this.confirmOnlineStateOrThrow();const{chains:o,statement:c="",uri:h,domain:p,nonce:d,type:u,exp:g,nbf:f,methods:y=[],expiry:b}=e,v=[...e.resources||[]],{topic:E,uri:I}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:n});this.client.logger.info({message:"Generated new pairing",pairing:{topic:E,uri:I}});const _=await this.client.core.crypto.generateKeyPair(),A=(0,a.EN$)(_);if(await Promise.all([this.client.auth.authKeys.set(N,{responseTopic:A,publicKey:_}),this.client.auth.pairingTopics.set(A,{topic:A,pairingTopic:E})]),await this.client.core.relayer.subscribe(A,{transportType:n}),this.client.logger.info(`sending request to new pairing topic: ${E}`),y.length>0){const{namespace:e}=(0,a._Yb)(o[0]);let t=(0,a.e8_)(e,"request",y);(0,a.VBM)(v)&&(t=(0,a.hVC)(t,v.pop())),v.push(t)}const C=b&&b>w.wc_sessionAuthenticate.req.ttl?b:w.wc_sessionAuthenticate.req.ttl,P={authPayload:{type:u??"caip122",chains:o,statement:c,aud:h,domain:p,version:"1",nonce:d,iat:(new Date).toISOString(),exp:g,nbf:f,resources:v},requester:{publicKey:_,metadata:this.client.metadata},expiryTimestamp:(0,a.Xw0)(C)},S={requiredNamespaces:{},optionalNamespaces:{eip155:{chains:o,methods:[...new Set(["personal_sign",...y])],events:["chainChanged","accountsChanged"]}},relays:[{protocol:"irn"}],pairingTopic:E,proposer:{publicKey:_,metadata:this.client.metadata},expiryTimestamp:(0,a.Xw0)(w.wc_sessionPropose.req.ttl),id:(0,l.payloadId)()},{done:O,resolve:T,reject:k}=(0,a.Wx8)(C,"Request expired"),U=(0,l.payloadId)(),D=(0,a.hEn)("session_connect",S.id),j=(0,a.hEn)("session_request",U),M=async({error:e,session:t})=>{this.events.off(j,L),e?k(e):t&&T({session:t})},L=async e=>{var s,r,o;if(await this.deletePendingAuthRequest(U,{message:"fulfilled",code:0}),e.error){const t=(0,a.Hjj)("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return e.error.code===t.code?void 0:(this.events.off(D,M),k(e.error.message))}await this.deleteProposal(S.id),this.events.off(D,M);const{cacaos:c,responder:h}=e.result,l=[],p=[];for(const e of c){await(0,a.IjX)({cacao:e,projectId:this.client.core.projectId})||(this.client.logger.error(e,"Signature verification failed"),k((0,a.Hjj)("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:t}=e,s=(0,a.VBM)(t.resources),i=[(0,a.xkc)(t.iss)],r=(0,a.q_h)(t.iss);if(s){const e=(0,a.sc_)(s),t=(0,a.WWN)(s);l.push(...e),i.push(...t)}for(const e of i)p.push(`${e}:${r}`)}const d=await this.client.core.crypto.generateSharedKey(_,h.publicKey);let u;l.length>0&&(u={topic:d,acknowledged:!0,self:{publicKey:_,metadata:this.client.metadata},peer:h,controller:h.publicKey,expiry:(0,a.Xw0)(m),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:E,namespaces:(0,a.Van)([...new Set(l)],[...new Set(p)]),transportType:n},await this.client.core.relayer.subscribe(d,{transportType:n}),await this.client.session.set(d,u),E&&await this.client.core.pairing.updateMetadata({topic:E,metadata:h.metadata}),u=this.client.session.get(d)),null!=(s=this.client.metadata.redirect)&&s.linkMode&&null!=(r=h.metadata.redirect)&&r.linkMode&&null!=(o=h.metadata.redirect)&&o.universal&&t&&(this.client.core.addLinkModeSupportedApp(h.metadata.redirect.universal),this.client.session.update(d,{transportType:i.cV.link_mode})),T({auths:c,session:u})};let q;this.events.once(D,M),this.events.once(j,L);try{if(r){const e=(0,l.formatJsonRpcRequest)("wc_sessionAuthenticate",P,U);this.client.core.history.set(E,e);const s=await this.client.core.crypto.encode("",e,{type:a.EHS,encoding:a.Pa8});q=(0,a.$Bq)(t,E,s)}else await Promise.all([this.sendRequest({topic:E,method:"wc_sessionAuthenticate",params:P,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:U}),this.sendRequest({topic:E,method:"wc_sessionPropose",params:S,expiry:w.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:S.id})])}catch(e){throw this.events.off(D,M),this.events.off(j,L),e}return await this.setProposal(S.id,S),await this.setAuthRequest(U,{request:R(x({},P),{verifyContext:{}}),pairingTopic:E,transportType:n}),{uri:q??I,response:O}}),U(this,"approveSessionAuthenticate",async e=>{const{id:t,auths:s}=e,r=this.client.core.eventClient.createEvent({properties:{topic:t.toString(),trace:[i.U$.authenticated_session_approve_started]}});try{this.isInitialized()}catch(e){throw r.setError(i.Tn.no_internet_connection),e}const n=this.getPendingAuthRequest(t);if(!n)throw r.setError(i.Tn.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${t}`);const o=n.transportType||i.cV.relay;o===i.cV.relay&&await this.confirmOnlineStateOrThrow();const c=n.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),l=(0,a.EN$)(c),p={type:a.Lp_,receiverPublicKey:c,senderPublicKey:h},d=[],u=[];for(const e of s){if(!await(0,a.IjX)({cacao:e,projectId:this.client.core.projectId})){r.setError(i.Tn.invalid_cacao);const e=(0,a.Hjj)("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:t,topic:l,error:e,encodeOpts:p}),new Error(e.message)}r.addTrace(i.U$.cacaos_verified);const{p:s}=e,n=(0,a.VBM)(s.resources),o=[(0,a.xkc)(s.iss)],c=(0,a.q_h)(s.iss);if(n){const e=(0,a.sc_)(n),t=(0,a.WWN)(n);d.push(...e),o.push(...t)}for(const e of o)u.push(`${e}:${c}`)}const g=await this.client.core.crypto.generateSharedKey(h,c);let f;if(r.addTrace(i.U$.create_authenticated_session_topic),d?.length>0){f={topic:g,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:c,metadata:n.requester.metadata},controller:c,expiry:(0,a.Xw0)(m),authentication:s,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:n.pairingTopic,namespaces:(0,a.Van)([...new Set(d)],[...new Set(u)]),transportType:o},r.addTrace(i.U$.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(g,{transportType:o})}catch(e){throw r.setError(i.Tn.subscribe_authenticated_session_topic_failure),e}r.addTrace(i.U$.subscribe_authenticated_session_topic_success),await this.client.session.set(g,f),r.addTrace(i.U$.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:n.pairingTopic,metadata:n.requester.metadata})}r.addTrace(i.U$.publishing_authenticated_session_approve);try{await this.sendResult({topic:l,id:t,result:{cacaos:s,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:p,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(n.requester.metadata,o)})}catch(e){throw r.setError(i.Tn.authenticated_session_approve_publish_failure),e}return await this.client.auth.requests.delete(t,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:n.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:r.eventId}),{session:f}}),U(this,"rejectSessionAuthenticate",async e=>{this.isInitialized();const{id:t,reason:s}=e,r=this.getPendingAuthRequest(t);if(!r)throw new Error(`Could not find pending auth request with id ${t}`);r.transportType===i.cV.relay&&await this.confirmOnlineStateOrThrow();const n=r.requester.publicKey,o=await this.client.core.crypto.generateKeyPair(),c=(0,a.EN$)(n),h={type:a.Lp_,receiverPublicKey:n,senderPublicKey:o};await this.sendError({id:t,topic:c,error:s,encodeOpts:h,rpcOpts:w.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(r.requester.metadata,r.transportType)}),await this.client.auth.requests.delete(t,{message:"rejected",code:0}),await this.client.proposal.delete(t,(0,a.Hjj)("USER_DISCONNECTED"))}),U(this,"formatAuthMessage",e=>{this.isInitialized();const{request:t,iss:s}=e;return(0,a.hwK)(t,s)}),U(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(0!==this.relayMessageCache.length)for(;this.relayMessageCache.length>0;)try{const e=this.relayMessageCache.shift();e&&await this.onRelayMessage(e)}catch(e){this.client.logger.error(e)}},50)}),U(this,"cleanupDuplicatePairings",async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.pairingTopic),s=this.client.core.pairing.pairings.getAll().filter(s=>{var i,r;return(null==(i=s.peerMetadata)?void 0:i.url)&&(null==(r=s.peerMetadata)?void 0:r.url)===e.peer.metadata.url&&s.topic&&s.topic!==t.topic});if(0===s.length)return;this.client.logger.info(`Cleaning up ${s.length} duplicate pairing(s)`),await Promise.all(s.map(e=>this.client.core.pairing.disconnect({topic:e.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}}),U(this,"deleteSession",async e=>{var t;const{topic:s,expirerHasDeleted:i=!1,emitEvent:r=!0,id:n=0}=e,{self:o}=this.client.session.get(s);await this.client.core.relayer.unsubscribe(s),await this.client.session.delete(s,(0,a.Hjj)("USER_DISCONNECTED")),this.addToRecentlyDeleted(s,"session"),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(s)&&await this.client.core.crypto.deleteSymKey(s),i||this.client.core.expirer.del(s),this.client.core.storage.removeItem(g).catch(e=>this.client.logger.warn(e)),this.getPendingSessionRequests().forEach(e=>{e.topic===s&&this.deletePendingSessionRequest(e.id,(0,a.Hjj)("USER_DISCONNECTED"))}),s===(null==(t=this.sessionRequestQueue.queue[0])?void 0:t.topic)&&(this.sessionRequestQueue.state=b),r&&this.client.events.emit("session_delete",{id:n,topic:s})}),U(this,"deleteProposal",async(e,t)=>{if(t)try{const t=this.client.proposal.get(e),s=this.client.core.eventClient.getEvent({topic:t.pairingTopic});s?.setError(i.U.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(e,(0,a.Hjj)("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")}),U(this,"deletePendingSessionRequest",async(e,t,s=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,t),s?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(t=>t.id!==e),s&&(this.sessionRequestQueue.state=b,this.client.events.emit("session_request_expire",{id:e}))}),U(this,"deletePendingAuthRequest",async(e,t,s=!1)=>{await Promise.all([this.client.auth.requests.delete(e,t),s?Promise.resolve():this.client.core.expirer.del(e)])}),U(this,"setExpiry",async(e,t)=>{this.client.session.keys.includes(e)&&(this.client.core.expirer.set(e,t),await this.client.session.update(e,{expiry:t}))}),U(this,"setProposal",async(e,t)=>{this.client.core.expirer.set(e,(0,a.Xw0)(w.wc_sessionPropose.req.ttl)),await this.client.proposal.set(e,t)}),U(this,"setAuthRequest",async(e,t)=>{const{request:s,pairingTopic:r,transportType:n=i.cV.relay}=t;this.client.core.expirer.set(e,s.expiryTimestamp),await this.client.auth.requests.set(e,{authPayload:s.authPayload,requester:s.requester,expiryTimestamp:s.expiryTimestamp,id:e,pairingTopic:r,verifyContext:s.verifyContext,transportType:n})}),U(this,"setPendingSessionRequest",async e=>{const{id:t,topic:s,params:i,verifyContext:r}=e,n=i.request.expiryTimestamp||(0,a.Xw0)(w.wc_sessionRequest.req.ttl);this.client.core.expirer.set(t,n),await this.client.pendingRequest.set(t,{id:t,topic:s,params:i,verifyContext:r})}),U(this,"sendRequest",async e=>{const{topic:t,method:i,params:r,expiry:n,relayRpcId:o,clientRpcId:c,throwOnFailedPublish:h,appLink:p,tvf:d}=e,u=(0,l.formatJsonRpcRequest)(i,r,c);let g;const f=!!p;try{const e=f?a.Pa8:a.EWt;g=await this.client.core.crypto.encode(t,u,{encoding:e})}catch(e){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${t} failed`),e}let m;if(I.includes(i)){const e=(0,a.ALl)(JSON.stringify(u)),t=(0,a.ALl)(g);m=await this.client.core.verify.register({id:t,decryptedId:e})}const y=w[i].req;if(y.attestation=m,n&&(y.ttl=n),o&&(y.id=o),this.client.core.history.set(t,u),f){const e=(0,a.$Bq)(p,t,g);await s.g.Linking.openURL(e,this.client.name)}else{const e=w[i].req;n&&(e.ttl=n),o&&(e.id=o),e.tvf=R(x({},d),{correlationId:u.id}),h?(e.internal=R(x({},e.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,g,e)):this.client.core.relayer.publish(t,g,e).catch(e=>this.client.logger.error(e))}return u.id}),U(this,"sendResult",async e=>{const{id:t,topic:i,result:r,throwOnFailedPublish:n,encodeOpts:o,appLink:c}=e,h=(0,l.formatJsonRpcResult)(t,r);let p;const d=c&&typeof(null==s.g?void 0:s.g.Linking)<"u";try{const e=d?a.Pa8:a.EWt;p=await this.client.core.crypto.encode(i,h,R(x({},o||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${i} failed`),e}let u,g;try{u=await this.client.core.history.get(i,t);const e=u.request;try{this.shouldSetTVF(e.method,e.params)&&(g=this.getTVFParams(t,e.params,r))}catch(e){this.client.logger.warn("sendResult() -> getTVFParams() failed",e)}}catch(e){throw this.client.logger.error(`sendResult() -> history.get(${i}, ${t}) failed`),e}if(d){const e=(0,a.$Bq)(c,i,p);await s.g.Linking.openURL(e,this.client.name)}else{const e=u.request.method,s=w[e].res;s.tvf=R(x({},g),{correlationId:t}),n?(s.internal=R(x({},s.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,p,s)):this.client.core.relayer.publish(i,p,s).catch(e=>this.client.logger.error(e))}await this.client.core.history.resolve(h)}),U(this,"sendError",async e=>{const{id:t,topic:i,error:r,encodeOpts:n,rpcOpts:o,appLink:c}=e,h=(0,l.formatJsonRpcError)(t,r);let p;const d=c&&typeof(null==s.g?void 0:s.g.Linking)<"u";try{const e=d?a.Pa8:a.EWt;p=await this.client.core.crypto.encode(i,h,R(x({},n||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${i} failed`),e}let u;try{u=await this.client.core.history.get(i,t)}catch(e){throw this.client.logger.error(`sendError() -> history.get(${i}, ${t}) failed`),e}if(d){const e=(0,a.$Bq)(c,i,p);await s.g.Linking.openURL(e,this.client.name)}else{const e=u.request.method,t=o||w[e].res;this.client.core.relayer.publish(i,p,t)}await this.client.core.history.resolve(h)}),U(this,"cleanup",async()=>{const e=[],t=[];this.client.session.getAll().forEach(t=>{let s=!1;(0,a._dF)(t.expiry)&&(s=!0),this.client.core.crypto.keychain.has(t.topic)||(s=!0),s&&e.push(t.topic)}),this.client.proposal.getAll().forEach(e=>{(0,a._dF)(e.expiryTimestamp)&&t.push(e.id)}),await Promise.all([...e.map(e=>this.deleteSession({topic:e})),...t.map(e=>this.deleteProposal(e))])}),U(this,"onProviderMessageEvent",async e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):await this.onRelayMessage(e)}),U(this,"onRelayEventRequest",async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()}),U(this,"processRequestsQueue",async()=>{if(this.requestQueue.state!==v){for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=v;const e=this.requestQueue.queue.shift();if(e)try{await this.processRequest(e)}catch(e){this.client.logger.warn(e)}}this.requestQueue.state=b}else this.client.logger.info("Request queue already active, skipping...")}),U(this,"processRequest",async e=>{const{topic:t,payload:s,attestation:i,transportType:r,encryptedId:n}=e,o=s.method;if(!this.shouldIgnorePairingRequest({topic:t,requestMethod:o}))switch(o){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:t,payload:s,attestation:i,encryptedId:n});case"wc_sessionSettle":return await this.onSessionSettleRequest(t,s);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(t,s);case"wc_sessionExtend":return await this.onSessionExtendRequest(t,s);case"wc_sessionPing":return await this.onSessionPingRequest(t,s);case"wc_sessionDelete":return await this.onSessionDeleteRequest(t,s);case"wc_sessionRequest":return await this.onSessionRequest({topic:t,payload:s,attestation:i,encryptedId:n,transportType:r});case"wc_sessionEvent":return await this.onSessionEventRequest(t,s);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:t,payload:s,attestation:i,encryptedId:n,transportType:r});default:return this.client.logger.info(`Unsupported request method ${o}`)}}),U(this,"onRelayEventResponse",async e=>{const{topic:t,payload:s,transportType:i}=e,r=(await this.client.core.history.get(t,s.id)).request.method;switch(r){case"wc_sessionPropose":return this.onSessionProposeResponse(t,s,i);case"wc_sessionSettle":return this.onSessionSettleResponse(t,s);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,s);case"wc_sessionExtend":return this.onSessionExtendResponse(t,s);case"wc_sessionPing":return this.onSessionPingResponse(t,s);case"wc_sessionRequest":return this.onSessionRequestResponse(t,s);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(t,s);default:return this.client.logger.info(`Unsupported response method ${r}`)}}),U(this,"onRelayEventUnknownPayload",e=>{const{topic:t}=e,{message:s}=(0,a.GuA)("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(s)}),U(this,"shouldIgnorePairingRequest",e=>{const{topic:t,requestMethod:s}=e,i=this.expectedPairingMethodMap.get(t);return!(!i||i.includes(s)||!(i.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0))}),U(this,"onSessionProposeRequest",async e=>{const{topic:t,payload:s,attestation:r,encryptedId:n}=e,{params:o,id:c}=s;try{const e=this.client.core.eventClient.getEvent({topic:t});0===this.client.events.listenerCount("session_proposal")&&(console.warn("No listener for session_proposal event"),e?.setError(i.S$.proposal_listener_not_found)),this.isValidConnect(x({},s.params));const h=o.expiryTimestamp||(0,a.Xw0)(w.wc_sessionPropose.req.ttl),l=x({id:c,pairingTopic:t,expiryTimestamp:h},o);await this.setProposal(c,l);const p=await this.getVerifyContext({attestationId:r,hash:(0,a.ALl)(JSON.stringify(s)),encryptedId:n,metadata:l.proposer.metadata});e?.addTrace(i.$w.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:l,verifyContext:p})}catch(e){await this.sendError({id:c,topic:t,error:e,rpcOpts:w.wc_sessionPropose.autoReject}),this.client.logger.error(e)}}),U(this,"onSessionProposeResponse",async(e,t,s)=>{const{id:i}=t;if((0,l.isJsonRpcResult)(t)){const{result:r}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:r});const n=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const o=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const a=r.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});const c=await this.client.core.crypto.generateSharedKey(o,a);this.pendingSessions.set(i,{sessionTopic:c,pairingTopic:e,proposalId:i,publicKey:o});const h=await this.client.core.relayer.subscribe(c,{transportType:s});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:e})}else if((0,l.isJsonRpcError)(t)){await this.client.proposal.delete(i,(0,a.Hjj)("USER_DISCONNECTED"));const e=(0,a.hEn)("session_connect",i);if(0===this.events.listenerCount(e))throw new Error(`emitting ${e} without any listeners, 954`);this.events.emit(e,{error:t.error})}}),U(this,"onSessionSettleRequest",async(e,t)=>{const{id:s,params:r}=t;try{this.isValidSessionSettleRequest(r);const{relay:s,controller:n,expiry:o,namespaces:c,sessionProperties:h,scopedProperties:l,sessionConfig:p}=t.params,d=[...this.pendingSessions.values()].find(t=>t.sessionTopic===e);if(!d)return this.client.logger.error(`Pending session not found for topic ${e}`);const u=this.client.proposal.get(d.proposalId),g=R(x(x(x({topic:e,relay:s,expiry:o,namespaces:c,acknowledged:!0,pairingTopic:d.pairingTopic,requiredNamespaces:u.requiredNamespaces,optionalNamespaces:u.optionalNamespaces,controller:n.publicKey,self:{publicKey:d.publicKey,metadata:this.client.metadata},peer:{publicKey:n.publicKey,metadata:n.metadata}},h&&{sessionProperties:h}),l&&{scopedProperties:l}),p&&{sessionConfig:p}),{transportType:i.cV.relay});await this.client.session.set(g.topic,g),await this.setExpiry(g.topic,g.expiry),await this.client.core.pairing.updateMetadata({topic:d.pairingTopic,metadata:g.peer.metadata}),this.client.events.emit("session_connect",{session:g}),this.events.emit((0,a.hEn)("session_connect",d.proposalId),{session:g}),this.pendingSessions.delete(d.proposalId),this.deleteProposal(d.proposalId,!1),this.cleanupDuplicatePairings(g),await this.sendResult({id:t.id,topic:e,result:!0,throwOnFailedPublish:!0})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"onSessionSettleResponse",async(e,t)=>{const{id:s}=t;(0,l.isJsonRpcResult)(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit((0,a.hEn)("session_approve",s),{})):(0,l.isJsonRpcError)(t)&&(await this.client.session.delete(e,(0,a.Hjj)("USER_DISCONNECTED")),this.events.emit((0,a.hEn)("session_approve",s),{error:t.error}))}),U(this,"onSessionUpdateRequest",async(e,t)=>{const{params:s,id:i}=t;try{const t=`${e}_session_update`,r=a.nyL.get(t);if(r&&this.isRequestOutOfSync(r,i))return this.client.logger.warn(`Discarding out of sync request - ${i}`),void this.sendError({id:i,topic:e,error:(0,a.Hjj)("INVALID_UPDATE_REQUEST")});this.isValidUpdate(x({topic:e},s));try{a.nyL.set(t,i),await this.client.session.update(e,{namespaces:s.namespaces}),await this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0})}catch(e){throw a.nyL.delete(t),e}this.client.events.emit("session_update",{id:i,topic:e,params:s})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"isRequestOutOfSync",(e,t)=>t.toString().slice(0,-3)<e.toString().slice(0,-3)),U(this,"onSessionUpdateResponse",(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_update",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_update",s),{}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_update",s),{error:t.error})}),U(this,"onSessionExtendRequest",async(e,t)=>{const{id:s}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,(0,a.Xw0)(m)),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:s,topic:e})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"onSessionExtendResponse",(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_extend",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_extend",s),{}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_extend",s),{error:t.error})}),U(this,"onSessionPingRequest",async(e,t)=>{const{id:s}=t;try{this.isValidPing({topic:e}),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:s,topic:e})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"onSessionPingResponse",(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_ping",s);setTimeout(()=>{if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners 2176`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_ping",s),{}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_ping",s),{error:t.error})},500)}),U(this,"onSessionDeleteRequest",async(e,t)=>{const{id:s}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),Promise.all([new Promise(t=>{this.client.core.relayer.once(i.Jf.publish,async()=>{t(await this.deleteSession({topic:e,id:s}))})}),this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:(0,a.Hjj)("USER_DISCONNECTED")})]).catch(e=>this.client.logger.error(e))}catch(e){this.client.logger.error(e)}}),U(this,"onSessionRequest",async e=>{var t,s,r;const{topic:n,payload:o,attestation:c,encryptedId:h,transportType:p}=e,{id:d,params:u}=o;try{await this.isValidRequest(x({topic:n},u));const e=this.client.session.get(n),o={id:d,topic:n,params:u,verifyContext:await this.getVerifyContext({attestationId:c,hash:(0,a.ALl)(JSON.stringify((0,l.formatJsonRpcRequest)("wc_sessionRequest",u,d))),encryptedId:h,metadata:e.peer.metadata,transportType:p})};await this.setPendingSessionRequest(o),p===i.cV.link_mode&&null!=(t=e.peer.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(null==(s=e.peer.metadata.redirect)?void 0:s.universal),null!=(r=this.client.signConfig)&&r.disableRequestQueue?this.emitSessionRequest(o):(this.addSessionRequestToSessionRequestQueue(o),this.processSessionRequestQueue())}catch(e){await this.sendError({id:d,topic:n,error:e}),this.client.logger.error(e)}}),U(this,"onSessionRequestResponse",(e,t)=>{const{id:s}=t,i=(0,a.hEn)("session_request",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_request",s),{result:t.result}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_request",s),{error:t.error})}),U(this,"onSessionEventRequest",async(e,t)=>{const{id:s,params:i}=t;try{const t=`${e}_session_event_${i.event.name}`,r=a.nyL.get(t);if(r&&this.isRequestOutOfSync(r,s))return void this.client.logger.info(`Discarding out of sync request - ${s}`);this.isValidEmit(x({topic:e},i)),this.client.events.emit("session_event",{id:s,topic:e,params:i}),a.nyL.set(t,s)}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),U(this,"onSessionAuthenticateResponse",(e,t)=>{const{id:s}=t;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:t}),(0,l.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_request",s),{result:t.result}):(0,l.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_request",s),{error:t.error})}),U(this,"onSessionAuthenticateRequest",async e=>{var t;const{topic:s,payload:r,attestation:n,encryptedId:o,transportType:c}=e;try{const{requester:e,authPayload:h,expiryTimestamp:l}=r.params,p=await this.getVerifyContext({attestationId:n,hash:(0,a.ALl)(JSON.stringify(r)),encryptedId:o,metadata:e.metadata,transportType:c}),d={requester:e,pairingTopic:s,id:r.id,authPayload:h,verifyContext:p,expiryTimestamp:l};await this.setAuthRequest(r.id,{request:d,pairingTopic:s,transportType:c}),c===i.cV.link_mode&&null!=(t=e.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(e.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:s,params:r.params,id:r.id,verifyContext:p})}catch(e){this.client.logger.error(e);const t=r.params.requester.publicKey,i=await this.client.core.crypto.generateKeyPair(),n=this.getAppLinkIfEnabled(r.params.requester.metadata,c),o={type:a.Lp_,receiverPublicKey:t,senderPublicKey:i};await this.sendError({id:r.id,topic:s,error:e,encodeOpts:o,rpcOpts:w.wc_sessionAuthenticate.autoReject,appLink:n})}}),U(this,"addSessionRequestToSessionRequestQueue",e=>{this.sessionRequestQueue.queue.push(e)}),U(this,"cleanupAfterResponse",e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=b,this.processSessionRequestQueue()},(0,o.toMiliseconds)(this.requestQueueDelay))}),U(this,"cleanupPendingSentRequestsForTopic",({topic:e,error:t})=>{const s=this.client.core.history.pending;s.length>0&&s.filter(t=>t.topic===e&&"wc_sessionRequest"===t.request.method).forEach(e=>{const s=e.request.id,i=(0,a.hEn)("session_request",s);if(0===this.events.listenerCount(i))throw new Error(`emitting ${i} without any listeners`);this.events.emit((0,a.hEn)("session_request",e.request.id),{error:t})})}),U(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===v)return void this.client.logger.info("session request queue is already active.");const e=this.sessionRequestQueue.queue[0];if(e)try{this.sessionRequestQueue.state=v,this.emitSessionRequest(e)}catch(e){this.client.logger.error(e)}else this.client.logger.info("session request queue is empty.")}),U(this,"emitSessionRequest",e=>{this.client.events.emit("session_request",e)}),U(this,"onPairingCreated",e=>{if(e.methods&&this.expectedPairingMethodMap.set(e.topic,e.methods),e.active)return;const t=this.client.proposal.getAll().find(t=>t.pairingTopic===e.topic);t&&this.onSessionProposeRequest({topic:e.topic,payload:(0,l.formatJsonRpcRequest)("wc_sessionPropose",R(x({},t),{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties,scopedProperties:t.scopedProperties}),t.id)})}),U(this,"isValidConnect",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(t)}const{pairingTopic:t,requiredNamespaces:s,optionalNamespaces:i,sessionProperties:r,scopedProperties:n,relays:o}=e;if((0,a.b07)(t)||await this.isValidPairingTopic(t),!(0,a.V9G)(o,!0)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`connect() relays: ${o}`);throw new Error(e)}if(!(0,a.b07)(s)&&0!==(0,a.aF0)(s)&&this.validateNamespaces(s,"requiredNamespaces"),!(0,a.b07)(i)&&0!==(0,a.aF0)(i)&&this.validateNamespaces(i,"optionalNamespaces"),(0,a.b07)(r)||this.validateSessionProps(r,"sessionProperties"),!(0,a.b07)(n)){this.validateSessionProps(n,"scopedProperties");const e=Object.keys(s||{}).concat(Object.keys(i||{}));if(!Object.keys(n).every(t=>e.includes(t)))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(n)}, required/optional namespaces: ${JSON.stringify(e)}`)}}),U(this,"validateNamespaces",(e,t)=>{const s=(0,a.esh)(e,"connect()",t);if(s)throw new Error(s.message)}),U(this,"isValidApprove",async e=>{if(!(0,a.TeY)(e))throw new Error((0,a.GuA)("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:t,namespaces:s,relayProtocol:i,sessionProperties:r,scopedProperties:n}=e;this.checkRecentlyDeleted(t),await this.isValidProposalId(t);const o=this.client.proposal.get(t),c=(0,a.FiO)(s,"approve()");if(c)throw new Error(c.message);const h=(0,a.XqR)(o.requiredNamespaces,s,"approve()");if(h)throw new Error(h.message);if(!(0,a.Qhg)(i,!0)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw new Error(e)}if((0,a.b07)(r)||this.validateSessionProps(r,"sessionProperties"),!(0,a.b07)(n)){this.validateSessionProps(n,"scopedProperties");const e=new Set(Object.keys(s));if(!Object.keys(n).every(t=>e.has(t)))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(n)}, approved namespaces: ${Array.from(e).join(", ")}`)}}),U(this,"isValidReject",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(t)}const{id:t,reason:s}=e;if(this.checkRecentlyDeleted(t),await this.isValidProposalId(t),!(0,a.X3c)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(s)}`);throw new Error(e)}}),U(this,"isValidSessionSettleRequest",e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}const{relay:t,controller:s,namespaces:i,expiry:r}=e;if(!(0,a.kuU)(t)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const n=(0,a.tk0)(s,"onSessionSettleRequest()");if(n)throw new Error(n.message);const o=(0,a.FiO)(i,"onSessionSettleRequest()");if(o)throw new Error(o.message);if((0,a._dF)(r)){const{message:e}=(0,a.GuA)("EXPIRED","onSessionSettleRequest()");throw new Error(e)}}),U(this,"isValidUpdate",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(t)}const{topic:t,namespaces:s}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const i=this.client.session.get(t),r=(0,a.FiO)(s,"update()");if(r)throw new Error(r.message);const n=(0,a.XqR)(i.requiredNamespaces,s,"update()");if(n)throw new Error(n.message)}),U(this,"isValidExtend",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:t}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t)}),U(this,"isValidRequest",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(t)}const{topic:t,request:s,chainId:i,expiry:r}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const{namespaces:n}=this.client.session.get(t);if(!(0,a.tLy)(n,i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() chainId: ${i}`);throw new Error(e)}if(!(0,a.iV1)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() ${JSON.stringify(s)}`);throw new Error(e)}if(!(0,a.oKp)(n,i,s.method)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() method: ${s.method}`);throw new Error(e)}if(r&&!(0,a.Hbs)(r,y)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() expiry: ${r}. Expiry must be a number (in seconds) between ${y.min} and ${y.max}`);throw new Error(e)}}),U(this,"isValidRespond",async e=>{var t;if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:s,response:i}=e;try{await this.isValidSessionTopic(s)}catch(s){throw null!=(t=e?.response)&&t.id&&this.cleanupAfterResponse(e),s}if(!(0,a.M8n)(i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(e)}}),U(this,"isValidPing",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),U(this,"isValidEmit",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(t)}const{topic:t,event:s,chainId:i}=e;await this.isValidSessionTopic(t);const{namespaces:r}=this.client.session.get(t);if(!(0,a.tLy)(r,i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw new Error(e)}if(!(0,a.FR8)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(e)}if(!(0,a.z2N)(r,i,s.name)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(s)}`);throw new Error(e)}}),U(this,"isValidDisconnect",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),U(this,"isValidAuthenticate",e=>{const{chains:t,uri:s,domain:i,nonce:r}=e;if(!Array.isArray(t)||0===t.length)throw new Error("chains is required and must be a non-empty array");if(!(0,a.Qhg)(s,!1))throw new Error("uri is required parameter");if(!(0,a.Qhg)(i,!1))throw new Error("domain is required parameter");if(!(0,a.Qhg)(r,!1))throw new Error("nonce is required parameter");if([...new Set(t.map(e=>(0,a._Yb)(e).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:n}=(0,a._Yb)(t[0]);if("eip155"!==n)throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),U(this,"getVerifyContext",async e=>{const{attestationId:t,hash:s,encryptedId:r,metadata:n,transportType:o}=e,a={verified:{verifyUrl:n.verifyUrl||i.WB,validation:"UNKNOWN",origin:n.url||""}};try{if(o===i.cV.link_mode){const e=this.getAppLinkIfEnabled(n,o);return a.verified.validation=e&&new URL(e).origin===new URL(n.url).origin?"VALID":"INVALID",a}const e=await this.client.core.verify.resolve({attestationId:t,hash:s,encryptedId:r,verifyUrl:n.verifyUrl});e&&(a.verified.origin=e.origin,a.verified.isScam=e.isScam,a.verified.validation=e.origin===new URL(n.url).origin?"VALID":"INVALID")}catch(e){this.client.logger.warn(e)}return this.client.logger.debug(`Verify context: ${JSON.stringify(a)}`),a}),U(this,"validateSessionProps",(e,t)=>{Object.values(e).forEach((s,i)=>{if(null==s){const{message:r}=(0,a.GuA)("MISSING_OR_INVALID",`${t} must contain an existing value for each key. Received: ${s} for key ${Object.keys(e)[i]}`);throw new Error(r)}})}),U(this,"getPendingAuthRequest",e=>{const t=this.client.auth.requests.get(e);return"object"==typeof t?t:void 0}),U(this,"addToRecentlyDeleted",(e,t)=>{if(this.recentlyDeletedMap.set(e,t),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let e=0;const t=this.recentlyDeletedLimit/2;for(const s of this.recentlyDeletedMap.keys()){if(e++>=t)break;this.recentlyDeletedMap.delete(s)}}}),U(this,"checkRecentlyDeleted",e=>{const t=this.recentlyDeletedMap.get(e);if(t){const{message:s}=(0,a.GuA)("MISSING_OR_INVALID",`Record was recently deleted - ${t}: ${e}`);throw new Error(s)}}),U(this,"isLinkModeEnabled",(e,t)=>{var r,n,o,a,c,h,l,p,d;return!(!e||t!==i.cV.link_mode)&&!0===(null==(n=null==(r=this.client.metadata)?void 0:r.redirect)?void 0:n.linkMode)&&void 0!==(null==(a=null==(o=this.client.metadata)?void 0:o.redirect)?void 0:a.universal)&&""!==(null==(h=null==(c=this.client.metadata)?void 0:c.redirect)?void 0:h.universal)&&void 0!==(null==(l=e?.redirect)?void 0:l.universal)&&""!==(null==(p=e?.redirect)?void 0:p.universal)&&!0===(null==(d=e?.redirect)?void 0:d.linkMode)&&this.client.core.linkModeSupportedApps.includes(e.redirect.universal)&&typeof(null==s.g?void 0:s.g.Linking)<"u"}),U(this,"getAppLinkIfEnabled",(e,t)=>{var s;return this.isLinkModeEnabled(e,t)?null==(s=e?.redirect)?void 0:s.universal:void 0}),U(this,"handleLinkModeMessage",({url:e})=>{if(!e||!e.includes("wc_ev")||!e.includes("topic"))return;const t=(0,a.$hI)(e,"topic")||"",s=decodeURIComponent((0,a.$hI)(e,"wc_ev")||""),r=this.client.session.keys.includes(t);r&&this.client.session.update(t,{transportType:i.cV.link_mode}),this.client.core.dispatchEnvelope({topic:t,message:s,sessionExists:r})}),U(this,"registerLinkModeListeners",async()=>{var e;if((0,a.w8K)()||(0,a.lVv)()&&null!=(e=this.client.metadata.redirect)&&e.linkMode){const e=null==s.g?void 0:s.g.Linking;if(typeof e<"u"){e.addEventListener("url",this.handleLinkModeMessage,this.client.name);const t=await e.getInitialURL();t&&setTimeout(()=>{this.handleLinkModeMessage({url:t})},50)}}}),U(this,"shouldSetTVF",(e,t)=>{if(!t||"wc_sessionRequest"!==e)return!1;const{request:s}=t;return Object.keys(E).includes(s.method)}),U(this,"getTVFParams",(e,t,s)=>{var i,r;try{const n=t.request.method,o=this.extractTxHashesFromResult(n,s);return R(x({correlationId:e,rpcMethods:[n],chainId:t.chainId},this.isValidContractData(t.request.params)&&{contractAddresses:[null==(r=null==(i=t.request.params)?void 0:i[0])?void 0:r.to]}),{txHashes:o})}catch(e){this.client.logger.warn("Error getting TVF params",e)}return{}}),U(this,"isValidContractData",e=>{var t;if(!e)return!1;try{const s=e?.data||(null==(t=e?.[0])?void 0:t.data);if(!s.startsWith("0x"))return!1;const i=s.slice(2);return!!/^[0-9a-fA-F]*$/.test(i)&&i.length%2==0}catch{}return!1}),U(this,"extractTxHashesFromResult",(e,t)=>{try{if("string"==typeof t)return[t];const s=t[E[e].key];if((0,a.OP1)(s))return"solana_signAllTransactions"===e?s.map(e=>(0,a.PAk)(e)):s;if("string"==typeof s)return[s]}catch(e){this.client.logger.warn("Error extracting tx hashes from result",e)}return[]})}async processPendingMessageEvents(){try{const e=this.client.session.keys,t=this.client.core.relayer.messages.getWithoutAck(e);for(const[e,s]of Object.entries(t))for(const t of s)try{await this.onProviderMessageEvent({topic:e,message:t,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${e}, message: ${t}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){const{message:e}=(0,a.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(i.Jf.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){const{topic:t,message:s,attestation:r,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(N)?this.client.auth.authKeys.get(N):{responseTopic:void 0,publicKey:void 0};try{const e=await this.client.core.crypto.decode(t,s,{receiverPublicKey:o,encoding:n===i.cV.link_mode?a.Pa8:a.EWt});(0,l.isJsonRpcRequest)(e)?(this.client.core.history.set(t,e),await this.onRelayEventRequest({topic:t,payload:e,attestation:r,transportType:n,encryptedId:(0,a.ALl)(s)})):(0,l.isJsonRpcResponse)(e)?(await this.client.core.history.resolve(e),await this.onRelayEventResponse({topic:t,payload:e,transportType:n}),this.client.core.history.delete(t,e.id)):await this.onRelayEventUnknownPayload({topic:t,payload:e,transportType:n}),await this.client.core.relayer.messages.ack(t,s)}catch(e){this.client.logger.error(e)}}registerExpirerEvents(){this.client.core.expirer.on(i.wn.expired,async e=>{const{topic:t,id:s}=(0,a.c82)(e.target);return s&&this.client.pendingRequest.keys.includes(s)?await this.deletePendingSessionRequest(s,(0,a.GuA)("EXPIRED"),!0):s&&this.client.auth.requests.keys.includes(s)?await this.deletePendingAuthRequest(s,(0,a.GuA)("EXPIRED"),!0):void(t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):s&&(await this.deleteProposal(s,!0),this.client.events.emit("proposal_expire",{id:s})))})}registerPairingEvents(){this.client.core.pairing.events.on(i.zN.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(i.zN.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!(0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=(0,a.GuA)("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!(0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=(0,a.GuA)("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else{if(!this.client.core.pairing.pairings.keys.includes(e)){if((0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if(!(0,a.Alu)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=(0,a.GuA)("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class j extends i.il{constructor(e,t){super(e,t,"proposal",d),this.core=e,this.logger=t}}class M extends i.il{constructor(e,t){super(e,t,"session",d),this.core=e,this.logger=t}}class L extends i.il{constructor(e,t){super(e,t,"request",d,e=>e.id),this.core=e,this.logger=t}}class q extends i.il{constructor(e,t){super(e,t,"authKeys",_,()=>N),this.core=e,this.logger=t}}class $ extends i.il{constructor(e,t){super(e,t,"pairingTopics",_),this.core=e,this.logger=t}}class B extends i.il{constructor(e,t){super(e,t,"requests",_,e=>e.id),this.core=e,this.logger=t}}var H=Object.defineProperty,W=(e,t,s)=>((e,t,s)=>t in e?H(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class z{constructor(e,t){this.core=e,this.logger=t,W(this,"authKeys"),W(this,"pairingTopics"),W(this,"requests"),this.authKeys=new q(this.core,this.logger),this.pairingTopics=new $(this.core,this.logger),this.requests=new B(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var V=Object.defineProperty,F=(e,t,s)=>((e,t,s)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class K extends n.S9{constructor(e){super(e),F(this,"protocol","wc"),F(this,"version",2),F(this,"name",u),F(this,"metadata"),F(this,"core"),F(this,"logger"),F(this,"events",new c.EventEmitter),F(this,"engine"),F(this,"session"),F(this,"proposal"),F(this,"pendingRequest"),F(this,"auth"),F(this,"signConfig"),F(this,"on",(e,t)=>this.events.on(e,t)),F(this,"once",(e,t)=>this.events.once(e,t)),F(this,"off",(e,t)=>this.events.off(e,t)),F(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),F(this,"removeAllListeners",e=>this.events.removeAllListeners(e)),F(this,"connect",async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"pair",async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"approve",async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"reject",async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"update",async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"extend",async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"request",async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"respond",async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"ping",async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"emit",async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"disconnect",async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"find",e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}}),F(this,"authenticate",async(e,t)=>{try{return await this.engine.authenticate(e,t)}catch(e){throw this.logger.error(e.message),e}}),F(this,"formatAuthMessage",e=>{try{return this.engine.formatAuthMessage(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"approveSessionAuthenticate",async e=>{try{return await this.engine.approveSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"rejectSessionAuthenticate",async e=>{try{return await this.engine.rejectSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),this.name=e?.name||u,this.metadata=e?.metadata||(0,a.lFF)(),this.signConfig=e?.signConfig;const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,r.h6)((0,r.iP)({level:e?.logger||"error"}));this.core=e?.core||new i.iJ(e),this.logger=(0,r.U5)(t,this.name),this.session=new M(this.core,this.logger),this.proposal=new j(this.core,this.logger),this.pendingRequest=new L(this.core,this.logger),this.engine=new D(this),this.auth=new z(this.core,this.logger)}static async init(e){const t=new K(e);return await t.initialize(),t}get context(){return(0,r.oI)(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},(0,o.toMiliseconds)(o.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}},38132:(e,t,s)=>{s.d(t,{r:()=>r});var i=s(70255);const r={createLogger(e,t="error"){const s=(0,i.iP)({level:t}),{logger:r}=(0,i.D5)({opts:s});return r.error=(...t)=>{for(const s of t)if(s instanceof Error)return void e(s,...t);e(void 0,...t)},r}}},38753:(e,t,s)=>{s.d(t,{A:()=>l});var i=s(50731),r=s(40868),n=s(16158),o=s(5813),a=s(11553),c=s(24313),h=s(74091);const l={filterOutDuplicatesByRDNS(e){const t=n.H.state.enableEIP6963?i.a.state.connectors:[],s=a.i.getRecentWallets(),r=t.map(e=>e.info?.rdns).filter(Boolean),c=s.map(e=>e.rdns).filter(Boolean),h=r.concat(c);if(h.includes("io.metamask.mobile")&&o.w.isMobile()){const e=h.indexOf("io.metamask.mobile");h[e]="io.metamask"}return e.filter(e=>!h.includes(String(e?.rdns)))},filterOutDuplicatesByIds(e){const t=i.a.state.connectors.filter(e=>"ANNOUNCED"===e.type||"INJECTED"===e.type),s=a.i.getRecentWallets(),r=t.map(e=>e.explorerId),n=s.map(e=>e.id),o=r.concat(n);return e.filter(e=>!o.includes(e?.id))},filterOutDuplicateWallets(e){const t=this.filterOutDuplicatesByRDNS(e);return this.filterOutDuplicatesByIds(t)},markWalletsAsInstalled(e){const{connectors:t}=i.a.state,s=t.filter(e=>"ANNOUNCED"===e.type).reduce((e,t)=>t.info?.rdns?(e[t.info.rdns]=!0,e):e,{});return e.map(e=>({...e,installed:Boolean(e.rdns)&&Boolean(s[e.rdns??""])})).sort((e,t)=>Number(t.installed)-Number(e.installed))},getConnectOrderMethod(e,t){const s=e?.connectMethodsOrder||n.H.state.features?.connectMethodsOrder,o=t||i.a.state.connectors;if(s)return s;const{injected:a,announced:l}=c.g.getConnectorsByType(o,r.N.state.recommended,r.N.state.featured),p=a.filter(c.g.showConnector),d=l.filter(c.g.showConnector);return p.length||d.length?["wallet","email","social"]:h.o.DEFAULT_CONNECT_METHOD_ORDER}}},40149:(e,t,s)=>{function i(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}s.d(t,{x:()=>i})},40446:(e,t,s)=>{s.d(t,{l:()=>Lr});var i=s(31575),r=s(76754),n=s(70255),o=s(64264),a=s(93786),c=s(14350),h=s(50046),l=s.n(h);const p="error",d="wc@2:universal_provider:",u="https://rpc.walletconnect.org/v1/",g="generic",f=`${u}bundler`,m="default_chain_changed";var w=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof s.g<"u"?s.g:typeof self<"u"?self:{},y=function(e,t){return e===t||e!=e&&t!=t},b=y,v=function(e,t){for(var s=e.length;s--;)if(b(e[s][0],t))return s;return-1},E=v,I=Array.prototype.splice,_=v,N=v,A=v,C=function(){this.__data__=[],this.size=0},P=function(e){var t=this.__data__,s=E(t,e);return!(s<0||(s==t.length-1?t.pop():I.call(t,s,1),--this.size,0))},S=function(e){var t=this.__data__,s=_(t,e);return s<0?void 0:t[s][1]},O=function(e){return N(this.__data__,e)>-1},T=function(e,t){var s=this.__data__,i=A(s,e);return i<0?(++this.size,s.push([e,t])):s[i][1]=t,this};function k(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var i=e[t];this.set(i[0],i[1])}}k.prototype.clear=C,k.prototype.delete=P,k.prototype.get=S,k.prototype.has=O,k.prototype.set=T;var x,R=k,U=R,D="object"==typeof w&&w&&w.Object===Object&&w,j=D,M="object"==typeof self&&self&&self.Object===Object&&self,L=j||M||Function("return this")(),q=L.Symbol,$=q,B=Object.prototype,H=B.hasOwnProperty,W=B.toString,z=$?$.toStringTag:void 0,V=Object.prototype.toString,F=function(e){var t=H.call(e,z),s=e[z];try{e[z]=void 0;var i=!0}catch{}var r=W.call(e);return i&&(t?e[z]=s:delete e[z]),r},K=function(e){return V.call(e)},G=q?q.toStringTag:void 0,J=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":G&&G in Object(e)?F(e):K(e)},Y=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},Q=J,X=Y,Z=function(e){if(!X(e))return!1;var t=Q(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},ee=L["__core-js_shared__"],te=(x=/[^.]+$/.exec(ee&&ee.keys&&ee.keys.IE_PROTO||""))?"Symbol(src)_1."+x:"",se=Function.prototype.toString,ie=Z,re=function(e){return!!te&&te in e},ne=Y,oe=function(e){if(null!=e){try{return se.call(e)}catch{}try{return e+""}catch{}}return""},ae=/^\[object .+?Constructor\]$/,ce=Function.prototype,he=Object.prototype,le=ce.toString,pe=he.hasOwnProperty,de=RegExp("^"+le.call(pe).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),ue=function(e){return!(!ne(e)||re(e))&&(ie(e)?de:ae).test(oe(e))},ge=function(e,t){return e?.[t]},fe=function(e,t){var s=ge(e,t);return ue(s)?s:void 0},me=fe(L,"Map"),we=fe(Object,"create"),ye=we,be=we,ve=Object.prototype.hasOwnProperty,Ee=we,Ie=Object.prototype.hasOwnProperty,_e=we,Ne=function(){this.__data__=ye?ye(null):{},this.size=0},Ae=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Ce=function(e){var t=this.__data__;if(be){var s=t[e];return"__lodash_hash_undefined__"===s?void 0:s}return ve.call(t,e)?t[e]:void 0},Pe=function(e){var t=this.__data__;return Ee?void 0!==t[e]:Ie.call(t,e)},Se=function(e,t){var s=this.__data__;return this.size+=this.has(e)?0:1,s[e]=_e&&void 0===t?"__lodash_hash_undefined__":t,this};function Oe(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var i=e[t];this.set(i[0],i[1])}}Oe.prototype.clear=Ne,Oe.prototype.delete=Ae,Oe.prototype.get=Ce,Oe.prototype.has=Pe,Oe.prototype.set=Se;var Te=Oe,ke=R,xe=me,Re=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e},Ue=function(e,t){var s=e.__data__;return Re(t)?s["string"==typeof t?"string":"hash"]:s.map},De=Ue,je=Ue,Me=Ue,Le=Ue,qe=function(e){var t=De(this,e).delete(e);return this.size-=t?1:0,t},$e=function(e){return je(this,e).get(e)},Be=function(e){return Me(this,e).has(e)},He=function(e,t){var s=Le(this,e),i=s.size;return s.set(e,t),this.size+=s.size==i?0:1,this};function We(e){var t=-1,s=null==e?0:e.length;for(this.clear();++t<s;){var i=e[t];this.set(i[0],i[1])}}We.prototype.clear=function(){this.size=0,this.__data__={hash:new Te,map:new(xe||ke),string:new Te}},We.prototype.delete=qe,We.prototype.get=$e,We.prototype.has=Be,We.prototype.set=He;var ze=R,Ve=me,Fe=We,Ke=R,Ge=function(){this.__data__=new U,this.size=0},Je=function(e){var t=this.__data__,s=t.delete(e);return this.size=t.size,s},Ye=function(e){return this.__data__.get(e)},Qe=function(e){return this.__data__.has(e)},Xe=function(e,t){var s=this.__data__;if(s instanceof ze){var i=s.__data__;if(!Ve||i.length<199)return i.push([e,t]),this.size=++s.size,this;s=this.__data__=new Fe(i)}return s.set(e,t),this.size=s.size,this};function Ze(e){var t=this.__data__=new Ke(e);this.size=t.size}Ze.prototype.clear=Ge,Ze.prototype.delete=Je,Ze.prototype.get=Ye,Ze.prototype.has=Qe,Ze.prototype.set=Xe;var et=Ze,tt=fe,st=function(){try{var e=tt(Object,"defineProperty");return e({},"",{}),e}catch{}}(),it=st,rt=it,nt=function(e,t,s){"__proto__"==t&&rt?rt(e,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):e[t]=s},ot=nt,at=y,ct=function(e,t,s){(void 0!==s&&!at(e[t],s)||void 0===s&&!(t in e))&&ot(e,t,s)},ht=function(e){return function(t,s,i){for(var r=-1,n=Object(t),o=i(t),a=o.length;a--;){var c=o[e?a:++r];if(!1===s(n[c],c,n))break}return t}}(),lt={exports:{}};!function(e,t){var s=L,i=t&&!t.nodeType&&t,r=i&&e&&!e.nodeType&&e,n=r&&r.exports===i?s.Buffer:void 0,o=n?n.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var s=e.length,i=o?o(s):new e.constructor(s);return e.copy(i),i}}(lt,lt.exports);var pt=L.Uint8Array,dt=function(e){var t=new e.constructor(e.byteLength);return new pt(t).set(new pt(e)),t},ut=Y,gt=Object.create,ft=function(){function e(){}return function(t){if(!ut(t))return{};if(gt)return gt(t);e.prototype=t;var s=new e;return e.prototype=void 0,s}}(),mt=ft,wt=function(e,t){return function(s){return e(t(s))}}(Object.getPrototypeOf,Object),yt=Object.prototype,bt=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||yt)},vt=mt,Et=wt,It=bt,_t=function(e){return null!=e&&"object"==typeof e},Nt=J,At=_t,Ct=function(e){return At(e)&&"[object Arguments]"==Nt(e)},Pt=_t,St=Object.prototype,Ot=St.hasOwnProperty,Tt=St.propertyIsEnumerable,kt=Ct(function(){return arguments}())?Ct:function(e){return Pt(e)&&Ot.call(e,"callee")&&!Tt.call(e,"callee")},xt=kt,Rt=Array.isArray,Ut=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991},Dt=Z,jt=Ut,Mt=function(e){return null!=e&&jt(e.length)&&!Dt(e)},Lt=Mt,qt=_t,$t={exports:{}},Bt=function(){return!1};!function(e,t){var s=L,i=Bt,r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,o=n&&n.exports===r?s.Buffer:void 0,a=(o?o.isBuffer:void 0)||i;e.exports=a}($t,$t.exports);var Ht=J,Wt=wt,zt=_t,Vt=Function.prototype,Ft=Object.prototype,Kt=Vt.toString,Gt=Ft.hasOwnProperty,Jt=Kt.call(Object),Yt=J,Qt=Ut,Xt=_t,Zt={};Zt["[object Float32Array]"]=Zt["[object Float64Array]"]=Zt["[object Int8Array]"]=Zt["[object Int16Array]"]=Zt["[object Int32Array]"]=Zt["[object Uint8Array]"]=Zt["[object Uint8ClampedArray]"]=Zt["[object Uint16Array]"]=Zt["[object Uint32Array]"]=!0,Zt["[object Arguments]"]=Zt["[object Array]"]=Zt["[object ArrayBuffer]"]=Zt["[object Boolean]"]=Zt["[object DataView]"]=Zt["[object Date]"]=Zt["[object Error]"]=Zt["[object Function]"]=Zt["[object Map]"]=Zt["[object Number]"]=Zt["[object Object]"]=Zt["[object RegExp]"]=Zt["[object Set]"]=Zt["[object String]"]=Zt["[object WeakMap]"]=!1;var es={exports:{}};!function(e,t){var s=D,i=t&&!t.nodeType&&t,r=i&&e&&!e.nodeType&&e,n=r&&r.exports===i&&s.process,o=function(){try{return r&&r.require&&r.require("util").types||n&&n.binding&&n.binding("util")}catch{}}();e.exports=o}(es,es.exports);var ts=function(e){return Xt(e)&&Qt(e.length)&&!!Zt[Yt(e)]},ss=function(e){return function(t){return e(t)}},is=es.exports,rs=is&&is.isTypedArray,ns=rs?ss(rs):ts,os=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]},as=nt,cs=y,hs=Object.prototype.hasOwnProperty,ls=function(e,t,s){var i=e[t];(!hs.call(e,t)||!cs(i,s)||void 0===s&&!(t in e))&&as(e,t,s)},ps=nt,ds=/^(?:0|[1-9]\d*)$/,us=function(e,t){var s=typeof e;return!!(t=t??9007199254740991)&&("number"==s||"symbol"!=s&&ds.test(e))&&e>-1&&e%1==0&&e<t},gs=function(e,t){for(var s=-1,i=Array(e);++s<e;)i[s]=t(s);return i},fs=xt,ms=Rt,ws=$t.exports,ys=us,bs=ns,vs=Object.prototype.hasOwnProperty,Es=Y,Is=bt,_s=function(e){var t=[];if(null!=e)for(var s in Object(e))t.push(s);return t},Ns=Object.prototype.hasOwnProperty,As=function(e,t){var s=ms(e),i=!s&&fs(e),r=!s&&!i&&ws(e),n=!s&&!i&&!r&&bs(e),o=s||i||r||n,a=o?gs(e.length,String):[],c=a.length;for(var h in e)(t||vs.call(e,h))&&(!o||!("length"==h||r&&("offset"==h||"parent"==h)||n&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||ys(h,c)))&&a.push(h);return a},Cs=function(e){if(!Es(e))return _s(e);var t=Is(e),s=[];for(var i in e)"constructor"==i&&(t||!Ns.call(e,i))||s.push(i);return s},Ps=Mt,Ss=function(e){return Ps(e)?As(e,!0):Cs(e)},Os=function(e,t,s,i){var r=!s;s||(s={});for(var n=-1,o=t.length;++n<o;){var a=t[n],c=i?i(s[a],e[a],a,s,e):void 0;void 0===c&&(c=e[a]),r?ps(s,a,c):ls(s,a,c)}return s},Ts=Ss,ks=ct,xs=lt.exports,Rs=function(e,t){var s=t?dt(e.buffer):e.buffer;return new e.constructor(s,e.byteOffset,e.length)},Us=function(e,t){var s=-1,i=e.length;for(t||(t=Array(i));++s<i;)t[s]=e[s];return t},Ds=function(e){return"function"!=typeof e.constructor||It(e)?{}:vt(Et(e))},js=xt,Ms=Rt,Ls=function(e){return qt(e)&&Lt(e)},qs=$t.exports,$s=Z,Bs=Y,Hs=function(e){if(!zt(e)||"[object Object]"!=Ht(e))return!1;var t=Wt(e);if(null===t)return!0;var s=Gt.call(t,"constructor")&&t.constructor;return"function"==typeof s&&s instanceof s&&Kt.call(s)==Jt},Ws=ns,zs=os,Vs=function(e){return Os(e,Ts(e))},Fs=et,Ks=ct,Gs=ht,Js=function(e,t,s,i,r,n,o){var a=zs(e,s),c=zs(t,s),h=o.get(c);if(h)ks(e,s,h);else{var l=n?n(a,c,s+"",e,t,o):void 0,p=void 0===l;if(p){var d=Ms(c),u=!d&&qs(c),g=!d&&!u&&Ws(c);l=c,d||u||g?Ms(a)?l=a:Ls(a)?l=Us(a):u?(p=!1,l=xs(c,!0)):g?(p=!1,l=Rs(c,!0)):l=[]:Hs(c)||js(c)?(l=a,js(a)?l=Vs(a):(!Bs(a)||$s(a))&&(l=Ds(c))):p=!1}p&&(o.set(c,l),r(l,c,i,n,o),o.delete(c)),ks(e,s,l)}},Ys=Y,Qs=Ss,Xs=os,Zs=function(e){return e},ei=function(e,t,s){switch(s.length){case 0:return e.call(t);case 1:return e.call(t,s[0]);case 2:return e.call(t,s[0],s[1]);case 3:return e.call(t,s[0],s[1],s[2])}return e.apply(t,s)},ti=Math.max,si=function(e){return function(){return e}},ii=it,ri=ii?function(e,t){return ii(e,"toString",{configurable:!0,enumerable:!1,value:si(t),writable:!0})}:Zs,ni=ri,oi=Date.now,ai=function(e){var t=0,s=0;return function(){var i=oi(),r=16-(i-s);if(s=i,r>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(ni),ci=Zs,hi=function(e,t,s){return t=ti(void 0===t?e.length-1:t,0),function(){for(var i=arguments,r=-1,n=ti(i.length-t,0),o=Array(n);++r<n;)o[r]=i[t+r];r=-1;for(var a=Array(t+1);++r<t;)a[r]=i[r];return a[t]=s(o),ei(e,this,a)}},li=ai,pi=y,di=Mt,ui=us,gi=Y,fi=function(e,t){return li(hi(e,t,ci),e+"")},mi=function(e,t,s){if(!gi(s))return!1;var i=typeof t;return!!("number"==i?di(s)&&ui(t,s.length):"string"==i&&t in s)&&pi(s[t],e)},wi=function e(t,s,i,r,n){t!==s&&Gs(s,function(o,a){if(n||(n=new Fs),Ys(o))Js(t,s,a,i,e,r,n);else{var c=r?r(Xs(t,a),o,a+"",t,s,n):void 0;void 0===c&&(c=o),Ks(t,a,c)}},Qs)},yi=function(e){return fi(function(t,s){var i=-1,r=s.length,n=r>1?s[r-1]:void 0,o=r>2?s[2]:void 0;for(n=e.length>3&&"function"==typeof n?(r--,n):void 0,o&&mi(s[0],s[1],o)&&(n=r<3?void 0:n,r=1),t=Object(t);++i<r;){var a=s[i];a&&e(t,a,i,n)}return t})}(function(e,t,s){wi(e,t,s)}),bi=yi,vi=Object.defineProperty,Ei=Object.defineProperties,Ii=Object.getOwnPropertyDescriptors,_i=Object.getOwnPropertySymbols,Ni=Object.prototype.hasOwnProperty,Ai=Object.prototype.propertyIsEnumerable,Ci=(e,t,s)=>t in e?vi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Pi=(e,t)=>{for(var s in t||(t={}))Ni.call(t,s)&&Ci(e,s,t[s]);if(_i)for(var s of _i(t))Ai.call(t,s)&&Ci(e,s,t[s]);return e},Si=(e,t)=>Ei(e,Ii(t));function Oi(e,t,s){var i;const n=(0,r._Yb)(e);return(null==(i=t.rpcMap)?void 0:i[n.reference])||`${u}?chainId=${n.namespace}:${n.reference}&projectId=${s}`}function Ti(e){return e.includes(":")?e.split(":")[1]:e}function ki(e){return e.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function xi(e={},t={}){const s=Ri(e),i=Ri(t);return bi(s,i)}function Ri(e){var t,s,i,n;const o={};if(!(0,r.aF0)(e))return o;for(const[a,c]of Object.entries(e)){const e=(0,r.nWe)(a)?[a]:c.chains,h=c.methods||[],l=c.events||[],p=c.rpcMap||{},d=(0,r.kob)(a);o[d]=Si(Pi(Pi({},o[d]),c),{chains:(0,r.TRk)(e,null==(t=o[d])?void 0:t.chains),methods:(0,r.TRk)(h,null==(s=o[d])?void 0:s.methods),events:(0,r.TRk)(l,null==(i=o[d])?void 0:i.events),rpcMap:Pi(Pi({},p),null==(n=o[d])?void 0:n.rpcMap)})}return o}function Ui(e){return e.includes(":")?e.split(":")[2]:e}function Di(e){const t={};for(const[s,i]of Object.entries(e)){const e=i.methods||[],n=i.events||[],o=i.accounts||[],a=(0,r.nWe)(s)?[s]:i.chains?i.chains:ki(i.accounts);t[s]={chains:a,methods:e,events:n,accounts:o}}return t}function ji(e){return"number"==typeof e?e:e.includes("0x")?parseInt(e,16):(e=e.includes(":")?e.split(":")[1]:e,isNaN(Number(e))?e:Number(e))}const Mi={},Li=e=>Mi[e],qi=(e,t)=>{Mi[e]=t};var $i=Object.defineProperty,Bi=(e,t,s)=>((e,t,s)=>t in e?$i(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Hi{constructor(e){Bi(this,"name","polkadot"),Bi(this,"client"),Bi(this,"httpProviders"),Bi(this,"events"),Bi(this,"namespace"),Bi(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=Ti(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Li("disableProviderPing")))}}var Wi=Object.defineProperty,zi=Object.defineProperties,Vi=Object.getOwnPropertyDescriptors,Fi=Object.getOwnPropertySymbols,Ki=Object.prototype.hasOwnProperty,Gi=Object.prototype.propertyIsEnumerable,Ji=(e,t,s)=>t in e?Wi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Yi=(e,t)=>{for(var s in t||(t={}))Ki.call(t,s)&&Ji(e,s,t[s]);if(Fi)for(var s of Fi(t))Gi.call(t,s)&&Ji(e,s,t[s]);return e},Qi=(e,t)=>zi(e,Vi(t)),Xi=(e,t,s)=>Ji(e,"symbol"!=typeof t?t+"":t,s);class Zi{constructor(e){Xi(this,"name","eip155"),Xi(this,"client"),Xi(this,"chainId"),Xi(this,"namespace"),Xi(this,"httpProviders"),Xi(this,"events"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(m,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const s=t||Oi(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.V(s,Li("disableProviderPing")))}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=parseInt(Ti(t));e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,s;let i=e.request.params?null==(t=e.request.params[0])?void 0:t.chainId:"0x0";i=i.startsWith("0x")?i:`0x${i}`;const r=parseInt(i,16);if(this.isChainApproved(r))this.setDefaultChain(`${r}`);else{if(!this.namespace.methods.includes("wallet_switchEthereumChain"))throw new Error(`Failed to switch to chain 'eip155:${r}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:i}]},chainId:null==(s=this.namespace.chains)?void 0:s[0]}),this.setDefaultChain(`${r}`)}return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,s,i;const r=null==(s=null==(t=e.request)?void 0:t.params)?void 0:s[0];if(!r)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const n=this.client.session.get(e.topic),o=(null==(i=n?.sessionProperties)?void 0:i.capabilities)||{};if(null!=o&&o[r])return o?.[r];const a=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Qi(Yi({},n.sessionProperties||{}),{capabilities:Qi(Yi({},o||{}),{[r]:a})})})}catch(e){console.warn("Failed to update session with capabilities",e)}return a}async getCallStatus(e){var t,s;const i=this.client.session.get(e.topic),r=null==(t=i.sessionProperties)?void 0:t.bundler_name;if(r){const t=this.getBundlerUrl(e.chainId,r);try{return await this.getUserOperationReceipt(t,e)}catch(e){console.warn("Failed to fetch call status from bundler",e,t)}}const n=null==(s=i.sessionProperties)?void 0:s.bundler_url;if(n)try{return await this.getUserOperationReceipt(n,e)}catch(e){console.warn("Failed to fetch call status from custom bundler",e,n)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var s;const i=new URL(e),r=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,c.formatJsonRpcRequest)("eth_getUserOperationReceipt",[null==(s=t.request.params)?void 0:s[0]]))});if(!r.ok)throw new Error(`Failed to fetch user operation receipt - ${r.status}`);return await r.json()}getBundlerUrl(e,t){return`${f}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}var er=Object.defineProperty,tr=(e,t,s)=>((e,t,s)=>t in e?er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class sr{constructor(e){tr(this,"name","solana"),tr(this,"client"),tr(this,"httpProviders"),tr(this,"events"),tr(this,"namespace"),tr(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=Ti(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Li("disableProviderPing")))}}var ir=Object.defineProperty,rr=(e,t,s)=>((e,t,s)=>t in e?ir(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class nr{constructor(e){rr(this,"name","cosmos"),rr(this,"client"),rr(this,"httpProviders"),rr(this,"events"),rr(this,"namespace"),rr(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=Ti(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Li("disableProviderPing")))}}var or=Object.defineProperty,ar=(e,t,s)=>((e,t,s)=>t in e?or(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class cr{constructor(e){ar(this,"name","algorand"),ar(this,"client"),ar(this,"httpProviders"),ar(this,"events"),ar(this,"namespace"),ar(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const s=t||Oi(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,s)}this.chainId=e,this.events.emit(m,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;e[t]=this.createHttpProvider(t,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace,this.client.core.projectId);return typeof s>"u"?void 0:new a.F(new o.A(s,Li("disableProviderPing")))}}var hr=Object.defineProperty,lr=(e,t,s)=>((e,t,s)=>t in e?hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class pr{constructor(e){lr(this,"name","cip34"),lr(this,"client"),lr(this,"httpProviders"),lr(this,"events"),lr(this,"namespace"),lr(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const s=this.getCardanoRPCUrl(t),i=Ti(t);e[i]=this.createHttpProvider(i,s)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||this.getCardanoRPCUrl(e);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Li("disableProviderPing")))}}var dr=Object.defineProperty,ur=(e,t,s)=>((e,t,s)=>t in e?dr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class gr{constructor(e){ur(this,"name","elrond"),ur(this,"client"),ur(this,"httpProviders"),ur(this,"events"),ur(this,"namespace"),ur(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=Ti(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Li("disableProviderPing")))}}var fr=Object.defineProperty,mr=(e,t,s)=>((e,t,s)=>t in e?fr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class wr{constructor(e){mr(this,"name","multiversx"),mr(this,"client"),mr(this,"httpProviders"),mr(this,"events"),mr(this,"namespace"),mr(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;const i=Ti(t);e[i]=this.createHttpProvider(i,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Li("disableProviderPing")))}}var yr=Object.defineProperty,br=(e,t,s)=>((e,t,s)=>t in e?yr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class vr{constructor(e){br(this,"name","near"),br(this,"client"),br(this,"httpProviders"),br(this,"events"),br(this,"namespace"),br(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const s=t||Oi(`${this.name}:${e}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,s)}this.events.emit(m,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var s;e[t]=this.createHttpProvider(t,null==(s=this.namespace.rpcMap)?void 0:s[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace);return typeof s>"u"?void 0:new a.F(new o.A(s,Li("disableProviderPing")))}}var Er=Object.defineProperty,Ir=(e,t,s)=>((e,t,s)=>t in e?Er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class _r{constructor(e){Ir(this,"name","tezos"),Ir(this,"client"),Ir(this,"httpProviders"),Ir(this,"events"),Ir(this,"namespace"),Ir(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const s=t||Oi(`${this.name}:${e}`,this.namespace);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,s)}this.events.emit(m,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{e[t]=this.createHttpProvider(t)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace);return typeof s>"u"?void 0:new a.F(new o.A(s))}}var Nr=Object.defineProperty,Ar=(e,t,s)=>((e,t,s)=>t in e?Nr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Cr{constructor(e){Ar(this,"name",g),Ar(this,"client"),Ar(this,"httpProviders"),Ar(this,"events"),Ar(this,"namespace"),Ar(this,"chainId"),this.namespace=e.namespace,this.events=Li("events"),this.client=Li("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){var e,t;const s={};return null==(t=null==(e=this.namespace)?void 0:e.accounts)||t.forEach(e=>{const t=(0,r._Yb)(e);s[`${t.namespace}:${t.reference}`]=this.createHttpProvider(e)}),s}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const s=this.createHttpProvider(e,t);s&&(this.httpProviders[e]=s)}createHttpProvider(e,t){const s=t||Oi(e,this.namespace,this.client.core.projectId);if(!s)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(s,Li("disableProviderPing")))}}var Pr=Object.defineProperty,Sr=Object.defineProperties,Or=Object.getOwnPropertyDescriptors,Tr=Object.getOwnPropertySymbols,kr=Object.prototype.hasOwnProperty,xr=Object.prototype.propertyIsEnumerable,Rr=(e,t,s)=>t in e?Pr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Ur=(e,t)=>{for(var s in t||(t={}))kr.call(t,s)&&Rr(e,s,t[s]);if(Tr)for(var s of Tr(t))xr.call(t,s)&&Rr(e,s,t[s]);return e},Dr=(e,t)=>Sr(e,Or(t)),jr=(e,t,s)=>Rr(e,"symbol"!=typeof t?t+"":t,s);class Mr{constructor(e){jr(this,"client"),jr(this,"namespaces"),jr(this,"optionalNamespaces"),jr(this,"sessionProperties"),jr(this,"events",new(l())),jr(this,"rpcProviders",{}),jr(this,"session"),jr(this,"providerOpts"),jr(this,"logger"),jr(this,"uri"),jr(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,n.h6)((0,n.iP)({level:e?.logger||p})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const t=new Mr(e);return await t.initialize(),t}async request(e,t,s){const[i,r]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:Ur({},e),chainId:`${i}:${r}`,topic:this.session.topic,expiry:s})}sendAsync(e,t,s,i){const r=(new Date).getTime();this.request(e,s,i).then(e=>t(null,(0,c.formatJsonRpcResult)(r,e))).catch(e=>t(e,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:null==(e=this.session)?void 0:e.topic,reason:(0,r.Hjj)("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:s,response:i}=await this.client.authenticate(e,t);s&&(this.uri=s,this.events.emit("display_uri",s));const r=await i();if(this.session=r.session,this.session){const e=Di(this.session.namespaces);this.namespaces=xi(this.namespaces,e),this.persist("namespaces",this.namespaces),this.onConnect()}return r}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){const{uri:t,approval:s}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});t&&(this.uri=t,this.events.emit("display_uri",t));const i=await s();this.session=i;const r=Di(i.namespaces);return this.namespaces=xi(this.namespaces,r),this.persist("namespaces",this.namespaces),this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[s,i]=this.validateChain(e),r=this.getProvider(s);r.name===g?r.setDefaultChain(`${s}:${i}`,t):r.setDefaultChain(i,t)}catch(e){if(!/Please call connect/.test(e.message))throw e}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if((0,r.OP1)(t)){for(const s of t)e.deletePairings?this.client.core.expirer.set(s.topic,0):await this.client.core.relayer.subscriber.unsubscribe(s.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await i.Ay.init({core:this.providerOpts.core,logger:this.providerOpts.logger||p,relayUrl:this.providerOpts.relayUrl||"wss://relay.walletconnect.org",projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(e=>(0,r.kob)(e)))];qi("client",this.client),qi("events",this.events),qi("disableProviderPing",this.disableProviderPing),e.forEach(e=>{if(!this.session)return;const t=function(e,t){const s=Object.keys(t.namespaces).filter(t=>t.includes(e));if(!s.length)return[];const i=[];return s.forEach(e=>{const s=t.namespaces[e].accounts;i.push(...s)}),i}(e,this.session),s=ki(t),i=xi(this.namespaces,this.optionalNamespaces),r=Dr(Ur({},i[e]),{accounts:t,chains:s});switch(e){case"eip155":this.rpcProviders[e]=new Zi({namespace:r});break;case"algorand":this.rpcProviders[e]=new cr({namespace:r});break;case"solana":this.rpcProviders[e]=new sr({namespace:r});break;case"cosmos":this.rpcProviders[e]=new nr({namespace:r});break;case"polkadot":this.rpcProviders[e]=new Hi({namespace:r});break;case"cip34":this.rpcProviders[e]=new pr({namespace:r});break;case"elrond":this.rpcProviders[e]=new gr({namespace:r});break;case"multiversx":this.rpcProviders[e]=new wr({namespace:r});break;case"near":this.rpcProviders[e]=new vr({namespace:r});break;case"tezos":this.rpcProviders[e]=new _r({namespace:r});break;default:this.rpcProviders[g]?this.rpcProviders[g].updateNamespace(r):this.rpcProviders[g]=new Cr({namespace:r})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:t}=e,{event:s}=t;if("accountsChanged"===s.name){const e=s.data;e&&(0,r.OP1)(e)&&this.events.emit("accountsChanged",e.map(Ui))}else if("chainChanged"===s.name){const e=t.chainId,s=t.event.data,i=(0,r.kob)(e),n=ji(e)!==ji(s)?`${i}:${ji(s)}`:e;this.onChainChanged(n)}else this.events.emit(s.name,s.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var s;const{namespaces:i}=t,r=null==(s=this.client)?void 0:s.session.get(e);this.session=Dr(Ur({},r),{namespaces:i}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Dr(Ur({},(0,r.Hjj)("USER_DISCONNECTED")),{data:e.topic}))}),this.on(m,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[g]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace(null==(t=this.session)?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:s,sessionProperties:i}=e;t&&Object.keys(t).length&&(this.namespaces=t),s&&Object.keys(s).length&&(this.optionalNamespaces=s),this.sessionProperties=i,this.persist("namespaces",t),this.persist("optionalNamespaces",s)}validateChain(e){const[t,s]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,s];if(t&&!Object.keys(this.namespaces||{}).map(e=>(0,r.kob)(e)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&s)return[t,s];const i=(0,r.kob)(Object.keys(this.namespaces)[0]);return[i,this.rpcProviders[i].getDefaultChain()]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){if(!this.namespaces)return;const[s,i]=this.validateChain(e);i&&(t||this.getProvider(s).setDefaultChain(i),this.namespaces[s]?this.namespaces[s].defaultChain=i:this.namespaces[`${s}:${i}`]?this.namespaces[`${s}:${i}`].defaultChain=i:this.namespaces[`${s}:${i}`]={defaultChain:i},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",i))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${d}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${d}/${e}`)}}const Lr=Mr},40770:(e,t,s)=>{s.d(t,{L:()=>n});var i=s(95191),r=s(98207);const n={ConnectorExplorerIds:{[i.o.CONNECTOR_ID.COINBASE]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[i.o.CONNECTOR_ID.COINBASE_SDK]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[i.o.CONNECTOR_ID.SAFE]:"225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",[i.o.CONNECTOR_ID.LEDGER]:"19177a98252e07ddfc9af2083ba8e07ef627cb6103467ffebb3f8f4205fd7927",[i.o.CONNECTOR_ID.OKX]:"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709",[r.o.METMASK_CONNECTOR_NAME]:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",[r.o.TRUST_CONNECTOR_NAME]:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",[r.o.SOLFLARE_CONNECTOR_NAME]:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",[r.o.PHANTOM_CONNECTOR_NAME]:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",[r.o.COIN98_CONNECTOR_NAME]:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",[r.o.MAGIC_EDEN_CONNECTOR_NAME]:"8b830a2b724a9c3fbab63af6f55ed29c9dfa8a55e732dc88c80a196a2ba136c6",[r.o.BACKPACK_CONNECTOR_NAME]:"2bd8c14e035c2d48f184aaa168559e86b0e3433228d3c4075900a221785019b0",[r.o.BITGET_CONNECTOR_NAME]:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",[r.o.FRONTIER_CONNECTOR_NAME]:"85db431492aa2e8672e93f4ea7acf10c88b97b867b0d373107af63dc4880f041",[r.o.XVERSE_CONNECTOR_NAME]:"2a87d74ae02e10bdd1f51f7ce6c4e1cc53cd5f2c0b6b5ad0d7b3007d2b13de7b",[r.o.LEATHER_CONNECTOR_NAME]:"483afe1df1df63daf313109971ff3ef8356ddf1cc4e45877d205eee0b7893a13"},NetworkImageIds:{1:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",42161:"3bff954d-5cb0-47a0-9a23-d20192e74600",43114:"30c46e53-e989-45fb-4549-be3bd4eb3b00",56:"93564157-2e8e-4ce7-81df-b264dbee9b00",250:"06b26297-fe0c-4733-5d6b-ffa5498aac00",10:"ab9c186a-c52f-464b-2906-ca59d760a400",137:"41d04d42-da3b-4453-8506-668cc0727900",5e3:"e86fae9b-b770-4eea-e520-150e12c81100",295:"6a97d510-cac8-4e58-c7ce-e8681b044c00",11155111:"e909ea0a-f92a-4512-c8fc-748044ea6800",84532:"a18a7ecd-e307-4360-4746-283182228e00",1301:"4eeea7ef-0014-4649-5d1d-07271a80f600",130:"2257980a-3463-48c6-cbac-a42d2a956e00",10143:"0a728e83-bacb-46db-7844-948f05434900",100:"02b53f6a-e3d4-479e-1cb4-21178987d100",9001:"f926ff41-260d-4028-635e-91913fc28e00",324:"b310f07f-4ef7-49f3-7073-2a0a39685800",314:"5a73b3dd-af74-424e-cae0-0de859ee9400",4689:"34e68754-e536-40da-c153-6ef2e7188a00",1088:"3897a66d-40b9-4833-162f-a2c90531c900",1284:"161038da-44ae-4ec7-1208-0ea569454b00",1285:"f1d73bb6-5450-4e18-38f7-fb6484264a00",7777777:"845c60df-d429-4991-e687-91ae45791600",42220:"ab781bbc-ccc6-418d-d32d-789b15da1f00",8453:"7289c336-3981-4081-c5f4-efc26ac64a00",1313161554:"3ff73439-a619-4894-9262-4470c773a100",2020:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",2021:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",80094:"e329c2c9-59b0-4a02-83e4-212ff3779900","5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp":"a1b58899-f671-4276-6a5e-56ca5bd59700","4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z":"a1b58899-f671-4276-6a5e-56ca5bd59700",EtWTRABZaYq6iMfeYKouRu166VU2xqa1:"a1b58899-f671-4276-6a5e-56ca5bd59700","000000000019d6689c085ae165831e93":"0b4838db-0161-4ffe-022d-532bf03dba00","000000000933ea01ad0ee984209779ba":"39354064-d79b-420b-065d-f980c4b78200"},ConnectorImageIds:{[i.o.CONNECTOR_ID.COINBASE]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[i.o.CONNECTOR_ID.COINBASE_SDK]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[i.o.CONNECTOR_ID.SAFE]:"461db637-8616-43ce-035a-d89b8a1d5800",[i.o.CONNECTOR_ID.LEDGER]:"54a1aa77-d202-4f8d-0fb2-5d2bb6db0300",[i.o.CONNECTOR_ID.WALLET_CONNECT]:"ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400",[i.o.CONNECTOR_ID.INJECTED]:"07ba87ed-43aa-4adf-4540-9e6a2b9cae00"},ConnectorNamesMap:{[i.o.CONNECTOR_ID.INJECTED]:"Browser Wallet",[i.o.CONNECTOR_ID.WALLET_CONNECT]:"WalletConnect",[i.o.CONNECTOR_ID.COINBASE]:"Coinbase",[i.o.CONNECTOR_ID.COINBASE_SDK]:"Coinbase",[i.o.CONNECTOR_ID.LEDGER]:"Ledger",[i.o.CONNECTOR_ID.SAFE]:"Safe"},ConnectorTypesMap:{[i.o.CONNECTOR_ID.INJECTED]:"INJECTED",[i.o.CONNECTOR_ID.WALLET_CONNECT]:"WALLET_CONNECT",[i.o.CONNECTOR_ID.EIP6963]:"ANNOUNCED",[i.o.CONNECTOR_ID.AUTH]:"AUTH"},WalletConnectRpcChainIds:[1,5,11155111,10,420,42161,421613,137,80001,42220,1313161554,1313161555,56,97,43114,43113,100,8453,84531,7777777,999,324,280]}},40868:(e,t,s)=>{s.d(t,{N:()=>w});var i=s(89168),r=s(39150),n=s(93224),o=s(5813),a=s(19760),c=s(11553),h=s(12472),l=s(99013),p=s(50731),d=s(14479),u=s(16158);const g=o.w.getApiUrl(),f=new a.Z({baseUrl:g,clientId:null}),m=(0,i.BX)({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1}),w={state:m,subscribeKey:(e,t)=>(0,r.u$)(m,e,t),_getSdkProperties(){const{projectId:e,sdkType:t,sdkVersion:s}=u.H.state;return{projectId:e,st:t||"appkit",sv:s||"html-wagmi-4.2.2"}},_filterOutExtensions:e=>u.H.state.isUniversalProvider?e.filter(e=>Boolean(e.mobile_link||e.desktop_link||e.webapp_link)):e,async _fetchWalletImage(e){const t=`${f.baseUrl}/getWalletImage/${e}`,s=await f.getBlob({path:t,params:w._getSdkProperties()});h.j.setWalletImage(e,URL.createObjectURL(s))},async _fetchNetworkImage(e){const t=`${f.baseUrl}/public/getAssetImage/${e}`,s=await f.getBlob({path:t,params:w._getSdkProperties()});h.j.setNetworkImage(e,URL.createObjectURL(s))},async _fetchConnectorImage(e){const t=`${f.baseUrl}/public/getAssetImage/${e}`,s=await f.getBlob({path:t,params:w._getSdkProperties()});h.j.setConnectorImage(e,URL.createObjectURL(s))},async _fetchCurrencyImage(e){const t=`${f.baseUrl}/public/getCurrencyImage/${e}`,s=await f.getBlob({path:t,params:w._getSdkProperties()});h.j.setCurrencyImage(e,URL.createObjectURL(s))},async _fetchTokenImage(e){const t=`${f.baseUrl}/public/getTokenImage/${e}`,s=await f.getBlob({path:t,params:w._getSdkProperties()});h.j.setTokenImage(e,URL.createObjectURL(s))},async fetchNetworkImages(){const e=l.W.getAllRequestedCaipNetworks(),t=e?.map(({assets:e})=>e?.imageId).filter(Boolean).filter(e=>!n.$.getNetworkImageById(e));t&&await Promise.allSettled(t.map(e=>w._fetchNetworkImage(e)))},async fetchConnectorImages(){const{connectors:e}=p.a.state,t=e.map(({imageId:e})=>e).filter(Boolean);await Promise.allSettled(t.map(e=>w._fetchConnectorImage(e)))},async fetchCurrencyImages(e=[]){await Promise.allSettled(e.map(e=>w._fetchCurrencyImage(e)))},async fetchTokenImages(e=[]){await Promise.allSettled(e.map(e=>w._fetchTokenImage(e)))},async fetchFeaturedWallets(){const{featuredWalletIds:e}=u.H.state;if(e?.length){const{data:t}=await f.get({path:"/getWallets",params:{...w._getSdkProperties(),page:"1",entries:e?.length?String(e.length):"4",include:e?.join(",")}});t.sort((t,s)=>e.indexOf(t.id)-e.indexOf(s.id));const s=t.map(e=>e.image_id).filter(Boolean);await Promise.allSettled(s.map(e=>w._fetchWalletImage(e))),m.featured=t,m.allFeatured=t}},async fetchRecommendedWallets(){try{m.isFetchingRecommendedWallets=!0;const{includeWalletIds:e,excludeWalletIds:t,featuredWalletIds:s}=u.H.state,i=[...t??[],...s??[]].filter(Boolean),r=l.W.getRequestedCaipNetworkIds().join(","),{data:n,count:o}=await f.get({path:"/getWallets",params:{...w._getSdkProperties(),page:"1",chains:r,entries:"4",include:e?.join(","),exclude:i?.join(",")}}),a=c.i.getRecentWallets(),h=n.map(e=>e.image_id).filter(Boolean),p=a.map(e=>e.image_id).filter(Boolean);await Promise.allSettled([...h,...p].map(e=>w._fetchWalletImage(e))),m.recommended=n,m.allRecommended=n,m.count=o??0}catch{}finally{m.isFetchingRecommendedWallets=!1}},async fetchWallets({page:e}){const{includeWalletIds:t,excludeWalletIds:s,featuredWalletIds:i}=u.H.state,r=l.W.getRequestedCaipNetworkIds().join(","),n=[...m.recommended.map(({id:e})=>e),...s??[],...i??[]].filter(Boolean),{data:a,count:c}=await f.get({path:"/getWallets",params:{...w._getSdkProperties(),page:String(e),entries:"40",chains:r,include:t?.join(","),exclude:n.join(",")}}),h=a.slice(0,20).map(e=>e.image_id).filter(Boolean);await Promise.allSettled(h.map(e=>w._fetchWalletImage(e))),m.wallets=o.w.uniqueBy([...m.wallets,...w._filterOutExtensions(a)],"id"),m.count=c>m.count?c:m.count,m.page=e},async initializeExcludedWallets({ids:e}){const t=l.W.getRequestedCaipNetworkIds().join(","),{data:s}=await f.get({path:"/getWallets",params:{...w._getSdkProperties(),page:"1",entries:String(e.length),chains:t,include:e?.join(",")}});s&&s.forEach(e=>{e?.rdns&&m.excludedWallets.push({rdns:e.rdns,name:e.name})})},async searchWallet({search:e,badge:t}){const{includeWalletIds:s,excludeWalletIds:i}=u.H.state;m.search=[];const r=l.W.getRequestedCaipNetworkIds().join(","),{data:n}=await f.get({path:"/getWallets",params:{...w._getSdkProperties(),page:"1",entries:"100",search:e?.trim(),badge_type:t,chains:r,include:s?.join(","),exclude:i?.join(",")}});d.E.sendEvent({type:"track",event:"SEARCH_WALLET",properties:{badge:t??"",search:e??""}});const a=n.map(e=>e.image_id).filter(Boolean);await Promise.allSettled([...a.map(e=>w._fetchWalletImage(e)),o.w.wait(300)]),m.search=w._filterOutExtensions(n)},initPromise:(e,t)=>m.promises[e]||(m.promises[e]=t()),prefetch({fetchConnectorImages:e=!0,fetchFeaturedWallets:t=!0,fetchRecommendedWallets:s=!0,fetchNetworkImages:i=!0}={}){const r=[e&&w.initPromise("connectorImages",w.fetchConnectorImages),t&&w.initPromise("featuredWallets",w.fetchFeaturedWallets),s&&w.initPromise("recommendedWallets",w.fetchRecommendedWallets),i&&w.initPromise("networkImages",w.fetchNetworkImages)].filter(Boolean);return Promise.allSettled(r)},prefetchAnalyticsConfig(){u.H.state.features?.analytics&&w.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:e}=await f.get({path:"/getAnalyticsConfig",params:w._getSdkProperties()});u.H.setFeatures({analytics:e})}catch(e){u.H.setFeatures({analytics:!1})}},setFilterByNamespace(e){if(!e)return m.featured=m.allFeatured,void(m.recommended=m.allRecommended);const t=l.W.getRequestedCaipNetworkIds().join(",");m.featured=m.allFeatured.filter(e=>e.chains?.some(e=>t.includes(e))),m.recommended=m.allRecommended.filter(e=>e.chains?.some(e=>t.includes(e)))}}},41276:(e,t,s)=>{s.d(t,{f:()=>i});class i extends Error{constructor(e){super(`WalletConnect Adapter - Method ${e} is not supported by the wallet`),this.name="WalletConnectFeatureNotSupportedError"}}},41430:(e,t,s)=>{s.d(t,{P:()=>c});var i=s(89168),r=s(39150),n=s(5813);const o=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),a=(0,i.BX)({...o}),c={state:a,subscribeKey:(e,t)=>(0,r.u$)(a,e,t),showLoading(e,t={}){this._showMessage({message:e,variant:"loading",...t})},showSuccess(e){this._showMessage({message:e,variant:"success"})},showSvg(e,t){this._showMessage({message:e,svg:t})},showError(e){const t=n.w.parseError(e);this._showMessage({message:t,variant:"error"})},hide(){a.message=o.message,a.variant=o.variant,a.svg=o.svg,a.open=o.open,a.autoClose=o.autoClose},_showMessage({message:e,svg:t,variant:s="success",autoClose:i=o.autoClose}){a.open?(a.open=!1,setTimeout(()=>{a.message=e,a.variant=s,a.svg=t,a.open=!0,a.autoClose=i},150)):(a.message=e,a.variant=s,a.svg=t,a.open=!0,a.autoClose=i)}}},41977:(e,t,s)=>{s.d(t,{_:()=>U});var i=s(1057),r=s(76020),n=s(95191),o=s(59677),a=s(67018),c=s(42831),h=s(16279),l=s(99013),p=s(89058),d=s(50731),u=s(41430),g=s(26545),f=s(16158),m=s(27006),w=s(25422),y=s(14479),b=s(29864),v=s(27938),E=s(93224),I=s(5813),_=s(11553),N=s(24096),A=s(94768),C=s(98207),P=s(28127),S=s(60039),O=s(38132),T=s(15579),k=s(79473),x=s(46779),R=s(86808);class U{constructor(e){this.hasSwitchedToPreferredAccountTypeOnConnect=!1,this.chainNamespaces=[],this.reportedAlertErrors={},this.getCaipNetwork=e=>{if(e){const t=l.W.getNetworkData(e)?.caipNetwork;return t||l.W.getRequestedCaipNetworks(e).filter(t=>t.chainNamespace===e)?.[0]}return l.W.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const e=this.getCaipNetwork();if(e)return e.id},this.getCaipNetworks=e=>l.W.getRequestedCaipNetworks(e),this.getActiveChainNamespace=()=>l.W.state.activeChain,this.setRequestedCaipNetworks=(e,t)=>{l.W.setRequestedCaipNetworks(e,t)},this.getApprovedCaipNetworkIds=()=>l.W.getAllApprovedCaipNetworkIds(),this.getCaipAddress=e=>l.W.state.activeChain!==e&&e?l.W.getAccountProp("caipAddress",e):l.W.state.activeCaipAddress,this.setClientId=e=>{m.T.setClientId(e)},this.getProvider=e=>k.A.getProvider(e),this.getProviderType=e=>k.A.getProviderId(e),this.getPreferredAccountType=()=>h.U.state.preferredAccountType,this.setCaipAddress=(e,t)=>{h.U.setCaipAddress(e,t)},this.setBalance=(e,t,s)=>{h.U.setBalance(e,t,s)},this.setProfileName=(e,t)=>{h.U.setProfileName(e,t)},this.setProfileImage=(e,t)=>{h.U.setProfileImage(e,t)},this.setUser=(e,t)=>{h.U.setUser(e,t),f.H.state.enableEmbedded&&a.W.close()},this.resetAccount=e=>{h.U.resetAccount(e)},this.setCaipNetwork=e=>{l.W.setActiveCaipNetwork(e)},this.setCaipNetworkOfNamespace=(e,t)=>{l.W.setChainNetworkData(t,{caipNetwork:e})},this.setAllAccounts=(e,t)=>{h.U.setAllAccounts(e,t),f.H.setHasMultipleAddresses(e?.length>1)},this.setStatus=(e,t)=>{h.U.setStatus(e,t),d.a.isConnected()?_.i.setConnectionStatus("connected"):_.i.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=e=>l.W.getAccountProp("address",e),this.setConnectors=e=>{const t=[...d.a.getConnectors(),...e];d.a.setConnectors(t)},this.fetchIdentity=e=>m.T.fetchIdentity(e),this.getReownName=e=>b.f.getNamesForAddress(e),this.getConnectors=()=>d.a.getConnectors(),this.getConnectorImage=e=>E.$.getConnectorImage(e),this.setConnectedWalletInfo=(e,t)=>{const s=k.A.getProviderId(t),i=e?{...e,type:s}:void 0;h.U.setConnectedWalletInfo(i,t)},this.getIsConnectedState=()=>Boolean(l.W.state.activeCaipAddress),this.addAddressLabel=(e,t,s)=>{h.U.addAddressLabel(e,t,s)},this.removeAddressLabel=(e,t)=>{h.U.removeAddressLabel(e,t)},this.getAddress=e=>l.W.state.activeChain!==e&&e?l.W.getAccountProp("address",e):h.U.state.address,this.setApprovedCaipNetworksData=e=>l.W.setApprovedCaipNetworksData(e),this.resetNetwork=e=>{l.W.resetNetwork(e)},this.addConnector=e=>{d.a.addConnector(e)},this.resetWcConnection=()=>{p.x.resetWcConnection()},this.setAddressExplorerUrl=(e,t)=>{h.U.setAddressExplorerUrl(e,t)},this.setSmartAccountDeployed=(e,t)=>{h.U.setSmartAccountDeployed(e,t)},this.setSmartAccountEnabledNetworks=(e,t)=>{l.W.setSmartAccountEnabledNetworks(e,t)},this.setPreferredAccountType=(e,t)=>{h.U.setPreferredAccountType(e,t)},this.setEIP6963Enabled=e=>{f.H.setEIP6963Enabled(e)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=[...new Set(this.caipNetworks?.map(e=>e.chainNamespace))],this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.initialize(e),this.sendInitializeEvent(e)}async initialize(e){this.initControllers(e),await this.initChainAdapters(),await this.injectModalUi(),await this.syncExistingConnection(),w.z.set({initialized:!0})}sendInitializeEvent(e){const{...t}=e;delete t.adapters,y.E.sendEvent({type:"track",event:"INITIALIZE",properties:{...t,networks:e.networks.map(e=>e.id),siweConfig:{options:e.siweConfig?.options||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&g.W.setThemeMode(e.themeMode),e.themeVariables&&g.W.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");l.W.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const t=this.getDefaultNetwork();t&&l.W.setActiveCaipNetwork(t)}initializeConnectionController(e){p.x.setWcBasic(e.basic??!1)}initializeConnectorController(){d.a.initialize(this.chainNamespaces)}initializeOptionsController(e){f.H.setDebug(!1!==e.debug),f.H.setEnableWalletConnect(!1!==e.enableWalletConnect),f.H.setEnableWalletGuide(!1!==e.enableWalletGuide),f.H.setEnableWallets(!1!==e.enableWallets),f.H.setEIP6963Enabled(!1!==e.enableEIP6963),f.H.setEnableNetworkSwitch(!1!==e.enableNetworkSwitch),f.H.setEnableAuthLogger(!1!==e.enableAuthLogger),f.H.setCustomRpcUrls(e.customRpcUrls),f.H.setSdkVersion(e.sdkVersion),f.H.setProjectId(e.projectId),f.H.setEnableEmbedded(e.enableEmbedded),f.H.setAllWallets(e.allWallets),f.H.setIncludeWalletIds(e.includeWalletIds),f.H.setExcludeWalletIds(e.excludeWalletIds),f.H.setFeaturedWalletIds(e.featuredWalletIds),f.H.setTokens(e.tokens),f.H.setTermsConditionsUrl(e.termsConditionsUrl),f.H.setPrivacyPolicyUrl(e.privacyPolicyUrl),f.H.setCustomWallets(e.customWallets),f.H.setFeatures(e.features),f.H.setAllowUnsupportedChain(e.allowUnsupportedChain),f.H.setDefaultAccountTypes(e.defaultAccountTypes),f.H.setUniversalProviderConfigOverride(e.universalProviderConfigOverride);const t=this.getDefaultMetaData();if(!e.metadata&&t&&(e.metadata=t),f.H.setMetadata(e.metadata),f.H.setDisableAppend(e.disableAppend),f.H.setEnableEmbedded(e.enableEmbedded),f.H.setSIWX(e.siwx),!e.projectId)return void v.h.open(S.R.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");const s=e.adapters?.find(e=>e.namespace===n.o.CHAIN.EVM);if(s&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");f.H.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){return"undefined"!=typeof window&&"undefined"!=typeof document?{name:document.getElementsByTagName("title")?.[0]?.textContent||"",description:document.querySelector('meta[property="og:description"]')?.content||"",url:window.location.origin,icons:[document.querySelector('link[rel~="icon"]')?.href||""]}:null}setUnsupportedNetwork(e){const t=this.getActiveChainNamespace();if(t){const s=T.R.getUnsupportedNetwork(`${t}:${e}`);l.W.setActiveCaipNetwork(s)}}getDefaultNetwork(){return T.R.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,t){return T.R.extendCaipNetwork(e,{customNetworkImageUrls:t.chainImages,projectId:t.projectId})}extendCaipNetworks(e){return T.R.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const t=e.networks.find(t=>t.id===e.defaultNetwork?.id);return t?T.R.extendCaipNetwork(t,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{const e=l.W.state.activeChain,t=this.getAdapter(e),s=this.getCaipNetwork(e)?.id;if(!t)throw new Error("Adapter not found");const i=await t.connectWalletConnect(s);this.close(),this.setClientId(i?.clientId||null),_.i.setConnectedNamespaces([...l.W.state.chains.keys()]),this.chainNamespaces.forEach(e=>{d.a.setConnectorId(C.o.CONNECTOR_TYPE_WALLET_CONNECT,e)}),await this.syncWalletConnectAccount()},connectExternal:async({id:e,info:t,type:s,provider:i,chain:r,caipNetwork:n})=>{const o=l.W.state.activeChain,a=r||o,c=this.getAdapter(a);if(r&&r!==o&&!n){const e=this.caipNetworks?.find(e=>e.chainNamespace===r);e&&this.setCaipNetwork(e)}if(!c)throw new Error("Adapter not found");const h=this.getCaipNetwork(a),p=await c.connect({id:e,info:t,type:s,provider:i,chainId:n?.id||h?.id,rpcUrl:n?.rpcUrls?.default?.http?.[0]||h?.rpcUrls?.default?.http?.[0]});if(!p)return;_.i.addConnectedNamespace(a),this.syncProvider({...p,chainNamespace:a}),await this.syncAccount({...p,chainNamespace:a});const{accounts:d}=await c.getAccounts({namespace:a,id:e});this.setAllAccounts(d,a)},reconnectExternal:async({id:e,info:t,type:s,provider:i})=>{const r=l.W.state.activeChain,n=this.getAdapter(r);n?.reconnect&&(await(n?.reconnect({id:e,info:t,type:s,provider:i,chainId:this.getCaipNetwork()?.id})),_.i.addConnectedNamespace(r))},disconnect:async e=>{const t=e||l.W.state.activeChain,s=this.getAdapter(t),i=k.A.getProvider(t),r=k.A.getProviderId(t);await(s?.disconnect({provider:i,providerType:r})),_.i.removeConnectedNamespace(t),k.A.resetChain(t),this.setUser(void 0,t),this.setStatus("disconnected",t),this.hasSwitchedToPreferredAccountTypeOnConnect=!1},checkInstalled:e=>e?e.some(e=>Boolean(window.ethereum?.[String(e)])):Boolean(window.ethereum),signMessage:async e=>{const t=this.getAdapter(l.W.state.activeChain),s=await(t?.signMessage({message:e,address:h.U.state.address,provider:k.A.getProvider(l.W.state.activeChain)}));return s?.signature||""},sendTransaction:async e=>{if(e.chainNamespace===n.o.CHAIN.EVM){const t=this.getAdapter(l.W.state.activeChain),s=k.A.getProvider(l.W.state.activeChain),i=await(t?.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:s}));return i?.hash||""}return""},estimateGas:async e=>{if(e.chainNamespace===n.o.CHAIN.EVM){const t=this.getAdapter(l.W.state.activeChain),s=k.A.getProvider(l.W.state.activeChain),i=this.getCaipNetwork();if(!i)throw new Error("CaipNetwork is undefined");const r=await(t?.estimateGas({...e,provider:s,caipNetwork:i}));return r?.gas||0n}return 0n},getEnsAvatar:async()=>{const e=this.getAdapter(l.W.state.activeChain),t=await(e?.getProfile({address:h.U.state.address,chainId:Number(this.getCaipNetwork()?.id)}));return t?.profileImage||!1},getEnsAddress:async e=>{const t=this.getAdapter(l.W.state.activeChain),s=this.getCaipNetwork();if(!s)return!1;const i=await(t?.getEnsAddress({name:e,caipNetwork:s}));return i?.address||!1},writeContract:async e=>{const t=this.getAdapter(l.W.state.activeChain),s=this.getCaipNetwork(),i=this.getCaipAddress(),r=k.A.getProvider(l.W.state.activeChain);if(!s||!i)throw new Error("CaipNetwork or CaipAddress is undefined");const n=await(t?.writeContract({...e,caipNetwork:s,provider:r,caipAddress:i}));return n?.hash},parseUnits:(e,t)=>{const s=this.getAdapter(l.W.state.activeChain);return s?.parseUnits({value:e,decimals:t})??0n},formatUnits:(e,t)=>{const s=this.getAdapter(l.W.state.activeChain);return s?.formatUnits({value:e,decimals:t})??"0"},getCapabilities:async e=>{const t=this.getAdapter(l.W.state.activeChain);return await(t?.getCapabilities(e))},grantPermissions:async e=>{const t=this.getAdapter(l.W.state.activeChain);return await(t?.grantPermissions(e))},revokePermissions:async e=>{const t=this.getAdapter(l.W.state.activeChain);return t?.revokePermissions?await t.revokePermissions(e):"0x"},walletGetAssets:async e=>{const t=this.getAdapter(l.W.state.activeChain);return await(t?.walletGetAssets(e))??{}}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},p.x.setClient(this.connectionControllerClient)}getApprovedCaipNetworksData(){if(k.A.getProviderId(l.W.state.activeChain)===C.o.CONNECTOR_TYPE_WALLET_CONNECT){const e=this.universalProvider?.session?.namespaces;return{supportsAllNetworks:"MetaMask Wallet"===this.universalProvider?.session?.peer?.metadata.name,approvedCaipNetworkIds:this.getChainsFromNamespaces(e)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){if(!e)return;const t=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const s=k.A.getProvider(t),i=k.A.getProviderId(t);if(e.chainNamespace===l.W.state.activeChain){const r=this.getAdapter(t);await(r?.switchNetwork({caipNetwork:e,provider:s,providerType:i}))}else if(this.setCaipNetwork(e),i===C.o.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const s=this.getAddressByChainNamespace(t);s&&this.syncAccount({address:s,chainId:e.id,chainNamespace:t})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(e=>{const t=e.chains||[],s=e.accounts.map(e=>{const{chainId:t,chainNamespace:s}=o.C.parseCaipAddress(e);return`${s}:${t}`});return Array.from(new Set([...t,...s]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((t,s)=>{const i=e?.find(e=>e.namespace===s);return i?(t[s]=i,t[s].namespace=s,t[s].construct({namespace:s,projectId:this.options?.projectId,networks:this.caipNetworks})):t[s]=new x.n({namespace:s,networks:this.caipNetworks}),t},{})}async initChainAdapter(e){this.onConnectors(e),this.listenAdapter(e),this.chainAdapters?.[e].syncConnectors(this.options,this),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)}))}onConnectors(e){const t=this.getAdapter(e);t?.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const t=this.getAdapter(e);if(!t)return;const s=_.i.getConnectionStatus();"connected"===s?this.setStatus("connecting",e):"disconnected"===s?(_.i.clearAddressCache(),this.setStatus(s,e)):this.setStatus(s,e),t.on("switchNetwork",({address:t,chainId:s})=>{const i=this.caipNetworks?.find(e=>e.id===s||e.caipNetworkId===s),r=l.W.state.activeChain===e,n=l.W.getAccountProp("address",e);if(i){const i=r&&t?t:n;i&&this.syncAccount({address:i,chainId:s,chainNamespace:e})}else this.setUnsupportedNetwork(s)}),t.on("disconnect",this.disconnect.bind(this,e)),t.on("pendingTransactions",()=>{const e=h.U.state.address,t=l.W.state.activeCaipNetwork;e&&t?.id&&this.updateNativeBalance(e,t.id,t.chainNamespace)}),t.on("accountChanged",({address:t,chainId:s})=>{const i=l.W.state.activeChain===e;i&&s?this.syncAccount({address:t,chainId:s,chainNamespace:e}):i&&l.W.state.activeCaipNetwork?.id?this.syncAccount({address:t,chainId:l.W.state.activeCaipNetwork?.id,chainNamespace:e}):this.syncAccountInfo(t,s,e)})}async createUniversalProviderForAdapter(e){await this.getUniversalProvider(),this.universalProvider&&this.chainAdapters?.[e]?.setUniversalProvider?.(this.universalProvider)}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async syncNamespaceConnection(e){try{const t=d.a.getConnectorId(e);switch(this.setStatus("connecting",e),t){case n.o.CONNECTOR_ID.WALLET_CONNECT:await this.syncWalletConnectAccount();break;case n.o.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(t){console.warn("AppKit couldn't sync existing connection",t),this.setStatus("disconnected",e)}}async syncAdapterConnection(e){const t=this.getAdapter(e),s=d.a.getConnectorId(e),i=this.getCaipNetwork(e),r=d.a.getConnectors(e).find(e=>e.id===s);try{if(!t||!r)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!i?.id)throw new Error("CaipNetwork not found");const s=await(t?.syncConnection({namespace:e,id:r.id,chainId:i.id,rpcUrl:i?.rpcUrls?.default?.http?.[0]}));if(s){const i=await(t?.getAccounts({namespace:e,id:r.id}));i&&i.accounts.length>0?this.setAllAccounts(i.accounts,e):this.setAllAccounts([I.w.createAccount(e,s.address,"eoa")],e),this.syncProvider({...s,chainNamespace:e}),await this.syncAccount({...s,chainNamespace:e}),this.setStatus("connected",e)}else this.setStatus("disconnected",e)}catch(t){this.setStatus("disconnected",e)}}async syncWalletConnectAccount(){const e=this.chainNamespaces.map(async e=>{const t=this.getAdapter(e),s=this.universalProvider?.session?.namespaces?.[e]?.accounts||[],i=l.W.state.activeCaipNetwork?.id,r=s.find(e=>{const{chainId:t}=o.C.parseCaipAddress(e);return t===i?.toString()})||s[0];if(r){const s=o.C.validateCaipAddress(r),{chainId:i,address:a}=o.C.parseCaipAddress(s);if(k.A.setProviderId(e,C.o.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&l.W.state.activeCaipNetwork&&t?.namespace!==n.o.CHAIN.EVM){const s=t?.getWalletConnectProvider({caipNetworks:this.caipNetworks,provider:this.universalProvider,activeCaipNetwork:l.W.state.activeCaipNetwork});k.A.setProvider(e,s)}else k.A.setProvider(e,this.universalProvider);d.a.setConnectorId(n.o.CONNECTOR_ID.WALLET_CONNECT,e),_.i.addConnectedNamespace(e),this.syncWalletConnectAccounts(e),await this.syncAccount({address:a,chainId:i,chainNamespace:e})}else this.setStatus("disconnected",e);await l.W.setApprovedCaipNetworksData(e)});await Promise.all(e)}syncWalletConnectAccounts(e){const t=this.universalProvider?.session?.namespaces?.[e]?.accounts?.map(e=>{const{address:t}=o.C.parseCaipAddress(e);return t}).filter((e,t,s)=>s.indexOf(e)===t);t&&this.setAllAccounts(t.map(t=>I.w.createAccount(e,t,"bip122"===e?"payment":"eoa")),e)}syncProvider({type:e,provider:t,id:s,chainNamespace:i}){k.A.setProviderId(i,e),k.A.setProvider(i,t),d.a.setConnectorId(s,i)}async syncAccount(e){const t=e.chainNamespace===l.W.state.activeChain,s=l.W.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:i,chainId:r,chainNamespace:a}=e,{chainId:c}=_.i.getActiveNetworkProps(),p=r||c,d=l.W.state.activeCaipNetwork?.name===n.o.UNSUPPORTED_NETWORK_NAME,u=l.W.getNetworkProp("supportsAllNetworks",a);if(this.setStatus("connected",a),(!d||u)&&p){let e=this.caipNetworks?.find(e=>e.id.toString()===p.toString()),r=this.caipNetworks?.find(e=>e.chainNamespace===a);if(!u&&!e&&!r){const t=this.getApprovedCaipNetworkIds()||[],s=t.find(e=>o.C.parseCaipNetworkId(e)?.chainId===p.toString()),i=t.find(e=>o.C.parseCaipNetworkId(e)?.chainNamespace===a);e=this.caipNetworks?.find(e=>e.caipNetworkId===s),r=this.caipNetworks?.find(e=>e.caipNetworkId===i||"deprecatedCaipNetworkId"in e&&e.deprecatedCaipNetworkId===i)}const c=e||r;c?.chainNamespace===l.W.state.activeChain?f.H.state.enableNetworkSwitch&&!f.H.state.allowUnsupportedChain&&l.W.state.activeCaipNetwork?.name===n.o.UNSUPPORTED_NETWORK_NAME?l.W.showUnsupportedChainUI():this.setCaipNetwork(c):t||s&&this.setCaipNetworkOfNamespace(s,a),this.syncConnectedWalletInfo(a),P.y.isLowerCaseMatch(i,h.U.state.address)||this.syncAccountInfo(i,c?.id,a),t?await this.syncBalance({address:i,chainId:c?.id,chainNamespace:a}):await this.syncBalance({address:i,chainId:s?.id,chainNamespace:a})}}async syncAccountInfo(e,t,s){const i=this.getCaipAddress(s),r=t||i?.split(":")[1];if(!r)return;const n=`${s}:${r}:${e}`;this.setCaipAddress(n,s),await this.syncIdentity({address:e,chainId:r,chainNamespace:s})}async syncReownName(e,t){try{const s=await this.getReownName(e);if(s[0]){const e=s[0];this.setProfileName(e.name,t)}else this.setProfileName(null,t)}catch{this.setProfileName(null,t)}}syncConnectedWalletInfo(e){const t=d.a.getConnectorId(e),s=k.A.getProviderId(e);if(s===C.o.CONNECTOR_TYPE_ANNOUNCED||s===C.o.CONNECTOR_TYPE_INJECTED){if(t){const s=this.getConnectors().find(e=>e.id===t);if(s){const{info:t,name:i,imageUrl:r}=s,n=r||this.getConnectorImage(s);this.setConnectedWalletInfo({name:i,icon:n,...t},e)}}}else if(s===C.o.CONNECTOR_TYPE_WALLET_CONNECT){const t=k.A.getProvider(e);t?.session&&this.setConnectedWalletInfo({...t.session.peer.metadata,name:t.session.peer.metadata.name,icon:t.session.peer.metadata.icons?.[0]},e)}else if(t)if(t===n.o.CONNECTOR_ID.COINBASE){const t=this.getConnectors().find(e=>e.id===n.o.CONNECTOR_ID.COINBASE);this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(t)},e)}else this.setConnectedWalletInfo({name:t},e)}async syncBalance(e){r.L.getNetworksByNamespace(this.caipNetworks,e.chainNamespace).find(t=>t.id.toString()===e.chainId?.toString())&&e.chainId&&await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async updateNativeBalance(e,t,s){const i=this.getAdapter(s);if(i){const r=await i.getBalance({address:e,chainId:t,caipNetwork:this.getCaipNetwork(s),tokens:this.options.tokens});this.setBalance(r.balance,r.symbol,s)}}async initializeUniversalAdapter(){const e=O.r.createLogger((e,...t)=>{e&&this.handleAlertError(e),console.error(...t)}),t={projectId:this.options?.projectId,metadata:{name:this.options?.metadata?this.options?.metadata.name:"",description:this.options?.metadata?this.options?.metadata.description:"",url:this.options?.metadata?this.options?.metadata.url:"",icons:this.options?.metadata?this.options?.metadata.icons:[""]},logger:e};f.H.setManualWCControl(Boolean(this.options?.manualWCControl)),this.universalProvider=this.options.universalProvider??await i.A.init(t),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&(this.universalProvider.on("display_uri",e=>{p.x.setUri(e)}),this.universalProvider.on("connect",p.x.finalizeWcConnection),this.universalProvider.on("disconnect",()=>{this.chainNamespaces.forEach(e=>{this.resetAccount(e)}),p.x.resetWcConnection()}),this.universalProvider.on("chainChanged",e=>{const t=this.caipNetworks?.find(t=>t.id==e),s=this.getCaipNetwork();t?s?.id!==t?.id&&this.setCaipNetwork(t):this.setUnsupportedNetwork(e)}),this.universalProvider.on("session_event",e=>{if(R.kl.isSessionEventData(e)){const{name:t,data:s}=e.params.event;"accountsChanged"===t&&Array.isArray(s)&&I.w.isCaipAddress(s[0])&&this.syncAccount(o.C.parseCaipAddress(s[0]))}}))}createUniversalProvider(){return!this.universalProviderInitPromise&&I.w.isClient()&&this.options?.projectId&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){y.E.sendEvent({type:"error",event:"INTERNAL_SDK_ERROR",properties:{errorType:"UniversalProviderInitError",errorMessage:e instanceof Error?e.message:"Unknown",uncaught:!1}}),console.error("AppKit:getUniversalProvider - Cannot create provider",e)}return this.universalProvider}handleAlertError(e){const t=Object.entries(S.R.UniversalProviderErrors).find(([,{message:t}])=>e.message.includes(t)),[s,i]=t??[],{message:r,alertErrorKey:n}=i??{};if(s&&r&&!this.reportedAlertErrors[s]){const e=S.R.ALERT_ERRORS[n];e&&(v.h.open(e,"error"),this.reportedAlertErrors[s]=!0)}}getAdapter(e){if(e)return this.chainAdapters?.[e]}createAdapter(e){if(!e)return;const t=e.namespace;if(!t)return;this.createClients();const s=e;s.namespace=t,s.construct({namespace:t,projectId:this.options?.projectId,networks:this.caipNetworks}),this.chainNamespaces.includes(t)||this.chainNamespaces.push(t),this.chainAdapters&&(this.chainAdapters[t]=s)}async open(e){await this.injectModalUi(),e?.uri&&p.x.setUri(e.uri),await a.W.open(e)}async close(){await this.injectModalUi(),a.W.close()}setLoading(e,t){a.W.setLoading(e,t)}async disconnect(e){await p.x.disconnect(e)}getError(){return""}getChainId(){return l.W.state.activeCaipNetwork?.id}async switchNetwork(e){const t=this.caipNetworks?.find(t=>t.id===e.id);t?await l.W.switchActiveNetwork(t):v.h.open(S.R.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error")}getWalletProvider(){return l.W.state.activeChain?k.A.state.providers[l.W.state.activeChain]:null}getWalletProviderType(){return k.A.getProviderId(l.W.state.activeChain)}subscribeProviders(e){return k.A.subscribeProviders(e)}getThemeMode(){return g.W.state.themeMode}getThemeVariables(){return g.W.state.themeVariables}setThemeMode(e){g.W.setThemeMode(e),(0,A.JX)(g.W.state.themeMode)}setTermsConditionsUrl(e){f.H.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){f.H.setPrivacyPolicyUrl(e)}setThemeVariables(e){g.W.setThemeVariables(e),(0,A.ds)(g.W.state.themeVariables)}subscribeTheme(e){return g.W.subscribe(e)}getWalletInfo(){return h.U.state.connectedWalletInfo}getAccount(e){const t=d.a.getAuthConnector(e),s=l.W.getAccountData(e);if(s)return{allAccounts:s.allAccounts,caipAddress:s.caipAddress,address:I.w.getPlainAddress(s.caipAddress),isConnected:Boolean(s.caipAddress),status:s.status,embeddedWalletInfo:t?{user:s.user,authProvider:s.socialProvider||"email",accountType:s.preferredAccountType,isSmartAccountDeployed:Boolean(s.smartAccountDeployed)}:void 0}}subscribeAccount(e,t){const s=()=>{const s=this.getAccount(t);s&&e(s)};t?l.W.subscribeChainProp("accountState",s,t):l.W.subscribe(s),d.a.subscribe(s)}subscribeNetwork(e){return l.W.subscribe(({activeCaipNetwork:t})=>{e({caipNetwork:t,chainId:t?.id,caipNetworkId:t?.caipNetworkId})})}subscribeWalletInfo(e){return h.U.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){h.U.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){l.W.subscribeKey("activeCaipNetwork",e)}getState(){return w.z.state}subscribeState(e){return w.z.subscribe(e)}showErrorMessage(e){u.P.showError(e)}showSuccessMessage(e){u.P.showSuccess(e)}getEvent(){return{...y.E.state}}subscribeEvents(e){return y.E.subscribe(e)}replace(e){c.I.replace(e)}redirect(e){c.I.push(e)}popTransactionStack(e){c.I.popTransactionStack(e)}isOpen(){return a.W.state.open}isTransactionStackEmpty(){return 0===c.I.state.transactionStack.length}isTransactionShouldReplaceView(){return c.I.state.transactionStack[c.I.state.transactionStack.length-1]?.replace}static getInstance(){return this.instance}updateFeatures(e){f.H.setFeatures(e)}updateOptions(e){const t={...f.H.state||{},...e};f.H.setOptions(t)}setConnectMethodsOrder(e){f.H.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){f.H.setWalletFeaturesOrder(e)}setCollapseWallets(e){f.H.setCollapseWallets(e)}setSocialsOrder(e){f.H.setSocialsOrder(e)}getConnectMethodsOrder(){return N.Aj.getConnectOrderMethod(f.H.state.features,d.a.getConnectors())}removeAdapter(e){const t=this.getIsConnectedState(),s=this.getAdapter(e);if(!s||!this.chainAdapters||t)return;const i=this.caipNetworks?.filter(t=>t.chainNamespace!==e);l.W.removeAdapter(e),d.a.removeAdapter(e),this.chainNamespaces=this.chainNamespaces.filter(t=>t!==e),this.caipNetworks=i,s.removeAllEventListeners(),Reflect.deleteProperty(this.chainAdapters,e)}addAdapter(e,t){const s=e.namespace;if(!this.connectionControllerClient||!this.networkControllerClient)return;if(!this.chainAdapters||!s)return;const i=this.extendCaipNetworks({...this.options,networks:t});this.caipNetworks=[...this.caipNetworks||[],...i],this.createAdapter(e),this.initChainAdapter(s),l.W.addAdapter(e,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient},i)}addNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const s=this.extendCaipNetwork(t,this.options);l.W.addNetwork(s),this.caipNetworks&&!this.caipNetworks?.find(e=>e.id===s.id)&&this.caipNetworks.push(s)}removeNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const s=this.caipNetworks?.find(e=>e.id===t);if(!s)throw new Error(`Network with ID ${t} not found`);if(!this.caipNetworks)return;const i=this.caipNetworks.filter(s=>s.chainNamespace===e&&s.id!==t);if(!i?.length)throw new Error("Cannot remove last network for a namespace");l.W.removeNetwork(e,t),this.caipNetworks=[...i]}}},42831:(e,t,s)=>{s.d(t,{I:()=>p});var i=s(89168),r=s(39150),n=s(16279),o=s(99013),a=s(50731),c=s(67018),h=s(16158);const l=(0,i.BX)({view:"Connect",history:["Connect"],transactionStack:[]}),p={state:l,subscribeKey:(e,t)=>(0,r.u$)(l,e,t),pushTransactionStack(e){l.transactionStack.push(e)},popTransactionStack(e){const t=l.transactionStack.pop();if(t)if(e)this.goBack(),t?.onCancel?.();else{if(t.goBack)this.goBack();else if(t.replace){const e=l.history.indexOf("ConnectingSiwe");e>0?this.goBackToIndex(e-1):(c.W.close(),l.history=[])}else t.view&&this.reset(t.view);t?.onSuccess?.()}},push(e,t){e!==l.view&&(l.view=e,l.history.push(e),l.data=t)},reset(e,t){l.view=e,l.history=[e],l.data=t},replace(e,t){l.history.at(-1)===e||(l.view=e,l.history[l.history.length-1]=e,l.data=t)},goBack(){const e=!o.W.state.activeCaipAddress&&"ConnectingFarcaster"===this.state.view;if(l.history.length>1&&!l.history.includes("UnsupportedChain")){l.history.pop();const[e]=l.history.slice(-1);e&&(l.view=e)}else c.W.close();l.data?.wallet&&(l.data.wallet=void 0),setTimeout(()=>{if(e){n.U.setFarcasterUrl(void 0,o.W.state.activeChain);const e=a.a.getAuthConnector();e?.provider?.reload();const t=(0,i.P9)(h.H.state);e?.provider?.syncDappData?.({metadata:t.metadata,sdkVersion:t.sdkVersion,projectId:t.projectId,sdkType:t.sdkType})}},100)},goBackToIndex(e){if(l.history.length>1){l.history=l.history.slice(0,e+1);const[t]=l.history.slice(-1);t&&(l.view=t)}}}},43039:(e,t,s)=>{s.d(t,{$Bq:()=>jt,$hI:()=>O,ALl:()=>Dt,Alu:()=>is,EHS:()=>Rt,EN$:()=>Ut,EWt:()=>Ot,FR8:()=>cs,FiO:()=>es,GuA:()=>Bt,HNf:()=>Gt,Hbs:()=>gs,Hjj:()=>Ht,IjX:()=>_e,Lp_:()=>xt,M8n:()=>as,OP1:()=>Wt,PAk:()=>le,Pa8:()=>Tt,Qhg:()=>Ft,TeY:()=>rs,V9G:()=>ss,VBM:()=>Re,Van:()=>Lt,WWN:()=>xe,Wx8:()=>E,X3c:()=>ns,XqR:()=>ds,Xw0:()=>_,_Yb:()=>d,_dF:()=>N,aF0:()=>zt,b07:()=>Vt,c82:()=>I,e8_:()=>Oe,esh:()=>Zt,hEn:()=>A,hVC:()=>Te,hwK:()=>Ne,iV1:()=>os,jTh:()=>S,kuU:()=>ts,lFF:()=>b,lVv:()=>w,n3s:()=>P,nyL:()=>ms,oKp:()=>ls,q_h:()=>Ie,sc_:()=>ke,tLy:()=>hs,tk0:()=>Yt,w8K:()=>T,xkc:()=>Ee,z2N:()=>ps});var i=s(91315),r=s(20635),n=s(67822),o=s(71268),a=s(33244),c=(s(97353),s(1030)),h=(s(13360),s(17367),s(39907)),l=s(48526).hp;const p=":";function d(e){const[t,s]=e.split(p);return{namespace:t,reference:s}}function u(e,t){return e.includes(":")?[e]:t.chains||[]}const g="ReactNative",f={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};function m(){return typeof h<"u"&&typeof h.versions<"u"&&typeof h.versions.node<"u"}function w(){return!(0,r.getDocument)()&&!!(0,r.getNavigator)()&&navigator.product===g}function y(){return!m()&&!!(0,r.getNavigator)()&&!!(0,r.getDocument)()}function b(){return(0,n.g)()||{name:"",description:"",url:"",icons:[""]}}function v(e,t){return e.filter(e=>t.includes(e)).length===e.length}function E(e=i.FIVE_MINUTES,t){const s=(0,i.toMiliseconds)(e||i.FIVE_MINUTES);let r,n,o,a;return{resolve:e=>{o&&r&&(clearTimeout(o),r(e),a=Promise.resolve(e))},reject:e=>{o&&n&&(clearTimeout(o),n(e))},done:()=>new Promise((e,i)=>{if(a)return e(a);o=setTimeout(()=>{const e=new Error(t);a=Promise.reject(e),i(e)},s),r=e,n=i})}}function I(e){const[t,s]=e.split(":"),i={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof s)i.topic=s;else{if("id"!==t||!Number.isInteger(Number(s)))throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${s}`);i.id=Number(s)}return i}function _(e,t){return(0,i.fromMiliseconds)((t||Date.now())+(0,i.toMiliseconds)(e))}function N(e){return Date.now()>=(0,i.toMiliseconds)(e)}function A(e,t){return`${e}${t?`:${t}`:""}`}function C(e=[],t=[]){return[...new Set([...e,...t])]}async function P({id:e,topic:t,wcDeepLink:i}){var n;try{if(!i)return;const o="string"==typeof i?JSON.parse(i):i,a=o?.href;if("string"!=typeof a)return;const c=function(e,t,s){const i=`requestId=${t}&sessionTopic=${s}`;e.endsWith("/")&&(e=e.slice(0,-1));let r=`${e}`;return r=e.startsWith("https://t.me")?`${r}${e.includes("?")?"&startapp=":"?startapp="}${function(e,t=!1){const s=l.from(e).toString("base64");return t?s.replace(/[=]/g,""):s}(i,!0)}`:`${r}/wc?${i}`,r}(a,e,t),h=w()?f.reactNative:m()?f.node:y()?f.browser:f.unknown;if(h===f.browser){if(null==(n=(0,r.getDocument)())||!n.hasFocus())return void console.warn("Document does not have focus, skipping deeplink.");!function(e){let t="_self";!function(){try{return window.self!==window.top}catch{return!1}}()?(typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)||e.startsWith("https://")||e.startsWith("http://"))&&(t="_blank"):t="_top",window.open(e,t,"noreferrer noopener")}(c)}else h===f.reactNative&&typeof(null==s.g?void 0:s.g.Linking)<"u"&&await s.g.Linking.openURL(c)}catch(e){console.error(e)}}async function S(e,t){let s="";try{if(y()&&(s=localStorage.getItem(t),s))return s;s=await e.getItem(t)}catch(e){console.error(e)}return s}function O(e,t){if(!e.includes(t))return null;const s=e.split(/([&,?,=])/),i=s.indexOf(t);return s[i+2]}function T(){return typeof h<"u"&&"true"===h.env.IS_VITEST}function k(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function x(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function R(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function U(e,t){x(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const D=BigInt(2**32-1),j=BigInt(32);function M(e,t=!1){return t?{h:Number(e&D),l:Number(e>>j&D)}:{h:0|Number(e>>j&D),l:0|Number(e&D)}}const L="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function q(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function $(e,t){return e<<32-t|e>>>t}const B=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function H(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function W(e){for(let t=0;t<e.length;t++)e[t]=H(e[t])}function z(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),x(e),e}class V{clone(){return this._cloneInto()}}function F(e){const t=t=>e().update(z(t)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}const K=[],G=[],J=[],Y=BigInt(0),Q=BigInt(1),X=BigInt(2),Z=BigInt(7),ee=BigInt(256),te=BigInt(113);for(let e=0,t=Q,s=1,i=0;e<24;e++){[s,i]=[i,(2*s+3*i)%5],K.push(2*(5*i+s)),G.push((e+1)*(e+2)/2%64);let r=Y;for(let e=0;e<7;e++)t=(t<<Q^(t>>Z)*te)%ee,t&X&&(r^=Q<<(Q<<BigInt(e))-Q);J.push(r)}const[se,ie]=function(e,t=!1){let s=new Uint32Array(e.length),i=new Uint32Array(e.length);for(let r=0;r<e.length;r++){const{h:n,l:o}=M(e[r],t);[s[r],i[r]]=[n,o]}return[s,i]}(J,!0),re=(e,t,s)=>s>32?((e,t,s)=>t<<s-32|e>>>64-s)(e,t,s):((e,t,s)=>e<<s|t>>>32-s)(e,t,s),ne=(e,t,s)=>s>32?((e,t,s)=>e<<s-32|t>>>64-s)(e,t,s):((e,t,s)=>t<<s|e>>>32-s)(e,t,s);class oe extends V{constructor(e,t,s,i=!1,r=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=s,this.enableXOF=i,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,k(s),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var n;this.state=new Uint8Array(200),this.state32=(n=this.state,new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)))}keccak(){B||W(this.state32),function(e,t=24){const s=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let t=0;t<10;t++)s[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const i=(t+8)%10,r=(t+2)%10,n=s[r],o=s[r+1],a=re(n,o,1)^s[i],c=ne(n,o,1)^s[i+1];for(let s=0;s<50;s+=10)e[t+s]^=a,e[t+s+1]^=c}let t=e[2],r=e[3];for(let s=0;s<24;s++){const i=G[s],n=re(t,r,i),o=ne(t,r,i),a=K[s];t=e[a],r=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let i=0;i<10;i++)s[i]=e[t+i];for(let i=0;i<10;i++)e[t+i]^=~s[(i+2)%10]&s[(i+4)%10]}e[0]^=se[i],e[1]^=ie[i]}s.fill(0)}(this.state32,this.rounds),B||W(this.state32),this.posOut=0,this.pos=0}update(e){R(this);const{blockLen:t,state:s}=this,i=(e=z(e)).length;for(let r=0;r<i;){const n=Math.min(t-this.pos,i-r);for(let t=0;t<n;t++)s[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:s,blockLen:i}=this;e[s]^=t,!!(128&t)&&s===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){R(this,!1),x(e),this.finish();const t=this.state,{blockLen:s}=this;for(let i=0,r=e.length;i<r;){this.posOut>=s&&this.keccak();const n=Math.min(s-this.posOut,r-i);e.set(t.subarray(this.posOut,this.posOut+n),i),this.posOut+=n,i+=n}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return k(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(U(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:s,outputLen:i,rounds:r,enableXOF:n}=this;return e||(e=new oe(t,s,i,n,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=s,e.outputLen=i,e.enableXOF=n,e.destroyed=this.destroyed,e}}const ae=F(()=>new oe(136,1,32)),ce="https://rpc.walletconnect.org/v1";function he(e){const t=`Ethereum Signed Message:\n${e.length}`,s=(new TextEncoder).encode(t+e);return"0x"+l.from(ae(s)).toString("hex")}function le(e){const t=atob(e),s=new Uint8Array(t.length);for(let e=0;e<t.length;e++)s[e]=t.charCodeAt(e);const i=s[0];if(0===i)throw new Error("No signatures found");const r=1+64*i;if(s.length<r)throw new Error("Transaction data too short for claimed signature count");if(s.length<100)throw new Error("Transaction too short");const n=l.from(e,"base64").slice(1,65);return a.A.encode(n)}var pe=Object.defineProperty,de=Object.defineProperties,ue=Object.getOwnPropertyDescriptors,ge=Object.getOwnPropertySymbols,fe=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable,we=(e,t,s)=>t in e?pe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,ye=(e,t)=>{for(var s in t||(t={}))fe.call(t,s)&&we(e,s,t[s]);if(ge)for(var s of ge(t))me.call(t,s)&&we(e,s,t[s]);return e},be=(e,t)=>de(e,ue(t));const ve=e=>e?.split(":"),Ee=e=>{const t=e&&ve(e);if(t)return t[2]+":"+t[3]},Ie=e=>{const t=e&&ve(e);if(t)return t.pop()};async function _e(e){const{cacao:t,projectId:s}=e,{s:i,p:r}=t,n=Ne(r,r.iss),a=Ie(r.iss);return await async function(e,t,s,i,r,n){switch(s.t){case"eip191":return await async function(e,t,s){return(await(0,o.x)({hash:he(t),signature:s})).toLowerCase()===e.toLowerCase()}(e,t,s.s);case"eip1271":return await async function(e,t,s,i,r,n){const o=d(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const o="0x1626ba7e",a="0000000000000000000000000000000000000000000000000000000000000040",c="0000000000000000000000000000000000000000000000000000000000000041",h=s.substring(2),l=o+he(t).substring(2)+a+c+h,p=await fetch(`${n||ce}/?chainId=${i}&projectId=${r}`,{method:"POST",body:JSON.stringify({id:Date.now()+Math.floor(1e3*Math.random()),jsonrpc:"2.0",method:"eth_call",params:[{to:e,data:l},"latest"]})}),{result:d}=await p.json();return!!d&&d.slice(0,o.length).toLowerCase()===o.toLowerCase()}catch(e){return console.error("isValidEip1271Signature: ",e),!1}}(e,t,s.s,i,r,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${s.t}`)}}(a,n,i,Ee(r.iss),s)}const Ne=(e,t)=>{const s=`${e.domain} wants you to sign in with your Ethereum account:`,i=Ie(t);if(!e.aud&&!e.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let r=e.statement||void 0;const n=`URI: ${e.aud||e.uri}`,o=`Version: ${e.version}`,a=`Chain ID: ${(e=>{const t=e&&ve(e);if(t)return e.includes("did:pkh:")?t[3]:t[1]})(t)}`,c=`Nonce: ${e.nonce}`,h=`Issued At: ${e.iat}`,l=e.exp?`Expiration Time: ${e.exp}`:void 0,p=e.nbf?`Not Before: ${e.nbf}`:void 0,d=e.requestId?`Request ID: ${e.requestId}`:void 0,u=e.resources?`Resources:${e.resources.map(e=>`\n- ${e}`).join("")}`:void 0,g=Re(e.resources);return g&&(r=function(e="",t){Ae(t);const s="I further authorize the stated URI to perform the following actions on my behalf: ";if(e.includes(s))return e;const i=[];let r=0;return Object.keys(t.att).forEach(e=>{const s=Object.keys(t.att[e]).map(e=>({ability:e.split("/")[0],action:e.split("/")[1]}));s.sort((e,t)=>e.action.localeCompare(t.action));const n={};s.forEach(e=>{n[e.ability]||(n[e.ability]=[]),n[e.ability].push(e.action)});const o=Object.keys(n).map(t=>(r++,`(${r}) '${t}': '${n[t].join("', '")}' for '${e}'.`));i.push(o.join(", ").replace(".,","."))}),`${e?e+" ":""}${s}${i.join(" ")}`}(r,Se(g))),[s,i,"",r,"",n,o,a,c,h,l,p,d,u].filter(e=>null!=e).join("\n")};function Ae(e){if(!e)throw new Error("No recap provided, value is undefined");if(!e.att)throw new Error("No `att` property found");const t=Object.keys(e.att);if(null==t||!t.length)throw new Error("No resources found in `att` property");t.forEach(t=>{const s=e.att[t];if(Array.isArray(s))throw new Error(`Resource must be an object: ${t}`);if("object"!=typeof s)throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(s).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(s).forEach(e=>{const t=s[e];if(!Array.isArray(t))throw new Error(`Ability limits ${e} must be an array of objects, found: ${t}`);if(!t.length)throw new Error(`Value of ${e} is empty array, must be an array with objects`);t.forEach(t=>{if("object"!=typeof t)throw new Error(`Ability limits (${e}) must be an array of objects, found: ${t}`)})})})}function Ce(e,t,s={}){t=t?.sort((e,t)=>e.localeCompare(t));const i=t.map(t=>({[`${e}/${t}`]:[s]}));return Object.assign({},...i)}function Pe(e){return Ae(e),`urn:recap:${function(e){return l.from(JSON.stringify(e)).toString("base64")}(e).replace(/=/g,"")}`}function Se(e){const t=function(e){return JSON.parse(l.from(e,"base64").toString("utf-8"))}(e.replace("urn:recap:",""));return Ae(t),t}function Oe(e,t,s){const i=function(e,t,s,i={}){return s?.sort((e,t)=>e.localeCompare(t)),{att:{[e]:Ce(t,s,i)}}}(e,t,s);return Pe(i)}function Te(e,t){const s=function(e,t){Ae(e),Ae(t);const s=Object.keys(e.att).concat(Object.keys(t.att)).sort((e,t)=>e.localeCompare(t)),i={att:{}};return s.forEach(s=>{var r,n;Object.keys((null==(r=e.att)?void 0:r[s])||{}).concat(Object.keys((null==(n=t.att)?void 0:n[s])||{})).sort((e,t)=>e.localeCompare(t)).forEach(r=>{var n,o;i.att[s]=be(ye({},i.att[s]),{[r]:(null==(n=e.att[s])?void 0:n[r])||(null==(o=t.att[s])?void 0:o[r])})})}),i}(Se(e),Se(t));return Pe(s)}function ke(e){var t;const s=Se(e);Ae(s);const i=null==(t=s.att)?void 0:t.eip155;return i?Object.keys(i).map(e=>e.split("/")[1]):[]}function xe(e){const t=Se(e);Ae(t);const s=[];return Object.values(t.att).forEach(e=>{Object.values(e).forEach(e=>{var t;null!=(t=e?.[0])&&t.chains&&s.push(e[0].chains)})}),[...new Set(s.flat())]}function Re(e){if(!e)return;const t=e?.[e.length-1];return function(e){return e&&e.includes("urn:recap:")}(t)?t:void 0}function Ue(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function De(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function je(e,...t){if(!De(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Me(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Le(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}const qe=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function $e(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!De(e))throw new Error("Uint8Array expected, got "+typeof e);e=We(e)}return e}function Be(e,t,s=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(s&&!function(e){return e.byteOffset%4==0}(t))throw new Error("invalid output, must be aligned");return t}function He(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(s>>r&n),a=Number(s&n),c=i?4:0,h=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+h,a,i)}function We(e){return Uint8Array.from(e)}function ze(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const Ve=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),Fe=Ve("expand 16-byte k"),Ke=Ve("expand 32-byte k"),Ge=qe(Fe),Je=qe(Ke);function Ye(e,t){return e<<t|e>>>32-t}function Qe(e){return e.byteOffset%4==0}const Xe=2**32-1,Ze=new Uint32Array,et=(e,t)=>255&e[t++]|(255&e[t++])<<8;class tt{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,je(e=$e(e),32);const t=et(e,0),s=et(e,2),i=et(e,4),r=et(e,6),n=et(e,8),o=et(e,10),a=et(e,12),c=et(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|s<<3),this.r[2]=7939&(s>>>10|i<<6),this.r[3]=8191&(i>>>7|r<<9),this.r[4]=255&(r>>>4|n<<12),this.r[5]=n>>>1&8190,this.r[6]=8191&(n>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=et(e,16+2*t)}process(e,t,s=!1){const i=s?0:2048,{h:r,r:n}=this,o=n[0],a=n[1],c=n[2],h=n[3],l=n[4],p=n[5],d=n[6],u=n[7],g=n[8],f=n[9],m=et(e,t+0),w=et(e,t+2),y=et(e,t+4),b=et(e,t+6),v=et(e,t+8),E=et(e,t+10),I=et(e,t+12),_=et(e,t+14);let N=r[0]+(8191&m),A=r[1]+(8191&(m>>>13|w<<3)),C=r[2]+(8191&(w>>>10|y<<6)),P=r[3]+(8191&(y>>>7|b<<9)),S=r[4]+(8191&(b>>>4|v<<12)),O=r[5]+(v>>>1&8191),T=r[6]+(8191&(v>>>14|E<<2)),k=r[7]+(8191&(E>>>11|I<<5)),x=r[8]+(8191&(I>>>8|_<<8)),R=r[9]+(_>>>5|i),U=0,D=U+N*o+A*(5*f)+C*(5*g)+P*(5*u)+S*(5*d);U=D>>>13,D&=8191,D+=O*(5*p)+T*(5*l)+k*(5*h)+x*(5*c)+R*(5*a),U+=D>>>13,D&=8191;let j=U+N*a+A*o+C*(5*f)+P*(5*g)+S*(5*u);U=j>>>13,j&=8191,j+=O*(5*d)+T*(5*p)+k*(5*l)+x*(5*h)+R*(5*c),U+=j>>>13,j&=8191;let M=U+N*c+A*a+C*o+P*(5*f)+S*(5*g);U=M>>>13,M&=8191,M+=O*(5*u)+T*(5*d)+k*(5*p)+x*(5*l)+R*(5*h),U+=M>>>13,M&=8191;let L=U+N*h+A*c+C*a+P*o+S*(5*f);U=L>>>13,L&=8191,L+=O*(5*g)+T*(5*u)+k*(5*d)+x*(5*p)+R*(5*l),U+=L>>>13,L&=8191;let q=U+N*l+A*h+C*c+P*a+S*o;U=q>>>13,q&=8191,q+=O*(5*f)+T*(5*g)+k*(5*u)+x*(5*d)+R*(5*p),U+=q>>>13,q&=8191;let $=U+N*p+A*l+C*h+P*c+S*a;U=$>>>13,$&=8191,$+=O*o+T*(5*f)+k*(5*g)+x*(5*u)+R*(5*d),U+=$>>>13,$&=8191;let B=U+N*d+A*p+C*l+P*h+S*c;U=B>>>13,B&=8191,B+=O*a+T*o+k*(5*f)+x*(5*g)+R*(5*u),U+=B>>>13,B&=8191;let H=U+N*u+A*d+C*p+P*l+S*h;U=H>>>13,H&=8191,H+=O*c+T*a+k*o+x*(5*f)+R*(5*g),U+=H>>>13,H&=8191;let W=U+N*g+A*u+C*d+P*p+S*l;U=W>>>13,W&=8191,W+=O*h+T*c+k*a+x*o+R*(5*f),U+=W>>>13,W&=8191;let z=U+N*f+A*g+C*u+P*d+S*p;U=z>>>13,z&=8191,z+=O*l+T*h+k*c+x*a+R*o,U+=z>>>13,z&=8191,U=(U<<2)+U|0,U=U+D|0,D=8191&U,U>>>=13,j+=U,r[0]=D,r[1]=j,r[2]=M,r[3]=L,r[4]=q,r[5]=$,r[6]=B,r[7]=H,r[8]=W,r[9]=z}finalize(){const{h:e,pad:t}=this,s=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=i,i=e[t]>>>13,e[t]&=8191;e[0]+=5*i,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,s[0]=e[0]+5,i=s[0]>>>13,s[0]&=8191;for(let t=1;t<10;t++)s[t]=e[t]+i,i=s[t]>>>13,s[t]&=8191;s[9]-=8192;let r=(1^i)-1;for(let e=0;e<10;e++)s[e]&=r;r=~r;for(let t=0;t<10;t++)e[t]=e[t]&r|s[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let n=e[0]+t[0];e[0]=65535&n;for(let s=1;s<8;s++)n=(e[s]+t[s]|0)+(n>>>16)|0,e[s]=65535&n;ze(s)}update(e){Me(this);const{buffer:t,blockLen:s}=this,i=(e=$e(e)).length;for(let r=0;r<i;){const n=Math.min(s-this.pos,i-r);if(n!==s)t.set(e.subarray(r,r+n),this.pos),this.pos+=n,r+=n,this.pos===s&&(this.process(t,0,!1),this.pos=0);else for(;s<=i-r;r+=s)this.process(e,r)}return this}destroy(){ze(this.h,this.r,this.buffer,this.pad)}digestInto(e){Me(this),function(e,t){je(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}(e,this),this.finished=!0;const{buffer:t,h:s}=this;let{pos:i}=this;if(i){for(t[i++]=1;i<16;i++)t[i]=0;this.process(t,0,!0)}this.finalize();let r=0;for(let t=0;t<8;t++)e[r++]=s[t]>>>0,e[r++]=s[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}}const st=function(e){const t=(t,s)=>e(s).update($e(t)).digest(),s=e(new Uint8Array(32));return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=t=>e(t),t}(e=>new tt(e)),it=function(e){const{allowShortKeys:t,extendNonceFn:s,counterLength:i,counterRight:r,rounds:n}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t)}(0,{counterRight:!1,counterLength:4,allowShortKeys:!1});return Ue(i),Ue(n),Le(r),Le(t),(o,a,c,h,l=0)=>{je(o),je(a),je(c);const p=c.length;if(void 0===h&&(h=new Uint8Array(p)),je(h),Ue(l),l<0||l>=Xe)throw new Error("arx: counter overflow");if(h.length<p)throw new Error(`arx: output (${h.length}) is shorter than data (${p})`);const d=[];let u,g,f=o.length;if(32===f)d.push(u=We(o)),g=Je;else{if(16!==f||!t)throw new Error(`arx: invalid 32-byte key, got length=${f}`);u=new Uint8Array(32),u.set(o),u.set(o,16),g=Ge,d.push(u)}Qe(a)||d.push(a=We(a));const m=qe(u);if(s){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");s(g,m,qe(a.subarray(0,16)),m),a=a.subarray(16)}const w=16-i;if(w!==a.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(12!==w){const e=new Uint8Array(12);e.set(a,r?0:12-a.length),a=e,d.push(a)}const y=qe(a);return function(e,t,s,i,r,n,o,a){const c=r.length,h=new Uint8Array(64),l=qe(h),p=Qe(r)&&Qe(n),d=p?qe(r):Ze,u=p?qe(n):Ze;for(let g=0;g<c;o++){if(e(t,s,i,l,o,a),o>=Xe)throw new Error("arx: counter overflow");const f=Math.min(64,c-g);if(p&&64===f){const e=g/4;if(g%4!=0)throw new Error("arx: invalid block position");for(let t,s=0;s<16;s++)t=e+s,u[t]=d[t]^l[s];g+=64;continue}for(let e,t=0;t<f;t++)e=g+t,n[e]=r[e]^h[t];g+=f}}(e,g,m,y,c,h,l,n),ze(...d),h}}(function(e,t,s,i,r,n=20){let o=e[0],a=e[1],c=e[2],h=e[3],l=t[0],p=t[1],d=t[2],u=t[3],g=t[4],f=t[5],m=t[6],w=t[7],y=r,b=s[0],v=s[1],E=s[2],I=o,_=a,N=c,A=h,C=l,P=p,S=d,O=u,T=g,k=f,x=m,R=w,U=y,D=b,j=v,M=E;for(let e=0;e<n;e+=2)I=I+C|0,U=Ye(U^I,16),T=T+U|0,C=Ye(C^T,12),I=I+C|0,U=Ye(U^I,8),T=T+U|0,C=Ye(C^T,7),_=_+P|0,D=Ye(D^_,16),k=k+D|0,P=Ye(P^k,12),_=_+P|0,D=Ye(D^_,8),k=k+D|0,P=Ye(P^k,7),N=N+S|0,j=Ye(j^N,16),x=x+j|0,S=Ye(S^x,12),N=N+S|0,j=Ye(j^N,8),x=x+j|0,S=Ye(S^x,7),A=A+O|0,M=Ye(M^A,16),R=R+M|0,O=Ye(O^R,12),A=A+O|0,M=Ye(M^A,8),R=R+M|0,O=Ye(O^R,7),I=I+P|0,M=Ye(M^I,16),x=x+M|0,P=Ye(P^x,12),I=I+P|0,M=Ye(M^I,8),x=x+M|0,P=Ye(P^x,7),_=_+S|0,U=Ye(U^_,16),R=R+U|0,S=Ye(S^R,12),_=_+S|0,U=Ye(U^_,8),R=R+U|0,S=Ye(S^R,7),N=N+O|0,D=Ye(D^N,16),T=T+D|0,O=Ye(O^T,12),N=N+O|0,D=Ye(D^N,8),T=T+D|0,O=Ye(O^T,7),A=A+C|0,j=Ye(j^A,16),k=k+j|0,C=Ye(C^k,12),A=A+C|0,j=Ye(j^A,8),k=k+j|0,C=Ye(C^k,7);let L=0;i[L++]=o+I|0,i[L++]=a+_|0,i[L++]=c+N|0,i[L++]=h+A|0,i[L++]=l+C|0,i[L++]=p+P|0,i[L++]=d+S|0,i[L++]=u+O|0,i[L++]=g+T|0,i[L++]=f+k|0,i[L++]=m+x|0,i[L++]=w+R|0,i[L++]=y+U|0,i[L++]=b+D|0,i[L++]=v+j|0,i[L++]=E+M|0}),rt=new Uint8Array(16),nt=(e,t)=>{e.update(t);const s=t.length%16;s&&e.update(rt.subarray(s))},ot=new Uint8Array(32);function at(e,t,s,i,r){const n=e(t,s,ot),o=st.create(n);r&&nt(o,r),nt(o,i);const a=new Uint8Array(16),c=(e=>new DataView(e.buffer,e.byteOffset,e.byteLength))(a);He(c,0,BigInt(r?r.length:0),!0),He(c,8,BigInt(i.length),!0),o.update(a);const h=o.digest();return ze(n,a),h}((e,t)=>{Object.assign(function(s,...i){if(je(s),void 0!==e.nonceLength){const t=i[0];if(!t)throw new Error("nonce / iv required");e.varSizeNonce?je(t):je(t,e.nonceLength)}const r=e.tagLength;r&&void 0!==i[1]&&je(i[1]);const n=t(s,...i),o=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");je(t)}};let a=!1;return{encrypt(e,t){if(a)throw new Error("cannot encrypt() twice with same key + nonce");return a=!0,je(e),o(n.encrypt.length,t),n.encrypt(e,t)},decrypt(e,t){if(je(e),r&&e.length<r)throw new Error("invalid ciphertext length: smaller than tagLength="+r);return o(n.decrypt.length,t),n.decrypt(e,t)}}},e)})({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,s,i)=>({encrypt(r,n){const o=r.length;(n=Be(o+16,n,!1)).set(r);const a=n.subarray(0,-16);e(t,s,a,a,1);const c=at(e,t,s,a,i);return n.set(c,o),ze(c),n},decrypt(r,n){n=Be(r.length-16,n,!1);const o=r.subarray(0,-16),a=r.subarray(-16),c=at(e,t,s,o,i);if(!function(e,t){if(e.length!==t.length)return!1;let s=0;for(let i=0;i<e.length;i++)s|=e[i]^t[i];return 0===s}(a,c))throw new Error("invalid tag");return n.set(r.subarray(0,-16)),e(t,s,n,n,1),ze(c),n}}))(it));function ct(e,t,s){return e&t^~e&s}function ht(e,t,s){return e&t^e&s^t&s}new Uint8Array([0]),new Uint8Array;class lt extends V{constructor(e,t,s,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=q(this.buffer)}update(e){R(this);const{view:t,buffer:s,blockLen:i}=this,r=(e=z(e)).length;for(let n=0;n<r;){const o=Math.min(i-this.pos,r-n);if(o===i){const t=q(e);for(;i<=r-n;n+=i)this.process(t,n);continue}s.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){R(this),U(e,this),this.finished=!0;const{buffer:t,view:s,blockLen:i,isLE:r}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>i-n&&(this.process(s,0),n=0);for(let e=n;e<i;e++)t[e]=0;(function(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(s>>r&n),a=Number(s&n),c=i?4:0,h=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+h,a,i)})(s,i-8,BigInt(8*this.length),r),this.process(s,0);const o=q(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,h[e],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:s,length:i,finished:r,destroyed:n,pos:o}=this;return e.length=i,e.pos=o,e.finished=r,e.destroyed=n,i%t&&e.buffer.set(s),e}}const pt=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),dt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ut=new Uint32Array(64);class gt extends lt{constructor(){super(64,32,8,!1),this.A=0|dt[0],this.B=0|dt[1],this.C=0|dt[2],this.D=0|dt[3],this.E=0|dt[4],this.F=0|dt[5],this.G=0|dt[6],this.H=0|dt[7]}get(){const{A:e,B:t,C:s,D:i,E:r,F:n,G:o,H:a}=this;return[e,t,s,i,r,n,o,a]}set(e,t,s,i,r,n,o,a){this.A=0|e,this.B=0|t,this.C=0|s,this.D=0|i,this.E=0|r,this.F=0|n,this.G=0|o,this.H=0|a}process(e,t){for(let s=0;s<16;s++,t+=4)ut[s]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=ut[e-15],s=ut[e-2],i=$(t,7)^$(t,18)^t>>>3,r=$(s,17)^$(s,19)^s>>>10;ut[e]=r+ut[e-7]+i+ut[e-16]|0}let{A:s,B:i,C:r,D:n,E:o,F:a,G:c,H:h}=this;for(let e=0;e<64;e++){const t=h+($(o,6)^$(o,11)^$(o,25))+ct(o,a,c)+pt[e]+ut[e]|0,l=($(s,2)^$(s,13)^$(s,22))+ht(s,i,r)|0;h=c,c=a,a=o,o=n+t|0,n=r,r=i,i=s,s=t+l|0}s=s+this.A|0,i=i+this.B|0,r=r+this.C|0,n=n+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(s,i,r,n,o,a,c,h)}roundClean(){ut.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ft=F(()=>new gt);BigInt(0);function mt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function wt(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function yt(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,s=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(s);for(let t=0,r=0;t<s;t++,r+=2){const s=wt(e.charCodeAt(r)),n=wt(e.charCodeAt(r+1));if(void 0===s||void 0===n){const t=e[r]+e[r+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+r)}i[t]=16*s+n}return i}const bt={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||mt(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)},vt=BigInt(0);BigInt(1);function Et(e,t){const s=e%t;return s>=vt?s:t+s}function It(e,t,s){let i=e;for(;t-- >vt;)i*=i,i%=s;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);BigInt(0),BigInt(1);const _t=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const Nt=BigInt(1),At=BigInt(2),Ct=BigInt(3),Pt=BigInt(5);BigInt(8),function(e){const t=function(e){return function(e,t,s={}){const i=(t,s,i)=>{const r=bt[s];if("function"!=typeof r)throw new Error("invalid validator function");const n=e[t];if(!(i&&void 0===n||r(n,e)))throw new Error("param "+String(t)+" is invalid. Expected "+s+", got "+n)};for(const[e,s]of Object.entries(t))i(e,s,!1);for(const[e,t]of Object.entries(s))i(e,t,!0)}(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:s}=t,i=e=>Et(e,s),r=t.montgomeryBits,n=Math.ceil(r/8);t.nByteLength,t.adjustScalarBytes,t.powPminus2;t.a,BigInt(2),BigInt(4);function o(e){return function(e,t){return function(e,t){return yt(e.toString(16).padStart(2*t,"0"))}(e,t).reverse()}(i(e),n)}o(t.Gu)}({P:_t,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=_t,{pow_p_5_8:s,b2:i}=function(e){const t=BigInt(10),s=BigInt(20),i=BigInt(40),r=BigInt(80),n=_t,o=e*e%n*e%n,a=It(o,At,n)*o%n,c=It(a,Nt,n)*e%n,h=It(c,Pt,n)*c%n,l=It(h,t,n)*h%n,p=It(l,s,n)*l%n,d=It(p,i,n)*p%n,u=It(d,r,n)*d%n,g=It(u,r,n)*d%n,f=It(g,t,n)*h%n;return{pow_p_5_8:It(f,At,n)*e%n,b2:o}}(e);return Et(It(s,Ct,t)*i,t)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},randomBytes:function(e=32){if(L&&"function"==typeof L.getRandomValues)return L.getRandomValues(new Uint8Array(e));if(L&&"function"==typeof L.randomBytes)return L.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}});const St="base16",Ot="base64pad",Tt="base64url",kt="utf8",xt=1,Rt=2;function Ut(e){const t=ft((0,c.sH)(e,St));return(0,c.dI)(t,St)}function Dt(e){const t=ft((0,c.sH)(e,kt));return(0,c.dI)(t,St)}function jt(e,t,s){return`${e}?wc_ev=${s}&topic=${t}`}function Mt(e){const t=[];return e.forEach(e=>{const[s,i]=e.split(":");t.push(`${s}:${i}`)}),t}function Lt(e,t){const s=function(e){const t={};return e?.forEach(e=>{var s;const[i,r]=e.split(":");t[i]||(t[i]={accounts:[],chains:[],events:[],methods:[]}),t[i].accounts.push(e),null==(s=t[i].chains)||s.push(`${i}:${r}`)}),t}(t=t.map(e=>e.replace("did:pkh:","")));for(const[t,i]of Object.entries(s))i.methods?i.methods=C(i.methods,e):i.methods=e,i.events=["chainChanged","accountsChanged"];return s}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const qt={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},$t={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function Bt(e,t){const{message:s,code:i}=$t[e];return{message:t?`${s} ${t}`:s,code:i}}function Ht(e,t){const{message:s,code:i}=qt[e];return{message:t?`${s} ${t}`:s,code:i}}function Wt(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function zt(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function Vt(e){return typeof e>"u"}function Ft(e,t){return!(!t||!Vt(e))||"string"==typeof e&&!!e.trim().length}function Kt(e,t){return!(!t||!Vt(e))||"number"==typeof e&&!isNaN(e)}function Gt(e,t){const{requiredNamespaces:s}=t,i=Object.keys(e.namespaces),r=Object.keys(s);let n=!0;return!!v(r,i)&&(i.forEach(t=>{const{accounts:i,methods:r,events:o}=e.namespaces[t],a=Mt(i),c=s[t];v(u(t,c),a)&&v(c.methods,r)&&v(c.events,o)||(n=!1)}),n)}function Jt(e){return!(!Ft(e,!1)||!e.includes(":"))&&2===e.split(":").length}function Yt(e,t){let s=null;return Ft(e?.publicKey,!1)||(s=Bt("MISSING_OR_INVALID",`${t} controller public key should be a string`)),s}function Qt(e){let t=!0;return Wt(e)?e.length&&(t=e.every(e=>Ft(e,!1))):t=!1,t}function Xt(e,t){let s=null;return Object.values(e).forEach(e=>{if(s)return;const i=function(e,t){let s=null;return Qt(e?.methods)?Qt(e?.events)||(s=Ht("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):s=Ht("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),s}(e,`${t}, namespace`);i&&(s=i)}),s}function Zt(e,t,s){let i=null;if(e&&zt(e)){const r=Xt(e,t);r&&(i=r);const n=function(e,t,s){let i=null;return Object.entries(e).forEach(([e,r])=>{if(i)return;const n=function(e,t,s){let i=null;return Wt(t)&&t.length?t.forEach(e=>{i||Jt(e)||(i=Ht("UNSUPPORTED_CHAINS",`${s}, chain ${e} should be a string and conform to "namespace:chainId" format`))}):Jt(e)||(i=Ht("UNSUPPORTED_CHAINS",`${s}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}(e,u(e,r),`${t} ${s}`);n&&(i=n)}),i}(e,t,s);n&&(i=n)}else i=Bt("MISSING_OR_INVALID",`${t}, ${s} should be an object with data`);return i}function es(e,t){let s=null;if(e&&zt(e)){const i=Xt(e,t);i&&(s=i);const r=function(e,t){let s=null;return Object.values(e).forEach(e=>{if(s)return;const i=function(e,t){let s=null;return Wt(e)?e.forEach(e=>{s||function(e){if(Ft(e,!1)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&Jt(e)}}return!1}(e)||(s=Ht("UNSUPPORTED_ACCOUNTS",`${t}, account ${e} should be a string and conform to "namespace:chainId:address" format`))}):s=Ht("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),s}(e?.accounts,`${t} namespace`);i&&(s=i)}),s}(e,t);r&&(s=r)}else s=Bt("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return s}function ts(e){return Ft(e.protocol,!0)}function ss(e,t){let s=!1;return t&&!e?s=!0:e&&Wt(e)&&e.length&&e.forEach(e=>{s=ts(e)}),s}function is(e){return"number"==typeof e}function rs(e){return typeof e<"u"&&null!==typeof e}function ns(e){return!!(e&&"object"==typeof e&&e.code&&Kt(e.code,!1)&&e.message&&Ft(e.message,!1))}function os(e){return!(Vt(e)||!Ft(e.method,!1))}function as(e){return!(Vt(e)||Vt(e.result)&&Vt(e.error)||!Kt(e.id,!1)||!Ft(e.jsonrpc,!1))}function cs(e){return!(Vt(e)||!Ft(e.name,!1))}function hs(e,t){return!(!Jt(t)||!function(e){const t=[];return Object.values(e).forEach(e=>{t.push(...Mt(e.accounts))}),t}(e).includes(t))}function ls(e,t,s){return!!Ft(s,!1)&&function(e,t){const s=[];return Object.values(e).forEach(e=>{Mt(e.accounts).includes(t)&&s.push(...e.methods)}),s}(e,t).includes(s)}function ps(e,t,s){return!!Ft(s,!1)&&function(e,t){const s=[];return Object.values(e).forEach(e=>{Mt(e.accounts).includes(t)&&s.push(...e.events)}),s}(e,t).includes(s)}function ds(e,t,s){let i=null;const r=function(e){const t={};return Object.keys(e).forEach(s=>{var i;s.includes(":")?t[s]=e[s]:null==(i=e[s].chains)||i.forEach(i=>{t[i]={methods:e[s].methods,events:e[s].events}})}),t}(e),n=function(e){const t={};return Object.keys(e).forEach(s=>{if(s.includes(":"))t[s]=e[s];else{const i=Mt(e[s].accounts);i?.forEach(i=>{t[i]={accounts:e[s].accounts.filter(e=>e.includes(`${i}:`)),methods:e[s].methods,events:e[s].events}})}}),t}(t),o=Object.keys(r),a=Object.keys(n),c=us(Object.keys(e)),h=us(Object.keys(t)),l=c.filter(e=>!h.includes(e));return l.length&&(i=Bt("NON_CONFORMING_NAMESPACES",`${s} namespaces keys don't satisfy requiredNamespaces.\n Required: ${l.toString()}\n Received: ${Object.keys(t).toString()}`)),v(o,a)||(i=Bt("NON_CONFORMING_NAMESPACES",`${s} namespaces chains don't satisfy required namespaces.\n Required: ${o.toString()}\n Approved: ${a.toString()}`)),Object.keys(t).forEach(e=>{if(!e.includes(":")||i)return;const r=Mt(t[e].accounts);r.includes(e)||(i=Bt("NON_CONFORMING_NAMESPACES",`${s} namespaces accounts don't satisfy namespace accounts for ${e}\n Required: ${e}\n Approved: ${r.toString()}`))}),o.forEach(e=>{i||(v(r[e].methods,n[e].methods)?v(r[e].events,n[e].events)||(i=Bt("NON_CONFORMING_NAMESPACES",`${s} namespaces events don't satisfy namespace events for ${e}`)):i=Bt("NON_CONFORMING_NAMESPACES",`${s} namespaces methods don't satisfy namespace methods for ${e}`))}),i}function us(e){return[...new Set(e.map(e=>e.includes(":")?e.split(":")[0]:e))]}function gs(e,t){return Kt(e,!1)&&e<=t.max&&e>=t.min}const fs={};class ms{static get(e){return fs[e]}static set(e,t){fs[e]=t}static delete(e){delete fs[e]}}},46779:(e,t,s)=>{s.d(t,{n:()=>u});var i=s(33244),r=s(38903),n=s(95191),o=s(16279),a=s(99013),c=s(84253),h=s(5813),l=s(33816),p=s(76663),d=s(24529);class u extends l.X{setUniversalProvider(e){this.addConnector(new p.F({provider:e,caipNetworks:this.caipNetworks||[],namespace:this.namespace}))}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{const e=this.getWalletConnectConnector();await e.disconnect()}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}}async getAccounts({namespace:e}){const t=this.provider,s=t?.session?.namespaces?.[e]?.accounts?.map(e=>{const[,,t]=e.split(":");return t}).filter((e,t,s)=>s.indexOf(e)===t)||[];return Promise.resolve({accounts:s.map(t=>h.w.createAccount(e,t,"bip122"===e?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){if(!e.caipNetwork||!c.oU.BALANCE_SUPPORTED_CHAINS.includes(e.caipNetwork?.chainNamespace)||e.caipNetwork?.testnet)return{balance:"0.00",symbol:e.caipNetwork?.nativeCurrency.symbol||""};if(o.U.state.balanceLoading&&e.chainId===a.W.state.activeCaipNetwork?.id)return{balance:o.U.state.balance||"0.00",symbol:o.U.state.balanceSymbol||""};const t=(await o.U.fetchTokenBalance()).find(t=>t.chainId===`${e.caipNetwork?.chainNamespace}:${e.chainId}`&&t.symbol===e.caipNetwork?.nativeCurrency.symbol);return{balance:t?.quantity.numeric||"0.00",symbol:t?.symbol||e.caipNetwork?.nativeCurrency.symbol||""}}async signMessage(e){const{provider:t,message:s,address:r}=e;if(!t)throw new Error("UniversalAdapter:signMessage - provider is undefined");let o="";return o=a.W.state.activeCaipNetwork?.chainNamespace===n.o.CHAIN.SOLANA?(await t.request({method:"solana_signMessage",params:{message:i.A.encode((new TextEncoder).encode(s)),pubkey:r}},a.W.state.activeCaipNetwork?.caipNetworkId)).signature:await t.request({method:"personal_sign",params:[s,r]},a.W.state.activeCaipNetwork?.caipNetworkId),{signature:o}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async getProfile(){return Promise.resolve({profileImage:"",profileName:""})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}async getEnsAddress(){return Promise.resolve({address:!1})}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){const{caipNetwork:t}=e,s=this.getWalletConnectConnector();if(t.chainNamespace===n.o.CHAIN.EVM)try{await(s.provider?.request({method:"wallet_switchEthereumChain",params:[{chainId:(0,r.nj)(t.id)}]}))}catch(e){if(e.code===d.E.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||e.code===d.E.ERROR_INVALID_CHAIN_ID||e.code===d.E.ERROR_CODE_DEFAULT||e?.data?.originalError?.code===d.E.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await(s.provider?.request({method:"wallet_addEthereumChain",params:[{chainId:(0,r.nj)(t.id),rpcUrls:[t?.rpcUrls.chainDefault?.http],chainName:t.name,nativeCurrency:t.nativeCurrency,blockExplorerUrls:[t.blockExplorers?.default.url]}]}))}catch(e){throw new Error("Chain is not supported")}}s.provider.setDefaultChain(t.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(e=>"WALLET_CONNECT"===e.type),t=e?.provider;return t}}},47431:(e,t,s)=>{s.d(t,{Hjj:()=>xe,OP1:()=>Re,TRk:()=>n,_Yb:()=>r,aF0:()=>Ue,kob:()=>Te,nWe:()=>Oe}),s(91315),s(20635),s(67822),s(33244),s(97353),s(1030),s(13360),s(17367),s(39907),s(48526).hp;const i=":";function r(e){const[t,s]=e.split(i);return{namespace:t,reference:s}}function n(e=[],t=[]){return[...new Set([...e,...t])]}function o(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function a(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function c(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function h(e,t){a(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const l=BigInt(2**32-1),p=BigInt(32);function d(e,t=!1){return t?{h:Number(e&l),l:Number(e>>p&l)}:{h:0|Number(e>>p&l),l:0|Number(e&l)}}const u="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function g(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function f(e,t){return e<<32-t|e>>>t}const m=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function w(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function y(e){for(let t=0;t<e.length;t++)e[t]=w(e[t])}function b(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),a(e),e}class v{clone(){return this._cloneInto()}}function E(e){const t=t=>e().update(b(t)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}const I=[],_=[],N=[],A=BigInt(0),C=BigInt(1),P=BigInt(2),S=BigInt(7),O=BigInt(256),T=BigInt(113);for(let e=0,t=C,s=1,i=0;e<24;e++){[s,i]=[i,(2*s+3*i)%5],I.push(2*(5*i+s)),_.push((e+1)*(e+2)/2%64);let r=A;for(let e=0;e<7;e++)t=(t<<C^(t>>S)*T)%O,t&P&&(r^=C<<(C<<BigInt(e))-C);N.push(r)}const[k,x]=function(e,t=!1){let s=new Uint32Array(e.length),i=new Uint32Array(e.length);for(let r=0;r<e.length;r++){const{h:n,l:o}=d(e[r],t);[s[r],i[r]]=[n,o]}return[s,i]}(N,!0),R=(e,t,s)=>s>32?((e,t,s)=>t<<s-32|e>>>64-s)(e,t,s):((e,t,s)=>e<<s|t>>>32-s)(e,t,s),U=(e,t,s)=>s>32?((e,t,s)=>e<<s-32|t>>>64-s)(e,t,s):((e,t,s)=>t<<s|e>>>32-s)(e,t,s);class D extends v{constructor(e,t,s,i=!1,r=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=s,this.enableXOF=i,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,o(s),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var n;this.state=new Uint8Array(200),this.state32=(n=this.state,new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)))}keccak(){m||y(this.state32),function(e,t=24){const s=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let t=0;t<10;t++)s[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const i=(t+8)%10,r=(t+2)%10,n=s[r],o=s[r+1],a=R(n,o,1)^s[i],c=U(n,o,1)^s[i+1];for(let s=0;s<50;s+=10)e[t+s]^=a,e[t+s+1]^=c}let t=e[2],r=e[3];for(let s=0;s<24;s++){const i=_[s],n=R(t,r,i),o=U(t,r,i),a=I[s];t=e[a],r=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let i=0;i<10;i++)s[i]=e[t+i];for(let i=0;i<10;i++)e[t+i]^=~s[(i+2)%10]&s[(i+4)%10]}e[0]^=k[i],e[1]^=x[i]}s.fill(0)}(this.state32,this.rounds),m||y(this.state32),this.posOut=0,this.pos=0}update(e){c(this);const{blockLen:t,state:s}=this,i=(e=b(e)).length;for(let r=0;r<i;){const n=Math.min(t-this.pos,i-r);for(let t=0;t<n;t++)s[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:s,blockLen:i}=this;e[s]^=t,!!(128&t)&&s===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){c(this,!1),a(e),this.finish();const t=this.state,{blockLen:s}=this;for(let i=0,r=e.length;i<r;){this.posOut>=s&&this.keccak();const n=Math.min(s-this.posOut,r-i);e.set(t.subarray(this.posOut,this.posOut+n),i),this.posOut+=n,i+=n}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return o(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(h(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:s,outputLen:i,rounds:r,enableXOF:n}=this;return e||(e=new D(t,s,i,n,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=s,e.outputLen=i,e.enableXOF=n,e.destroyed=this.destroyed,e}}function j(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function M(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function L(e,...t){if(!M(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function q(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function $(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}E(()=>new D(136,1,32)),Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const B=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function H(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!M(e))throw new Error("Uint8Array expected, got "+typeof e);e=V(e)}return e}function W(e,t,s=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(s&&!function(e){return e.byteOffset%4==0}(t))throw new Error("invalid output, must be aligned");return t}function z(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(s>>r&n),a=Number(s&n),c=i?4:0,h=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+h,a,i)}function V(e){return Uint8Array.from(e)}function F(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const K=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),G=K("expand 16-byte k"),J=K("expand 32-byte k"),Y=B(G),Q=B(J);function X(e,t){return e<<t|e>>>32-t}function Z(e){return e.byteOffset%4==0}const ee=2**32-1,te=new Uint32Array,se=(e,t)=>255&e[t++]|(255&e[t++])<<8;class ie{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,L(e=H(e),32);const t=se(e,0),s=se(e,2),i=se(e,4),r=se(e,6),n=se(e,8),o=se(e,10),a=se(e,12),c=se(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|s<<3),this.r[2]=7939&(s>>>10|i<<6),this.r[3]=8191&(i>>>7|r<<9),this.r[4]=255&(r>>>4|n<<12),this.r[5]=n>>>1&8190,this.r[6]=8191&(n>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=se(e,16+2*t)}process(e,t,s=!1){const i=s?0:2048,{h:r,r:n}=this,o=n[0],a=n[1],c=n[2],h=n[3],l=n[4],p=n[5],d=n[6],u=n[7],g=n[8],f=n[9],m=se(e,t+0),w=se(e,t+2),y=se(e,t+4),b=se(e,t+6),v=se(e,t+8),E=se(e,t+10),I=se(e,t+12),_=se(e,t+14);let N=r[0]+(8191&m),A=r[1]+(8191&(m>>>13|w<<3)),C=r[2]+(8191&(w>>>10|y<<6)),P=r[3]+(8191&(y>>>7|b<<9)),S=r[4]+(8191&(b>>>4|v<<12)),O=r[5]+(v>>>1&8191),T=r[6]+(8191&(v>>>14|E<<2)),k=r[7]+(8191&(E>>>11|I<<5)),x=r[8]+(8191&(I>>>8|_<<8)),R=r[9]+(_>>>5|i),U=0,D=U+N*o+A*(5*f)+C*(5*g)+P*(5*u)+S*(5*d);U=D>>>13,D&=8191,D+=O*(5*p)+T*(5*l)+k*(5*h)+x*(5*c)+R*(5*a),U+=D>>>13,D&=8191;let j=U+N*a+A*o+C*(5*f)+P*(5*g)+S*(5*u);U=j>>>13,j&=8191,j+=O*(5*d)+T*(5*p)+k*(5*l)+x*(5*h)+R*(5*c),U+=j>>>13,j&=8191;let M=U+N*c+A*a+C*o+P*(5*f)+S*(5*g);U=M>>>13,M&=8191,M+=O*(5*u)+T*(5*d)+k*(5*p)+x*(5*l)+R*(5*h),U+=M>>>13,M&=8191;let L=U+N*h+A*c+C*a+P*o+S*(5*f);U=L>>>13,L&=8191,L+=O*(5*g)+T*(5*u)+k*(5*d)+x*(5*p)+R*(5*l),U+=L>>>13,L&=8191;let q=U+N*l+A*h+C*c+P*a+S*o;U=q>>>13,q&=8191,q+=O*(5*f)+T*(5*g)+k*(5*u)+x*(5*d)+R*(5*p),U+=q>>>13,q&=8191;let $=U+N*p+A*l+C*h+P*c+S*a;U=$>>>13,$&=8191,$+=O*o+T*(5*f)+k*(5*g)+x*(5*u)+R*(5*d),U+=$>>>13,$&=8191;let B=U+N*d+A*p+C*l+P*h+S*c;U=B>>>13,B&=8191,B+=O*a+T*o+k*(5*f)+x*(5*g)+R*(5*u),U+=B>>>13,B&=8191;let H=U+N*u+A*d+C*p+P*l+S*h;U=H>>>13,H&=8191,H+=O*c+T*a+k*o+x*(5*f)+R*(5*g),U+=H>>>13,H&=8191;let W=U+N*g+A*u+C*d+P*p+S*l;U=W>>>13,W&=8191,W+=O*h+T*c+k*a+x*o+R*(5*f),U+=W>>>13,W&=8191;let z=U+N*f+A*g+C*u+P*d+S*p;U=z>>>13,z&=8191,z+=O*l+T*h+k*c+x*a+R*o,U+=z>>>13,z&=8191,U=(U<<2)+U|0,U=U+D|0,D=8191&U,U>>>=13,j+=U,r[0]=D,r[1]=j,r[2]=M,r[3]=L,r[4]=q,r[5]=$,r[6]=B,r[7]=H,r[8]=W,r[9]=z}finalize(){const{h:e,pad:t}=this,s=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=i,i=e[t]>>>13,e[t]&=8191;e[0]+=5*i,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,s[0]=e[0]+5,i=s[0]>>>13,s[0]&=8191;for(let t=1;t<10;t++)s[t]=e[t]+i,i=s[t]>>>13,s[t]&=8191;s[9]-=8192;let r=(1^i)-1;for(let e=0;e<10;e++)s[e]&=r;r=~r;for(let t=0;t<10;t++)e[t]=e[t]&r|s[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let n=e[0]+t[0];e[0]=65535&n;for(let s=1;s<8;s++)n=(e[s]+t[s]|0)+(n>>>16)|0,e[s]=65535&n;F(s)}update(e){q(this);const{buffer:t,blockLen:s}=this,i=(e=H(e)).length;for(let r=0;r<i;){const n=Math.min(s-this.pos,i-r);if(n!==s)t.set(e.subarray(r,r+n),this.pos),this.pos+=n,r+=n,this.pos===s&&(this.process(t,0,!1),this.pos=0);else for(;s<=i-r;r+=s)this.process(e,r)}return this}destroy(){F(this.h,this.r,this.buffer,this.pad)}digestInto(e){q(this),function(e,t){L(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}(e,this),this.finished=!0;const{buffer:t,h:s}=this;let{pos:i}=this;if(i){for(t[i++]=1;i<16;i++)t[i]=0;this.process(t,0,!0)}this.finalize();let r=0;for(let t=0;t<8;t++)e[r++]=s[t]>>>0,e[r++]=s[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}}const re=function(e){const t=(t,s)=>e(s).update(H(t)).digest(),s=e(new Uint8Array(32));return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=t=>e(t),t}(e=>new ie(e)),ne=function(e){const{allowShortKeys:t,extendNonceFn:s,counterLength:i,counterRight:r,rounds:n}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t)}(0,{counterRight:!1,counterLength:4,allowShortKeys:!1});return j(i),j(n),$(r),$(t),(o,a,c,h,l=0)=>{L(o),L(a),L(c);const p=c.length;if(void 0===h&&(h=new Uint8Array(p)),L(h),j(l),l<0||l>=ee)throw new Error("arx: counter overflow");if(h.length<p)throw new Error(`arx: output (${h.length}) is shorter than data (${p})`);const d=[];let u,g,f=o.length;if(32===f)d.push(u=V(o)),g=Q;else{if(16!==f||!t)throw new Error(`arx: invalid 32-byte key, got length=${f}`);u=new Uint8Array(32),u.set(o),u.set(o,16),g=Y,d.push(u)}Z(a)||d.push(a=V(a));const m=B(u);if(s){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");s(g,m,B(a.subarray(0,16)),m),a=a.subarray(16)}const w=16-i;if(w!==a.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(12!==w){const e=new Uint8Array(12);e.set(a,r?0:12-a.length),a=e,d.push(a)}const y=B(a);return function(e,t,s,i,r,n,o,a){const c=r.length,h=new Uint8Array(64),l=B(h),p=Z(r)&&Z(n),d=p?B(r):te,u=p?B(n):te;for(let g=0;g<c;o++){if(e(t,s,i,l,o,a),o>=ee)throw new Error("arx: counter overflow");const f=Math.min(64,c-g);if(p&&64===f){const e=g/4;if(g%4!=0)throw new Error("arx: invalid block position");for(let t,s=0;s<16;s++)t=e+s,u[t]=d[t]^l[s];g+=64;continue}for(let e,t=0;t<f;t++)e=g+t,n[e]=r[e]^h[t];g+=f}}(e,g,m,y,c,h,l,n),F(...d),h}}(function(e,t,s,i,r,n=20){let o=e[0],a=e[1],c=e[2],h=e[3],l=t[0],p=t[1],d=t[2],u=t[3],g=t[4],f=t[5],m=t[6],w=t[7],y=r,b=s[0],v=s[1],E=s[2],I=o,_=a,N=c,A=h,C=l,P=p,S=d,O=u,T=g,k=f,x=m,R=w,U=y,D=b,j=v,M=E;for(let e=0;e<n;e+=2)I=I+C|0,U=X(U^I,16),T=T+U|0,C=X(C^T,12),I=I+C|0,U=X(U^I,8),T=T+U|0,C=X(C^T,7),_=_+P|0,D=X(D^_,16),k=k+D|0,P=X(P^k,12),_=_+P|0,D=X(D^_,8),k=k+D|0,P=X(P^k,7),N=N+S|0,j=X(j^N,16),x=x+j|0,S=X(S^x,12),N=N+S|0,j=X(j^N,8),x=x+j|0,S=X(S^x,7),A=A+O|0,M=X(M^A,16),R=R+M|0,O=X(O^R,12),A=A+O|0,M=X(M^A,8),R=R+M|0,O=X(O^R,7),I=I+P|0,M=X(M^I,16),x=x+M|0,P=X(P^x,12),I=I+P|0,M=X(M^I,8),x=x+M|0,P=X(P^x,7),_=_+S|0,U=X(U^_,16),R=R+U|0,S=X(S^R,12),_=_+S|0,U=X(U^_,8),R=R+U|0,S=X(S^R,7),N=N+O|0,D=X(D^N,16),T=T+D|0,O=X(O^T,12),N=N+O|0,D=X(D^N,8),T=T+D|0,O=X(O^T,7),A=A+C|0,j=X(j^A,16),k=k+j|0,C=X(C^k,12),A=A+C|0,j=X(j^A,8),k=k+j|0,C=X(C^k,7);let L=0;i[L++]=o+I|0,i[L++]=a+_|0,i[L++]=c+N|0,i[L++]=h+A|0,i[L++]=l+C|0,i[L++]=p+P|0,i[L++]=d+S|0,i[L++]=u+O|0,i[L++]=g+T|0,i[L++]=f+k|0,i[L++]=m+x|0,i[L++]=w+R|0,i[L++]=y+U|0,i[L++]=b+D|0,i[L++]=v+j|0,i[L++]=E+M|0}),oe=new Uint8Array(16),ae=(e,t)=>{e.update(t);const s=t.length%16;s&&e.update(oe.subarray(s))},ce=new Uint8Array(32);function he(e,t,s,i,r){const n=e(t,s,ce),o=re.create(n);r&&ae(o,r),ae(o,i);const a=new Uint8Array(16),c=(e=>new DataView(e.buffer,e.byteOffset,e.byteLength))(a);z(c,0,BigInt(r?r.length:0),!0),z(c,8,BigInt(i.length),!0),o.update(a);const h=o.digest();return F(n,a),h}((e,t)=>{Object.assign(function(s,...i){if(L(s),void 0!==e.nonceLength){const t=i[0];if(!t)throw new Error("nonce / iv required");e.varSizeNonce?L(t):L(t,e.nonceLength)}const r=e.tagLength;r&&void 0!==i[1]&&L(i[1]);const n=t(s,...i),o=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");L(t)}};let a=!1;return{encrypt(e,t){if(a)throw new Error("cannot encrypt() twice with same key + nonce");return a=!0,L(e),o(n.encrypt.length,t),n.encrypt(e,t)},decrypt(e,t){if(L(e),r&&e.length<r)throw new Error("invalid ciphertext length: smaller than tagLength="+r);return o(n.decrypt.length,t),n.decrypt(e,t)}}},e)})({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,s,i)=>({encrypt(r,n){const o=r.length;(n=W(o+16,n,!1)).set(r);const a=n.subarray(0,-16);e(t,s,a,a,1);const c=he(e,t,s,a,i);return n.set(c,o),F(c),n},decrypt(r,n){n=W(r.length-16,n,!1);const o=r.subarray(0,-16),a=r.subarray(-16),c=he(e,t,s,o,i);if(!function(e,t){if(e.length!==t.length)return!1;let s=0;for(let i=0;i<e.length;i++)s|=e[i]^t[i];return 0===s}(a,c))throw new Error("invalid tag");return n.set(r.subarray(0,-16)),e(t,s,n,n,1),F(c),n}}))(ne));function le(e,t,s){return e&t^~e&s}function pe(e,t,s){return e&t^e&s^t&s}new Uint8Array([0]),new Uint8Array;class de extends v{constructor(e,t,s,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=g(this.buffer)}update(e){c(this);const{view:t,buffer:s,blockLen:i}=this,r=(e=b(e)).length;for(let n=0;n<r;){const o=Math.min(i-this.pos,r-n);if(o===i){const t=g(e);for(;i<=r-n;n+=i)this.process(t,n);continue}s.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){c(this),h(e,this),this.finished=!0;const{buffer:t,view:s,blockLen:i,isLE:r}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>i-n&&(this.process(s,0),n=0);for(let e=n;e<i;e++)t[e]=0;(function(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(s>>r&n),a=Number(s&n),c=i?4:0,h=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+h,a,i)})(s,i-8,BigInt(8*this.length),r),this.process(s,0);const o=g(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=a/4,p=this.get();if(l>p.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<l;e++)o.setUint32(4*e,p[e],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:s,length:i,finished:r,destroyed:n,pos:o}=this;return e.length=i,e.pos=o,e.finished=r,e.destroyed=n,i%t&&e.buffer.set(s),e}}const ue=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ge=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),fe=new Uint32Array(64);class me extends de{constructor(){super(64,32,8,!1),this.A=0|ge[0],this.B=0|ge[1],this.C=0|ge[2],this.D=0|ge[3],this.E=0|ge[4],this.F=0|ge[5],this.G=0|ge[6],this.H=0|ge[7]}get(){const{A:e,B:t,C:s,D:i,E:r,F:n,G:o,H:a}=this;return[e,t,s,i,r,n,o,a]}set(e,t,s,i,r,n,o,a){this.A=0|e,this.B=0|t,this.C=0|s,this.D=0|i,this.E=0|r,this.F=0|n,this.G=0|o,this.H=0|a}process(e,t){for(let s=0;s<16;s++,t+=4)fe[s]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=fe[e-15],s=fe[e-2],i=f(t,7)^f(t,18)^t>>>3,r=f(s,17)^f(s,19)^s>>>10;fe[e]=r+fe[e-7]+i+fe[e-16]|0}let{A:s,B:i,C:r,D:n,E:o,F:a,G:c,H:h}=this;for(let e=0;e<64;e++){const t=h+(f(o,6)^f(o,11)^f(o,25))+le(o,a,c)+ue[e]+fe[e]|0,l=(f(s,2)^f(s,13)^f(s,22))+pe(s,i,r)|0;h=c,c=a,a=o,o=n+t|0,n=r,r=i,i=s,s=t+l|0}s=s+this.A|0,i=i+this.B|0,r=r+this.C|0,n=n+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(s,i,r,n,o,a,c,h)}roundClean(){fe.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}E(()=>new me);BigInt(0);function we(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ye(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function be(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,s=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(s);for(let t=0,r=0;t<s;t++,r+=2){const s=ye(e.charCodeAt(r)),n=ye(e.charCodeAt(r+1));if(void 0===s||void 0===n){const t=e[r]+e[r+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+r)}i[t]=16*s+n}return i}const ve={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||we(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)},Ee=BigInt(0);BigInt(1);function Ie(e,t){const s=e%t;return s>=Ee?s:t+s}function _e(e,t,s){let i=e;for(;t-- >Ee;)i*=i,i%=s;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);BigInt(0),BigInt(1);const Ne=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const Ae=BigInt(1),Ce=BigInt(2),Pe=BigInt(3),Se=BigInt(5);function Oe(e){return e.includes(":")}function Te(e){return Oe(e)?e.split(":")[0]:e}BigInt(8),function(e){const t=function(e){return function(e,t,s={}){const i=(t,s,i)=>{const r=ve[s];if("function"!=typeof r)throw new Error("invalid validator function");const n=e[t];if(!(i&&void 0===n||r(n,e)))throw new Error("param "+String(t)+" is invalid. Expected "+s+", got "+n)};for(const[e,s]of Object.entries(t))i(e,s,!1);for(const[e,t]of Object.entries(s))i(e,t,!0)}(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:s}=t,i=e=>Ie(e,s),r=t.montgomeryBits,n=Math.ceil(r/8);t.nByteLength,t.adjustScalarBytes,t.powPminus2;t.a,BigInt(2),BigInt(4);function o(e){return function(e,t){return function(e,t){return be(e.toString(16).padStart(2*t,"0"))}(e,t).reverse()}(i(e),n)}o(t.Gu)}({P:Ne,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=Ne,{pow_p_5_8:s,b2:i}=function(e){const t=BigInt(10),s=BigInt(20),i=BigInt(40),r=BigInt(80),n=Ne,o=e*e%n*e%n,a=_e(o,Ce,n)*o%n,c=_e(a,Ae,n)*e%n,h=_e(c,Se,n)*c%n,l=_e(h,t,n)*h%n,p=_e(l,s,n)*l%n,d=_e(p,i,n)*p%n,u=_e(d,r,n)*d%n,g=_e(u,r,n)*d%n,f=_e(g,t,n)*h%n;return{pow_p_5_8:_e(f,Ce,n)*e%n,b2:o}}(e);return Ie(_e(s,Pe,t)*i,t)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},randomBytes:function(e=32){if(u&&"function"==typeof u.getRandomValues)return u.getRandomValues(new Uint8Array(e));if(u&&"function"==typeof u.randomBytes)return u.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}}),Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const ke={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}};function xe(e,t){const{message:s,code:i}=ke[e];return{message:t?`${s} ${t}`:s,code:i}}function Re(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function Ue(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}},48336:(e,t,s)=>{s.d(t,{s:()=>n});var i=s(88315),r=s(58906);function n(e){return new i._({...e,basic:!0,sdkVersion:`html-core-${r.i}`})}},48851:(e,t,s)=>{s.d(t,{ADD:()=>k,ALl:()=>Vt,AYU:()=>ys,AwN:()=>ts,BdH:()=>v,C5G:()=>es,CTo:()=>bs,EN$:()=>zt,EWt:()=>xt,F$L:()=>Qt,GuA:()=>gs,Hjj:()=>fs,K3g:()=>O,Lln:()=>m,Lp_:()=>Dt,PUk:()=>P,QJh:()=>ps,Qhg:()=>ws,R7U:()=>I,TZl:()=>Bt,TeY:()=>Es,Tw2:()=>Yt,U0i:()=>rs,V7m:()=>ss,Wx8:()=>S,Xw0:()=>U,YcA:()=>Jt,_dF:()=>D,aRZ:()=>b,aa1:()=>as,b07:()=>ms,bEt:()=>kt,c82:()=>R,gOF:()=>x,gZm:()=>M,h0Y:()=>C,hEn:()=>j,iui:()=>Zt,jUZ:()=>A,lFF:()=>_,m01:()=>y,mr0:()=>vs,n6V:()=>os,ojD:()=>N,ovp:()=>Wt,ps1:()=>is,sc7:()=>Is,two:()=>Ht,uym:()=>_s,w8K:()=>L,wYp:()=>hs,wa2:()=>Gt,x0t:()=>Kt,yy4:()=>$});var i=s(24661),r=s(91315),n=s(20635),o=s(67822),a=(s(33244),s(97353)),c=s(1030),h=s(13360),l=s(17367),p=s(39907),d=s(48526).hp;const u="ReactNative",g={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},f="js";function m(){return typeof p<"u"&&typeof p.versions<"u"&&typeof p.versions.node<"u"}function w(){return!(0,n.getDocument)()&&!!(0,n.getNavigator)()&&navigator.product===u}function y(){return w()&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Platform)<"u"&&"android"===(null==s.g?void 0:s.g.Platform.OS)}function b(){return w()&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Platform)<"u"&&"ios"===(null==s.g?void 0:s.g.Platform.OS)}function v(){return!m()&&!!(0,n.getNavigator)()&&!!(0,n.getDocument)()}function E(){return w()?g.reactNative:m()?g.node:v()?g.browser:g.unknown}function I(){var e;try{return w()&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Application)<"u"?null==(e=s.g.Application)?void 0:e.applicationId:void 0}catch{return}}function _(){return(0,o.g)()||{name:"",description:"",url:"",icons:[""]}}function N(e,t,r){const o=function(){if(E()===g.reactNative&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Platform)<"u"){const{OS:e,Version:t}=s.g.Platform;return[e,t].join("-")}const e=(0,i.o0)();if(null===e)return"unknown";const t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return"browser"===e.type?[t,e.name,e.version].join("-"):[t,e.version].join("-")}(),a=function(){var e;const t=E();return t===g.browser?[t,(null==(e=(0,n.getLocation)())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),[f,r].join("-"),o,a].join("/")}function A({protocol:e,version:t,relayUrl:s,sdkVersion:i,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const h=s.split("?"),l={auth:r,ua:N(e,t,i),projectId:n,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},p=function(e,t){const s=new URLSearchParams(e);for(const e of Object.keys(t).sort())if(t.hasOwnProperty(e)){const i=t[e];void 0!==i&&s.set(e,i)}return s.toString()}(h[1]||"",l);return h[0]+"?"+p}function C(e){return Object.fromEntries(e.entries())}function P(e){return new Map(Object.entries(e))}function S(e=r.FIVE_MINUTES,t){const s=(0,r.toMiliseconds)(e||r.FIVE_MINUTES);let i,n,o,a;return{resolve:e=>{o&&i&&(clearTimeout(o),i(e),a=Promise.resolve(e))},reject:e=>{o&&n&&(clearTimeout(o),n(e))},done:()=>new Promise((e,r)=>{if(a)return e(a);o=setTimeout(()=>{const e=new Error(t);a=Promise.reject(e),r(e)},s),i=e,n=r})}}function O(e,t,s){return new Promise(async(i,r)=>{const n=setTimeout(()=>r(new Error(s)),t);try{i(await e)}catch(e){r(e)}clearTimeout(n)})}function T(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${e}`)}function k(e){return T("topic",e)}function x(e){return T("id",e)}function R(e){const[t,s]=e.split(":"),i={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof s)i.topic=s;else{if("id"!==t||!Number.isInteger(Number(s)))throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${s}`);i.id=Number(s)}return i}function U(e,t){return(0,r.fromMiliseconds)((t||Date.now())+(0,r.toMiliseconds)(e))}function D(e){return Date.now()>=(0,r.toMiliseconds)(e)}function j(e,t){return`${e}${t?`:${t}`:""}`}function M(){return typeof crypto<"u"&&null!=crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function L(){return typeof p<"u"&&"true"===p.env.IS_VITEST}function q(e){return d.from(e,"base64").toString("utf-8")}function $(e){return new Promise(t=>setTimeout(t,e))}function B(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function H(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function W(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");B(e.outputLen),B(e.blockLen)}function z(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function V(e,t){H(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const F=BigInt(2**32-1),K=BigInt(32);function G(e,t=!1){return t?{h:Number(e&F),l:Number(e>>K&F)}:{h:0|Number(e>>K&F),l:0|Number(e&F)}}const J="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function Y(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Q(e,t){return e<<32-t|e>>>t}const X=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function Z(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function ee(e){for(let t=0;t<e.length;t++)e[t]=Z(e[t])}function te(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),H(e),e}class se{clone(){return this._cloneInto()}}function ie(e){const t=t=>e().update(te(t)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}function re(e=32){if(J&&"function"==typeof J.getRandomValues)return J.getRandomValues(new Uint8Array(e));if(J&&"function"==typeof J.randomBytes)return J.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}const ne=[],oe=[],ae=[],ce=BigInt(0),he=BigInt(1),le=BigInt(2),pe=BigInt(7),de=BigInt(256),ue=BigInt(113);for(let e=0,t=he,s=1,i=0;e<24;e++){[s,i]=[i,(2*s+3*i)%5],ne.push(2*(5*i+s)),oe.push((e+1)*(e+2)/2%64);let r=ce;for(let e=0;e<7;e++)t=(t<<he^(t>>pe)*ue)%de,t&le&&(r^=he<<(he<<BigInt(e))-he);ae.push(r)}const[ge,fe]=function(e,t=!1){let s=new Uint32Array(e.length),i=new Uint32Array(e.length);for(let r=0;r<e.length;r++){const{h:n,l:o}=G(e[r],t);[s[r],i[r]]=[n,o]}return[s,i]}(ae,!0),me=(e,t,s)=>s>32?((e,t,s)=>t<<s-32|e>>>64-s)(e,t,s):((e,t,s)=>e<<s|t>>>32-s)(e,t,s),we=(e,t,s)=>s>32?((e,t,s)=>e<<s-32|t>>>64-s)(e,t,s):((e,t,s)=>t<<s|e>>>32-s)(e,t,s);class ye extends se{constructor(e,t,s,i=!1,r=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=s,this.enableXOF=i,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,B(s),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var n;this.state=new Uint8Array(200),this.state32=(n=this.state,new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)))}keccak(){X||ee(this.state32),function(e,t=24){const s=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let t=0;t<10;t++)s[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const i=(t+8)%10,r=(t+2)%10,n=s[r],o=s[r+1],a=me(n,o,1)^s[i],c=we(n,o,1)^s[i+1];for(let s=0;s<50;s+=10)e[t+s]^=a,e[t+s+1]^=c}let t=e[2],r=e[3];for(let s=0;s<24;s++){const i=oe[s],n=me(t,r,i),o=we(t,r,i),a=ne[s];t=e[a],r=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let i=0;i<10;i++)s[i]=e[t+i];for(let i=0;i<10;i++)e[t+i]^=~s[(i+2)%10]&s[(i+4)%10]}e[0]^=ge[i],e[1]^=fe[i]}s.fill(0)}(this.state32,this.rounds),X||ee(this.state32),this.posOut=0,this.pos=0}update(e){z(this);const{blockLen:t,state:s}=this,i=(e=te(e)).length;for(let r=0;r<i;){const n=Math.min(t-this.pos,i-r);for(let t=0;t<n;t++)s[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:s,blockLen:i}=this;e[s]^=t,!!(128&t)&&s===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){z(this,!1),H(e),this.finish();const t=this.state,{blockLen:s}=this;for(let i=0,r=e.length;i<r;){this.posOut>=s&&this.keccak();const n=Math.min(s-this.posOut,r-i);e.set(t.subarray(this.posOut,this.posOut+n),i),this.posOut+=n,i+=n}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return B(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(V(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:s,outputLen:i,rounds:r,enableXOF:n}=this;return e||(e=new ye(t,s,i,n,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=s,e.outputLen=i,e.enableXOF=n,e.destroyed=this.destroyed,e}}function be(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ve(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Ee(e,...t){if(!ve(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ie(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function _e(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}ie(()=>new ye(136,1,32)),Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const Ne=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function Ae(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!ve(e))throw new Error("Uint8Array expected, got "+typeof e);e=Se(e)}return e}function Ce(e,t,s=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(s&&!function(e){return e.byteOffset%4==0}(t))throw new Error("invalid output, must be aligned");return t}function Pe(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(s>>r&n),a=Number(s&n),c=i?4:0,h=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+h,a,i)}function Se(e){return Uint8Array.from(e)}function Oe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const Te=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),ke=Te("expand 16-byte k"),xe=Te("expand 32-byte k"),Re=Ne(ke),Ue=Ne(xe);function De(e,t){return e<<t|e>>>32-t}function je(e){return e.byteOffset%4==0}const Me=2**32-1,Le=new Uint32Array,qe=(e,t)=>255&e[t++]|(255&e[t++])<<8;class $e{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,Ee(e=Ae(e),32);const t=qe(e,0),s=qe(e,2),i=qe(e,4),r=qe(e,6),n=qe(e,8),o=qe(e,10),a=qe(e,12),c=qe(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|s<<3),this.r[2]=7939&(s>>>10|i<<6),this.r[3]=8191&(i>>>7|r<<9),this.r[4]=255&(r>>>4|n<<12),this.r[5]=n>>>1&8190,this.r[6]=8191&(n>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=qe(e,16+2*t)}process(e,t,s=!1){const i=s?0:2048,{h:r,r:n}=this,o=n[0],a=n[1],c=n[2],h=n[3],l=n[4],p=n[5],d=n[6],u=n[7],g=n[8],f=n[9],m=qe(e,t+0),w=qe(e,t+2),y=qe(e,t+4),b=qe(e,t+6),v=qe(e,t+8),E=qe(e,t+10),I=qe(e,t+12),_=qe(e,t+14);let N=r[0]+(8191&m),A=r[1]+(8191&(m>>>13|w<<3)),C=r[2]+(8191&(w>>>10|y<<6)),P=r[3]+(8191&(y>>>7|b<<9)),S=r[4]+(8191&(b>>>4|v<<12)),O=r[5]+(v>>>1&8191),T=r[6]+(8191&(v>>>14|E<<2)),k=r[7]+(8191&(E>>>11|I<<5)),x=r[8]+(8191&(I>>>8|_<<8)),R=r[9]+(_>>>5|i),U=0,D=U+N*o+A*(5*f)+C*(5*g)+P*(5*u)+S*(5*d);U=D>>>13,D&=8191,D+=O*(5*p)+T*(5*l)+k*(5*h)+x*(5*c)+R*(5*a),U+=D>>>13,D&=8191;let j=U+N*a+A*o+C*(5*f)+P*(5*g)+S*(5*u);U=j>>>13,j&=8191,j+=O*(5*d)+T*(5*p)+k*(5*l)+x*(5*h)+R*(5*c),U+=j>>>13,j&=8191;let M=U+N*c+A*a+C*o+P*(5*f)+S*(5*g);U=M>>>13,M&=8191,M+=O*(5*u)+T*(5*d)+k*(5*p)+x*(5*l)+R*(5*h),U+=M>>>13,M&=8191;let L=U+N*h+A*c+C*a+P*o+S*(5*f);U=L>>>13,L&=8191,L+=O*(5*g)+T*(5*u)+k*(5*d)+x*(5*p)+R*(5*l),U+=L>>>13,L&=8191;let q=U+N*l+A*h+C*c+P*a+S*o;U=q>>>13,q&=8191,q+=O*(5*f)+T*(5*g)+k*(5*u)+x*(5*d)+R*(5*p),U+=q>>>13,q&=8191;let $=U+N*p+A*l+C*h+P*c+S*a;U=$>>>13,$&=8191,$+=O*o+T*(5*f)+k*(5*g)+x*(5*u)+R*(5*d),U+=$>>>13,$&=8191;let B=U+N*d+A*p+C*l+P*h+S*c;U=B>>>13,B&=8191,B+=O*a+T*o+k*(5*f)+x*(5*g)+R*(5*u),U+=B>>>13,B&=8191;let H=U+N*u+A*d+C*p+P*l+S*h;U=H>>>13,H&=8191,H+=O*c+T*a+k*o+x*(5*f)+R*(5*g),U+=H>>>13,H&=8191;let W=U+N*g+A*u+C*d+P*p+S*l;U=W>>>13,W&=8191,W+=O*h+T*c+k*a+x*o+R*(5*f),U+=W>>>13,W&=8191;let z=U+N*f+A*g+C*u+P*d+S*p;U=z>>>13,z&=8191,z+=O*l+T*h+k*c+x*a+R*o,U+=z>>>13,z&=8191,U=(U<<2)+U|0,U=U+D|0,D=8191&U,U>>>=13,j+=U,r[0]=D,r[1]=j,r[2]=M,r[3]=L,r[4]=q,r[5]=$,r[6]=B,r[7]=H,r[8]=W,r[9]=z}finalize(){const{h:e,pad:t}=this,s=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=i,i=e[t]>>>13,e[t]&=8191;e[0]+=5*i,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,s[0]=e[0]+5,i=s[0]>>>13,s[0]&=8191;for(let t=1;t<10;t++)s[t]=e[t]+i,i=s[t]>>>13,s[t]&=8191;s[9]-=8192;let r=(1^i)-1;for(let e=0;e<10;e++)s[e]&=r;r=~r;for(let t=0;t<10;t++)e[t]=e[t]&r|s[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let n=e[0]+t[0];e[0]=65535&n;for(let s=1;s<8;s++)n=(e[s]+t[s]|0)+(n>>>16)|0,e[s]=65535&n;Oe(s)}update(e){Ie(this);const{buffer:t,blockLen:s}=this,i=(e=Ae(e)).length;for(let r=0;r<i;){const n=Math.min(s-this.pos,i-r);if(n!==s)t.set(e.subarray(r,r+n),this.pos),this.pos+=n,r+=n,this.pos===s&&(this.process(t,0,!1),this.pos=0);else for(;s<=i-r;r+=s)this.process(e,r)}return this}destroy(){Oe(this.h,this.r,this.buffer,this.pad)}digestInto(e){Ie(this),function(e,t){Ee(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}(e,this),this.finished=!0;const{buffer:t,h:s}=this;let{pos:i}=this;if(i){for(t[i++]=1;i<16;i++)t[i]=0;this.process(t,0,!0)}this.finalize();let r=0;for(let t=0;t<8;t++)e[r++]=s[t]>>>0,e[r++]=s[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}}const Be=function(e){const t=(t,s)=>e(s).update(Ae(t)).digest(),s=e(new Uint8Array(32));return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=t=>e(t),t}(e=>new $e(e)),He=function(e){const{allowShortKeys:t,extendNonceFn:s,counterLength:i,counterRight:r,rounds:n}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t)}(0,{counterRight:!1,counterLength:4,allowShortKeys:!1});return be(i),be(n),_e(r),_e(t),(o,a,c,h,l=0)=>{Ee(o),Ee(a),Ee(c);const p=c.length;if(void 0===h&&(h=new Uint8Array(p)),Ee(h),be(l),l<0||l>=Me)throw new Error("arx: counter overflow");if(h.length<p)throw new Error(`arx: output (${h.length}) is shorter than data (${p})`);const d=[];let u,g,f=o.length;if(32===f)d.push(u=Se(o)),g=Ue;else{if(16!==f||!t)throw new Error(`arx: invalid 32-byte key, got length=${f}`);u=new Uint8Array(32),u.set(o),u.set(o,16),g=Re,d.push(u)}je(a)||d.push(a=Se(a));const m=Ne(u);if(s){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");s(g,m,Ne(a.subarray(0,16)),m),a=a.subarray(16)}const w=16-i;if(w!==a.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(12!==w){const e=new Uint8Array(12);e.set(a,r?0:12-a.length),a=e,d.push(a)}const y=Ne(a);return function(e,t,s,i,r,n,o,a){const c=r.length,h=new Uint8Array(64),l=Ne(h),p=je(r)&&je(n),d=p?Ne(r):Le,u=p?Ne(n):Le;for(let g=0;g<c;o++){if(e(t,s,i,l,o,a),o>=Me)throw new Error("arx: counter overflow");const f=Math.min(64,c-g);if(p&&64===f){const e=g/4;if(g%4!=0)throw new Error("arx: invalid block position");for(let t,s=0;s<16;s++)t=e+s,u[t]=d[t]^l[s];g+=64;continue}for(let e,t=0;t<f;t++)e=g+t,n[e]=r[e]^h[t];g+=f}}(e,g,m,y,c,h,l,n),Oe(...d),h}}(function(e,t,s,i,r,n=20){let o=e[0],a=e[1],c=e[2],h=e[3],l=t[0],p=t[1],d=t[2],u=t[3],g=t[4],f=t[5],m=t[6],w=t[7],y=r,b=s[0],v=s[1],E=s[2],I=o,_=a,N=c,A=h,C=l,P=p,S=d,O=u,T=g,k=f,x=m,R=w,U=y,D=b,j=v,M=E;for(let e=0;e<n;e+=2)I=I+C|0,U=De(U^I,16),T=T+U|0,C=De(C^T,12),I=I+C|0,U=De(U^I,8),T=T+U|0,C=De(C^T,7),_=_+P|0,D=De(D^_,16),k=k+D|0,P=De(P^k,12),_=_+P|0,D=De(D^_,8),k=k+D|0,P=De(P^k,7),N=N+S|0,j=De(j^N,16),x=x+j|0,S=De(S^x,12),N=N+S|0,j=De(j^N,8),x=x+j|0,S=De(S^x,7),A=A+O|0,M=De(M^A,16),R=R+M|0,O=De(O^R,12),A=A+O|0,M=De(M^A,8),R=R+M|0,O=De(O^R,7),I=I+P|0,M=De(M^I,16),x=x+M|0,P=De(P^x,12),I=I+P|0,M=De(M^I,8),x=x+M|0,P=De(P^x,7),_=_+S|0,U=De(U^_,16),R=R+U|0,S=De(S^R,12),_=_+S|0,U=De(U^_,8),R=R+U|0,S=De(S^R,7),N=N+O|0,D=De(D^N,16),T=T+D|0,O=De(O^T,12),N=N+O|0,D=De(D^N,8),T=T+D|0,O=De(O^T,7),A=A+C|0,j=De(j^A,16),k=k+j|0,C=De(C^k,12),A=A+C|0,j=De(j^A,8),k=k+j|0,C=De(C^k,7);let L=0;i[L++]=o+I|0,i[L++]=a+_|0,i[L++]=c+N|0,i[L++]=h+A|0,i[L++]=l+C|0,i[L++]=p+P|0,i[L++]=d+S|0,i[L++]=u+O|0,i[L++]=g+T|0,i[L++]=f+k|0,i[L++]=m+x|0,i[L++]=w+R|0,i[L++]=y+U|0,i[L++]=b+D|0,i[L++]=v+j|0,i[L++]=E+M|0}),We=new Uint8Array(16),ze=(e,t)=>{e.update(t);const s=t.length%16;s&&e.update(We.subarray(s))},Ve=new Uint8Array(32);function Fe(e,t,s,i,r){const n=e(t,s,Ve),o=Be.create(n);r&&ze(o,r),ze(o,i);const a=new Uint8Array(16),c=(e=>new DataView(e.buffer,e.byteOffset,e.byteLength))(a);Pe(c,0,BigInt(r?r.length:0),!0),Pe(c,8,BigInt(i.length),!0),o.update(a);const h=o.digest();return Oe(n,a),h}const Ke=((e,t)=>{function s(s,...i){if(Ee(s),void 0!==e.nonceLength){const t=i[0];if(!t)throw new Error("nonce / iv required");e.varSizeNonce?Ee(t):Ee(t,e.nonceLength)}const r=e.tagLength;r&&void 0!==i[1]&&Ee(i[1]);const n=t(s,...i),o=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");Ee(t)}};let a=!1;return{encrypt(e,t){if(a)throw new Error("cannot encrypt() twice with same key + nonce");return a=!0,Ee(e),o(n.encrypt.length,t),n.encrypt(e,t)},decrypt(e,t){if(Ee(e),r&&e.length<r)throw new Error("invalid ciphertext length: smaller than tagLength="+r);return o(n.decrypt.length,t),n.decrypt(e,t)}}}return Object.assign(s,e),s})({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,s,i)=>({encrypt(r,n){const o=r.length;(n=Ce(o+16,n,!1)).set(r);const a=n.subarray(0,-16);e(t,s,a,a,1);const c=Fe(e,t,s,a,i);return n.set(c,o),Oe(c),n},decrypt(r,n){n=Ce(r.length-16,n,!1);const o=r.subarray(0,-16),a=r.subarray(-16),c=Fe(e,t,s,o,i);if(!function(e,t){if(e.length!==t.length)return!1;let s=0;for(let i=0;i<e.length;i++)s|=e[i]^t[i];return 0===s}(a,c))throw new Error("invalid tag");return n.set(r.subarray(0,-16)),e(t,s,n,n,1),Oe(c),n}}))(He));class Ge extends se{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,W(e);const s=te(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,r=new Uint8Array(i);r.set(s.length>i?e.create().update(s).digest():s);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),r.fill(0)}update(e){return z(this),this.iHash.update(e),this}digestInto(e){z(this),H(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:s,finished:i,destroyed:r,blockLen:n,outputLen:o}=this;return e.finished=i,e.destroyed=r,e.blockLen=n,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=s._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Je=(e,t,s)=>new Ge(e,t).update(s).digest();Je.create=(e,t)=>new Ge(e,t);const Ye=new Uint8Array([0]),Qe=new Uint8Array,Xe=(e,t,s,i,r)=>function(e,t,s,i=32){if(W(e),B(i),i>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const r=Math.ceil(i/e.outputLen);void 0===s&&(s=Qe);const n=new Uint8Array(r*e.outputLen),o=Je.create(e,t),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let t=0;t<r;t++)Ye[0]=t+1,a.update(0===t?Qe:c).update(s).update(Ye).digestInto(c),n.set(c,e.outputLen*t),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),Ye.fill(0),n.slice(0,i)}(e,function(e,t,s){return W(e),void 0===s&&(s=new Uint8Array(e.outputLen)),Je(e,te(s),te(t))}(e,t,s),i,r);function Ze(e,t,s){return e&t^~e&s}function et(e,t,s){return e&t^e&s^t&s}class tt extends se{constructor(e,t,s,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Y(this.buffer)}update(e){z(this);const{view:t,buffer:s,blockLen:i}=this,r=(e=te(e)).length;for(let n=0;n<r;){const o=Math.min(i-this.pos,r-n);if(o===i){const t=Y(e);for(;i<=r-n;n+=i)this.process(t,n);continue}s.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){z(this),V(e,this),this.finished=!0;const{buffer:t,view:s,blockLen:i,isLE:r}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>i-n&&(this.process(s,0),n=0);for(let e=n;e<i;e++)t[e]=0;(function(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(s>>r&n),a=Number(s&n),c=i?4:0,h=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+h,a,i)})(s,i-8,BigInt(8*this.length),r),this.process(s,0);const o=Y(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,h[e],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:s,length:i,finished:r,destroyed:n,pos:o}=this;return e.length=i,e.pos=o,e.finished=r,e.destroyed=n,i%t&&e.buffer.set(s),e}}const st=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),it=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),rt=new Uint32Array(64);class nt extends tt{constructor(){super(64,32,8,!1),this.A=0|it[0],this.B=0|it[1],this.C=0|it[2],this.D=0|it[3],this.E=0|it[4],this.F=0|it[5],this.G=0|it[6],this.H=0|it[7]}get(){const{A:e,B:t,C:s,D:i,E:r,F:n,G:o,H:a}=this;return[e,t,s,i,r,n,o,a]}set(e,t,s,i,r,n,o,a){this.A=0|e,this.B=0|t,this.C=0|s,this.D=0|i,this.E=0|r,this.F=0|n,this.G=0|o,this.H=0|a}process(e,t){for(let s=0;s<16;s++,t+=4)rt[s]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=rt[e-15],s=rt[e-2],i=Q(t,7)^Q(t,18)^t>>>3,r=Q(s,17)^Q(s,19)^s>>>10;rt[e]=r+rt[e-7]+i+rt[e-16]|0}let{A:s,B:i,C:r,D:n,E:o,F:a,G:c,H:h}=this;for(let e=0;e<64;e++){const t=h+(Q(o,6)^Q(o,11)^Q(o,25))+Ze(o,a,c)+st[e]+rt[e]|0,l=(Q(s,2)^Q(s,13)^Q(s,22))+et(s,i,r)|0;h=c,c=a,a=o,o=n+t|0,n=r,r=i,i=s,s=t+l|0}s=s+this.A|0,i=i+this.B|0,r=r+this.C|0,n=n+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(s,i,r,n,o,a,c,h)}roundClean(){rt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ot=ie(()=>new nt),at=BigInt(0);function ct(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function ht(e){if(!ct(e))throw new Error("Uint8Array expected")}const lt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function pt(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function dt(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,s=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(s);for(let t=0,r=0;t<s;t++,r+=2){const s=pt(e.charCodeAt(r)),n=pt(e.charCodeAt(r+1));if(void 0===s||void 0===n){const t=e[r]+e[r+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+r)}i[t]=16*s+n}return i}function ut(e){return ht(e),function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?at:BigInt("0x"+e)}(function(e){ht(e);let t="";for(let s=0;s<e.length;s++)t+=lt[e[s]];return t}(Uint8Array.from(e).reverse()))}function gt(e,t,s){let i;if("string"==typeof t)try{i=dt(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!ct(t))throw new Error(e+" must be hex string or Uint8Array");i=Uint8Array.from(t)}const r=i.length;if("number"==typeof s&&r!==s)throw new Error(e+" of length "+s+" expected, got "+r);return i}const ft=e=>"bigint"==typeof e&&at<=e;function mt(e,t,s,i){if(!function(e,t,s){return ft(e)&&ft(t)&&ft(s)&&t<=e&&e<s}(t,s,i))throw new Error("expected valid "+e+": "+s+" <= n < "+i+", got "+t)}const wt={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||ct(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)},yt=BigInt(0),bt=BigInt(1);function vt(e,t){const s=e%t;return s>=yt?s:t+s}function Et(e,t,s){let i=e;for(;t-- >yt;)i*=i,i%=s;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const It=BigInt(0),_t=BigInt(1);const Nt=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const At=BigInt(1),Ct=BigInt(2),Pt=BigInt(3),St=BigInt(5);BigInt(8);const Ot=function(e){const t=function(e){return function(e,t,s={}){const i=(t,s,i)=>{const r=wt[s];if("function"!=typeof r)throw new Error("invalid validator function");const n=e[t];if(!(i&&void 0===n||r(n,e)))throw new Error("param "+String(t)+" is invalid. Expected "+s+", got "+n)};for(const[e,s]of Object.entries(t))i(e,s,!1);for(const[e,t]of Object.entries(s))i(e,t,!0)}(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:s}=t,i=e=>vt(e,s),r=t.montgomeryBits,n=Math.ceil(r/8),o=t.nByteLength,a=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>function(e,t,s){if(t<yt)throw new Error("invalid exponent, negatives unsupported");if(s<=yt)throw new Error("invalid modulus");if(s===bt)return yt;let i=bt;for(;t>yt;)t&bt&&(i=i*e%s),e=e*e%s,t>>=bt;return i}(e,s-BigInt(2),s));function h(e,t,s){const r=i(e*(t-s));return[t=i(t-r),s=i(s+r)]}const l=(t.a-BigInt(2))/BigInt(4);function p(e){return function(e,t){return function(e,t){return dt(e.toString(16).padStart(2*t,"0"))}(e,t).reverse()}(i(e),n)}function d(e,t){const d=function(e){const t=gt("u coordinate",e,n);return 32===o&&(t[31]&=127),ut(t)}(t),u=function(e){const t=gt("scalar",e),s=t.length;if(s!==n&&s!==o)throw new Error("invalid scalar, expected "+n+" or "+o+" bytes, got "+s);return ut(a(t))}(e),g=function(e,t){mt("u",e,It,s),mt("scalar",t,It,s);const n=t,o=e;let a,p=_t,d=It,u=e,g=_t,f=It;for(let e=BigInt(r-1);e>=It;e--){const t=n>>e&_t;f^=t,a=h(f,p,u),p=a[0],u=a[1],a=h(f,d,g),d=a[0],g=a[1],f=t;const s=p+d,r=i(s*s),c=p-d,m=i(c*c),w=r-m,y=u+g,b=i((u-g)*s),v=i(y*c),E=b+v,I=b-v;u=i(E*E),g=i(o*i(I*I)),p=i(r*m),d=i(w*(r+i(l*w)))}a=h(f,p,u),p=a[0],u=a[1],a=h(f,d,g),d=a[0],g=a[1];const m=c(d);return i(p*m)}(d,u);if(g===It)throw new Error("invalid private or public key received");return p(g)}const u=p(t.Gu);function g(e){return d(e,u)}return{scalarMult:d,scalarMultBase:g,getSharedSecret:(e,t)=>d(e,t),getPublicKey:e=>g(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:u}}({P:Nt,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=Nt,{pow_p_5_8:s,b2:i}=function(e){const t=BigInt(10),s=BigInt(20),i=BigInt(40),r=BigInt(80),n=Nt,o=e*e%n*e%n,a=Et(o,Ct,n)*o%n,c=Et(a,At,n)*e%n,h=Et(c,St,n)*c%n,l=Et(h,t,n)*h%n,p=Et(l,s,n)*l%n,d=Et(p,i,n)*p%n,u=Et(d,r,n)*d%n,g=Et(u,r,n)*d%n,f=Et(g,t,n)*h%n;return{pow_p_5_8:Et(f,Ct,n)*e%n,b2:o}}(e);return vt(Et(s,Pt,t)*i,t)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},randomBytes:re}),Tt="base10",kt="base16",xt="base64pad",Rt="utf8",Ut=0,Dt=1,jt=2,Mt=0,Lt=1,qt=12,$t=32;function Bt(){const e=Ot.utils.randomPrivateKey(),t=Ot.getPublicKey(e);return{privateKey:(0,c.dI)(e,kt),publicKey:(0,c.dI)(t,kt)}}function Ht(){const e=re($t);return(0,c.dI)(e,kt)}function Wt(e,t){const s=Ot.getSharedSecret((0,c.sH)(e,kt),(0,c.sH)(t,kt)),i=Xe(ot,s,void 0,void 0,$t);return(0,c.dI)(i,kt)}function zt(e){const t=ot((0,c.sH)(e,kt));return(0,c.dI)(t,kt)}function Vt(e){const t=ot((0,c.sH)(e,Rt));return(0,c.dI)(t,kt)}function Ft(e){return(0,c.sH)(`${e}`,Tt)}function Kt(e){return Number((0,c.dI)(e,Tt))}function Gt(e){const t=Ft(typeof e.type<"u"?e.type:Ut);if(Kt(t)===Dt&&typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const s=typeof e.senderPublicKey<"u"?(0,c.sH)(e.senderPublicKey,kt):void 0,i=typeof e.iv<"u"?(0,c.sH)(e.iv,kt):re(qt),r=(0,c.sH)(e.symKey,kt);return Xt({type:t,sealed:Ke(r,i).encrypt((0,c.sH)(e.message,Rt)),iv:i,senderPublicKey:s,encoding:e.encoding})}function Jt(e){const t=(0,c.sH)(e.symKey,kt),{sealed:s,iv:i}=Zt(e),r=Ke(t,i).decrypt(s);if(null===r)throw new Error("Failed to decrypt");return(0,c.dI)(r,Rt)}function Yt(e,t){const s=Ft(jt),i=re(qt);return Xt({type:s,sealed:(0,c.sH)(e,Rt),iv:i,encoding:t})}function Qt(e,t){const{sealed:s}=Zt({encoded:e,encoding:t});return(0,c.dI)(s,Rt)}function Xt(e){const{encoding:t=xt}=e;if(Kt(e.type)===jt)return(0,c.dI)((0,c.xW)([e.type,e.sealed]),t);if(Kt(e.type)===Dt){if(typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return(0,c.dI)((0,c.xW)([e.type,e.senderPublicKey,e.iv,e.sealed]),t)}return(0,c.dI)((0,c.xW)([e.type,e.iv,e.sealed]),t)}function Zt(e){const{encoded:t,encoding:s=xt}=e,i=(0,c.sH)(t,s),r=i.slice(Mt,Lt),n=Lt;if(Kt(r)===Dt){const e=n+$t,t=e+qt,s=i.slice(n,e),o=i.slice(e,t);return{type:r,sealed:i.slice(t),iv:o,senderPublicKey:s}}if(Kt(r)===jt)return{type:r,sealed:i.slice(n),iv:re(qt)};const o=n+qt,a=i.slice(n,o);return{type:r,sealed:i.slice(o),iv:a}}function es(e,t){const s=Zt({encoded:e,encoding:t?.encoding});return ts({type:Kt(s.type),senderPublicKey:typeof s.senderPublicKey<"u"?(0,c.dI)(s.senderPublicKey,kt):void 0,receiverPublicKey:t?.receiverPublicKey})}function ts(e){const t=e?.type||Ut;if(t===Dt){if(typeof e?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function ss(e){return e.type===Dt&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}function is(e){return e.type===jt}function rs(e,t){const[s,i,r]=e.split("."),n=function(e){return d.from(function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const s=t.length%4;return s>0&&(t+="=".repeat(4-s)),t}(e),"base64")}(r);if(64!==n.length)throw new Error("Invalid signature length");const o=n.slice(0,32).toString("hex"),l=n.slice(32,64).toString("hex"),p=ot(`${s}.${i}`),u=function(e){return new h.ec("p256").keyFromPublic({x:d.from(e.x,"base64").toString("hex"),y:d.from(e.y,"base64").toString("hex")},"hex")}(t),g=(0,c.dI)(p,kt);if(!u.verify(g,{r:o,s:l}))throw new Error("Invalid signature");return(0,a.Cq)(e).payload}const ns="irn";function os(e){return e?.relay||{protocol:ns}}function as(e){const t=l.CG[e];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${e}`);return t}function cs(e,t="-"){const s={},i="relay"+t;return Object.keys(e).forEach(t=>{if(t.startsWith(i)){const r=t.replace(i,""),n=e[t];s[r]=n}}),s}function hs(e){if(!e.includes("wc:")){const t=q(e);null!=t&&t.includes("wc:")&&(e=t)}const t=(e=(e=e.includes("wc://")?e.replace("wc://",""):e).includes("wc:")?e.replace("wc:",""):e).indexOf(":"),s=-1!==e.indexOf("?")?e.indexOf("?"):void 0,i=e.substring(0,t),r=e.substring(t+1,s).split("@"),n=typeof s<"u"?e.substring(s):"",o=new URLSearchParams(n),a={};o.forEach((e,t)=>{a[t]=e});const c="string"==typeof a.methods?a.methods.split(","):void 0;return{protocol:i,topic:ls(r[0]),version:parseInt(r[1],10),symKey:a.symKey,relay:cs(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function ls(e){return e.startsWith("//")?e.substring(2):e}function ps(e){const t=new URLSearchParams,s=function(e,t="-"){const s={};return Object.keys(e).forEach(i=>{const r=i,n="relay"+t+r;e[r]&&(s[n]=e[r])}),s}(e.relay);Object.keys(s).sort().forEach(e=>{t.set(e,s[e])}),t.set("symKey",e.symKey),e.expiryTimestamp&&t.set("expiryTimestamp",e.expiryTimestamp.toString()),e.methods&&t.set("methods",e.methods.join(","));const i=t.toString();return`${e.protocol}:${e.topic}@${e.version}?${i}`}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const ds={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},us={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function gs(e,t){const{message:s,code:i}=us[e];return{message:t?`${s} ${t}`:s,code:i}}function fs(e,t){const{message:s,code:i}=ds[e];return{message:t?`${s} ${t}`:s,code:i}}function ms(e){return typeof e>"u"}function ws(e,t){return!(!t||!ms(e))||"string"==typeof e&&!!e.trim().length}function ys(e){function t(e){try{return typeof new URL(e)<"u"}catch{return!1}}try{if(ws(e,!1))return!!t(e)||t(q(e))}catch{}return!1}function bs(e){var t;return null==(t=e?.proposer)?void 0:t.publicKey}function vs(e){return e?.topic}function Es(e){return typeof e<"u"&&null!==typeof e}function Is(){const e=E();return new Promise(t=>{switch(e){case g.browser:t(v()&&navigator?.onLine);break;case g.reactNative:t(async function(){if(w()&&typeof s.g<"u"&&null!=s.g&&s.g.NetInfo){const e=await(null==s.g?void 0:s.g.NetInfo.fetch());return e?.isConnected}return!0}());break;case g.node:default:t(!0)}})}function _s(e){switch(E()){case g.browser:!function(e){!w()&&v()&&(window.addEventListener("online",()=>e(!0)),window.addEventListener("offline",()=>e(!1)))}(e);break;case g.reactNative:!function(e){w()&&typeof s.g<"u"&&null!=s.g&&s.g.NetInfo&&s.g?.NetInfo.addEventListener(t=>e(t?.isConnected))}(e);case g.node:}}},49009:(e,t,s)=>{s.d(t,{Q:()=>i});const i=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}]},50047:(e,t,s)=>{s.d(t,{R:()=>i});const i=(0,s(40149).x)({id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",deprecatedCaipNetworkId:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"})},50731:(e,t,s)=>{s.d(t,{a:()=>m});var i=s(89168),r=s(39150),n=s(95191),o=s(11807),a=s(26097),c=s(11553),h=s(40868),l=s(99013),p=s(16158),d=s(42831),u=s(26545);const g={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0},f=(0,i.BX)({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:{...g}}),m={state:f,subscribe:e=>(0,i.B1)(f,()=>{e(f)}),subscribeKey:(e,t)=>(0,r.u$)(f,e,t),initialize(e){e.forEach(e=>{const t=c.i.getConnectedConnectorId(e);t&&this.setConnectorId(t,e)})},setActiveConnector(e){e&&(f.activeConnector=(0,i.KR)(e))},setConnectors(e){e.filter(e=>!f.allConnectors.some(t=>t.id===e.id&&this.getConnectorName(t.name)===this.getConnectorName(e.name)&&t.chain===e.chain)).forEach(e=>{"MULTI_CHAIN"!==e.type&&f.allConnectors.push((0,i.KR)(e))}),f.connectors=this.mergeMultiChainConnectors(f.allConnectors)},removeAdapter(e){f.allConnectors=f.allConnectors.filter(t=>t.chain!==e),f.connectors=this.mergeMultiChainConnectors(f.allConnectors)},mergeMultiChainConnectors(e){const t=this.generateConnectorMapByName(e),s=[];return t.forEach(e=>{const t=e[0],i=t?.id===n.o.CONNECTOR_ID.AUTH;e.length>1&&t?s.push({name:t.name,imageUrl:t.imageUrl,imageId:t.imageId,connectors:[...e],type:i?"AUTH":"MULTI_CHAIN",chain:"eip155",id:t?.id||""}):t&&s.push(t)}),s},generateConnectorMapByName(e){const t=new Map;return e.forEach(e=>{const{name:s}=e,i=this.getConnectorName(s);if(!i)return;const r=t.get(i)||[];r.find(t=>t.chain===e.chain)||r.push(e),t.set(i,r)}),t},getConnectorName:e=>e&&{"Trust Wallet":"Trust"}[e]||e,getUniqueConnectorsByName(e){const t=[];return e.forEach(e=>{t.find(t=>t.chain===e.chain)||t.push(e)}),t},addConnector(e){if(e.id===n.o.CONNECTOR_ID.AUTH){const t=e,s=(0,i.P9)(p.H.state),r=u.W.getSnapshot().themeMode,n=u.W.getSnapshot().themeVariables;t?.provider?.syncDappData?.({metadata:s.metadata,sdkVersion:s.sdkVersion,projectId:s.projectId,sdkType:s.sdkType}),t?.provider?.syncTheme({themeMode:r,themeVariables:n,w3mThemeVariables:(0,o.o)(n,r)}),this.setConnectors([e])}else this.setConnectors([e])},getAuthConnector(e){const t=e||l.W.state.activeChain,s=f.connectors.find(e=>e.id===n.o.CONNECTOR_ID.AUTH);if(s)return s?.connectors?.length?s.connectors.find(e=>e.chain===t):s},getAnnouncedConnectorRdns:()=>f.connectors.filter(e=>"ANNOUNCED"===e.type).map(e=>e.info?.rdns),getConnectorById:e=>f.allConnectors.find(t=>t.id===e),getConnector:(e,t)=>f.allConnectors.filter(e=>e.chain===l.W.state.activeChain).find(s=>s.explorerId===e||s.info?.rdns===t),syncIfAuthConnector(e){if("ID_AUTH"!==e.id)return;const t=e,s=(0,i.P9)(p.H.state),r=u.W.getSnapshot().themeMode,n=u.W.getSnapshot().themeVariables;t?.provider?.syncDappData?.({metadata:s.metadata,sdkVersion:s.sdkVersion,sdkType:s.sdkType,projectId:s.projectId}),t.provider.syncTheme({themeMode:r,themeVariables:n,w3mThemeVariables:(0,o.o)(n,r)})},getConnectorsByNamespace(e){const t=f.allConnectors.filter(t=>t.chain===e);return this.mergeMultiChainConnectors(t)},selectWalletConnector(e){const t=m.getConnector(e.id,e.rdns);l.W.state.activeChain===n.o.CHAIN.SOLANA&&a.W.handleSolanaDeeplinkRedirect(t?.name||e.name||""),t?d.I.push("ConnectingExternal",{connector:t}):d.I.push("ConnectingWalletConnect",{wallet:e})},getConnectors(e){return e?this.getConnectorsByNamespace(e):this.mergeMultiChainConnectors(f.allConnectors)},setFilterByNamespace(e){f.filterByNamespace=e,f.connectors=this.getConnectors(e),h.N.setFilterByNamespace(e)},setConnectorId(e,t){e&&(f.activeConnectorIds={...f.activeConnectorIds,[t]:e},c.i.setConnectedConnectorId(t,e))},removeConnectorId(e){f.activeConnectorIds={...f.activeConnectorIds,[e]:void 0},c.i.deleteConnectedConnectorId(e)},getConnectorId(e){if(e)return f.activeConnectorIds[e]},isConnected:e=>e?Boolean(f.activeConnectorIds[e]):Object.values(f.activeConnectorIds).some(e=>Boolean(e)),resetConnectorIds(){f.activeConnectorIds={...g}}}},51493:(e,t,s)=>{},52059:(e,t,s)=>{s.d(t,{W:()=>d});var i=s(89168),r=s(9663),n=s(16279),o=s(27006),a=s(99013),c=s(14479),h=s(16158),l=s(41430);const p=(0,i.BX)({transactions:[],coinbaseTransactions:{},transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),d={state:p,subscribe:e=>(0,i.B1)(p,()=>e(p)),setLastNetworkInView(e){p.lastNetworkInView=e},async fetchTransactions(e,t){if(!e)throw new Error("Transactions can't be fetched without an accountAddress");p.loading=!0;try{const s=await o.T.fetchTransactions({account:e,cursor:p.next,onramp:t,cache:"coinbase"===t?"no-cache":void 0,chainId:a.W.state.activeCaipNetwork?.caipNetworkId}),i=this.filterSpamTransactions(s.data),r=this.filterByConnectedChain(i),n=[...p.transactions,...r];p.loading=!1,"coinbase"===t?p.coinbaseTransactions=this.groupTransactionsByYearAndMonth(p.coinbaseTransactions,s.data):(p.transactions=n,p.transactionsByYear=this.groupTransactionsByYearAndMonth(p.transactionsByYear,r)),p.empty=0===n.length,p.next=s.next?s.next:void 0}catch(t){c.E.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:e,projectId:h.H.state.projectId,cursor:p.next,isSmartAccount:n.U.state.preferredAccountType===r.Vl.ACCOUNT_TYPES.SMART_ACCOUNT}}),l.P.showError("Failed to fetch transactions"),p.loading=!1,p.empty=!0,p.next=void 0}},groupTransactionsByYearAndMonth(e={},t=[]){const s=e;return t.forEach(e=>{const t=new Date(e.metadata.minedAt).getFullYear(),i=new Date(e.metadata.minedAt).getMonth(),r=s[t]??{},n=(r[i]??[]).filter(t=>t.id!==e.id);s[t]={...r,[i]:[...n,e].sort((e,t)=>new Date(t.metadata.minedAt).getTime()-new Date(e.metadata.minedAt).getTime())}}),s},filterSpamTransactions:e=>e.filter(e=>!e.transfers.every(e=>!0===e.nft_info?.flags.is_spam)),filterByConnectedChain(e){const t=a.W.state.activeCaipNetwork?.caipNetworkId;return e.filter(e=>e.metadata.chain===t)},clearCursor(){p.next=void 0},resetTransactions(){p.transactions=[],p.transactionsByYear={},p.lastNetworkInView=void 0,p.loading=!1,p.empty=!1,p.next=void 0}}},55164:(e,t,s)=>{s.d(t,{Rn0:()=>i.Rn,gTy:()=>i.gT,tWt:()=>i.tW});var i=s(14133);s(95642)},55770:(e,t,s)=>{s.d(t,{r:()=>i});const i=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}]},58906:(e,t,s)=>{s.d(t,{i:()=>i});const i="1.7.2"},59677:(e,t,s)=>{s.d(t,{C:()=>i});const i={validateCaipAddress(e){if(3!==e.split(":")?.length)throw new Error("Invalid CAIP Address");return e},parseCaipAddress(e){const t=e.split(":");if(3!==t.length)throw new Error(`Invalid CAIP-10 address: ${e}`);const[s,i,r]=t;if(!s||!i||!r)throw new Error(`Invalid CAIP-10 address: ${e}`);return{chainNamespace:s,chainId:i,address:r}},parseCaipNetworkId(e){const t=e.split(":");if(2!==t.length)throw new Error(`Invalid CAIP-2 network id: ${e}`);const[s,i]=t;if(!s||!i)throw new Error(`Invalid CAIP-2 network id: ${e}`);return{chainNamespace:s,chainId:i}}}},60039:(e,t,s)=>{s.d(t,{R:()=>i});const i={UniversalProviderErrors:{UNAUTHORIZED_DOMAIN_NOT_ALLOWED:{message:"Unauthorized: origin not allowed",alertErrorKey:"INVALID_APP_CONFIGURATION"},JWT_VALIDATION_ERROR:{message:"JWT validation error: JWT Token is not yet valid",alertErrorKey:"JWT_TOKEN_NOT_VALID"},INVALID_KEY:{message:"Unauthorized: invalid key",alertErrorKey:"INVALID_PROJECT_ID"}},ALERT_ERRORS:{SWITCH_NETWORK_NOT_FOUND:{shortMessage:"Network Not Found",longMessage:"Network not found - please make sure it is included in 'networks' array in createAppKit function"},INVALID_APP_CONFIGURATION:{shortMessage:"Invalid App Configuration",longMessage:()=>`Origin ${"undefined"!=typeof window?window.origin:"unknown"} not found on Allowlist - update configuration on cloud.reown.com`},SOCIALS_TIMEOUT:{shortMessage:"Invalid App Configuration",longMessage:()=>"There was an issue loading the embedded wallet. Please verify that your domain is allowed at cloud.reown.com"},JWT_TOKEN_NOT_VALID:{shortMessage:"Session Expired",longMessage:"Invalid session found on UniversalProvider - please check your time settings and connect again"},INVALID_PROJECT_ID:{shortMessage:"Invalid App Configuration",longMessage:"Invalid Project ID - update configuration"},PROJECT_ID_NOT_CONFIGURED:{shortMessage:"Project ID Not Configured",longMessage:"Project ID Not Configured - update configuration on cloud.reown.com"}}}},63789:(e,t,s)=>{s.d(t,{Z:()=>i});const i={getSpacingStyles:(e,t)=>Array.isArray(e)?e[t]?`var(--wui-spacing-${e[t]})`:void 0:"string"==typeof e?`var(--wui-spacing-${e})`:void 0,getFormattedDate:e=>new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(e),getHostName(e){try{return new URL(e).hostname}catch(e){return""}},getTruncateString:({string:e,charsStart:t,charsEnd:s,truncate:i})=>e.length<=t+s?e:"end"===i?`${e.substring(0,t)}...`:"start"===i?`...${e.substring(e.length-s)}`:`${e.substring(0,Math.floor(t))}...${e.substring(e.length-Math.floor(s))}`,generateAvatarColors(e){const t=e.toLowerCase().replace(/^0x/iu,"").replace(/[^a-f0-9]/gu,"").substring(0,6).padEnd(6,"0"),s=this.hexToRgb(t),i=getComputedStyle(document.documentElement).getPropertyValue("--w3m-border-radius-master"),r=100-3*Number(i?.replace("px","")),n=`${r}% ${r}% at 65% 40%`,o=[];for(let e=0;e<5;e+=1){const t=this.tintColor(s,.15*e);o.push(`rgb(${t[0]}, ${t[1]}, ${t[2]})`)}return`\n --local-color-1: ${o[0]};\n --local-color-2: ${o[1]};\n --local-color-3: ${o[2]};\n --local-color-4: ${o[3]};\n --local-color-5: ${o[4]};\n --local-radial-circle: ${n}\n `},hexToRgb(e){const t=parseInt(e,16);return[t>>16&255,t>>8&255,255&t]},tintColor(e,t){const[s,i,r]=e;return[Math.round(s+(255-s)*t),Math.round(i+(255-i)*t),Math.round(r+(255-r)*t)]},isNumber:e=>/^[0-9]+$/u.test(e),getColorTheme:e=>e||("undefined"!=typeof window&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)")?.matches?"dark":"light":"dark"),splitBalance(e){const t=e.split(".");return 2===t.length?[t[0],t[1]]:["0","00"]},roundNumber:(e,t,s)=>e.toString().length>=t?Number(e).toFixed(s):e,formatNumberToLocalString:(e,t=2)=>void 0===e?"0.00":"number"==typeof e?e.toLocaleString("en-US",{maximumFractionDigits:t,minimumFractionDigits:t}):parseFloat(e).toLocaleString("en-US",{maximumFractionDigits:t,minimumFractionDigits:t})}},66715:(e,t,s)=>{s.d(t,{f:()=>w});var i=s(53834),r=s(73821),n=s(3834),o=s(40446),a=s(76754),c=s(48336),h=s(30544),l=s(33244),p=s(96759),d=s(84320),u=s(41276),g=s(89351),f=s(85445),m=s(48526).hp;class w{_UniversalProvider;_session;_modal;_projectId;_network;_ConnectQueueResolver;constructor(e){if(this.initClient(e.options),this._network=e.network,!e.options.projectId)throw Error("WalletConnect Adapter: Project ID is undefined");this._projectId=e.options.projectId}async connect(){if(this._UniversalProvider||await new Promise(e=>{this._ConnectQueueResolver=e}),!this._UniversalProvider)throw new Error("WalletConnect Adapter - Universal Provider was undefined while calling 'connect()'");if(this._UniversalProvider.session){this._session=this._UniversalProvider.session;const e=(0,g.hJ)(this._session,this._network);return this._network=e,this._UniversalProvider.setDefaultChain(e),{publicKey:this.publicKey}}await this.initModal();const e=(0,g.lC)(this._network);this._modal?.open();const t=new AbortController,s=t.signal;this._modal?.subscribeState(e=>{e.open||t.abort(new f.K)});try{const t=await Promise.race([this._UniversalProvider?.connect(e),new Promise((e,t)=>{s.addEventListener("abort",()=>{t(s.reason)})})]);if(this._modal?.close(),this._session=t,!t)throw new i.Y6;const r=(0,g.hJ)(t,this._network);return this._network=r,this._UniversalProvider?.setDefaultChain(r),{publicKey:this.publicKey}}catch(e){throw this._modal?.close(),e}}async disconnect(){if(!this._UniversalProvider?.session)throw new d.r;if(await this.initModal(),!this._modal)throw Error("WalletConnect Adapter -Modal is undefined: unable to disconnect");await this.client.disconnect(),this._session=void 0}get client(){if(this._UniversalProvider)return this._UniversalProvider;throw new d.r}get session(){if(!this._session)throw new d.r;return this._session}get publicKey(){if(this._UniversalProvider?.session&&this._session){const{address:e}=(0,a.cK)(this._session?.namespaces.solana?.accounts[0]??"");return new n.PublicKey(e)}throw new d.r}async signTransaction(e){this.checkIfWalletSupportsMethod(p.jD.signTransaction);const t=(0,r.Y)(e),s=t?{}:e,{signature:i,transaction:n}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:p.jD.signTransaction,params:{...s,transaction:this.serialize(e)}}});return n?this.deserialize(n,t):(e.addSignature(this.publicKey,m.from(l.A.decode(i))),e)}async signMessage(e){this.checkIfWalletSupportsMethod(p.jD.signMessage);const{signature:t}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:p.jD.signMessage,params:{pubkey:this.publicKey.toString(),message:l.A.encode(e)}}});return l.A.decode(t)}async signAndSendTransaction(e){this.checkIfWalletSupportsMethod(p.jD.signAndSendTransaction);const{signature:t}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:p.jD.signAndSendTransaction,params:{transaction:this.serialize(e)}}});return t}async signAllTransactions(e){try{this.checkIfWalletSupportsMethod(p.jD.signAllTransactions);const t=e.map(e=>this.serialize(e)),{transactions:s}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:p.jD.signAllTransactions,params:{transactions:t}}});return e.map((e,t)=>(0,r.Y)(e)?this.deserialize(s[t]??"",!0):this.deserialize(s[t]??""))}catch(t){if(t instanceof u.f){const t=e.map(e=>this.signTransaction(e));return await Promise.all(t)}throw t}}async initClient(e){const t=await o.l.init(e);this._UniversalProvider=t,this._ConnectQueueResolver&&this._ConnectQueueResolver(!0)}async initModal(){if(!this._modal){if(!this._UniversalProvider)throw new Error("WalletConnect Adapter - cannot init modal when Universal Provider is undefined");this._modal=(0,c.s)({projectId:this._projectId,universalProvider:this._UniversalProvider,networks:[h.tWt,h.Rn0,h.gTy],manualWCControl:!0})}}serialize(e){return m.from(e.serialize({verifySignatures:!1})).toString("base64")}deserialize(e,t=!1){return t?n.VersionedTransaction.deserialize(m.from(e,"base64")):n.Transaction.from(m.from(e,"base64"))}checkIfWalletSupportsMethod(e){if(!this.session.namespaces.solana?.methods.includes(e))throw new u.f(e)}}},67018:(e,t,s)=>{s.d(t,{W:()=>m});var i=s(89168),r=s(39150),n=s(5813),o=s(16279),a=s(40868),c=s(99013),h=s(89058),l=s(50731),p=s(14479),d=s(16158),u=s(25422),g=s(42831);const f=(0,i.BX)({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),m={state:f,subscribe:e=>(0,i.B1)(f,()=>e(f)),subscribeKey:(e,t)=>(0,r.u$)(f,e,t),async open(e){const t="connected"===o.U.state.status;h.x.state.wcBasic?a.N.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1}):await a.N.prefetch({fetchConnectorImages:!t,fetchFeaturedWallets:!t,fetchRecommendedWallets:!t}),e?.namespace?(await c.W.switchActiveNamespace(e.namespace),m.setLoading(!0,e.namespace)):m.setLoading(!0),l.a.setFilterByNamespace(e?.namespace);const s=c.W.getAccountData(e?.namespace)?.caipAddress;c.W.state.noAdapters&&!s?n.w.isMobile()?g.I.reset("AllWallets"):g.I.reset("ConnectingWalletConnectBasic"):e?.view?g.I.reset(e.view):s?g.I.reset("Account"):g.I.reset("Connect"),f.open=!0,u.z.set({open:!0}),p.E.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:Boolean(s)}})},close(){const e=d.H.state.enableEmbedded,t=Boolean(c.W.state.activeCaipAddress);f.open&&p.E.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:t}}),f.open=!1,m.clearLoading(),e?t?g.I.replace("Account"):g.I.push("Connect"):u.z.set({open:!1}),h.x.resetUri()},setLoading(e,t){t&&f.loadingNamespaceMap.set(t,e),f.loading=e,u.z.set({loading:e})},clearLoading(){f.loadingNamespaceMap.clear(),f.loading=!1},shake(){f.shake||(f.shake=!0,setTimeout(()=>{f.shake=!1},500))}}},69033:(e,t,s)=>{s.d(t,{k:()=>o});var i=s(29864),r=s(55164);const n={solana:["solana_signMessage","solana_signTransaction","solana_requestAccounts","solana_getAccounts","solana_signAllTransactions","solana_signAndSendTransaction"],eip155:["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_showCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"],bip122:["sendTransfer","signMessage","signPsbt","getAccountAddresses"]},o={getMethodsByChainNamespace:e=>n[e]||[],createDefaultNamespace(e){return{methods:this.getMethodsByChainNamespace(e),events:["accountsChanged","chainChanged"],chains:[],rpcMap:{}}},applyNamespaceOverrides(e,t){if(!t)return{...e};const s={...e},i=new Set;if(t.methods&&Object.keys(t.methods).forEach(e=>i.add(e)),t.chains&&Object.keys(t.chains).forEach(e=>i.add(e)),t.events&&Object.keys(t.events).forEach(e=>i.add(e)),t.rpcMap&&Object.keys(t.rpcMap).forEach(e=>{const[t]=e.split(":");t&&i.add(t)}),i.forEach(e=>{s[e]||(s[e]=this.createDefaultNamespace(e))}),t.methods&&Object.entries(t.methods).forEach(([e,t])=>{s[e]&&(s[e].methods=t)}),t.chains&&Object.entries(t.chains).forEach(([e,t])=>{s[e]&&(s[e].chains=t)}),t.events&&Object.entries(t.events).forEach(([e,t])=>{s[e]&&(s[e].events=t)}),t.rpcMap){const e=new Set;Object.entries(t.rpcMap).forEach(([t,i])=>{const[r,n]=t.split(":");r&&n&&s[r]&&(s[r].rpcMap||(s[r].rpcMap={}),e.has(r)||(s[r].rpcMap={},e.add(r)),s[r].rpcMap[n]=i)})}return s},createNamespaces(e,t){const s=e.reduce((e,t)=>{const{id:s,chainNamespace:i,rpcUrls:n}=t,o=n.default.http[0];e[i]||(e[i]=this.createDefaultNamespace(i));const a=`${i}:${s}`,c=e[i];switch(c.chains.push(a),a){case r.tWt.caipNetworkId:c.chains.push(r.tWt.deprecatedCaipNetworkId);break;case r.Rn0.caipNetworkId:c.chains.push(r.Rn0.deprecatedCaipNetworkId)}return c?.rpcMap&&o&&(c.rpcMap[s]=o),e},{});return this.applyNamespaceOverrides(s,t)},resolveReownName:async e=>{const t=await i.f.resolveName(e),s=Object.values(t?.addresses)||[];return s[0]?.address||!1},getChainsFromNamespaces:(e={})=>Object.values(e).flatMap(e=>{const t=e.chains||[],s=e.accounts.map(e=>{const[t,s]=e.split(":");return`${t}:${s}`});return Array.from(new Set([...t,...s]))}),isSessionEventData:e=>"object"==typeof e&&null!==e&&"id"in e&&"topic"in e&&"params"in e&&"object"==typeof e.params&&null!==e.params&&"chainId"in e.params&&"event"in e.params&&"object"==typeof e.params.event&&null!==e.params.event}},72931:(e,t,s)=>{s(3496),s(63789)},74091:(e,t,s)=>{s.d(t,{o:()=>r});var i=s(39907);const r={ACCOUNT_TABS:[{label:"Tokens"},{label:"NFTs"},{label:"Activity"}],SECURE_SITE_ORIGIN:(void 0!==i&&void 0!==i.env?i.env.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",VIEW_DIRECTION:{Next:"next",Prev:"prev"},DEFAULT_CONNECT_METHOD_ORDER:["email","social","wallet"],ANIMATION_DURATIONS:{HeaderText:120,ModalHeight:150,ViewTransition:150}}},76020:(e,t,s)=>{s.d(t,{L:()=>i});const i={caipNetworkIdToNumber:e=>e?Number(e.split(":")[1]):void 0,parseEvmChainId(e){return"string"==typeof e?this.caipNetworkIdToNumber(e):e},getNetworksByNamespace:(e,t)=>e?.filter(e=>e.chainNamespace===t)||[],getFirstNetworkByNamespace(e,t){return this.getNetworksByNamespace(e,t)[0]}}},76663:(e,t,s)=>{s.d(t,{F:()=>c}),s(1057);var i=s(95191),r=s(16158),n=s(24537),o=s(40770),a=s(86808);class c{constructor({provider:e,caipNetworks:t,namespace:s}){this.id=i.o.CONNECTOR_ID.WALLET_CONNECT,this.name=o.L.ConnectorNamesMap[i.o.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=o.L.ConnectorImageIds[i.o.CONNECTOR_ID.WALLET_CONNECT],this.caipNetworks=t,this.provider=e,this.chain=s}get chains(){return this.caipNetworks}async connectWalletConnect(){if(!await this.authenticate()){const e=r.H.state.universalProviderConfigOverride,t=a.kl.createNamespaces(this.caipNetworks,e);await this.provider.connect({optionalNamespaces:t})}return{clientId:await this.provider.client.core.crypto.getClientId(),session:this.provider.session}}async disconnect(){await this.provider.disconnect()}async authenticate(){const e=this.chains.map(e=>e.caipNetworkId);return n.U.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:h})}}const h=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"]},76754:(e,t,s)=>{s.d(t,{$Bq:()=>Js,$hI:()=>F,ADD:()=>M,ALl:()=>Ss,AYU:()=>pi,Alu:()=>Ei,AwN:()=>Ls,BdH:()=>A,C5G:()=>Ms,CTo:()=>di,EHS:()=>bs,EN$:()=>Ps,EWt:()=>gs,F$L:()=>Us,FR8:()=>Ci,FiO:()=>yi,GuA:()=>si,HNf:()=>hi,Hbs:()=>xi,Hjj:()=>ii,IjX:()=>ze,K3g:()=>D,Lln:()=>E,Lp_:()=>ys,M8n:()=>Ai,OP1:()=>ri,PUk:()=>R,Pa8:()=>fs,QJh:()=>Gs,Qhg:()=>ai,R7U:()=>P,TRk:()=>W,TZl:()=>Ns,TeY:()=>Ii,Tw2:()=>Rs,U0i:()=>Bs,V7m:()=>qs,V9G:()=>vi,VBM:()=>et,Van:()=>Zs,WWN:()=>Ze,Wx8:()=>U,X3c:()=>_i,XqR:()=>Ti,Xw0:()=>$,YcA:()=>xs,_Yb:()=>f,_dF:()=>B,aF0:()=>ni,aRZ:()=>N,aa1:()=>zs,b07:()=>oi,bEt:()=>us,c82:()=>q,cK:()=>m,e8_:()=>Ye,esh:()=>wi,gOF:()=>L,gZm:()=>K,h0Y:()=>x,hEn:()=>H,hVC:()=>Qe,hwK:()=>Ve,iV1:()=>Ni,iui:()=>js,jTh:()=>V,jUZ:()=>T,kob:()=>Xs,kuU:()=>bi,lFF:()=>S,lVv:()=>I,m01:()=>_,mr0:()=>ui,n3s:()=>z,n6V:()=>Ws,nWe:()=>Qs,nyL:()=>ji,oKp:()=>Si,ojD:()=>O,ovp:()=>Cs,ps1:()=>$s,q_h:()=>We,sc7:()=>Ri,sc_:()=>Xe,tLy:()=>Pi,tk0:()=>gi,two:()=>As,uym:()=>Ui,w8K:()=>G,wYp:()=>Fs,wa2:()=>ks,x0t:()=>Ts,xkc:()=>He,yy4:()=>Y,z2N:()=>Oi});var i=s(24661),r=s(91315),n=s(20635),o=s(67822),a=s(71268),c=s(97353),h=s(1030),l=s(13360),p=s(17367),d=s(39907),u=s(48526).hp;const g=":";function f(e){const[t,s]=e.split(g);return{namespace:t,reference:s}}function m(e){const[t,s,i]=e.split(g);return{namespace:t,reference:s,address:i}}function w(e,t){return e.includes(":")?[e]:t.chains||[]}const y="ReactNative",b={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},v="js";function E(){return typeof d<"u"&&typeof d.versions<"u"&&typeof d.versions.node<"u"}function I(){return!(0,n.getDocument)()&&!!(0,n.getNavigator)()&&navigator.product===y}function _(){return I()&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Platform)<"u"&&"android"===(null==s.g?void 0:s.g.Platform.OS)}function N(){return I()&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Platform)<"u"&&"ios"===(null==s.g?void 0:s.g.Platform.OS)}function A(){return!E()&&!!(0,n.getNavigator)()&&!!(0,n.getDocument)()}function C(){return I()?b.reactNative:E()?b.node:A()?b.browser:b.unknown}function P(){var e;try{return I()&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Application)<"u"?null==(e=s.g.Application)?void 0:e.applicationId:void 0}catch{return}}function S(){return(0,o.g)()||{name:"",description:"",url:"",icons:[""]}}function O(e,t,r){const o=function(){if(C()===b.reactNative&&typeof s.g<"u"&&typeof(null==s.g?void 0:s.g.Platform)<"u"){const{OS:e,Version:t}=s.g.Platform;return[e,t].join("-")}const e=(0,i.o0)();if(null===e)return"unknown";const t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return"browser"===e.type?[t,e.name,e.version].join("-"):[t,e.version].join("-")}(),a=function(){var e;const t=C();return t===b.browser?[t,(null==(e=(0,n.getLocation)())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),[v,r].join("-"),o,a].join("/")}function T({protocol:e,version:t,relayUrl:s,sdkVersion:i,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const h=s.split("?"),l={auth:r,ua:O(e,t,i),projectId:n,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},p=function(e,t){const s=new URLSearchParams(e);for(const e of Object.keys(t).sort())if(t.hasOwnProperty(e)){const i=t[e];void 0!==i&&s.set(e,i)}return s.toString()}(h[1]||"",l);return h[0]+"?"+p}function k(e,t){return e.filter(e=>t.includes(e)).length===e.length}function x(e){return Object.fromEntries(e.entries())}function R(e){return new Map(Object.entries(e))}function U(e=r.FIVE_MINUTES,t){const s=(0,r.toMiliseconds)(e||r.FIVE_MINUTES);let i,n,o,a;return{resolve:e=>{o&&i&&(clearTimeout(o),i(e),a=Promise.resolve(e))},reject:e=>{o&&n&&(clearTimeout(o),n(e))},done:()=>new Promise((e,r)=>{if(a)return e(a);o=setTimeout(()=>{const e=new Error(t);a=Promise.reject(e),r(e)},s),i=e,n=r})}}function D(e,t,s){return new Promise(async(i,r)=>{const n=setTimeout(()=>r(new Error(s)),t);try{i(await e)}catch(e){r(e)}clearTimeout(n)})}function j(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${e}`)}function M(e){return j("topic",e)}function L(e){return j("id",e)}function q(e){const[t,s]=e.split(":"),i={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof s)i.topic=s;else{if("id"!==t||!Number.isInteger(Number(s)))throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${s}`);i.id=Number(s)}return i}function $(e,t){return(0,r.fromMiliseconds)((t||Date.now())+(0,r.toMiliseconds)(e))}function B(e){return Date.now()>=(0,r.toMiliseconds)(e)}function H(e,t){return`${e}${t?`:${t}`:""}`}function W(e=[],t=[]){return[...new Set([...e,...t])]}async function z({id:e,topic:t,wcDeepLink:i}){var r;try{if(!i)return;const o="string"==typeof i?JSON.parse(i):i,a=o?.href;if("string"!=typeof a)return;const c=function(e,t,s){const i=`requestId=${t}&sessionTopic=${s}`;e.endsWith("/")&&(e=e.slice(0,-1));let r=`${e}`;return r=e.startsWith("https://t.me")?`${r}${e.includes("?")?"&startapp=":"?startapp="}${function(e,t=!1){const s=u.from(e).toString("base64");return t?s.replace(/[=]/g,""):s}(i,!0)}`:`${r}/wc?${i}`,r}(a,e,t),h=C();if(h===b.browser){if(null==(r=(0,n.getDocument)())||!r.hasFocus())return void console.warn("Document does not have focus, skipping deeplink.");!function(e){let t="_self";!function(){try{return window.self!==window.top}catch{return!1}}()?(typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)||e.startsWith("https://")||e.startsWith("http://"))&&(t="_blank"):t="_top",window.open(e,t,"noreferrer noopener")}(c)}else h===b.reactNative&&typeof(null==s.g?void 0:s.g.Linking)<"u"&&await s.g.Linking.openURL(c)}catch(e){console.error(e)}}async function V(e,t){let s="";try{if(A()&&(s=localStorage.getItem(t),s))return s;s=await e.getItem(t)}catch(e){console.error(e)}return s}function F(e,t){if(!e.includes(t))return null;const s=e.split(/([&,?,=])/),i=s.indexOf(t);return s[i+2]}function K(){return typeof crypto<"u"&&null!=crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function G(){return typeof d<"u"&&"true"===d.env.IS_VITEST}function J(e){return u.from(e,"base64").toString("utf-8")}function Y(e){return new Promise(t=>setTimeout(t,e))}function Q(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function X(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Z(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Q(e.outputLen),Q(e.blockLen)}function ee(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function te(e,t){X(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}const se=BigInt(2**32-1),ie=BigInt(32);function re(e,t=!1){return t?{h:Number(e&se),l:Number(e>>ie&se)}:{h:0|Number(e>>ie&se),l:0|Number(e&se)}}const ne="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function oe(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ae(e,t){return e<<32-t|e>>>t}const ce=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function he(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function le(e){for(let t=0;t<e.length;t++)e[t]=he(e[t])}function pe(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),X(e),e}class de{clone(){return this._cloneInto()}}function ue(e){const t=t=>e().update(pe(t)).digest(),s=e();return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=()=>e(),t}function ge(e=32){if(ne&&"function"==typeof ne.getRandomValues)return ne.getRandomValues(new Uint8Array(e));if(ne&&"function"==typeof ne.randomBytes)return ne.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}const fe=[],me=[],we=[],ye=BigInt(0),be=BigInt(1),ve=BigInt(2),Ee=BigInt(7),Ie=BigInt(256),_e=BigInt(113);for(let e=0,t=be,s=1,i=0;e<24;e++){[s,i]=[i,(2*s+3*i)%5],fe.push(2*(5*i+s)),me.push((e+1)*(e+2)/2%64);let r=ye;for(let e=0;e<7;e++)t=(t<<be^(t>>Ee)*_e)%Ie,t&ve&&(r^=be<<(be<<BigInt(e))-be);we.push(r)}const[Ne,Ae]=function(e,t=!1){let s=new Uint32Array(e.length),i=new Uint32Array(e.length);for(let r=0;r<e.length;r++){const{h:n,l:o}=re(e[r],t);[s[r],i[r]]=[n,o]}return[s,i]}(we,!0),Ce=(e,t,s)=>s>32?((e,t,s)=>t<<s-32|e>>>64-s)(e,t,s):((e,t,s)=>e<<s|t>>>32-s)(e,t,s),Pe=(e,t,s)=>s>32?((e,t,s)=>e<<s-32|t>>>64-s)(e,t,s):((e,t,s)=>t<<s|e>>>32-s)(e,t,s);class Se extends de{constructor(e,t,s,i=!1,r=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=s,this.enableXOF=i,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Q(s),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var n;this.state=new Uint8Array(200),this.state32=(n=this.state,new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)))}keccak(){ce||le(this.state32),function(e,t=24){const s=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let t=0;t<10;t++)s[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const i=(t+8)%10,r=(t+2)%10,n=s[r],o=s[r+1],a=Ce(n,o,1)^s[i],c=Pe(n,o,1)^s[i+1];for(let s=0;s<50;s+=10)e[t+s]^=a,e[t+s+1]^=c}let t=e[2],r=e[3];for(let s=0;s<24;s++){const i=me[s],n=Ce(t,r,i),o=Pe(t,r,i),a=fe[s];t=e[a],r=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let i=0;i<10;i++)s[i]=e[t+i];for(let i=0;i<10;i++)e[t+i]^=~s[(i+2)%10]&s[(i+4)%10]}e[0]^=Ne[i],e[1]^=Ae[i]}s.fill(0)}(this.state32,this.rounds),ce||le(this.state32),this.posOut=0,this.pos=0}update(e){ee(this);const{blockLen:t,state:s}=this,i=(e=pe(e)).length;for(let r=0;r<i;){const n=Math.min(t-this.pos,i-r);for(let t=0;t<n;t++)s[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:s,blockLen:i}=this;e[s]^=t,!!(128&t)&&s===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){ee(this,!1),X(e),this.finish();const t=this.state,{blockLen:s}=this;for(let i=0,r=e.length;i<r;){this.posOut>=s&&this.keccak();const n=Math.min(s-this.posOut,r-i);e.set(t.subarray(this.posOut,this.posOut+n),i),this.posOut+=n,i+=n}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Q(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(te(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:s,outputLen:i,rounds:r,enableXOF:n}=this;return e||(e=new Se(t,s,i,n,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=s,e.outputLen=i,e.enableXOF=n,e.destroyed=this.destroyed,e}}const Oe=ue(()=>new Se(136,1,32)),Te="https://rpc.walletconnect.org/v1";function ke(e){const t=`Ethereum Signed Message:\n${e.length}`,s=(new TextEncoder).encode(t+e);return"0x"+u.from(Oe(s)).toString("hex")}var xe=Object.defineProperty,Re=Object.defineProperties,Ue=Object.getOwnPropertyDescriptors,De=Object.getOwnPropertySymbols,je=Object.prototype.hasOwnProperty,Me=Object.prototype.propertyIsEnumerable,Le=(e,t,s)=>t in e?xe(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,qe=(e,t)=>{for(var s in t||(t={}))je.call(t,s)&&Le(e,s,t[s]);if(De)for(var s of De(t))Me.call(t,s)&&Le(e,s,t[s]);return e},$e=(e,t)=>Re(e,Ue(t));const Be=e=>e?.split(":"),He=e=>{const t=e&&Be(e);if(t)return t[2]+":"+t[3]},We=e=>{const t=e&&Be(e);if(t)return t.pop()};async function ze(e){const{cacao:t,projectId:s}=e,{s:i,p:r}=t,n=Ve(r,r.iss),o=We(r.iss);return await async function(e,t,s,i,r,n){switch(s.t){case"eip191":return await async function(e,t,s){return(await(0,a.x)({hash:ke(t),signature:s})).toLowerCase()===e.toLowerCase()}(e,t,s.s);case"eip1271":return await async function(e,t,s,i,r,n){const o=f(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const o="0x1626ba7e",a="0000000000000000000000000000000000000000000000000000000000000040",c="0000000000000000000000000000000000000000000000000000000000000041",h=s.substring(2),l=o+ke(t).substring(2)+a+c+h,p=await fetch(`${n||Te}/?chainId=${i}&projectId=${r}`,{method:"POST",body:JSON.stringify({id:Date.now()+Math.floor(1e3*Math.random()),jsonrpc:"2.0",method:"eth_call",params:[{to:e,data:l},"latest"]})}),{result:d}=await p.json();return!!d&&d.slice(0,o.length).toLowerCase()===o.toLowerCase()}catch(e){return console.error("isValidEip1271Signature: ",e),!1}}(e,t,s.s,i,r,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${s.t}`)}}(o,n,i,He(r.iss),s)}const Ve=(e,t)=>{const s=`${e.domain} wants you to sign in with your Ethereum account:`,i=We(t);if(!e.aud&&!e.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let r=e.statement||void 0;const n=`URI: ${e.aud||e.uri}`,o=`Version: ${e.version}`,a=`Chain ID: ${(e=>{const t=e&&Be(e);if(t)return e.includes("did:pkh:")?t[3]:t[1]})(t)}`,c=`Nonce: ${e.nonce}`,h=`Issued At: ${e.iat}`,l=e.exp?`Expiration Time: ${e.exp}`:void 0,p=e.nbf?`Not Before: ${e.nbf}`:void 0,d=e.requestId?`Request ID: ${e.requestId}`:void 0,u=e.resources?`Resources:${e.resources.map(e=>`\n- ${e}`).join("")}`:void 0,g=et(e.resources);return g&&(r=function(e="",t){Fe(t);const s="I further authorize the stated URI to perform the following actions on my behalf: ";if(e.includes(s))return e;const i=[];let r=0;return Object.keys(t.att).forEach(e=>{const s=Object.keys(t.att[e]).map(e=>({ability:e.split("/")[0],action:e.split("/")[1]}));s.sort((e,t)=>e.action.localeCompare(t.action));const n={};s.forEach(e=>{n[e.ability]||(n[e.ability]=[]),n[e.ability].push(e.action)});const o=Object.keys(n).map(t=>(r++,`(${r}) '${t}': '${n[t].join("', '")}' for '${e}'.`));i.push(o.join(", ").replace(".,","."))}),`${e?e+" ":""}${s}${i.join(" ")}`}(r,Je(g))),[s,i,"",r,"",n,o,a,c,h,l,p,d,u].filter(e=>null!=e).join("\n")};function Fe(e){if(!e)throw new Error("No recap provided, value is undefined");if(!e.att)throw new Error("No `att` property found");const t=Object.keys(e.att);if(null==t||!t.length)throw new Error("No resources found in `att` property");t.forEach(t=>{const s=e.att[t];if(Array.isArray(s))throw new Error(`Resource must be an object: ${t}`);if("object"!=typeof s)throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(s).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(s).forEach(e=>{const t=s[e];if(!Array.isArray(t))throw new Error(`Ability limits ${e} must be an array of objects, found: ${t}`);if(!t.length)throw new Error(`Value of ${e} is empty array, must be an array with objects`);t.forEach(t=>{if("object"!=typeof t)throw new Error(`Ability limits (${e}) must be an array of objects, found: ${t}`)})})})}function Ke(e,t,s={}){t=t?.sort((e,t)=>e.localeCompare(t));const i=t.map(t=>({[`${e}/${t}`]:[s]}));return Object.assign({},...i)}function Ge(e){return Fe(e),`urn:recap:${function(e){return u.from(JSON.stringify(e)).toString("base64")}(e).replace(/=/g,"")}`}function Je(e){const t=function(e){return JSON.parse(u.from(e,"base64").toString("utf-8"))}(e.replace("urn:recap:",""));return Fe(t),t}function Ye(e,t,s){const i=function(e,t,s,i={}){return s?.sort((e,t)=>e.localeCompare(t)),{att:{[e]:Ke(t,s,i)}}}(e,t,s);return Ge(i)}function Qe(e,t){const s=function(e,t){Fe(e),Fe(t);const s=Object.keys(e.att).concat(Object.keys(t.att)).sort((e,t)=>e.localeCompare(t)),i={att:{}};return s.forEach(s=>{var r,n;Object.keys((null==(r=e.att)?void 0:r[s])||{}).concat(Object.keys((null==(n=t.att)?void 0:n[s])||{})).sort((e,t)=>e.localeCompare(t)).forEach(r=>{var n,o;i.att[s]=$e(qe({},i.att[s]),{[r]:(null==(n=e.att[s])?void 0:n[r])||(null==(o=t.att[s])?void 0:o[r])})})}),i}(Je(e),Je(t));return Ge(s)}function Xe(e){var t;const s=Je(e);Fe(s);const i=null==(t=s.att)?void 0:t.eip155;return i?Object.keys(i).map(e=>e.split("/")[1]):[]}function Ze(e){const t=Je(e);Fe(t);const s=[];return Object.values(t.att).forEach(e=>{Object.values(e).forEach(e=>{var t;null!=(t=e?.[0])&&t.chains&&s.push(e[0].chains)})}),[...new Set(s.flat())]}function et(e){if(!e)return;const t=e?.[e.length-1];return function(e){return e&&e.includes("urn:recap:")}(t)?t:void 0}function tt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function st(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function it(e,...t){if(!st(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function rt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function nt(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}const ot=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function at(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!st(e))throw new Error("Uint8Array expected, got "+typeof e);e=lt(e)}return e}function ct(e,t,s=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(s&&!function(e){return e.byteOffset%4==0}(t))throw new Error("invalid output, must be aligned");return t}function ht(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(s>>r&n),a=Number(s&n),c=i?4:0,h=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+h,a,i)}function lt(e){return Uint8Array.from(e)}function pt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const dt=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),ut=dt("expand 16-byte k"),gt=dt("expand 32-byte k"),ft=ot(ut),mt=ot(gt);function wt(e,t){return e<<t|e>>>32-t}function yt(e){return e.byteOffset%4==0}const bt=2**32-1,vt=new Uint32Array,Et=(e,t)=>255&e[t++]|(255&e[t++])<<8;class It{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,it(e=at(e),32);const t=Et(e,0),s=Et(e,2),i=Et(e,4),r=Et(e,6),n=Et(e,8),o=Et(e,10),a=Et(e,12),c=Et(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|s<<3),this.r[2]=7939&(s>>>10|i<<6),this.r[3]=8191&(i>>>7|r<<9),this.r[4]=255&(r>>>4|n<<12),this.r[5]=n>>>1&8190,this.r[6]=8191&(n>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=Et(e,16+2*t)}process(e,t,s=!1){const i=s?0:2048,{h:r,r:n}=this,o=n[0],a=n[1],c=n[2],h=n[3],l=n[4],p=n[5],d=n[6],u=n[7],g=n[8],f=n[9],m=Et(e,t+0),w=Et(e,t+2),y=Et(e,t+4),b=Et(e,t+6),v=Et(e,t+8),E=Et(e,t+10),I=Et(e,t+12),_=Et(e,t+14);let N=r[0]+(8191&m),A=r[1]+(8191&(m>>>13|w<<3)),C=r[2]+(8191&(w>>>10|y<<6)),P=r[3]+(8191&(y>>>7|b<<9)),S=r[4]+(8191&(b>>>4|v<<12)),O=r[5]+(v>>>1&8191),T=r[6]+(8191&(v>>>14|E<<2)),k=r[7]+(8191&(E>>>11|I<<5)),x=r[8]+(8191&(I>>>8|_<<8)),R=r[9]+(_>>>5|i),U=0,D=U+N*o+A*(5*f)+C*(5*g)+P*(5*u)+S*(5*d);U=D>>>13,D&=8191,D+=O*(5*p)+T*(5*l)+k*(5*h)+x*(5*c)+R*(5*a),U+=D>>>13,D&=8191;let j=U+N*a+A*o+C*(5*f)+P*(5*g)+S*(5*u);U=j>>>13,j&=8191,j+=O*(5*d)+T*(5*p)+k*(5*l)+x*(5*h)+R*(5*c),U+=j>>>13,j&=8191;let M=U+N*c+A*a+C*o+P*(5*f)+S*(5*g);U=M>>>13,M&=8191,M+=O*(5*u)+T*(5*d)+k*(5*p)+x*(5*l)+R*(5*h),U+=M>>>13,M&=8191;let L=U+N*h+A*c+C*a+P*o+S*(5*f);U=L>>>13,L&=8191,L+=O*(5*g)+T*(5*u)+k*(5*d)+x*(5*p)+R*(5*l),U+=L>>>13,L&=8191;let q=U+N*l+A*h+C*c+P*a+S*o;U=q>>>13,q&=8191,q+=O*(5*f)+T*(5*g)+k*(5*u)+x*(5*d)+R*(5*p),U+=q>>>13,q&=8191;let $=U+N*p+A*l+C*h+P*c+S*a;U=$>>>13,$&=8191,$+=O*o+T*(5*f)+k*(5*g)+x*(5*u)+R*(5*d),U+=$>>>13,$&=8191;let B=U+N*d+A*p+C*l+P*h+S*c;U=B>>>13,B&=8191,B+=O*a+T*o+k*(5*f)+x*(5*g)+R*(5*u),U+=B>>>13,B&=8191;let H=U+N*u+A*d+C*p+P*l+S*h;U=H>>>13,H&=8191,H+=O*c+T*a+k*o+x*(5*f)+R*(5*g),U+=H>>>13,H&=8191;let W=U+N*g+A*u+C*d+P*p+S*l;U=W>>>13,W&=8191,W+=O*h+T*c+k*a+x*o+R*(5*f),U+=W>>>13,W&=8191;let z=U+N*f+A*g+C*u+P*d+S*p;U=z>>>13,z&=8191,z+=O*l+T*h+k*c+x*a+R*o,U+=z>>>13,z&=8191,U=(U<<2)+U|0,U=U+D|0,D=8191&U,U>>>=13,j+=U,r[0]=D,r[1]=j,r[2]=M,r[3]=L,r[4]=q,r[5]=$,r[6]=B,r[7]=H,r[8]=W,r[9]=z}finalize(){const{h:e,pad:t}=this,s=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=i,i=e[t]>>>13,e[t]&=8191;e[0]+=5*i,i=e[0]>>>13,e[0]&=8191,e[1]+=i,i=e[1]>>>13,e[1]&=8191,e[2]+=i,s[0]=e[0]+5,i=s[0]>>>13,s[0]&=8191;for(let t=1;t<10;t++)s[t]=e[t]+i,i=s[t]>>>13,s[t]&=8191;s[9]-=8192;let r=(1^i)-1;for(let e=0;e<10;e++)s[e]&=r;r=~r;for(let t=0;t<10;t++)e[t]=e[t]&r|s[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let n=e[0]+t[0];e[0]=65535&n;for(let s=1;s<8;s++)n=(e[s]+t[s]|0)+(n>>>16)|0,e[s]=65535&n;pt(s)}update(e){rt(this);const{buffer:t,blockLen:s}=this,i=(e=at(e)).length;for(let r=0;r<i;){const n=Math.min(s-this.pos,i-r);if(n!==s)t.set(e.subarray(r,r+n),this.pos),this.pos+=n,r+=n,this.pos===s&&(this.process(t,0,!1),this.pos=0);else for(;s<=i-r;r+=s)this.process(e,r)}return this}destroy(){pt(this.h,this.r,this.buffer,this.pad)}digestInto(e){rt(this),function(e,t){it(e);const s=t.outputLen;if(e.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}(e,this),this.finished=!0;const{buffer:t,h:s}=this;let{pos:i}=this;if(i){for(t[i++]=1;i<16;i++)t[i]=0;this.process(t,0,!0)}this.finalize();let r=0;for(let t=0;t<8;t++)e[r++]=s[t]>>>0,e[r++]=s[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}}const _t=function(e){const t=(t,s)=>e(s).update(at(t)).digest(),s=e(new Uint8Array(32));return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=t=>e(t),t}(e=>new It(e)),Nt=function(e){const{allowShortKeys:t,extendNonceFn:s,counterLength:i,counterRight:r,rounds:n}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t)}(0,{counterRight:!1,counterLength:4,allowShortKeys:!1});return tt(i),tt(n),nt(r),nt(t),(o,a,c,h,l=0)=>{it(o),it(a),it(c);const p=c.length;if(void 0===h&&(h=new Uint8Array(p)),it(h),tt(l),l<0||l>=bt)throw new Error("arx: counter overflow");if(h.length<p)throw new Error(`arx: output (${h.length}) is shorter than data (${p})`);const d=[];let u,g,f=o.length;if(32===f)d.push(u=lt(o)),g=mt;else{if(16!==f||!t)throw new Error(`arx: invalid 32-byte key, got length=${f}`);u=new Uint8Array(32),u.set(o),u.set(o,16),g=ft,d.push(u)}yt(a)||d.push(a=lt(a));const m=ot(u);if(s){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");s(g,m,ot(a.subarray(0,16)),m),a=a.subarray(16)}const w=16-i;if(w!==a.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(12!==w){const e=new Uint8Array(12);e.set(a,r?0:12-a.length),a=e,d.push(a)}const y=ot(a);return function(e,t,s,i,r,n,o,a){const c=r.length,h=new Uint8Array(64),l=ot(h),p=yt(r)&&yt(n),d=p?ot(r):vt,u=p?ot(n):vt;for(let g=0;g<c;o++){if(e(t,s,i,l,o,a),o>=bt)throw new Error("arx: counter overflow");const f=Math.min(64,c-g);if(p&&64===f){const e=g/4;if(g%4!=0)throw new Error("arx: invalid block position");for(let t,s=0;s<16;s++)t=e+s,u[t]=d[t]^l[s];g+=64;continue}for(let e,t=0;t<f;t++)e=g+t,n[e]=r[e]^h[t];g+=f}}(e,g,m,y,c,h,l,n),pt(...d),h}}(function(e,t,s,i,r,n=20){let o=e[0],a=e[1],c=e[2],h=e[3],l=t[0],p=t[1],d=t[2],u=t[3],g=t[4],f=t[5],m=t[6],w=t[7],y=r,b=s[0],v=s[1],E=s[2],I=o,_=a,N=c,A=h,C=l,P=p,S=d,O=u,T=g,k=f,x=m,R=w,U=y,D=b,j=v,M=E;for(let e=0;e<n;e+=2)I=I+C|0,U=wt(U^I,16),T=T+U|0,C=wt(C^T,12),I=I+C|0,U=wt(U^I,8),T=T+U|0,C=wt(C^T,7),_=_+P|0,D=wt(D^_,16),k=k+D|0,P=wt(P^k,12),_=_+P|0,D=wt(D^_,8),k=k+D|0,P=wt(P^k,7),N=N+S|0,j=wt(j^N,16),x=x+j|0,S=wt(S^x,12),N=N+S|0,j=wt(j^N,8),x=x+j|0,S=wt(S^x,7),A=A+O|0,M=wt(M^A,16),R=R+M|0,O=wt(O^R,12),A=A+O|0,M=wt(M^A,8),R=R+M|0,O=wt(O^R,7),I=I+P|0,M=wt(M^I,16),x=x+M|0,P=wt(P^x,12),I=I+P|0,M=wt(M^I,8),x=x+M|0,P=wt(P^x,7),_=_+S|0,U=wt(U^_,16),R=R+U|0,S=wt(S^R,12),_=_+S|0,U=wt(U^_,8),R=R+U|0,S=wt(S^R,7),N=N+O|0,D=wt(D^N,16),T=T+D|0,O=wt(O^T,12),N=N+O|0,D=wt(D^N,8),T=T+D|0,O=wt(O^T,7),A=A+C|0,j=wt(j^A,16),k=k+j|0,C=wt(C^k,12),A=A+C|0,j=wt(j^A,8),k=k+j|0,C=wt(C^k,7);let L=0;i[L++]=o+I|0,i[L++]=a+_|0,i[L++]=c+N|0,i[L++]=h+A|0,i[L++]=l+C|0,i[L++]=p+P|0,i[L++]=d+S|0,i[L++]=u+O|0,i[L++]=g+T|0,i[L++]=f+k|0,i[L++]=m+x|0,i[L++]=w+R|0,i[L++]=y+U|0,i[L++]=b+D|0,i[L++]=v+j|0,i[L++]=E+M|0}),At=new Uint8Array(16),Ct=(e,t)=>{e.update(t);const s=t.length%16;s&&e.update(At.subarray(s))},Pt=new Uint8Array(32);function St(e,t,s,i,r){const n=e(t,s,Pt),o=_t.create(n);r&&Ct(o,r),Ct(o,i);const a=new Uint8Array(16),c=(e=>new DataView(e.buffer,e.byteOffset,e.byteLength))(a);ht(c,0,BigInt(r?r.length:0),!0),ht(c,8,BigInt(i.length),!0),o.update(a);const h=o.digest();return pt(n,a),h}const Ot=((e,t)=>{function s(s,...i){if(it(s),void 0!==e.nonceLength){const t=i[0];if(!t)throw new Error("nonce / iv required");e.varSizeNonce?it(t):it(t,e.nonceLength)}const r=e.tagLength;r&&void 0!==i[1]&&it(i[1]);const n=t(s,...i),o=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");it(t)}};let a=!1;return{encrypt(e,t){if(a)throw new Error("cannot encrypt() twice with same key + nonce");return a=!0,it(e),o(n.encrypt.length,t),n.encrypt(e,t)},decrypt(e,t){if(it(e),r&&e.length<r)throw new Error("invalid ciphertext length: smaller than tagLength="+r);return o(n.decrypt.length,t),n.decrypt(e,t)}}}return Object.assign(s,e),s})({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,s,i)=>({encrypt(r,n){const o=r.length;(n=ct(o+16,n,!1)).set(r);const a=n.subarray(0,-16);e(t,s,a,a,1);const c=St(e,t,s,a,i);return n.set(c,o),pt(c),n},decrypt(r,n){n=ct(r.length-16,n,!1);const o=r.subarray(0,-16),a=r.subarray(-16),c=St(e,t,s,o,i);if(!function(e,t){if(e.length!==t.length)return!1;let s=0;for(let i=0;i<e.length;i++)s|=e[i]^t[i];return 0===s}(a,c))throw new Error("invalid tag");return n.set(r.subarray(0,-16)),e(t,s,n,n,1),pt(c),n}}))(Nt));class Tt extends de{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Z(e);const s=pe(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const i=this.blockLen,r=new Uint8Array(i);r.set(s.length>i?e.create().update(s).digest():s);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),r.fill(0)}update(e){return ee(this),this.iHash.update(e),this}digestInto(e){ee(this),X(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:s,finished:i,destroyed:r,blockLen:n,outputLen:o}=this;return e.finished=i,e.destroyed=r,e.blockLen=n,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=s._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const kt=(e,t,s)=>new Tt(e,t).update(s).digest();kt.create=(e,t)=>new Tt(e,t);const xt=new Uint8Array([0]),Rt=new Uint8Array,Ut=(e,t,s,i,r)=>function(e,t,s,i=32){if(Z(e),Q(i),i>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const r=Math.ceil(i/e.outputLen);void 0===s&&(s=Rt);const n=new Uint8Array(r*e.outputLen),o=kt.create(e,t),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let t=0;t<r;t++)xt[0]=t+1,a.update(0===t?Rt:c).update(s).update(xt).digestInto(c),n.set(c,e.outputLen*t),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),xt.fill(0),n.slice(0,i)}(e,function(e,t,s){return Z(e),void 0===s&&(s=new Uint8Array(e.outputLen)),kt(e,pe(s),pe(t))}(e,t,s),i,r);function Dt(e,t,s){return e&t^~e&s}function jt(e,t,s){return e&t^e&s^t&s}class Mt extends de{constructor(e,t,s,i){super(),this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=oe(this.buffer)}update(e){ee(this);const{view:t,buffer:s,blockLen:i}=this,r=(e=pe(e)).length;for(let n=0;n<r;){const o=Math.min(i-this.pos,r-n);if(o===i){const t=oe(e);for(;i<=r-n;n+=i)this.process(t,n);continue}s.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ee(this),te(e,this),this.finished=!0;const{buffer:t,view:s,blockLen:i,isLE:r}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>i-n&&(this.process(s,0),n=0);for(let e=n;e<i;e++)t[e]=0;(function(e,t,s,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,s,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(s>>r&n),a=Number(s&n),c=i?4:0,h=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+h,a,i)})(s,i-8,BigInt(8*this.length),r),this.process(s,0);const o=oe(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,h[e],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:s,length:i,finished:r,destroyed:n,pos:o}=this;return e.length=i,e.pos=o,e.finished=r,e.destroyed=n,i%t&&e.buffer.set(s),e}}const Lt=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),qt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),$t=new Uint32Array(64);class Bt extends Mt{constructor(){super(64,32,8,!1),this.A=0|qt[0],this.B=0|qt[1],this.C=0|qt[2],this.D=0|qt[3],this.E=0|qt[4],this.F=0|qt[5],this.G=0|qt[6],this.H=0|qt[7]}get(){const{A:e,B:t,C:s,D:i,E:r,F:n,G:o,H:a}=this;return[e,t,s,i,r,n,o,a]}set(e,t,s,i,r,n,o,a){this.A=0|e,this.B=0|t,this.C=0|s,this.D=0|i,this.E=0|r,this.F=0|n,this.G=0|o,this.H=0|a}process(e,t){for(let s=0;s<16;s++,t+=4)$t[s]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=$t[e-15],s=$t[e-2],i=ae(t,7)^ae(t,18)^t>>>3,r=ae(s,17)^ae(s,19)^s>>>10;$t[e]=r+$t[e-7]+i+$t[e-16]|0}let{A:s,B:i,C:r,D:n,E:o,F:a,G:c,H:h}=this;for(let e=0;e<64;e++){const t=h+(ae(o,6)^ae(o,11)^ae(o,25))+Dt(o,a,c)+Lt[e]+$t[e]|0,l=(ae(s,2)^ae(s,13)^ae(s,22))+jt(s,i,r)|0;h=c,c=a,a=o,o=n+t|0,n=r,r=i,i=s,s=t+l|0}s=s+this.A|0,i=i+this.B|0,r=r+this.C|0,n=n+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(s,i,r,n,o,a,c,h)}roundClean(){$t.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Ht=ue(()=>new Bt),Wt=BigInt(0);function zt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Vt(e){if(!zt(e))throw new Error("Uint8Array expected")}const Ft=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Kt(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function Gt(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,s=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(s);for(let t=0,r=0;t<s;t++,r+=2){const s=Kt(e.charCodeAt(r)),n=Kt(e.charCodeAt(r+1));if(void 0===s||void 0===n){const t=e[r]+e[r+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+r)}i[t]=16*s+n}return i}function Jt(e){return Vt(e),function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?Wt:BigInt("0x"+e)}(function(e){Vt(e);let t="";for(let s=0;s<e.length;s++)t+=Ft[e[s]];return t}(Uint8Array.from(e).reverse()))}function Yt(e,t,s){let i;if("string"==typeof t)try{i=Gt(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!zt(t))throw new Error(e+" must be hex string or Uint8Array");i=Uint8Array.from(t)}const r=i.length;if("number"==typeof s&&r!==s)throw new Error(e+" of length "+s+" expected, got "+r);return i}const Qt=e=>"bigint"==typeof e&&Wt<=e;function Xt(e,t,s,i){if(!function(e,t,s){return Qt(e)&&Qt(t)&&Qt(s)&&t<=e&&e<s}(t,s,i))throw new Error("expected valid "+e+": "+s+" <= n < "+i+", got "+t)}const Zt={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||zt(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)},es=BigInt(0),ts=BigInt(1);function ss(e,t){const s=e%t;return s>=es?s:t+s}function is(e,t,s){let i=e;for(;t-- >es;)i*=i,i%=s;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const rs=BigInt(0),ns=BigInt(1);const os=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const as=BigInt(1),cs=BigInt(2),hs=BigInt(3),ls=BigInt(5);BigInt(8);const ps=function(e){const t=function(e){return function(e,t,s={}){const i=(t,s,i)=>{const r=Zt[s];if("function"!=typeof r)throw new Error("invalid validator function");const n=e[t];if(!(i&&void 0===n||r(n,e)))throw new Error("param "+String(t)+" is invalid. Expected "+s+", got "+n)};for(const[e,s]of Object.entries(t))i(e,s,!1);for(const[e,t]of Object.entries(s))i(e,t,!0)}(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:s}=t,i=e=>ss(e,s),r=t.montgomeryBits,n=Math.ceil(r/8),o=t.nByteLength,a=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>function(e,t,s){if(t<es)throw new Error("invalid exponent, negatives unsupported");if(s<=es)throw new Error("invalid modulus");if(s===ts)return es;let i=ts;for(;t>es;)t&ts&&(i=i*e%s),e=e*e%s,t>>=ts;return i}(e,s-BigInt(2),s));function h(e,t,s){const r=i(e*(t-s));return[t=i(t-r),s=i(s+r)]}const l=(t.a-BigInt(2))/BigInt(4);function p(e){return function(e,t){return function(e,t){return Gt(e.toString(16).padStart(2*t,"0"))}(e,t).reverse()}(i(e),n)}function d(e,t){const d=function(e){const t=Yt("u coordinate",e,n);return 32===o&&(t[31]&=127),Jt(t)}(t),u=function(e){const t=Yt("scalar",e),s=t.length;if(s!==n&&s!==o)throw new Error("invalid scalar, expected "+n+" or "+o+" bytes, got "+s);return Jt(a(t))}(e),g=function(e,t){Xt("u",e,rs,s),Xt("scalar",t,rs,s);const n=t,o=e;let a,p=ns,d=rs,u=e,g=ns,f=rs;for(let e=BigInt(r-1);e>=rs;e--){const t=n>>e&ns;f^=t,a=h(f,p,u),p=a[0],u=a[1],a=h(f,d,g),d=a[0],g=a[1],f=t;const s=p+d,r=i(s*s),c=p-d,m=i(c*c),w=r-m,y=u+g,b=i((u-g)*s),v=i(y*c),E=b+v,I=b-v;u=i(E*E),g=i(o*i(I*I)),p=i(r*m),d=i(w*(r+i(l*w)))}a=h(f,p,u),p=a[0],u=a[1],a=h(f,d,g),d=a[0],g=a[1];const m=c(d);return i(p*m)}(d,u);if(g===rs)throw new Error("invalid private or public key received");return p(g)}const u=p(t.Gu);function g(e){return d(e,u)}return{scalarMult:d,scalarMultBase:g,getSharedSecret:(e,t)=>d(e,t),getPublicKey:e=>g(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:u}}({P:os,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=os,{pow_p_5_8:s,b2:i}=function(e){const t=BigInt(10),s=BigInt(20),i=BigInt(40),r=BigInt(80),n=os,o=e*e%n*e%n,a=is(o,cs,n)*o%n,c=is(a,as,n)*e%n,h=is(c,ls,n)*c%n,l=is(h,t,n)*h%n,p=is(l,s,n)*l%n,d=is(p,i,n)*p%n,u=is(d,r,n)*d%n,g=is(u,r,n)*d%n,f=is(g,t,n)*h%n;return{pow_p_5_8:is(f,cs,n)*e%n,b2:o}}(e);return ss(is(s,hs,t)*i,t)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},randomBytes:ge}),ds="base10",us="base16",gs="base64pad",fs="base64url",ms="utf8",ws=0,ys=1,bs=2,vs=0,Es=1,Is=12,_s=32;function Ns(){const e=ps.utils.randomPrivateKey(),t=ps.getPublicKey(e);return{privateKey:(0,h.dI)(e,us),publicKey:(0,h.dI)(t,us)}}function As(){const e=ge(_s);return(0,h.dI)(e,us)}function Cs(e,t){const s=ps.getSharedSecret((0,h.sH)(e,us),(0,h.sH)(t,us)),i=Ut(Ht,s,void 0,void 0,_s);return(0,h.dI)(i,us)}function Ps(e){const t=Ht((0,h.sH)(e,us));return(0,h.dI)(t,us)}function Ss(e){const t=Ht((0,h.sH)(e,ms));return(0,h.dI)(t,us)}function Os(e){return(0,h.sH)(`${e}`,ds)}function Ts(e){return Number((0,h.dI)(e,ds))}function ks(e){const t=Os(typeof e.type<"u"?e.type:ws);if(Ts(t)===ys&&typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const s=typeof e.senderPublicKey<"u"?(0,h.sH)(e.senderPublicKey,us):void 0,i=typeof e.iv<"u"?(0,h.sH)(e.iv,us):ge(Is),r=(0,h.sH)(e.symKey,us);return Ds({type:t,sealed:Ot(r,i).encrypt((0,h.sH)(e.message,ms)),iv:i,senderPublicKey:s,encoding:e.encoding})}function xs(e){const t=(0,h.sH)(e.symKey,us),{sealed:s,iv:i}=js(e),r=Ot(t,i).decrypt(s);if(null===r)throw new Error("Failed to decrypt");return(0,h.dI)(r,ms)}function Rs(e,t){const s=Os(bs),i=ge(Is);return Ds({type:s,sealed:(0,h.sH)(e,ms),iv:i,encoding:t})}function Us(e,t){const{sealed:s}=js({encoded:e,encoding:t});return(0,h.dI)(s,ms)}function Ds(e){const{encoding:t=gs}=e;if(Ts(e.type)===bs)return(0,h.dI)((0,h.xW)([e.type,e.sealed]),t);if(Ts(e.type)===ys){if(typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return(0,h.dI)((0,h.xW)([e.type,e.senderPublicKey,e.iv,e.sealed]),t)}return(0,h.dI)((0,h.xW)([e.type,e.iv,e.sealed]),t)}function js(e){const{encoded:t,encoding:s=gs}=e,i=(0,h.sH)(t,s),r=i.slice(vs,Es),n=Es;if(Ts(r)===ys){const e=n+_s,t=e+Is,s=i.slice(n,e),o=i.slice(e,t);return{type:r,sealed:i.slice(t),iv:o,senderPublicKey:s}}if(Ts(r)===bs)return{type:r,sealed:i.slice(n),iv:ge(Is)};const o=n+Is,a=i.slice(n,o);return{type:r,sealed:i.slice(o),iv:a}}function Ms(e,t){const s=js({encoded:e,encoding:t?.encoding});return Ls({type:Ts(s.type),senderPublicKey:typeof s.senderPublicKey<"u"?(0,h.dI)(s.senderPublicKey,us):void 0,receiverPublicKey:t?.receiverPublicKey})}function Ls(e){const t=e?.type||ws;if(t===ys){if(typeof e?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function qs(e){return e.type===ys&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}function $s(e){return e.type===bs}function Bs(e,t){const[s,i,r]=e.split("."),n=function(e){return u.from(function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const s=t.length%4;return s>0&&(t+="=".repeat(4-s)),t}(e),"base64")}(r);if(64!==n.length)throw new Error("Invalid signature length");const o=n.slice(0,32).toString("hex"),a=n.slice(32,64).toString("hex"),p=Ht(`${s}.${i}`),d=function(e){return new l.ec("p256").keyFromPublic({x:u.from(e.x,"base64").toString("hex"),y:u.from(e.y,"base64").toString("hex")},"hex")}(t),g=(0,h.dI)(p,us);if(!d.verify(g,{r:o,s:a}))throw new Error("Invalid signature");return(0,c.Cq)(e).payload}const Hs="irn";function Ws(e){return e?.relay||{protocol:Hs}}function zs(e){const t=p.CG[e];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${e}`);return t}function Vs(e,t="-"){const s={},i="relay"+t;return Object.keys(e).forEach(t=>{if(t.startsWith(i)){const r=t.replace(i,""),n=e[t];s[r]=n}}),s}function Fs(e){if(!e.includes("wc:")){const t=J(e);null!=t&&t.includes("wc:")&&(e=t)}const t=(e=(e=e.includes("wc://")?e.replace("wc://",""):e).includes("wc:")?e.replace("wc:",""):e).indexOf(":"),s=-1!==e.indexOf("?")?e.indexOf("?"):void 0,i=e.substring(0,t),r=e.substring(t+1,s).split("@"),n=typeof s<"u"?e.substring(s):"",o=new URLSearchParams(n),a={};o.forEach((e,t)=>{a[t]=e});const c="string"==typeof a.methods?a.methods.split(","):void 0;return{protocol:i,topic:Ks(r[0]),version:parseInt(r[1],10),symKey:a.symKey,relay:Vs(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function Ks(e){return e.startsWith("//")?e.substring(2):e}function Gs(e){const t=new URLSearchParams,s=function(e,t="-"){const s={};return Object.keys(e).forEach(i=>{const r=i,n="relay"+t+r;e[r]&&(s[n]=e[r])}),s}(e.relay);Object.keys(s).sort().forEach(e=>{t.set(e,s[e])}),t.set("symKey",e.symKey),e.expiryTimestamp&&t.set("expiryTimestamp",e.expiryTimestamp.toString()),e.methods&&t.set("methods",e.methods.join(","));const i=t.toString();return`${e.protocol}:${e.topic}@${e.version}?${i}`}function Js(e,t,s){return`${e}?wc_ev=${s}&topic=${t}`}function Ys(e){const t=[];return e.forEach(e=>{const[s,i]=e.split(":");t.push(`${s}:${i}`)}),t}function Qs(e){return e.includes(":")}function Xs(e){return Qs(e)?e.split(":")[0]:e}function Zs(e,t){const s=function(e){const t={};return e?.forEach(e=>{var s;const[i,r]=e.split(":");t[i]||(t[i]={accounts:[],chains:[],events:[],methods:[]}),t[i].accounts.push(e),null==(s=t[i].chains)||s.push(`${i}:${r}`)}),t}(t=t.map(e=>e.replace("did:pkh:","")));for(const[t,i]of Object.entries(s))i.methods?i.methods=W(i.methods,e):i.methods=e,i.events=["chainChanged","accountsChanged"];return s}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const ei={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},ti={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function si(e,t){const{message:s,code:i}=ti[e];return{message:t?`${s} ${t}`:s,code:i}}function ii(e,t){const{message:s,code:i}=ei[e];return{message:t?`${s} ${t}`:s,code:i}}function ri(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function ni(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function oi(e){return typeof e>"u"}function ai(e,t){return!(!t||!oi(e))||"string"==typeof e&&!!e.trim().length}function ci(e,t){return!(!t||!oi(e))||"number"==typeof e&&!isNaN(e)}function hi(e,t){const{requiredNamespaces:s}=t,i=Object.keys(e.namespaces),r=Object.keys(s);let n=!0;return!!k(r,i)&&(i.forEach(t=>{const{accounts:i,methods:r,events:o}=e.namespaces[t],a=Ys(i),c=s[t];k(w(t,c),a)&&k(c.methods,r)&&k(c.events,o)||(n=!1)}),n)}function li(e){return!(!ai(e,!1)||!e.includes(":"))&&2===e.split(":").length}function pi(e){function t(e){try{return typeof new URL(e)<"u"}catch{return!1}}try{if(ai(e,!1))return!!t(e)||t(J(e))}catch{}return!1}function di(e){var t;return null==(t=e?.proposer)?void 0:t.publicKey}function ui(e){return e?.topic}function gi(e,t){let s=null;return ai(e?.publicKey,!1)||(s=si("MISSING_OR_INVALID",`${t} controller public key should be a string`)),s}function fi(e){let t=!0;return ri(e)?e.length&&(t=e.every(e=>ai(e,!1))):t=!1,t}function mi(e,t){let s=null;return Object.values(e).forEach(e=>{if(s)return;const i=function(e,t){let s=null;return fi(e?.methods)?fi(e?.events)||(s=ii("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):s=ii("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),s}(e,`${t}, namespace`);i&&(s=i)}),s}function wi(e,t,s){let i=null;if(e&&ni(e)){const r=mi(e,t);r&&(i=r);const n=function(e,t,s){let i=null;return Object.entries(e).forEach(([e,r])=>{if(i)return;const n=function(e,t,s){let i=null;return ri(t)&&t.length?t.forEach(e=>{i||li(e)||(i=ii("UNSUPPORTED_CHAINS",`${s}, chain ${e} should be a string and conform to "namespace:chainId" format`))}):li(e)||(i=ii("UNSUPPORTED_CHAINS",`${s}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}(e,w(e,r),`${t} ${s}`);n&&(i=n)}),i}(e,t,s);n&&(i=n)}else i=si("MISSING_OR_INVALID",`${t}, ${s} should be an object with data`);return i}function yi(e,t){let s=null;if(e&&ni(e)){const i=mi(e,t);i&&(s=i);const r=function(e,t){let s=null;return Object.values(e).forEach(e=>{if(s)return;const i=function(e,t){let s=null;return ri(e)?e.forEach(e=>{s||function(e){if(ai(e,!1)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&li(e)}}return!1}(e)||(s=ii("UNSUPPORTED_ACCOUNTS",`${t}, account ${e} should be a string and conform to "namespace:chainId:address" format`))}):s=ii("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),s}(e?.accounts,`${t} namespace`);i&&(s=i)}),s}(e,t);r&&(s=r)}else s=si("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return s}function bi(e){return ai(e.protocol,!0)}function vi(e,t){let s=!1;return t&&!e?s=!0:e&&ri(e)&&e.length&&e.forEach(e=>{s=bi(e)}),s}function Ei(e){return"number"==typeof e}function Ii(e){return typeof e<"u"&&null!==typeof e}function _i(e){return!!(e&&"object"==typeof e&&e.code&&ci(e.code,!1)&&e.message&&ai(e.message,!1))}function Ni(e){return!(oi(e)||!ai(e.method,!1))}function Ai(e){return!(oi(e)||oi(e.result)&&oi(e.error)||!ci(e.id,!1)||!ai(e.jsonrpc,!1))}function Ci(e){return!(oi(e)||!ai(e.name,!1))}function Pi(e,t){return!(!li(t)||!function(e){const t=[];return Object.values(e).forEach(e=>{t.push(...Ys(e.accounts))}),t}(e).includes(t))}function Si(e,t,s){return!!ai(s,!1)&&function(e,t){const s=[];return Object.values(e).forEach(e=>{Ys(e.accounts).includes(t)&&s.push(...e.methods)}),s}(e,t).includes(s)}function Oi(e,t,s){return!!ai(s,!1)&&function(e,t){const s=[];return Object.values(e).forEach(e=>{Ys(e.accounts).includes(t)&&s.push(...e.events)}),s}(e,t).includes(s)}function Ti(e,t,s){let i=null;const r=function(e){const t={};return Object.keys(e).forEach(s=>{var i;s.includes(":")?t[s]=e[s]:null==(i=e[s].chains)||i.forEach(i=>{t[i]={methods:e[s].methods,events:e[s].events}})}),t}(e),n=function(e){const t={};return Object.keys(e).forEach(s=>{if(s.includes(":"))t[s]=e[s];else{const i=Ys(e[s].accounts);i?.forEach(i=>{t[i]={accounts:e[s].accounts.filter(e=>e.includes(`${i}:`)),methods:e[s].methods,events:e[s].events}})}}),t}(t),o=Object.keys(r),a=Object.keys(n),c=ki(Object.keys(e)),h=ki(Object.keys(t)),l=c.filter(e=>!h.includes(e));return l.length&&(i=si("NON_CONFORMING_NAMESPACES",`${s} namespaces keys don't satisfy requiredNamespaces.\n Required: ${l.toString()}\n Received: ${Object.keys(t).toString()}`)),k(o,a)||(i=si("NON_CONFORMING_NAMESPACES",`${s} namespaces chains don't satisfy required namespaces.\n Required: ${o.toString()}\n Approved: ${a.toString()}`)),Object.keys(t).forEach(e=>{if(!e.includes(":")||i)return;const r=Ys(t[e].accounts);r.includes(e)||(i=si("NON_CONFORMING_NAMESPACES",`${s} namespaces accounts don't satisfy namespace accounts for ${e}\n Required: ${e}\n Approved: ${r.toString()}`))}),o.forEach(e=>{i||(k(r[e].methods,n[e].methods)?k(r[e].events,n[e].events)||(i=si("NON_CONFORMING_NAMESPACES",`${s} namespaces events don't satisfy namespace events for ${e}`)):i=si("NON_CONFORMING_NAMESPACES",`${s} namespaces methods don't satisfy namespace methods for ${e}`))}),i}function ki(e){return[...new Set(e.map(e=>e.includes(":")?e.split(":")[0]:e))]}function xi(e,t){return ci(e,!1)&&e<=t.max&&e>=t.min}function Ri(){const e=C();return new Promise(t=>{switch(e){case b.browser:t(A()&&navigator?.onLine);break;case b.reactNative:t(async function(){if(I()&&typeof s.g<"u"&&null!=s.g&&s.g.NetInfo){const e=await(null==s.g?void 0:s.g.NetInfo.fetch());return e?.isConnected}return!0}());break;case b.node:default:t(!0)}})}function Ui(e){switch(C()){case b.browser:!function(e){!I()&&A()&&(window.addEventListener("online",()=>e(!0)),window.addEventListener("offline",()=>e(!1)))}(e);break;case b.reactNative:!function(e){I()&&typeof s.g<"u"&&null!=s.g&&s.g.NetInfo&&s.g?.NetInfo.addEventListener(t=>e(t?.isConnected))}(e);case b.node:}}const Di={};class ji{static get(e){return Di[e]}static set(e,t){Di[e]=t}static delete(e){delete Di[e]}}},78760:(e,t,s)=>{s.d(t,{p:()=>r});const i=2147483648,r={convertEVMChainIdToCoinType(e){if(e>=i)throw new Error("Invalid chainId");return(i|e)>>>0}}},79473:(e,t,s)=>{s.d(t,{A:()=>a});var i=s(89168),r=s(39150);const n={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0},o=(0,i.BX)({providers:{...n},providerIds:{...n}}),a={state:o,subscribeKey:(e,t)=>(0,r.u$)(o,e,t),subscribe:e=>(0,i.B1)(o,()=>{e(o)}),subscribeProviders:e=>(0,i.B1)(o.providers,()=>e(o.providers)),setProvider(e,t){t&&(o.providers[e]=(0,i.KR)(t))},getProvider:e=>o.providers[e],setProviderId(e,t){t&&(o.providerIds[e]=t)},getProviderId(e){if(e)return o.providerIds[e]},reset(){o.providers={...n},o.providerIds={...n}},resetChain(e){o.providers[e]=void 0,o.providerIds[e]=void 0}}},84253:(e,t,s)=>{s.d(t,{oU:()=>n});var i=s(39907);const r=(void 0!==i&&void 0!==i.env?i.env.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",n={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,FIVE_SEC_MS:5e3,THREE_SEC_MS:3e3,ONE_SEC_MS:1e3,SECURE_SITE:r,SECURE_SITE_DASHBOARD:`${r}/dashboard`,SECURE_SITE_FAVICON:`${r}/images/favicon.png`,RESTRICTED_TIMEZONES:["ASIA/SHANGHAI","ASIA/URUMQI","ASIA/CHONGQING","ASIA/HARBIN","ASIA/KASHGAR","ASIA/MACAU","ASIA/HONG_KONG","ASIA/MACAO","ASIA/BEIJING","ASIA/HARBIN"],WC_COINBASE_PAY_SDK_CHAINS:["ethereum","arbitrum","polygon","berachain","avalanche-c-chain","optimism","celo","base"],WC_COINBASE_PAY_SDK_FALLBACK_CHAIN:"ethereum",WC_COINBASE_PAY_SDK_CHAIN_NAME_MAP:{Ethereum:"ethereum","Arbitrum One":"arbitrum",Polygon:"polygon",Berachain:"berachain",Avalanche:"avalanche-c-chain","OP Mainnet":"optimism",Celo:"celo",Base:"base"},WC_COINBASE_ONRAMP_APP_ID:"bf18c88d-495a-463b-b249-0b9d3656cf5e",SWAP_SUGGESTED_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP"],SWAP_POPULAR_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP","METAL","DAI","CHAMP","WOLF","SALE","BAL","BUSD","MUST","BTCpx","ROUTE","HEX","WELT","amDAI","VSQ","VISION","AURUM","pSP","SNX","VC","LINK","CHP","amUSDT","SPHERE","FOX","GIDDY","GFC","OMEN","OX_OLD","DE","WNT"],BALANCE_SUPPORTED_CHAINS:["eip155","solana"],SWAP_SUPPORTED_NETWORKS:["eip155:1","eip155:42161","eip155:10","eip155:324","eip155:8453","eip155:56","eip155:137","eip155:100","eip155:43114","eip155:250","eip155:8217","eip155:1313161554"],NAMES_SUPPORTED_CHAIN_NAMESPACES:["eip155"],ONRAMP_SUPPORTED_CHAIN_NAMESPACES:["eip155","solana"],ACTIVITY_ENABLED_CHAIN_NAMESPACES:["eip155","solana"],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in a new browser tab"},DEFAULT_FEATURES:{swaps:!0,onramp:!0,receive:!0,send:!0,email:!0,emailShowWallets:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],history:!0,analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0},DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",BITCOIN:"bitcoin"}}},84320:(e,t,s)=>{s.d(t,{r:()=>i});class i extends Error{constructor(){super(),Object.setPrototypeOf(this,i.prototype)}}},85445:(e,t,s)=>{s.d(t,{K:()=>i});class i extends Error{constructor(){super("QR Code Modal was closed by user"),Object.setPrototypeOf(this,i.prototype),this.name="QRCodeModalError"}}},86808:(e,t,s)=>{s.d(t,{kl:()=>i.k}),s(24529);var i=s(69033)},87201:(e,t,s)=>{s.d(t,{WalletConnectWalletAdapter:()=>h});var i=s(80110),r=s(53834),n=s(68559),o=s(13324),a=s(96759),c=s(66715);class h extends n.Kl{name="WalletConnect";url="https://walletconnect.org";icon="data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4NSIgdmlld0JveD0iMCAwIDMwMCAxODUiIHdpZHRoPSIzMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTYxLjQzODU0MjkgMzYuMjU2MjYxMmM0OC45MTEyMjQxLTQ3Ljg4ODE2NjMgMTI4LjIxMTk4NzEtNDcuODg4MTY2MyAxNzcuMTIzMjA5MSAwbDUuODg2NTQ1IDUuNzYzNDE3NGMyLjQ0NTU2MSAyLjM5NDQwODEgMi40NDU1NjEgNi4yNzY1MTEyIDAgOC42NzA5MjA0bC0yMC4xMzY2OTUgMTkuNzE1NTAzYy0xLjIyMjc4MSAxLjE5NzIwNTEtMy4yMDUzIDEuMTk3MjA1MS00LjQyODA4MSAwbC04LjEwMDU4NC03LjkzMTE0NzljLTM0LjEyMTY5Mi0zMy40MDc5ODE3LTg5LjQ0Mzg4Ni0zMy40MDc5ODE3LTEyMy41NjU1Nzg4IDBsLTguNjc1MDU2MiA4LjQ5MzYwNTFjLTEuMjIyNzgxNiAxLjE5NzIwNDEtMy4yMDUzMDEgMS4xOTcyMDQxLTQuNDI4MDgwNiAwbC0yMC4xMzY2OTQ5LTE5LjcxNTUwMzFjLTIuNDQ1NTYxMi0yLjM5NDQwOTItMi40NDU1NjEyLTYuMjc2NTEyMiAwLTguNjcwOTIwNHptMjE4Ljc2Nzc5NjEgNDAuNzczNzQ0OSAxNy45MjE2OTcgMTcuNTQ2ODk3YzIuNDQ1NTQ5IDIuMzk0Mzk2OSAyLjQ0NTU2MyA2LjI3NjQ3NjkuMDAwMDMxIDguNjcwODg5OWwtODAuODEwMTcxIDc5LjEyMTEzNGMtMi40NDU1NDQgMi4zOTQ0MjYtNi40MTA1ODIgMi4zOTQ0NTMtOC44NTYxNi4wMDAwNjItLjAwMDAxLS4wMDAwMS0uMDAwMDIyLS4wMDAwMjItLjAwMDAzMi0uMDAwMDMybC01Ny4zNTQxNDMtNTYuMTU0NTcyYy0uNjExMzktLjU5ODYwMi0xLjYwMjY1LS41OTg2MDItMi4yMTQwNCAwLS4wMDAwMDQuMDAwMDA0LS4wMDAwMDcuMDAwMDA4LS4wMDAwMTEuMDAwMDExbC01Ny4zNTI5MjEyIDU2LjE1NDUzMWMtMi40NDU1MzY4IDIuMzk0NDMyLTYuNDEwNTc1NSAyLjM5NDQ3Mi04Ljg1NjE2MTIuMDAwMDg3LS4wMDAwMTQzLS4wMDAwMTQtLjAwMDAyOTYtLjAwMDAyOC0uMDAwMDQ0OS0uMDAwMDQ0bC04MC44MTI0MTk0My03OS4xMjIxODVjLTIuNDQ1NTYwMjEtMi4zOTQ0MDgtMi40NDU1NjAyMS02LjI3NjUxMTUgMC04LjY3MDkxOTdsMTcuOTIxNzI5NjMtMTcuNTQ2ODY3M2MyLjQ0NTU2MDItMi4zOTQ0MDgyIDYuNDEwNTk4OS0yLjM5NDQwODIgOC44NTYxNjAyIDBsNTcuMzU0OTc3NSA1Ni4xNTUzNTdjLjYxMTM5MDguNTk4NjAyIDEuNjAyNjQ5LjU5ODYwMiAyLjIxNDAzOTggMCAuMDAwMDA5Mi0uMDAwMDA5LjAwMDAxNzQtLjAwMDAxNy4wMDAwMjY1LS4wMDAwMjRsNTcuMzUyMTAzMS01Ni4xNTUzMzNjMi40NDU1MDUtMi4zOTQ0NjMzIDYuNDEwNTQ0LTIuMzk0NTUzMSA4Ljg1NjE2MS0uMDAwMi4wMDAwMzQuMDAwMDMzNi4wMDAwNjguMDAwMDY3My4wMDAxMDEuMDAwMTAxbDU3LjM1NDkwMiA1Ni4xNTU0MzJjLjYxMTM5LjU5ODYwMSAxLjYwMjY1LjU5ODYwMSAyLjIxNDA0IDBsNTcuMzUzOTc1LTU2LjE1NDMyNDljMi40NDU1NjEtMi4zOTQ0MDkyIDYuNDEwNTk5LTIuMzk0NDA5MiA4Ljg1NjE2IDB6IiBmaWxsPSIjM2I5OWZjIi8+PC9zdmc+";supportedTransactionVersions=new Set(["legacy",0]);_publicKey;_connecting;_wallet;_config;_readyState;_onDisconnect;constructor(e){super(),this._publicKey=null,this._connecting=!1,this._config=e,this._wallet=null,this._readyState="undefined"==typeof window?i.Ok.Unsupported:i.Ok.Loadable,this._onDisconnect=this.disconnect.bind(this)}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==i.Ok.Loadable)throw new r.AE;this._connecting=!0,this._wallet=new c.f({network:this._config.network===o.B.Mainnet?a.aj.Mainnet:a.aj.Devnet,options:this._config.options});const{publicKey:e}=await this._wallet.connect();this._publicKey=e,this.emit("connect",e),this._wallet.client.on("session_delete",this._onDisconnect)}catch(e){if("QRCodeModalError"===e.constructor.name||e instanceof Error&&"QRCodeModalError"===e.name)throw new r.KL;throw this._connecting=!1,e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){e.client.off("session_delete",this._onDisconnect),this._publicKey=null;try{e.client.session&&await e.disconnect()}catch(e){console.error("WalletConnectWalletAdapter: disconnect error",e),this.emit("error",new r.Y8(e?.message,e))}}this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new r.kW;try{return await t.signTransaction(e)}catch(e){throw new r.z4(e?.message,e)}}catch(e){throw this.emit("error",e),e}}async signMessage(e){try{const t=this._wallet;if(!t)throw new r.kW;try{return await t.signMessage(e)}catch(e){throw new r.K3(e?.message,e)}}catch(e){throw this.emit("error",e),e}}async signAndSendTransaction(e){try{const t=this._wallet;if(!t)throw new r.kW;try{return await t.signAndSendTransaction(e)}catch(e){throw new r.z4(e?.message,e)}}catch(e){throw this.emit("error",e),e}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new r.kW;try{return await t.signAllTransactions(e)}catch(e){throw new r.z4(e?.message,e)}}catch(e){throw this.emit("error",e),e}}}},87841:(e,t,s)=>{s.d(t,{g:()=>o});var i=s(95191),r=s(99013),n=s(93927);function o(e){const t=Array.from(r.W.state.chains.keys());let s=[];return e?(s.push([e,r.W.state.chains.get(e)]),(0,n.Q)(e,i.o.CONNECTOR_ID.WALLET_CONNECT)?t.forEach(t=>{t!==e&&(0,n.Q)(t,i.o.CONNECTOR_ID.WALLET_CONNECT)&&s.push([t,r.W.state.chains.get(t)])}):(0,n.Q)(e,i.o.CONNECTOR_ID.AUTH)&&t.forEach(t=>{t!==e&&(0,n.Q)(t,i.o.CONNECTOR_ID.AUTH)&&s.push([t,r.W.state.chains.get(t)])})):s=Array.from(r.W.state.chains.entries()),s}},88315:(e,t,s)=>{s.d(t,{_:()=>h});var i=s(89058),r=s(50731),n=s(16158),o=s(5813),a=s(41977);let c=!1;class h extends a._{async open(e){r.a.isConnected()||await super.open(e)}async close(){await super.close(),this.options.manualWCControl&&i.x.finalizeWcConnection()}async syncIdentity(e){return Promise.resolve()}async syncBalance(e){return Promise.resolve()}async injectModalUi(){if(!c&&o.w.isClient()){if(await Promise.all([s.e(6484),s.e(4194),s.e(4379)]).then(s.bind(s,34379)),await Promise.all([s.e(4194),s.e(5972)]).then(s.bind(s,45972)),!document.querySelector("w3m-modal")){const e=document.createElement("w3m-modal");n.H.state.disableAppend||n.H.state.enableEmbedded||document.body.insertAdjacentElement("beforeend",e)}c=!0}}}},89058:(e,t,s)=>{s.d(t,{x:()=>m});var i=s(89168),r=s(39150),n=s(5813),o=s(24537),a=s(11553),c=s(99013),h=s(50731),l=s(14479),p=s(67018),d=s(42831),u=s(52059);const g=(0,i.BX)({wcError:!1,buffering:!1,status:"disconnected"});let f;const m={state:g,subscribeKey:(e,t)=>(0,r.u$)(g,e,t),_getClient:()=>g._client,setClient(e){g._client=(0,i.KR)(e)},async connectWalletConnect(){if(n.w.isTelegram()||n.w.isSafari()&&n.w.isIos()){if(f)return await f,void(f=void 0);if(!n.w.isPairingExpired(g?.wcPairingExpiry)){const e=g.wcUri;return void(g.wcUri=e)}f=this._getClient()?.connectWalletConnect?.().catch(()=>{}),this.state.status="connecting",await f,f=void 0,g.wcPairingExpiry=void 0,this.state.status="connected"}else await(this._getClient()?.connectWalletConnect?.())},async connectExternal(e,t,s=!0){await(this._getClient()?.connectExternal?.(e)),s&&c.W.setActiveNamespace(t)},async reconnectExternal(e){await(this._getClient()?.reconnectExternal?.(e));const t=e.chain||c.W.state.activeChain;t&&h.a.setConnectorId(e.id,t)},async setPreferredAccountType(e){p.W.setLoading(!0,c.W.state.activeChain);const t=h.a.getAuthConnector();t&&(await(t?.provider.setPreferredAccount(e)),await this.reconnectExternal(t),p.W.setLoading(!1,c.W.state.activeChain),l.E.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:e,network:c.W.state.activeCaipNetwork?.caipNetworkId||""}}))},async signMessage(e){return this._getClient()?.signMessage(e)},parseUnits(e,t){return this._getClient()?.parseUnits(e,t)},formatUnits(e,t){return this._getClient()?.formatUnits(e,t)},async sendTransaction(e){return this._getClient()?.sendTransaction(e)},async getCapabilities(e){return this._getClient()?.getCapabilities(e)},async grantPermissions(e){return this._getClient()?.grantPermissions(e)},async walletGetAssets(e){return this._getClient()?.walletGetAssets(e)??{}},async estimateGas(e){return this._getClient()?.estimateGas(e)},async writeContract(e){return this._getClient()?.writeContract(e)},async getEnsAddress(e){return this._getClient()?.getEnsAddress(e)},async getEnsAvatar(e){return this._getClient()?.getEnsAvatar(e)},checkInstalled(e){return this._getClient()?.checkInstalled?.(e)||!1},resetWcConnection(){g.wcUri=void 0,g.wcPairingExpiry=void 0,g.wcLinking=void 0,g.recentWallet=void 0,g.status="disconnected",u.W.resetTransactions(),a.i.deleteWalletConnectDeepLink()},resetUri(){g.wcUri=void 0,g.wcPairingExpiry=void 0},finalizeWcConnection(){const{wcLinking:e,recentWallet:t}=m.state;e&&a.i.setWalletConnectDeepLink(e),t&&a.i.setAppKitRecent(t),l.E.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:e?"mobile":"qrcode",name:d.I.state.data?.wallet?.name||"Unknown"}})},setWcBasic(e){g.wcBasic=e},setUri(e){g.wcUri=e,g.wcPairingExpiry=n.w.getPairingExpiry()},setWcLinking(e){g.wcLinking=e},setWcError(e){g.wcError=e,g.buffering=!1},setRecentWallet(e){g.recentWallet=e},setBuffering(e){g.buffering=e},setStatus(e){g.status=e},async disconnect(e){try{p.W.setLoading(!0,e),await o.U.clearSessions(),await c.W.disconnect(e),p.W.setLoading(!1,e),h.a.setFilterByNamespace(void 0)}catch(e){throw new Error("Failed to disconnect")}}}},89351:(e,t,s)=>{s.d(t,{hJ:()=>n,lC:()=>o});var i=s(96759);const r={mainnet:`You are using a deprecated chain ID for Solana Mainnet, please use ${i.ac.Mainnet} instead.`,devnet:`You are using a deprecated chain ID for Solana Devnet, please use ${i.ac.Devnet} instead.`,wallet:"The connected wallet is using a deprecated chain ID for Solana. Please, contact them to upgrade. You can learn more at https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip10.md#chain-ids"};function n(e,t){const s=e.namespaces.solana?.accounts.map(e=>`solana:${e.split(":")[1]}`);if(t===i.ac.Mainnet)return s?.find(e=>e===i.ac.Mainnet)?i.ac.Mainnet:(console.warn(r.wallet),i.ac.Deprecated_Mainnet);if(t===i.ac.Devnet)return s?.find(e=>e===i.ac.Devnet)?i.ac.Devnet:(console.warn(r.wallet),i.ac.Deprecated_Devnet);throw Error("WalletConnect Solana Adapter: Unable to get a default chain from the session.")}function o(e){const t=function(e){let t=[e];return e===i.ac.Mainnet||e===i.ac.Deprecated_Mainnet?(t=[i.ac.Mainnet,i.ac.Deprecated_Mainnet],e===i.ac.Deprecated_Mainnet&&console.warn(r.mainnet)):e!==i.ac.Deprecated_Devnet&&e!==i.ac.Devnet||(t=[i.ac.Devnet,i.ac.Deprecated_Devnet],i.ac.Deprecated_Devnet&&console.warn(r.devnet)),t}(e);return{optionalNamespaces:{solana:{chains:t,methods:[i.jD.signTransaction,i.jD.signMessage],events:[]}}}}},91310:(e,t,s)=>{s.d(t,{D:()=>n});var i=s(84253),r=s(5813);const n={getFeatureValue(e,t){const s=t?.[e];return void 0===s?i.oU.DEFAULT_FEATURES[e]:s},filterSocialsByPlatform(e){if(!e||!e.length)return e;if(r.w.isTelegram()){if(r.w.isIos())return e.filter(e=>"google"!==e);if(r.w.isMac())return e.filter(e=>"x"!==e);if(r.w.isAndroid())return e.filter(e=>!["facebook","x"].includes(e))}return e}}},93224:(e,t,s)=>{s.d(t,{$:()=>c});var i=s(89168),r=s(40868),n=s(12472);const o={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00"},a=(0,i.BX)({networkImagePromises:{}}),c={async fetchWalletImage(e){if(e)return await r.N._fetchWalletImage(e),this.getWalletImageById(e)},async fetchNetworkImage(e){if(!e)return;return this.getNetworkImageById(e)||(a.networkImagePromises[e]||(a.networkImagePromises[e]=r.N._fetchNetworkImage(e)),await a.networkImagePromises[e],this.getNetworkImageById(e))},getWalletImageById(e){if(e)return n.j.state.walletImages[e]},getWalletImage:e=>e?.image_url?e?.image_url:e?.image_id?n.j.state.walletImages[e.image_id]:void 0,getNetworkImage:e=>e?.assets?.imageUrl?e?.assets?.imageUrl:e?.assets?.imageId?n.j.state.networkImages[e.assets.imageId]:void 0,getNetworkImageById(e){if(e)return n.j.state.networkImages[e]},getConnectorImage:e=>e?.imageUrl?e.imageUrl:e?.imageId?n.j.state.connectorImages[e.imageId]:void 0,getChainImage:e=>n.j.state.networkImages[o[e]]}},93927:(e,t,s)=>{s.d(t,{Q:()=>r});var i=s(50731);function r(e,t){return i.a.getConnectorId(e)===t}},94768:(e,t,s)=>{s.d(t,{EM:()=>n.E,JX:()=>i.JX,RF:()=>i.RF,Zv:()=>r.Z,ds:()=>i.ds}),s(51493);var i=s(24210),r=s(63789),n=(s(72931),s(27305))},95191:(e,t,s)=>{s.d(t,{o:()=>i});const i={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"ID_AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122"},CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],HTTP_STATUS_CODES:{SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network"}},95642:(e,t,s)=>{var i=s(40149);(0,i.x)({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}}),(0,i.x)({id:"000000000933ea01ad0ee984209779ba",caipNetworkId:"bip122:000000000933ea01ad0ee984209779ba",chainNamespace:"bip122",name:"Bitcoin Testnet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},testnet:!0})},96759:(e,t,s)=>{var i,r;s.d(t,{ac:()=>n,aj:()=>i,jD:()=>r}),function(e){e.Mainnet="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",e.Devnet="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",e.Deprecated_Mainnet="solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",e.Deprecated_Devnet="solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"}(i||(i={})),function(e){e.signTransaction="solana_signTransaction",e.signMessage="solana_signMessage",e.signAndSendTransaction="solana_signAndSendTransaction",e.signAndSendAllTransactions="solana_signAndSendAllTransactions",e.signAllTransactions="solana_signAllTransactions"}(r||(r={}));const n={Mainnet:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",Devnet:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",Deprecated_Mainnet:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",Deprecated_Devnet:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"}},98207:(e,t,s)=>{s.d(t,{o:()=>i});const i={METMASK_CONNECTOR_NAME:"MetaMask",TRUST_CONNECTOR_NAME:"Trust Wallet",SOLFLARE_CONNECTOR_NAME:"Solflare",PHANTOM_CONNECTOR_NAME:"Phantom",COIN98_CONNECTOR_NAME:"Coin98",MAGIC_EDEN_CONNECTOR_NAME:"Magic Eden",BACKPACK_CONNECTOR_NAME:"Backpack",BITGET_CONNECTOR_NAME:"Bitget Wallet",FRONTIER_CONNECTOR_NAME:"Frontier",XVERSE_CONNECTOR_NAME:"Xverse Wallet",LEATHER_CONNECTOR_NAME:"Leather",EIP155:"eip155",ADD_CHAIN_METHOD:"wallet_addEthereumChain",EIP6963_ANNOUNCE_EVENT:"eip6963:announceProvider",EIP6963_REQUEST_EVENT:"eip6963:requestProvider",CONNECTOR_RDNS_MAP:{coinbaseWallet:"com.coinbase.wallet",coinbaseWalletSDK:"com.coinbase.wallet"},CONNECTOR_TYPE_EXTERNAL:"EXTERNAL",CONNECTOR_TYPE_WALLET_CONNECT:"WALLET_CONNECT",CONNECTOR_TYPE_INJECTED:"INJECTED",CONNECTOR_TYPE_ANNOUNCED:"ANNOUNCED",CONNECTOR_TYPE_AUTH:"AUTH",CONNECTOR_TYPE_MULTI_CHAIN:"MULTI_CHAIN",CONNECTOR_TYPE_W3M_AUTH:"ID_AUTH"}},98752:(e,t,s)=>{s.d(t,{$I:()=>Y,$w:()=>G,Jf:()=>P,S$:()=>J,Tn:()=>Z,U:()=>Q,U$:()=>X,WB:()=>V,cV:()=>R,iJ:()=>hi,il:()=>ks,sD:()=>A,wn:()=>W,zN:()=>q});var i=s(50046),r=s.n(i),n=s(37147),o=s(81030),a=s(70255),c=s(21910),h=s(91315),l=s(25607),p=s(97353),d=s(48851),u=s(1030),g=s(93786),f=s(14350),m=s(63342),w=s(20635),y=s(48526).hp;const b="core",v=`wc@2:${b}:`,E={database:":memory:"},I="client_ed25519_seed",_=h.ONE_DAY,N=h.SIX_HOURS,A="irn",C="wss://relay.walletconnect.org",P={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},S="payload",O="connect",T="disconnect",k="error",x="2.19.1",R={link_mode:"link_mode",relay:"relay"},U="inbound",D="WALLETCONNECT_LINK_MODE_APPS",j="subscription_created",M="subscription_deleted",L=(h.FIVE_SECONDS,{wc_pairingDelete:{req:{ttl:h.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:h.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:h.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:h.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:h.ONE_DAY,prompt:!1,tag:0},res:{ttl:h.ONE_DAY,prompt:!1,tag:0}}}),q={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},$="history_created",B="history_updated",H="history_deleted",W={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},z="https://verify.walletconnect.org",V=z,F=`${V}/v3`,K=["https://verify.walletconnect.com",z],G={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},J={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},Y={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},Q={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},X={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Z={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"};const ee=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class te{constructor(e,t,s){this.name=e,this.prefix=t,this.baseEncode=s}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class se{constructor(e,t,s){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=s}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return re(this,e)}}class ie{constructor(e){this.decoders=e}or(e){return re(this,e)}decode(e){const t=e[0],s=this.decoders[t];if(s)return s.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const re=(e,t)=>new ie({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class ne{constructor(e,t,s,i){this.name=e,this.prefix=t,this.baseEncode=s,this.baseDecode=i,this.encoder=new te(e,t,s),this.decoder=new se(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const oe=({name:e,prefix:t,encode:s,decode:i})=>new ne(e,t,s,i),ae=({prefix:e,name:t,alphabet:s})=>{const{encode:i,decode:r}=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),i=0;i<s.length;i++)s[i]=255;for(var r=0;r<e.length;r++){var n=e.charAt(r),o=n.charCodeAt(0);if(255!==s[o])throw new TypeError(n+" is ambiguous");s[o]=r}var a=e.length,c=e.charAt(0),h=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function p(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var i=0,r=0;e[t]===c;)i++,t++;for(var n=(e.length-t)*h+1>>>0,o=new Uint8Array(n);e[t];){var l=s[e.charCodeAt(t)];if(255===l)return;for(var p=0,d=n-1;(0!==l||p<r)&&-1!==d;d--,p++)l+=a*o[d]>>>0,o[d]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");r=p,t++}if(" "!==e[t]){for(var u=n-r;u!==n&&0===o[u];)u++;for(var g=new Uint8Array(i+(n-u)),f=i;u!==n;)g[f++]=o[u++];return g}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var s=0,i=0,r=0,n=t.length;r!==n&&0===t[r];)r++,s++;for(var o=(n-r)*l+1>>>0,h=new Uint8Array(o);r!==n;){for(var p=t[r],d=0,u=o-1;(0!==p||d<i)&&-1!==u;u--,d++)p+=256*h[u]>>>0,h[u]=p%a>>>0,p=p/a>>>0;if(0!==p)throw new Error("Non-zero carry");i=d,r++}for(var g=o-i;g!==o&&0===h[g];)g++;for(var f=c.repeat(s);g<o;++g)f+=e.charAt(h[g]);return f},decodeUnsafe:p,decode:function(e){var s=p(e);if(s)return s;throw new Error(`Non-${t} character`)}}}(s,t);return oe({prefix:e,name:t,encode:i,decode:e=>ee(r(e))})},ce=({name:e,prefix:t,bitsPerChar:s,alphabet:i})=>oe({prefix:t,name:e,encode:e=>((e,t,s)=>{const i="="===t[t.length-1],r=(1<<s)-1;let n="",o=0,a=0;for(let i=0;i<e.length;++i)for(a=a<<8|e[i],o+=8;o>s;)o-=s,n+=t[r&a>>o];if(o&&(n+=t[r&a<<s-o]),i)for(;n.length*s&7;)n+="=";return n})(e,i,s),decode:t=>((e,t,s,i)=>{const r={};for(let e=0;e<t.length;++e)r[t[e]]=e;let n=e.length;for(;"="===e[n-1];)--n;const o=new Uint8Array(n*s/8|0);let a=0,c=0,h=0;for(let t=0;t<n;++t){const n=r[e[t]];if(void 0===n)throw new SyntaxError(`Non-${i} character`);c=c<<s|n,a+=s,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=s||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,i,s,e)}),he=oe({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var le=Object.freeze({__proto__:null,identity:he});const pe=ce({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var de=Object.freeze({__proto__:null,base2:pe});const ue=ce({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var ge=Object.freeze({__proto__:null,base8:ue});const fe=ae({prefix:"9",name:"base10",alphabet:"0123456789"});var me=Object.freeze({__proto__:null,base10:fe});const we=ce({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ye=ce({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var be=Object.freeze({__proto__:null,base16:we,base16upper:ye});const ve=ce({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ee=ce({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ie=ce({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),_e=ce({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ne=ce({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ae=ce({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ce=ce({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Pe=ce({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Se=ce({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Oe=Object.freeze({__proto__:null,base32:ve,base32upper:Ee,base32pad:Ie,base32padupper:_e,base32hex:Ne,base32hexupper:Ae,base32hexpad:Ce,base32hexpadupper:Pe,base32z:Se});const Te=ae({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),ke=ae({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var xe=Object.freeze({__proto__:null,base36:Te,base36upper:ke});const Re=ae({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ue=ae({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var De=Object.freeze({__proto__:null,base58btc:Re,base58flickr:Ue});const je=ce({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Me=ce({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Le=ce({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),qe=ce({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var $e=Object.freeze({__proto__:null,base64:je,base64pad:Me,base64url:Le,base64urlpad:qe});const Be=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),He=Be.reduce((e,t,s)=>(e[s]=t,e),[]),We=Be.reduce((e,t,s)=>(e[t.codePointAt(0)]=s,e),[]),ze=oe({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce((e,t)=>e+He[t],"")},decode:function(e){const t=[];for(const s of e){const e=We[s.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${s}`);t.push(e)}return new Uint8Array(t)}});var Ve=Object.freeze({__proto__:null,base256emoji:ze}),Fe=128,Ke=-128,Ge=Math.pow(2,31),Je=Math.pow(2,7),Ye=Math.pow(2,14),Qe=Math.pow(2,21),Xe=Math.pow(2,28),Ze=Math.pow(2,35),et=Math.pow(2,42),tt=Math.pow(2,49),st=Math.pow(2,56),it=Math.pow(2,63),rt=function e(t,s,i){s=s||[];for(var r=i=i||0;t>=Ge;)s[i++]=255&t|Fe,t/=128;for(;t&Ke;)s[i++]=255&t|Fe,t>>>=7;return s[i]=0|t,e.bytes=i-r+1,s},nt=function(e){return e<Je?1:e<Ye?2:e<Qe?3:e<Xe?4:e<Ze?5:e<et?6:e<tt?7:e<st?8:e<it?9:10};const ot=(e,t,s=0)=>(rt(e,t,s),t),at=e=>nt(e),ct=(e,t)=>{const s=t.byteLength,i=at(e),r=i+at(s),n=new Uint8Array(r+s);return ot(e,n,0),ot(s,n,i),n.set(t,r),new ht(e,s,t,n)};class ht{constructor(e,t,s,i){this.code=e,this.size=t,this.digest=s,this.bytes=i}}const lt=({name:e,code:t,encode:s})=>new pt(e,t,s);class pt{constructor(e,t,s){this.name=e,this.code=t,this.encode=s}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ct(this.code,t):t.then(e=>ct(this.code,e))}throw Error("Unknown type, must be binary type")}}const dt=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),ut=lt({name:"sha2-256",code:18,encode:dt("SHA-256")}),gt=lt({name:"sha2-512",code:19,encode:dt("SHA-512")});Object.freeze({__proto__:null,sha256:ut,sha512:gt});const ft=ee,mt={code:0,name:"identity",encode:ft,digest:e=>ct(0,ft(e))};Object.freeze({__proto__:null,identity:mt}),new TextEncoder,new TextDecoder;const wt={...le,...de,...ge,...me,...be,...Oe,...xe,...De,...$e,...Ve};function yt(e,t,s,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:s},decoder:{decode:i}}}const bt=yt("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>(new TextEncoder).encode(e.substring(1))),vt=yt("ascii","a",e=>{let t="a";for(let s=0;s<e.length;s++)t+=String.fromCharCode(e[s]);return t},e=>{const t=function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}((e=e.substring(1)).length);for(let s=0;s<e.length;s++)t[s]=e.charCodeAt(s);return t}),Et={utf8:bt,"utf-8":bt,hex:wt.base16,latin1:vt,ascii:vt,binary:vt,...wt};var It=Object.defineProperty,_t=(e,t,s)=>((e,t,s)=>t in e?It(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Nt{constructor(e,t){this.core=e,this.logger=t,_t(this,"keychain",new Map),_t(this,"name","keychain"),_t(this,"version","0.3"),_t(this,"initialized",!1),_t(this,"storagePrefix",v),_t(this,"init",async()=>{if(!this.initialized){const e=await this.getKeyChain();typeof e<"u"&&(this.keychain=e),this.initialized=!0}}),_t(this,"has",e=>(this.isInitialized(),this.keychain.has(e))),_t(this,"set",async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()}),_t(this,"get",e=>{this.isInitialized();const t=this.keychain.get(e);if(typeof t>"u"){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}),_t(this,"del",async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()}),this.core=e,this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,(0,d.h0Y)(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?(0,d.PUk)(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var At=Object.defineProperty,Ct=(e,t,s)=>((e,t,s)=>t in e?At(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Pt{constructor(e,t,s){this.core=e,this.logger=t,Ct(this,"name","crypto"),Ct(this,"keychain"),Ct(this,"randomSessionIdentifier",(0,d.two)()),Ct(this,"initialized",!1),Ct(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Ct(this,"hasKeys",e=>(this.isInitialized(),this.keychain.has(e))),Ct(this,"getClientId",async()=>{this.isInitialized();const e=await this.getClientSeed(),t=p.TZ(e);return p.UF(t.publicKey)}),Ct(this,"generateKeyPair",()=>{this.isInitialized();const e=(0,d.TZl)();return this.setPrivateKey(e.publicKey,e.privateKey)}),Ct(this,"signJWT",async e=>{this.isInitialized();const t=await this.getClientSeed(),s=p.TZ(t),i=this.randomSessionIdentifier,r=_;return await p.FA(i,e,r,s)}),Ct(this,"generateSharedKey",(e,t,s)=>{this.isInitialized();const i=this.getPrivateKey(e),r=(0,d.ovp)(i,t);return this.setSymKey(r,s)}),Ct(this,"setSymKey",async(e,t)=>{this.isInitialized();const s=t||(0,d.EN$)(e);return await this.keychain.set(s,e),s}),Ct(this,"deleteKeyPair",async e=>{this.isInitialized(),await this.keychain.del(e)}),Ct(this,"deleteSymKey",async e=>{this.isInitialized(),await this.keychain.del(e)}),Ct(this,"encode",async(e,t,s)=>{this.isInitialized();const i=(0,d.AwN)(s),r=(0,l.h)(t);if((0,d.ps1)(i))return(0,d.Tw2)(r,s?.encoding);if((0,d.V7m)(i)){const t=i.senderPublicKey,s=i.receiverPublicKey;e=await this.generateSharedKey(t,s)}const n=this.getSymKey(e),{type:o,senderPublicKey:a}=i;return(0,d.wa2)({type:o,symKey:n,message:r,senderPublicKey:a,encoding:s?.encoding})}),Ct(this,"decode",async(e,t,s)=>{this.isInitialized();const i=(0,d.C5G)(t,s);if((0,d.ps1)(i)){const e=(0,d.F$L)(t,s?.encoding);return(0,l.j)(e)}if((0,d.V7m)(i)){const t=i.receiverPublicKey,s=i.senderPublicKey;e=await this.generateSharedKey(t,s)}try{const i=this.getSymKey(e),r=(0,d.YcA)({symKey:i,encoded:t,encoding:s?.encoding});return(0,l.j)(r)}catch(t){this.logger.error(`Failed to decode message from topic: '${e}', clientId: '${await this.getClientId()}'`),this.logger.error(t)}}),Ct(this,"getPayloadType",(e,t=d.EWt)=>{const s=(0,d.iui)({encoded:e,encoding:t});return(0,d.x0t)(s.type)}),Ct(this,"getPayloadSenderPublicKey",(e,t=d.EWt)=>{const s=(0,d.iui)({encoded:e,encoding:t});return s.senderPublicKey?(0,u.dI)(s.senderPublicKey,d.bEt):void 0}),this.core=e,this.logger=(0,a.U5)(t,this.name),this.keychain=s||new Nt(this.core,this.logger)}get context(){return(0,a.oI)(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(I)}catch{e=(0,d.two)(),await this.keychain.set(I,e)}return function(e,t="utf8"){const s=Et[t];if(!s)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?s.decoder.decode(`${s.prefix}${e}`):globalThis.Buffer.from(e,"utf8")}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var St=Object.defineProperty,Ot=Object.defineProperties,Tt=Object.getOwnPropertyDescriptors,kt=Object.getOwnPropertySymbols,xt=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable,Ut=(e,t,s)=>t in e?St(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Dt=(e,t,s)=>Ut(e,"symbol"!=typeof t?t+"":t,s);class jt extends c.dQ{constructor(e,t){super(e,t),this.logger=e,this.core=t,Dt(this,"messages",new Map),Dt(this,"messagesWithoutClientAck",new Map),Dt(this,"name","messages"),Dt(this,"version","0.3"),Dt(this,"initialized",!1),Dt(this,"storagePrefix",v),Dt(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const e=await this.getRelayerMessages();typeof e<"u"&&(this.messages=e);const t=await this.getRelayerMessagesWithoutClientAck();typeof t<"u"&&(this.messagesWithoutClientAck=t),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}}),Dt(this,"set",async(e,t,s)=>{this.isInitialized();const i=(0,d.ALl)(t);let r=this.messages.get(e);if(typeof r>"u"&&(r={}),typeof r[i]<"u")return i;if(r[i]=t,this.messages.set(e,r),s===U){const s=this.messagesWithoutClientAck.get(e)||{};this.messagesWithoutClientAck.set(e,((e,t)=>Ot(e,Tt(t)))(((e,t)=>{for(var s in t||(t={}))xt.call(t,s)&&Ut(e,s,t[s]);if(kt)for(var s of kt(t))Rt.call(t,s)&&Ut(e,s,t[s]);return e})({},s),{[i]:t}))}return await this.persist(),i}),Dt(this,"get",e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t}),Dt(this,"getWithoutAck",e=>{this.isInitialized();const t={};for(const s of e){const e=this.messagesWithoutClientAck.get(s)||{};t[s]=Object.values(e)}return t}),Dt(this,"has",(e,t)=>(this.isInitialized(),typeof this.get(e)[(0,d.ALl)(t)]<"u")),Dt(this,"ack",async(e,t)=>{this.isInitialized();const s=this.messagesWithoutClientAck.get(e);typeof s>"u"||(delete s[(0,d.ALl)(t)],0===Object.keys(s).length?this.messagesWithoutClientAck.delete(e):this.messagesWithoutClientAck.set(e,s),await this.persist())}),Dt(this,"del",async e=>{this.isInitialized(),this.messages.delete(e),this.messagesWithoutClientAck.delete(e),await this.persist()}),this.logger=(0,a.U5)(e,this.name),this.core=t}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,(0,d.h0Y)(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,(0,d.h0Y)(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?(0,d.PUk)(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?(0,d.PUk)(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Mt=Object.defineProperty,Lt=Object.defineProperties,qt=Object.getOwnPropertyDescriptors,$t=Object.getOwnPropertySymbols,Bt=Object.prototype.hasOwnProperty,Ht=Object.prototype.propertyIsEnumerable,Wt=(e,t,s)=>t in e?Mt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,zt=(e,t)=>{for(var s in t||(t={}))Bt.call(t,s)&&Wt(e,s,t[s]);if($t)for(var s of $t(t))Ht.call(t,s)&&Wt(e,s,t[s]);return e},Vt=(e,t)=>Lt(e,qt(t)),Ft=(e,t,s)=>Wt(e,"symbol"!=typeof t?t+"":t,s);class Kt extends c.qE{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,Ft(this,"events",new i.EventEmitter),Ft(this,"name","publisher"),Ft(this,"queue",new Map),Ft(this,"publishTimeout",(0,h.toMiliseconds)(h.ONE_MINUTE)),Ft(this,"initialPublishTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),Ft(this,"needsTransportRestart",!1),Ft(this,"publish",async(e,t,s)=>{var i;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:s}});const r=s?.ttl||N,n=(0,d.n6V)(s),o=s?.prompt||!1,a=s?.tag||0,c=s?.id||(0,f.getBigIntRpcId)().toString(),h={topic:e,message:t,opts:{ttl:r,relay:n,prompt:o,tag:a,id:c,attestation:s?.attestation,tvf:s?.tvf}},l=`Failed to publish payload, please try again. id:${c} tag:${a}`;try{const i=new Promise(async i=>{const n=({id:e})=>{h.opts.id===e&&(this.removeRequestFromQueue(e),this.relayer.events.removeListener(P.publish,n),i(h))};this.relayer.events.on(P.publish,n);const l=(0,d.K3g)(new Promise((i,n)=>{this.rpcPublish({topic:e,message:t,ttl:r,prompt:o,tag:a,id:c,attestation:s?.attestation,tvf:s?.tvf}).then(i).catch(e=>{this.logger.warn(e,e?.message),n(e)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${c} tag:${a}`);try{await l,this.events.removeListener(P.publish,n)}catch(e){this.queue.set(c,Vt(zt({},h),{attempt:1})),this.logger.warn(e,e?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:c,topic:e,message:t,opts:s}}),await(0,d.K3g)(i,this.publishTimeout,l)}catch(e){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(e),null!=(i=s?.internal)&&i.throwOnFailedPublish)throw e}finally{this.queue.delete(c)}}),Ft(this,"on",(e,t)=>{this.events.on(e,t)}),Ft(this,"once",(e,t)=>{this.events.once(e,t)}),Ft(this,"off",(e,t)=>{this.events.off(e,t)}),Ft(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.relayer=e,this.logger=(0,a.U5)(t,this.name),this.registerEventListeners()}get context(){return(0,a.oI)(this.logger)}async rpcPublish(e){var t,s,i,r;const{topic:n,message:o,ttl:a=N,prompt:c,tag:h,id:l,attestation:p,tvf:u}=e,g={method:(0,d.aa1)((0,d.n6V)().protocol).publish,params:zt({topic:n,message:o,ttl:a,prompt:c,tag:h,attestation:p},u),id:l};(0,d.b07)(null==(t=g.params)?void 0:t.prompt)&&(null==(s=g.params)||delete s.prompt),(0,d.b07)(null==(i=g.params)?void 0:i.tag)&&(null==(r=g.params)||delete r.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:g});const f=await this.relayer.request(g);return this.relayer.events.emit(P.publish,e),this.logger.debug("Successfully Published Payload"),f}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{const s=e.attempt+1;this.queue.set(t,Vt(zt({},e),{attempt:s}));const{topic:i,message:r,opts:n,attestation:o}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${s}`),await this.rpcPublish(Vt(zt({},e),{topic:i,message:r,ttl:n.ttl,prompt:n.prompt,tag:n.tag,id:n.id,attestation:o,tvf:n.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(n.li.pulse,()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(P.connection_stalled);this.checkQueue()}),this.relayer.on(P.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var Gt=Object.defineProperty,Jt=(e,t,s)=>((e,t,s)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Yt{constructor(){Jt(this,"map",new Map),Jt(this,"set",(e,t)=>{const s=this.get(e);this.exists(e,t)||this.map.set(e,[...s,t])}),Jt(this,"get",e=>this.map.get(e)||[]),Jt(this,"exists",(e,t)=>this.get(e).includes(t)),Jt(this,"delete",(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const s=this.get(e);if(!this.exists(e,t))return;const i=s.filter(e=>e!==t);i.length?this.map.set(e,i):this.map.delete(e)}),Jt(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var Qt=Object.defineProperty,Xt=Object.defineProperties,Zt=Object.getOwnPropertyDescriptors,es=Object.getOwnPropertySymbols,ts=Object.prototype.hasOwnProperty,ss=Object.prototype.propertyIsEnumerable,is=(e,t,s)=>t in e?Qt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,rs=(e,t)=>{for(var s in t||(t={}))ts.call(t,s)&&is(e,s,t[s]);if(es)for(var s of es(t))ss.call(t,s)&&is(e,s,t[s]);return e},ns=(e,t)=>Xt(e,Zt(t)),os=(e,t,s)=>is(e,"symbol"!=typeof t?t+"":t,s);class as extends c.mF{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,os(this,"subscriptions",new Map),os(this,"topicMap",new Yt),os(this,"events",new i.EventEmitter),os(this,"name","subscription"),os(this,"version","0.3"),os(this,"pending",new Map),os(this,"cached",[]),os(this,"initialized",!1),os(this,"storagePrefix",v),os(this,"subscribeTimeout",(0,h.toMiliseconds)(h.ONE_MINUTE)),os(this,"initialSubscribeTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),os(this,"clientId"),os(this,"batchSubscribeTopicsLimit",500),os(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),os(this,"subscribe",async(e,t)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const s=(0,d.n6V)(t),i={topic:e,relay:s,transportType:t?.transportType};this.pending.set(e,i);const r=await this.rpcSubscribe(e,s,t);return"string"==typeof r&&(this.onSubscribe(r,i),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}})),r}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}}),os(this,"unsubscribe",async(e,t)=>{this.isInitialized(),typeof t?.id<"u"?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)}),os(this,"isSubscribed",e=>new Promise(t=>{t(this.topicMap.topics.includes(e))})),os(this,"isKnownTopic",e=>new Promise(t=>{t(this.topicMap.topics.includes(e)||this.pending.has(e)||this.cached.some(t=>t.topic===e))})),os(this,"on",(e,t)=>{this.events.on(e,t)}),os(this,"once",(e,t)=>{this.events.once(e,t)}),os(this,"off",(e,t)=>{this.events.off(e,t)}),os(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),os(this,"start",async()=>{await this.onConnect()}),os(this,"stop",async()=>{await this.onDisconnect()}),os(this,"restart",async()=>{await this.restore(),await this.onRestart()}),os(this,"checkPending",async()=>{if(!(0!==this.pending.size||this.initialized&&this.relayer.connected))return;const e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e)}),os(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(n.li.pulse,async()=>{await this.checkPending()}),this.events.on(j,async e=>{const t=j;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(M,async e=>{const t=M;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}),this.relayer=e,this.logger=(0,a.U5)(t,this.name),this.clientId=""}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,t){let s=!1;try{s=this.getSubscription(e).topic===t}catch{}return s}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const s=this.topicMap.get(e);await Promise.all(s.map(async s=>await this.unsubscribeById(e,s,t)))}async unsubscribeById(e,t,s){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:s}});try{const i=(0,d.n6V)(s);await this.restartToComplete({topic:e,id:t,relay:i}),await this.rpcUnsubscribe(e,t,i);const r=(0,d.Hjj)("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,r),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:s}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t,s){var i;(!s||s?.transportType===R.relay)&&await this.restartToComplete({topic:e,id:e,relay:t});const r={method:(0,d.aa1)(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});const n=null==(i=s?.internal)?void 0:i.throwOnFailedPublish;try{const t=await this.getSubscriptionId(e);if(s?.transportType===R.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(r).catch(e=>this.logger.warn(e))},(0,h.toMiliseconds)(h.ONE_SECOND)),t;const i=new Promise(async t=>{const s=i=>{i.topic===e&&(this.events.removeListener(j,s),t(i.id))};this.events.on(j,s);try{const i=await(0,d.K3g)(new Promise((e,t)=>{this.relayer.request(r).catch(e=>{this.logger.warn(e,e?.message),t(e)}).then(e)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(j,s),t(i)}catch{}}),o=await(0,d.K3g)(i,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!o&&n)throw new Error(`Subscribing to ${e} failed, please try again`);return o?t:null}catch(e){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(P.connection_stalled),n)throw e}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,s={method:(0,d.aa1)(t.protocol).batchSubscribe,params:{topics:e.map(e=>e.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{await await(0,d.K3g)(new Promise(e=>{this.relayer.request(s).catch(e=>this.logger.warn(e)).then(e)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(P.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,s={method:(0,d.aa1)(t.protocol).batchFetchMessages,params:{topics:e.map(e=>e.topic)}};let i;this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s});try{i=await await(0,d.K3g)(new Promise((e,t)=>{this.relayer.request(s).catch(e=>{this.logger.warn(e),t(e)}).then(e)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(P.connection_stalled)}return i}rpcUnsubscribe(e,t,s){const i={method:(0,d.aa1)(s.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i}),this.relayer.request(i)}onSubscribe(e,t){this.setSubscription(e,ns(rs({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(e=>{this.setSubscription(e.id,rs({},e)),this.pending.delete(e.topic)})}async onUnsubscribe(e,t,s){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,s),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,rs({},t)),this.topicMap.set(t.topic,e),this.events.emit(j,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const s=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(s.topic,e),this.events.emit(M,ns(rs({},s),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit("subscription_sync")}async onRestart(){if(this.cached.length){const e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let s=0;s<t;s++){const t=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(t)}}this.events.emit("subscription_resubscribed")}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:e}=(0,d.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async e=>ns(rs({},e),{id:await this.getSubscriptionId(e.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await(0,d.yy4)((0,h.toMiliseconds)(h.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(t.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return(0,d.ALl)(e+await this.getClientId())}}var cs=Object.defineProperty,hs=Object.getOwnPropertySymbols,ls=Object.prototype.hasOwnProperty,ps=Object.prototype.propertyIsEnumerable,ds=(e,t,s)=>t in e?cs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,us=(e,t)=>{for(var s in t||(t={}))ls.call(t,s)&&ds(e,s,t[s]);if(hs)for(var s of hs(t))ps.call(t,s)&&ds(e,s,t[s]);return e},gs=(e,t,s)=>ds(e,"symbol"!=typeof t?t+"":t,s);class fs extends c.m5{constructor(e){super(e),gs(this,"protocol","wc"),gs(this,"version",2),gs(this,"core"),gs(this,"logger"),gs(this,"events",new i.EventEmitter),gs(this,"provider"),gs(this,"messages"),gs(this,"subscriber"),gs(this,"publisher"),gs(this,"name","relayer"),gs(this,"transportExplicitlyClosed",!1),gs(this,"initialized",!1),gs(this,"connectionAttemptInProgress",!1),gs(this,"relayUrl"),gs(this,"projectId"),gs(this,"packageName"),gs(this,"bundleId"),gs(this,"hasExperiencedNetworkDisruption",!1),gs(this,"pingTimeout"),gs(this,"heartBeatTimeout",(0,h.toMiliseconds)(h.THIRTY_SECONDS+h.FIVE_SECONDS)),gs(this,"reconnectTimeout"),gs(this,"connectPromise"),gs(this,"reconnectInProgress",!1),gs(this,"requestsInFlight",[]),gs(this,"connectTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),gs(this,"request",async e=>{var t,s;this.logger.debug("Publishing Request Payload");const i=e.id||(0,f.getBigIntRpcId)().toString();await this.toEstablishConnection();try{this.logger.trace({id:i,method:e.method,topic:null==(t=e.params)?void 0:t.topic},"relayer.request - publishing...");const r=`${i}:${(null==(s=e.params)?void 0:s.tag)||""}`;this.requestsInFlight.push(r);const n=await this.provider.request(e);return this.requestsInFlight=this.requestsInFlight.filter(e=>e!==r),n}catch(e){throw this.logger.debug(`Failed to Publish Request: ${i}`),e}}),gs(this,"resetPingTimeout",()=>{(0,d.Lln)()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var e,t,s,i;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),null==(i=null==(s=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:s.terminate)||i.call(s)}catch(e){this.logger.warn(e,e?.message)}},this.heartBeatTimeout))}),gs(this,"onPayloadHandler",e=>{this.onProviderPayload(e),this.resetPingTimeout()}),gs(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(P.connect)}),gs(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),gs(this,"onProviderErrorHandler",e=>{this.logger.fatal(`Fatal socket error: ${e.message}`),this.events.emit(P.error,e),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),gs(this,"registerProviderListeners",()=>{this.provider.on(S,this.onPayloadHandler),this.provider.on(O,this.onConnectHandler),this.provider.on(T,this.onDisconnectHandler),this.provider.on(k,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&"string"!=typeof e.logger?(0,a.U5)(e.logger,this.name):(0,a.h6)((0,a.iP)({level:e.logger||"error"})),this.messages=new jt(this.logger,e.core),this.subscriber=new as(this,this.logger),this.publisher=new Kt(this,this.logger),this.relayUrl=e?.relayUrl||C,this.projectId=e.projectId,(0,d.m01)()?this.packageName=(0,d.R7U)():(0,d.aRZ)()&&(this.bundleId=(0,d.R7U)()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return(0,a.oI)(this.logger)}get connected(){var e,t,s;return 1===(null==(s=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:s.readyState)||!1}get connecting(){var e,t,s;return 0===(null==(s=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:s.readyState)||void 0!==this.connectPromise||!1}async publish(e,t,s){this.isInitialized(),await this.publisher.publish(e,t,s),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:R.relay},"outbound")}async subscribe(e,t){var s,i,r;this.isInitialized(),(null==t||!t.transportType||"relay"===t?.transportType)&&await this.toEstablishConnection();const n=typeof(null==(s=t?.internal)?void 0:s.throwOnFailedPublish)>"u"||(null==(i=t?.internal)?void 0:i.throwOnFailedPublish);let o,a=(null==(r=this.subscriber.topicMap.get(e))?void 0:r[0])||"";const c=t=>{t.topic===e&&(this.subscriber.off(j,c),o())};return await Promise.all([new Promise(e=>{o=e,this.subscriber.on(j,c)}),new Promise(async(s,i)=>{a=await this.subscriber.subscribe(e,us({internal:{throwOnFailedPublish:n}},t)).catch(e=>{n&&i(e)})||a,s()})]),a}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await(0,d.K3g)(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(this.subscriber.hasAnyTopics){if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(t,s)=>{await this.connect(e).then(t).catch(s).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}else this.logger.warn("Starting WS connection skipped because the client has no topics to work with.")}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await(0,d.sc7)())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(0===e?.length)return void this.logger.trace("Batch message events is empty. Ignoring...");const t=e.sort((e,t)=>e.publishedAt-t.publishedAt);this.logger.debug(`Batch of ${t.length} message events sorted`);for(const e of t)try{await this.onMessageEvent(e)}catch(e){this.logger.warn(e,"Error while processing batch message event: "+e?.message)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:s}=e;if(!t.sessionExists){const e={topic:s,expiry:(0,d.Xw0)(h.FIVE_MINUTES),relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(s,e)}this.events.emit(P.message,e),await this.recordMessageEvent(e,U)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let t=1;for(;t<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(e,t)=>{const s=()=>{t(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(T,s),await(0,d.K3g)(new Promise((e,t)=>{this.provider.connect().then(e).catch(t)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(e=>{t(e)}).finally(()=>{this.provider.off(T,s),clearTimeout(this.reconnectTimeout)}),await new Promise(async(e,t)=>{const s=()=>{t(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(T,s),await this.subscriber.start().then(e).catch(t).finally(()=>{this.provider.off(T,s)})}),this.hasExperiencedNetworkDisruption=!1,e()})}catch(e){await this.subscriber.stop();const t=e;this.logger.warn({},t.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(e=>setTimeout(e,(0,h.toMiliseconds)(1*t))),t++}}startPingTimeout(){var e,t,s,i,r;if((0,d.Lln)())try{null!=(t=null==(e=this.provider)?void 0:e.connection)&&t.socket&&(null==(r=null==(i=null==(s=this.provider)?void 0:s.connection)?void 0:i.socket)||r.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(e){this.logger.warn(e,e?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new g.F(new m.A((0,d.jUZ)({sdkVersion:x,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e,t){const{topic:s,message:i}=e;await this.messages.set(s,i,t)}async shouldIgnoreMessageEvent(e){const{topic:t,message:s}=e;if(!s||0===s.length)return this.logger.warn(`Ignoring invalid/empty message: ${s}`),!0;if(!await this.subscriber.isKnownTopic(t))return this.logger.warn(`Ignoring message for unknown topic ${t}`),!0;const i=this.messages.has(t,s);return i&&this.logger.warn(`Ignoring duplicate message: ${s}`),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),(0,f.isJsonRpcRequest)(e)){if(!e.method.endsWith("_subscription"))return;const t=e.params,{topic:s,message:i,publishedAt:r,attestation:n}=t.data,o={topic:s,message:i,publishedAt:r,transportType:R.relay,attestation:n};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(us({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o)}else(0,f.isJsonRpcResponse)(e)&&this.events.emit(P.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,U),this.events.emit(P.message,e))}async acknowledgePayload(e){const t=(0,f.formatJsonRpcResult)(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(S,this.onPayloadHandler),this.provider.off(O,this.onConnectHandler),this.provider.off(T,this.onDisconnectHandler),this.provider.off(k,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await(0,d.sc7)();(0,d.uym)(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(e=>this.logger.error(e,e?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(P.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},(0,h.toMiliseconds)(.1)))))}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.connect()}}function ms(){}function ws(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&"[object Object]"===Object.prototype.toString.call(e)}function ys(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function bs(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const vs="[object Arguments]",Es="[object Object]";function Is(e,t,s,i,r,n,o){const a=o(e,t,s,i,r,n);if(void 0!==a)return a;if(typeof e==typeof t)switch(typeof e){case"bigint":case"string":case"boolean":case"symbol":case"undefined":case"function":return e===t;case"number":return e===t||Object.is(e,t);case"object":return _s(e,t,n,o)}return _s(e,t,n,o)}function _s(e,t,s,i){if(Object.is(e,t))return!0;let r=bs(e),n=bs(t);if(r===vs&&(r=Es),n===vs&&(n=Es),r!==n)return!1;switch(r){case"[object String]":return e.toString()===t.toString();case"[object Number]":return function(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}(e.valueOf(),t.valueOf());case"[object Boolean]":case"[object Date]":case"[object Symbol]":return Object.is(e.valueOf(),t.valueOf());case"[object RegExp]":return e.source===t.source&&e.flags===t.flags;case"[object Function]":return e===t}const o=(s=s??new Map).get(e),a=s.get(t);if(null!=o&&null!=a)return o===t;s.set(e,t),s.set(t,e);try{switch(r){case"[object Map]":if(e.size!==t.size)return!1;for(const[r,n]of e.entries())if(!t.has(r)||!Is(n,t.get(r),r,e,t,s,i))return!1;return!0;case"[object Set]":{if(e.size!==t.size)return!1;const r=Array.from(e.values()),n=Array.from(t.values());for(let o=0;o<r.length;o++){const a=r[o],c=n.findIndex(r=>Is(a,r,void 0,e,t,s,i));if(-1===c)return!1;n.splice(c,1)}return!0}case"[object Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":case"[object BigUint64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object BigInt64Array]":case"[object Float32Array]":case"[object Float64Array]":if(typeof y<"u"&&y.isBuffer(e)!==y.isBuffer(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Is(e[r],t[r],r,e,t,s,i))return!1;return!0;case"[object ArrayBuffer]":return e.byteLength===t.byteLength&&_s(new Uint8Array(e),new Uint8Array(t),s,i);case"[object DataView]":return e.byteLength===t.byteLength&&e.byteOffset===t.byteOffset&&_s(new Uint8Array(e),new Uint8Array(t),s,i);case"[object Error]":return e.name===t.name&&e.message===t.message;case Es:{if(!(_s(e.constructor,t.constructor,s,i)||ws(e)&&ws(t)))return!1;const r=[...Object.keys(e),...ys(e)],n=[...Object.keys(t),...ys(t)];if(r.length!==n.length)return!1;for(let n=0;n<r.length;n++){const o=r[n],a=e[o];if(!Object.hasOwn(t,o))return!1;if(!Is(a,t[o],o,e,t,s,i))return!1}return!0}default:return!1}}finally{s.delete(e),s.delete(t)}}var Ns=Object.defineProperty,As=Object.getOwnPropertySymbols,Cs=Object.prototype.hasOwnProperty,Ps=Object.prototype.propertyIsEnumerable,Ss=(e,t,s)=>t in e?Ns(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Os=(e,t)=>{for(var s in t||(t={}))Cs.call(t,s)&&Ss(e,s,t[s]);if(As)for(var s of As(t))Ps.call(t,s)&&Ss(e,s,t[s]);return e},Ts=(e,t,s)=>Ss(e,"symbol"!=typeof t?t+"":t,s);class ks extends c.pi{constructor(e,t,s,i=v,r=void 0){super(e,t,s,i),this.core=e,this.logger=t,this.name=s,Ts(this,"map",new Map),Ts(this,"version","0.3"),Ts(this,"cached",[]),Ts(this,"initialized",!1),Ts(this,"getKey"),Ts(this,"storagePrefix",v),Ts(this,"recentlyDeleted",[]),Ts(this,"recentlyDeletedLimit",200),Ts(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>{this.getKey&&null!==e&&!(0,d.b07)(e)?this.map.set(this.getKey(e),e):(0,d.CTo)(e)?this.map.set(e.id,e):(0,d.mr0)(e)&&this.map.set(e.topic,e)}),this.cached=[],this.initialized=!0)}),Ts(this,"set",async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())}),Ts(this,"get",e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e))),Ts(this,"getAll",e=>(this.isInitialized(),e?this.values.filter(t=>Object.keys(e).every(s=>function(e,t){return function(e,t,s){return Is(e,t,void 0,void 0,void 0,void 0,s)}(e,t,ms)}(t[s],e[s]))):this.values)),Ts(this,"update",async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});const s=Os(Os({},this.getData(e)),t);this.map.set(e,s),await this.persist()}),Ts(this,"delete",async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:e,reason:t}),this.map.delete(e),this.addToRecentlyDeleted(e),await this.persist())}),this.logger=(0,a.U5)(t,this.name),this.storagePrefix=i,this.getKey=r}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:t}=(0,d.GuA)("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:e}=(0,d.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var xs=Object.defineProperty,Rs=(e,t,s)=>((e,t,s)=>t in e?xs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Us{constructor(e,t){this.core=e,this.logger=t,Rs(this,"name","pairing"),Rs(this,"version","0.3"),Rs(this,"events",new(r())),Rs(this,"pairings"),Rs(this,"initialized",!1),Rs(this,"storagePrefix",v),Rs(this,"ignoredPayloadTypes",[d.Lp_]),Rs(this,"registeredMethods",[]),Rs(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),Rs(this,"register",({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]}),Rs(this,"create",async e=>{this.isInitialized();const t=(0,d.two)(),s=await this.core.crypto.setSymKey(t),i=(0,d.Xw0)(h.FIVE_MINUTES),r={protocol:A},n={topic:s,expiry:i,relay:r,active:!1,methods:e?.methods},o=(0,d.QJh)({protocol:this.core.protocol,version:this.core.version,topic:s,symKey:t,relay:r,expiryTimestamp:i,methods:e?.methods});return this.events.emit(q.create,n),this.core.expirer.set(s,i),await this.pairings.set(s,n),await this.core.relayer.subscribe(s,{transportType:e?.transportType}),{topic:s,uri:o}}),Rs(this,"pair",async e=>{this.isInitialized();const t=this.core.eventClient.createEvent({properties:{topic:e?.uri,trace:[G.pairing_started]}});this.isValidPair(e,t);const{topic:s,symKey:i,relay:r,expiryTimestamp:n,methods:o}=(0,d.wYp)(e.uri);let a;if(t.props.properties.topic=s,t.addTrace(G.pairing_uri_validation_success),t.addTrace(G.pairing_uri_not_expired),this.pairings.keys.includes(s)){if(a=this.pairings.get(s),t.addTrace(G.existing_pairing),a.active)throw t.setError(J.active_pairing_already_exists),new Error(`Pairing already exists: ${s}. Please try again with a new connection URI.`);t.addTrace(G.pairing_not_expired)}const c=n||(0,d.Xw0)(h.FIVE_MINUTES),l={topic:s,relay:r,expiry:c,active:!1,methods:o};this.core.expirer.set(s,c),await this.pairings.set(s,l),t.addTrace(G.store_new_pairing),e.activatePairing&&await this.activate({topic:s}),this.events.emit(q.create,l),t.addTrace(G.emit_inactive_pairing),this.core.crypto.keychain.has(s)||await this.core.crypto.setSymKey(i,s),t.addTrace(G.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{t.setError(J.no_internet_connection)}try{await this.core.relayer.subscribe(s,{relay:r})}catch(e){throw t.setError(J.subscribe_pairing_topic_failure),e}return t.addTrace(G.subscribe_pairing_topic_success),l}),Rs(this,"activate",async({topic:e})=>{this.isInitialized();const t=(0,d.Xw0)(h.FIVE_MINUTES);this.core.expirer.set(e,t),await this.pairings.update(e,{active:!0,expiry:t})}),Rs(this,"ping",async e=>{this.isInitialized(),await this.isValidPing(e),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:t}=e;if(this.pairings.keys.includes(t)){const e=await this.sendRequest(t,"wc_pairingPing",{}),{done:s,resolve:i,reject:r}=(0,d.Wx8)();this.events.once((0,d.hEn)("pairing_ping",e),({error:e})=>{e?r(e):i()}),await s()}}),Rs(this,"updateExpiry",async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})}),Rs(this,"updateMetadata",async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})}),Rs(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),Rs(this,"disconnect",async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",(0,d.Hjj)("USER_DISCONNECTED")),await this.deletePairing(t))}),Rs(this,"formatUriFromPairing",e=>{this.isInitialized();const{topic:t,relay:s,expiry:i,methods:r}=e,n=this.core.crypto.keychain.get(t);return(0,d.QJh)({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:n,relay:s,expiryTimestamp:i,methods:r})}),Rs(this,"sendRequest",async(e,t,s)=>{const i=(0,f.formatJsonRpcRequest)(t,s),r=await this.core.crypto.encode(e,i),n=L[t].req;return this.core.history.set(e,i),this.core.relayer.publish(e,r,n),i.id}),Rs(this,"sendResult",async(e,t,s)=>{const i=(0,f.formatJsonRpcResult)(e,s),r=await this.core.crypto.encode(t,i),n=(await this.core.history.get(t,e)).request.method,o=L[n].res;await this.core.relayer.publish(t,r,o),await this.core.history.resolve(i)}),Rs(this,"sendError",async(e,t,s)=>{const i=(0,f.formatJsonRpcError)(e,s),r=await this.core.crypto.encode(t,i),n=(await this.core.history.get(t,e)).request.method,o=L[n]?L[n].res:L.unregistered_method.res;await this.core.relayer.publish(t,r,o),await this.core.history.resolve(i)}),Rs(this,"deletePairing",async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,(0,d.Hjj)("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])}),Rs(this,"cleanup",async()=>{const e=this.pairings.getAll().filter(e=>(0,d._dF)(e.expiry));await Promise.all(e.map(e=>this.deletePairing(e.topic)))}),Rs(this,"onRelayEventRequest",async e=>{const{topic:t,payload:s}=e;switch(s.method){case"wc_pairingPing":return await this.onPairingPingRequest(t,s);case"wc_pairingDelete":return await this.onPairingDeleteRequest(t,s);default:return await this.onUnknownRpcMethodRequest(t,s)}}),Rs(this,"onRelayEventResponse",async e=>{const{topic:t,payload:s}=e,i=(await this.core.history.get(t,s.id)).request.method;return"wc_pairingPing"===i?this.onPairingPingResponse(t,s):this.onUnknownRpcMethodResponse(i)}),Rs(this,"onPairingPingRequest",async(e,t)=>{const{id:s}=t;try{this.isValidPing({topic:e}),await this.sendResult(s,e,!0),this.events.emit(q.ping,{id:s,topic:e})}catch(t){await this.sendError(s,e,t),this.logger.error(t)}}),Rs(this,"onPairingPingResponse",(e,t)=>{const{id:s}=t;setTimeout(()=>{(0,f.isJsonRpcResult)(t)?this.events.emit((0,d.hEn)("pairing_ping",s),{}):(0,f.isJsonRpcError)(t)&&this.events.emit((0,d.hEn)("pairing_ping",s),{error:t.error})},500)}),Rs(this,"onPairingDeleteRequest",async(e,t)=>{const{id:s}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit(q.delete,{id:s,topic:e})}catch(t){await this.sendError(s,e,t),this.logger.error(t)}}),Rs(this,"onUnknownRpcMethodRequest",async(e,t)=>{const{id:s,method:i}=t;try{if(this.registeredMethods.includes(i))return;const t=(0,d.Hjj)("WC_METHOD_UNSUPPORTED",i);await this.sendError(s,e,t),this.logger.error(t)}catch(t){await this.sendError(s,e,t),this.logger.error(t)}}),Rs(this,"onUnknownRpcMethodResponse",e=>{this.registeredMethods.includes(e)||this.logger.error((0,d.Hjj)("WC_METHOD_UNSUPPORTED",e))}),Rs(this,"isValidPair",(e,t)=>{var s;if(!(0,d.TeY)(e)){const{message:s}=(0,d.GuA)("MISSING_OR_INVALID",`pair() params: ${e}`);throw t.setError(J.malformed_pairing_uri),new Error(s)}if(!(0,d.AYU)(e.uri)){const{message:s}=(0,d.GuA)("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw t.setError(J.malformed_pairing_uri),new Error(s)}const i=(0,d.wYp)(e?.uri);if(null==(s=i?.relay)||!s.protocol){const{message:e}=(0,d.GuA)("MISSING_OR_INVALID","pair() uri#relay-protocol");throw t.setError(J.malformed_pairing_uri),new Error(e)}if(null==i||!i.symKey){const{message:e}=(0,d.GuA)("MISSING_OR_INVALID","pair() uri#symKey");throw t.setError(J.malformed_pairing_uri),new Error(e)}if(null!=i&&i.expiryTimestamp&&(0,h.toMiliseconds)(i?.expiryTimestamp)<Date.now()){t.setError(J.pairing_expired);const{message:e}=(0,d.GuA)("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(e)}}),Rs(this,"isValidPing",async e=>{if(!(0,d.TeY)(e)){const{message:t}=(0,d.GuA)("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)}),Rs(this,"isValidDisconnect",async e=>{if(!(0,d.TeY)(e)){const{message:t}=(0,d.GuA)("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)}),Rs(this,"isValidPairingTopic",async e=>{if(!(0,d.Qhg)(e,!1)){const{message:t}=(0,d.GuA)("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.pairings.keys.includes(e)){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if((0,d._dF)(this.pairings.get(e).expiry)){await this.deletePairing(e);const{message:t}=(0,d.GuA)("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}),this.core=e,this.logger=(0,a.U5)(t,this.name),this.pairings=new ks(this.core,this.logger,this.name,this.storagePrefix)}get context(){return(0,a.oI)(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(P.message,async e=>{const{topic:t,message:s,transportType:i}=e;if(this.pairings.keys.includes(t)&&i!==R.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(s)))try{const e=await this.core.crypto.decode(t,s);(0,f.isJsonRpcRequest)(e)?(this.core.history.set(t,e),await this.onRelayEventRequest({topic:t,payload:e})):(0,f.isJsonRpcResponse)(e)&&(await this.core.history.resolve(e),await this.onRelayEventResponse({topic:t,payload:e}),this.core.history.delete(t,e.id)),await this.core.relayer.messages.ack(t,s)}catch(e){this.logger.error(e)}})}registerExpirerEvents(){this.core.expirer.on(W.expired,async e=>{const{topic:t}=(0,d.c82)(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(q.expire,{topic:t}))})}}var Ds=Object.defineProperty,js=(e,t,s)=>((e,t,s)=>t in e?Ds(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Ms extends c.lZ{constructor(e,t){super(e,t),this.core=e,this.logger=t,js(this,"records",new Map),js(this,"events",new i.EventEmitter),js(this,"name","history"),js(this,"version","0.3"),js(this,"cached",[]),js(this,"initialized",!1),js(this,"storagePrefix",v),js(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.records.set(e.id,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),js(this,"set",(e,t,s)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:s}),this.records.has(t.id))return;const i={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:s,expiry:(0,d.Xw0)(h.THIRTY_DAYS)};this.records.set(i.id,i),this.persist(),this.events.emit($,i)}),js(this,"resolve",async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;const t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=(0,f.isJsonRpcError)(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.persist(),this.events.emit(B,t))}),js(this,"get",async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t))),js(this,"delete",(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach(s=>{if(s.topic===e){if(typeof t<"u"&&s.id!==t)return;this.records.delete(s.id),this.events.emit(H,s)}}),this.persist()}),js(this,"exists",async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e)),js(this,"on",(e,t)=>{this.events.on(e,t)}),js(this,"once",(e,t)=>{this.events.once(e,t)}),js(this,"off",(e,t)=>{this.events.off(e,t)}),js(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const s={topic:t.topic,request:(0,f.formatJsonRpcRequest)(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(s)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit("history_sync")}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:e}=(0,d.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on($,e=>{const t=$;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(B,e=>{const t=B;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(H,e=>{const t=H;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(n.li.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,h.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(H,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Ls=Object.defineProperty,qs=(e,t,s)=>((e,t,s)=>t in e?Ls(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class $s extends c.Vx{constructor(e,t){super(e,t),this.core=e,this.logger=t,qs(this,"expirations",new Map),qs(this,"events",new i.EventEmitter),qs(this,"name","expirer"),qs(this,"version","0.3"),qs(this,"cached",[]),qs(this,"initialized",!1),qs(this,"storagePrefix",v),qs(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.expirations.set(e.target,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),qs(this,"has",e=>{try{const t=this.formatTarget(e);return typeof this.getExpiration(t)<"u"}catch{return!1}}),qs(this,"set",(e,t)=>{this.isInitialized();const s=this.formatTarget(e),i={target:s,expiry:t};this.expirations.set(s,i),this.checkExpiry(s,i),this.events.emit(W.created,{target:s,expiration:i})}),qs(this,"get",e=>{this.isInitialized();const t=this.formatTarget(e);return this.getExpiration(t)}),qs(this,"del",e=>{if(this.isInitialized(),this.has(e)){const t=this.formatTarget(e),s=this.getExpiration(t);this.expirations.delete(t),this.events.emit(W.deleted,{target:t,expiration:s})}}),qs(this,"on",(e,t)=>{this.events.on(e,t)}),qs(this,"once",(e,t)=>{this.events.once(e,t)}),qs(this,"off",(e,t)=>{this.events.off(e,t)}),qs(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if("string"==typeof e)return(0,d.ADD)(e);if("number"==typeof e)return(0,d.gOF)(e);const{message:t}=(0,d.GuA)("UNKNOWN_TYPE","Target type: "+typeof e);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(W.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:e}=(0,d.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:t}=(0,d.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(t),new Error(t)}return t}checkExpiry(e,t){const{expiry:s}=t;(0,h.toMiliseconds)(s)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(W.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(n.li.pulse,()=>this.checkExpirations()),this.events.on(W.created,e=>{const t=W.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(W.expired,e=>{const t=W.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(W.deleted,e=>{const t=W.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=(0,d.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Bs=Object.defineProperty,Hs=(e,t,s)=>((e,t,s)=>t in e?Bs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Ws extends c.zl{constructor(e,t,s){super(e,t,s),this.core=e,this.logger=t,this.store=s,Hs(this,"name","verify-api"),Hs(this,"abortController"),Hs(this,"isDevEnv"),Hs(this,"verifyUrlV3",F),Hs(this,"storagePrefix",v),Hs(this,"version",2),Hs(this,"publicKey"),Hs(this,"fetchPromise"),Hs(this,"init",async()=>{var e;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,h.toMiliseconds)(null==(e=this.publicKey)?void 0:e.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),Hs(this,"register",async e=>{if(!(0,d.BdH)()||this.isDevEnv)return;const t=window.location.origin,{id:s,decryptedId:i}=e,r=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${t}&id=${s}&decryptedId=${i}`;try{const e=(0,w.getDocument)(),t=this.startAbortTimer(5*h.ONE_SECOND),i=await new Promise((i,n)=>{const o=()=>{window.removeEventListener("message",c),e.body.removeChild(a),n("attestation aborted")};this.abortController.signal.addEventListener("abort",o);const a=e.createElement("iframe");a.src=r,a.style.display="none",a.addEventListener("error",o,{signal:this.abortController.signal});const c=r=>{if(r.data&&"string"==typeof r.data)try{const n=JSON.parse(r.data);if("verify_attestation"===n.type){if((0,p.Cq)(n.attestation).payload.id!==s)return;clearInterval(t),e.body.removeChild(a),this.abortController.signal.removeEventListener("abort",o),window.removeEventListener("message",c),i(null===n.attestation?"":n.attestation)}}catch(e){this.logger.warn(e)}};e.body.appendChild(a),window.addEventListener("message",c,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",i),i}catch(e){this.logger.warn(e)}return""}),Hs(this,"resolve",async e=>{if(this.isDevEnv)return"";const{attestationId:t,hash:s,encryptedId:i}=e;if(""===t)return void this.logger.debug("resolve: attestationId is empty, skipping");if(t){if((0,p.Cq)(t).payload.id!==i)return;const e=await this.isValidJwtAttestation(t);if(e)return e.isVerified?e:void this.logger.warn("resolve: jwt attestation: origin url not verified")}if(!s)return;const r=this.getVerifyUrl(e?.verifyUrl);return this.fetchAttestation(s,r)}),Hs(this,"fetchAttestation",async(e,t)=>{this.logger.debug(`resolving attestation: ${e} from url: ${t}`);const s=this.startAbortTimer(5*h.ONE_SECOND),i=await fetch(`${t}/attestation/${e}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(s),200===i.status?await i.json():void 0}),Hs(this,"getVerifyUrl",e=>{let t=e||V;return K.includes(t)||(this.logger.info(`verify url: ${t}, not included in trusted list, assigning default: ${V}`),t=V),t}),Hs(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const e=this.startAbortTimer(h.FIVE_SECONDS),t=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(e),await t.json()}catch(e){this.logger.warn(e)}}),Hs(this,"persistPublicKey",async e=>{this.logger.debug("persisting public key to local storage",e),await this.store.setItem(this.storeKey,e),this.publicKey=e}),Hs(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),Hs(this,"isValidJwtAttestation",async e=>{const t=await this.getPublicKey();try{if(t)return this.validateAttestation(e,t)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}const s=await this.fetchAndPersistPublicKey();try{if(s)return this.validateAttestation(e,s)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}}),Hs(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),Hs(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async e=>{const t=await this.fetchPublicKey();t&&(await this.persistPublicKey(t),e(t))});const e=await this.fetchPromise;return this.fetchPromise=void 0,e}),Hs(this,"validateAttestation",(e,t)=>{const s=(0,d.U0i)(e,t.publicKey),i={hasExpired:(0,h.toMiliseconds)(s.exp)<Date.now(),payload:s};if(i.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:i.payload.origin,isScam:i.payload.isScam,isVerified:i.payload.isVerified}}),this.logger=(0,a.U5)(t,this.name),this.abortController=new AbortController,this.isDevEnv=(0,d.w8K)(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return(0,a.oI)(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),(0,h.toMiliseconds)(e))}}var zs=Object.defineProperty,Vs=(e,t,s)=>((e,t,s)=>t in e?zs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s)(e,"symbol"!=typeof t?t+"":t,s);class Fs extends c.GF{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,Vs(this,"context","echo"),Vs(this,"registerDeviceToken",async e=>{const{clientId:t,token:s,notificationType:i,enableEncrypted:r=!1}=e,n=`https://echo.walletconnect.com/${this.projectId}/clients`;await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:t,type:i,token:s,always_raw:r})})}),this.logger=(0,a.U5)(t,this.context)}}var Ks=Object.defineProperty,Gs=Object.getOwnPropertySymbols,Js=Object.prototype.hasOwnProperty,Ys=Object.prototype.propertyIsEnumerable,Qs=(e,t,s)=>t in e?Ks(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,Xs=(e,t)=>{for(var s in t||(t={}))Js.call(t,s)&&Qs(e,s,t[s]);if(Gs)for(var s of Gs(t))Ys.call(t,s)&&Qs(e,s,t[s]);return e},Zs=(e,t,s)=>Qs(e,"symbol"!=typeof t?t+"":t,s);class ei extends c.$Q{constructor(e,t,s=!0){super(e,t,s),this.core=e,this.logger=t,Zs(this,"context","event-client"),Zs(this,"storagePrefix",v),Zs(this,"storageVersion",.1),Zs(this,"events",new Map),Zs(this,"shouldPersist",!1),Zs(this,"init",async()=>{if(!(0,d.w8K)())try{const e={eventId:(0,d.gZm)(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:(0,d.ojD)(this.core.relayer.protocol,this.core.relayer.version,x)}}};await this.sendEvent([e])}catch(e){this.logger.warn(e)}}),Zs(this,"createEvent",e=>{const{event:t="ERROR",type:s="",properties:{topic:i,trace:r}}=e,n=(0,d.gZm)(),o=this.core.projectId||"",a=Date.now(),c=Xs({eventId:n,timestamp:a,props:{event:t,type:s,properties:{topic:i,trace:r}},bundleId:o,domain:this.getAppDomain()},this.setMethods(n));return this.telemetryEnabled&&(this.events.set(n,c),this.shouldPersist=!0),c}),Zs(this,"getEvent",e=>{const{eventId:t,topic:s}=e;if(t)return this.events.get(t);const i=Array.from(this.events.values()).find(e=>e.props.properties.topic===s);return i?Xs(Xs({},i),this.setMethods(i.eventId)):void 0}),Zs(this,"deleteEvent",e=>{const{eventId:t}=e;this.events.delete(t),this.shouldPersist=!0}),Zs(this,"setEventListeners",()=>{this.core.heartbeat.on(n.li.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(e=>{(0,h.fromMiliseconds)(Date.now())-(0,h.fromMiliseconds)(e.timestamp)>86400&&(this.events.delete(e.eventId),this.shouldPersist=!0)})})}),Zs(this,"setMethods",e=>({addTrace:t=>this.addTrace(e,t),setError:t=>this.setError(e,t)})),Zs(this,"addTrace",(e,t)=>{const s=this.events.get(e);s&&(s.props.properties.trace.push(t),this.events.set(e,s),this.shouldPersist=!0)}),Zs(this,"setError",(e,t)=>{const s=this.events.get(e);s&&(s.props.type=t,s.timestamp=Date.now(),this.events.set(e,s),this.shouldPersist=!0)}),Zs(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),Zs(this,"restore",async()=>{try{const e=await this.core.storage.getItem(this.storageKey)||[];if(!e.length)return;e.forEach(e=>{this.events.set(e.eventId,Xs(Xs({},e),this.setMethods(e.eventId)))})}catch(e){this.logger.warn(e)}}),Zs(this,"submit",async()=>{if(!this.telemetryEnabled||0===this.events.size)return;const e=[];for(const[t,s]of this.events)s.props.type&&e.push(s);if(0!==e.length)try{if((await this.sendEvent(e)).ok)for(const t of e)this.events.delete(t.eventId),this.shouldPersist=!0}catch(e){this.logger.warn(e)}}),Zs(this,"sendEvent",async e=>{const t=this.getAppDomain()?"":"&sp=desktop";return await fetch(`https://pulse.walletconnect.org/batch?projectId=${this.core.projectId}&st=events_sdk&sv=js-${x}${t}`,{method:"POST",body:JSON.stringify(e)})}),Zs(this,"getAppDomain",()=>(0,d.lFF)().url),this.logger=(0,a.U5)(t,this.context),this.telemetryEnabled=s,s?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var ti=Object.defineProperty,si=Object.getOwnPropertySymbols,ii=Object.prototype.hasOwnProperty,ri=Object.prototype.propertyIsEnumerable,ni=(e,t,s)=>t in e?ti(e,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):e[t]=s,oi=(e,t)=>{for(var s in t||(t={}))ii.call(t,s)&&ni(e,s,t[s]);if(si)for(var s of si(t))ri.call(t,s)&&ni(e,s,t[s]);return e},ai=(e,t,s)=>ni(e,"symbol"!=typeof t?t+"":t,s);class ci extends c.ZP{constructor(e){var t;super(e),ai(this,"protocol","wc"),ai(this,"version",2),ai(this,"name",b),ai(this,"relayUrl"),ai(this,"projectId"),ai(this,"customStoragePrefix"),ai(this,"events",new i.EventEmitter),ai(this,"logger"),ai(this,"heartbeat"),ai(this,"relayer"),ai(this,"crypto"),ai(this,"storage"),ai(this,"history"),ai(this,"expirer"),ai(this,"pairing"),ai(this,"verify"),ai(this,"echoClient"),ai(this,"linkModeSupportedApps"),ai(this,"eventClient"),ai(this,"initialized",!1),ai(this,"logChunkController"),ai(this,"on",(e,t)=>this.events.on(e,t)),ai(this,"once",(e,t)=>this.events.once(e,t)),ai(this,"off",(e,t)=>this.events.off(e,t)),ai(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),ai(this,"dispatchEnvelope",({topic:e,message:t,sessionExists:s})=>{if(!e||!t)return;const i={topic:e,message:t,publishedAt:Date.now(),transportType:R.link_mode};this.relayer.onLinkMessageEvent(i,{sessionExists:s})}),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||C,this.customStoragePrefix=null!=e&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const s=(0,a.iP)({level:"string"==typeof e?.logger&&e.logger?e.logger:"error",name:b}),{logger:r,chunkLoggerController:c}=(0,a.D5)({opts:s,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=c,null!=(t=this.logChunkController)&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var e,t;null!=(e=this.logChunkController)&&e.downloadLogsBlobInBrowser&&(null==(t=this.logChunkController)||t.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=(0,a.U5)(r,this.name),this.heartbeat=new n.VH,this.crypto=new Pt(this,this.logger,e?.keychain),this.history=new Ms(this,this.logger),this.expirer=new $s(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new o.A(oi(oi({},E),e?.storageOptions)),this.relayer=new fs({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Us(this,this.logger),this.verify=new Ws(this,this.logger,this.storage),this.echoClient=new Fs(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new ei(this,this.logger,e?.telemetryEnabled)}static async init(e){const t=new ci(e);await t.initialize();const s=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",s),t}get context(){return(0,a.oI)(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return null==(e=this.logChunkController)?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(D,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(D)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const hi=ci},99013:(e,t,s)=>{s.d(t,{W:()=>_});var i=s(89168),r=s(39150),n=s(76020),o=s(95191),a=s(87841),c=s(84253),h=s(5813),l=s(11553),p=s(16279),d=s(89058),u=s(50731),g=s(14479),f=s(67018),m=s(16158),w=s(25422),y=s(42831),b=s(16652);const v={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[],user:void 0},E={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},I=(0,i.BX)({chains:(0,r.zC)(),activeCaipAddress:void 0,activeChain:void 0,activeCaipNetwork:void 0,noAdapters:!1,universalAdapter:{networkControllerClient:void 0,connectionControllerClient:void 0},isSwitchingNamespace:!1}),_={state:I,subscribe:e=>(0,i.B1)(I,()=>{e(I)}),subscribeKey:(e,t)=>(0,r.u$)(I,e,t),subscribeChainProp(e,t,s){let r;return(0,i.B1)(I.chains,()=>{const i=s||I.activeChain;if(i){const s=I.chains.get(i)?.[e];r!==s&&(r=s,t(s))}})},initialize(e,t,s){const{chainId:r,namespace:n}=l.i.getActiveNetworkProps(),o=t?.find(e=>e.id.toString()===r?.toString()),a=e.find(e=>e?.namespace===n)||e?.[0],c=new Set([...t?.map(e=>e.chainNamespace)??[]]);0!==e?.length&&a||(I.noAdapters=!0),I.noAdapters||(I.activeChain=a?.namespace,I.activeCaipNetwork=o,this.setChainNetworkData(a?.namespace,{caipNetwork:o}),I.activeChain&&w.z.set({activeChain:a?.namespace})),c.forEach(e=>{const r=t?.filter(t=>t.chainNamespace===e);_.state.chains.set(e,{namespace:e,networkState:(0,i.BX)({...E,caipNetwork:r?.[0]}),accountState:(0,i.BX)(v),caipNetworks:r??[],...s}),this.setRequestedCaipNetworks(r??[],e)})},removeAdapter(e){if(I.activeChain===e){const t=Array.from(I.chains.entries()).find(([t])=>t!==e);if(t){const e=t[1]?.caipNetworks?.[0];e&&this.setActiveCaipNetwork(e)}}I.chains.delete(e)},addAdapter(e,{networkControllerClient:t,connectionControllerClient:s},i){I.chains.set(e.namespace,{namespace:e.namespace,networkState:{...E,caipNetwork:i[0]},accountState:v,caipNetworks:i,connectionControllerClient:s,networkControllerClient:t}),this.setRequestedCaipNetworks(i?.filter(t=>t.chainNamespace===e.namespace)??[],e.namespace)},addNetwork(e){const t=I.chains.get(e.chainNamespace);if(t){const s=[...t.caipNetworks||[]];t.caipNetworks?.find(t=>t.id===e.id)||s.push(e),I.chains.set(e.chainNamespace,{...t,caipNetworks:s}),this.setRequestedCaipNetworks(s,e.chainNamespace)}},removeNetwork(e,t){const s=I.chains.get(e);if(s){const i=I.activeCaipNetwork?.id===t,r=[...s.caipNetworks?.filter(e=>e.id!==t)||[]];i&&s?.caipNetworks?.[0]&&this.setActiveCaipNetwork(s.caipNetworks[0]),I.chains.set(e,{...s,caipNetworks:r}),this.setRequestedCaipNetworks(r||[],e)}},setAdapterNetworkState(e,t){const s=I.chains.get(e);s&&(s.networkState={...s.networkState||E,...t},I.chains.set(e,s))},setChainAccountData(e,t,s=!0){if(!e)throw new Error("Chain is required to update chain account data");const i=I.chains.get(e);if(i){const s={...i.accountState||v,...t};I.chains.set(e,{...i,accountState:s}),1!==I.chains.size&&I.activeChain!==e||(t.caipAddress&&(I.activeCaipAddress=t.caipAddress),p.U.replaceState(s))}},setChainNetworkData(e,t){if(!e)return;const s=I.chains.get(e);if(s){const i={...s.networkState||E,...t};I.chains.set(e,{...s,networkState:i})}},setAccountProp(e,t,s,i=!0){this.setChainAccountData(s,{[e]:t},i),"status"===e&&"disconnected"===t&&s&&u.a.removeConnectorId(s)},setActiveNamespace(e){I.activeChain=e;const t=e?I.chains.get(e):void 0,s=t?.networkState?.caipNetwork;s?.id&&e&&(I.activeCaipAddress=t?.accountState?.caipAddress,I.activeCaipNetwork=s,this.setChainNetworkData(e,{caipNetwork:s}),l.i.setActiveCaipNetworkId(s?.caipNetworkId),w.z.set({activeChain:e,selectedNetworkId:s?.caipNetworkId}))},setActiveCaipNetwork(e){if(!e)return;I.activeChain!==e.chainNamespace&&this.setIsSwitchingNamespace(!0);const t=I.chains.get(e.chainNamespace);I.activeChain=e.chainNamespace,I.activeCaipNetwork=e,this.setChainNetworkData(e.chainNamespace,{caipNetwork:e}),I.activeCaipAddress=t?.accountState?.address?`${e.chainNamespace}:${e.id}:${t?.accountState?.address}`:void 0,this.setAccountProp("caipAddress",I.activeCaipAddress,e.chainNamespace),t&&p.U.replaceState(t.accountState),b.R.resetSend(),w.z.set({activeChain:I.activeChain,selectedNetworkId:I.activeCaipNetwork?.caipNetworkId}),l.i.setActiveCaipNetworkId(e.caipNetworkId),this.checkIfSupportedNetwork(e.chainNamespace)||!m.H.state.enableNetworkSwitch||m.H.state.allowUnsupportedChain||d.x.state.wcBasic||this.showUnsupportedChainUI()},addCaipNetwork(e){if(!e)return;const t=I.chains.get(e.chainNamespace);t&&t?.caipNetworks?.push(e)},async switchActiveNamespace(e){if(!e)return;const t=e!==_.state.activeChain,s=_.getNetworkData(e)?.caipNetwork,i=_.getCaipNetworkByNamespace(e,s?.id);t&&i&&await _.switchActiveNetwork(i)},async switchActiveNetwork(e){const t=_.state.chains.get(_.state.activeChain);!t?.caipNetworks?.some(e=>e.id===I.activeCaipNetwork?.id)&&y.I.goBack();const s=this.getNetworkControllerClient(e.chainNamespace);s&&(await s.switchCaipNetwork(e),g.E.sendEvent({type:"track",event:"SWITCH_NETWORK",properties:{network:e.caipNetworkId}}))},getNetworkControllerClient(e){const t=e||I.activeChain,s=I.chains.get(t);if(!s)throw new Error("Chain adapter not found");if(!s.networkControllerClient)throw new Error("NetworkController client not set");return s.networkControllerClient},getConnectionControllerClient(e){const t=e||I.activeChain;if(!t)throw new Error("Chain is required to get connection controller client");const s=I.chains.get(t);if(!s?.connectionControllerClient)throw new Error("ConnectionController client not set");return s.connectionControllerClient},getAccountProp(e,t){let s=I.activeChain;if(t&&(s=t),!s)return;const i=I.chains.get(s)?.accountState;return i?i[e]:void 0},getNetworkProp(e,t){const s=I.chains.get(t)?.networkState;if(s)return s[e]},getRequestedCaipNetworks(e){const t=I.chains.get(e),{approvedCaipNetworkIds:s=[],requestedCaipNetworks:i=[]}=t?.networkState||{};return h.w.sortRequestedNetworks(s,i)},getAllRequestedCaipNetworks(){const e=[];return I.chains.forEach(t=>{const s=this.getRequestedCaipNetworks(t.namespace);e.push(...s)}),e},setRequestedCaipNetworks(e,t){this.setAdapterNetworkState(t,{requestedCaipNetworks:e})},getAllApprovedCaipNetworkIds(){const e=[];return I.chains.forEach(t=>{const s=this.getApprovedCaipNetworkIds(t.namespace);e.push(...s)}),e},getActiveCaipNetwork:()=>I.activeCaipNetwork,getActiveCaipAddress:()=>I.activeCaipAddress,getApprovedCaipNetworkIds(e){const t=I.chains.get(e);return t?.networkState?.approvedCaipNetworkIds||[]},async setApprovedCaipNetworksData(e){const t=this.getNetworkControllerClient(),s=await(t?.getApprovedCaipNetworksData());this.setAdapterNetworkState(e,{approvedCaipNetworkIds:s?.approvedCaipNetworkIds,supportsAllNetworks:s?.supportsAllNetworks})},checkIfSupportedNetwork(e,t){const s=t||I.activeCaipNetwork,i=this.getRequestedCaipNetworks(e);return!i.length||i?.some(e=>e.id===s?.id)},checkIfSupportedChainId(e){if(!I.activeChain)return!0;const t=this.getRequestedCaipNetworks(I.activeChain);return t?.some(t=>t.id===e)},setSmartAccountEnabledNetworks(e,t){this.setAdapterNetworkState(t,{smartAccountEnabledNetworks:e})},checkIfSmartAccountEnabled(){const e=n.L.caipNetworkIdToNumber(I.activeCaipNetwork?.caipNetworkId),t=I.activeChain;if(!t||!e)return!1;const s=this.getNetworkProp("smartAccountEnabledNetworks",t);return Boolean(s?.includes(Number(e)))},getActiveNetworkTokenAddress(){const e=I.activeCaipNetwork?.chainNamespace||"eip155";return`${e}:${I.activeCaipNetwork?.id||1}:${c.oU.NATIVE_TOKEN_ADDRESS[e]}`},showUnsupportedChainUI(){f.W.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const e=I.activeCaipNetwork;return Boolean(e?.chainNamespace&&c.oU.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(e.chainNamespace))},resetNetwork(e){this.setAdapterNetworkState(e,{approvedCaipNetworkIds:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]})},resetAccount(e){const t=e;if(!t)throw new Error("Chain is required to set account prop");I.activeCaipAddress=void 0,this.setChainAccountData(t,{smartAccountDeployed:!1,currentTab:0,caipAddress:void 0,address:void 0,balance:void 0,balanceSymbol:void 0,profileName:void 0,profileImage:void 0,addressExplorerUrl:void 0,tokenBalance:[],connectedWalletInfo:void 0,preferredAccountType:void 0,socialProvider:void 0,socialWindow:void 0,farcasterUrl:void 0,allAccounts:[],user:void 0,status:"disconnected"}),u.a.removeConnectorId(t)},async disconnect(e){const t=(0,a.g)(e);try{b.R.resetSend();const s=await Promise.allSettled(t.map(async([e,t])=>{try{const{caipAddress:s}=this.getAccountData(e)||{};s&&t.connectionControllerClient?.disconnect&&await t.connectionControllerClient.disconnect(e),this.resetAccount(e),this.resetNetwork(e)}catch(t){throw new Error(`Failed to disconnect chain ${e}: ${t.message}`)}}));d.x.resetWcConnection();const i=s.filter(e=>"rejected"===e.status);if(i.length>0)throw new Error(i.map(e=>e.reason.message).join(", "));l.i.deleteConnectedSocialProvider(),e?u.a.removeConnectorId(e):u.a.resetConnectorIds(),g.E.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:e||"all"}})}catch(e){console.error(e.message||"Failed to disconnect chains"),g.E.sendEvent({type:"track",event:"DISCONNECT_ERROR",properties:{message:e.message||"Failed to disconnect chains"}})}},setIsSwitchingNamespace(e){I.isSwitchingNamespace=e},getFirstCaipNetworkSupportsAuthConnector(){const e=[];let t;if(I.chains.forEach(t=>{o.o.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(e=>e===t.namespace)&&t.namespace&&e.push(t.namespace)}),e.length>0){const s=e[0];return t=s?I.chains.get(s)?.caipNetworks?.[0]:void 0,t}},getAccountData:e=>e?_.state.chains.get(e)?.accountState:p.U.state,getNetworkData(e){const t=e||I.activeChain;if(t)return _.state.chains.get(t)?.networkState},getCaipNetworkByNamespace(e,t){if(!e)return;const s=_.state.chains.get(e),i=s?.caipNetworks?.find(e=>e.id===t);return i||s?.networkState?.caipNetwork||s?.caipNetworks?.[0]},getRequestedCaipNetworkIds(){const e=u.a.state.filterByNamespace;return(e?[I.chains.get(e)]:Array.from(I.chains.values())).flatMap(e=>e?.caipNetworks||[]).map(e=>e.caipNetworkId)}}},99057:(e,t,s)=>{s(70255),s(64264),s(93786),s(14350),s(50046),s(48526).hp,Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable,Object.defineProperty,Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable}};
|
|
878
|
+
`},24313:(e,t,i)=>{i.d(t,{g:()=>p});var s=i(95191),r=i(99013),n=i(89058),o=i(50731),a=i(40868),c=i(16158),h=i(5813),d=i(11553),l=i(28127),u=i(38753);const p={getConnectorsByType(e,t,i){const{customWallets:s}=c.H.state,r=d.i.getRecentWallets(),n=u.A.filterOutDuplicateWallets(t),o=u.A.filterOutDuplicateWallets(i),a=e.filter(e=>"MULTI_CHAIN"===e.type),h=e.filter(e=>"ANNOUNCED"===e.type),l=e.filter(e=>"INJECTED"===e.type);return{custom:s,recent:r,external:e.filter(e=>"EXTERNAL"===e.type),multiChain:a,announced:h,injected:l,recommended:n,featured:o}},showConnector(e){const t=e.info?.rdns,i=Boolean(t)&&a.N.state.excludedWallets.some(e=>e.rdns===t),s=Boolean(e.name)&&a.N.state.excludedWallets.some(t=>l.y.isLowerCaseMatch(t.name,e.name));if("INJECTED"===e.type){if(!h.w.isMobile()&&"Browser Wallet"===e.name)return!1;if(!t&&!n.x.checkInstalled())return!1;if(i||s)return!1}return"ANNOUNCED"!==e.type||!i&&!s},getIsConnectedWithWC:()=>Array.from(r.W.state.chains.values()).some(e=>o.a.getConnectorId(e.namespace)===s.o.CONNECTOR_ID.WALLET_CONNECT),getConnectorTypeOrder({recommended:e,featured:t,custom:i,recent:s,announced:r,injected:n,multiChain:o,external:a,overriddenConnectors:h=c.H.state.features?.connectorTypeOrder??[]}){const d=p.getIsConnectedWithWC(),l=[{type:"walletConnect",isEnabled:c.H.state.enableWalletConnect&&!d},{type:"recent",isEnabled:s.length>0},{type:"injected",isEnabled:[...n,...r,...o].length>0},{type:"featured",isEnabled:t.length>0},{type:"custom",isEnabled:i&&i.length>0},{type:"external",isEnabled:a.length>0},{type:"recommended",isEnabled:e.length>0}].filter(e=>e.isEnabled),u=new Set(l.map(e=>e.type)),f=h.filter(e=>u.has(e)).map(e=>({type:e,isEnabled:!0})),g=l.filter(({type:e})=>!f.some(({type:t})=>t===e));return Array.from(new Set([...f,...g].map(({type:e})=>e)))}}},24529:(e,t,i)=>{i.d(t,{E:()=>s});const s={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603}},24537:(e,t,i)=>{i.d(t,{U:()=>g}),i(99057);var s=i(95191),r=i(9663),n=i(16279),o=i(99013),a=i(89058),c=i(50731),h=i(14479),d=i(44637),l=i(16158),u=i(42831),p=i(41430),f=i(5813);const g={getSIWX:()=>l.H.state.siwx,async initializeIfEnabled(){const e=l.H.state.siwx,t=o.W.getActiveCaipAddress();if(!e||!t)return;const[i,s,r]=t.split(":");if(o.W.checkIfSupportedNetwork(i))try{if((await e.getSessions(`${i}:${s}`,r)).length)return;await d.W.open({view:"SIWXSignMessage"})}catch(e){console.error("SIWXUtil:initializeIfEnabled",e),h.E.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties()}),await(a.x._getClient()?.disconnect().catch(console.error)),u.I.reset("Connect"),p.P.showError("A problem occurred while trying initialize authentication")}},async requestSignMessage(){const e=l.H.state.siwx,t=f.w.getPlainAddress(o.W.getActiveCaipAddress()),i=o.W.getActiveCaipNetwork(),r=a.x._getClient();if(!e)throw new Error("SIWX is not enabled");if(!t)throw new Error("No ActiveCaipAddress found");if(!i)throw new Error("No ActiveCaipNetwork or client found");if(!r)throw new Error("No ConnectionController client found");try{const n=await e.createMessage({chainId:i.caipNetworkId,accountAddress:t}),o=n.toString();c.a.getConnectorId(i.chainNamespace)===s.o.CONNECTOR_ID.AUTH&&u.I.pushTransactionStack({view:null,goBack:!1,replace:!0});const a=await r.signMessage(o);await e.addSession({data:n,message:o,signature:a}),d.W.close(),h.E.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:this.getSIWXEventProperties()})}catch(e){const t=this.getSIWXEventProperties();d.W.state.open&&"ApproveTransaction"!==u.I.state.view||await d.W.open({view:"SIWXSignMessage"}),t.isSmartAccount?p.P.showError("This application might not support Smart Accounts"):p.P.showError("Signature declined"),h.E.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:t}),console.error("SWIXUtil:requestSignMessage",e)}},async cancelSignMessage(){try{const e=this.getSIWX(),t=e?.getRequired?.();t?await a.x.disconnect():d.W.close(),u.I.reset("Connect"),h.E.sendEvent({event:"CLICK_CANCEL_SIWX",type:"track",properties:this.getSIWXEventProperties()})}catch(e){console.error("SIWXUtil:cancelSignMessage",e)}},async getSessions(){const e=l.H.state.siwx,t=f.w.getPlainAddress(o.W.getActiveCaipAddress()),i=o.W.getActiveCaipNetwork();return e&&t&&i?e.getSessions(i.caipNetworkId,t):[]},async isSIWXCloseDisabled(){const e=this.getSIWX();if(e){const t="ApproveTransaction"===u.I.state.view,i="SIWXSignMessage"===u.I.state.view;if(t||i)return e.getRequired?.()&&0===(await this.getSessions()).length}return!1},async universalProviderAuthenticate({universalProvider:e,chains:t,methods:i}){const s=g.getSIWX(),r=new Set(t.map(e=>e.split(":")[0]));if(!s||1!==r.size||!r.has("eip155"))return!1;const a=await s.createMessage({chainId:o.W.getActiveCaipNetwork()?.caipNetworkId||"",accountAddress:""}),c=await e.authenticate({nonce:a.nonce,domain:a.domain,uri:a.uri,exp:a.expirationTime,iat:a.issuedAt,nbf:a.notBefore,requestId:a.requestId,version:a.version,resources:a.resources,statement:a.statement,chainId:a.chainId,methods:i,chains:[a.chainId,...t.filter(e=>e!==a.chainId)]});if(p.P.showLoading("Authenticating...",{autoClose:!1}),n.U.setConnectedWalletInfo({...c.session.peer.metadata,name:c.session.peer.metadata.name,icon:c.session.peer.metadata.icons?.[0],type:"WALLET_CONNECT"},Array.from(r)[0]),c?.auths?.length){const t=c.auths.map(t=>{const i=e.client.formatAuthMessage({request:t.p,iss:t.p.iss});return{data:{...t.p,accountAddress:t.p.iss.split(":").slice(-1).join(""),chainId:t.p.iss.split(":").slice(2,4).join(":"),uri:t.p.aud,version:t.p.version||a.version,expirationTime:t.p.exp,issuedAt:t.p.iat,notBefore:t.p.nbf},message:i,signature:t.s.s,cacao:t}});try{await s.setSessions(t),h.E.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:g.getSIWXEventProperties()})}catch(t){throw console.error("SIWX:universalProviderAuth - failed to set sessions",t),h.E.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:g.getSIWXEventProperties()}),await e.disconnect().catch(console.error),t}finally{p.P.hide()}}return!0},getSIWXEventProperties:()=>({network:o.W.state.activeCaipNetwork?.caipNetworkId||"",isSmartAccount:n.U.state.preferredAccountType===r.Vl.ACCOUNT_TYPES.SMART_ACCOUNT}),async clearSessions(){const e=this.getSIWX();e&&await e.setSessions([])}}},25422:(e,t,i)=>{i.d(t,{z:()=>n});var s=i(89168);const r=(0,s.BX)({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),n={state:r,subscribe:e=>(0,s.B1)(r,()=>e(r)),set(e){Object.assign(r,{...r,...e})}}},26097:(e,t,i)=>{i.d(t,{W:()=>n});var s=i(95191),r=i(99013);const n={handleSolanaDeeplinkRedirect(e){if(r.W.state.activeChain===s.o.CHAIN.SOLANA){const t=window.location.href,i=encodeURIComponent(t);if("Phantom"===e&&!("phantom"in window)){const e=t.startsWith("https")?"https":"http",s=t.split("/")[2],r=encodeURIComponent(`${e}://${s}`);window.location.href=`https://phantom.app/ul/browse/${i}?ref=${r}`}"Coinbase Wallet"!==e||"coinbaseSolana"in window||(window.location.href=`https://go.cb-w.com/dapp?cb_url=${i}`)}}}},26545:(e,t,i)=>{i.d(t,{W:()=>a});var s=i(89168),r=i(11807),n=i(50731);const o=(0,s.BX)({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),a={state:o,subscribe:e=>(0,s.B1)(o,()=>e(o)),setThemeMode(e){o.themeMode=e;try{const t=n.a.getAuthConnector();if(t){const i=a.getSnapshot().themeVariables;t.provider.syncTheme({themeMode:e,themeVariables:i,w3mThemeVariables:(0,r.o)(i,e)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(e){o.themeVariables={...o.themeVariables,...e};try{const e=n.a.getAuthConnector();if(e){const t=a.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:t,w3mThemeVariables:(0,r.o)(o.themeVariables,o.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot:()=>(0,s.P9)(o)}},27006:(e,t,i)=>{i.d(t,{T:()=>g});var s=i(89168),r=i(84253),n=i(5813),o=i(19760),a=i(11553),c=i(16279),h=i(99013),d=i(16158),l=i(41430);const u={purchaseCurrencies:[{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"Ether",symbol:"ETH",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]}],paymentCurrencies:[{id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},{id:"EUR",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]}]},p=n.w.getBlockchainApiUrl(),f=(0,s.BX)({clientId:null,api:new o.Z({baseUrl:p,clientId:null}),supportedChains:{http:[],ws:[]}}),g={state:f,async get(e){const{st:t,sv:i}=g.getSdkProperties(),s=d.H.state.projectId,r={...e.params||{},st:t,sv:i,projectId:s};return f.api.get({...e,params:r})},getSdkProperties(){const{sdkType:e,sdkVersion:t}=d.H.state;return{st:e||"unknown",sv:t||"unknown"}},async isNetworkSupported(e){if(!e)return!1;try{f.supportedChains.http.length||await g.getSupportedNetworks()}catch(e){return!1}return f.supportedChains.http.includes(e)},async getSupportedNetworks(){const e=await g.get({path:"v1/supported-chains"});return f.supportedChains=e,e},async fetchIdentity({address:e,caipNetworkId:t}){if(!await g.isNetworkSupported(t))return{avatar:"",name:""};const i=a.i.getIdentityFromCacheForAddress(e);if(i)return i;const s=await g.get({path:`/v1/identity/${e}`,params:{sender:h.W.state.activeCaipAddress?n.w.getPlainAddress(h.W.state.activeCaipAddress):void 0}});return a.i.updateIdentityCache({address:e,identity:s,timestamp:Date.now()}),s},fetchTransactions:async({account:e,cursor:t,onramp:i,signal:s,cache:r,chainId:n})=>await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?g.get({path:`/v1/account/${e}/history`,params:{cursor:t,onramp:i,chainId:n},signal:s,cache:r}):{data:[],next:void 0},fetchSwapQuote:async({amount:e,userAddress:t,from:i,to:s,gasPrice:r})=>await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?g.get({path:"/v1/convert/quotes",headers:{"Content-Type":"application/json"},params:{amount:e,userAddress:t,from:i,to:s,gasPrice:r}}):{quotes:[]},fetchSwapTokens:async({chainId:e})=>await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?g.get({path:"/v1/convert/tokens",params:{chainId:e}}):{tokens:[]},fetchTokenPrice:async({addresses:e})=>await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.api.post({path:"/v1/fungible/price",body:{currency:"usd",addresses:e,projectId:d.H.state.projectId},headers:{"Content-Type":"application/json"}}):{fungibles:[]},fetchSwapAllowance:async({tokenAddress:e,userAddress:t})=>await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?g.get({path:"/v1/convert/allowance",params:{tokenAddress:e,userAddress:t},headers:{"Content-Type":"application/json"}}):{allowance:"0"},async fetchGasPrice({chainId:e}){const{st:t,sv:i}=g.getSdkProperties();if(!await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Gas Price");return g.get({path:"/v1/convert/gas-price",headers:{"Content-Type":"application/json"},params:{chainId:e,st:t,sv:i}})},async generateSwapCalldata({amount:e,from:t,to:i,userAddress:s,disableEstimate:n}){if(!await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Swaps");return f.api.post({path:"/v1/convert/build-transaction",headers:{"Content-Type":"application/json"},body:{amount:e,eip155:{slippage:r.oU.CONVERT_SLIPPAGE_TOLERANCE},projectId:d.H.state.projectId,from:t,to:i,userAddress:s,disableEstimate:n}})},async generateApproveCalldata({from:e,to:t,userAddress:i}){const{st:s,sv:r}=g.getSdkProperties();if(!await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Swaps");return g.get({path:"/v1/convert/build-approve",headers:{"Content-Type":"application/json"},params:{userAddress:i,from:e,to:t,st:s,sv:r}})},async getBalance(e,t,i){const{st:s,sv:r}=g.getSdkProperties();if(!await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId))return l.P.showError("Token Balance Unavailable"),{balances:[]};const n=`${t}:${e}`,o=a.i.getBalanceCacheForCaipAddress(n);if(o)return o;const c=await g.get({path:`/v1/account/${e}/balance`,params:{currency:"usd",chainId:t,forceUpdate:i,st:s,sv:r}});return a.i.updateBalanceCache({caipAddress:n,balance:c,timestamp:Date.now()}),c},lookupEnsName:async e=>await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?g.get({path:`/v1/profile/account/${e}`,params:{apiVersion:"2"}}):{addresses:{},attributes:[]},reverseLookupEnsName:async({address:e})=>await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?g.get({path:`/v1/profile/reverse/${e}`,params:{sender:c.U.state.address,apiVersion:"2"}}):[],getEnsNameSuggestions:async e=>await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?g.get({path:`/v1/profile/suggestions/${e}`,params:{zone:"reown.id"}}):{suggestions:[]},registerEnsName:async({coinType:e,address:t,message:i,signature:s})=>await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.api.post({path:"/v1/profile/account",body:{coin_type:e,address:t,message:i,signature:s},headers:{"Content-Type":"application/json"}}):{success:!1},generateOnRampURL:async({destinationWallets:e,partnerUserId:t,defaultNetwork:i,purchaseAmount:s,paymentAmount:r})=>await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?(await f.api.post({path:"/v1/generators/onrampurl",params:{projectId:d.H.state.projectId},body:{destinationWallets:e,defaultNetwork:i,partnerUserId:t,defaultExperience:"buy",presetCryptoAmount:s,presetFiatAmount:r}})).url:"",async getOnrampOptions(){if(!await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await g.get({path:"/v1/onramp/options"})}catch(e){return u}},async getOnrampQuote({purchaseCurrency:e,paymentCurrency:t,amount:i,network:s}){try{return await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?await f.api.post({path:"/v1/onramp/quote",params:{projectId:d.H.state.projectId},body:{purchaseCurrency:e,paymentCurrency:t,amount:i,network:s}}):null}catch(e){return{coinbaseFee:{amount:i,currency:t.id},networkFee:{amount:i,currency:t.id},paymentSubtotal:{amount:i,currency:t.id},paymentTotal:{amount:i,currency:t.id},purchaseAmount:{amount:i,currency:t.id},quoteId:"mocked-quote-id"}}},getSmartSessions:async e=>await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?g.get({path:`/v1/sessions/${e}`}):[],revokeSmartSession:async(e,t,i)=>await g.isNetworkSupported(h.W.state.activeCaipNetwork?.caipNetworkId)?f.api.post({path:`/v1/sessions/${e}/revoke`,params:{projectId:d.H.state.projectId},body:{pci:t,signature:i}}):{success:!1},setClientId(e){f.clientId=e,f.api=new o.Z({baseUrl:p,clientId:e})}}},27305:(e,t,i)=>{function s(e){return function(t){return"function"==typeof t?function(e,t){return customElements.get(e)||customElements.define(e,t),t}(e,t):function(e,t){const{kind:i,elements:s}=t;return{kind:i,elements:s,finisher(t){customElements.get(e)||customElements.define(e,t)}}}(e,t)}}i.d(t,{E:()=>s})},27938:(e,t,i)=>{i.d(t,{h:()=>a});var s=i(89168),r=i(39150),n=i(16158);const o=(0,s.BX)({message:"",variant:"info",open:!1}),a={state:o,subscribeKey:(e,t)=>(0,r.u$)(o,e,t),open(e,t){const{debug:i}=n.H.state,{shortMessage:s,longMessage:r}=e;i&&(o.message=s,o.variant=t,o.open=!0),r&&console.error("function"==typeof r?r():r)},close(){o.open=!1,o.message="",o.variant="info"}}},28127:(e,t,i)=>{i.d(t,{y:()=>r});var s=i(98207);const r={getCaipTokens(e){if(!e)return;const t={};return Object.entries(e).forEach(([e,i])=>{t[`${s.o.EIP155}:${e}`]=i}),t},isLowerCaseMatch:(e,t)=>e?.toLowerCase()===t?.toLowerCase()}},29864:(e,t,i)=>{i.d(t,{f:()=>f});var s=i(89168),r=i(39150),n=i(78760),o=i(11553),a=i(16279),c=i(27006),h=i(99013),d=i(89058),l=i(50731),u=i(42831);const p=(0,s.BX)({suggestions:[],loading:!1}),f={state:p,subscribe:e=>(0,s.B1)(p,()=>e(p)),subscribeKey:(e,t)=>(0,r.u$)(p,e,t),async resolveName(e){try{return await c.T.lookupEnsName(e)}catch(e){const t=e;throw new Error(t?.reasons?.[0]?.description||"Error resolving name")}},async isNameRegistered(e){try{return await c.T.lookupEnsName(e),!0}catch{return!1}},async getSuggestions(e){try{p.loading=!0,p.suggestions=[];const t=await c.T.getEnsNameSuggestions(e);return p.suggestions=t.suggestions.map(e=>({...e,name:e.name}))||[],p.suggestions}catch(e){const t=this.parseEnsApiError(e,"Error fetching name suggestions");throw new Error(t)}finally{p.loading=!1}},async getNamesForAddress(e){try{if(!h.W.state.activeCaipNetwork)return[];const t=o.i.getEnsFromCacheForAddress(e);if(t)return t;const i=await c.T.reverseLookupEnsName({address:e});return o.i.updateEnsCache({address:e,ens:i,timestamp:Date.now()}),i}catch(e){const t=this.parseEnsApiError(e,"Error fetching names for address");throw new Error(t)}},async registerName(e){const t=h.W.state.activeCaipNetwork;if(!t)throw new Error("Network not found");const i=a.U.state.address,s=l.a.getAuthConnector();if(!i||!s)throw new Error("Address or auth connector not found");p.loading=!0;try{const s=JSON.stringify({name:e,attributes:{},timestamp:Math.floor(Date.now()/1e3)});u.I.pushTransactionStack({view:"RegisterAccountNameSuccess",goBack:!1,replace:!0,onCancel(){p.loading=!1}});const r=await d.x.signMessage(s),o=t.id;if(!o)throw new Error("Network not found");const h=n.p.convertEVMChainIdToCoinType(Number(o));await c.T.registerEnsName({coinType:h,address:i,signature:r,message:s}),a.U.setProfileName(e,t.chainNamespace),u.I.replace("RegisterAccountNameSuccess")}catch(t){const i=this.parseEnsApiError(t,`Error registering name ${e}`);throw u.I.replace("RegisterAccountName"),new Error(i)}finally{p.loading=!1}},validateName:e=>/^[a-zA-Z0-9-]{4,}$/u.test(e),parseEnsApiError(e,t){const i=e;return i?.reasons?.[0]?.description||t}}},29967:(e,t,i)=>{var s=i(70461),r=i(92157);function n(){if(!(this instanceof n))return new n;r.call(this),this.h=[3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]}s.inherits(n,r),e.exports=n,n.blockSize=1024,n.outSize=384,n.hmacStrength=192,n.padLength=128,n.prototype._digest=function(e){return"hex"===e?s.toHex32(this.h.slice(0,12),"big"):s.split32(this.h.slice(0,12),"big")}},30183:e=>{e.exports={rE:"6.6.1"}},30544:(e,t,i)=>{i.d(t,{Rn0:()=>s.Rn0,gTy:()=>s.gTy,tWt:()=>s.tWt});var s=i(55164)},31575:(e,t,i)=>{i.d(t,{Ay:()=>K});var s=i(11629),r=i(70255),n=i(3665),o=i(91315),a=i(76754),c=i(50046),h=i.n(c),d=i(14350);const l="client",u=`wc@2:${l}:`,p=l,f="WALLETCONNECT_DEEPLINK_CHOICE",g="Proposal expired",m=o.SEVEN_DAYS,b={wc_sessionPropose:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1104},res:{ttl:o.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1106},res:{ttl:o.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1112},res:{ttl:o.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1114},res:{ttl:o.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:o.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:o.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1119}}},y={min:o.FIVE_MINUTES,max:o.SEVEN_DAYS},w="IDLE",v="ACTIVE",I={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},E=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],_="wc@1.5:auth:",A=`${_}:PUB_KEY`;var N=Object.defineProperty,C=Object.defineProperties,S=Object.getOwnPropertyDescriptors,P=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,x=(e,t,i)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,k=(e,t)=>{for(var i in t||(t={}))O.call(t,i)&&x(e,i,t[i]);if(P)for(var i of P(t))T.call(t,i)&&x(e,i,t[i]);return e},R=(e,t)=>C(e,S(t)),M=(e,t,i)=>x(e,"symbol"!=typeof t?t+"":t,i);class U extends n.yJ{constructor(e){super(e),M(this,"name","engine"),M(this,"events",new(h())),M(this,"initialized",!1),M(this,"requestQueue",{state:w,queue:[]}),M(this,"sessionRequestQueue",{state:w,queue:[]}),M(this,"requestQueueDelay",o.ONE_SECOND),M(this,"expectedPairingMethodMap",new Map),M(this,"recentlyDeletedMap",new Map),M(this,"recentlyDeletedLimit",200),M(this,"relayMessageCache",[]),M(this,"pendingSessions",new Map),M(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(b)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,o.toMiliseconds)(this.requestQueueDelay)))}),M(this,"connect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const t=R(k({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);const{pairingTopic:i,requiredNamespaces:r,optionalNamespaces:n,sessionProperties:c,relays:h}=t;let l,u=i,p=!1;try{if(u){const e=this.client.core.pairing.pairings.get(u);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),p=e.active}}catch(e){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),e}if(!u||!p){const{topic:e,uri:t}=await this.client.core.pairing.create();u=e,l=t}if(!u){const{message:e}=(0,a.GuA)("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(e)}const f=await this.client.core.crypto.generateKeyPair(),m=b.wc_sessionPropose.req.ttl||o.FIVE_MINUTES,y=(0,a.Xw0)(m),w=R(k({requiredNamespaces:r,optionalNamespaces:n,relays:h??[{protocol:s.sD}],proposer:{publicKey:f,metadata:this.client.metadata},expiryTimestamp:y,pairingTopic:u},c&&{sessionProperties:c}),{id:(0,d.payloadId)()}),v=(0,a.hEn)("session_connect",w.id),{reject:I,resolve:E,done:_}=(0,a.Wx8)(m,g),A=({id:e})=>{e===w.id&&(this.client.events.off("proposal_expire",A),this.pendingSessions.delete(w.id),this.events.emit(v,{error:{message:g,code:0}}))};return this.client.events.on("proposal_expire",A),this.events.once(v,({error:e,session:t})=>{this.client.events.off("proposal_expire",A),e?I(e):t&&E(t)}),await this.sendRequest({topic:u,method:"wc_sessionPropose",params:w,throwOnFailedPublish:!0,clientRpcId:w.id}),await this.setProposal(w.id,w),{uri:l,approval:_}}),M(this,"pair",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(e)}catch(e){throw this.client.logger.error("pair() failed"),e}}),M(this,"approve",async e=>{var t,i,r;const n=this.client.core.eventClient.createEvent({properties:{topic:null==(t=e?.id)?void 0:t.toString(),trace:[s.$I.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(e){throw n.setError(s.U.no_internet_connection),e}try{await this.isValidProposalId(e?.id)}catch(t){throw this.client.logger.error(`approve() -> proposal.get(${e?.id}) failed`),n.setError(s.U.proposal_not_found),t}try{await this.isValidApprove(e)}catch(e){throw this.client.logger.error("approve() -> isValidApprove() failed"),n.setError(s.U.session_approve_namespace_validation_failure),e}const{id:o,relayProtocol:c,namespaces:h,sessionProperties:d,sessionConfig:l}=e,u=this.client.proposal.get(o);this.client.core.eventClient.deleteEvent({eventId:n.eventId});const{pairingTopic:p,proposer:f,requiredNamespaces:g,optionalNamespaces:b}=u;let y=null==(i=this.client.core.eventClient)?void 0:i.getEvent({topic:p});y||(y=null==(r=this.client.core.eventClient)?void 0:r.createEvent({type:s.$I.session_approve_started,properties:{topic:p,trace:[s.$I.session_approve_started,s.$I.session_namespaces_validation_success]}}));const w=await this.client.core.crypto.generateKeyPair(),v=f.publicKey,I=await this.client.core.crypto.generateSharedKey(w,v),E=k(k({relay:{protocol:c??"irn"},namespaces:h,controller:{publicKey:w,metadata:this.client.metadata},expiry:(0,a.Xw0)(m)},d&&{sessionProperties:d}),l&&{sessionConfig:l}),_=s.cV.relay;y.addTrace(s.$I.subscribing_session_topic);try{await this.client.core.relayer.subscribe(I,{transportType:_})}catch(e){throw y.setError(s.U.subscribe_session_topic_failure),e}y.addTrace(s.$I.subscribe_session_topic_success);const A=R(k({},E),{topic:I,requiredNamespaces:g,optionalNamespaces:b,pairingTopic:p,acknowledged:!1,self:E.controller,peer:{publicKey:f.publicKey,metadata:f.metadata},controller:w,transportType:s.cV.relay});await this.client.session.set(I,A),y.addTrace(s.$I.store_session);try{y.addTrace(s.$I.publishing_session_settle),await this.sendRequest({topic:I,method:"wc_sessionSettle",params:E,throwOnFailedPublish:!0}).catch(e=>{throw y?.setError(s.U.session_settle_publish_failure),e}),y.addTrace(s.$I.session_settle_publish_success),y.addTrace(s.$I.publishing_session_approve),await this.sendResult({id:o,topic:p,result:{relay:{protocol:c??"irn"},responderPublicKey:w},throwOnFailedPublish:!0}).catch(e=>{throw y?.setError(s.U.session_approve_publish_failure),e}),y.addTrace(s.$I.session_approve_publish_success)}catch(e){throw this.client.logger.error(e),this.client.session.delete(I,(0,a.Hjj)("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(I),e}return this.client.core.eventClient.deleteEvent({eventId:y.eventId}),await this.client.core.pairing.updateMetadata({topic:p,metadata:f.metadata}),await this.client.proposal.delete(o,(0,a.Hjj)("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:p}),await this.setExpiry(I,(0,a.Xw0)(m)),{topic:I,acknowledged:()=>Promise.resolve(this.client.session.get(I))}}),M(this,"reject",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(e)}catch(e){throw this.client.logger.error("reject() -> isValidReject() failed"),e}const{id:t,reason:i}=e;let s;try{s=this.client.proposal.get(t).pairingTopic}catch(e){throw this.client.logger.error(`reject() -> proposal.get(${t}) failed`),e}s&&(await this.sendError({id:t,topic:s,error:i,rpcOpts:b.wc_sessionPropose.reject}),await this.client.proposal.delete(t,(0,a.Hjj)("USER_DISCONNECTED")))}),M(this,"update",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(e)}catch(e){throw this.client.logger.error("update() -> isValidUpdate() failed"),e}const{topic:t,namespaces:i}=e,{done:s,resolve:r,reject:n}=(0,a.Wx8)(),o=(0,d.payloadId)(),c=(0,d.getBigIntRpcId)().toString(),h=this.client.session.get(t).namespaces;return this.events.once((0,a.hEn)("session_update",o),({error:e})=>{e?n(e):r()}),await this.client.session.update(t,{namespaces:i}),await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:i},throwOnFailedPublish:!0,clientRpcId:o,relayRpcId:c}).catch(e=>{this.client.logger.error(e),this.client.session.update(t,{namespaces:h}),n(e)}),{acknowledged:s}}),M(this,"extend",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(e)}catch(e){throw this.client.logger.error("extend() -> isValidExtend() failed"),e}const{topic:t}=e,i=(0,d.payloadId)(),{done:s,resolve:r,reject:n}=(0,a.Wx8)();return this.events.once((0,a.hEn)("session_extend",i),({error:e})=>{e?n(e):r()}),await this.setExpiry(t,(0,a.Xw0)(m)),this.sendRequest({topic:t,method:"wc_sessionExtend",params:{},clientRpcId:i,throwOnFailedPublish:!0}).catch(e=>{n(e)}),{acknowledged:s}}),M(this,"request",async e=>{this.isInitialized();try{await this.isValidRequest(e)}catch(e){throw this.client.logger.error("request() -> isValidRequest() failed"),e}const{chainId:t,request:i,topic:r,expiry:n=b.wc_sessionRequest.req.ttl}=e,o=this.client.session.get(r);o?.transportType===s.cV.relay&&await this.confirmOnlineStateOrThrow();const c=(0,d.payloadId)(),h=(0,d.getBigIntRpcId)().toString(),{done:l,resolve:u,reject:p}=(0,a.Wx8)(n,"Request expired. Please try again.");this.events.once((0,a.hEn)("session_request",c),({error:e,result:t})=>{e?p(e):u(t)});const g="wc_sessionRequest",m=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);if(m)return await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:r,method:g,params:{request:R(k({},i),{expiryTimestamp:(0,a.Xw0)(n)}),chainId:t},expiry:n,throwOnFailedPublish:!0,appLink:m}).catch(e=>p(e)),this.client.events.emit("session_request_sent",{topic:r,request:i,chainId:t,id:c}),await l();const y={request:R(k({},i),{expiryTimestamp:(0,a.Xw0)(n)}),chainId:t},w=this.shouldSetTVF(g,y);return await Promise.all([new Promise(async e=>{await this.sendRequest(k({clientRpcId:c,relayRpcId:h,topic:r,method:g,params:y,expiry:n,throwOnFailedPublish:!0},w&&{tvf:this.getTVFParams(c,y)})).catch(e=>p(e)),this.client.events.emit("session_request_sent",{topic:r,request:i,chainId:t,id:c}),e()}),new Promise(async e=>{var t;if(null==(t=o.sessionConfig)||!t.disableDeepLink){const e=await(0,a.jTh)(this.client.core.storage,f);await(0,a.n3s)({id:c,topic:r,wcDeepLink:e})}e()}),l()]).then(e=>e[2])}),M(this,"respond",async e=>{this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:i}=e,{id:r}=i,n=this.client.session.get(t);n.transportType===s.cV.relay&&await this.confirmOnlineStateOrThrow();const o=this.getAppLinkIfEnabled(n.peer.metadata,n.transportType);(0,d.isJsonRpcResult)(i)?await this.sendResult({id:r,topic:t,result:i.result,throwOnFailedPublish:!0,appLink:o}):(0,d.isJsonRpcError)(i)&&await this.sendError({id:r,topic:t,error:i.error,appLink:o}),this.cleanupAfterResponse(e)}),M(this,"ping",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(e)}catch(e){throw this.client.logger.error("ping() -> isValidPing() failed"),e}const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=(0,d.payloadId)(),i=(0,d.getBigIntRpcId)().toString(),{done:s,resolve:r,reject:n}=(0,a.Wx8)();this.events.once((0,a.hEn)("session_ping",e),({error:e})=>{e?n(e):r()}),await Promise.all([this.sendRequest({topic:t,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:e,relayRpcId:i}),s()])}else this.client.core.pairing.pairings.keys.includes(t)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:t}))}),M(this,"emit",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(e);const{topic:t,event:i,chainId:s}=e,r=(0,d.getBigIntRpcId)().toString(),n=(0,d.payloadId)();await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:i,chainId:s},throwOnFailedPublish:!0,relayRpcId:r,clientRpcId:n})}),M(this,"disconnect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(e);const{topic:t}=e;if(this.client.session.keys.includes(t))await this.sendRequest({topic:t,method:"wc_sessionDelete",params:(0,a.Hjj)("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:t,emitEvent:!1});else{if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=(0,a.GuA)("MISMATCHED_TOPIC",`Session or pairing topic not found: ${t}`);throw new Error(e)}await this.client.core.pairing.disconnect({topic:t})}}),M(this,"find",e=>(this.isInitialized(),this.client.session.getAll().filter(t=>(0,a.HNf)(t,e)))),M(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),M(this,"authenticate",async(e,t)=>{var i;this.isInitialized(),this.isValidAuthenticate(e);const r=t&&this.client.core.linkModeSupportedApps.includes(t)&&(null==(i=this.client.metadata.redirect)?void 0:i.linkMode),n=r?s.cV.link_mode:s.cV.relay;n===s.cV.relay&&await this.confirmOnlineStateOrThrow();const{chains:o,statement:c="",uri:h,domain:l,nonce:u,type:p,exp:f,nbf:g,methods:y=[],expiry:w}=e,v=[...e.resources||[]],{topic:I,uri:E}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:n});this.client.logger.info({message:"Generated new pairing",pairing:{topic:I,uri:E}});const _=await this.client.core.crypto.generateKeyPair(),N=(0,a.EN$)(_);if(await Promise.all([this.client.auth.authKeys.set(A,{responseTopic:N,publicKey:_}),this.client.auth.pairingTopics.set(N,{topic:N,pairingTopic:I})]),await this.client.core.relayer.subscribe(N,{transportType:n}),this.client.logger.info(`sending request to new pairing topic: ${I}`),y.length>0){const{namespace:e}=(0,a._Yb)(o[0]);let t=(0,a.e8_)(e,"request",y);(0,a.VBM)(v)&&(t=(0,a.hVC)(t,v.pop())),v.push(t)}const C=w&&w>b.wc_sessionAuthenticate.req.ttl?w:b.wc_sessionAuthenticate.req.ttl,S={authPayload:{type:p??"caip122",chains:o,statement:c,aud:h,domain:l,version:"1",nonce:u,iat:(new Date).toISOString(),exp:f,nbf:g,resources:v},requester:{publicKey:_,metadata:this.client.metadata},expiryTimestamp:(0,a.Xw0)(C)},P={requiredNamespaces:{},optionalNamespaces:{eip155:{chains:o,methods:[...new Set(["personal_sign",...y])],events:["chainChanged","accountsChanged"]}},relays:[{protocol:"irn"}],pairingTopic:I,proposer:{publicKey:_,metadata:this.client.metadata},expiryTimestamp:(0,a.Xw0)(b.wc_sessionPropose.req.ttl),id:(0,d.payloadId)()},{done:O,resolve:T,reject:x}=(0,a.Wx8)(C,"Request expired"),M=(0,d.payloadId)(),U=(0,a.hEn)("session_connect",P.id),D=(0,a.hEn)("session_request",M),j=async({error:e,session:t})=>{this.events.off(D,L),e?x(e):t&&T({session:t})},L=async e=>{var i,r,o;if(await this.deletePendingAuthRequest(M,{message:"fulfilled",code:0}),e.error){const t=(0,a.Hjj)("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return e.error.code===t.code?void 0:(this.events.off(U,j),x(e.error.message))}await this.deleteProposal(P.id),this.events.off(U,j);const{cacaos:c,responder:h}=e.result,d=[],l=[];for(const e of c){await(0,a.IjX)({cacao:e,projectId:this.client.core.projectId})||(this.client.logger.error(e,"Signature verification failed"),x((0,a.Hjj)("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:t}=e,i=(0,a.VBM)(t.resources),s=[(0,a.xkc)(t.iss)],r=(0,a.q_h)(t.iss);if(i){const e=(0,a.sc_)(i),t=(0,a.WWN)(i);d.push(...e),s.push(...t)}for(const e of s)l.push(`${e}:${r}`)}const u=await this.client.core.crypto.generateSharedKey(_,h.publicKey);let p;d.length>0&&(p={topic:u,acknowledged:!0,self:{publicKey:_,metadata:this.client.metadata},peer:h,controller:h.publicKey,expiry:(0,a.Xw0)(m),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:I,namespaces:(0,a.Van)([...new Set(d)],[...new Set(l)]),transportType:n},await this.client.core.relayer.subscribe(u,{transportType:n}),await this.client.session.set(u,p),I&&await this.client.core.pairing.updateMetadata({topic:I,metadata:h.metadata}),p=this.client.session.get(u)),null!=(i=this.client.metadata.redirect)&&i.linkMode&&null!=(r=h.metadata.redirect)&&r.linkMode&&null!=(o=h.metadata.redirect)&&o.universal&&t&&(this.client.core.addLinkModeSupportedApp(h.metadata.redirect.universal),this.client.session.update(u,{transportType:s.cV.link_mode})),T({auths:c,session:p})};let q;this.events.once(U,j),this.events.once(D,L);try{if(r){const e=(0,d.formatJsonRpcRequest)("wc_sessionAuthenticate",S,M);this.client.core.history.set(I,e);const i=await this.client.core.crypto.encode("",e,{type:a.EHS,encoding:a.Pa8});q=(0,a.$Bq)(t,I,i)}else await Promise.all([this.sendRequest({topic:I,method:"wc_sessionAuthenticate",params:S,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:M}),this.sendRequest({topic:I,method:"wc_sessionPropose",params:P,expiry:b.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:P.id})])}catch(e){throw this.events.off(U,j),this.events.off(D,L),e}return await this.setProposal(P.id,P),await this.setAuthRequest(M,{request:R(k({},S),{verifyContext:{}}),pairingTopic:I,transportType:n}),{uri:q??E,response:O}}),M(this,"approveSessionAuthenticate",async e=>{const{id:t,auths:i}=e,r=this.client.core.eventClient.createEvent({properties:{topic:t.toString(),trace:[s.U$.authenticated_session_approve_started]}});try{this.isInitialized()}catch(e){throw r.setError(s.Tn.no_internet_connection),e}const n=this.getPendingAuthRequest(t);if(!n)throw r.setError(s.Tn.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${t}`);const o=n.transportType||s.cV.relay;o===s.cV.relay&&await this.confirmOnlineStateOrThrow();const c=n.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),d=(0,a.EN$)(c),l={type:a.Lp_,receiverPublicKey:c,senderPublicKey:h},u=[],p=[];for(const e of i){if(!await(0,a.IjX)({cacao:e,projectId:this.client.core.projectId})){r.setError(s.Tn.invalid_cacao);const e=(0,a.Hjj)("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:t,topic:d,error:e,encodeOpts:l}),new Error(e.message)}r.addTrace(s.U$.cacaos_verified);const{p:i}=e,n=(0,a.VBM)(i.resources),o=[(0,a.xkc)(i.iss)],c=(0,a.q_h)(i.iss);if(n){const e=(0,a.sc_)(n),t=(0,a.WWN)(n);u.push(...e),o.push(...t)}for(const e of o)p.push(`${e}:${c}`)}const f=await this.client.core.crypto.generateSharedKey(h,c);let g;if(r.addTrace(s.U$.create_authenticated_session_topic),u?.length>0){g={topic:f,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:c,metadata:n.requester.metadata},controller:c,expiry:(0,a.Xw0)(m),authentication:i,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:n.pairingTopic,namespaces:(0,a.Van)([...new Set(u)],[...new Set(p)]),transportType:o},r.addTrace(s.U$.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(f,{transportType:o})}catch(e){throw r.setError(s.Tn.subscribe_authenticated_session_topic_failure),e}r.addTrace(s.U$.subscribe_authenticated_session_topic_success),await this.client.session.set(f,g),r.addTrace(s.U$.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:n.pairingTopic,metadata:n.requester.metadata})}r.addTrace(s.U$.publishing_authenticated_session_approve);try{await this.sendResult({topic:d,id:t,result:{cacaos:i,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:l,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(n.requester.metadata,o)})}catch(e){throw r.setError(s.Tn.authenticated_session_approve_publish_failure),e}return await this.client.auth.requests.delete(t,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:n.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:r.eventId}),{session:g}}),M(this,"rejectSessionAuthenticate",async e=>{this.isInitialized();const{id:t,reason:i}=e,r=this.getPendingAuthRequest(t);if(!r)throw new Error(`Could not find pending auth request with id ${t}`);r.transportType===s.cV.relay&&await this.confirmOnlineStateOrThrow();const n=r.requester.publicKey,o=await this.client.core.crypto.generateKeyPair(),c=(0,a.EN$)(n),h={type:a.Lp_,receiverPublicKey:n,senderPublicKey:o};await this.sendError({id:t,topic:c,error:i,encodeOpts:h,rpcOpts:b.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(r.requester.metadata,r.transportType)}),await this.client.auth.requests.delete(t,{message:"rejected",code:0}),await this.client.proposal.delete(t,(0,a.Hjj)("USER_DISCONNECTED"))}),M(this,"formatAuthMessage",e=>{this.isInitialized();const{request:t,iss:i}=e;return(0,a.hwK)(t,i)}),M(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(0!==this.relayMessageCache.length)for(;this.relayMessageCache.length>0;)try{const e=this.relayMessageCache.shift();e&&await this.onRelayMessage(e)}catch(e){this.client.logger.error(e)}},50)}),M(this,"cleanupDuplicatePairings",async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.pairingTopic),i=this.client.core.pairing.pairings.getAll().filter(i=>{var s,r;return(null==(s=i.peerMetadata)?void 0:s.url)&&(null==(r=i.peerMetadata)?void 0:r.url)===e.peer.metadata.url&&i.topic&&i.topic!==t.topic});if(0===i.length)return;this.client.logger.info(`Cleaning up ${i.length} duplicate pairing(s)`),await Promise.all(i.map(e=>this.client.core.pairing.disconnect({topic:e.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}}),M(this,"deleteSession",async e=>{var t;const{topic:i,expirerHasDeleted:s=!1,emitEvent:r=!0,id:n=0}=e,{self:o}=this.client.session.get(i);await this.client.core.relayer.unsubscribe(i),await this.client.session.delete(i,(0,a.Hjj)("USER_DISCONNECTED")),this.addToRecentlyDeleted(i,"session"),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(i)&&await this.client.core.crypto.deleteSymKey(i),s||this.client.core.expirer.del(i),this.client.core.storage.removeItem(f).catch(e=>this.client.logger.warn(e)),this.getPendingSessionRequests().forEach(e=>{e.topic===i&&this.deletePendingSessionRequest(e.id,(0,a.Hjj)("USER_DISCONNECTED"))}),i===(null==(t=this.sessionRequestQueue.queue[0])?void 0:t.topic)&&(this.sessionRequestQueue.state=w),r&&this.client.events.emit("session_delete",{id:n,topic:i})}),M(this,"deleteProposal",async(e,t)=>{if(t)try{const t=this.client.proposal.get(e),i=this.client.core.eventClient.getEvent({topic:t.pairingTopic});i?.setError(s.U.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(e,(0,a.Hjj)("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")}),M(this,"deletePendingSessionRequest",async(e,t,i=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,t),i?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(t=>t.id!==e),i&&(this.sessionRequestQueue.state=w,this.client.events.emit("session_request_expire",{id:e}))}),M(this,"deletePendingAuthRequest",async(e,t,i=!1)=>{await Promise.all([this.client.auth.requests.delete(e,t),i?Promise.resolve():this.client.core.expirer.del(e)])}),M(this,"setExpiry",async(e,t)=>{this.client.session.keys.includes(e)&&(this.client.core.expirer.set(e,t),await this.client.session.update(e,{expiry:t}))}),M(this,"setProposal",async(e,t)=>{this.client.core.expirer.set(e,(0,a.Xw0)(b.wc_sessionPropose.req.ttl)),await this.client.proposal.set(e,t)}),M(this,"setAuthRequest",async(e,t)=>{const{request:i,pairingTopic:r,transportType:n=s.cV.relay}=t;this.client.core.expirer.set(e,i.expiryTimestamp),await this.client.auth.requests.set(e,{authPayload:i.authPayload,requester:i.requester,expiryTimestamp:i.expiryTimestamp,id:e,pairingTopic:r,verifyContext:i.verifyContext,transportType:n})}),M(this,"setPendingSessionRequest",async e=>{const{id:t,topic:i,params:s,verifyContext:r}=e,n=s.request.expiryTimestamp||(0,a.Xw0)(b.wc_sessionRequest.req.ttl);this.client.core.expirer.set(t,n),await this.client.pendingRequest.set(t,{id:t,topic:i,params:s,verifyContext:r})}),M(this,"sendRequest",async e=>{const{topic:t,method:s,params:r,expiry:n,relayRpcId:o,clientRpcId:c,throwOnFailedPublish:h,appLink:l,tvf:u}=e,p=(0,d.formatJsonRpcRequest)(s,r,c);let f;const g=!!l;try{const e=g?a.Pa8:a.EWt;f=await this.client.core.crypto.encode(t,p,{encoding:e})}catch(e){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${t} failed`),e}let m;if(E.includes(s)){const e=(0,a.ALl)(JSON.stringify(p)),t=(0,a.ALl)(f);m=await this.client.core.verify.register({id:t,decryptedId:e})}const y=b[s].req;if(y.attestation=m,n&&(y.ttl=n),o&&(y.id=o),this.client.core.history.set(t,p),g){const e=(0,a.$Bq)(l,t,f);await i.g.Linking.openURL(e,this.client.name)}else{const e=b[s].req;n&&(e.ttl=n),o&&(e.id=o),e.tvf=R(k({},u),{correlationId:p.id}),h?(e.internal=R(k({},e.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,f,e)):this.client.core.relayer.publish(t,f,e).catch(e=>this.client.logger.error(e))}return p.id}),M(this,"sendResult",async e=>{const{id:t,topic:s,result:r,throwOnFailedPublish:n,encodeOpts:o,appLink:c}=e,h=(0,d.formatJsonRpcResult)(t,r);let l;const u=c&&typeof(null==i.g?void 0:i.g.Linking)<"u";try{const e=u?a.Pa8:a.EWt;l=await this.client.core.crypto.encode(s,h,R(k({},o||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s} failed`),e}let p,f;try{p=await this.client.core.history.get(s,t);const e=p.request;try{this.shouldSetTVF(e.method,e.params)&&(f=this.getTVFParams(t,e.params,r))}catch(e){this.client.logger.warn("sendResult() -> getTVFParams() failed",e)}}catch(e){throw this.client.logger.error(`sendResult() -> history.get(${s}, ${t}) failed`),e}if(u){const e=(0,a.$Bq)(c,s,l);await i.g.Linking.openURL(e,this.client.name)}else{const e=p.request.method,i=b[e].res;i.tvf=R(k({},f),{correlationId:t}),n?(i.internal=R(k({},i.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,l,i)):this.client.core.relayer.publish(s,l,i).catch(e=>this.client.logger.error(e))}await this.client.core.history.resolve(h)}),M(this,"sendError",async e=>{const{id:t,topic:s,error:r,encodeOpts:n,rpcOpts:o,appLink:c}=e,h=(0,d.formatJsonRpcError)(t,r);let l;const u=c&&typeof(null==i.g?void 0:i.g.Linking)<"u";try{const e=u?a.Pa8:a.EWt;l=await this.client.core.crypto.encode(s,h,R(k({},n||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s} failed`),e}let p;try{p=await this.client.core.history.get(s,t)}catch(e){throw this.client.logger.error(`sendError() -> history.get(${s}, ${t}) failed`),e}if(u){const e=(0,a.$Bq)(c,s,l);await i.g.Linking.openURL(e,this.client.name)}else{const e=p.request.method,t=o||b[e].res;this.client.core.relayer.publish(s,l,t)}await this.client.core.history.resolve(h)}),M(this,"cleanup",async()=>{const e=[],t=[];this.client.session.getAll().forEach(t=>{let i=!1;(0,a._dF)(t.expiry)&&(i=!0),this.client.core.crypto.keychain.has(t.topic)||(i=!0),i&&e.push(t.topic)}),this.client.proposal.getAll().forEach(e=>{(0,a._dF)(e.expiryTimestamp)&&t.push(e.id)}),await Promise.all([...e.map(e=>this.deleteSession({topic:e})),...t.map(e=>this.deleteProposal(e))])}),M(this,"onRelayEventRequest",async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()}),M(this,"processRequestsQueue",async()=>{if(this.requestQueue.state!==v){for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=v;const e=this.requestQueue.queue.shift();if(e)try{await this.processRequest(e)}catch(e){this.client.logger.warn(e)}}this.requestQueue.state=w}else this.client.logger.info("Request queue already active, skipping...")}),M(this,"processRequest",async e=>{const{topic:t,payload:i,attestation:s,transportType:r,encryptedId:n}=e,o=i.method;if(!this.shouldIgnorePairingRequest({topic:t,requestMethod:o}))switch(o){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:t,payload:i,attestation:s,encryptedId:n});case"wc_sessionSettle":return await this.onSessionSettleRequest(t,i);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(t,i);case"wc_sessionExtend":return await this.onSessionExtendRequest(t,i);case"wc_sessionPing":return await this.onSessionPingRequest(t,i);case"wc_sessionDelete":return await this.onSessionDeleteRequest(t,i);case"wc_sessionRequest":return await this.onSessionRequest({topic:t,payload:i,attestation:s,encryptedId:n,transportType:r});case"wc_sessionEvent":return await this.onSessionEventRequest(t,i);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:t,payload:i,attestation:s,encryptedId:n,transportType:r});default:return this.client.logger.info(`Unsupported request method ${o}`)}}),M(this,"onRelayEventResponse",async e=>{const{topic:t,payload:i,transportType:s}=e,r=(await this.client.core.history.get(t,i.id)).request.method;switch(r){case"wc_sessionPropose":return this.onSessionProposeResponse(t,i,s);case"wc_sessionSettle":return this.onSessionSettleResponse(t,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,i);case"wc_sessionExtend":return this.onSessionExtendResponse(t,i);case"wc_sessionPing":return this.onSessionPingResponse(t,i);case"wc_sessionRequest":return this.onSessionRequestResponse(t,i);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(t,i);default:return this.client.logger.info(`Unsupported response method ${r}`)}}),M(this,"onRelayEventUnknownPayload",e=>{const{topic:t}=e,{message:i}=(0,a.GuA)("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(i)}),M(this,"shouldIgnorePairingRequest",e=>{const{topic:t,requestMethod:i}=e,s=this.expectedPairingMethodMap.get(t);return!(!s||s.includes(i)||!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0))}),M(this,"onSessionProposeRequest",async e=>{const{topic:t,payload:i,attestation:r,encryptedId:n}=e,{params:o,id:c}=i;try{const e=this.client.core.eventClient.getEvent({topic:t});0===this.client.events.listenerCount("session_proposal")&&(console.warn("No listener for session_proposal event"),e?.setError(s.S$.proposal_listener_not_found)),this.isValidConnect(k({},i.params));const h=o.expiryTimestamp||(0,a.Xw0)(b.wc_sessionPropose.req.ttl),d=k({id:c,pairingTopic:t,expiryTimestamp:h},o);await this.setProposal(c,d);const l=await this.getVerifyContext({attestationId:r,hash:(0,a.ALl)(JSON.stringify(i)),encryptedId:n,metadata:d.proposer.metadata});e?.addTrace(s.$w.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:d,verifyContext:l})}catch(e){await this.sendError({id:c,topic:t,error:e,rpcOpts:b.wc_sessionPropose.autoReject}),this.client.logger.error(e)}}),M(this,"onSessionProposeResponse",async(e,t,i)=>{const{id:s}=t;if((0,d.isJsonRpcResult)(t)){const{result:r}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:r});const n=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const o=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const a=r.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});const c=await this.client.core.crypto.generateSharedKey(o,a);this.pendingSessions.set(s,{sessionTopic:c,pairingTopic:e,proposalId:s,publicKey:o});const h=await this.client.core.relayer.subscribe(c,{transportType:i});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:e})}else if((0,d.isJsonRpcError)(t)){await this.client.proposal.delete(s,(0,a.Hjj)("USER_DISCONNECTED"));const e=(0,a.hEn)("session_connect",s);if(0===this.events.listenerCount(e))throw new Error(`emitting ${e} without any listeners, 954`);this.events.emit(e,{error:t.error})}}),M(this,"onSessionSettleRequest",async(e,t)=>{const{id:i,params:r}=t;try{this.isValidSessionSettleRequest(r);const{relay:i,controller:n,expiry:o,namespaces:c,sessionProperties:h,sessionConfig:d}=t.params,l=[...this.pendingSessions.values()].find(t=>t.sessionTopic===e);if(!l)return this.client.logger.error(`Pending session not found for topic ${e}`);const u=this.client.proposal.get(l.proposalId),p=R(k(k({topic:e,relay:i,expiry:o,namespaces:c,acknowledged:!0,pairingTopic:l.pairingTopic,requiredNamespaces:u.requiredNamespaces,optionalNamespaces:u.optionalNamespaces,controller:n.publicKey,self:{publicKey:l.publicKey,metadata:this.client.metadata},peer:{publicKey:n.publicKey,metadata:n.metadata}},h&&{sessionProperties:h}),d&&{sessionConfig:d}),{transportType:s.cV.relay});await this.client.session.set(p.topic,p),await this.setExpiry(p.topic,p.expiry),await this.client.core.pairing.updateMetadata({topic:l.pairingTopic,metadata:p.peer.metadata}),this.client.events.emit("session_connect",{session:p}),this.events.emit((0,a.hEn)("session_connect",l.proposalId),{session:p}),this.pendingSessions.delete(l.proposalId),this.deleteProposal(l.proposalId,!1),this.cleanupDuplicatePairings(p),await this.sendResult({id:t.id,topic:e,result:!0,throwOnFailedPublish:!0})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),M(this,"onSessionSettleResponse",async(e,t)=>{const{id:i}=t;(0,d.isJsonRpcResult)(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit((0,a.hEn)("session_approve",i),{})):(0,d.isJsonRpcError)(t)&&(await this.client.session.delete(e,(0,a.Hjj)("USER_DISCONNECTED")),this.events.emit((0,a.hEn)("session_approve",i),{error:t.error}))}),M(this,"onSessionUpdateRequest",async(e,t)=>{const{params:i,id:s}=t;try{const t=`${e}_session_update`,r=a.nyL.get(t);if(r&&this.isRequestOutOfSync(r,s))return this.client.logger.warn(`Discarding out of sync request - ${s}`),void this.sendError({id:s,topic:e,error:(0,a.Hjj)("INVALID_UPDATE_REQUEST")});this.isValidUpdate(k({topic:e},i));try{a.nyL.set(t,s),await this.client.session.update(e,{namespaces:i.namespaces}),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0})}catch(e){throw a.nyL.delete(t),e}this.client.events.emit("session_update",{id:s,topic:e,params:i})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),M(this,"isRequestOutOfSync",(e,t)=>t.toString().slice(0,-3)<e.toString().slice(0,-3)),M(this,"onSessionUpdateResponse",(e,t)=>{const{id:i}=t,s=(0,a.hEn)("session_update",i);if(0===this.events.listenerCount(s))throw new Error(`emitting ${s} without any listeners`);(0,d.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_update",i),{}):(0,d.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_update",i),{error:t.error})}),M(this,"onSessionExtendRequest",async(e,t)=>{const{id:i}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,(0,a.Xw0)(m)),await this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:i,topic:e})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),M(this,"onSessionExtendResponse",(e,t)=>{const{id:i}=t,s=(0,a.hEn)("session_extend",i);if(0===this.events.listenerCount(s))throw new Error(`emitting ${s} without any listeners`);(0,d.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_extend",i),{}):(0,d.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_extend",i),{error:t.error})}),M(this,"onSessionPingRequest",async(e,t)=>{const{id:i}=t;try{this.isValidPing({topic:e}),await this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:i,topic:e})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),M(this,"onSessionPingResponse",(e,t)=>{const{id:i}=t,s=(0,a.hEn)("session_ping",i);if(0===this.events.listenerCount(s))throw new Error(`emitting ${s} without any listeners`);setTimeout(()=>{(0,d.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_ping",i),{}):(0,d.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_ping",i),{error:t.error})},500)}),M(this,"onSessionDeleteRequest",async(e,t)=>{const{id:i}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),Promise.all([new Promise(t=>{this.client.core.relayer.once(s.Jf.publish,async()=>{t(await this.deleteSession({topic:e,id:i}))})}),this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:(0,a.Hjj)("USER_DISCONNECTED")})]).catch(e=>this.client.logger.error(e))}catch(e){this.client.logger.error(e)}}),M(this,"onSessionRequest",async e=>{var t,i,r;const{topic:n,payload:o,attestation:c,encryptedId:h,transportType:l}=e,{id:u,params:p}=o;try{await this.isValidRequest(k({topic:n},p));const e=this.client.session.get(n),o={id:u,topic:n,params:p,verifyContext:await this.getVerifyContext({attestationId:c,hash:(0,a.ALl)(JSON.stringify((0,d.formatJsonRpcRequest)("wc_sessionRequest",p,u))),encryptedId:h,metadata:e.peer.metadata,transportType:l})};await this.setPendingSessionRequest(o),l===s.cV.link_mode&&null!=(t=e.peer.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(null==(i=e.peer.metadata.redirect)?void 0:i.universal),null!=(r=this.client.signConfig)&&r.disableRequestQueue?this.emitSessionRequest(o):(this.addSessionRequestToSessionRequestQueue(o),this.processSessionRequestQueue())}catch(e){await this.sendError({id:u,topic:n,error:e}),this.client.logger.error(e)}}),M(this,"onSessionRequestResponse",(e,t)=>{const{id:i}=t,s=(0,a.hEn)("session_request",i);if(0===this.events.listenerCount(s))throw new Error(`emitting ${s} without any listeners`);(0,d.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_request",i),{result:t.result}):(0,d.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_request",i),{error:t.error})}),M(this,"onSessionEventRequest",async(e,t)=>{const{id:i,params:s}=t;try{const t=`${e}_session_event_${s.event.name}`,r=a.nyL.get(t);if(r&&this.isRequestOutOfSync(r,i))return void this.client.logger.info(`Discarding out of sync request - ${i}`);this.isValidEmit(k({topic:e},s)),this.client.events.emit("session_event",{id:i,topic:e,params:s}),a.nyL.set(t,i)}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),M(this,"onSessionAuthenticateResponse",(e,t)=>{const{id:i}=t;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:t}),(0,d.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_request",i),{result:t.result}):(0,d.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_request",i),{error:t.error})}),M(this,"onSessionAuthenticateRequest",async e=>{var t;const{topic:i,payload:r,attestation:n,encryptedId:o,transportType:c}=e;try{const{requester:e,authPayload:h,expiryTimestamp:d}=r.params,l=await this.getVerifyContext({attestationId:n,hash:(0,a.ALl)(JSON.stringify(r)),encryptedId:o,metadata:e.metadata,transportType:c}),u={requester:e,pairingTopic:i,id:r.id,authPayload:h,verifyContext:l,expiryTimestamp:d};await this.setAuthRequest(r.id,{request:u,pairingTopic:i,transportType:c}),c===s.cV.link_mode&&null!=(t=e.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(e.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:i,params:r.params,id:r.id,verifyContext:l})}catch(e){this.client.logger.error(e);const t=r.params.requester.publicKey,s=await this.client.core.crypto.generateKeyPair(),n=this.getAppLinkIfEnabled(r.params.requester.metadata,c),o={type:a.Lp_,receiverPublicKey:t,senderPublicKey:s};await this.sendError({id:r.id,topic:i,error:e,encodeOpts:o,rpcOpts:b.wc_sessionAuthenticate.autoReject,appLink:n})}}),M(this,"addSessionRequestToSessionRequestQueue",e=>{this.sessionRequestQueue.queue.push(e)}),M(this,"cleanupAfterResponse",e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=w,this.processSessionRequestQueue()},(0,o.toMiliseconds)(this.requestQueueDelay))}),M(this,"cleanupPendingSentRequestsForTopic",({topic:e,error:t})=>{const i=this.client.core.history.pending;i.length>0&&i.filter(t=>t.topic===e&&"wc_sessionRequest"===t.request.method).forEach(e=>{const i=e.request.id,s=(0,a.hEn)("session_request",i);if(0===this.events.listenerCount(s))throw new Error(`emitting ${s} without any listeners`);this.events.emit((0,a.hEn)("session_request",e.request.id),{error:t})})}),M(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===v)return void this.client.logger.info("session request queue is already active.");const e=this.sessionRequestQueue.queue[0];if(e)try{this.sessionRequestQueue.state=v,this.emitSessionRequest(e)}catch(e){this.client.logger.error(e)}else this.client.logger.info("session request queue is empty.")}),M(this,"emitSessionRequest",e=>{this.client.events.emit("session_request",e)}),M(this,"onPairingCreated",e=>{if(e.methods&&this.expectedPairingMethodMap.set(e.topic,e.methods),e.active)return;const t=this.client.proposal.getAll().find(t=>t.pairingTopic===e.topic);t&&this.onSessionProposeRequest({topic:e.topic,payload:(0,d.formatJsonRpcRequest)("wc_sessionPropose",{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties},t.id)})}),M(this,"isValidConnect",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(t)}const{pairingTopic:t,requiredNamespaces:i,optionalNamespaces:s,sessionProperties:r,relays:n}=e;if((0,a.b07)(t)||await this.isValidPairingTopic(t),!(0,a.V9G)(n,!0)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`connect() relays: ${n}`);throw new Error(e)}!(0,a.b07)(i)&&0!==(0,a.aF0)(i)&&this.validateNamespaces(i,"requiredNamespaces"),!(0,a.b07)(s)&&0!==(0,a.aF0)(s)&&this.validateNamespaces(s,"optionalNamespaces"),(0,a.b07)(r)||this.validateSessionProps(r,"sessionProperties")}),M(this,"validateNamespaces",(e,t)=>{const i=(0,a.esh)(e,"connect()",t);if(i)throw new Error(i.message)}),M(this,"isValidApprove",async e=>{if(!(0,a.TeY)(e))throw new Error((0,a.GuA)("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:t,namespaces:i,relayProtocol:s,sessionProperties:r}=e;this.checkRecentlyDeleted(t),await this.isValidProposalId(t);const n=this.client.proposal.get(t),o=(0,a.FiO)(i,"approve()");if(o)throw new Error(o.message);const c=(0,a.XqR)(n.requiredNamespaces,i,"approve()");if(c)throw new Error(c.message);if(!(0,a.Qhg)(s,!0)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(e)}(0,a.b07)(r)||this.validateSessionProps(r,"sessionProperties")}),M(this,"isValidReject",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(t)}const{id:t,reason:i}=e;if(this.checkRecentlyDeleted(t),await this.isValidProposalId(t),!(0,a.X3c)(i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(e)}}),M(this,"isValidSessionSettleRequest",e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}const{relay:t,controller:i,namespaces:s,expiry:r}=e;if(!(0,a.kuU)(t)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const n=(0,a.tk0)(i,"onSessionSettleRequest()");if(n)throw new Error(n.message);const o=(0,a.FiO)(s,"onSessionSettleRequest()");if(o)throw new Error(o.message);if((0,a._dF)(r)){const{message:e}=(0,a.GuA)("EXPIRED","onSessionSettleRequest()");throw new Error(e)}}),M(this,"isValidUpdate",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(t)}const{topic:t,namespaces:i}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const s=this.client.session.get(t),r=(0,a.FiO)(i,"update()");if(r)throw new Error(r.message);const n=(0,a.XqR)(s.requiredNamespaces,i,"update()");if(n)throw new Error(n.message)}),M(this,"isValidExtend",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:t}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t)}),M(this,"isValidRequest",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(t)}const{topic:t,request:i,chainId:s,expiry:r}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const{namespaces:n}=this.client.session.get(t);if(!(0,a.tLy)(n,s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(e)}if(!(0,a.iV1)(i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(e)}if(!(0,a.oKp)(n,s,i.method)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(e)}if(r&&!(0,a.Hbs)(r,y)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() expiry: ${r}. Expiry must be a number (in seconds) between ${y.min} and ${y.max}`);throw new Error(e)}}),M(this,"isValidRespond",async e=>{var t;if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:i,response:s}=e;try{await this.isValidSessionTopic(i)}catch(i){throw null!=(t=e?.response)&&t.id&&this.cleanupAfterResponse(e),i}if(!(0,a.M8n)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(e)}}),M(this,"isValidPing",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),M(this,"isValidEmit",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(t)}const{topic:t,event:i,chainId:s}=e;await this.isValidSessionTopic(t);const{namespaces:r}=this.client.session.get(t);if(!(0,a.tLy)(r,s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(e)}if(!(0,a.FR8)(i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(e)}if(!(0,a.z2N)(r,s,i.name)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(e)}}),M(this,"isValidDisconnect",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),M(this,"isValidAuthenticate",e=>{const{chains:t,uri:i,domain:s,nonce:r}=e;if(!Array.isArray(t)||0===t.length)throw new Error("chains is required and must be a non-empty array");if(!(0,a.Qhg)(i,!1))throw new Error("uri is required parameter");if(!(0,a.Qhg)(s,!1))throw new Error("domain is required parameter");if(!(0,a.Qhg)(r,!1))throw new Error("nonce is required parameter");if([...new Set(t.map(e=>(0,a._Yb)(e).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:n}=(0,a._Yb)(t[0]);if("eip155"!==n)throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),M(this,"getVerifyContext",async e=>{const{attestationId:t,hash:i,encryptedId:r,metadata:n,transportType:o}=e,a={verified:{verifyUrl:n.verifyUrl||s.WB,validation:"UNKNOWN",origin:n.url||""}};try{if(o===s.cV.link_mode){const e=this.getAppLinkIfEnabled(n,o);return a.verified.validation=e&&new URL(e).origin===new URL(n.url).origin?"VALID":"INVALID",a}const e=await this.client.core.verify.resolve({attestationId:t,hash:i,encryptedId:r,verifyUrl:n.verifyUrl});e&&(a.verified.origin=e.origin,a.verified.isScam=e.isScam,a.verified.validation=e.origin===new URL(n.url).origin?"VALID":"INVALID")}catch(e){this.client.logger.warn(e)}return this.client.logger.debug(`Verify context: ${JSON.stringify(a)}`),a}),M(this,"validateSessionProps",(e,t)=>{Object.values(e).forEach(e=>{if(!(0,a.Qhg)(e,!1)){const{message:i}=(0,a.GuA)("MISSING_OR_INVALID",`${t} must be in Record<string, string> format. Received: ${JSON.stringify(e)}`);throw new Error(i)}})}),M(this,"getPendingAuthRequest",e=>{const t=this.client.auth.requests.get(e);return"object"==typeof t?t:void 0}),M(this,"addToRecentlyDeleted",(e,t)=>{if(this.recentlyDeletedMap.set(e,t),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let e=0;const t=this.recentlyDeletedLimit/2;for(const i of this.recentlyDeletedMap.keys()){if(e++>=t)break;this.recentlyDeletedMap.delete(i)}}}),M(this,"checkRecentlyDeleted",e=>{const t=this.recentlyDeletedMap.get(e);if(t){const{message:i}=(0,a.GuA)("MISSING_OR_INVALID",`Record was recently deleted - ${t}: ${e}`);throw new Error(i)}}),M(this,"isLinkModeEnabled",(e,t)=>{var r,n,o,a,c,h,d,l,u;return!(!e||t!==s.cV.link_mode)&&!0===(null==(n=null==(r=this.client.metadata)?void 0:r.redirect)?void 0:n.linkMode)&&void 0!==(null==(a=null==(o=this.client.metadata)?void 0:o.redirect)?void 0:a.universal)&&""!==(null==(h=null==(c=this.client.metadata)?void 0:c.redirect)?void 0:h.universal)&&void 0!==(null==(d=e?.redirect)?void 0:d.universal)&&""!==(null==(l=e?.redirect)?void 0:l.universal)&&!0===(null==(u=e?.redirect)?void 0:u.linkMode)&&this.client.core.linkModeSupportedApps.includes(e.redirect.universal)&&typeof(null==i.g?void 0:i.g.Linking)<"u"}),M(this,"getAppLinkIfEnabled",(e,t)=>{var i;return this.isLinkModeEnabled(e,t)?null==(i=e?.redirect)?void 0:i.universal:void 0}),M(this,"handleLinkModeMessage",({url:e})=>{if(!e||!e.includes("wc_ev")||!e.includes("topic"))return;const t=(0,a.$hI)(e,"topic")||"",i=decodeURIComponent((0,a.$hI)(e,"wc_ev")||""),r=this.client.session.keys.includes(t);r&&this.client.session.update(t,{transportType:s.cV.link_mode}),this.client.core.dispatchEnvelope({topic:t,message:i,sessionExists:r})}),M(this,"registerLinkModeListeners",async()=>{var e;if((0,a.w8K)()||(0,a.lVv)()&&null!=(e=this.client.metadata.redirect)&&e.linkMode){const e=null==i.g?void 0:i.g.Linking;if(typeof e<"u"){e.addEventListener("url",this.handleLinkModeMessage,this.client.name);const t=await e.getInitialURL();t&&setTimeout(()=>{this.handleLinkModeMessage({url:t})},50)}}}),M(this,"shouldSetTVF",(e,t)=>{if(!t||"wc_sessionRequest"!==e)return!1;const{request:i}=t;return Object.keys(I).includes(i.method)}),M(this,"getTVFParams",(e,t,i)=>{var s,r;try{const n=t.request.method,o=this.extractTxHashesFromResult(n,i);return R(k({correlationId:e,rpcMethods:[n],chainId:t.chainId},this.isValidContractData(t.request.params)&&{contractAddresses:[null==(r=null==(s=t.request.params)?void 0:s[0])?void 0:r.to]}),{txHashes:o})}catch(e){this.client.logger.warn("Error getting TVF params",e)}return{}}),M(this,"isValidContractData",e=>{var t;if(!e)return!1;try{const i=e?.data||(null==(t=e?.[0])?void 0:t.data);if(!i.startsWith("0x"))return!1;const s=i.slice(2);return!!/^[0-9a-fA-F]*$/.test(s)&&s.length%2==0}catch{}return!1}),M(this,"extractTxHashesFromResult",(e,t)=>{try{if("string"==typeof t)return[t];const i=t[I[e].key];if((0,a.OP1)(i))return i;if("string"==typeof i)return[i]}catch(e){this.client.logger.warn("Error extracting tx hashes from result",e)}return[]})}isInitialized(){if(!this.initialized){const{message:e}=(0,a.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(s.Jf.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:t,message:i,attestation:r,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(A)?this.client.auth.authKeys.get(A):{responseTopic:void 0,publicKey:void 0},c=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:n===s.cV.link_mode?a.Pa8:a.EWt});try{(0,d.isJsonRpcRequest)(c)?(this.client.core.history.set(t,c),this.onRelayEventRequest({topic:t,payload:c,attestation:r,transportType:n,encryptedId:(0,a.ALl)(i)})):(0,d.isJsonRpcResponse)(c)?(await this.client.core.history.resolve(c),await this.onRelayEventResponse({topic:t,payload:c,transportType:n}),this.client.core.history.delete(t,c.id)):this.onRelayEventUnknownPayload({topic:t,payload:c,transportType:n})}catch(e){this.client.logger.error(e)}}registerExpirerEvents(){this.client.core.expirer.on(s.wn.expired,async e=>{const{topic:t,id:i}=(0,a.c82)(e.target);return i&&this.client.pendingRequest.keys.includes(i)?await this.deletePendingSessionRequest(i,(0,a.GuA)("EXPIRED"),!0):i&&this.client.auth.requests.keys.includes(i)?await this.deletePendingAuthRequest(i,(0,a.GuA)("EXPIRED"),!0):void(t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i})))})}registerPairingEvents(){this.client.core.pairing.events.on(s.zN.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(s.zN.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!(0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=(0,a.GuA)("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!(0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=(0,a.GuA)("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else{if(!this.client.core.pairing.pairings.keys.includes(e)){if((0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if(!(0,a.Alu)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=(0,a.GuA)("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class D extends s.il{constructor(e,t){super(e,t,"proposal",u),this.core=e,this.logger=t}}class j extends s.il{constructor(e,t){super(e,t,"session",u),this.core=e,this.logger=t}}class L extends s.il{constructor(e,t){super(e,t,"request",u,e=>e.id),this.core=e,this.logger=t}}class q extends s.il{constructor(e,t){super(e,t,"authKeys",_,()=>A),this.core=e,this.logger=t}}class $ extends s.il{constructor(e,t){super(e,t,"pairingTopics",_),this.core=e,this.logger=t}}class B extends s.il{constructor(e,t){super(e,t,"requests",_,e=>e.id),this.core=e,this.logger=t}}var z=Object.defineProperty,H=(e,t,i)=>((e,t,i)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class W{constructor(e,t){this.core=e,this.logger=t,H(this,"authKeys"),H(this,"pairingTopics"),H(this,"requests"),this.authKeys=new q(this.core,this.logger),this.pairingTopics=new $(this.core,this.logger),this.requests=new B(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var V=Object.defineProperty,F=(e,t,i)=>((e,t,i)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class K extends n.S9{constructor(e){super(e),F(this,"protocol","wc"),F(this,"version",2),F(this,"name",p),F(this,"metadata"),F(this,"core"),F(this,"logger"),F(this,"events",new c.EventEmitter),F(this,"engine"),F(this,"session"),F(this,"proposal"),F(this,"pendingRequest"),F(this,"auth"),F(this,"signConfig"),F(this,"on",(e,t)=>this.events.on(e,t)),F(this,"once",(e,t)=>this.events.once(e,t)),F(this,"off",(e,t)=>this.events.off(e,t)),F(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),F(this,"removeAllListeners",e=>this.events.removeAllListeners(e)),F(this,"connect",async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"pair",async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"approve",async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"reject",async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"update",async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"extend",async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"request",async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"respond",async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"ping",async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"emit",async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"disconnect",async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"find",e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}}),F(this,"authenticate",async(e,t)=>{try{return await this.engine.authenticate(e,t)}catch(e){throw this.logger.error(e.message),e}}),F(this,"formatAuthMessage",e=>{try{return this.engine.formatAuthMessage(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"approveSessionAuthenticate",async e=>{try{return await this.engine.approveSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"rejectSessionAuthenticate",async e=>{try{return await this.engine.rejectSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),this.name=e?.name||p,this.metadata=e?.metadata||(0,a.lFF)(),this.signConfig=e?.signConfig;const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,r.h6)((0,r.iP)({level:e?.logger||"error"}));this.core=e?.core||new s.iJ(e),this.logger=(0,r.U5)(t,this.name),this.session=new j(this.core,this.logger),this.proposal=new D(this.core,this.logger),this.pendingRequest=new L(this.core,this.logger),this.engine=new U(this),this.auth=new W(this.core,this.logger)}static async init(e){const t=new K(e);return await t.initialize(),t}get context(){return(0,r.oI)(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},(0,o.toMiliseconds)(o.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}},32191:(e,t,i)=>{var s=i(70461),r=i(7784);function n(){this.pending=null,this.pendingTotal=0,this.blockSize=this.constructor.blockSize,this.outSize=this.constructor.outSize,this.hmacStrength=this.constructor.hmacStrength,this.padLength=this.constructor.padLength/8,this.endian="big",this._delta8=this.blockSize/8,this._delta32=this.blockSize/32}t.BlockHash=n,n.prototype.update=function(e,t){if(e=s.toArray(e,t),this.pending?this.pending=this.pending.concat(e):this.pending=e,this.pendingTotal+=e.length,this.pending.length>=this._delta8){var i=(e=this.pending).length%this._delta8;this.pending=e.slice(e.length-i,e.length),0===this.pending.length&&(this.pending=null),e=s.join32(e,0,e.length-i,this.endian);for(var r=0;r<e.length;r+=this._delta32)this._update(e,r,r+this._delta32)}return this},n.prototype.digest=function(e){return this.update(this._pad()),r(null===this.pending),this._digest(e)},n.prototype._pad=function(){var e=this.pendingTotal,t=this._delta8,i=t-(e+this.padLength)%t,s=new Array(i+this.padLength);s[0]=128;for(var r=1;r<i;r++)s[r]=0;if(e<<=3,"big"===this.endian){for(var n=8;n<this.padLength;n++)s[r++]=0;s[r++]=0,s[r++]=0,s[r++]=0,s[r++]=0,s[r++]=e>>>24&255,s[r++]=e>>>16&255,s[r++]=e>>>8&255,s[r++]=255&e}else for(s[r++]=255&e,s[r++]=e>>>8&255,s[r++]=e>>>16&255,s[r++]=e>>>24&255,s[r++]=0,s[r++]=0,s[r++]=0,s[r++]=0,n=8;n<this.padLength;n++)s[r++]=0;return s}},32681:(e,t,i)=>{i.d(t,{IP:()=>o,T8:()=>r,Ud:()=>n,Ws:()=>s});const s={WALLET_ID:"@appkit/wallet_id",WALLET_NAME:"@appkit/wallet_name",SOLANA_WALLET:"@appkit/solana_wallet",SOLANA_CAIP_CHAIN:"@appkit/solana_caip_chain",ACTIVE_CAIP_NETWORK_ID:"@appkit/active_caip_network_id",CONNECTED_SOCIAL:"@appkit/connected_social",CONNECTED_SOCIAL_USERNAME:"@appkit-wallet/SOCIAL_USERNAME",RECENT_WALLETS:"@appkit/recent_wallets",DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",ACTIVE_NAMESPACE:"@appkit/active_namespace",CONNECTED_NAMESPACES:"@appkit/connected_namespaces",CONNECTION_STATUS:"@appkit/connection_status",SIWX_AUTH_TOKEN:"@appkit/siwx-auth-token",SIWX_NONCE_TOKEN:"@appkit/siwx-nonce-token",TELEGRAM_SOCIAL_PROVIDER:"@appkit/social_provider",NATIVE_BALANCE_CACHE:"@appkit/native_balance_cache",PORTFOLIO_CACHE:"@appkit/portfolio_cache",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache"};function r(e){if(!e)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${e}:connected_connector_id`}const n={setItem(e,t){o()&&void 0!==t&&localStorage.setItem(e,t)},getItem(e){if(o())return localStorage.getItem(e)||void 0},removeItem(e){o()&&localStorage.removeItem(e)},clear(){o()&&localStorage.clear()}};function o(){return"undefined"!=typeof window&&"undefined"!=typeof localStorage}},33816:(e,t,i)=>{i.d(t,{X:()=>c}),i(23438);var s=i(95191),r=i(16279),n=i(16158),o=i(40770),a=i(76663);class c{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,e&&this.construct(e)}construct(e){this.caipNetworks=e.networks,this.projectId=e.projectId,this.namespace=e.namespace,this.adapterType=e.adapterType}get connectors(){return this.availableConnectors}get networks(){return this.caipNetworks||[]}setAuthProvider(e){this.addConnector({id:s.o.CONNECTOR_ID.AUTH,type:"AUTH",name:s.o.CONNECTOR_NAMES.AUTH,provider:e,imageId:o.L.ConnectorImageIds[s.o.CONNECTOR_ID.AUTH],chain:this.namespace,chains:[]})}addConnector(...e){const t=new Set;this.availableConnectors=[...e,...this.availableConnectors].filter(e=>!t.has(e.id)&&(t.add(e.id),!0)),this.emit("connectors",this.availableConnectors)}setStatus(e,t){r.U.setStatus(e,t)}on(e,t){this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e)?.add(t)}off(e,t){const i=this.eventListeners.get(e);i&&i.delete(t)}removeAllEventListeners(){this.eventListeners.forEach(e=>{e.clear()})}emit(e,t){const i=this.eventListeners.get(e);i&&i.forEach(e=>e(t))}async connectWalletConnect(e){const t=this.getWalletConnectConnector();return{clientId:(await t.connectWalletConnect()).clientId}}async switchNetwork(e){const{caipNetwork:t,providerType:i}=e;if(!e.provider)return;const s="provider"in e.provider?e.provider.provider:e.provider;if("WALLET_CONNECT"!==i){if(s&&"AUTH"===i){const e=s;await e.switchNetwork(t.caipNetworkId);const i=await e.getUser({chainId:t.caipNetworkId,preferredAccountType:n.H.state.defaultAccountTypes[t.chainNamespace]});this.emit("switchNetwork",i)}}else s.setDefaultChain(t.caipNetworkId)}getWalletConnectConnector(){const e=this.connectors.find(e=>e instanceof a.F);if(!e)throw new Error("WalletConnectConnector not found");return e}}},33937:(e,t,i)=>{i.d(t,{t:()=>s});const s=(0,i(40149).x)({id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!1,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",deprecatedCaipNetworkId:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ"})},35615:e=>{"function"==typeof Object.create?e.exports=function(e,t){t&&(e.super_=t,e.prototype=Object.create(t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}))}:e.exports=function(e,t){if(t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}}},35842:(e,t,i)=>{i.d(t,{AH:()=>s.AH,JW:()=>s.JW,WF:()=>s.WF,iz:()=>s.iz,qy:()=>s.qy}),i(58207),i(80181);var s=i(46477)},36641:(e,t,i)=>{i.d(t,{T:()=>r});var s=i(88612);const r={createBalance(e,t){const i={name:e.metadata.name||"",symbol:e.metadata.symbol||"",decimals:e.metadata.decimals||0,value:e.metadata.value||0,price:e.metadata.price||0,iconUrl:e.metadata.iconUrl||""};return{name:i.name,symbol:i.symbol,chainId:t,address:"native"===e.address?void 0:this.convertAddressToCAIP10Address(e.address,t),value:i.value,price:i.price,quantity:{decimals:i.decimals.toString(),numeric:this.convertHexToBalance({hex:e.balance,decimals:i.decimals})},iconUrl:i.iconUrl}},convertHexToBalance:({hex:e,decimals:t})=>(0,s.J)(BigInt(e),t),convertAddressToCAIP10Address:(e,t)=>`${t}:${e}`,createCAIP2ChainId:(e,t)=>`${t}:${parseInt(e,16)}`,getChainIdHexFromCAIP2ChainId(e){const t=e.split(":");if(t.length<2||!t[1])return"0x0";const i=t[1],s=parseInt(i,10);return isNaN(s)?"0x0":`0x${s.toString(16)}`},isWalletGetAssetsResponse(e){return"object"==typeof e&&null!==e&&Object.values(e).every(e=>Array.isArray(e)&&e.every(e=>this.isValidAsset(e)))},isValidAsset:e=>"object"==typeof e&&null!==e&&"string"==typeof e.address&&"string"==typeof e.balance&&("ERC20"===e.type||"NATIVE"===e.type)&&"object"==typeof e.metadata&&null!==e.metadata&&"string"==typeof e.metadata.name&&"string"==typeof e.metadata.symbol&&"number"==typeof e.metadata.decimals&&"number"==typeof e.metadata.price&&"string"==typeof e.metadata.iconUrl}},37876:(e,t,i)=>{i.d(t,{Ay:()=>K});var s=i(98752),r=i(70255),n=i(21910),o=i(91315),a=i(43039),c=i(50046),h=i.n(c),d=i(14350);const l="client",u=`wc@2:${l}:`,p=l,f="WALLETCONNECT_DEEPLINK_CHOICE",g="Proposal expired",m=o.SEVEN_DAYS,b={wc_sessionPropose:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1104},res:{ttl:o.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1106},res:{ttl:o.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:o.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1112},res:{ttl:o.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:o.ONE_DAY,prompt:!1,tag:1114},res:{ttl:o.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:o.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:o.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:o.FIVE_MINUTES,prompt:!1,tag:1119}}},y={min:o.FIVE_MINUTES,max:o.SEVEN_DAYS},w="IDLE",v="ACTIVE",I={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},E=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],_="wc@1.5:auth:",A=`${_}:PUB_KEY`;var N=Object.defineProperty,C=Object.defineProperties,S=Object.getOwnPropertyDescriptors,P=Object.getOwnPropertySymbols,O=Object.prototype.hasOwnProperty,T=Object.prototype.propertyIsEnumerable,x=(e,t,i)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,k=(e,t)=>{for(var i in t||(t={}))O.call(t,i)&&x(e,i,t[i]);if(P)for(var i of P(t))T.call(t,i)&&x(e,i,t[i]);return e},R=(e,t)=>C(e,S(t)),M=(e,t,i)=>x(e,"symbol"!=typeof t?t+"":t,i);class U extends n.yJ{constructor(e){super(e),M(this,"name","engine"),M(this,"events",new(h())),M(this,"initialized",!1),M(this,"requestQueue",{state:w,queue:[]}),M(this,"sessionRequestQueue",{state:w,queue:[]}),M(this,"requestQueueDelay",o.ONE_SECOND),M(this,"expectedPairingMethodMap",new Map),M(this,"recentlyDeletedMap",new Map),M(this,"recentlyDeletedLimit",200),M(this,"relayMessageCache",[]),M(this,"pendingSessions",new Map),M(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(b)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,o.toMiliseconds)(this.requestQueueDelay)))}),M(this,"connect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const t=R(k({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t);const{pairingTopic:i,requiredNamespaces:r,optionalNamespaces:n,sessionProperties:c,scopedProperties:h,relays:l}=t;let u,p=i,f=!1;try{if(p){const e=this.client.core.pairing.pairings.get(p);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),f=e.active}}catch(e){throw this.client.logger.error(`connect() -> pairing.get(${p}) failed`),e}if(!p||!f){const{topic:e,uri:t}=await this.client.core.pairing.create();p=e,u=t}if(!p){const{message:e}=(0,a.GuA)("NO_MATCHING_KEY",`connect() pairing topic: ${p}`);throw new Error(e)}const m=await this.client.core.crypto.generateKeyPair(),y=b.wc_sessionPropose.req.ttl||o.FIVE_MINUTES,w=(0,a.Xw0)(y),v=R(k(k({requiredNamespaces:r,optionalNamespaces:n,relays:l??[{protocol:s.sD}],proposer:{publicKey:m,metadata:this.client.metadata},expiryTimestamp:w,pairingTopic:p},c&&{sessionProperties:c}),h&&{scopedProperties:h}),{id:(0,d.payloadId)()}),I=(0,a.hEn)("session_connect",v.id),{reject:E,resolve:_,done:A}=(0,a.Wx8)(y,g),N=({id:e})=>{e===v.id&&(this.client.events.off("proposal_expire",N),this.pendingSessions.delete(v.id),this.events.emit(I,{error:{message:g,code:0}}))};return this.client.events.on("proposal_expire",N),this.events.once(I,({error:e,session:t})=>{this.client.events.off("proposal_expire",N),e?E(e):t&&_(t)}),await this.sendRequest({topic:p,method:"wc_sessionPropose",params:v,throwOnFailedPublish:!0,clientRpcId:v.id}),await this.setProposal(v.id,v),{uri:u,approval:A}}),M(this,"pair",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(e)}catch(e){throw this.client.logger.error("pair() failed"),e}}),M(this,"approve",async e=>{var t,i,r;const n=this.client.core.eventClient.createEvent({properties:{topic:null==(t=e?.id)?void 0:t.toString(),trace:[s.$I.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(e){throw n.setError(s.U.no_internet_connection),e}try{await this.isValidProposalId(e?.id)}catch(t){throw this.client.logger.error(`approve() -> proposal.get(${e?.id}) failed`),n.setError(s.U.proposal_not_found),t}try{await this.isValidApprove(e)}catch(e){throw this.client.logger.error("approve() -> isValidApprove() failed"),n.setError(s.U.session_approve_namespace_validation_failure),e}const{id:o,relayProtocol:c,namespaces:h,sessionProperties:d,scopedProperties:l,sessionConfig:u}=e,p=this.client.proposal.get(o);this.client.core.eventClient.deleteEvent({eventId:n.eventId});const{pairingTopic:f,proposer:g,requiredNamespaces:b,optionalNamespaces:y}=p;let w=null==(i=this.client.core.eventClient)?void 0:i.getEvent({topic:f});w||(w=null==(r=this.client.core.eventClient)?void 0:r.createEvent({type:s.$I.session_approve_started,properties:{topic:f,trace:[s.$I.session_approve_started,s.$I.session_namespaces_validation_success]}}));const v=await this.client.core.crypto.generateKeyPair(),I=g.publicKey,E=await this.client.core.crypto.generateSharedKey(v,I),_=k(k(k({relay:{protocol:c??"irn"},namespaces:h,controller:{publicKey:v,metadata:this.client.metadata},expiry:(0,a.Xw0)(m)},d&&{sessionProperties:d}),l&&{scopedProperties:l}),u&&{sessionConfig:u}),A=s.cV.relay;w.addTrace(s.$I.subscribing_session_topic);try{await this.client.core.relayer.subscribe(E,{transportType:A})}catch(e){throw w.setError(s.U.subscribe_session_topic_failure),e}w.addTrace(s.$I.subscribe_session_topic_success);const N=R(k({},_),{topic:E,requiredNamespaces:b,optionalNamespaces:y,pairingTopic:f,acknowledged:!1,self:_.controller,peer:{publicKey:g.publicKey,metadata:g.metadata},controller:v,transportType:s.cV.relay});await this.client.session.set(E,N),w.addTrace(s.$I.store_session);try{w.addTrace(s.$I.publishing_session_settle),await this.sendRequest({topic:E,method:"wc_sessionSettle",params:_,throwOnFailedPublish:!0}).catch(e=>{throw w?.setError(s.U.session_settle_publish_failure),e}),w.addTrace(s.$I.session_settle_publish_success),w.addTrace(s.$I.publishing_session_approve),await this.sendResult({id:o,topic:f,result:{relay:{protocol:c??"irn"},responderPublicKey:v},throwOnFailedPublish:!0}).catch(e=>{throw w?.setError(s.U.session_approve_publish_failure),e}),w.addTrace(s.$I.session_approve_publish_success)}catch(e){throw this.client.logger.error(e),this.client.session.delete(E,(0,a.Hjj)("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(E),e}return this.client.core.eventClient.deleteEvent({eventId:w.eventId}),await this.client.core.pairing.updateMetadata({topic:f,metadata:g.metadata}),await this.client.proposal.delete(o,(0,a.Hjj)("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:f}),await this.setExpiry(E,(0,a.Xw0)(m)),{topic:E,acknowledged:()=>Promise.resolve(this.client.session.get(E))}}),M(this,"reject",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(e)}catch(e){throw this.client.logger.error("reject() -> isValidReject() failed"),e}const{id:t,reason:i}=e;let s;try{s=this.client.proposal.get(t).pairingTopic}catch(e){throw this.client.logger.error(`reject() -> proposal.get(${t}) failed`),e}s&&(await this.sendError({id:t,topic:s,error:i,rpcOpts:b.wc_sessionPropose.reject}),await this.client.proposal.delete(t,(0,a.Hjj)("USER_DISCONNECTED")))}),M(this,"update",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(e)}catch(e){throw this.client.logger.error("update() -> isValidUpdate() failed"),e}const{topic:t,namespaces:i}=e,{done:s,resolve:r,reject:n}=(0,a.Wx8)(),o=(0,d.payloadId)(),c=(0,d.getBigIntRpcId)().toString(),h=this.client.session.get(t).namespaces;return this.events.once((0,a.hEn)("session_update",o),({error:e})=>{e?n(e):r()}),await this.client.session.update(t,{namespaces:i}),await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:i},throwOnFailedPublish:!0,clientRpcId:o,relayRpcId:c}).catch(e=>{this.client.logger.error(e),this.client.session.update(t,{namespaces:h}),n(e)}),{acknowledged:s}}),M(this,"extend",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(e)}catch(e){throw this.client.logger.error("extend() -> isValidExtend() failed"),e}const{topic:t}=e,i=(0,d.payloadId)(),{done:s,resolve:r,reject:n}=(0,a.Wx8)();return this.events.once((0,a.hEn)("session_extend",i),({error:e})=>{e?n(e):r()}),await this.setExpiry(t,(0,a.Xw0)(m)),this.sendRequest({topic:t,method:"wc_sessionExtend",params:{},clientRpcId:i,throwOnFailedPublish:!0}).catch(e=>{n(e)}),{acknowledged:s}}),M(this,"request",async e=>{this.isInitialized();try{await this.isValidRequest(e)}catch(e){throw this.client.logger.error("request() -> isValidRequest() failed"),e}const{chainId:t,request:i,topic:r,expiry:n=b.wc_sessionRequest.req.ttl}=e,o=this.client.session.get(r);o?.transportType===s.cV.relay&&await this.confirmOnlineStateOrThrow();const c=(0,d.payloadId)(),h=(0,d.getBigIntRpcId)().toString(),{done:l,resolve:u,reject:p}=(0,a.Wx8)(n,"Request expired. Please try again.");this.events.once((0,a.hEn)("session_request",c),({error:e,result:t})=>{e?p(e):u(t)});const g="wc_sessionRequest",m=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);if(m)return await this.sendRequest({clientRpcId:c,relayRpcId:h,topic:r,method:g,params:{request:R(k({},i),{expiryTimestamp:(0,a.Xw0)(n)}),chainId:t},expiry:n,throwOnFailedPublish:!0,appLink:m}).catch(e=>p(e)),this.client.events.emit("session_request_sent",{topic:r,request:i,chainId:t,id:c}),await l();const y={request:R(k({},i),{expiryTimestamp:(0,a.Xw0)(n)}),chainId:t},w=this.shouldSetTVF(g,y);return await Promise.all([new Promise(async e=>{await this.sendRequest(k({clientRpcId:c,relayRpcId:h,topic:r,method:g,params:y,expiry:n,throwOnFailedPublish:!0},w&&{tvf:this.getTVFParams(c,y)})).catch(e=>p(e)),this.client.events.emit("session_request_sent",{topic:r,request:i,chainId:t,id:c}),e()}),new Promise(async e=>{var t;if(null==(t=o.sessionConfig)||!t.disableDeepLink){const e=await(0,a.jTh)(this.client.core.storage,f);await(0,a.n3s)({id:c,topic:r,wcDeepLink:e})}e()}),l()]).then(e=>e[2])}),M(this,"respond",async e=>{this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:i}=e,{id:r}=i,n=this.client.session.get(t);n.transportType===s.cV.relay&&await this.confirmOnlineStateOrThrow();const o=this.getAppLinkIfEnabled(n.peer.metadata,n.transportType);(0,d.isJsonRpcResult)(i)?await this.sendResult({id:r,topic:t,result:i.result,throwOnFailedPublish:!0,appLink:o}):(0,d.isJsonRpcError)(i)&&await this.sendError({id:r,topic:t,error:i.error,appLink:o}),this.cleanupAfterResponse(e)}),M(this,"ping",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(e)}catch(e){throw this.client.logger.error("ping() -> isValidPing() failed"),e}const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=(0,d.payloadId)(),i=(0,d.getBigIntRpcId)().toString(),{done:s,resolve:r,reject:n}=(0,a.Wx8)();this.events.once((0,a.hEn)("session_ping",e),({error:e})=>{e?n(e):r()}),await Promise.all([this.sendRequest({topic:t,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:e,relayRpcId:i}),s()])}else this.client.core.pairing.pairings.keys.includes(t)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:t}))}),M(this,"emit",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(e);const{topic:t,event:i,chainId:s}=e,r=(0,d.getBigIntRpcId)().toString(),n=(0,d.payloadId)();await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:i,chainId:s},throwOnFailedPublish:!0,relayRpcId:r,clientRpcId:n})}),M(this,"disconnect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(e);const{topic:t}=e;if(this.client.session.keys.includes(t))await this.sendRequest({topic:t,method:"wc_sessionDelete",params:(0,a.Hjj)("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:t,emitEvent:!1});else{if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=(0,a.GuA)("MISMATCHED_TOPIC",`Session or pairing topic not found: ${t}`);throw new Error(e)}await this.client.core.pairing.disconnect({topic:t})}}),M(this,"find",e=>(this.isInitialized(),this.client.session.getAll().filter(t=>(0,a.HNf)(t,e)))),M(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),M(this,"authenticate",async(e,t)=>{var i;this.isInitialized(),this.isValidAuthenticate(e);const r=t&&this.client.core.linkModeSupportedApps.includes(t)&&(null==(i=this.client.metadata.redirect)?void 0:i.linkMode),n=r?s.cV.link_mode:s.cV.relay;n===s.cV.relay&&await this.confirmOnlineStateOrThrow();const{chains:o,statement:c="",uri:h,domain:l,nonce:u,type:p,exp:f,nbf:g,methods:y=[],expiry:w}=e,v=[...e.resources||[]],{topic:I,uri:E}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:n});this.client.logger.info({message:"Generated new pairing",pairing:{topic:I,uri:E}});const _=await this.client.core.crypto.generateKeyPair(),N=(0,a.EN$)(_);if(await Promise.all([this.client.auth.authKeys.set(A,{responseTopic:N,publicKey:_}),this.client.auth.pairingTopics.set(N,{topic:N,pairingTopic:I})]),await this.client.core.relayer.subscribe(N,{transportType:n}),this.client.logger.info(`sending request to new pairing topic: ${I}`),y.length>0){const{namespace:e}=(0,a._Yb)(o[0]);let t=(0,a.e8_)(e,"request",y);(0,a.VBM)(v)&&(t=(0,a.hVC)(t,v.pop())),v.push(t)}const C=w&&w>b.wc_sessionAuthenticate.req.ttl?w:b.wc_sessionAuthenticate.req.ttl,S={authPayload:{type:p??"caip122",chains:o,statement:c,aud:h,domain:l,version:"1",nonce:u,iat:(new Date).toISOString(),exp:f,nbf:g,resources:v},requester:{publicKey:_,metadata:this.client.metadata},expiryTimestamp:(0,a.Xw0)(C)},P={requiredNamespaces:{},optionalNamespaces:{eip155:{chains:o,methods:[...new Set(["personal_sign",...y])],events:["chainChanged","accountsChanged"]}},relays:[{protocol:"irn"}],pairingTopic:I,proposer:{publicKey:_,metadata:this.client.metadata},expiryTimestamp:(0,a.Xw0)(b.wc_sessionPropose.req.ttl),id:(0,d.payloadId)()},{done:O,resolve:T,reject:x}=(0,a.Wx8)(C,"Request expired"),M=(0,d.payloadId)(),U=(0,a.hEn)("session_connect",P.id),D=(0,a.hEn)("session_request",M),j=async({error:e,session:t})=>{this.events.off(D,L),e?x(e):t&&T({session:t})},L=async e=>{var i,r,o;if(await this.deletePendingAuthRequest(M,{message:"fulfilled",code:0}),e.error){const t=(0,a.Hjj)("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return e.error.code===t.code?void 0:(this.events.off(U,j),x(e.error.message))}await this.deleteProposal(P.id),this.events.off(U,j);const{cacaos:c,responder:h}=e.result,d=[],l=[];for(const e of c){await(0,a.IjX)({cacao:e,projectId:this.client.core.projectId})||(this.client.logger.error(e,"Signature verification failed"),x((0,a.Hjj)("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:t}=e,i=(0,a.VBM)(t.resources),s=[(0,a.xkc)(t.iss)],r=(0,a.q_h)(t.iss);if(i){const e=(0,a.sc_)(i),t=(0,a.WWN)(i);d.push(...e),s.push(...t)}for(const e of s)l.push(`${e}:${r}`)}const u=await this.client.core.crypto.generateSharedKey(_,h.publicKey);let p;d.length>0&&(p={topic:u,acknowledged:!0,self:{publicKey:_,metadata:this.client.metadata},peer:h,controller:h.publicKey,expiry:(0,a.Xw0)(m),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:I,namespaces:(0,a.Van)([...new Set(d)],[...new Set(l)]),transportType:n},await this.client.core.relayer.subscribe(u,{transportType:n}),await this.client.session.set(u,p),I&&await this.client.core.pairing.updateMetadata({topic:I,metadata:h.metadata}),p=this.client.session.get(u)),null!=(i=this.client.metadata.redirect)&&i.linkMode&&null!=(r=h.metadata.redirect)&&r.linkMode&&null!=(o=h.metadata.redirect)&&o.universal&&t&&(this.client.core.addLinkModeSupportedApp(h.metadata.redirect.universal),this.client.session.update(u,{transportType:s.cV.link_mode})),T({auths:c,session:p})};let q;this.events.once(U,j),this.events.once(D,L);try{if(r){const e=(0,d.formatJsonRpcRequest)("wc_sessionAuthenticate",S,M);this.client.core.history.set(I,e);const i=await this.client.core.crypto.encode("",e,{type:a.EHS,encoding:a.Pa8});q=(0,a.$Bq)(t,I,i)}else await Promise.all([this.sendRequest({topic:I,method:"wc_sessionAuthenticate",params:S,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:M}),this.sendRequest({topic:I,method:"wc_sessionPropose",params:P,expiry:b.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:P.id})])}catch(e){throw this.events.off(U,j),this.events.off(D,L),e}return await this.setProposal(P.id,P),await this.setAuthRequest(M,{request:R(k({},S),{verifyContext:{}}),pairingTopic:I,transportType:n}),{uri:q??E,response:O}}),M(this,"approveSessionAuthenticate",async e=>{const{id:t,auths:i}=e,r=this.client.core.eventClient.createEvent({properties:{topic:t.toString(),trace:[s.U$.authenticated_session_approve_started]}});try{this.isInitialized()}catch(e){throw r.setError(s.Tn.no_internet_connection),e}const n=this.getPendingAuthRequest(t);if(!n)throw r.setError(s.Tn.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${t}`);const o=n.transportType||s.cV.relay;o===s.cV.relay&&await this.confirmOnlineStateOrThrow();const c=n.requester.publicKey,h=await this.client.core.crypto.generateKeyPair(),d=(0,a.EN$)(c),l={type:a.Lp_,receiverPublicKey:c,senderPublicKey:h},u=[],p=[];for(const e of i){if(!await(0,a.IjX)({cacao:e,projectId:this.client.core.projectId})){r.setError(s.Tn.invalid_cacao);const e=(0,a.Hjj)("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:t,topic:d,error:e,encodeOpts:l}),new Error(e.message)}r.addTrace(s.U$.cacaos_verified);const{p:i}=e,n=(0,a.VBM)(i.resources),o=[(0,a.xkc)(i.iss)],c=(0,a.q_h)(i.iss);if(n){const e=(0,a.sc_)(n),t=(0,a.WWN)(n);u.push(...e),o.push(...t)}for(const e of o)p.push(`${e}:${c}`)}const f=await this.client.core.crypto.generateSharedKey(h,c);let g;if(r.addTrace(s.U$.create_authenticated_session_topic),u?.length>0){g={topic:f,acknowledged:!0,self:{publicKey:h,metadata:this.client.metadata},peer:{publicKey:c,metadata:n.requester.metadata},controller:c,expiry:(0,a.Xw0)(m),authentication:i,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:n.pairingTopic,namespaces:(0,a.Van)([...new Set(u)],[...new Set(p)]),transportType:o},r.addTrace(s.U$.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(f,{transportType:o})}catch(e){throw r.setError(s.Tn.subscribe_authenticated_session_topic_failure),e}r.addTrace(s.U$.subscribe_authenticated_session_topic_success),await this.client.session.set(f,g),r.addTrace(s.U$.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:n.pairingTopic,metadata:n.requester.metadata})}r.addTrace(s.U$.publishing_authenticated_session_approve);try{await this.sendResult({topic:d,id:t,result:{cacaos:i,responder:{publicKey:h,metadata:this.client.metadata}},encodeOpts:l,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(n.requester.metadata,o)})}catch(e){throw r.setError(s.Tn.authenticated_session_approve_publish_failure),e}return await this.client.auth.requests.delete(t,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:n.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:r.eventId}),{session:g}}),M(this,"rejectSessionAuthenticate",async e=>{this.isInitialized();const{id:t,reason:i}=e,r=this.getPendingAuthRequest(t);if(!r)throw new Error(`Could not find pending auth request with id ${t}`);r.transportType===s.cV.relay&&await this.confirmOnlineStateOrThrow();const n=r.requester.publicKey,o=await this.client.core.crypto.generateKeyPair(),c=(0,a.EN$)(n),h={type:a.Lp_,receiverPublicKey:n,senderPublicKey:o};await this.sendError({id:t,topic:c,error:i,encodeOpts:h,rpcOpts:b.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(r.requester.metadata,r.transportType)}),await this.client.auth.requests.delete(t,{message:"rejected",code:0}),await this.client.proposal.delete(t,(0,a.Hjj)("USER_DISCONNECTED"))}),M(this,"formatAuthMessage",e=>{this.isInitialized();const{request:t,iss:i}=e;return(0,a.hwK)(t,i)}),M(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(0!==this.relayMessageCache.length)for(;this.relayMessageCache.length>0;)try{const e=this.relayMessageCache.shift();e&&await this.onRelayMessage(e)}catch(e){this.client.logger.error(e)}},50)}),M(this,"cleanupDuplicatePairings",async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.pairingTopic),i=this.client.core.pairing.pairings.getAll().filter(i=>{var s,r;return(null==(s=i.peerMetadata)?void 0:s.url)&&(null==(r=i.peerMetadata)?void 0:r.url)===e.peer.metadata.url&&i.topic&&i.topic!==t.topic});if(0===i.length)return;this.client.logger.info(`Cleaning up ${i.length} duplicate pairing(s)`),await Promise.all(i.map(e=>this.client.core.pairing.disconnect({topic:e.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(e){this.client.logger.error(e)}}),M(this,"deleteSession",async e=>{var t;const{topic:i,expirerHasDeleted:s=!1,emitEvent:r=!0,id:n=0}=e,{self:o}=this.client.session.get(i);await this.client.core.relayer.unsubscribe(i),await this.client.session.delete(i,(0,a.Hjj)("USER_DISCONNECTED")),this.addToRecentlyDeleted(i,"session"),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(i)&&await this.client.core.crypto.deleteSymKey(i),s||this.client.core.expirer.del(i),this.client.core.storage.removeItem(f).catch(e=>this.client.logger.warn(e)),this.getPendingSessionRequests().forEach(e=>{e.topic===i&&this.deletePendingSessionRequest(e.id,(0,a.Hjj)("USER_DISCONNECTED"))}),i===(null==(t=this.sessionRequestQueue.queue[0])?void 0:t.topic)&&(this.sessionRequestQueue.state=w),r&&this.client.events.emit("session_delete",{id:n,topic:i})}),M(this,"deleteProposal",async(e,t)=>{if(t)try{const t=this.client.proposal.get(e),i=this.client.core.eventClient.getEvent({topic:t.pairingTopic});i?.setError(s.U.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(e,(0,a.Hjj)("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")}),M(this,"deletePendingSessionRequest",async(e,t,i=!1)=>{await Promise.all([this.client.pendingRequest.delete(e,t),i?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(t=>t.id!==e),i&&(this.sessionRequestQueue.state=w,this.client.events.emit("session_request_expire",{id:e}))}),M(this,"deletePendingAuthRequest",async(e,t,i=!1)=>{await Promise.all([this.client.auth.requests.delete(e,t),i?Promise.resolve():this.client.core.expirer.del(e)])}),M(this,"setExpiry",async(e,t)=>{this.client.session.keys.includes(e)&&(this.client.core.expirer.set(e,t),await this.client.session.update(e,{expiry:t}))}),M(this,"setProposal",async(e,t)=>{this.client.core.expirer.set(e,(0,a.Xw0)(b.wc_sessionPropose.req.ttl)),await this.client.proposal.set(e,t)}),M(this,"setAuthRequest",async(e,t)=>{const{request:i,pairingTopic:r,transportType:n=s.cV.relay}=t;this.client.core.expirer.set(e,i.expiryTimestamp),await this.client.auth.requests.set(e,{authPayload:i.authPayload,requester:i.requester,expiryTimestamp:i.expiryTimestamp,id:e,pairingTopic:r,verifyContext:i.verifyContext,transportType:n})}),M(this,"setPendingSessionRequest",async e=>{const{id:t,topic:i,params:s,verifyContext:r}=e,n=s.request.expiryTimestamp||(0,a.Xw0)(b.wc_sessionRequest.req.ttl);this.client.core.expirer.set(t,n),await this.client.pendingRequest.set(t,{id:t,topic:i,params:s,verifyContext:r})}),M(this,"sendRequest",async e=>{const{topic:t,method:s,params:r,expiry:n,relayRpcId:o,clientRpcId:c,throwOnFailedPublish:h,appLink:l,tvf:u}=e,p=(0,d.formatJsonRpcRequest)(s,r,c);let f;const g=!!l;try{const e=g?a.Pa8:a.EWt;f=await this.client.core.crypto.encode(t,p,{encoding:e})}catch(e){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${t} failed`),e}let m;if(E.includes(s)){const e=(0,a.ALl)(JSON.stringify(p)),t=(0,a.ALl)(f);m=await this.client.core.verify.register({id:t,decryptedId:e})}const y=b[s].req;if(y.attestation=m,n&&(y.ttl=n),o&&(y.id=o),this.client.core.history.set(t,p),g){const e=(0,a.$Bq)(l,t,f);await i.g.Linking.openURL(e,this.client.name)}else{const e=b[s].req;n&&(e.ttl=n),o&&(e.id=o),e.tvf=R(k({},u),{correlationId:p.id}),h?(e.internal=R(k({},e.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,f,e)):this.client.core.relayer.publish(t,f,e).catch(e=>this.client.logger.error(e))}return p.id}),M(this,"sendResult",async e=>{const{id:t,topic:s,result:r,throwOnFailedPublish:n,encodeOpts:o,appLink:c}=e,h=(0,d.formatJsonRpcResult)(t,r);let l;const u=c&&typeof(null==i.g?void 0:i.g.Linking)<"u";try{const e=u?a.Pa8:a.EWt;l=await this.client.core.crypto.encode(s,h,R(k({},o||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${s} failed`),e}let p,f;try{p=await this.client.core.history.get(s,t);const e=p.request;try{this.shouldSetTVF(e.method,e.params)&&(f=this.getTVFParams(t,e.params,r))}catch(e){this.client.logger.warn("sendResult() -> getTVFParams() failed",e)}}catch(e){throw this.client.logger.error(`sendResult() -> history.get(${s}, ${t}) failed`),e}if(u){const e=(0,a.$Bq)(c,s,l);await i.g.Linking.openURL(e,this.client.name)}else{const e=p.request.method,i=b[e].res;i.tvf=R(k({},f),{correlationId:t}),n?(i.internal=R(k({},i.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(s,l,i)):this.client.core.relayer.publish(s,l,i).catch(e=>this.client.logger.error(e))}await this.client.core.history.resolve(h)}),M(this,"sendError",async e=>{const{id:t,topic:s,error:r,encodeOpts:n,rpcOpts:o,appLink:c}=e,h=(0,d.formatJsonRpcError)(t,r);let l;const u=c&&typeof(null==i.g?void 0:i.g.Linking)<"u";try{const e=u?a.Pa8:a.EWt;l=await this.client.core.crypto.encode(s,h,R(k({},n||{}),{encoding:e}))}catch(e){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${s} failed`),e}let p;try{p=await this.client.core.history.get(s,t)}catch(e){throw this.client.logger.error(`sendError() -> history.get(${s}, ${t}) failed`),e}if(u){const e=(0,a.$Bq)(c,s,l);await i.g.Linking.openURL(e,this.client.name)}else{const e=p.request.method,t=o||b[e].res;this.client.core.relayer.publish(s,l,t)}await this.client.core.history.resolve(h)}),M(this,"cleanup",async()=>{const e=[],t=[];this.client.session.getAll().forEach(t=>{let i=!1;(0,a._dF)(t.expiry)&&(i=!0),this.client.core.crypto.keychain.has(t.topic)||(i=!0),i&&e.push(t.topic)}),this.client.proposal.getAll().forEach(e=>{(0,a._dF)(e.expiryTimestamp)&&t.push(e.id)}),await Promise.all([...e.map(e=>this.deleteSession({topic:e})),...t.map(e=>this.deleteProposal(e))])}),M(this,"onProviderMessageEvent",async e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):await this.onRelayMessage(e)}),M(this,"onRelayEventRequest",async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()}),M(this,"processRequestsQueue",async()=>{if(this.requestQueue.state!==v){for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=v;const e=this.requestQueue.queue.shift();if(e)try{await this.processRequest(e)}catch(e){this.client.logger.warn(e)}}this.requestQueue.state=w}else this.client.logger.info("Request queue already active, skipping...")}),M(this,"processRequest",async e=>{const{topic:t,payload:i,attestation:s,transportType:r,encryptedId:n}=e,o=i.method;if(!this.shouldIgnorePairingRequest({topic:t,requestMethod:o}))switch(o){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:t,payload:i,attestation:s,encryptedId:n});case"wc_sessionSettle":return await this.onSessionSettleRequest(t,i);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(t,i);case"wc_sessionExtend":return await this.onSessionExtendRequest(t,i);case"wc_sessionPing":return await this.onSessionPingRequest(t,i);case"wc_sessionDelete":return await this.onSessionDeleteRequest(t,i);case"wc_sessionRequest":return await this.onSessionRequest({topic:t,payload:i,attestation:s,encryptedId:n,transportType:r});case"wc_sessionEvent":return await this.onSessionEventRequest(t,i);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:t,payload:i,attestation:s,encryptedId:n,transportType:r});default:return this.client.logger.info(`Unsupported request method ${o}`)}}),M(this,"onRelayEventResponse",async e=>{const{topic:t,payload:i,transportType:s}=e,r=(await this.client.core.history.get(t,i.id)).request.method;switch(r){case"wc_sessionPropose":return this.onSessionProposeResponse(t,i,s);case"wc_sessionSettle":return this.onSessionSettleResponse(t,i);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,i);case"wc_sessionExtend":return this.onSessionExtendResponse(t,i);case"wc_sessionPing":return this.onSessionPingResponse(t,i);case"wc_sessionRequest":return this.onSessionRequestResponse(t,i);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(t,i);default:return this.client.logger.info(`Unsupported response method ${r}`)}}),M(this,"onRelayEventUnknownPayload",e=>{const{topic:t}=e,{message:i}=(0,a.GuA)("MISSING_OR_INVALID",`Decoded payload on topic ${t} is not identifiable as a JSON-RPC request or a response.`);throw new Error(i)}),M(this,"shouldIgnorePairingRequest",e=>{const{topic:t,requestMethod:i}=e,s=this.expectedPairingMethodMap.get(t);return!(!s||s.includes(i)||!(s.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0))}),M(this,"onSessionProposeRequest",async e=>{const{topic:t,payload:i,attestation:r,encryptedId:n}=e,{params:o,id:c}=i;try{const e=this.client.core.eventClient.getEvent({topic:t});0===this.client.events.listenerCount("session_proposal")&&(console.warn("No listener for session_proposal event"),e?.setError(s.S$.proposal_listener_not_found)),this.isValidConnect(k({},i.params));const h=o.expiryTimestamp||(0,a.Xw0)(b.wc_sessionPropose.req.ttl),d=k({id:c,pairingTopic:t,expiryTimestamp:h},o);await this.setProposal(c,d);const l=await this.getVerifyContext({attestationId:r,hash:(0,a.ALl)(JSON.stringify(i)),encryptedId:n,metadata:d.proposer.metadata});e?.addTrace(s.$w.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:d,verifyContext:l})}catch(e){await this.sendError({id:c,topic:t,error:e,rpcOpts:b.wc_sessionPropose.autoReject}),this.client.logger.error(e)}}),M(this,"onSessionProposeResponse",async(e,t,i)=>{const{id:s}=t;if((0,d.isJsonRpcResult)(t)){const{result:r}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:r});const n=this.client.proposal.get(s);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:n});const o=n.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const a=r.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:a});const c=await this.client.core.crypto.generateSharedKey(o,a);this.pendingSessions.set(s,{sessionTopic:c,pairingTopic:e,proposalId:s,publicKey:o});const h=await this.client.core.relayer.subscribe(c,{transportType:i});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:h}),await this.client.core.pairing.activate({topic:e})}else if((0,d.isJsonRpcError)(t)){await this.client.proposal.delete(s,(0,a.Hjj)("USER_DISCONNECTED"));const e=(0,a.hEn)("session_connect",s);if(0===this.events.listenerCount(e))throw new Error(`emitting ${e} without any listeners, 954`);this.events.emit(e,{error:t.error})}}),M(this,"onSessionSettleRequest",async(e,t)=>{const{id:i,params:r}=t;try{this.isValidSessionSettleRequest(r);const{relay:i,controller:n,expiry:o,namespaces:c,sessionProperties:h,scopedProperties:d,sessionConfig:l}=t.params,u=[...this.pendingSessions.values()].find(t=>t.sessionTopic===e);if(!u)return this.client.logger.error(`Pending session not found for topic ${e}`);const p=this.client.proposal.get(u.proposalId),f=R(k(k(k({topic:e,relay:i,expiry:o,namespaces:c,acknowledged:!0,pairingTopic:u.pairingTopic,requiredNamespaces:p.requiredNamespaces,optionalNamespaces:p.optionalNamespaces,controller:n.publicKey,self:{publicKey:u.publicKey,metadata:this.client.metadata},peer:{publicKey:n.publicKey,metadata:n.metadata}},h&&{sessionProperties:h}),d&&{scopedProperties:d}),l&&{sessionConfig:l}),{transportType:s.cV.relay});await this.client.session.set(f.topic,f),await this.setExpiry(f.topic,f.expiry),await this.client.core.pairing.updateMetadata({topic:u.pairingTopic,metadata:f.peer.metadata}),this.client.events.emit("session_connect",{session:f}),this.events.emit((0,a.hEn)("session_connect",u.proposalId),{session:f}),this.pendingSessions.delete(u.proposalId),this.deleteProposal(u.proposalId,!1),this.cleanupDuplicatePairings(f),await this.sendResult({id:t.id,topic:e,result:!0,throwOnFailedPublish:!0})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),M(this,"onSessionSettleResponse",async(e,t)=>{const{id:i}=t;(0,d.isJsonRpcResult)(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit((0,a.hEn)("session_approve",i),{})):(0,d.isJsonRpcError)(t)&&(await this.client.session.delete(e,(0,a.Hjj)("USER_DISCONNECTED")),this.events.emit((0,a.hEn)("session_approve",i),{error:t.error}))}),M(this,"onSessionUpdateRequest",async(e,t)=>{const{params:i,id:s}=t;try{const t=`${e}_session_update`,r=a.nyL.get(t);if(r&&this.isRequestOutOfSync(r,s))return this.client.logger.warn(`Discarding out of sync request - ${s}`),void this.sendError({id:s,topic:e,error:(0,a.Hjj)("INVALID_UPDATE_REQUEST")});this.isValidUpdate(k({topic:e},i));try{a.nyL.set(t,s),await this.client.session.update(e,{namespaces:i.namespaces}),await this.sendResult({id:s,topic:e,result:!0,throwOnFailedPublish:!0})}catch(e){throw a.nyL.delete(t),e}this.client.events.emit("session_update",{id:s,topic:e,params:i})}catch(t){await this.sendError({id:s,topic:e,error:t}),this.client.logger.error(t)}}),M(this,"isRequestOutOfSync",(e,t)=>t.toString().slice(0,-3)<e.toString().slice(0,-3)),M(this,"onSessionUpdateResponse",(e,t)=>{const{id:i}=t,s=(0,a.hEn)("session_update",i);if(0===this.events.listenerCount(s))throw new Error(`emitting ${s} without any listeners`);(0,d.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_update",i),{}):(0,d.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_update",i),{error:t.error})}),M(this,"onSessionExtendRequest",async(e,t)=>{const{id:i}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,(0,a.Xw0)(m)),await this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:i,topic:e})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),M(this,"onSessionExtendResponse",(e,t)=>{const{id:i}=t,s=(0,a.hEn)("session_extend",i);if(0===this.events.listenerCount(s))throw new Error(`emitting ${s} without any listeners`);(0,d.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_extend",i),{}):(0,d.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_extend",i),{error:t.error})}),M(this,"onSessionPingRequest",async(e,t)=>{const{id:i}=t;try{this.isValidPing({topic:e}),await this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:i,topic:e})}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),M(this,"onSessionPingResponse",(e,t)=>{const{id:i}=t,s=(0,a.hEn)("session_ping",i);setTimeout(()=>{if(0===this.events.listenerCount(s))throw new Error(`emitting ${s} without any listeners 2176`);(0,d.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_ping",i),{}):(0,d.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_ping",i),{error:t.error})},500)}),M(this,"onSessionDeleteRequest",async(e,t)=>{const{id:i}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),Promise.all([new Promise(t=>{this.client.core.relayer.once(s.Jf.publish,async()=>{t(await this.deleteSession({topic:e,id:i}))})}),this.sendResult({id:i,topic:e,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:(0,a.Hjj)("USER_DISCONNECTED")})]).catch(e=>this.client.logger.error(e))}catch(e){this.client.logger.error(e)}}),M(this,"onSessionRequest",async e=>{var t,i,r;const{topic:n,payload:o,attestation:c,encryptedId:h,transportType:l}=e,{id:u,params:p}=o;try{await this.isValidRequest(k({topic:n},p));const e=this.client.session.get(n),o={id:u,topic:n,params:p,verifyContext:await this.getVerifyContext({attestationId:c,hash:(0,a.ALl)(JSON.stringify((0,d.formatJsonRpcRequest)("wc_sessionRequest",p,u))),encryptedId:h,metadata:e.peer.metadata,transportType:l})};await this.setPendingSessionRequest(o),l===s.cV.link_mode&&null!=(t=e.peer.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(null==(i=e.peer.metadata.redirect)?void 0:i.universal),null!=(r=this.client.signConfig)&&r.disableRequestQueue?this.emitSessionRequest(o):(this.addSessionRequestToSessionRequestQueue(o),this.processSessionRequestQueue())}catch(e){await this.sendError({id:u,topic:n,error:e}),this.client.logger.error(e)}}),M(this,"onSessionRequestResponse",(e,t)=>{const{id:i}=t,s=(0,a.hEn)("session_request",i);if(0===this.events.listenerCount(s))throw new Error(`emitting ${s} without any listeners`);(0,d.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_request",i),{result:t.result}):(0,d.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_request",i),{error:t.error})}),M(this,"onSessionEventRequest",async(e,t)=>{const{id:i,params:s}=t;try{const t=`${e}_session_event_${s.event.name}`,r=a.nyL.get(t);if(r&&this.isRequestOutOfSync(r,i))return void this.client.logger.info(`Discarding out of sync request - ${i}`);this.isValidEmit(k({topic:e},s)),this.client.events.emit("session_event",{id:i,topic:e,params:s}),a.nyL.set(t,i)}catch(t){await this.sendError({id:i,topic:e,error:t}),this.client.logger.error(t)}}),M(this,"onSessionAuthenticateResponse",(e,t)=>{const{id:i}=t;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:t}),(0,d.isJsonRpcResult)(t)?this.events.emit((0,a.hEn)("session_request",i),{result:t.result}):(0,d.isJsonRpcError)(t)&&this.events.emit((0,a.hEn)("session_request",i),{error:t.error})}),M(this,"onSessionAuthenticateRequest",async e=>{var t;const{topic:i,payload:r,attestation:n,encryptedId:o,transportType:c}=e;try{const{requester:e,authPayload:h,expiryTimestamp:d}=r.params,l=await this.getVerifyContext({attestationId:n,hash:(0,a.ALl)(JSON.stringify(r)),encryptedId:o,metadata:e.metadata,transportType:c}),u={requester:e,pairingTopic:i,id:r.id,authPayload:h,verifyContext:l,expiryTimestamp:d};await this.setAuthRequest(r.id,{request:u,pairingTopic:i,transportType:c}),c===s.cV.link_mode&&null!=(t=e.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(e.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:i,params:r.params,id:r.id,verifyContext:l})}catch(e){this.client.logger.error(e);const t=r.params.requester.publicKey,s=await this.client.core.crypto.generateKeyPair(),n=this.getAppLinkIfEnabled(r.params.requester.metadata,c),o={type:a.Lp_,receiverPublicKey:t,senderPublicKey:s};await this.sendError({id:r.id,topic:i,error:e,encodeOpts:o,rpcOpts:b.wc_sessionAuthenticate.autoReject,appLink:n})}}),M(this,"addSessionRequestToSessionRequestQueue",e=>{this.sessionRequestQueue.queue.push(e)}),M(this,"cleanupAfterResponse",e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=w,this.processSessionRequestQueue()},(0,o.toMiliseconds)(this.requestQueueDelay))}),M(this,"cleanupPendingSentRequestsForTopic",({topic:e,error:t})=>{const i=this.client.core.history.pending;i.length>0&&i.filter(t=>t.topic===e&&"wc_sessionRequest"===t.request.method).forEach(e=>{const i=e.request.id,s=(0,a.hEn)("session_request",i);if(0===this.events.listenerCount(s))throw new Error(`emitting ${s} without any listeners`);this.events.emit((0,a.hEn)("session_request",e.request.id),{error:t})})}),M(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===v)return void this.client.logger.info("session request queue is already active.");const e=this.sessionRequestQueue.queue[0];if(e)try{this.sessionRequestQueue.state=v,this.emitSessionRequest(e)}catch(e){this.client.logger.error(e)}else this.client.logger.info("session request queue is empty.")}),M(this,"emitSessionRequest",e=>{this.client.events.emit("session_request",e)}),M(this,"onPairingCreated",e=>{if(e.methods&&this.expectedPairingMethodMap.set(e.topic,e.methods),e.active)return;const t=this.client.proposal.getAll().find(t=>t.pairingTopic===e.topic);t&&this.onSessionProposeRequest({topic:e.topic,payload:(0,d.formatJsonRpcRequest)("wc_sessionPropose",R(k({},t),{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties,scopedProperties:t.scopedProperties}),t.id)})}),M(this,"isValidConnect",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(e)}`);throw new Error(t)}const{pairingTopic:t,requiredNamespaces:i,optionalNamespaces:s,sessionProperties:r,scopedProperties:n,relays:o}=e;if((0,a.b07)(t)||await this.isValidPairingTopic(t),!(0,a.V9G)(o,!0)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`connect() relays: ${o}`);throw new Error(e)}if(!(0,a.b07)(i)&&0!==(0,a.aF0)(i)&&this.validateNamespaces(i,"requiredNamespaces"),!(0,a.b07)(s)&&0!==(0,a.aF0)(s)&&this.validateNamespaces(s,"optionalNamespaces"),(0,a.b07)(r)||this.validateSessionProps(r,"sessionProperties"),!(0,a.b07)(n)){this.validateSessionProps(n,"scopedProperties");const e=Object.keys(i||{}).concat(Object.keys(s||{}));if(!Object.keys(n).every(t=>e.includes(t)))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(n)}, required/optional namespaces: ${JSON.stringify(e)}`)}}),M(this,"validateNamespaces",(e,t)=>{const i=(0,a.esh)(e,"connect()",t);if(i)throw new Error(i.message)}),M(this,"isValidApprove",async e=>{if(!(0,a.TeY)(e))throw new Error((0,a.GuA)("MISSING_OR_INVALID",`approve() params: ${e}`).message);const{id:t,namespaces:i,relayProtocol:s,sessionProperties:r,scopedProperties:n}=e;this.checkRecentlyDeleted(t),await this.isValidProposalId(t);const o=this.client.proposal.get(t),c=(0,a.FiO)(i,"approve()");if(c)throw new Error(c.message);const h=(0,a.XqR)(o.requiredNamespaces,i,"approve()");if(h)throw new Error(h.message);if(!(0,a.Qhg)(s,!0)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`approve() relayProtocol: ${s}`);throw new Error(e)}if((0,a.b07)(r)||this.validateSessionProps(r,"sessionProperties"),!(0,a.b07)(n)){this.validateSessionProps(n,"scopedProperties");const e=new Set(Object.keys(i));if(!Object.keys(n).every(t=>e.has(t)))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(n)}, approved namespaces: ${Array.from(e).join(", ")}`)}}),M(this,"isValidReject",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`reject() params: ${e}`);throw new Error(t)}const{id:t,reason:i}=e;if(this.checkRecentlyDeleted(t),await this.isValidProposalId(t),!(0,a.X3c)(i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(i)}`);throw new Error(e)}}),M(this,"isValidSessionSettleRequest",e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${e}`);throw new Error(t)}const{relay:t,controller:i,namespaces:s,expiry:r}=e;if(!(0,a.kuU)(t)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const n=(0,a.tk0)(i,"onSessionSettleRequest()");if(n)throw new Error(n.message);const o=(0,a.FiO)(s,"onSessionSettleRequest()");if(o)throw new Error(o.message);if((0,a._dF)(r)){const{message:e}=(0,a.GuA)("EXPIRED","onSessionSettleRequest()");throw new Error(e)}}),M(this,"isValidUpdate",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`update() params: ${e}`);throw new Error(t)}const{topic:t,namespaces:i}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const s=this.client.session.get(t),r=(0,a.FiO)(i,"update()");if(r)throw new Error(r.message);const n=(0,a.XqR)(s.requiredNamespaces,i,"update()");if(n)throw new Error(n.message)}),M(this,"isValidExtend",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`extend() params: ${e}`);throw new Error(t)}const{topic:t}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t)}),M(this,"isValidRequest",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`request() params: ${e}`);throw new Error(t)}const{topic:t,request:i,chainId:s,expiry:r}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const{namespaces:n}=this.client.session.get(t);if(!(0,a.tLy)(n,s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() chainId: ${s}`);throw new Error(e)}if(!(0,a.iV1)(i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() ${JSON.stringify(i)}`);throw new Error(e)}if(!(0,a.oKp)(n,s,i.method)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() method: ${i.method}`);throw new Error(e)}if(r&&!(0,a.Hbs)(r,y)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`request() expiry: ${r}. Expiry must be a number (in seconds) between ${y.min} and ${y.max}`);throw new Error(e)}}),M(this,"isValidRespond",async e=>{var t;if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`respond() params: ${e}`);throw new Error(t)}const{topic:i,response:s}=e;try{await this.isValidSessionTopic(i)}catch(i){throw null!=(t=e?.response)&&t.id&&this.cleanupAfterResponse(e),i}if(!(0,a.M8n)(s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(s)}`);throw new Error(e)}}),M(this,"isValidPing",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),M(this,"isValidEmit",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`emit() params: ${e}`);throw new Error(t)}const{topic:t,event:i,chainId:s}=e;await this.isValidSessionTopic(t);const{namespaces:r}=this.client.session.get(t);if(!(0,a.tLy)(r,s)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() chainId: ${s}`);throw new Error(e)}if(!(0,a.FR8)(i)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(e)}if(!(0,a.z2N)(r,s,i.name)){const{message:e}=(0,a.GuA)("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(i)}`);throw new Error(e)}}),M(this,"isValidDisconnect",async e=>{if(!(0,a.TeY)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),M(this,"isValidAuthenticate",e=>{const{chains:t,uri:i,domain:s,nonce:r}=e;if(!Array.isArray(t)||0===t.length)throw new Error("chains is required and must be a non-empty array");if(!(0,a.Qhg)(i,!1))throw new Error("uri is required parameter");if(!(0,a.Qhg)(s,!1))throw new Error("domain is required parameter");if(!(0,a.Qhg)(r,!1))throw new Error("nonce is required parameter");if([...new Set(t.map(e=>(0,a._Yb)(e).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:n}=(0,a._Yb)(t[0]);if("eip155"!==n)throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),M(this,"getVerifyContext",async e=>{const{attestationId:t,hash:i,encryptedId:r,metadata:n,transportType:o}=e,a={verified:{verifyUrl:n.verifyUrl||s.WB,validation:"UNKNOWN",origin:n.url||""}};try{if(o===s.cV.link_mode){const e=this.getAppLinkIfEnabled(n,o);return a.verified.validation=e&&new URL(e).origin===new URL(n.url).origin?"VALID":"INVALID",a}const e=await this.client.core.verify.resolve({attestationId:t,hash:i,encryptedId:r,verifyUrl:n.verifyUrl});e&&(a.verified.origin=e.origin,a.verified.isScam=e.isScam,a.verified.validation=e.origin===new URL(n.url).origin?"VALID":"INVALID")}catch(e){this.client.logger.warn(e)}return this.client.logger.debug(`Verify context: ${JSON.stringify(a)}`),a}),M(this,"validateSessionProps",(e,t)=>{Object.values(e).forEach((i,s)=>{if(null==i){const{message:r}=(0,a.GuA)("MISSING_OR_INVALID",`${t} must contain an existing value for each key. Received: ${i} for key ${Object.keys(e)[s]}`);throw new Error(r)}})}),M(this,"getPendingAuthRequest",e=>{const t=this.client.auth.requests.get(e);return"object"==typeof t?t:void 0}),M(this,"addToRecentlyDeleted",(e,t)=>{if(this.recentlyDeletedMap.set(e,t),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let e=0;const t=this.recentlyDeletedLimit/2;for(const i of this.recentlyDeletedMap.keys()){if(e++>=t)break;this.recentlyDeletedMap.delete(i)}}}),M(this,"checkRecentlyDeleted",e=>{const t=this.recentlyDeletedMap.get(e);if(t){const{message:i}=(0,a.GuA)("MISSING_OR_INVALID",`Record was recently deleted - ${t}: ${e}`);throw new Error(i)}}),M(this,"isLinkModeEnabled",(e,t)=>{var r,n,o,a,c,h,d,l,u;return!(!e||t!==s.cV.link_mode)&&!0===(null==(n=null==(r=this.client.metadata)?void 0:r.redirect)?void 0:n.linkMode)&&void 0!==(null==(a=null==(o=this.client.metadata)?void 0:o.redirect)?void 0:a.universal)&&""!==(null==(h=null==(c=this.client.metadata)?void 0:c.redirect)?void 0:h.universal)&&void 0!==(null==(d=e?.redirect)?void 0:d.universal)&&""!==(null==(l=e?.redirect)?void 0:l.universal)&&!0===(null==(u=e?.redirect)?void 0:u.linkMode)&&this.client.core.linkModeSupportedApps.includes(e.redirect.universal)&&typeof(null==i.g?void 0:i.g.Linking)<"u"}),M(this,"getAppLinkIfEnabled",(e,t)=>{var i;return this.isLinkModeEnabled(e,t)?null==(i=e?.redirect)?void 0:i.universal:void 0}),M(this,"handleLinkModeMessage",({url:e})=>{if(!e||!e.includes("wc_ev")||!e.includes("topic"))return;const t=(0,a.$hI)(e,"topic")||"",i=decodeURIComponent((0,a.$hI)(e,"wc_ev")||""),r=this.client.session.keys.includes(t);r&&this.client.session.update(t,{transportType:s.cV.link_mode}),this.client.core.dispatchEnvelope({topic:t,message:i,sessionExists:r})}),M(this,"registerLinkModeListeners",async()=>{var e;if((0,a.w8K)()||(0,a.lVv)()&&null!=(e=this.client.metadata.redirect)&&e.linkMode){const e=null==i.g?void 0:i.g.Linking;if(typeof e<"u"){e.addEventListener("url",this.handleLinkModeMessage,this.client.name);const t=await e.getInitialURL();t&&setTimeout(()=>{this.handleLinkModeMessage({url:t})},50)}}}),M(this,"shouldSetTVF",(e,t)=>{if(!t||"wc_sessionRequest"!==e)return!1;const{request:i}=t;return Object.keys(I).includes(i.method)}),M(this,"getTVFParams",(e,t,i)=>{var s,r;try{const n=t.request.method,o=this.extractTxHashesFromResult(n,i);return R(k({correlationId:e,rpcMethods:[n],chainId:t.chainId},this.isValidContractData(t.request.params)&&{contractAddresses:[null==(r=null==(s=t.request.params)?void 0:s[0])?void 0:r.to]}),{txHashes:o})}catch(e){this.client.logger.warn("Error getting TVF params",e)}return{}}),M(this,"isValidContractData",e=>{var t;if(!e)return!1;try{const i=e?.data||(null==(t=e?.[0])?void 0:t.data);if(!i.startsWith("0x"))return!1;const s=i.slice(2);return!!/^[0-9a-fA-F]*$/.test(s)&&s.length%2==0}catch{}return!1}),M(this,"extractTxHashesFromResult",(e,t)=>{try{if("string"==typeof t)return[t];const i=t[I[e].key];if((0,a.OP1)(i))return"solana_signAllTransactions"===e?i.map(e=>(0,a.PAk)(e)):i;if("string"==typeof i)return[i]}catch(e){this.client.logger.warn("Error extracting tx hashes from result",e)}return[]})}async processPendingMessageEvents(){try{const e=this.client.session.keys,t=this.client.core.relayer.messages.getWithoutAck(e);for(const[e,i]of Object.entries(t))for(const t of i)try{await this.onProviderMessageEvent({topic:e,message:t,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${e}, message: ${t}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){const{message:e}=(0,a.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(s.Jf.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){const{topic:t,message:i,attestation:r,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(A)?this.client.auth.authKeys.get(A):{responseTopic:void 0,publicKey:void 0};try{const e=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:n===s.cV.link_mode?a.Pa8:a.EWt});(0,d.isJsonRpcRequest)(e)?(this.client.core.history.set(t,e),await this.onRelayEventRequest({topic:t,payload:e,attestation:r,transportType:n,encryptedId:(0,a.ALl)(i)})):(0,d.isJsonRpcResponse)(e)?(await this.client.core.history.resolve(e),await this.onRelayEventResponse({topic:t,payload:e,transportType:n}),this.client.core.history.delete(t,e.id)):await this.onRelayEventUnknownPayload({topic:t,payload:e,transportType:n}),await this.client.core.relayer.messages.ack(t,i)}catch(e){this.client.logger.error(e)}}registerExpirerEvents(){this.client.core.expirer.on(s.wn.expired,async e=>{const{topic:t,id:i}=(0,a.c82)(e.target);return i&&this.client.pendingRequest.keys.includes(i)?await this.deletePendingSessionRequest(i,(0,a.GuA)("EXPIRED"),!0):i&&this.client.auth.requests.keys.includes(i)?await this.deletePendingAuthRequest(i,(0,a.GuA)("EXPIRED"),!0):void(t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i})))})}registerPairingEvents(){this.client.core.pairing.events.on(s.zN.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(s.zN.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!(0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=(0,a.GuA)("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!(0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=(0,a.GuA)("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else{if(!this.client.core.pairing.pairings.keys.includes(e)){if((0,a.Qhg)(e,!1)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}{const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if(!(0,a.Alu)(e)){const{message:t}=(0,a.GuA)("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=(0,a.GuA)("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if((0,a._dF)(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=(0,a.GuA)("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}}class D extends s.il{constructor(e,t){super(e,t,"proposal",u),this.core=e,this.logger=t}}class j extends s.il{constructor(e,t){super(e,t,"session",u),this.core=e,this.logger=t}}class L extends s.il{constructor(e,t){super(e,t,"request",u,e=>e.id),this.core=e,this.logger=t}}class q extends s.il{constructor(e,t){super(e,t,"authKeys",_,()=>A),this.core=e,this.logger=t}}class $ extends s.il{constructor(e,t){super(e,t,"pairingTopics",_),this.core=e,this.logger=t}}class B extends s.il{constructor(e,t){super(e,t,"requests",_,e=>e.id),this.core=e,this.logger=t}}var z=Object.defineProperty,H=(e,t,i)=>((e,t,i)=>t in e?z(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class W{constructor(e,t){this.core=e,this.logger=t,H(this,"authKeys"),H(this,"pairingTopics"),H(this,"requests"),this.authKeys=new q(this.core,this.logger),this.pairingTopics=new $(this.core,this.logger),this.requests=new B(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var V=Object.defineProperty,F=(e,t,i)=>((e,t,i)=>t in e?V(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class K extends n.S9{constructor(e){super(e),F(this,"protocol","wc"),F(this,"version",2),F(this,"name",p),F(this,"metadata"),F(this,"core"),F(this,"logger"),F(this,"events",new c.EventEmitter),F(this,"engine"),F(this,"session"),F(this,"proposal"),F(this,"pendingRequest"),F(this,"auth"),F(this,"signConfig"),F(this,"on",(e,t)=>this.events.on(e,t)),F(this,"once",(e,t)=>this.events.once(e,t)),F(this,"off",(e,t)=>this.events.off(e,t)),F(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),F(this,"removeAllListeners",e=>this.events.removeAllListeners(e)),F(this,"connect",async e=>{try{return await this.engine.connect(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"pair",async e=>{try{return await this.engine.pair(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"approve",async e=>{try{return await this.engine.approve(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"reject",async e=>{try{return await this.engine.reject(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"update",async e=>{try{return await this.engine.update(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"extend",async e=>{try{return await this.engine.extend(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"request",async e=>{try{return await this.engine.request(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"respond",async e=>{try{return await this.engine.respond(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"ping",async e=>{try{return await this.engine.ping(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"emit",async e=>{try{return await this.engine.emit(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"disconnect",async e=>{try{return await this.engine.disconnect(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"find",e=>{try{return this.engine.find(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(e){throw this.logger.error(e.message),e}}),F(this,"authenticate",async(e,t)=>{try{return await this.engine.authenticate(e,t)}catch(e){throw this.logger.error(e.message),e}}),F(this,"formatAuthMessage",e=>{try{return this.engine.formatAuthMessage(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"approveSessionAuthenticate",async e=>{try{return await this.engine.approveSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),F(this,"rejectSessionAuthenticate",async e=>{try{return await this.engine.rejectSessionAuthenticate(e)}catch(e){throw this.logger.error(e.message),e}}),this.name=e?.name||p,this.metadata=e?.metadata||(0,a.lFF)(),this.signConfig=e?.signConfig;const t=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,r.h6)((0,r.iP)({level:e?.logger||"error"}));this.core=e?.core||new s.iJ(e),this.logger=(0,r.U5)(t,this.name),this.session=new j(this.core,this.logger),this.proposal=new D(this.core,this.logger),this.pendingRequest=new L(this.core,this.logger),this.engine=new U(this),this.auth=new W(this.core,this.logger)}static async init(e){const t=new K(e);return await t.initialize(),t}get context(){return(0,r.oI)(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},(0,o.toMiliseconds)(o.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}},38132:(e,t,i)=>{i.d(t,{r:()=>r});var s=i(70255);const r={createLogger(e,t="error"){const i=(0,s.iP)({level:t}),{logger:r}=(0,s.D5)({opts:i});return r.error=(...t)=>{for(const i of t)if(i instanceof Error)return void e(i,...t);e(void 0,...t)},r}}},38753:(e,t,i)=>{i.d(t,{A:()=>d});var s=i(50731),r=i(40868),n=i(16158),o=i(5813),a=i(11553),c=i(24313),h=i(74091);const d={filterOutDuplicatesByRDNS(e){const t=n.H.state.enableEIP6963?s.a.state.connectors:[],i=a.i.getRecentWallets(),r=t.map(e=>e.info?.rdns).filter(Boolean),c=i.map(e=>e.rdns).filter(Boolean),h=r.concat(c);if(h.includes("io.metamask.mobile")&&o.w.isMobile()){const e=h.indexOf("io.metamask.mobile");h[e]="io.metamask"}return e.filter(e=>!h.includes(String(e?.rdns)))},filterOutDuplicatesByIds(e){const t=s.a.state.connectors.filter(e=>"ANNOUNCED"===e.type||"INJECTED"===e.type),i=a.i.getRecentWallets(),r=t.map(e=>e.explorerId),n=i.map(e=>e.id),o=r.concat(n);return e.filter(e=>!o.includes(e?.id))},filterOutDuplicateWallets(e){const t=this.filterOutDuplicatesByRDNS(e);return this.filterOutDuplicatesByIds(t)},markWalletsAsInstalled(e){const{connectors:t}=s.a.state,i=t.filter(e=>"ANNOUNCED"===e.type).reduce((e,t)=>t.info?.rdns?(e[t.info.rdns]=!0,e):e,{});return e.map(e=>({...e,installed:Boolean(e.rdns)&&Boolean(i[e.rdns??""])})).sort((e,t)=>Number(t.installed)-Number(e.installed))},getConnectOrderMethod(e,t){const i=e?.connectMethodsOrder||n.H.state.features?.connectMethodsOrder,o=t||s.a.state.connectors;if(i)return i;const{injected:a,announced:d}=c.g.getConnectorsByType(o,r.N.state.recommended,r.N.state.featured),l=a.filter(c.g.showConnector),u=d.filter(c.g.showConnector);return l.length||u.length?["wallet","email","social"]:h.o.DEFAULT_CONNECT_METHOD_ORDER}}},40149:(e,t,i)=>{function s(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}i.d(t,{x:()=>s})},40446:(e,t,i)=>{i.d(t,{l:()=>Lr});var s=i(31575),r=i(76754),n=i(70255),o=i(64264),a=i(93786),c=i(14350),h=i(50046),d=i.n(h);const l="error",u="wc@2:universal_provider:",p="https://rpc.walletconnect.org/v1/",f="generic",g=`${p}bundler`,m="default_chain_changed";var b=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof i.g<"u"?i.g:typeof self<"u"?self:{},y=function(e,t){return e===t||e!=e&&t!=t},w=y,v=function(e,t){for(var i=e.length;i--;)if(w(e[i][0],t))return i;return-1},I=v,E=Array.prototype.splice,_=v,A=v,N=v,C=function(){this.__data__=[],this.size=0},S=function(e){var t=this.__data__,i=I(t,e);return!(i<0||(i==t.length-1?t.pop():E.call(t,i,1),--this.size,0))},P=function(e){var t=this.__data__,i=_(t,e);return i<0?void 0:t[i][1]},O=function(e){return A(this.__data__,e)>-1},T=function(e,t){var i=this.__data__,s=N(i,e);return s<0?(++this.size,i.push([e,t])):i[s][1]=t,this};function x(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var s=e[t];this.set(s[0],s[1])}}x.prototype.clear=C,x.prototype.delete=S,x.prototype.get=P,x.prototype.has=O,x.prototype.set=T;var k,R=x,M=R,U="object"==typeof b&&b&&b.Object===Object&&b,D=U,j="object"==typeof self&&self&&self.Object===Object&&self,L=D||j||Function("return this")(),q=L.Symbol,$=q,B=Object.prototype,z=B.hasOwnProperty,H=B.toString,W=$?$.toStringTag:void 0,V=Object.prototype.toString,F=function(e){var t=z.call(e,W),i=e[W];try{e[W]=void 0;var s=!0}catch{}var r=H.call(e);return s&&(t?e[W]=i:delete e[W]),r},K=function(e){return V.call(e)},G=q?q.toStringTag:void 0,J=function(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":G&&G in Object(e)?F(e):K(e)},Y=function(e){var t=typeof e;return null!=e&&("object"==t||"function"==t)},X=J,Q=Y,Z=function(e){if(!Q(e))return!1;var t=X(e);return"[object Function]"==t||"[object GeneratorFunction]"==t||"[object AsyncFunction]"==t||"[object Proxy]"==t},ee=L["__core-js_shared__"],te=(k=/[^.]+$/.exec(ee&&ee.keys&&ee.keys.IE_PROTO||""))?"Symbol(src)_1."+k:"",ie=Function.prototype.toString,se=Z,re=function(e){return!!te&&te in e},ne=Y,oe=function(e){if(null!=e){try{return ie.call(e)}catch{}try{return e+""}catch{}}return""},ae=/^\[object .+?Constructor\]$/,ce=Function.prototype,he=Object.prototype,de=ce.toString,le=he.hasOwnProperty,ue=RegExp("^"+de.call(le).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),pe=function(e){return!(!ne(e)||re(e))&&(se(e)?ue:ae).test(oe(e))},fe=function(e,t){return e?.[t]},ge=function(e,t){var i=fe(e,t);return pe(i)?i:void 0},me=ge(L,"Map"),be=ge(Object,"create"),ye=be,we=be,ve=Object.prototype.hasOwnProperty,Ie=be,Ee=Object.prototype.hasOwnProperty,_e=be,Ae=function(){this.__data__=ye?ye(null):{},this.size=0},Ne=function(e){var t=this.has(e)&&delete this.__data__[e];return this.size-=t?1:0,t},Ce=function(e){var t=this.__data__;if(we){var i=t[e];return"__lodash_hash_undefined__"===i?void 0:i}return ve.call(t,e)?t[e]:void 0},Se=function(e){var t=this.__data__;return Ie?void 0!==t[e]:Ee.call(t,e)},Pe=function(e,t){var i=this.__data__;return this.size+=this.has(e)?0:1,i[e]=_e&&void 0===t?"__lodash_hash_undefined__":t,this};function Oe(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var s=e[t];this.set(s[0],s[1])}}Oe.prototype.clear=Ae,Oe.prototype.delete=Ne,Oe.prototype.get=Ce,Oe.prototype.has=Se,Oe.prototype.set=Pe;var Te=Oe,xe=R,ke=me,Re=function(e){var t=typeof e;return"string"==t||"number"==t||"symbol"==t||"boolean"==t?"__proto__"!==e:null===e},Me=function(e,t){var i=e.__data__;return Re(t)?i["string"==typeof t?"string":"hash"]:i.map},Ue=Me,De=Me,je=Me,Le=Me,qe=function(e){var t=Ue(this,e).delete(e);return this.size-=t?1:0,t},$e=function(e){return De(this,e).get(e)},Be=function(e){return je(this,e).has(e)},ze=function(e,t){var i=Le(this,e),s=i.size;return i.set(e,t),this.size+=i.size==s?0:1,this};function He(e){var t=-1,i=null==e?0:e.length;for(this.clear();++t<i;){var s=e[t];this.set(s[0],s[1])}}He.prototype.clear=function(){this.size=0,this.__data__={hash:new Te,map:new(ke||xe),string:new Te}},He.prototype.delete=qe,He.prototype.get=$e,He.prototype.has=Be,He.prototype.set=ze;var We=R,Ve=me,Fe=He,Ke=R,Ge=function(){this.__data__=new M,this.size=0},Je=function(e){var t=this.__data__,i=t.delete(e);return this.size=t.size,i},Ye=function(e){return this.__data__.get(e)},Xe=function(e){return this.__data__.has(e)},Qe=function(e,t){var i=this.__data__;if(i instanceof We){var s=i.__data__;if(!Ve||s.length<199)return s.push([e,t]),this.size=++i.size,this;i=this.__data__=new Fe(s)}return i.set(e,t),this.size=i.size,this};function Ze(e){var t=this.__data__=new Ke(e);this.size=t.size}Ze.prototype.clear=Ge,Ze.prototype.delete=Je,Ze.prototype.get=Ye,Ze.prototype.has=Xe,Ze.prototype.set=Qe;var et=Ze,tt=ge,it=function(){try{var e=tt(Object,"defineProperty");return e({},"",{}),e}catch{}}(),st=it,rt=st,nt=function(e,t,i){"__proto__"==t&&rt?rt(e,t,{configurable:!0,enumerable:!0,value:i,writable:!0}):e[t]=i},ot=nt,at=y,ct=function(e,t,i){(void 0!==i&&!at(e[t],i)||void 0===i&&!(t in e))&&ot(e,t,i)},ht=function(e){return function(t,i,s){for(var r=-1,n=Object(t),o=s(t),a=o.length;a--;){var c=o[e?a:++r];if(!1===i(n[c],c,n))break}return t}}(),dt={exports:{}};!function(e,t){var i=L,s=t&&!t.nodeType&&t,r=s&&e&&!e.nodeType&&e,n=r&&r.exports===s?i.Buffer:void 0,o=n?n.allocUnsafe:void 0;e.exports=function(e,t){if(t)return e.slice();var i=e.length,s=o?o(i):new e.constructor(i);return e.copy(s),s}}(dt,dt.exports);var lt=L.Uint8Array,ut=function(e){var t=new e.constructor(e.byteLength);return new lt(t).set(new lt(e)),t},pt=Y,ft=Object.create,gt=function(){function e(){}return function(t){if(!pt(t))return{};if(ft)return ft(t);e.prototype=t;var i=new e;return e.prototype=void 0,i}}(),mt=gt,bt=function(e,t){return function(i){return e(t(i))}}(Object.getPrototypeOf,Object),yt=Object.prototype,wt=function(e){var t=e&&e.constructor;return e===("function"==typeof t&&t.prototype||yt)},vt=mt,It=bt,Et=wt,_t=function(e){return null!=e&&"object"==typeof e},At=J,Nt=_t,Ct=function(e){return Nt(e)&&"[object Arguments]"==At(e)},St=_t,Pt=Object.prototype,Ot=Pt.hasOwnProperty,Tt=Pt.propertyIsEnumerable,xt=Ct(function(){return arguments}())?Ct:function(e){return St(e)&&Ot.call(e,"callee")&&!Tt.call(e,"callee")},kt=xt,Rt=Array.isArray,Mt=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991},Ut=Z,Dt=Mt,jt=function(e){return null!=e&&Dt(e.length)&&!Ut(e)},Lt=jt,qt=_t,$t={exports:{}},Bt=function(){return!1};!function(e,t){var i=L,s=Bt,r=t&&!t.nodeType&&t,n=r&&e&&!e.nodeType&&e,o=n&&n.exports===r?i.Buffer:void 0,a=(o?o.isBuffer:void 0)||s;e.exports=a}($t,$t.exports);var zt=J,Ht=bt,Wt=_t,Vt=Function.prototype,Ft=Object.prototype,Kt=Vt.toString,Gt=Ft.hasOwnProperty,Jt=Kt.call(Object),Yt=J,Xt=Mt,Qt=_t,Zt={};Zt["[object Float32Array]"]=Zt["[object Float64Array]"]=Zt["[object Int8Array]"]=Zt["[object Int16Array]"]=Zt["[object Int32Array]"]=Zt["[object Uint8Array]"]=Zt["[object Uint8ClampedArray]"]=Zt["[object Uint16Array]"]=Zt["[object Uint32Array]"]=!0,Zt["[object Arguments]"]=Zt["[object Array]"]=Zt["[object ArrayBuffer]"]=Zt["[object Boolean]"]=Zt["[object DataView]"]=Zt["[object Date]"]=Zt["[object Error]"]=Zt["[object Function]"]=Zt["[object Map]"]=Zt["[object Number]"]=Zt["[object Object]"]=Zt["[object RegExp]"]=Zt["[object Set]"]=Zt["[object String]"]=Zt["[object WeakMap]"]=!1;var ei={exports:{}};!function(e,t){var i=U,s=t&&!t.nodeType&&t,r=s&&e&&!e.nodeType&&e,n=r&&r.exports===s&&i.process,o=function(){try{return r&&r.require&&r.require("util").types||n&&n.binding&&n.binding("util")}catch{}}();e.exports=o}(ei,ei.exports);var ti=function(e){return Qt(e)&&Xt(e.length)&&!!Zt[Yt(e)]},ii=function(e){return function(t){return e(t)}},si=ei.exports,ri=si&&si.isTypedArray,ni=ri?ii(ri):ti,oi=function(e,t){if(("constructor"!==t||"function"!=typeof e[t])&&"__proto__"!=t)return e[t]},ai=nt,ci=y,hi=Object.prototype.hasOwnProperty,di=function(e,t,i){var s=e[t];(!hi.call(e,t)||!ci(s,i)||void 0===i&&!(t in e))&&ai(e,t,i)},li=nt,ui=/^(?:0|[1-9]\d*)$/,pi=function(e,t){var i=typeof e;return!!(t=t??9007199254740991)&&("number"==i||"symbol"!=i&&ui.test(e))&&e>-1&&e%1==0&&e<t},fi=function(e,t){for(var i=-1,s=Array(e);++i<e;)s[i]=t(i);return s},gi=kt,mi=Rt,bi=$t.exports,yi=pi,wi=ni,vi=Object.prototype.hasOwnProperty,Ii=Y,Ei=wt,_i=function(e){var t=[];if(null!=e)for(var i in Object(e))t.push(i);return t},Ai=Object.prototype.hasOwnProperty,Ni=function(e,t){var i=mi(e),s=!i&&gi(e),r=!i&&!s&&bi(e),n=!i&&!s&&!r&&wi(e),o=i||s||r||n,a=o?fi(e.length,String):[],c=a.length;for(var h in e)(t||vi.call(e,h))&&(!o||!("length"==h||r&&("offset"==h||"parent"==h)||n&&("buffer"==h||"byteLength"==h||"byteOffset"==h)||yi(h,c)))&&a.push(h);return a},Ci=function(e){if(!Ii(e))return _i(e);var t=Ei(e),i=[];for(var s in e)"constructor"==s&&(t||!Ai.call(e,s))||i.push(s);return i},Si=jt,Pi=function(e){return Si(e)?Ni(e,!0):Ci(e)},Oi=function(e,t,i,s){var r=!i;i||(i={});for(var n=-1,o=t.length;++n<o;){var a=t[n],c=s?s(i[a],e[a],a,i,e):void 0;void 0===c&&(c=e[a]),r?li(i,a,c):di(i,a,c)}return i},Ti=Pi,xi=ct,ki=dt.exports,Ri=function(e,t){var i=t?ut(e.buffer):e.buffer;return new e.constructor(i,e.byteOffset,e.length)},Mi=function(e,t){var i=-1,s=e.length;for(t||(t=Array(s));++i<s;)t[i]=e[i];return t},Ui=function(e){return"function"!=typeof e.constructor||Et(e)?{}:vt(It(e))},Di=kt,ji=Rt,Li=function(e){return qt(e)&&Lt(e)},qi=$t.exports,$i=Z,Bi=Y,zi=function(e){if(!Wt(e)||"[object Object]"!=zt(e))return!1;var t=Ht(e);if(null===t)return!0;var i=Gt.call(t,"constructor")&&t.constructor;return"function"==typeof i&&i instanceof i&&Kt.call(i)==Jt},Hi=ni,Wi=oi,Vi=function(e){return Oi(e,Ti(e))},Fi=et,Ki=ct,Gi=ht,Ji=function(e,t,i,s,r,n,o){var a=Wi(e,i),c=Wi(t,i),h=o.get(c);if(h)xi(e,i,h);else{var d=n?n(a,c,i+"",e,t,o):void 0,l=void 0===d;if(l){var u=ji(c),p=!u&&qi(c),f=!u&&!p&&Hi(c);d=c,u||p||f?ji(a)?d=a:Li(a)?d=Mi(a):p?(l=!1,d=ki(c,!0)):f?(l=!1,d=Ri(c,!0)):d=[]:zi(c)||Di(c)?(d=a,Di(a)?d=Vi(a):(!Bi(a)||$i(a))&&(d=Ui(c))):l=!1}l&&(o.set(c,d),r(d,c,s,n,o),o.delete(c)),xi(e,i,d)}},Yi=Y,Xi=Pi,Qi=oi,Zi=function(e){return e},es=function(e,t,i){switch(i.length){case 0:return e.call(t);case 1:return e.call(t,i[0]);case 2:return e.call(t,i[0],i[1]);case 3:return e.call(t,i[0],i[1],i[2])}return e.apply(t,i)},ts=Math.max,is=function(e){return function(){return e}},ss=st,rs=ss?function(e,t){return ss(e,"toString",{configurable:!0,enumerable:!1,value:is(t),writable:!0})}:Zi,ns=rs,os=Date.now,as=function(e){var t=0,i=0;return function(){var s=os(),r=16-(s-i);if(i=s,r>0){if(++t>=800)return arguments[0]}else t=0;return e.apply(void 0,arguments)}}(ns),cs=Zi,hs=function(e,t,i){return t=ts(void 0===t?e.length-1:t,0),function(){for(var s=arguments,r=-1,n=ts(s.length-t,0),o=Array(n);++r<n;)o[r]=s[t+r];r=-1;for(var a=Array(t+1);++r<t;)a[r]=s[r];return a[t]=i(o),es(e,this,a)}},ds=as,ls=y,us=jt,ps=pi,fs=Y,gs=function(e,t){return ds(hs(e,t,cs),e+"")},ms=function(e,t,i){if(!fs(i))return!1;var s=typeof t;return!!("number"==s?us(i)&&ps(t,i.length):"string"==s&&t in i)&&ls(i[t],e)},bs=function e(t,i,s,r,n){t!==i&&Gi(i,function(o,a){if(n||(n=new Fi),Yi(o))Ji(t,i,a,s,e,r,n);else{var c=r?r(Qi(t,a),o,a+"",t,i,n):void 0;void 0===c&&(c=o),Ki(t,a,c)}},Xi)},ys=function(e){return gs(function(t,i){var s=-1,r=i.length,n=r>1?i[r-1]:void 0,o=r>2?i[2]:void 0;for(n=e.length>3&&"function"==typeof n?(r--,n):void 0,o&&ms(i[0],i[1],o)&&(n=r<3?void 0:n,r=1),t=Object(t);++s<r;){var a=i[s];a&&e(t,a,s,n)}return t})}(function(e,t,i){bs(e,t,i)}),ws=ys,vs=Object.defineProperty,Is=Object.defineProperties,Es=Object.getOwnPropertyDescriptors,_s=Object.getOwnPropertySymbols,As=Object.prototype.hasOwnProperty,Ns=Object.prototype.propertyIsEnumerable,Cs=(e,t,i)=>t in e?vs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Ss=(e,t)=>{for(var i in t||(t={}))As.call(t,i)&&Cs(e,i,t[i]);if(_s)for(var i of _s(t))Ns.call(t,i)&&Cs(e,i,t[i]);return e},Ps=(e,t)=>Is(e,Es(t));function Os(e,t,i){var s;const n=(0,r._Yb)(e);return(null==(s=t.rpcMap)?void 0:s[n.reference])||`${p}?chainId=${n.namespace}:${n.reference}&projectId=${i}`}function Ts(e){return e.includes(":")?e.split(":")[1]:e}function xs(e){return e.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function ks(e={},t={}){const i=Rs(e),s=Rs(t);return ws(i,s)}function Rs(e){var t,i,s,n;const o={};if(!(0,r.aF0)(e))return o;for(const[a,c]of Object.entries(e)){const e=(0,r.nWe)(a)?[a]:c.chains,h=c.methods||[],d=c.events||[],l=c.rpcMap||{},u=(0,r.kob)(a);o[u]=Ps(Ss(Ss({},o[u]),c),{chains:(0,r.TRk)(e,null==(t=o[u])?void 0:t.chains),methods:(0,r.TRk)(h,null==(i=o[u])?void 0:i.methods),events:(0,r.TRk)(d,null==(s=o[u])?void 0:s.events),rpcMap:Ss(Ss({},l),null==(n=o[u])?void 0:n.rpcMap)})}return o}function Ms(e){return e.includes(":")?e.split(":")[2]:e}function Us(e){const t={};for(const[i,s]of Object.entries(e)){const e=s.methods||[],n=s.events||[],o=s.accounts||[],a=(0,r.nWe)(i)?[i]:s.chains?s.chains:xs(s.accounts);t[i]={chains:a,methods:e,events:n,accounts:o}}return t}function Ds(e){return"number"==typeof e?e:e.includes("0x")?parseInt(e,16):(e=e.includes(":")?e.split(":")[1]:e,isNaN(Number(e))?e:Number(e))}const js={},Ls=e=>js[e],qs=(e,t)=>{js[e]=t};var $s=Object.defineProperty,Bs=(e,t,i)=>((e,t,i)=>t in e?$s(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class zs{constructor(e){Bs(this,"name","polkadot"),Bs(this,"client"),Bs(this,"httpProviders"),Bs(this,"events"),Bs(this,"namespace"),Bs(this,"chainId"),this.namespace=e.namespace,this.events=Ls("events"),this.client=Ls("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=Ts(t);e[s]=this.createHttpProvider(s,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||Os(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(i,Ls("disableProviderPing")))}}var Hs=Object.defineProperty,Ws=Object.defineProperties,Vs=Object.getOwnPropertyDescriptors,Fs=Object.getOwnPropertySymbols,Ks=Object.prototype.hasOwnProperty,Gs=Object.prototype.propertyIsEnumerable,Js=(e,t,i)=>t in e?Hs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Ys=(e,t)=>{for(var i in t||(t={}))Ks.call(t,i)&&Js(e,i,t[i]);if(Fs)for(var i of Fs(t))Gs.call(t,i)&&Js(e,i,t[i]);return e},Xs=(e,t)=>Ws(e,Vs(t)),Qs=(e,t,i)=>Js(e,"symbol"!=typeof t?t+"":t,i);class Zs{constructor(e){Qs(this,"name","eip155"),Qs(this,"client"),Qs(this,"chainId"),Qs(this,"namespace"),Qs(this,"httpProviders"),Qs(this,"events"),this.namespace=e.namespace,this.events=Ls("events"),this.client=Ls("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(m,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const i=t||Os(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.V(i,Ls("disableProviderPing")))}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=parseInt(Ts(t));e[s]=this.createHttpProvider(s,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,i;let s=e.request.params?null==(t=e.request.params[0])?void 0:t.chainId:"0x0";s=s.startsWith("0x")?s:`0x${s}`;const r=parseInt(s,16);if(this.isChainApproved(r))this.setDefaultChain(`${r}`);else{if(!this.namespace.methods.includes("wallet_switchEthereumChain"))throw new Error(`Failed to switch to chain 'eip155:${r}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:s}]},chainId:null==(i=this.namespace.chains)?void 0:i[0]}),this.setDefaultChain(`${r}`)}return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,i,s;const r=null==(i=null==(t=e.request)?void 0:t.params)?void 0:i[0];if(!r)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const n=this.client.session.get(e.topic),o=(null==(s=n?.sessionProperties)?void 0:s.capabilities)||{};if(null!=o&&o[r])return o?.[r];const a=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Xs(Ys({},n.sessionProperties||{}),{capabilities:Xs(Ys({},o||{}),{[r]:a})})})}catch(e){console.warn("Failed to update session with capabilities",e)}return a}async getCallStatus(e){var t,i;const s=this.client.session.get(e.topic),r=null==(t=s.sessionProperties)?void 0:t.bundler_name;if(r){const t=this.getBundlerUrl(e.chainId,r);try{return await this.getUserOperationReceipt(t,e)}catch(e){console.warn("Failed to fetch call status from bundler",e,t)}}const n=null==(i=s.sessionProperties)?void 0:i.bundler_url;if(n)try{return await this.getUserOperationReceipt(n,e)}catch(e){console.warn("Failed to fetch call status from custom bundler",e,n)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var i;const s=new URL(e),r=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,c.formatJsonRpcRequest)("eth_getUserOperationReceipt",[null==(i=t.request.params)?void 0:i[0]]))});if(!r.ok)throw new Error(`Failed to fetch user operation receipt - ${r.status}`);return await r.json()}getBundlerUrl(e,t){return`${g}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}var er=Object.defineProperty,tr=(e,t,i)=>((e,t,i)=>t in e?er(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class ir{constructor(e){tr(this,"name","solana"),tr(this,"client"),tr(this,"httpProviders"),tr(this,"events"),tr(this,"namespace"),tr(this,"chainId"),this.namespace=e.namespace,this.events=Ls("events"),this.client=Ls("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=Ts(t);e[s]=this.createHttpProvider(s,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||Os(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(i,Ls("disableProviderPing")))}}var sr=Object.defineProperty,rr=(e,t,i)=>((e,t,i)=>t in e?sr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class nr{constructor(e){rr(this,"name","cosmos"),rr(this,"client"),rr(this,"httpProviders"),rr(this,"events"),rr(this,"namespace"),rr(this,"chainId"),this.namespace=e.namespace,this.events=Ls("events"),this.client=Ls("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=Ts(t);e[s]=this.createHttpProvider(s,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||Os(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(i,Ls("disableProviderPing")))}}var or=Object.defineProperty,ar=(e,t,i)=>((e,t,i)=>t in e?or(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class cr{constructor(e){ar(this,"name","algorand"),ar(this,"client"),ar(this,"httpProviders"),ar(this,"events"),ar(this,"namespace"),ar(this,"chainId"),this.namespace=e.namespace,this.events=Ls("events"),this.client=Ls("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const i=t||Os(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(m,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||Os(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new a.F(new o.A(i,Ls("disableProviderPing")))}}var hr=Object.defineProperty,dr=(e,t,i)=>((e,t,i)=>t in e?hr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class lr{constructor(e){dr(this,"name","cip34"),dr(this,"client"),dr(this,"httpProviders"),dr(this,"events"),dr(this,"namespace"),dr(this,"chainId"),this.namespace=e.namespace,this.events=Ls("events"),this.client=Ls("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const i=this.getCardanoRPCUrl(t),s=Ts(t);e[s]=this.createHttpProvider(s,i)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||this.getCardanoRPCUrl(e);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(i,Ls("disableProviderPing")))}}var ur=Object.defineProperty,pr=(e,t,i)=>((e,t,i)=>t in e?ur(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class fr{constructor(e){pr(this,"name","elrond"),pr(this,"client"),pr(this,"httpProviders"),pr(this,"events"),pr(this,"namespace"),pr(this,"chainId"),this.namespace=e.namespace,this.events=Ls("events"),this.client=Ls("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=Ts(t);e[s]=this.createHttpProvider(s,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||Os(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(i,Ls("disableProviderPing")))}}var gr=Object.defineProperty,mr=(e,t,i)=>((e,t,i)=>t in e?gr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class br{constructor(e){mr(this,"name","multiversx"),mr(this,"client"),mr(this,"httpProviders"),mr(this,"events"),mr(this,"namespace"),mr(this,"chainId"),this.namespace=e.namespace,this.events=Ls("events"),this.client=Ls("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const s=Ts(t);e[s]=this.createHttpProvider(s,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||Os(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(i,Ls("disableProviderPing")))}}var yr=Object.defineProperty,wr=(e,t,i)=>((e,t,i)=>t in e?yr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class vr{constructor(e){wr(this,"name","near"),wr(this,"client"),wr(this,"httpProviders"),wr(this,"events"),wr(this,"namespace"),wr(this,"chainId"),this.namespace=e.namespace,this.events=Ls("events"),this.client=Ls("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||Os(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(m,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,null==(i=this.namespace.rpcMap)?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||Os(e,this.namespace);return typeof i>"u"?void 0:new a.F(new o.A(i,Ls("disableProviderPing")))}}var Ir=Object.defineProperty,Er=(e,t,i)=>((e,t,i)=>t in e?Ir(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class _r{constructor(e){Er(this,"name","tezos"),Er(this,"client"),Er(this,"httpProviders"),Er(this,"events"),Er(this,"namespace"),Er(this,"chainId"),this.namespace=e.namespace,this.events=Ls("events"),this.client=Ls("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||Os(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(m,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e&&e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2])||[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{e[t]=this.createHttpProvider(t)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||Os(e,this.namespace);return typeof i>"u"?void 0:new a.F(new o.A(i))}}var Ar=Object.defineProperty,Nr=(e,t,i)=>((e,t,i)=>t in e?Ar(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Cr{constructor(e){Nr(this,"name",f),Nr(this,"client"),Nr(this,"httpProviders"),Nr(this,"events"),Nr(this,"namespace"),Nr(this,"chainId"),this.namespace=e.namespace,this.events=Ls("events"),this.client=Ls("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(m,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(e=>e.split(":")[1]===this.chainId.toString()).map(e=>e.split(":")[2]))]:[]}createHttpProviders(){var e,t;const i={};return null==(t=null==(e=this.namespace)?void 0:e.accounts)||t.forEach(e=>{const t=(0,r._Yb)(e);i[`${t.namespace}:${t.reference}`]=this.createHttpProvider(e)}),i}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||Os(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new a.F(new o.A(i,Ls("disableProviderPing")))}}var Sr=Object.defineProperty,Pr=Object.defineProperties,Or=Object.getOwnPropertyDescriptors,Tr=Object.getOwnPropertySymbols,xr=Object.prototype.hasOwnProperty,kr=Object.prototype.propertyIsEnumerable,Rr=(e,t,i)=>t in e?Sr(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Mr=(e,t)=>{for(var i in t||(t={}))xr.call(t,i)&&Rr(e,i,t[i]);if(Tr)for(var i of Tr(t))kr.call(t,i)&&Rr(e,i,t[i]);return e},Ur=(e,t)=>Pr(e,Or(t)),Dr=(e,t,i)=>Rr(e,"symbol"!=typeof t?t+"":t,i);class jr{constructor(e){Dr(this,"client"),Dr(this,"namespaces"),Dr(this,"optionalNamespaces"),Dr(this,"sessionProperties"),Dr(this,"events",new(d())),Dr(this,"rpcProviders",{}),Dr(this,"session"),Dr(this,"providerOpts"),Dr(this,"logger"),Dr(this,"uri"),Dr(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof e?.logger<"u"&&"string"!=typeof e?.logger?e.logger:(0,n.h6)((0,n.iP)({level:e?.logger||l})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const t=new jr(e);return await t.initialize(),t}async request(e,t,i){const[s,r]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(s).request({request:Mr({},e),chainId:`${s}:${r}`,topic:this.session.topic,expiry:i})}sendAsync(e,t,i,s){const r=(new Date).getTime();this.request(e,i,s).then(e=>t(null,(0,c.formatJsonRpcResult)(r,e))).catch(e=>t(e,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:null==(e=this.session)?void 0:e.topic,reason:(0,r.Hjj)("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:i,response:s}=await this.client.authenticate(e,t);i&&(this.uri=i,this.events.emit("display_uri",i));const r=await s();if(this.session=r.session,this.session){const e=Us(this.session.namespaces);this.namespaces=ks(this.namespaces,e),this.persist("namespaces",this.namespaces),this.onConnect()}return r}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){const{uri:t,approval:i}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});t&&(this.uri=t,this.events.emit("display_uri",t));const s=await i();this.session=s;const r=Us(s.namespaces);return this.namespaces=ks(this.namespaces,r),this.persist("namespaces",this.namespaces),this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[i,s]=this.validateChain(e),r=this.getProvider(i);r.name===f?r.setDefaultChain(`${i}:${s}`,t):r.setDefaultChain(s,t)}catch(e){if(!/Please call connect/.test(e.message))throw e}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if((0,r.OP1)(t)){for(const i of t)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await s.Ay.init({core:this.providerOpts.core,logger:this.providerOpts.logger||l,relayUrl:this.providerOpts.relayUrl||"wss://relay.walletconnect.org",projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(e=>(0,r.kob)(e)))];qs("client",this.client),qs("events",this.events),qs("disableProviderPing",this.disableProviderPing),e.forEach(e=>{if(!this.session)return;const t=function(e,t){const i=Object.keys(t.namespaces).filter(t=>t.includes(e));if(!i.length)return[];const s=[];return i.forEach(e=>{const i=t.namespaces[e].accounts;s.push(...i)}),s}(e,this.session),i=xs(t),s=ks(this.namespaces,this.optionalNamespaces),r=Ur(Mr({},s[e]),{accounts:t,chains:i});switch(e){case"eip155":this.rpcProviders[e]=new Zs({namespace:r});break;case"algorand":this.rpcProviders[e]=new cr({namespace:r});break;case"solana":this.rpcProviders[e]=new ir({namespace:r});break;case"cosmos":this.rpcProviders[e]=new nr({namespace:r});break;case"polkadot":this.rpcProviders[e]=new zs({namespace:r});break;case"cip34":this.rpcProviders[e]=new lr({namespace:r});break;case"elrond":this.rpcProviders[e]=new fr({namespace:r});break;case"multiversx":this.rpcProviders[e]=new br({namespace:r});break;case"near":this.rpcProviders[e]=new vr({namespace:r});break;case"tezos":this.rpcProviders[e]=new _r({namespace:r});break;default:this.rpcProviders[f]?this.rpcProviders[f].updateNamespace(r):this.rpcProviders[f]=new Cr({namespace:r})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:t}=e,{event:i}=t;if("accountsChanged"===i.name){const e=i.data;e&&(0,r.OP1)(e)&&this.events.emit("accountsChanged",e.map(Ms))}else if("chainChanged"===i.name){const e=t.chainId,i=t.event.data,s=(0,r.kob)(e),n=Ds(e)!==Ds(i)?`${s}:${Ds(i)}`:e;this.onChainChanged(n)}else this.events.emit(i.name,i.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var i;const{namespaces:s}=t,r=null==(i=this.client)?void 0:i.session.get(e);this.session=Ur(Mr({},r),{namespaces:s}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",Ur(Mr({},(0,r.Hjj)("USER_DISCONNECTED")),{data:e.topic}))}),this.on(m,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[f]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace(null==(t=this.session)?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:i,sessionProperties:s}=e;t&&Object.keys(t).length&&(this.namespaces=t),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=s,this.persist("namespaces",t),this.persist("optionalNamespaces",i)}validateChain(e){const[t,i]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,i];if(t&&!Object.keys(this.namespaces||{}).map(e=>(0,r.kob)(e)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&i)return[t,i];const s=(0,r.kob)(Object.keys(this.namespaces)[0]);return[s,this.rpcProviders[s].getDefaultChain()]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){if(!this.namespaces)return;const[i,s]=this.validateChain(e);s&&(t||this.getProvider(i).setDefaultChain(s),this.namespaces[i]?this.namespaces[i].defaultChain=s:this.namespaces[`${i}:${s}`]?this.namespaces[`${i}:${s}`].defaultChain=s:this.namespaces[`${i}:${s}`]={defaultChain:s},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",s))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${u}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${u}/${e}`)}}const Lr=jr},40770:(e,t,i)=>{i.d(t,{L:()=>n});var s=i(95191),r=i(98207);const n={ConnectorExplorerIds:{[s.o.CONNECTOR_ID.COINBASE]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[s.o.CONNECTOR_ID.COINBASE_SDK]:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",[s.o.CONNECTOR_ID.SAFE]:"225affb176778569276e484e1b92637ad061b01e13a048b35a9d280c3b58970f",[s.o.CONNECTOR_ID.LEDGER]:"19177a98252e07ddfc9af2083ba8e07ef627cb6103467ffebb3f8f4205fd7927",[s.o.CONNECTOR_ID.OKX]:"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709",[r.o.METMASK_CONNECTOR_NAME]:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",[r.o.TRUST_CONNECTOR_NAME]:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",[r.o.SOLFLARE_CONNECTOR_NAME]:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",[r.o.PHANTOM_CONNECTOR_NAME]:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",[r.o.COIN98_CONNECTOR_NAME]:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",[r.o.MAGIC_EDEN_CONNECTOR_NAME]:"8b830a2b724a9c3fbab63af6f55ed29c9dfa8a55e732dc88c80a196a2ba136c6",[r.o.BACKPACK_CONNECTOR_NAME]:"2bd8c14e035c2d48f184aaa168559e86b0e3433228d3c4075900a221785019b0",[r.o.BITGET_CONNECTOR_NAME]:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",[r.o.FRONTIER_CONNECTOR_NAME]:"85db431492aa2e8672e93f4ea7acf10c88b97b867b0d373107af63dc4880f041",[r.o.XVERSE_CONNECTOR_NAME]:"2a87d74ae02e10bdd1f51f7ce6c4e1cc53cd5f2c0b6b5ad0d7b3007d2b13de7b",[r.o.LEATHER_CONNECTOR_NAME]:"483afe1df1df63daf313109971ff3ef8356ddf1cc4e45877d205eee0b7893a13"},NetworkImageIds:{1:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",42161:"3bff954d-5cb0-47a0-9a23-d20192e74600",43114:"30c46e53-e989-45fb-4549-be3bd4eb3b00",56:"93564157-2e8e-4ce7-81df-b264dbee9b00",250:"06b26297-fe0c-4733-5d6b-ffa5498aac00",10:"ab9c186a-c52f-464b-2906-ca59d760a400",137:"41d04d42-da3b-4453-8506-668cc0727900",5e3:"e86fae9b-b770-4eea-e520-150e12c81100",295:"6a97d510-cac8-4e58-c7ce-e8681b044c00",11155111:"e909ea0a-f92a-4512-c8fc-748044ea6800",84532:"a18a7ecd-e307-4360-4746-283182228e00",1301:"4eeea7ef-0014-4649-5d1d-07271a80f600",130:"2257980a-3463-48c6-cbac-a42d2a956e00",10143:"0a728e83-bacb-46db-7844-948f05434900",100:"02b53f6a-e3d4-479e-1cb4-21178987d100",9001:"f926ff41-260d-4028-635e-91913fc28e00",324:"b310f07f-4ef7-49f3-7073-2a0a39685800",314:"5a73b3dd-af74-424e-cae0-0de859ee9400",4689:"34e68754-e536-40da-c153-6ef2e7188a00",1088:"3897a66d-40b9-4833-162f-a2c90531c900",1284:"161038da-44ae-4ec7-1208-0ea569454b00",1285:"f1d73bb6-5450-4e18-38f7-fb6484264a00",7777777:"845c60df-d429-4991-e687-91ae45791600",42220:"ab781bbc-ccc6-418d-d32d-789b15da1f00",8453:"7289c336-3981-4081-c5f4-efc26ac64a00",1313161554:"3ff73439-a619-4894-9262-4470c773a100",2020:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",2021:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",80094:"e329c2c9-59b0-4a02-83e4-212ff3779900","5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp":"a1b58899-f671-4276-6a5e-56ca5bd59700","4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z":"a1b58899-f671-4276-6a5e-56ca5bd59700",EtWTRABZaYq6iMfeYKouRu166VU2xqa1:"a1b58899-f671-4276-6a5e-56ca5bd59700","000000000019d6689c085ae165831e93":"0b4838db-0161-4ffe-022d-532bf03dba00","000000000933ea01ad0ee984209779ba":"39354064-d79b-420b-065d-f980c4b78200"},ConnectorImageIds:{[s.o.CONNECTOR_ID.COINBASE]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[s.o.CONNECTOR_ID.COINBASE_SDK]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[s.o.CONNECTOR_ID.SAFE]:"461db637-8616-43ce-035a-d89b8a1d5800",[s.o.CONNECTOR_ID.LEDGER]:"54a1aa77-d202-4f8d-0fb2-5d2bb6db0300",[s.o.CONNECTOR_ID.WALLET_CONNECT]:"ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400",[s.o.CONNECTOR_ID.INJECTED]:"07ba87ed-43aa-4adf-4540-9e6a2b9cae00"},ConnectorNamesMap:{[s.o.CONNECTOR_ID.INJECTED]:"Browser Wallet",[s.o.CONNECTOR_ID.WALLET_CONNECT]:"WalletConnect",[s.o.CONNECTOR_ID.COINBASE]:"Coinbase",[s.o.CONNECTOR_ID.COINBASE_SDK]:"Coinbase",[s.o.CONNECTOR_ID.LEDGER]:"Ledger",[s.o.CONNECTOR_ID.SAFE]:"Safe"},ConnectorTypesMap:{[s.o.CONNECTOR_ID.INJECTED]:"INJECTED",[s.o.CONNECTOR_ID.WALLET_CONNECT]:"WALLET_CONNECT",[s.o.CONNECTOR_ID.EIP6963]:"ANNOUNCED",[s.o.CONNECTOR_ID.AUTH]:"AUTH"},WalletConnectRpcChainIds:[1,5,11155111,10,420,42161,421613,137,80001,42220,1313161554,1313161555,56,97,43114,43113,100,8453,84531,7777777,999,324,280]}},40868:(e,t,i)=>{i.d(t,{N:()=>b});var s=i(89168),r=i(39150),n=i(93224),o=i(5813),a=i(19760),c=i(11553),h=i(12472),d=i(99013),l=i(50731),u=i(14479),p=i(16158);const f=o.w.getApiUrl(),g=new a.Z({baseUrl:f,clientId:null}),m=(0,s.BX)({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1}),b={state:m,subscribeKey:(e,t)=>(0,r.u$)(m,e,t),_getSdkProperties(){const{projectId:e,sdkType:t,sdkVersion:i}=p.H.state;return{projectId:e,st:t||"appkit",sv:i||"html-wagmi-4.2.2"}},_filterOutExtensions:e=>p.H.state.isUniversalProvider?e.filter(e=>Boolean(e.mobile_link||e.desktop_link||e.webapp_link)):e,async _fetchWalletImage(e){const t=`${g.baseUrl}/getWalletImage/${e}`,i=await g.getBlob({path:t,params:b._getSdkProperties()});h.j.setWalletImage(e,URL.createObjectURL(i))},async _fetchNetworkImage(e){const t=`${g.baseUrl}/public/getAssetImage/${e}`,i=await g.getBlob({path:t,params:b._getSdkProperties()});h.j.setNetworkImage(e,URL.createObjectURL(i))},async _fetchConnectorImage(e){const t=`${g.baseUrl}/public/getAssetImage/${e}`,i=await g.getBlob({path:t,params:b._getSdkProperties()});h.j.setConnectorImage(e,URL.createObjectURL(i))},async _fetchCurrencyImage(e){const t=`${g.baseUrl}/public/getCurrencyImage/${e}`,i=await g.getBlob({path:t,params:b._getSdkProperties()});h.j.setCurrencyImage(e,URL.createObjectURL(i))},async _fetchTokenImage(e){const t=`${g.baseUrl}/public/getTokenImage/${e}`,i=await g.getBlob({path:t,params:b._getSdkProperties()});h.j.setTokenImage(e,URL.createObjectURL(i))},async fetchNetworkImages(){const e=d.W.getAllRequestedCaipNetworks(),t=e?.map(({assets:e})=>e?.imageId).filter(Boolean).filter(e=>!n.$.getNetworkImageById(e));t&&await Promise.allSettled(t.map(e=>b._fetchNetworkImage(e)))},async fetchConnectorImages(){const{connectors:e}=l.a.state,t=e.map(({imageId:e})=>e).filter(Boolean);await Promise.allSettled(t.map(e=>b._fetchConnectorImage(e)))},async fetchCurrencyImages(e=[]){await Promise.allSettled(e.map(e=>b._fetchCurrencyImage(e)))},async fetchTokenImages(e=[]){await Promise.allSettled(e.map(e=>b._fetchTokenImage(e)))},async fetchFeaturedWallets(){const{featuredWalletIds:e}=p.H.state;if(e?.length){const{data:t}=await g.get({path:"/getWallets",params:{...b._getSdkProperties(),page:"1",entries:e?.length?String(e.length):"4",include:e?.join(",")}});t.sort((t,i)=>e.indexOf(t.id)-e.indexOf(i.id));const i=t.map(e=>e.image_id).filter(Boolean);await Promise.allSettled(i.map(e=>b._fetchWalletImage(e))),m.featured=t,m.allFeatured=t}},async fetchRecommendedWallets(){try{m.isFetchingRecommendedWallets=!0;const{includeWalletIds:e,excludeWalletIds:t,featuredWalletIds:i}=p.H.state,s=[...t??[],...i??[]].filter(Boolean),r=d.W.getRequestedCaipNetworkIds().join(","),{data:n,count:o}=await g.get({path:"/getWallets",params:{...b._getSdkProperties(),page:"1",chains:r,entries:"4",include:e?.join(","),exclude:s?.join(",")}}),a=c.i.getRecentWallets(),h=n.map(e=>e.image_id).filter(Boolean),l=a.map(e=>e.image_id).filter(Boolean);await Promise.allSettled([...h,...l].map(e=>b._fetchWalletImage(e))),m.recommended=n,m.allRecommended=n,m.count=o??0}catch{}finally{m.isFetchingRecommendedWallets=!1}},async fetchWallets({page:e}){const{includeWalletIds:t,excludeWalletIds:i,featuredWalletIds:s}=p.H.state,r=d.W.getRequestedCaipNetworkIds().join(","),n=[...m.recommended.map(({id:e})=>e),...i??[],...s??[]].filter(Boolean),{data:a,count:c}=await g.get({path:"/getWallets",params:{...b._getSdkProperties(),page:String(e),entries:"40",chains:r,include:t?.join(","),exclude:n.join(",")}}),h=a.slice(0,20).map(e=>e.image_id).filter(Boolean);await Promise.allSettled(h.map(e=>b._fetchWalletImage(e))),m.wallets=o.w.uniqueBy([...m.wallets,...b._filterOutExtensions(a)],"id"),m.count=c>m.count?c:m.count,m.page=e},async initializeExcludedWallets({ids:e}){const t=d.W.getRequestedCaipNetworkIds().join(","),{data:i}=await g.get({path:"/getWallets",params:{...b._getSdkProperties(),page:"1",entries:String(e.length),chains:t,include:e?.join(",")}});i&&i.forEach(e=>{e?.rdns&&m.excludedWallets.push({rdns:e.rdns,name:e.name})})},async searchWallet({search:e,badge:t}){const{includeWalletIds:i,excludeWalletIds:s}=p.H.state;m.search=[];const r=d.W.getRequestedCaipNetworkIds().join(","),{data:n}=await g.get({path:"/getWallets",params:{...b._getSdkProperties(),page:"1",entries:"100",search:e?.trim(),badge_type:t,chains:r,include:i?.join(","),exclude:s?.join(",")}});u.E.sendEvent({type:"track",event:"SEARCH_WALLET",properties:{badge:t??"",search:e??""}});const a=n.map(e=>e.image_id).filter(Boolean);await Promise.allSettled([...a.map(e=>b._fetchWalletImage(e)),o.w.wait(300)]),m.search=b._filterOutExtensions(n)},initPromise:(e,t)=>m.promises[e]||(m.promises[e]=t()),prefetch({fetchConnectorImages:e=!0,fetchFeaturedWallets:t=!0,fetchRecommendedWallets:i=!0,fetchNetworkImages:s=!0}={}){const r=[e&&b.initPromise("connectorImages",b.fetchConnectorImages),t&&b.initPromise("featuredWallets",b.fetchFeaturedWallets),i&&b.initPromise("recommendedWallets",b.fetchRecommendedWallets),s&&b.initPromise("networkImages",b.fetchNetworkImages)].filter(Boolean);return Promise.allSettled(r)},prefetchAnalyticsConfig(){p.H.state.features?.analytics&&b.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:e}=await g.get({path:"/getAnalyticsConfig",params:b._getSdkProperties()});p.H.setFeatures({analytics:e})}catch(e){p.H.setFeatures({analytics:!1})}},setFilterByNamespace(e){if(!e)return m.featured=m.allFeatured,void(m.recommended=m.allRecommended);const t=d.W.getRequestedCaipNetworkIds().join(",");m.featured=m.allFeatured.filter(e=>e.chains?.some(e=>t.includes(e))),m.recommended=m.allRecommended.filter(e=>e.chains?.some(e=>t.includes(e)))}}},41276:(e,t,i)=>{i.d(t,{f:()=>s});class s extends Error{constructor(e){super(`WalletConnect Adapter - Method ${e} is not supported by the wallet`),this.name="WalletConnectFeatureNotSupportedError"}}},41430:(e,t,i)=>{i.d(t,{P:()=>c});var s=i(89168),r=i(39150),n=i(5813);const o=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),a=(0,s.BX)({...o}),c={state:a,subscribeKey:(e,t)=>(0,r.u$)(a,e,t),showLoading(e,t={}){this._showMessage({message:e,variant:"loading",...t})},showSuccess(e){this._showMessage({message:e,variant:"success"})},showSvg(e,t){this._showMessage({message:e,svg:t})},showError(e){const t=n.w.parseError(e);this._showMessage({message:t,variant:"error"})},hide(){a.message=o.message,a.variant=o.variant,a.svg=o.svg,a.open=o.open,a.autoClose=o.autoClose},_showMessage({message:e,svg:t,variant:i="success",autoClose:s=o.autoClose}){a.open?(a.open=!1,setTimeout(()=>{a.message=e,a.variant=i,a.svg=t,a.open=!0,a.autoClose=s},150)):(a.message=e,a.variant=i,a.svg=t,a.open=!0,a.autoClose=s)}}},41874:(e,t,i)=>{var s=t,r=i(64845),n=i(7784),o=i(89042);s.assert=n,s.toArray=o.toArray,s.zero2=o.zero2,s.toHex=o.toHex,s.encode=o.encode,s.getNAF=function(e,t,i){var s,r=new Array(Math.max(e.bitLength(),i)+1);for(s=0;s<r.length;s+=1)r[s]=0;var n=1<<t+1,o=e.clone();for(s=0;s<r.length;s++){var a,c=o.andln(n-1);o.isOdd()?(a=c>(n>>1)-1?(n>>1)-c:c,o.isubn(a)):a=0,r[s]=a,o.iushrn(1)}return r},s.getJSF=function(e,t){var i=[[],[]];e=e.clone(),t=t.clone();for(var s,r=0,n=0;e.cmpn(-r)>0||t.cmpn(-n)>0;){var o,a,c=e.andln(3)+r&3,h=t.andln(3)+n&3;3===c&&(c=-1),3===h&&(h=-1),o=1&c?3!=(s=e.andln(7)+r&7)&&5!==s||2!==h?c:-c:0,i[0].push(o),a=1&h?3!=(s=t.andln(7)+n&7)&&5!==s||2!==c?h:-h:0,i[1].push(a),2*r===o+1&&(r=1-r),2*n===a+1&&(n=1-n),e.iushrn(1),t.iushrn(1)}return i},s.cachedProperty=function(e,t,i){var s="_"+t;e.prototype[t]=function(){return void 0!==this[s]?this[s]:this[s]=i.call(this)}},s.parseBytes=function(e){return"string"==typeof e?s.toArray(e,"hex"):e},s.intFromLE=function(e){return new r(e,"hex","le")}},41977:(e,t,i)=>{i.d(t,{_:()=>M});var s=i(23438),r=i(76020),n=i(95191),o=i(59677),a=i(44637),c=i(42831),h=i(16279),d=i(99013),l=i(89058),u=i(50731),p=i(41430),f=i(26545),g=i(16158),m=i(27006),b=i(25422),y=i(14479),w=i(29864),v=i(27938),I=i(93224),E=i(5813),_=i(11553),A=i(24096),N=i(94768),C=i(98207),S=i(28127),P=i(82420),O=i(38132),T=i(15579),x=i(79473),k=i(46779),R=i(86808);class M{constructor(e){this.hasSwitchedToPreferredAccountTypeOnConnect=!1,this.chainNamespaces=[],this.reportedAlertErrors={},this.getCaipNetwork=e=>{if(e){const t=d.W.getNetworkData(e)?.caipNetwork;return t||d.W.getRequestedCaipNetworks(e).filter(t=>t.chainNamespace===e)?.[0]}return d.W.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const e=this.getCaipNetwork();if(e)return e.id},this.getCaipNetworks=e=>d.W.getRequestedCaipNetworks(e),this.getActiveChainNamespace=()=>d.W.state.activeChain,this.setRequestedCaipNetworks=(e,t)=>{d.W.setRequestedCaipNetworks(e,t)},this.getApprovedCaipNetworkIds=()=>d.W.getAllApprovedCaipNetworkIds(),this.getCaipAddress=e=>d.W.state.activeChain!==e&&e?d.W.getAccountProp("caipAddress",e):d.W.state.activeCaipAddress,this.setClientId=e=>{m.T.setClientId(e)},this.getProvider=e=>x.A.getProvider(e),this.getProviderType=e=>x.A.getProviderId(e),this.getPreferredAccountType=()=>h.U.state.preferredAccountType,this.setCaipAddress=(e,t)=>{h.U.setCaipAddress(e,t)},this.setBalance=(e,t,i)=>{h.U.setBalance(e,t,i)},this.setProfileName=(e,t)=>{h.U.setProfileName(e,t)},this.setProfileImage=(e,t)=>{h.U.setProfileImage(e,t)},this.setUser=(e,t)=>{h.U.setUser(e,t),g.H.state.enableEmbedded&&a.W.close()},this.resetAccount=e=>{h.U.resetAccount(e)},this.setCaipNetwork=e=>{d.W.setActiveCaipNetwork(e)},this.setCaipNetworkOfNamespace=(e,t)=>{d.W.setChainNetworkData(t,{caipNetwork:e})},this.setAllAccounts=(e,t)=>{h.U.setAllAccounts(e,t),g.H.setHasMultipleAddresses(e?.length>1)},this.setStatus=(e,t)=>{h.U.setStatus(e,t),u.a.isConnected()?_.i.setConnectionStatus("connected"):_.i.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=e=>d.W.getAccountProp("address",e),this.setConnectors=e=>{const t=[...u.a.getConnectors(),...e];u.a.setConnectors(t)},this.fetchIdentity=e=>m.T.fetchIdentity(e),this.getReownName=e=>w.f.getNamesForAddress(e),this.getConnectors=()=>u.a.getConnectors(),this.getConnectorImage=e=>I.$.getConnectorImage(e),this.setConnectedWalletInfo=(e,t)=>{const i=x.A.getProviderId(t),s=e?{...e,type:i}:void 0;h.U.setConnectedWalletInfo(s,t)},this.getIsConnectedState=()=>Boolean(d.W.state.activeCaipAddress),this.addAddressLabel=(e,t,i)=>{h.U.addAddressLabel(e,t,i)},this.removeAddressLabel=(e,t)=>{h.U.removeAddressLabel(e,t)},this.getAddress=e=>d.W.state.activeChain!==e&&e?d.W.getAccountProp("address",e):h.U.state.address,this.setApprovedCaipNetworksData=e=>d.W.setApprovedCaipNetworksData(e),this.resetNetwork=e=>{d.W.resetNetwork(e)},this.addConnector=e=>{u.a.addConnector(e)},this.resetWcConnection=()=>{l.x.resetWcConnection()},this.setAddressExplorerUrl=(e,t)=>{h.U.setAddressExplorerUrl(e,t)},this.setSmartAccountDeployed=(e,t)=>{h.U.setSmartAccountDeployed(e,t)},this.setSmartAccountEnabledNetworks=(e,t)=>{d.W.setSmartAccountEnabledNetworks(e,t)},this.setPreferredAccountType=(e,t)=>{h.U.setPreferredAccountType(e,t)},this.setEIP6963Enabled=e=>{g.H.setEIP6963Enabled(e)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=[...new Set(this.caipNetworks?.map(e=>e.chainNamespace))],this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.initialize(e),this.sendInitializeEvent(e)}async initialize(e){this.initControllers(e),await this.initChainAdapters(),await this.injectModalUi(),await this.syncExistingConnection(),b.z.set({initialized:!0})}sendInitializeEvent(e){const{...t}=e;delete t.adapters,y.E.sendEvent({type:"track",event:"INITIALIZE",properties:{...t,networks:e.networks.map(e=>e.id),siweConfig:{options:e.siweConfig?.options||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&f.W.setThemeMode(e.themeMode),e.themeVariables&&f.W.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");d.W.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const t=this.getDefaultNetwork();t&&d.W.setActiveCaipNetwork(t)}initializeConnectionController(e){l.x.setWcBasic(e.basic??!1)}initializeConnectorController(){u.a.initialize(this.chainNamespaces)}initializeOptionsController(e){g.H.setDebug(!1!==e.debug),g.H.setEnableWalletConnect(!1!==e.enableWalletConnect),g.H.setEnableWalletGuide(!1!==e.enableWalletGuide),g.H.setEnableWallets(!1!==e.enableWallets),g.H.setEIP6963Enabled(!1!==e.enableEIP6963),g.H.setEnableNetworkSwitch(!1!==e.enableNetworkSwitch),g.H.setEnableAuthLogger(!1!==e.enableAuthLogger),g.H.setCustomRpcUrls(e.customRpcUrls),g.H.setSdkVersion(e.sdkVersion),g.H.setProjectId(e.projectId),g.H.setEnableEmbedded(e.enableEmbedded),g.H.setAllWallets(e.allWallets),g.H.setIncludeWalletIds(e.includeWalletIds),g.H.setExcludeWalletIds(e.excludeWalletIds),g.H.setFeaturedWalletIds(e.featuredWalletIds),g.H.setTokens(e.tokens),g.H.setTermsConditionsUrl(e.termsConditionsUrl),g.H.setPrivacyPolicyUrl(e.privacyPolicyUrl),g.H.setCustomWallets(e.customWallets),g.H.setFeatures(e.features),g.H.setAllowUnsupportedChain(e.allowUnsupportedChain),g.H.setDefaultAccountTypes(e.defaultAccountTypes),g.H.setUniversalProviderConfigOverride(e.universalProviderConfigOverride);const t=this.getDefaultMetaData();if(!e.metadata&&t&&(e.metadata=t),g.H.setMetadata(e.metadata),g.H.setDisableAppend(e.disableAppend),g.H.setEnableEmbedded(e.enableEmbedded),g.H.setSIWX(e.siwx),!e.projectId)return void v.h.open(P.R.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");const i=e.adapters?.find(e=>e.namespace===n.o.CHAIN.EVM);if(i&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");g.H.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){return"undefined"!=typeof window&&"undefined"!=typeof document?{name:document.getElementsByTagName("title")?.[0]?.textContent||"",description:document.querySelector('meta[property="og:description"]')?.content||"",url:window.location.origin,icons:[document.querySelector('link[rel~="icon"]')?.href||""]}:null}setUnsupportedNetwork(e){const t=this.getActiveChainNamespace();if(t){const i=T.R.getUnsupportedNetwork(`${t}:${e}`);d.W.setActiveCaipNetwork(i)}}getDefaultNetwork(){return T.R.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,t){return T.R.extendCaipNetwork(e,{customNetworkImageUrls:t.chainImages,projectId:t.projectId})}extendCaipNetworks(e){return T.R.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const t=e.networks.find(t=>t.id===e.defaultNetwork?.id);return t?T.R.extendCaipNetwork(t,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{const e=d.W.state.activeChain,t=this.getAdapter(e),i=this.getCaipNetwork(e)?.id;if(!t)throw new Error("Adapter not found");const s=await t.connectWalletConnect(i);this.close(),this.setClientId(s?.clientId||null),_.i.setConnectedNamespaces([...d.W.state.chains.keys()]),this.chainNamespaces.forEach(e=>{u.a.setConnectorId(C.o.CONNECTOR_TYPE_WALLET_CONNECT,e)}),await this.syncWalletConnectAccount()},connectExternal:async({id:e,info:t,type:i,provider:s,chain:r,caipNetwork:n})=>{const o=d.W.state.activeChain,a=r||o,c=this.getAdapter(a);if(r&&r!==o&&!n){const e=this.caipNetworks?.find(e=>e.chainNamespace===r);e&&this.setCaipNetwork(e)}if(!c)throw new Error("Adapter not found");const h=this.getCaipNetwork(a),l=await c.connect({id:e,info:t,type:i,provider:s,chainId:n?.id||h?.id,rpcUrl:n?.rpcUrls?.default?.http?.[0]||h?.rpcUrls?.default?.http?.[0]});if(!l)return;_.i.addConnectedNamespace(a),this.syncProvider({...l,chainNamespace:a}),await this.syncAccount({...l,chainNamespace:a});const{accounts:u}=await c.getAccounts({namespace:a,id:e});this.setAllAccounts(u,a)},reconnectExternal:async({id:e,info:t,type:i,provider:s})=>{const r=d.W.state.activeChain,n=this.getAdapter(r);n?.reconnect&&(await(n?.reconnect({id:e,info:t,type:i,provider:s,chainId:this.getCaipNetwork()?.id})),_.i.addConnectedNamespace(r))},disconnect:async e=>{const t=e||d.W.state.activeChain,i=this.getAdapter(t),s=x.A.getProvider(t),r=x.A.getProviderId(t);await(i?.disconnect({provider:s,providerType:r})),_.i.removeConnectedNamespace(t),x.A.resetChain(t),this.setUser(void 0,t),this.setStatus("disconnected",t),this.hasSwitchedToPreferredAccountTypeOnConnect=!1},checkInstalled:e=>e?e.some(e=>Boolean(window.ethereum?.[String(e)])):Boolean(window.ethereum),signMessage:async e=>{const t=this.getAdapter(d.W.state.activeChain),i=await(t?.signMessage({message:e,address:h.U.state.address,provider:x.A.getProvider(d.W.state.activeChain)}));return i?.signature||""},sendTransaction:async e=>{if(e.chainNamespace===n.o.CHAIN.EVM){const t=this.getAdapter(d.W.state.activeChain),i=x.A.getProvider(d.W.state.activeChain),s=await(t?.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:i}));return s?.hash||""}return""},estimateGas:async e=>{if(e.chainNamespace===n.o.CHAIN.EVM){const t=this.getAdapter(d.W.state.activeChain),i=x.A.getProvider(d.W.state.activeChain),s=this.getCaipNetwork();if(!s)throw new Error("CaipNetwork is undefined");const r=await(t?.estimateGas({...e,provider:i,caipNetwork:s}));return r?.gas||0n}return 0n},getEnsAvatar:async()=>{const e=this.getAdapter(d.W.state.activeChain),t=await(e?.getProfile({address:h.U.state.address,chainId:Number(this.getCaipNetwork()?.id)}));return t?.profileImage||!1},getEnsAddress:async e=>{const t=this.getAdapter(d.W.state.activeChain),i=this.getCaipNetwork();if(!i)return!1;const s=await(t?.getEnsAddress({name:e,caipNetwork:i}));return s?.address||!1},writeContract:async e=>{const t=this.getAdapter(d.W.state.activeChain),i=this.getCaipNetwork(),s=this.getCaipAddress(),r=x.A.getProvider(d.W.state.activeChain);if(!i||!s)throw new Error("CaipNetwork or CaipAddress is undefined");const n=await(t?.writeContract({...e,caipNetwork:i,provider:r,caipAddress:s}));return n?.hash},parseUnits:(e,t)=>{const i=this.getAdapter(d.W.state.activeChain);return i?.parseUnits({value:e,decimals:t})??0n},formatUnits:(e,t)=>{const i=this.getAdapter(d.W.state.activeChain);return i?.formatUnits({value:e,decimals:t})??"0"},getCapabilities:async e=>{const t=this.getAdapter(d.W.state.activeChain);return await(t?.getCapabilities(e))},grantPermissions:async e=>{const t=this.getAdapter(d.W.state.activeChain);return await(t?.grantPermissions(e))},revokePermissions:async e=>{const t=this.getAdapter(d.W.state.activeChain);return t?.revokePermissions?await t.revokePermissions(e):"0x"},walletGetAssets:async e=>{const t=this.getAdapter(d.W.state.activeChain);return await(t?.walletGetAssets(e))??{}}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},l.x.setClient(this.connectionControllerClient)}getApprovedCaipNetworksData(){if(x.A.getProviderId(d.W.state.activeChain)===C.o.CONNECTOR_TYPE_WALLET_CONNECT){const e=this.universalProvider?.session?.namespaces;return{supportsAllNetworks:"MetaMask Wallet"===this.universalProvider?.session?.peer?.metadata.name,approvedCaipNetworkIds:this.getChainsFromNamespaces(e)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){if(!e)return;const t=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const i=x.A.getProvider(t),s=x.A.getProviderId(t);if(e.chainNamespace===d.W.state.activeChain){const r=this.getAdapter(t);await(r?.switchNetwork({caipNetwork:e,provider:i,providerType:s}))}else if(this.setCaipNetwork(e),s===C.o.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const i=this.getAddressByChainNamespace(t);i&&this.syncAccount({address:i,chainId:e.id,chainNamespace:t})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(e=>{const t=e.chains||[],i=e.accounts.map(e=>{const{chainId:t,chainNamespace:i}=o.C.parseCaipAddress(e);return`${i}:${t}`});return Array.from(new Set([...t,...i]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((t,i)=>{const s=e?.find(e=>e.namespace===i);return s?(t[i]=s,t[i].namespace=i,t[i].construct({namespace:i,projectId:this.options?.projectId,networks:this.caipNetworks})):t[i]=new k.n({namespace:i,networks:this.caipNetworks}),t},{})}async initChainAdapter(e){this.onConnectors(e),this.listenAdapter(e),this.chainAdapters?.[e].syncConnectors(this.options,this),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)}))}onConnectors(e){const t=this.getAdapter(e);t?.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const t=this.getAdapter(e);if(!t)return;const i=_.i.getConnectionStatus();"connected"===i?this.setStatus("connecting",e):"disconnected"===i?(_.i.clearAddressCache(),this.setStatus(i,e)):this.setStatus(i,e),t.on("switchNetwork",({address:t,chainId:i})=>{const s=this.caipNetworks?.find(e=>e.id===i||e.caipNetworkId===i),r=d.W.state.activeChain===e,n=d.W.getAccountProp("address",e);if(s){const s=r&&t?t:n;s&&this.syncAccount({address:s,chainId:i,chainNamespace:e})}else this.setUnsupportedNetwork(i)}),t.on("disconnect",this.disconnect.bind(this,e)),t.on("pendingTransactions",()=>{const e=h.U.state.address,t=d.W.state.activeCaipNetwork;e&&t?.id&&this.updateNativeBalance(e,t.id,t.chainNamespace)}),t.on("accountChanged",({address:t,chainId:i})=>{const s=d.W.state.activeChain===e;s&&i?this.syncAccount({address:t,chainId:i,chainNamespace:e}):s&&d.W.state.activeCaipNetwork?.id?this.syncAccount({address:t,chainId:d.W.state.activeCaipNetwork?.id,chainNamespace:e}):this.syncAccountInfo(t,i,e)})}async createUniversalProviderForAdapter(e){await this.getUniversalProvider(),this.universalProvider&&this.chainAdapters?.[e]?.setUniversalProvider?.(this.universalProvider)}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async syncNamespaceConnection(e){try{const t=u.a.getConnectorId(e);switch(this.setStatus("connecting",e),t){case n.o.CONNECTOR_ID.WALLET_CONNECT:await this.syncWalletConnectAccount();break;case n.o.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(t){console.warn("AppKit couldn't sync existing connection",t),this.setStatus("disconnected",e)}}async syncAdapterConnection(e){const t=this.getAdapter(e),i=u.a.getConnectorId(e),s=this.getCaipNetwork(e),r=u.a.getConnectors(e).find(e=>e.id===i);try{if(!t||!r)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!s?.id)throw new Error("CaipNetwork not found");const i=await(t?.syncConnection({namespace:e,id:r.id,chainId:s.id,rpcUrl:s?.rpcUrls?.default?.http?.[0]}));if(i){const s=await(t?.getAccounts({namespace:e,id:r.id}));s&&s.accounts.length>0?this.setAllAccounts(s.accounts,e):this.setAllAccounts([E.w.createAccount(e,i.address,"eoa")],e),this.syncProvider({...i,chainNamespace:e}),await this.syncAccount({...i,chainNamespace:e}),this.setStatus("connected",e)}else this.setStatus("disconnected",e)}catch(t){this.setStatus("disconnected",e)}}async syncWalletConnectAccount(){const e=this.chainNamespaces.map(async e=>{const t=this.getAdapter(e),i=this.universalProvider?.session?.namespaces?.[e]?.accounts||[],s=d.W.state.activeCaipNetwork?.id,r=i.find(e=>{const{chainId:t}=o.C.parseCaipAddress(e);return t===s?.toString()})||i[0];if(r){const i=o.C.validateCaipAddress(r),{chainId:s,address:a}=o.C.parseCaipAddress(i);if(x.A.setProviderId(e,C.o.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&d.W.state.activeCaipNetwork&&t?.namespace!==n.o.CHAIN.EVM){const i=t?.getWalletConnectProvider({caipNetworks:this.caipNetworks,provider:this.universalProvider,activeCaipNetwork:d.W.state.activeCaipNetwork});x.A.setProvider(e,i)}else x.A.setProvider(e,this.universalProvider);u.a.setConnectorId(n.o.CONNECTOR_ID.WALLET_CONNECT,e),_.i.addConnectedNamespace(e),this.syncWalletConnectAccounts(e),await this.syncAccount({address:a,chainId:s,chainNamespace:e})}else this.setStatus("disconnected",e);await d.W.setApprovedCaipNetworksData(e)});await Promise.all(e)}syncWalletConnectAccounts(e){const t=this.universalProvider?.session?.namespaces?.[e]?.accounts?.map(e=>{const{address:t}=o.C.parseCaipAddress(e);return t}).filter((e,t,i)=>i.indexOf(e)===t);t&&this.setAllAccounts(t.map(t=>E.w.createAccount(e,t,"bip122"===e?"payment":"eoa")),e)}syncProvider({type:e,provider:t,id:i,chainNamespace:s}){x.A.setProviderId(s,e),x.A.setProvider(s,t),u.a.setConnectorId(i,s)}async syncAccount(e){const t=e.chainNamespace===d.W.state.activeChain,i=d.W.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:s,chainId:r,chainNamespace:a}=e,{chainId:c}=_.i.getActiveNetworkProps(),l=r||c,u=d.W.state.activeCaipNetwork?.name===n.o.UNSUPPORTED_NETWORK_NAME,p=d.W.getNetworkProp("supportsAllNetworks",a);if(this.setStatus("connected",a),(!u||p)&&l){let e=this.caipNetworks?.find(e=>e.id.toString()===l.toString()),r=this.caipNetworks?.find(e=>e.chainNamespace===a);if(!p&&!e&&!r){const t=this.getApprovedCaipNetworkIds()||[],i=t.find(e=>o.C.parseCaipNetworkId(e)?.chainId===l.toString()),s=t.find(e=>o.C.parseCaipNetworkId(e)?.chainNamespace===a);e=this.caipNetworks?.find(e=>e.caipNetworkId===i),r=this.caipNetworks?.find(e=>e.caipNetworkId===s||"deprecatedCaipNetworkId"in e&&e.deprecatedCaipNetworkId===s)}const c=e||r;c?.chainNamespace===d.W.state.activeChain?g.H.state.enableNetworkSwitch&&!g.H.state.allowUnsupportedChain&&d.W.state.activeCaipNetwork?.name===n.o.UNSUPPORTED_NETWORK_NAME?d.W.showUnsupportedChainUI():this.setCaipNetwork(c):t||i&&this.setCaipNetworkOfNamespace(i,a),this.syncConnectedWalletInfo(a),S.y.isLowerCaseMatch(s,h.U.state.address)||this.syncAccountInfo(s,c?.id,a),t?await this.syncBalance({address:s,chainId:c?.id,chainNamespace:a}):await this.syncBalance({address:s,chainId:i?.id,chainNamespace:a})}}async syncAccountInfo(e,t,i){const s=this.getCaipAddress(i),r=t||s?.split(":")[1];if(!r)return;const n=`${i}:${r}:${e}`;this.setCaipAddress(n,i),await this.syncIdentity({address:e,chainId:r,chainNamespace:i})}async syncReownName(e,t){try{const i=await this.getReownName(e);if(i[0]){const e=i[0];this.setProfileName(e.name,t)}else this.setProfileName(null,t)}catch{this.setProfileName(null,t)}}syncConnectedWalletInfo(e){const t=u.a.getConnectorId(e),i=x.A.getProviderId(e);if(i===C.o.CONNECTOR_TYPE_ANNOUNCED||i===C.o.CONNECTOR_TYPE_INJECTED){if(t){const i=this.getConnectors().find(e=>e.id===t);if(i){const{info:t,name:s,imageUrl:r}=i,n=r||this.getConnectorImage(i);this.setConnectedWalletInfo({name:s,icon:n,...t},e)}}}else if(i===C.o.CONNECTOR_TYPE_WALLET_CONNECT){const t=x.A.getProvider(e);t?.session&&this.setConnectedWalletInfo({...t.session.peer.metadata,name:t.session.peer.metadata.name,icon:t.session.peer.metadata.icons?.[0]},e)}else if(t)if(t===n.o.CONNECTOR_ID.COINBASE){const t=this.getConnectors().find(e=>e.id===n.o.CONNECTOR_ID.COINBASE);this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(t)},e)}else this.setConnectedWalletInfo({name:t},e)}async syncBalance(e){r.L.getNetworksByNamespace(this.caipNetworks,e.chainNamespace).find(t=>t.id.toString()===e.chainId?.toString())&&e.chainId&&await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async updateNativeBalance(e,t,i){const s=this.getAdapter(i);if(s){const r=await s.getBalance({address:e,chainId:t,caipNetwork:this.getCaipNetwork(i),tokens:this.options.tokens});this.setBalance(r.balance,r.symbol,i)}}async initializeUniversalAdapter(){const e=O.r.createLogger((e,...t)=>{e&&this.handleAlertError(e),console.error(...t)}),t={projectId:this.options?.projectId,metadata:{name:this.options?.metadata?this.options?.metadata.name:"",description:this.options?.metadata?this.options?.metadata.description:"",url:this.options?.metadata?this.options?.metadata.url:"",icons:this.options?.metadata?this.options?.metadata.icons:[""]},logger:e};g.H.setManualWCControl(Boolean(this.options?.manualWCControl)),this.universalProvider=this.options.universalProvider??await s.A.init(t),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&(this.universalProvider.on("display_uri",e=>{l.x.setUri(e)}),this.universalProvider.on("connect",l.x.finalizeWcConnection),this.universalProvider.on("disconnect",()=>{this.chainNamespaces.forEach(e=>{this.resetAccount(e)}),l.x.resetWcConnection()}),this.universalProvider.on("chainChanged",e=>{const t=this.caipNetworks?.find(t=>t.id==e),i=this.getCaipNetwork();t?i?.id!==t?.id&&this.setCaipNetwork(t):this.setUnsupportedNetwork(e)}),this.universalProvider.on("session_event",e=>{if(R.kl.isSessionEventData(e)){const{name:t,data:i}=e.params.event;"accountsChanged"===t&&Array.isArray(i)&&E.w.isCaipAddress(i[0])&&this.syncAccount(o.C.parseCaipAddress(i[0]))}}))}createUniversalProvider(){return!this.universalProviderInitPromise&&E.w.isClient()&&this.options?.projectId&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){y.E.sendEvent({type:"error",event:"INTERNAL_SDK_ERROR",properties:{errorType:"UniversalProviderInitError",errorMessage:e instanceof Error?e.message:"Unknown",uncaught:!1}}),console.error("AppKit:getUniversalProvider - Cannot create provider",e)}return this.universalProvider}handleAlertError(e){const t=Object.entries(P.R.UniversalProviderErrors).find(([,{message:t}])=>e.message.includes(t)),[i,s]=t??[],{message:r,alertErrorKey:n}=s??{};if(i&&r&&!this.reportedAlertErrors[i]){const e=P.R.ALERT_ERRORS[n];e&&(v.h.open(e,"error"),this.reportedAlertErrors[i]=!0)}}getAdapter(e){if(e)return this.chainAdapters?.[e]}createAdapter(e){if(!e)return;const t=e.namespace;if(!t)return;this.createClients();const i=e;i.namespace=t,i.construct({namespace:t,projectId:this.options?.projectId,networks:this.caipNetworks}),this.chainNamespaces.includes(t)||this.chainNamespaces.push(t),this.chainAdapters&&(this.chainAdapters[t]=i)}async open(e){await this.injectModalUi(),e?.uri&&l.x.setUri(e.uri),await a.W.open(e)}async close(){await this.injectModalUi(),a.W.close()}setLoading(e,t){a.W.setLoading(e,t)}async disconnect(e){await l.x.disconnect(e)}getError(){return""}getChainId(){return d.W.state.activeCaipNetwork?.id}async switchNetwork(e){const t=this.caipNetworks?.find(t=>t.id===e.id);t?await d.W.switchActiveNetwork(t):v.h.open(P.R.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error")}getWalletProvider(){return d.W.state.activeChain?x.A.state.providers[d.W.state.activeChain]:null}getWalletProviderType(){return x.A.getProviderId(d.W.state.activeChain)}subscribeProviders(e){return x.A.subscribeProviders(e)}getThemeMode(){return f.W.state.themeMode}getThemeVariables(){return f.W.state.themeVariables}setThemeMode(e){f.W.setThemeMode(e),(0,N.JX)(f.W.state.themeMode)}setTermsConditionsUrl(e){g.H.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){g.H.setPrivacyPolicyUrl(e)}setThemeVariables(e){f.W.setThemeVariables(e),(0,N.ds)(f.W.state.themeVariables)}subscribeTheme(e){return f.W.subscribe(e)}getWalletInfo(){return h.U.state.connectedWalletInfo}getAccount(e){const t=u.a.getAuthConnector(e),i=d.W.getAccountData(e);if(i)return{allAccounts:i.allAccounts,caipAddress:i.caipAddress,address:E.w.getPlainAddress(i.caipAddress),isConnected:Boolean(i.caipAddress),status:i.status,embeddedWalletInfo:t?{user:i.user,authProvider:i.socialProvider||"email",accountType:i.preferredAccountType,isSmartAccountDeployed:Boolean(i.smartAccountDeployed)}:void 0}}subscribeAccount(e,t){const i=()=>{const i=this.getAccount(t);i&&e(i)};t?d.W.subscribeChainProp("accountState",i,t):d.W.subscribe(i),u.a.subscribe(i)}subscribeNetwork(e){return d.W.subscribe(({activeCaipNetwork:t})=>{e({caipNetwork:t,chainId:t?.id,caipNetworkId:t?.caipNetworkId})})}subscribeWalletInfo(e){return h.U.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){h.U.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){d.W.subscribeKey("activeCaipNetwork",e)}getState(){return b.z.state}subscribeState(e){return b.z.subscribe(e)}showErrorMessage(e){p.P.showError(e)}showSuccessMessage(e){p.P.showSuccess(e)}getEvent(){return{...y.E.state}}subscribeEvents(e){return y.E.subscribe(e)}replace(e){c.I.replace(e)}redirect(e){c.I.push(e)}popTransactionStack(e){c.I.popTransactionStack(e)}isOpen(){return a.W.state.open}isTransactionStackEmpty(){return 0===c.I.state.transactionStack.length}isTransactionShouldReplaceView(){return c.I.state.transactionStack[c.I.state.transactionStack.length-1]?.replace}static getInstance(){return this.instance}updateFeatures(e){g.H.setFeatures(e)}updateOptions(e){const t={...g.H.state||{},...e};g.H.setOptions(t)}setConnectMethodsOrder(e){g.H.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){g.H.setWalletFeaturesOrder(e)}setCollapseWallets(e){g.H.setCollapseWallets(e)}setSocialsOrder(e){g.H.setSocialsOrder(e)}getConnectMethodsOrder(){return A.Aj.getConnectOrderMethod(g.H.state.features,u.a.getConnectors())}removeAdapter(e){const t=this.getIsConnectedState(),i=this.getAdapter(e);if(!i||!this.chainAdapters||t)return;const s=this.caipNetworks?.filter(t=>t.chainNamespace!==e);d.W.removeAdapter(e),u.a.removeAdapter(e),this.chainNamespaces=this.chainNamespaces.filter(t=>t!==e),this.caipNetworks=s,i.removeAllEventListeners(),Reflect.deleteProperty(this.chainAdapters,e)}addAdapter(e,t){const i=e.namespace;if(!this.connectionControllerClient||!this.networkControllerClient)return;if(!this.chainAdapters||!i)return;const s=this.extendCaipNetworks({...this.options,networks:t});this.caipNetworks=[...this.caipNetworks||[],...s],this.createAdapter(e),this.initChainAdapter(i),d.W.addAdapter(e,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient},s)}addNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const i=this.extendCaipNetwork(t,this.options);d.W.addNetwork(i),this.caipNetworks&&!this.caipNetworks?.find(e=>e.id===i.id)&&this.caipNetworks.push(i)}removeNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const i=this.caipNetworks?.find(e=>e.id===t);if(!i)throw new Error(`Network with ID ${t} not found`);if(!this.caipNetworks)return;const s=this.caipNetworks.filter(i=>i.chainNamespace===e&&i.id!==t);if(!s?.length)throw new Error("Cannot remove last network for a namespace");d.W.removeNetwork(e,t),this.caipNetworks=[...s]}}},42831:(e,t,i)=>{i.d(t,{I:()=>l});var s=i(89168),r=i(39150),n=i(16279),o=i(99013),a=i(50731),c=i(44637),h=i(16158);const d=(0,s.BX)({view:"Connect",history:["Connect"],transactionStack:[]}),l={state:d,subscribeKey:(e,t)=>(0,r.u$)(d,e,t),pushTransactionStack(e){d.transactionStack.push(e)},popTransactionStack(e){const t=d.transactionStack.pop();if(t)if(e)this.goBack(),t?.onCancel?.();else{if(t.goBack)this.goBack();else if(t.replace){const e=d.history.indexOf("ConnectingSiwe");e>0?this.goBackToIndex(e-1):(c.W.close(),d.history=[])}else t.view&&this.reset(t.view);t?.onSuccess?.()}},push(e,t){e!==d.view&&(d.view=e,d.history.push(e),d.data=t)},reset(e,t){d.view=e,d.history=[e],d.data=t},replace(e,t){d.history.at(-1)===e||(d.view=e,d.history[d.history.length-1]=e,d.data=t)},goBack(){const e=!o.W.state.activeCaipAddress&&"ConnectingFarcaster"===this.state.view;if(d.history.length>1&&!d.history.includes("UnsupportedChain")){d.history.pop();const[e]=d.history.slice(-1);e&&(d.view=e)}else c.W.close();d.data?.wallet&&(d.data.wallet=void 0),setTimeout(()=>{if(e){n.U.setFarcasterUrl(void 0,o.W.state.activeChain);const e=a.a.getAuthConnector();e?.provider?.reload();const t=(0,s.P9)(h.H.state);e?.provider?.syncDappData?.({metadata:t.metadata,sdkVersion:t.sdkVersion,projectId:t.projectId,sdkType:t.sdkType})}},100)},goBackToIndex(e){if(d.history.length>1){d.history=d.history.slice(0,e+1);const[t]=d.history.slice(-1);t&&(d.view=t)}}}},43039:(e,t,i)=>{i.d(t,{$Bq:()=>Dt,$hI:()=>O,ALl:()=>Ut,Alu:()=>si,EHS:()=>Rt,EN$:()=>Mt,EWt:()=>Ot,FR8:()=>ci,FiO:()=>ei,GuA:()=>Bt,HNf:()=>Gt,Hbs:()=>fi,Hjj:()=>zt,IjX:()=>_e,Lp_:()=>kt,M8n:()=>ai,OP1:()=>Ht,PAk:()=>de,Pa8:()=>Tt,Qhg:()=>Ft,TeY:()=>ri,V9G:()=>ii,VBM:()=>Re,Van:()=>Lt,WWN:()=>ke,Wx8:()=>I,X3c:()=>ni,XqR:()=>ui,Xw0:()=>_,_Yb:()=>u,_dF:()=>A,aF0:()=>Wt,b07:()=>Vt,c82:()=>E,e8_:()=>Oe,esh:()=>Zt,hEn:()=>N,hVC:()=>Te,hwK:()=>Ae,iV1:()=>oi,jTh:()=>P,kuU:()=>ti,lFF:()=>w,lVv:()=>b,n3s:()=>S,nyL:()=>mi,oKp:()=>di,q_h:()=>Ee,sc_:()=>xe,tLy:()=>hi,tk0:()=>Yt,w8K:()=>T,xkc:()=>Ie,z2N:()=>li});var s=i(91315),r=i(20635),n=i(67822),o=i(71268),a=i(33244),c=(i(97353),i(1030)),h=(i(13360),i(17367),i(39907)),d=i(48526).hp;const l=":";function u(e){const[t,i]=e.split(l);return{namespace:t,reference:i}}function p(e,t){return e.includes(":")?[e]:t.chains||[]}const f="ReactNative",g={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"};function m(){return typeof h<"u"&&typeof h.versions<"u"&&typeof h.versions.node<"u"}function b(){return!(0,r.getDocument)()&&!!(0,r.getNavigator)()&&navigator.product===f}function y(){return!m()&&!!(0,r.getNavigator)()&&!!(0,r.getDocument)()}function w(){return(0,n.g)()||{name:"",description:"",url:"",icons:[""]}}function v(e,t){return e.filter(e=>t.includes(e)).length===e.length}function I(e=s.FIVE_MINUTES,t){const i=(0,s.toMiliseconds)(e||s.FIVE_MINUTES);let r,n,o,a;return{resolve:e=>{o&&r&&(clearTimeout(o),r(e),a=Promise.resolve(e))},reject:e=>{o&&n&&(clearTimeout(o),n(e))},done:()=>new Promise((e,s)=>{if(a)return e(a);o=setTimeout(()=>{const e=new Error(t);a=Promise.reject(e),s(e)},i),r=e,n=s})}}function E(e){const[t,i]=e.split(":"),s={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof i)s.topic=i;else{if("id"!==t||!Number.isInteger(Number(i)))throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${i}`);s.id=Number(i)}return s}function _(e,t){return(0,s.fromMiliseconds)((t||Date.now())+(0,s.toMiliseconds)(e))}function A(e){return Date.now()>=(0,s.toMiliseconds)(e)}function N(e,t){return`${e}${t?`:${t}`:""}`}function C(e=[],t=[]){return[...new Set([...e,...t])]}async function S({id:e,topic:t,wcDeepLink:s}){var n;try{if(!s)return;const o="string"==typeof s?JSON.parse(s):s,a=o?.href;if("string"!=typeof a)return;const c=function(e,t,i){const s=`requestId=${t}&sessionTopic=${i}`;e.endsWith("/")&&(e=e.slice(0,-1));let r=`${e}`;return r=e.startsWith("https://t.me")?`${r}${e.includes("?")?"&startapp=":"?startapp="}${function(e,t=!1){const i=d.from(e).toString("base64");return t?i.replace(/[=]/g,""):i}(s,!0)}`:`${r}/wc?${s}`,r}(a,e,t),h=b()?g.reactNative:m()?g.node:y()?g.browser:g.unknown;if(h===g.browser){if(null==(n=(0,r.getDocument)())||!n.hasFocus())return void console.warn("Document does not have focus, skipping deeplink.");!function(e){let t="_self";!function(){try{return window.self!==window.top}catch{return!1}}()?(typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)||e.startsWith("https://")||e.startsWith("http://"))&&(t="_blank"):t="_top",window.open(e,t,"noreferrer noopener")}(c)}else h===g.reactNative&&typeof(null==i.g?void 0:i.g.Linking)<"u"&&await i.g.Linking.openURL(c)}catch(e){console.error(e)}}async function P(e,t){let i="";try{if(y()&&(i=localStorage.getItem(t),i))return i;i=await e.getItem(t)}catch(e){console.error(e)}return i}function O(e,t){if(!e.includes(t))return null;const i=e.split(/([&,?,=])/),s=i.indexOf(t);return i[s+2]}function T(){return typeof h<"u"&&"true"===h.env.IS_VITEST}function x(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function k(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function R(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function M(e,t){k(e);const i=t.outputLen;if(e.length<i)throw new Error("digestInto() expects output buffer of length at least "+i)}const U=BigInt(2**32-1),D=BigInt(32);function j(e,t=!1){return t?{h:Number(e&U),l:Number(e>>D&U)}:{h:0|Number(e>>D&U),l:0|Number(e&U)}}const L="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function q(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function $(e,t){return e<<32-t|e>>>t}const B=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function z(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function H(e){for(let t=0;t<e.length;t++)e[t]=z(e[t])}function W(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),k(e),e}class V{clone(){return this._cloneInto()}}function F(e){const t=t=>e().update(W(t)).digest(),i=e();return t.outputLen=i.outputLen,t.blockLen=i.blockLen,t.create=()=>e(),t}const K=[],G=[],J=[],Y=BigInt(0),X=BigInt(1),Q=BigInt(2),Z=BigInt(7),ee=BigInt(256),te=BigInt(113);for(let e=0,t=X,i=1,s=0;e<24;e++){[i,s]=[s,(2*i+3*s)%5],K.push(2*(5*s+i)),G.push((e+1)*(e+2)/2%64);let r=Y;for(let e=0;e<7;e++)t=(t<<X^(t>>Z)*te)%ee,t&Q&&(r^=X<<(X<<BigInt(e))-X);J.push(r)}const[ie,se]=function(e,t=!1){let i=new Uint32Array(e.length),s=new Uint32Array(e.length);for(let r=0;r<e.length;r++){const{h:n,l:o}=j(e[r],t);[i[r],s[r]]=[n,o]}return[i,s]}(J,!0),re=(e,t,i)=>i>32?((e,t,i)=>t<<i-32|e>>>64-i)(e,t,i):((e,t,i)=>e<<i|t>>>32-i)(e,t,i),ne=(e,t,i)=>i>32?((e,t,i)=>e<<i-32|t>>>64-i)(e,t,i):((e,t,i)=>t<<i|e>>>32-i)(e,t,i);class oe extends V{constructor(e,t,i,s=!1,r=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=s,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,x(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var n;this.state=new Uint8Array(200),this.state32=(n=this.state,new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)))}keccak(){B||H(this.state32),function(e,t=24){const i=new Uint32Array(10);for(let s=24-t;s<24;s++){for(let t=0;t<10;t++)i[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const s=(t+8)%10,r=(t+2)%10,n=i[r],o=i[r+1],a=re(n,o,1)^i[s],c=ne(n,o,1)^i[s+1];for(let i=0;i<50;i+=10)e[t+i]^=a,e[t+i+1]^=c}let t=e[2],r=e[3];for(let i=0;i<24;i++){const s=G[i],n=re(t,r,s),o=ne(t,r,s),a=K[i];t=e[a],r=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let s=0;s<10;s++)i[s]=e[t+s];for(let s=0;s<10;s++)e[t+s]^=~i[(s+2)%10]&i[(s+4)%10]}e[0]^=ie[s],e[1]^=se[s]}i.fill(0)}(this.state32,this.rounds),B||H(this.state32),this.posOut=0,this.pos=0}update(e){R(this);const{blockLen:t,state:i}=this,s=(e=W(e)).length;for(let r=0;r<s;){const n=Math.min(t-this.pos,s-r);for(let t=0;t<n;t++)i[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:s}=this;e[i]^=t,!!(128&t)&&i===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){R(this,!1),k(e),this.finish();const t=this.state,{blockLen:i}=this;for(let s=0,r=e.length;s<r;){this.posOut>=i&&this.keccak();const n=Math.min(i-this.posOut,r-s);e.set(t.subarray(this.posOut,this.posOut+n),s),this.posOut+=n,s+=n}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return x(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(M(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:s,rounds:r,enableXOF:n}=this;return e||(e=new oe(t,i,s,n,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=i,e.outputLen=s,e.enableXOF=n,e.destroyed=this.destroyed,e}}const ae=F(()=>new oe(136,1,32)),ce="https://rpc.walletconnect.org/v1";function he(e){const t=`Ethereum Signed Message:\n${e.length}`,i=(new TextEncoder).encode(t+e);return"0x"+d.from(ae(i)).toString("hex")}function de(e){const t=atob(e),i=new Uint8Array(t.length);for(let e=0;e<t.length;e++)i[e]=t.charCodeAt(e);const s=i[0];if(0===s)throw new Error("No signatures found");const r=1+64*s;if(i.length<r)throw new Error("Transaction data too short for claimed signature count");if(i.length<100)throw new Error("Transaction too short");const n=d.from(e,"base64").slice(1,65);return a.A.encode(n)}var le=Object.defineProperty,ue=Object.defineProperties,pe=Object.getOwnPropertyDescriptors,fe=Object.getOwnPropertySymbols,ge=Object.prototype.hasOwnProperty,me=Object.prototype.propertyIsEnumerable,be=(e,t,i)=>t in e?le(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,ye=(e,t)=>{for(var i in t||(t={}))ge.call(t,i)&&be(e,i,t[i]);if(fe)for(var i of fe(t))me.call(t,i)&&be(e,i,t[i]);return e},we=(e,t)=>ue(e,pe(t));const ve=e=>e?.split(":"),Ie=e=>{const t=e&&ve(e);if(t)return t[2]+":"+t[3]},Ee=e=>{const t=e&&ve(e);if(t)return t.pop()};async function _e(e){const{cacao:t,projectId:i}=e,{s,p:r}=t,n=Ae(r,r.iss),a=Ee(r.iss);return await async function(e,t,i,s,r,n){switch(i.t){case"eip191":return await async function(e,t,i){return(await(0,o.x)({hash:he(t),signature:i})).toLowerCase()===e.toLowerCase()}(e,t,i.s);case"eip1271":return await async function(e,t,i,s,r,n){const o=u(s);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${s}`);try{const o="0x1626ba7e",a="0000000000000000000000000000000000000000000000000000000000000040",c="0000000000000000000000000000000000000000000000000000000000000041",h=i.substring(2),d=o+he(t).substring(2)+a+c+h,l=await fetch(`${n||ce}/?chainId=${s}&projectId=${r}`,{method:"POST",body:JSON.stringify({id:Date.now()+Math.floor(1e3*Math.random()),jsonrpc:"2.0",method:"eth_call",params:[{to:e,data:d},"latest"]})}),{result:u}=await l.json();return!!u&&u.slice(0,o.length).toLowerCase()===o.toLowerCase()}catch(e){return console.error("isValidEip1271Signature: ",e),!1}}(e,t,i.s,s,r,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${i.t}`)}}(a,n,s,Ie(r.iss),i)}const Ae=(e,t)=>{const i=`${e.domain} wants you to sign in with your Ethereum account:`,s=Ee(t);if(!e.aud&&!e.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let r=e.statement||void 0;const n=`URI: ${e.aud||e.uri}`,o=`Version: ${e.version}`,a=`Chain ID: ${(e=>{const t=e&&ve(e);if(t)return e.includes("did:pkh:")?t[3]:t[1]})(t)}`,c=`Nonce: ${e.nonce}`,h=`Issued At: ${e.iat}`,d=e.exp?`Expiration Time: ${e.exp}`:void 0,l=e.nbf?`Not Before: ${e.nbf}`:void 0,u=e.requestId?`Request ID: ${e.requestId}`:void 0,p=e.resources?`Resources:${e.resources.map(e=>`\n- ${e}`).join("")}`:void 0,f=Re(e.resources);return f&&(r=function(e="",t){Ne(t);const i="I further authorize the stated URI to perform the following actions on my behalf: ";if(e.includes(i))return e;const s=[];let r=0;return Object.keys(t.att).forEach(e=>{const i=Object.keys(t.att[e]).map(e=>({ability:e.split("/")[0],action:e.split("/")[1]}));i.sort((e,t)=>e.action.localeCompare(t.action));const n={};i.forEach(e=>{n[e.ability]||(n[e.ability]=[]),n[e.ability].push(e.action)});const o=Object.keys(n).map(t=>(r++,`(${r}) '${t}': '${n[t].join("', '")}' for '${e}'.`));s.push(o.join(", ").replace(".,","."))}),`${e?e+" ":""}${i}${s.join(" ")}`}(r,Pe(f))),[i,s,"",r,"",n,o,a,c,h,d,l,u,p].filter(e=>null!=e).join("\n")};function Ne(e){if(!e)throw new Error("No recap provided, value is undefined");if(!e.att)throw new Error("No `att` property found");const t=Object.keys(e.att);if(null==t||!t.length)throw new Error("No resources found in `att` property");t.forEach(t=>{const i=e.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if("object"!=typeof i)throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(e=>{const t=i[e];if(!Array.isArray(t))throw new Error(`Ability limits ${e} must be an array of objects, found: ${t}`);if(!t.length)throw new Error(`Value of ${e} is empty array, must be an array with objects`);t.forEach(t=>{if("object"!=typeof t)throw new Error(`Ability limits (${e}) must be an array of objects, found: ${t}`)})})})}function Ce(e,t,i={}){t=t?.sort((e,t)=>e.localeCompare(t));const s=t.map(t=>({[`${e}/${t}`]:[i]}));return Object.assign({},...s)}function Se(e){return Ne(e),`urn:recap:${function(e){return d.from(JSON.stringify(e)).toString("base64")}(e).replace(/=/g,"")}`}function Pe(e){const t=function(e){return JSON.parse(d.from(e,"base64").toString("utf-8"))}(e.replace("urn:recap:",""));return Ne(t),t}function Oe(e,t,i){const s=function(e,t,i,s={}){return i?.sort((e,t)=>e.localeCompare(t)),{att:{[e]:Ce(t,i,s)}}}(e,t,i);return Se(s)}function Te(e,t){const i=function(e,t){Ne(e),Ne(t);const i=Object.keys(e.att).concat(Object.keys(t.att)).sort((e,t)=>e.localeCompare(t)),s={att:{}};return i.forEach(i=>{var r,n;Object.keys((null==(r=e.att)?void 0:r[i])||{}).concat(Object.keys((null==(n=t.att)?void 0:n[i])||{})).sort((e,t)=>e.localeCompare(t)).forEach(r=>{var n,o;s.att[i]=we(ye({},s.att[i]),{[r]:(null==(n=e.att[i])?void 0:n[r])||(null==(o=t.att[i])?void 0:o[r])})})}),s}(Pe(e),Pe(t));return Se(i)}function xe(e){var t;const i=Pe(e);Ne(i);const s=null==(t=i.att)?void 0:t.eip155;return s?Object.keys(s).map(e=>e.split("/")[1]):[]}function ke(e){const t=Pe(e);Ne(t);const i=[];return Object.values(t.att).forEach(e=>{Object.values(e).forEach(e=>{var t;null!=(t=e?.[0])&&t.chains&&i.push(e[0].chains)})}),[...new Set(i.flat())]}function Re(e){if(!e)return;const t=e?.[e.length-1];return function(e){return e&&e.includes("urn:recap:")}(t)?t:void 0}function Me(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ue(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function De(e,...t){if(!Ue(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function je(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Le(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}const qe=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function $e(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!Ue(e))throw new Error("Uint8Array expected, got "+typeof e);e=He(e)}return e}function Be(e,t,i=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(i&&!function(e){return e.byteOffset%4==0}(t))throw new Error("invalid output, must be aligned");return t}function ze(e,t,i,s){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,i,s);const r=BigInt(32),n=BigInt(4294967295),o=Number(i>>r&n),a=Number(i&n),c=s?4:0,h=s?0:4;e.setUint32(t+c,o,s),e.setUint32(t+h,a,s)}function He(e){return Uint8Array.from(e)}function We(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const Ve=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),Fe=Ve("expand 16-byte k"),Ke=Ve("expand 32-byte k"),Ge=qe(Fe),Je=qe(Ke);function Ye(e,t){return e<<t|e>>>32-t}function Xe(e){return e.byteOffset%4==0}const Qe=2**32-1,Ze=new Uint32Array,et=(e,t)=>255&e[t++]|(255&e[t++])<<8;class tt{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,De(e=$e(e),32);const t=et(e,0),i=et(e,2),s=et(e,4),r=et(e,6),n=et(e,8),o=et(e,10),a=et(e,12),c=et(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|i<<3),this.r[2]=7939&(i>>>10|s<<6),this.r[3]=8191&(s>>>7|r<<9),this.r[4]=255&(r>>>4|n<<12),this.r[5]=n>>>1&8190,this.r[6]=8191&(n>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=et(e,16+2*t)}process(e,t,i=!1){const s=i?0:2048,{h:r,r:n}=this,o=n[0],a=n[1],c=n[2],h=n[3],d=n[4],l=n[5],u=n[6],p=n[7],f=n[8],g=n[9],m=et(e,t+0),b=et(e,t+2),y=et(e,t+4),w=et(e,t+6),v=et(e,t+8),I=et(e,t+10),E=et(e,t+12),_=et(e,t+14);let A=r[0]+(8191&m),N=r[1]+(8191&(m>>>13|b<<3)),C=r[2]+(8191&(b>>>10|y<<6)),S=r[3]+(8191&(y>>>7|w<<9)),P=r[4]+(8191&(w>>>4|v<<12)),O=r[5]+(v>>>1&8191),T=r[6]+(8191&(v>>>14|I<<2)),x=r[7]+(8191&(I>>>11|E<<5)),k=r[8]+(8191&(E>>>8|_<<8)),R=r[9]+(_>>>5|s),M=0,U=M+A*o+N*(5*g)+C*(5*f)+S*(5*p)+P*(5*u);M=U>>>13,U&=8191,U+=O*(5*l)+T*(5*d)+x*(5*h)+k*(5*c)+R*(5*a),M+=U>>>13,U&=8191;let D=M+A*a+N*o+C*(5*g)+S*(5*f)+P*(5*p);M=D>>>13,D&=8191,D+=O*(5*u)+T*(5*l)+x*(5*d)+k*(5*h)+R*(5*c),M+=D>>>13,D&=8191;let j=M+A*c+N*a+C*o+S*(5*g)+P*(5*f);M=j>>>13,j&=8191,j+=O*(5*p)+T*(5*u)+x*(5*l)+k*(5*d)+R*(5*h),M+=j>>>13,j&=8191;let L=M+A*h+N*c+C*a+S*o+P*(5*g);M=L>>>13,L&=8191,L+=O*(5*f)+T*(5*p)+x*(5*u)+k*(5*l)+R*(5*d),M+=L>>>13,L&=8191;let q=M+A*d+N*h+C*c+S*a+P*o;M=q>>>13,q&=8191,q+=O*(5*g)+T*(5*f)+x*(5*p)+k*(5*u)+R*(5*l),M+=q>>>13,q&=8191;let $=M+A*l+N*d+C*h+S*c+P*a;M=$>>>13,$&=8191,$+=O*o+T*(5*g)+x*(5*f)+k*(5*p)+R*(5*u),M+=$>>>13,$&=8191;let B=M+A*u+N*l+C*d+S*h+P*c;M=B>>>13,B&=8191,B+=O*a+T*o+x*(5*g)+k*(5*f)+R*(5*p),M+=B>>>13,B&=8191;let z=M+A*p+N*u+C*l+S*d+P*h;M=z>>>13,z&=8191,z+=O*c+T*a+x*o+k*(5*g)+R*(5*f),M+=z>>>13,z&=8191;let H=M+A*f+N*p+C*u+S*l+P*d;M=H>>>13,H&=8191,H+=O*h+T*c+x*a+k*o+R*(5*g),M+=H>>>13,H&=8191;let W=M+A*g+N*f+C*p+S*u+P*l;M=W>>>13,W&=8191,W+=O*d+T*h+x*c+k*a+R*o,M+=W>>>13,W&=8191,M=(M<<2)+M|0,M=M+U|0,U=8191&M,M>>>=13,D+=M,r[0]=U,r[1]=D,r[2]=j,r[3]=L,r[4]=q,r[5]=$,r[6]=B,r[7]=z,r[8]=H,r[9]=W}finalize(){const{h:e,pad:t}=this,i=new Uint16Array(10);let s=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=s,s=e[t]>>>13,e[t]&=8191;e[0]+=5*s,s=e[0]>>>13,e[0]&=8191,e[1]+=s,s=e[1]>>>13,e[1]&=8191,e[2]+=s,i[0]=e[0]+5,s=i[0]>>>13,i[0]&=8191;for(let t=1;t<10;t++)i[t]=e[t]+s,s=i[t]>>>13,i[t]&=8191;i[9]-=8192;let r=(1^s)-1;for(let e=0;e<10;e++)i[e]&=r;r=~r;for(let t=0;t<10;t++)e[t]=e[t]&r|i[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let n=e[0]+t[0];e[0]=65535&n;for(let i=1;i<8;i++)n=(e[i]+t[i]|0)+(n>>>16)|0,e[i]=65535&n;We(i)}update(e){je(this);const{buffer:t,blockLen:i}=this,s=(e=$e(e)).length;for(let r=0;r<s;){const n=Math.min(i-this.pos,s-r);if(n!==i)t.set(e.subarray(r,r+n),this.pos),this.pos+=n,r+=n,this.pos===i&&(this.process(t,0,!1),this.pos=0);else for(;i<=s-r;r+=i)this.process(e,r)}return this}destroy(){We(this.h,this.r,this.buffer,this.pad)}digestInto(e){je(this),function(e,t){De(e);const i=t.outputLen;if(e.length<i)throw new Error("digestInto() expects output buffer of length at least "+i)}(e,this),this.finished=!0;const{buffer:t,h:i}=this;let{pos:s}=this;if(s){for(t[s++]=1;s<16;s++)t[s]=0;this.process(t,0,!0)}this.finalize();let r=0;for(let t=0;t<8;t++)e[r++]=i[t]>>>0,e[r++]=i[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}}const it=function(e){const t=(t,i)=>e(i).update($e(t)).digest(),i=e(new Uint8Array(32));return t.outputLen=i.outputLen,t.blockLen=i.blockLen,t.create=t=>e(t),t}(e=>new tt(e)),st=function(e){const{allowShortKeys:t,extendNonceFn:i,counterLength:s,counterRight:r,rounds:n}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t)}(0,{counterRight:!1,counterLength:4,allowShortKeys:!1});return Me(s),Me(n),Le(r),Le(t),(o,a,c,h,d=0)=>{De(o),De(a),De(c);const l=c.length;if(void 0===h&&(h=new Uint8Array(l)),De(h),Me(d),d<0||d>=Qe)throw new Error("arx: counter overflow");if(h.length<l)throw new Error(`arx: output (${h.length}) is shorter than data (${l})`);const u=[];let p,f,g=o.length;if(32===g)u.push(p=He(o)),f=Je;else{if(16!==g||!t)throw new Error(`arx: invalid 32-byte key, got length=${g}`);p=new Uint8Array(32),p.set(o),p.set(o,16),f=Ge,u.push(p)}Xe(a)||u.push(a=He(a));const m=qe(p);if(i){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");i(f,m,qe(a.subarray(0,16)),m),a=a.subarray(16)}const b=16-s;if(b!==a.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(12!==b){const e=new Uint8Array(12);e.set(a,r?0:12-a.length),a=e,u.push(a)}const y=qe(a);return function(e,t,i,s,r,n,o,a){const c=r.length,h=new Uint8Array(64),d=qe(h),l=Xe(r)&&Xe(n),u=l?qe(r):Ze,p=l?qe(n):Ze;for(let f=0;f<c;o++){if(e(t,i,s,d,o,a),o>=Qe)throw new Error("arx: counter overflow");const g=Math.min(64,c-f);if(l&&64===g){const e=f/4;if(f%4!=0)throw new Error("arx: invalid block position");for(let t,i=0;i<16;i++)t=e+i,p[t]=u[t]^d[i];f+=64;continue}for(let e,t=0;t<g;t++)e=f+t,n[e]=r[e]^h[t];f+=g}}(e,f,m,y,c,h,d,n),We(...u),h}}(function(e,t,i,s,r,n=20){let o=e[0],a=e[1],c=e[2],h=e[3],d=t[0],l=t[1],u=t[2],p=t[3],f=t[4],g=t[5],m=t[6],b=t[7],y=r,w=i[0],v=i[1],I=i[2],E=o,_=a,A=c,N=h,C=d,S=l,P=u,O=p,T=f,x=g,k=m,R=b,M=y,U=w,D=v,j=I;for(let e=0;e<n;e+=2)E=E+C|0,M=Ye(M^E,16),T=T+M|0,C=Ye(C^T,12),E=E+C|0,M=Ye(M^E,8),T=T+M|0,C=Ye(C^T,7),_=_+S|0,U=Ye(U^_,16),x=x+U|0,S=Ye(S^x,12),_=_+S|0,U=Ye(U^_,8),x=x+U|0,S=Ye(S^x,7),A=A+P|0,D=Ye(D^A,16),k=k+D|0,P=Ye(P^k,12),A=A+P|0,D=Ye(D^A,8),k=k+D|0,P=Ye(P^k,7),N=N+O|0,j=Ye(j^N,16),R=R+j|0,O=Ye(O^R,12),N=N+O|0,j=Ye(j^N,8),R=R+j|0,O=Ye(O^R,7),E=E+S|0,j=Ye(j^E,16),k=k+j|0,S=Ye(S^k,12),E=E+S|0,j=Ye(j^E,8),k=k+j|0,S=Ye(S^k,7),_=_+P|0,M=Ye(M^_,16),R=R+M|0,P=Ye(P^R,12),_=_+P|0,M=Ye(M^_,8),R=R+M|0,P=Ye(P^R,7),A=A+O|0,U=Ye(U^A,16),T=T+U|0,O=Ye(O^T,12),A=A+O|0,U=Ye(U^A,8),T=T+U|0,O=Ye(O^T,7),N=N+C|0,D=Ye(D^N,16),x=x+D|0,C=Ye(C^x,12),N=N+C|0,D=Ye(D^N,8),x=x+D|0,C=Ye(C^x,7);let L=0;s[L++]=o+E|0,s[L++]=a+_|0,s[L++]=c+A|0,s[L++]=h+N|0,s[L++]=d+C|0,s[L++]=l+S|0,s[L++]=u+P|0,s[L++]=p+O|0,s[L++]=f+T|0,s[L++]=g+x|0,s[L++]=m+k|0,s[L++]=b+R|0,s[L++]=y+M|0,s[L++]=w+U|0,s[L++]=v+D|0,s[L++]=I+j|0}),rt=new Uint8Array(16),nt=(e,t)=>{e.update(t);const i=t.length%16;i&&e.update(rt.subarray(i))},ot=new Uint8Array(32);function at(e,t,i,s,r){const n=e(t,i,ot),o=it.create(n);r&&nt(o,r),nt(o,s);const a=new Uint8Array(16),c=(e=>new DataView(e.buffer,e.byteOffset,e.byteLength))(a);ze(c,0,BigInt(r?r.length:0),!0),ze(c,8,BigInt(s.length),!0),o.update(a);const h=o.digest();return We(n,a),h}((e,t)=>{Object.assign(function(i,...s){if(De(i),void 0!==e.nonceLength){const t=s[0];if(!t)throw new Error("nonce / iv required");e.varSizeNonce?De(t):De(t,e.nonceLength)}const r=e.tagLength;r&&void 0!==s[1]&&De(s[1]);const n=t(i,...s),o=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");De(t)}};let a=!1;return{encrypt(e,t){if(a)throw new Error("cannot encrypt() twice with same key + nonce");return a=!0,De(e),o(n.encrypt.length,t),n.encrypt(e,t)},decrypt(e,t){if(De(e),r&&e.length<r)throw new Error("invalid ciphertext length: smaller than tagLength="+r);return o(n.decrypt.length,t),n.decrypt(e,t)}}},e)})({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,i,s)=>({encrypt(r,n){const o=r.length;(n=Be(o+16,n,!1)).set(r);const a=n.subarray(0,-16);e(t,i,a,a,1);const c=at(e,t,i,a,s);return n.set(c,o),We(c),n},decrypt(r,n){n=Be(r.length-16,n,!1);const o=r.subarray(0,-16),a=r.subarray(-16),c=at(e,t,i,o,s);if(!function(e,t){if(e.length!==t.length)return!1;let i=0;for(let s=0;s<e.length;s++)i|=e[s]^t[s];return 0===i}(a,c))throw new Error("invalid tag");return n.set(r.subarray(0,-16)),e(t,i,n,n,1),We(c),n}}))(st));function ct(e,t,i){return e&t^~e&i}function ht(e,t,i){return e&t^e&i^t&i}new Uint8Array([0]),new Uint8Array;class dt extends V{constructor(e,t,i,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=q(this.buffer)}update(e){R(this);const{view:t,buffer:i,blockLen:s}=this,r=(e=W(e)).length;for(let n=0;n<r;){const o=Math.min(s-this.pos,r-n);if(o===s){const t=q(e);for(;s<=r-n;n+=s)this.process(t,n);continue}i.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){R(this),M(e,this),this.finished=!0;const{buffer:t,view:i,blockLen:s,isLE:r}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>s-n&&(this.process(i,0),n=0);for(let e=n;e<s;e++)t[e]=0;(function(e,t,i,s){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,i,s);const r=BigInt(32),n=BigInt(4294967295),o=Number(i>>r&n),a=Number(i&n),c=s?4:0,h=s?0:4;e.setUint32(t+c,o,s),e.setUint32(t+h,a,s)})(i,s-8,BigInt(8*this.length),r),this.process(i,0);const o=q(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,h[e],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:i,length:s,finished:r,destroyed:n,pos:o}=this;return e.length=s,e.pos=o,e.finished=r,e.destroyed=n,s%t&&e.buffer.set(i),e}}const lt=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),ut=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),pt=new Uint32Array(64);class ft extends dt{constructor(){super(64,32,8,!1),this.A=0|ut[0],this.B=0|ut[1],this.C=0|ut[2],this.D=0|ut[3],this.E=0|ut[4],this.F=0|ut[5],this.G=0|ut[6],this.H=0|ut[7]}get(){const{A:e,B:t,C:i,D:s,E:r,F:n,G:o,H:a}=this;return[e,t,i,s,r,n,o,a]}set(e,t,i,s,r,n,o,a){this.A=0|e,this.B=0|t,this.C=0|i,this.D=0|s,this.E=0|r,this.F=0|n,this.G=0|o,this.H=0|a}process(e,t){for(let i=0;i<16;i++,t+=4)pt[i]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=pt[e-15],i=pt[e-2],s=$(t,7)^$(t,18)^t>>>3,r=$(i,17)^$(i,19)^i>>>10;pt[e]=r+pt[e-7]+s+pt[e-16]|0}let{A:i,B:s,C:r,D:n,E:o,F:a,G:c,H:h}=this;for(let e=0;e<64;e++){const t=h+($(o,6)^$(o,11)^$(o,25))+ct(o,a,c)+lt[e]+pt[e]|0,d=($(i,2)^$(i,13)^$(i,22))+ht(i,s,r)|0;h=c,c=a,a=o,o=n+t|0,n=r,r=s,s=i,i=t+d|0}i=i+this.A|0,s=s+this.B|0,r=r+this.C|0,n=n+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(i,s,r,n,o,a,c,h)}roundClean(){pt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const gt=F(()=>new ft);BigInt(0);function mt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function bt(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function yt(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,i=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const s=new Uint8Array(i);for(let t=0,r=0;t<i;t++,r+=2){const i=bt(e.charCodeAt(r)),n=bt(e.charCodeAt(r+1));if(void 0===i||void 0===n){const t=e[r]+e[r+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+r)}s[t]=16*i+n}return s}const wt={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||mt(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)},vt=BigInt(0);BigInt(1);function It(e,t){const i=e%t;return i>=vt?i:t+i}function Et(e,t,i){let s=e;for(;t-- >vt;)s*=s,s%=i;return s}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);BigInt(0),BigInt(1);const _t=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const At=BigInt(1),Nt=BigInt(2),Ct=BigInt(3),St=BigInt(5);BigInt(8),function(e){const t=function(e){return function(e,t,i={}){const s=(t,i,s)=>{const r=wt[i];if("function"!=typeof r)throw new Error("invalid validator function");const n=e[t];if(!(s&&void 0===n||r(n,e)))throw new Error("param "+String(t)+" is invalid. Expected "+i+", got "+n)};for(const[e,i]of Object.entries(t))s(e,i,!1);for(const[e,t]of Object.entries(i))s(e,t,!0)}(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:i}=t,s=e=>It(e,i),r=t.montgomeryBits,n=Math.ceil(r/8);t.nByteLength,t.adjustScalarBytes,t.powPminus2;t.a,BigInt(2),BigInt(4);function o(e){return function(e,t){return function(e,t){return yt(e.toString(16).padStart(2*t,"0"))}(e,t).reverse()}(s(e),n)}o(t.Gu)}({P:_t,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=_t,{pow_p_5_8:i,b2:s}=function(e){const t=BigInt(10),i=BigInt(20),s=BigInt(40),r=BigInt(80),n=_t,o=e*e%n*e%n,a=Et(o,Nt,n)*o%n,c=Et(a,At,n)*e%n,h=Et(c,St,n)*c%n,d=Et(h,t,n)*h%n,l=Et(d,i,n)*d%n,u=Et(l,s,n)*l%n,p=Et(u,r,n)*u%n,f=Et(p,r,n)*u%n,g=Et(f,t,n)*h%n;return{pow_p_5_8:Et(g,Nt,n)*e%n,b2:o}}(e);return It(Et(i,Ct,t)*s,t)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},randomBytes:function(e=32){if(L&&"function"==typeof L.getRandomValues)return L.getRandomValues(new Uint8Array(e));if(L&&"function"==typeof L.randomBytes)return L.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}});const Pt="base16",Ot="base64pad",Tt="base64url",xt="utf8",kt=1,Rt=2;function Mt(e){const t=gt((0,c.sH)(e,Pt));return(0,c.dI)(t,Pt)}function Ut(e){const t=gt((0,c.sH)(e,xt));return(0,c.dI)(t,Pt)}function Dt(e,t,i){return`${e}?wc_ev=${i}&topic=${t}`}function jt(e){const t=[];return e.forEach(e=>{const[i,s]=e.split(":");t.push(`${i}:${s}`)}),t}function Lt(e,t){const i=function(e){const t={};return e?.forEach(e=>{var i;const[s,r]=e.split(":");t[s]||(t[s]={accounts:[],chains:[],events:[],methods:[]}),t[s].accounts.push(e),null==(i=t[s].chains)||i.push(`${s}:${r}`)}),t}(t=t.map(e=>e.replace("did:pkh:","")));for(const[t,s]of Object.entries(i))s.methods?s.methods=C(s.methods,e):s.methods=e,s.events=["chainChanged","accountsChanged"];return i}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const qt={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},$t={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function Bt(e,t){const{message:i,code:s}=$t[e];return{message:t?`${i} ${t}`:i,code:s}}function zt(e,t){const{message:i,code:s}=qt[e];return{message:t?`${i} ${t}`:i,code:s}}function Ht(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function Wt(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function Vt(e){return typeof e>"u"}function Ft(e,t){return!(!t||!Vt(e))||"string"==typeof e&&!!e.trim().length}function Kt(e,t){return!(!t||!Vt(e))||"number"==typeof e&&!isNaN(e)}function Gt(e,t){const{requiredNamespaces:i}=t,s=Object.keys(e.namespaces),r=Object.keys(i);let n=!0;return!!v(r,s)&&(s.forEach(t=>{const{accounts:s,methods:r,events:o}=e.namespaces[t],a=jt(s),c=i[t];v(p(t,c),a)&&v(c.methods,r)&&v(c.events,o)||(n=!1)}),n)}function Jt(e){return!(!Ft(e,!1)||!e.includes(":"))&&2===e.split(":").length}function Yt(e,t){let i=null;return Ft(e?.publicKey,!1)||(i=Bt("MISSING_OR_INVALID",`${t} controller public key should be a string`)),i}function Xt(e){let t=!0;return Ht(e)?e.length&&(t=e.every(e=>Ft(e,!1))):t=!1,t}function Qt(e,t){let i=null;return Object.values(e).forEach(e=>{if(i)return;const s=function(e,t){let i=null;return Xt(e?.methods)?Xt(e?.events)||(i=zt("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):i=zt("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),i}(e,`${t}, namespace`);s&&(i=s)}),i}function Zt(e,t,i){let s=null;if(e&&Wt(e)){const r=Qt(e,t);r&&(s=r);const n=function(e,t,i){let s=null;return Object.entries(e).forEach(([e,r])=>{if(s)return;const n=function(e,t,i){let s=null;return Ht(t)&&t.length?t.forEach(e=>{s||Jt(e)||(s=zt("UNSUPPORTED_CHAINS",`${i}, chain ${e} should be a string and conform to "namespace:chainId" format`))}):Jt(e)||(s=zt("UNSUPPORTED_CHAINS",`${i}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),s}(e,p(e,r),`${t} ${i}`);n&&(s=n)}),s}(e,t,i);n&&(s=n)}else s=Bt("MISSING_OR_INVALID",`${t}, ${i} should be an object with data`);return s}function ei(e,t){let i=null;if(e&&Wt(e)){const s=Qt(e,t);s&&(i=s);const r=function(e,t){let i=null;return Object.values(e).forEach(e=>{if(i)return;const s=function(e,t){let i=null;return Ht(e)?e.forEach(e=>{i||function(e){if(Ft(e,!1)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&Jt(e)}}return!1}(e)||(i=zt("UNSUPPORTED_ACCOUNTS",`${t}, account ${e} should be a string and conform to "namespace:chainId:address" format`))}):i=zt("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),i}(e?.accounts,`${t} namespace`);s&&(i=s)}),i}(e,t);r&&(i=r)}else i=Bt("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return i}function ti(e){return Ft(e.protocol,!0)}function ii(e,t){let i=!1;return t&&!e?i=!0:e&&Ht(e)&&e.length&&e.forEach(e=>{i=ti(e)}),i}function si(e){return"number"==typeof e}function ri(e){return typeof e<"u"&&null!==typeof e}function ni(e){return!!(e&&"object"==typeof e&&e.code&&Kt(e.code,!1)&&e.message&&Ft(e.message,!1))}function oi(e){return!(Vt(e)||!Ft(e.method,!1))}function ai(e){return!(Vt(e)||Vt(e.result)&&Vt(e.error)||!Kt(e.id,!1)||!Ft(e.jsonrpc,!1))}function ci(e){return!(Vt(e)||!Ft(e.name,!1))}function hi(e,t){return!(!Jt(t)||!function(e){const t=[];return Object.values(e).forEach(e=>{t.push(...jt(e.accounts))}),t}(e).includes(t))}function di(e,t,i){return!!Ft(i,!1)&&function(e,t){const i=[];return Object.values(e).forEach(e=>{jt(e.accounts).includes(t)&&i.push(...e.methods)}),i}(e,t).includes(i)}function li(e,t,i){return!!Ft(i,!1)&&function(e,t){const i=[];return Object.values(e).forEach(e=>{jt(e.accounts).includes(t)&&i.push(...e.events)}),i}(e,t).includes(i)}function ui(e,t,i){let s=null;const r=function(e){const t={};return Object.keys(e).forEach(i=>{var s;i.includes(":")?t[i]=e[i]:null==(s=e[i].chains)||s.forEach(s=>{t[s]={methods:e[i].methods,events:e[i].events}})}),t}(e),n=function(e){const t={};return Object.keys(e).forEach(i=>{if(i.includes(":"))t[i]=e[i];else{const s=jt(e[i].accounts);s?.forEach(s=>{t[s]={accounts:e[i].accounts.filter(e=>e.includes(`${s}:`)),methods:e[i].methods,events:e[i].events}})}}),t}(t),o=Object.keys(r),a=Object.keys(n),c=pi(Object.keys(e)),h=pi(Object.keys(t)),d=c.filter(e=>!h.includes(e));return d.length&&(s=Bt("NON_CONFORMING_NAMESPACES",`${i} namespaces keys don't satisfy requiredNamespaces.\n Required: ${d.toString()}\n Received: ${Object.keys(t).toString()}`)),v(o,a)||(s=Bt("NON_CONFORMING_NAMESPACES",`${i} namespaces chains don't satisfy required namespaces.\n Required: ${o.toString()}\n Approved: ${a.toString()}`)),Object.keys(t).forEach(e=>{if(!e.includes(":")||s)return;const r=jt(t[e].accounts);r.includes(e)||(s=Bt("NON_CONFORMING_NAMESPACES",`${i} namespaces accounts don't satisfy namespace accounts for ${e}\n Required: ${e}\n Approved: ${r.toString()}`))}),o.forEach(e=>{s||(v(r[e].methods,n[e].methods)?v(r[e].events,n[e].events)||(s=Bt("NON_CONFORMING_NAMESPACES",`${i} namespaces events don't satisfy namespace events for ${e}`)):s=Bt("NON_CONFORMING_NAMESPACES",`${i} namespaces methods don't satisfy namespace methods for ${e}`))}),s}function pi(e){return[...new Set(e.map(e=>e.includes(":")?e.split(":")[0]:e))]}function fi(e,t){return Kt(e,!1)&&e<=t.max&&e>=t.min}const gi={};class mi{static get(e){return gi[e]}static set(e,t){gi[e]=t}static delete(e){delete gi[e]}}},44637:(e,t,i)=>{i.d(t,{W:()=>m});var s=i(89168),r=i(39150),n=i(5813),o=i(16279),a=i(40868),c=i(99013),h=i(89058),d=i(50731),l=i(14479),u=i(16158),p=i(25422),f=i(42831);const g=(0,s.BX)({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),m={state:g,subscribe:e=>(0,s.B1)(g,()=>e(g)),subscribeKey:(e,t)=>(0,r.u$)(g,e,t),async open(e){const t="connected"===o.U.state.status;h.x.state.wcBasic?a.N.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1}):await a.N.prefetch({fetchConnectorImages:!t,fetchFeaturedWallets:!t,fetchRecommendedWallets:!t}),e?.namespace?(await c.W.switchActiveNamespace(e.namespace),m.setLoading(!0,e.namespace)):m.setLoading(!0),d.a.setFilterByNamespace(e?.namespace);const i=c.W.getAccountData(e?.namespace)?.caipAddress;c.W.state.noAdapters&&!i?n.w.isMobile()?f.I.reset("AllWallets"):f.I.reset("ConnectingWalletConnectBasic"):e?.view?f.I.reset(e.view):i?f.I.reset("Account"):f.I.reset("Connect"),g.open=!0,p.z.set({open:!0}),l.E.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:Boolean(i)}})},close(){const e=u.H.state.enableEmbedded,t=Boolean(c.W.state.activeCaipAddress);g.open&&l.E.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:t}}),g.open=!1,m.clearLoading(),e?t?f.I.replace("Account"):f.I.push("Connect"):p.z.set({open:!1}),h.x.resetUri()},setLoading(e,t){t&&g.loadingNamespaceMap.set(t,e),g.loading=e,p.z.set({loading:e})},clearLoading(){g.loadingNamespaceMap.clear(),g.loading=!1},shake(){g.shake||(g.shake=!0,setTimeout(()=>{g.shake=!1},500))}}},46779:(e,t,i)=>{i.d(t,{n:()=>p});var s=i(33244),r=i(38903),n=i(95191),o=i(16279),a=i(99013),c=i(84253),h=i(5813),d=i(33816),l=i(76663),u=i(24529);class p extends d.X{setUniversalProvider(e){this.addConnector(new l.F({provider:e,caipNetworks:this.caipNetworks||[],namespace:this.namespace}))}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{const e=this.getWalletConnectConnector();await e.disconnect()}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}}async getAccounts({namespace:e}){const t=this.provider,i=t?.session?.namespaces?.[e]?.accounts?.map(e=>{const[,,t]=e.split(":");return t}).filter((e,t,i)=>i.indexOf(e)===t)||[];return Promise.resolve({accounts:i.map(t=>h.w.createAccount(e,t,"bip122"===e?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){if(!e.caipNetwork||!c.oU.BALANCE_SUPPORTED_CHAINS.includes(e.caipNetwork?.chainNamespace)||e.caipNetwork?.testnet)return{balance:"0.00",symbol:e.caipNetwork?.nativeCurrency.symbol||""};if(o.U.state.balanceLoading&&e.chainId===a.W.state.activeCaipNetwork?.id)return{balance:o.U.state.balance||"0.00",symbol:o.U.state.balanceSymbol||""};const t=(await o.U.fetchTokenBalance()).find(t=>t.chainId===`${e.caipNetwork?.chainNamespace}:${e.chainId}`&&t.symbol===e.caipNetwork?.nativeCurrency.symbol);return{balance:t?.quantity.numeric||"0.00",symbol:t?.symbol||e.caipNetwork?.nativeCurrency.symbol||""}}async signMessage(e){const{provider:t,message:i,address:r}=e;if(!t)throw new Error("UniversalAdapter:signMessage - provider is undefined");let o="";return o=a.W.state.activeCaipNetwork?.chainNamespace===n.o.CHAIN.SOLANA?(await t.request({method:"solana_signMessage",params:{message:s.A.encode((new TextEncoder).encode(i)),pubkey:r}},a.W.state.activeCaipNetwork?.caipNetworkId)).signature:await t.request({method:"personal_sign",params:[i,r]},a.W.state.activeCaipNetwork?.caipNetworkId),{signature:o}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async getProfile(){return Promise.resolve({profileImage:"",profileName:""})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}async getEnsAddress(){return Promise.resolve({address:!1})}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){const{caipNetwork:t}=e,i=this.getWalletConnectConnector();if(t.chainNamespace===n.o.CHAIN.EVM)try{await(i.provider?.request({method:"wallet_switchEthereumChain",params:[{chainId:(0,r.nj)(t.id)}]}))}catch(e){if(e.code===u.E.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||e.code===u.E.ERROR_INVALID_CHAIN_ID||e.code===u.E.ERROR_CODE_DEFAULT||e?.data?.originalError?.code===u.E.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await(i.provider?.request({method:"wallet_addEthereumChain",params:[{chainId:(0,r.nj)(t.id),rpcUrls:[t?.rpcUrls.chainDefault?.http],chainName:t.name,nativeCurrency:t.nativeCurrency,blockExplorerUrls:[t.blockExplorers?.default.url]}]}))}catch(e){throw new Error("Chain is not supported")}}i.provider.setDefaultChain(t.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(e=>"WALLET_CONNECT"===e.type),t=e?.provider;return t}}},47048:(e,t,i)=>{var s;function r(e){this.rand=e}if(e.exports=function(e){return s||(s=new r(null)),s.generate(e)},e.exports.Rand=r,r.prototype.generate=function(e){return this._rand(e)},r.prototype._rand=function(e){if(this.rand.getBytes)return this.rand.getBytes(e);for(var t=new Uint8Array(e),i=0;i<t.length;i++)t[i]=this.rand.getByte();return t},"object"==typeof self)self.crypto&&self.crypto.getRandomValues?r.prototype._rand=function(e){var t=new Uint8Array(e);return self.crypto.getRandomValues(t),t}:self.msCrypto&&self.msCrypto.getRandomValues?r.prototype._rand=function(e){var t=new Uint8Array(e);return self.msCrypto.getRandomValues(t),t}:"object"==typeof window&&(r.prototype._rand=function(){throw new Error("Not implemented yet")});else try{var n=i(93553);if("function"!=typeof n.randomBytes)throw new Error("Not supported");r.prototype._rand=function(e){return n.randomBytes(e)}}catch(e){}},47431:(e,t,i)=>{i.d(t,{Hjj:()=>ke,OP1:()=>Re,TRk:()=>n,_Yb:()=>r,aF0:()=>Me,kob:()=>Te,nWe:()=>Oe}),i(91315),i(20635),i(67822),i(33244),i(97353),i(1030),i(13360),i(17367),i(39907),i(48526).hp;const s=":";function r(e){const[t,i]=e.split(s);return{namespace:t,reference:i}}function n(e=[],t=[]){return[...new Set([...e,...t])]}function o(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function a(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function c(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function h(e,t){a(e);const i=t.outputLen;if(e.length<i)throw new Error("digestInto() expects output buffer of length at least "+i)}const d=BigInt(2**32-1),l=BigInt(32);function u(e,t=!1){return t?{h:Number(e&d),l:Number(e>>l&d)}:{h:0|Number(e>>l&d),l:0|Number(e&d)}}const p="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function f(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function g(e,t){return e<<32-t|e>>>t}const m=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function b(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function y(e){for(let t=0;t<e.length;t++)e[t]=b(e[t])}function w(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),a(e),e}class v{clone(){return this._cloneInto()}}function I(e){const t=t=>e().update(w(t)).digest(),i=e();return t.outputLen=i.outputLen,t.blockLen=i.blockLen,t.create=()=>e(),t}const E=[],_=[],A=[],N=BigInt(0),C=BigInt(1),S=BigInt(2),P=BigInt(7),O=BigInt(256),T=BigInt(113);for(let e=0,t=C,i=1,s=0;e<24;e++){[i,s]=[s,(2*i+3*s)%5],E.push(2*(5*s+i)),_.push((e+1)*(e+2)/2%64);let r=N;for(let e=0;e<7;e++)t=(t<<C^(t>>P)*T)%O,t&S&&(r^=C<<(C<<BigInt(e))-C);A.push(r)}const[x,k]=function(e,t=!1){let i=new Uint32Array(e.length),s=new Uint32Array(e.length);for(let r=0;r<e.length;r++){const{h:n,l:o}=u(e[r],t);[i[r],s[r]]=[n,o]}return[i,s]}(A,!0),R=(e,t,i)=>i>32?((e,t,i)=>t<<i-32|e>>>64-i)(e,t,i):((e,t,i)=>e<<i|t>>>32-i)(e,t,i),M=(e,t,i)=>i>32?((e,t,i)=>e<<i-32|t>>>64-i)(e,t,i):((e,t,i)=>t<<i|e>>>32-i)(e,t,i);class U extends v{constructor(e,t,i,s=!1,r=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=s,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,o(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var n;this.state=new Uint8Array(200),this.state32=(n=this.state,new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)))}keccak(){m||y(this.state32),function(e,t=24){const i=new Uint32Array(10);for(let s=24-t;s<24;s++){for(let t=0;t<10;t++)i[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const s=(t+8)%10,r=(t+2)%10,n=i[r],o=i[r+1],a=R(n,o,1)^i[s],c=M(n,o,1)^i[s+1];for(let i=0;i<50;i+=10)e[t+i]^=a,e[t+i+1]^=c}let t=e[2],r=e[3];for(let i=0;i<24;i++){const s=_[i],n=R(t,r,s),o=M(t,r,s),a=E[i];t=e[a],r=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let s=0;s<10;s++)i[s]=e[t+s];for(let s=0;s<10;s++)e[t+s]^=~i[(s+2)%10]&i[(s+4)%10]}e[0]^=x[s],e[1]^=k[s]}i.fill(0)}(this.state32,this.rounds),m||y(this.state32),this.posOut=0,this.pos=0}update(e){c(this);const{blockLen:t,state:i}=this,s=(e=w(e)).length;for(let r=0;r<s;){const n=Math.min(t-this.pos,s-r);for(let t=0;t<n;t++)i[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:s}=this;e[i]^=t,!!(128&t)&&i===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){c(this,!1),a(e),this.finish();const t=this.state,{blockLen:i}=this;for(let s=0,r=e.length;s<r;){this.posOut>=i&&this.keccak();const n=Math.min(i-this.posOut,r-s);e.set(t.subarray(this.posOut,this.posOut+n),s),this.posOut+=n,s+=n}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return o(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(h(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:s,rounds:r,enableXOF:n}=this;return e||(e=new U(t,i,s,n,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=i,e.outputLen=s,e.enableXOF=n,e.destroyed=this.destroyed,e}}function D(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function j(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function L(e,...t){if(!j(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function q(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function $(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}I(()=>new U(136,1,32)),Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const B=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function z(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!j(e))throw new Error("Uint8Array expected, got "+typeof e);e=V(e)}return e}function H(e,t,i=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(i&&!function(e){return e.byteOffset%4==0}(t))throw new Error("invalid output, must be aligned");return t}function W(e,t,i,s){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,i,s);const r=BigInt(32),n=BigInt(4294967295),o=Number(i>>r&n),a=Number(i&n),c=s?4:0,h=s?0:4;e.setUint32(t+c,o,s),e.setUint32(t+h,a,s)}function V(e){return Uint8Array.from(e)}function F(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const K=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),G=K("expand 16-byte k"),J=K("expand 32-byte k"),Y=B(G),X=B(J);function Q(e,t){return e<<t|e>>>32-t}function Z(e){return e.byteOffset%4==0}const ee=2**32-1,te=new Uint32Array,ie=(e,t)=>255&e[t++]|(255&e[t++])<<8;class se{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,L(e=z(e),32);const t=ie(e,0),i=ie(e,2),s=ie(e,4),r=ie(e,6),n=ie(e,8),o=ie(e,10),a=ie(e,12),c=ie(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|i<<3),this.r[2]=7939&(i>>>10|s<<6),this.r[3]=8191&(s>>>7|r<<9),this.r[4]=255&(r>>>4|n<<12),this.r[5]=n>>>1&8190,this.r[6]=8191&(n>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=ie(e,16+2*t)}process(e,t,i=!1){const s=i?0:2048,{h:r,r:n}=this,o=n[0],a=n[1],c=n[2],h=n[3],d=n[4],l=n[5],u=n[6],p=n[7],f=n[8],g=n[9],m=ie(e,t+0),b=ie(e,t+2),y=ie(e,t+4),w=ie(e,t+6),v=ie(e,t+8),I=ie(e,t+10),E=ie(e,t+12),_=ie(e,t+14);let A=r[0]+(8191&m),N=r[1]+(8191&(m>>>13|b<<3)),C=r[2]+(8191&(b>>>10|y<<6)),S=r[3]+(8191&(y>>>7|w<<9)),P=r[4]+(8191&(w>>>4|v<<12)),O=r[5]+(v>>>1&8191),T=r[6]+(8191&(v>>>14|I<<2)),x=r[7]+(8191&(I>>>11|E<<5)),k=r[8]+(8191&(E>>>8|_<<8)),R=r[9]+(_>>>5|s),M=0,U=M+A*o+N*(5*g)+C*(5*f)+S*(5*p)+P*(5*u);M=U>>>13,U&=8191,U+=O*(5*l)+T*(5*d)+x*(5*h)+k*(5*c)+R*(5*a),M+=U>>>13,U&=8191;let D=M+A*a+N*o+C*(5*g)+S*(5*f)+P*(5*p);M=D>>>13,D&=8191,D+=O*(5*u)+T*(5*l)+x*(5*d)+k*(5*h)+R*(5*c),M+=D>>>13,D&=8191;let j=M+A*c+N*a+C*o+S*(5*g)+P*(5*f);M=j>>>13,j&=8191,j+=O*(5*p)+T*(5*u)+x*(5*l)+k*(5*d)+R*(5*h),M+=j>>>13,j&=8191;let L=M+A*h+N*c+C*a+S*o+P*(5*g);M=L>>>13,L&=8191,L+=O*(5*f)+T*(5*p)+x*(5*u)+k*(5*l)+R*(5*d),M+=L>>>13,L&=8191;let q=M+A*d+N*h+C*c+S*a+P*o;M=q>>>13,q&=8191,q+=O*(5*g)+T*(5*f)+x*(5*p)+k*(5*u)+R*(5*l),M+=q>>>13,q&=8191;let $=M+A*l+N*d+C*h+S*c+P*a;M=$>>>13,$&=8191,$+=O*o+T*(5*g)+x*(5*f)+k*(5*p)+R*(5*u),M+=$>>>13,$&=8191;let B=M+A*u+N*l+C*d+S*h+P*c;M=B>>>13,B&=8191,B+=O*a+T*o+x*(5*g)+k*(5*f)+R*(5*p),M+=B>>>13,B&=8191;let z=M+A*p+N*u+C*l+S*d+P*h;M=z>>>13,z&=8191,z+=O*c+T*a+x*o+k*(5*g)+R*(5*f),M+=z>>>13,z&=8191;let H=M+A*f+N*p+C*u+S*l+P*d;M=H>>>13,H&=8191,H+=O*h+T*c+x*a+k*o+R*(5*g),M+=H>>>13,H&=8191;let W=M+A*g+N*f+C*p+S*u+P*l;M=W>>>13,W&=8191,W+=O*d+T*h+x*c+k*a+R*o,M+=W>>>13,W&=8191,M=(M<<2)+M|0,M=M+U|0,U=8191&M,M>>>=13,D+=M,r[0]=U,r[1]=D,r[2]=j,r[3]=L,r[4]=q,r[5]=$,r[6]=B,r[7]=z,r[8]=H,r[9]=W}finalize(){const{h:e,pad:t}=this,i=new Uint16Array(10);let s=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=s,s=e[t]>>>13,e[t]&=8191;e[0]+=5*s,s=e[0]>>>13,e[0]&=8191,e[1]+=s,s=e[1]>>>13,e[1]&=8191,e[2]+=s,i[0]=e[0]+5,s=i[0]>>>13,i[0]&=8191;for(let t=1;t<10;t++)i[t]=e[t]+s,s=i[t]>>>13,i[t]&=8191;i[9]-=8192;let r=(1^s)-1;for(let e=0;e<10;e++)i[e]&=r;r=~r;for(let t=0;t<10;t++)e[t]=e[t]&r|i[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let n=e[0]+t[0];e[0]=65535&n;for(let i=1;i<8;i++)n=(e[i]+t[i]|0)+(n>>>16)|0,e[i]=65535&n;F(i)}update(e){q(this);const{buffer:t,blockLen:i}=this,s=(e=z(e)).length;for(let r=0;r<s;){const n=Math.min(i-this.pos,s-r);if(n!==i)t.set(e.subarray(r,r+n),this.pos),this.pos+=n,r+=n,this.pos===i&&(this.process(t,0,!1),this.pos=0);else for(;i<=s-r;r+=i)this.process(e,r)}return this}destroy(){F(this.h,this.r,this.buffer,this.pad)}digestInto(e){q(this),function(e,t){L(e);const i=t.outputLen;if(e.length<i)throw new Error("digestInto() expects output buffer of length at least "+i)}(e,this),this.finished=!0;const{buffer:t,h:i}=this;let{pos:s}=this;if(s){for(t[s++]=1;s<16;s++)t[s]=0;this.process(t,0,!0)}this.finalize();let r=0;for(let t=0;t<8;t++)e[r++]=i[t]>>>0,e[r++]=i[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}}const re=function(e){const t=(t,i)=>e(i).update(z(t)).digest(),i=e(new Uint8Array(32));return t.outputLen=i.outputLen,t.blockLen=i.blockLen,t.create=t=>e(t),t}(e=>new se(e)),ne=function(e){const{allowShortKeys:t,extendNonceFn:i,counterLength:s,counterRight:r,rounds:n}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t)}(0,{counterRight:!1,counterLength:4,allowShortKeys:!1});return D(s),D(n),$(r),$(t),(o,a,c,h,d=0)=>{L(o),L(a),L(c);const l=c.length;if(void 0===h&&(h=new Uint8Array(l)),L(h),D(d),d<0||d>=ee)throw new Error("arx: counter overflow");if(h.length<l)throw new Error(`arx: output (${h.length}) is shorter than data (${l})`);const u=[];let p,f,g=o.length;if(32===g)u.push(p=V(o)),f=X;else{if(16!==g||!t)throw new Error(`arx: invalid 32-byte key, got length=${g}`);p=new Uint8Array(32),p.set(o),p.set(o,16),f=Y,u.push(p)}Z(a)||u.push(a=V(a));const m=B(p);if(i){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");i(f,m,B(a.subarray(0,16)),m),a=a.subarray(16)}const b=16-s;if(b!==a.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(12!==b){const e=new Uint8Array(12);e.set(a,r?0:12-a.length),a=e,u.push(a)}const y=B(a);return function(e,t,i,s,r,n,o,a){const c=r.length,h=new Uint8Array(64),d=B(h),l=Z(r)&&Z(n),u=l?B(r):te,p=l?B(n):te;for(let f=0;f<c;o++){if(e(t,i,s,d,o,a),o>=ee)throw new Error("arx: counter overflow");const g=Math.min(64,c-f);if(l&&64===g){const e=f/4;if(f%4!=0)throw new Error("arx: invalid block position");for(let t,i=0;i<16;i++)t=e+i,p[t]=u[t]^d[i];f+=64;continue}for(let e,t=0;t<g;t++)e=f+t,n[e]=r[e]^h[t];f+=g}}(e,f,m,y,c,h,d,n),F(...u),h}}(function(e,t,i,s,r,n=20){let o=e[0],a=e[1],c=e[2],h=e[3],d=t[0],l=t[1],u=t[2],p=t[3],f=t[4],g=t[5],m=t[6],b=t[7],y=r,w=i[0],v=i[1],I=i[2],E=o,_=a,A=c,N=h,C=d,S=l,P=u,O=p,T=f,x=g,k=m,R=b,M=y,U=w,D=v,j=I;for(let e=0;e<n;e+=2)E=E+C|0,M=Q(M^E,16),T=T+M|0,C=Q(C^T,12),E=E+C|0,M=Q(M^E,8),T=T+M|0,C=Q(C^T,7),_=_+S|0,U=Q(U^_,16),x=x+U|0,S=Q(S^x,12),_=_+S|0,U=Q(U^_,8),x=x+U|0,S=Q(S^x,7),A=A+P|0,D=Q(D^A,16),k=k+D|0,P=Q(P^k,12),A=A+P|0,D=Q(D^A,8),k=k+D|0,P=Q(P^k,7),N=N+O|0,j=Q(j^N,16),R=R+j|0,O=Q(O^R,12),N=N+O|0,j=Q(j^N,8),R=R+j|0,O=Q(O^R,7),E=E+S|0,j=Q(j^E,16),k=k+j|0,S=Q(S^k,12),E=E+S|0,j=Q(j^E,8),k=k+j|0,S=Q(S^k,7),_=_+P|0,M=Q(M^_,16),R=R+M|0,P=Q(P^R,12),_=_+P|0,M=Q(M^_,8),R=R+M|0,P=Q(P^R,7),A=A+O|0,U=Q(U^A,16),T=T+U|0,O=Q(O^T,12),A=A+O|0,U=Q(U^A,8),T=T+U|0,O=Q(O^T,7),N=N+C|0,D=Q(D^N,16),x=x+D|0,C=Q(C^x,12),N=N+C|0,D=Q(D^N,8),x=x+D|0,C=Q(C^x,7);let L=0;s[L++]=o+E|0,s[L++]=a+_|0,s[L++]=c+A|0,s[L++]=h+N|0,s[L++]=d+C|0,s[L++]=l+S|0,s[L++]=u+P|0,s[L++]=p+O|0,s[L++]=f+T|0,s[L++]=g+x|0,s[L++]=m+k|0,s[L++]=b+R|0,s[L++]=y+M|0,s[L++]=w+U|0,s[L++]=v+D|0,s[L++]=I+j|0}),oe=new Uint8Array(16),ae=(e,t)=>{e.update(t);const i=t.length%16;i&&e.update(oe.subarray(i))},ce=new Uint8Array(32);function he(e,t,i,s,r){const n=e(t,i,ce),o=re.create(n);r&&ae(o,r),ae(o,s);const a=new Uint8Array(16),c=(e=>new DataView(e.buffer,e.byteOffset,e.byteLength))(a);W(c,0,BigInt(r?r.length:0),!0),W(c,8,BigInt(s.length),!0),o.update(a);const h=o.digest();return F(n,a),h}((e,t)=>{Object.assign(function(i,...s){if(L(i),void 0!==e.nonceLength){const t=s[0];if(!t)throw new Error("nonce / iv required");e.varSizeNonce?L(t):L(t,e.nonceLength)}const r=e.tagLength;r&&void 0!==s[1]&&L(s[1]);const n=t(i,...s),o=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");L(t)}};let a=!1;return{encrypt(e,t){if(a)throw new Error("cannot encrypt() twice with same key + nonce");return a=!0,L(e),o(n.encrypt.length,t),n.encrypt(e,t)},decrypt(e,t){if(L(e),r&&e.length<r)throw new Error("invalid ciphertext length: smaller than tagLength="+r);return o(n.decrypt.length,t),n.decrypt(e,t)}}},e)})({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,i,s)=>({encrypt(r,n){const o=r.length;(n=H(o+16,n,!1)).set(r);const a=n.subarray(0,-16);e(t,i,a,a,1);const c=he(e,t,i,a,s);return n.set(c,o),F(c),n},decrypt(r,n){n=H(r.length-16,n,!1);const o=r.subarray(0,-16),a=r.subarray(-16),c=he(e,t,i,o,s);if(!function(e,t){if(e.length!==t.length)return!1;let i=0;for(let s=0;s<e.length;s++)i|=e[s]^t[s];return 0===i}(a,c))throw new Error("invalid tag");return n.set(r.subarray(0,-16)),e(t,i,n,n,1),F(c),n}}))(ne));function de(e,t,i){return e&t^~e&i}function le(e,t,i){return e&t^e&i^t&i}new Uint8Array([0]),new Uint8Array;class ue extends v{constructor(e,t,i,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=f(this.buffer)}update(e){c(this);const{view:t,buffer:i,blockLen:s}=this,r=(e=w(e)).length;for(let n=0;n<r;){const o=Math.min(s-this.pos,r-n);if(o===s){const t=f(e);for(;s<=r-n;n+=s)this.process(t,n);continue}i.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){c(this),h(e,this),this.finished=!0;const{buffer:t,view:i,blockLen:s,isLE:r}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>s-n&&(this.process(i,0),n=0);for(let e=n;e<s;e++)t[e]=0;(function(e,t,i,s){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,i,s);const r=BigInt(32),n=BigInt(4294967295),o=Number(i>>r&n),a=Number(i&n),c=s?4:0,h=s?0:4;e.setUint32(t+c,o,s),e.setUint32(t+h,a,s)})(i,s-8,BigInt(8*this.length),r),this.process(i,0);const o=f(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=a/4,l=this.get();if(d>l.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<d;e++)o.setUint32(4*e,l[e],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:i,length:s,finished:r,destroyed:n,pos:o}=this;return e.length=s,e.pos=o,e.finished=r,e.destroyed=n,s%t&&e.buffer.set(i),e}}const pe=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),fe=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ge=new Uint32Array(64);class me extends ue{constructor(){super(64,32,8,!1),this.A=0|fe[0],this.B=0|fe[1],this.C=0|fe[2],this.D=0|fe[3],this.E=0|fe[4],this.F=0|fe[5],this.G=0|fe[6],this.H=0|fe[7]}get(){const{A:e,B:t,C:i,D:s,E:r,F:n,G:o,H:a}=this;return[e,t,i,s,r,n,o,a]}set(e,t,i,s,r,n,o,a){this.A=0|e,this.B=0|t,this.C=0|i,this.D=0|s,this.E=0|r,this.F=0|n,this.G=0|o,this.H=0|a}process(e,t){for(let i=0;i<16;i++,t+=4)ge[i]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=ge[e-15],i=ge[e-2],s=g(t,7)^g(t,18)^t>>>3,r=g(i,17)^g(i,19)^i>>>10;ge[e]=r+ge[e-7]+s+ge[e-16]|0}let{A:i,B:s,C:r,D:n,E:o,F:a,G:c,H:h}=this;for(let e=0;e<64;e++){const t=h+(g(o,6)^g(o,11)^g(o,25))+de(o,a,c)+pe[e]+ge[e]|0,d=(g(i,2)^g(i,13)^g(i,22))+le(i,s,r)|0;h=c,c=a,a=o,o=n+t|0,n=r,r=s,s=i,i=t+d|0}i=i+this.A|0,s=s+this.B|0,r=r+this.C|0,n=n+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(i,s,r,n,o,a,c,h)}roundClean(){ge.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}I(()=>new me);BigInt(0);function be(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function ye(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function we(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,i=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const s=new Uint8Array(i);for(let t=0,r=0;t<i;t++,r+=2){const i=ye(e.charCodeAt(r)),n=ye(e.charCodeAt(r+1));if(void 0===i||void 0===n){const t=e[r]+e[r+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+r)}s[t]=16*i+n}return s}const ve={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||be(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)},Ie=BigInt(0);BigInt(1);function Ee(e,t){const i=e%t;return i>=Ie?i:t+i}function _e(e,t,i){let s=e;for(;t-- >Ie;)s*=s,s%=i;return s}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);BigInt(0),BigInt(1);const Ae=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const Ne=BigInt(1),Ce=BigInt(2),Se=BigInt(3),Pe=BigInt(5);function Oe(e){return e.includes(":")}function Te(e){return Oe(e)?e.split(":")[0]:e}BigInt(8),function(e){const t=function(e){return function(e,t,i={}){const s=(t,i,s)=>{const r=ve[i];if("function"!=typeof r)throw new Error("invalid validator function");const n=e[t];if(!(s&&void 0===n||r(n,e)))throw new Error("param "+String(t)+" is invalid. Expected "+i+", got "+n)};for(const[e,i]of Object.entries(t))s(e,i,!1);for(const[e,t]of Object.entries(i))s(e,t,!0)}(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:i}=t,s=e=>Ee(e,i),r=t.montgomeryBits,n=Math.ceil(r/8);t.nByteLength,t.adjustScalarBytes,t.powPminus2;t.a,BigInt(2),BigInt(4);function o(e){return function(e,t){return function(e,t){return we(e.toString(16).padStart(2*t,"0"))}(e,t).reverse()}(s(e),n)}o(t.Gu)}({P:Ae,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=Ae,{pow_p_5_8:i,b2:s}=function(e){const t=BigInt(10),i=BigInt(20),s=BigInt(40),r=BigInt(80),n=Ae,o=e*e%n*e%n,a=_e(o,Ce,n)*o%n,c=_e(a,Ne,n)*e%n,h=_e(c,Pe,n)*c%n,d=_e(h,t,n)*h%n,l=_e(d,i,n)*d%n,u=_e(l,s,n)*l%n,p=_e(u,r,n)*u%n,f=_e(p,r,n)*u%n,g=_e(f,t,n)*h%n;return{pow_p_5_8:_e(g,Ce,n)*e%n,b2:o}}(e);return Ee(_e(i,Se,t)*s,t)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},randomBytes:function(e=32){if(p&&"function"==typeof p.getRandomValues)return p.getRandomValues(new Uint8Array(e));if(p&&"function"==typeof p.randomBytes)return p.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}}),Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const xe={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}};function ke(e,t){const{message:i,code:s}=xe[e];return{message:t?`${i} ${t}`:i,code:s}}function Re(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function Me(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}},47531:(e,t,i)=>{var s=i(64845),r=i(41874).assert;function n(e,t){this.ec=e,this.priv=null,this.pub=null,t.priv&&this._importPrivate(t.priv,t.privEnc),t.pub&&this._importPublic(t.pub,t.pubEnc)}e.exports=n,n.fromPublic=function(e,t,i){return t instanceof n?t:new n(e,{pub:t,pubEnc:i})},n.fromPrivate=function(e,t,i){return t instanceof n?t:new n(e,{priv:t,privEnc:i})},n.prototype.validate=function(){var e=this.getPublic();return e.isInfinity()?{result:!1,reason:"Invalid public key"}:e.validate()?e.mul(this.ec.curve.n).isInfinity()?{result:!0,reason:null}:{result:!1,reason:"Public key * N != O"}:{result:!1,reason:"Public key is not a point"}},n.prototype.getPublic=function(e,t){return"string"==typeof e&&(t=e,e=null),this.pub||(this.pub=this.ec.g.mul(this.priv)),t?this.pub.encode(t,e):this.pub},n.prototype.getPrivate=function(e){return"hex"===e?this.priv.toString(16,2):this.priv},n.prototype._importPrivate=function(e,t){this.priv=new s(e,t||16),this.priv=this.priv.umod(this.ec.curve.n)},n.prototype._importPublic=function(e,t){if(e.x||e.y)return"mont"===this.ec.curve.type?r(e.x,"Need x coordinate"):"short"!==this.ec.curve.type&&"edwards"!==this.ec.curve.type||r(e.x&&e.y,"Need both x and y coordinate"),void(this.pub=this.ec.curve.point(e.x,e.y));this.pub=this.ec.curve.decodePoint(e,t)},n.prototype.derive=function(e){return e.validate()||r(e.validate(),"public point not validated"),e.mul(this.priv).getX()},n.prototype.sign=function(e,t,i){return this.ec.sign(e,this,t,i)},n.prototype.verify=function(e,t,i){return this.ec.verify(e,t,this,void 0,i)},n.prototype.inspect=function(){return"<Key priv: "+(this.priv&&this.priv.toString(16,2))+" pub: "+(this.pub&&this.pub.inspect())+" >"}},48336:(e,t,i)=>{i.d(t,{s:()=>n});var s=i(88315),r=i(58906);function n(e){return new s._({...e,basic:!0,sdkVersion:`html-core-${r.i}`})}},48851:(e,t,i)=>{i.d(t,{ADD:()=>x,ALl:()=>Vt,AYU:()=>yi,AwN:()=>ti,BdH:()=>v,C5G:()=>ei,CTo:()=>wi,EN$:()=>Wt,EWt:()=>kt,F$L:()=>Xt,GuA:()=>fi,Hjj:()=>gi,K3g:()=>O,Lln:()=>m,Lp_:()=>Ut,PUk:()=>S,QJh:()=>li,Qhg:()=>bi,R7U:()=>E,TZl:()=>Bt,TeY:()=>Ii,Tw2:()=>Yt,U0i:()=>ri,V7m:()=>ii,Wx8:()=>P,Xw0:()=>M,YcA:()=>Jt,_dF:()=>U,aRZ:()=>w,aa1:()=>ai,b07:()=>mi,bEt:()=>xt,c82:()=>R,gOF:()=>k,gZm:()=>j,h0Y:()=>C,hEn:()=>D,iui:()=>Zt,jUZ:()=>N,lFF:()=>_,m01:()=>y,mr0:()=>vi,n6V:()=>oi,ojD:()=>A,ovp:()=>Ht,ps1:()=>si,sc7:()=>Ei,two:()=>zt,uym:()=>_i,w8K:()=>L,wYp:()=>hi,wa2:()=>Gt,x0t:()=>Kt,yy4:()=>$});var s=i(24661),r=i(91315),n=i(20635),o=i(67822),a=(i(33244),i(97353)),c=i(1030),h=i(13360),d=i(17367),l=i(39907),u=i(48526).hp;const p="ReactNative",f={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},g="js";function m(){return typeof l<"u"&&typeof l.versions<"u"&&typeof l.versions.node<"u"}function b(){return!(0,n.getDocument)()&&!!(0,n.getNavigator)()&&navigator.product===p}function y(){return b()&&typeof i.g<"u"&&typeof(null==i.g?void 0:i.g.Platform)<"u"&&"android"===(null==i.g?void 0:i.g.Platform.OS)}function w(){return b()&&typeof i.g<"u"&&typeof(null==i.g?void 0:i.g.Platform)<"u"&&"ios"===(null==i.g?void 0:i.g.Platform.OS)}function v(){return!m()&&!!(0,n.getNavigator)()&&!!(0,n.getDocument)()}function I(){return b()?f.reactNative:m()?f.node:v()?f.browser:f.unknown}function E(){var e;try{return b()&&typeof i.g<"u"&&typeof(null==i.g?void 0:i.g.Application)<"u"?null==(e=i.g.Application)?void 0:e.applicationId:void 0}catch{return}}function _(){return(0,o.g)()||{name:"",description:"",url:"",icons:[""]}}function A(e,t,r){const o=function(){if(I()===f.reactNative&&typeof i.g<"u"&&typeof(null==i.g?void 0:i.g.Platform)<"u"){const{OS:e,Version:t}=i.g.Platform;return[e,t].join("-")}const e=(0,s.o0)();if(null===e)return"unknown";const t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return"browser"===e.type?[t,e.name,e.version].join("-"):[t,e.version].join("-")}(),a=function(){var e;const t=I();return t===f.browser?[t,(null==(e=(0,n.getLocation)())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),[g,r].join("-"),o,a].join("/")}function N({protocol:e,version:t,relayUrl:i,sdkVersion:s,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const h=i.split("?"),d={auth:r,ua:A(e,t,s),projectId:n,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},l=function(e,t){const i=new URLSearchParams(e);for(const e of Object.keys(t).sort())if(t.hasOwnProperty(e)){const s=t[e];void 0!==s&&i.set(e,s)}return i.toString()}(h[1]||"",d);return h[0]+"?"+l}function C(e){return Object.fromEntries(e.entries())}function S(e){return new Map(Object.entries(e))}function P(e=r.FIVE_MINUTES,t){const i=(0,r.toMiliseconds)(e||r.FIVE_MINUTES);let s,n,o,a;return{resolve:e=>{o&&s&&(clearTimeout(o),s(e),a=Promise.resolve(e))},reject:e=>{o&&n&&(clearTimeout(o),n(e))},done:()=>new Promise((e,r)=>{if(a)return e(a);o=setTimeout(()=>{const e=new Error(t);a=Promise.reject(e),r(e)},i),s=e,n=r})}}function O(e,t,i){return new Promise(async(s,r)=>{const n=setTimeout(()=>r(new Error(i)),t);try{s(await e)}catch(e){r(e)}clearTimeout(n)})}function T(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${e}`)}function x(e){return T("topic",e)}function k(e){return T("id",e)}function R(e){const[t,i]=e.split(":"),s={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof i)s.topic=i;else{if("id"!==t||!Number.isInteger(Number(i)))throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${i}`);s.id=Number(i)}return s}function M(e,t){return(0,r.fromMiliseconds)((t||Date.now())+(0,r.toMiliseconds)(e))}function U(e){return Date.now()>=(0,r.toMiliseconds)(e)}function D(e,t){return`${e}${t?`:${t}`:""}`}function j(){return typeof crypto<"u"&&null!=crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function L(){return typeof l<"u"&&"true"===l.env.IS_VITEST}function q(e){return u.from(e,"base64").toString("utf-8")}function $(e){return new Promise(t=>setTimeout(t,e))}function B(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function z(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function H(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");B(e.outputLen),B(e.blockLen)}function W(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function V(e,t){z(e);const i=t.outputLen;if(e.length<i)throw new Error("digestInto() expects output buffer of length at least "+i)}const F=BigInt(2**32-1),K=BigInt(32);function G(e,t=!1){return t?{h:Number(e&F),l:Number(e>>K&F)}:{h:0|Number(e>>K&F),l:0|Number(e&F)}}const J="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function Y(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function X(e,t){return e<<32-t|e>>>t}const Q=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function Z(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function ee(e){for(let t=0;t<e.length;t++)e[t]=Z(e[t])}function te(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),z(e),e}class ie{clone(){return this._cloneInto()}}function se(e){const t=t=>e().update(te(t)).digest(),i=e();return t.outputLen=i.outputLen,t.blockLen=i.blockLen,t.create=()=>e(),t}function re(e=32){if(J&&"function"==typeof J.getRandomValues)return J.getRandomValues(new Uint8Array(e));if(J&&"function"==typeof J.randomBytes)return J.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}const ne=[],oe=[],ae=[],ce=BigInt(0),he=BigInt(1),de=BigInt(2),le=BigInt(7),ue=BigInt(256),pe=BigInt(113);for(let e=0,t=he,i=1,s=0;e<24;e++){[i,s]=[s,(2*i+3*s)%5],ne.push(2*(5*s+i)),oe.push((e+1)*(e+2)/2%64);let r=ce;for(let e=0;e<7;e++)t=(t<<he^(t>>le)*pe)%ue,t&de&&(r^=he<<(he<<BigInt(e))-he);ae.push(r)}const[fe,ge]=function(e,t=!1){let i=new Uint32Array(e.length),s=new Uint32Array(e.length);for(let r=0;r<e.length;r++){const{h:n,l:o}=G(e[r],t);[i[r],s[r]]=[n,o]}return[i,s]}(ae,!0),me=(e,t,i)=>i>32?((e,t,i)=>t<<i-32|e>>>64-i)(e,t,i):((e,t,i)=>e<<i|t>>>32-i)(e,t,i),be=(e,t,i)=>i>32?((e,t,i)=>e<<i-32|t>>>64-i)(e,t,i):((e,t,i)=>t<<i|e>>>32-i)(e,t,i);class ye extends ie{constructor(e,t,i,s=!1,r=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=s,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,B(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var n;this.state=new Uint8Array(200),this.state32=(n=this.state,new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)))}keccak(){Q||ee(this.state32),function(e,t=24){const i=new Uint32Array(10);for(let s=24-t;s<24;s++){for(let t=0;t<10;t++)i[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const s=(t+8)%10,r=(t+2)%10,n=i[r],o=i[r+1],a=me(n,o,1)^i[s],c=be(n,o,1)^i[s+1];for(let i=0;i<50;i+=10)e[t+i]^=a,e[t+i+1]^=c}let t=e[2],r=e[3];for(let i=0;i<24;i++){const s=oe[i],n=me(t,r,s),o=be(t,r,s),a=ne[i];t=e[a],r=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let s=0;s<10;s++)i[s]=e[t+s];for(let s=0;s<10;s++)e[t+s]^=~i[(s+2)%10]&i[(s+4)%10]}e[0]^=fe[s],e[1]^=ge[s]}i.fill(0)}(this.state32,this.rounds),Q||ee(this.state32),this.posOut=0,this.pos=0}update(e){W(this);const{blockLen:t,state:i}=this,s=(e=te(e)).length;for(let r=0;r<s;){const n=Math.min(t-this.pos,s-r);for(let t=0;t<n;t++)i[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:s}=this;e[i]^=t,!!(128&t)&&i===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){W(this,!1),z(e),this.finish();const t=this.state,{blockLen:i}=this;for(let s=0,r=e.length;s<r;){this.posOut>=i&&this.keccak();const n=Math.min(i-this.posOut,r-s);e.set(t.subarray(this.posOut,this.posOut+n),s),this.posOut+=n,s+=n}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return B(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(V(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:s,rounds:r,enableXOF:n}=this;return e||(e=new ye(t,i,s,n,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=i,e.outputLen=s,e.enableXOF=n,e.destroyed=this.destroyed,e}}function we(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function ve(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Ie(e,...t){if(!ve(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ee(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function _e(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}se(()=>new ye(136,1,32)),Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const Ae=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function Ne(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!ve(e))throw new Error("Uint8Array expected, got "+typeof e);e=Pe(e)}return e}function Ce(e,t,i=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(i&&!function(e){return e.byteOffset%4==0}(t))throw new Error("invalid output, must be aligned");return t}function Se(e,t,i,s){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,i,s);const r=BigInt(32),n=BigInt(4294967295),o=Number(i>>r&n),a=Number(i&n),c=s?4:0,h=s?0:4;e.setUint32(t+c,o,s),e.setUint32(t+h,a,s)}function Pe(e){return Uint8Array.from(e)}function Oe(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const Te=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),xe=Te("expand 16-byte k"),ke=Te("expand 32-byte k"),Re=Ae(xe),Me=Ae(ke);function Ue(e,t){return e<<t|e>>>32-t}function De(e){return e.byteOffset%4==0}const je=2**32-1,Le=new Uint32Array,qe=(e,t)=>255&e[t++]|(255&e[t++])<<8;class $e{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,Ie(e=Ne(e),32);const t=qe(e,0),i=qe(e,2),s=qe(e,4),r=qe(e,6),n=qe(e,8),o=qe(e,10),a=qe(e,12),c=qe(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|i<<3),this.r[2]=7939&(i>>>10|s<<6),this.r[3]=8191&(s>>>7|r<<9),this.r[4]=255&(r>>>4|n<<12),this.r[5]=n>>>1&8190,this.r[6]=8191&(n>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=qe(e,16+2*t)}process(e,t,i=!1){const s=i?0:2048,{h:r,r:n}=this,o=n[0],a=n[1],c=n[2],h=n[3],d=n[4],l=n[5],u=n[6],p=n[7],f=n[8],g=n[9],m=qe(e,t+0),b=qe(e,t+2),y=qe(e,t+4),w=qe(e,t+6),v=qe(e,t+8),I=qe(e,t+10),E=qe(e,t+12),_=qe(e,t+14);let A=r[0]+(8191&m),N=r[1]+(8191&(m>>>13|b<<3)),C=r[2]+(8191&(b>>>10|y<<6)),S=r[3]+(8191&(y>>>7|w<<9)),P=r[4]+(8191&(w>>>4|v<<12)),O=r[5]+(v>>>1&8191),T=r[6]+(8191&(v>>>14|I<<2)),x=r[7]+(8191&(I>>>11|E<<5)),k=r[8]+(8191&(E>>>8|_<<8)),R=r[9]+(_>>>5|s),M=0,U=M+A*o+N*(5*g)+C*(5*f)+S*(5*p)+P*(5*u);M=U>>>13,U&=8191,U+=O*(5*l)+T*(5*d)+x*(5*h)+k*(5*c)+R*(5*a),M+=U>>>13,U&=8191;let D=M+A*a+N*o+C*(5*g)+S*(5*f)+P*(5*p);M=D>>>13,D&=8191,D+=O*(5*u)+T*(5*l)+x*(5*d)+k*(5*h)+R*(5*c),M+=D>>>13,D&=8191;let j=M+A*c+N*a+C*o+S*(5*g)+P*(5*f);M=j>>>13,j&=8191,j+=O*(5*p)+T*(5*u)+x*(5*l)+k*(5*d)+R*(5*h),M+=j>>>13,j&=8191;let L=M+A*h+N*c+C*a+S*o+P*(5*g);M=L>>>13,L&=8191,L+=O*(5*f)+T*(5*p)+x*(5*u)+k*(5*l)+R*(5*d),M+=L>>>13,L&=8191;let q=M+A*d+N*h+C*c+S*a+P*o;M=q>>>13,q&=8191,q+=O*(5*g)+T*(5*f)+x*(5*p)+k*(5*u)+R*(5*l),M+=q>>>13,q&=8191;let $=M+A*l+N*d+C*h+S*c+P*a;M=$>>>13,$&=8191,$+=O*o+T*(5*g)+x*(5*f)+k*(5*p)+R*(5*u),M+=$>>>13,$&=8191;let B=M+A*u+N*l+C*d+S*h+P*c;M=B>>>13,B&=8191,B+=O*a+T*o+x*(5*g)+k*(5*f)+R*(5*p),M+=B>>>13,B&=8191;let z=M+A*p+N*u+C*l+S*d+P*h;M=z>>>13,z&=8191,z+=O*c+T*a+x*o+k*(5*g)+R*(5*f),M+=z>>>13,z&=8191;let H=M+A*f+N*p+C*u+S*l+P*d;M=H>>>13,H&=8191,H+=O*h+T*c+x*a+k*o+R*(5*g),M+=H>>>13,H&=8191;let W=M+A*g+N*f+C*p+S*u+P*l;M=W>>>13,W&=8191,W+=O*d+T*h+x*c+k*a+R*o,M+=W>>>13,W&=8191,M=(M<<2)+M|0,M=M+U|0,U=8191&M,M>>>=13,D+=M,r[0]=U,r[1]=D,r[2]=j,r[3]=L,r[4]=q,r[5]=$,r[6]=B,r[7]=z,r[8]=H,r[9]=W}finalize(){const{h:e,pad:t}=this,i=new Uint16Array(10);let s=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=s,s=e[t]>>>13,e[t]&=8191;e[0]+=5*s,s=e[0]>>>13,e[0]&=8191,e[1]+=s,s=e[1]>>>13,e[1]&=8191,e[2]+=s,i[0]=e[0]+5,s=i[0]>>>13,i[0]&=8191;for(let t=1;t<10;t++)i[t]=e[t]+s,s=i[t]>>>13,i[t]&=8191;i[9]-=8192;let r=(1^s)-1;for(let e=0;e<10;e++)i[e]&=r;r=~r;for(let t=0;t<10;t++)e[t]=e[t]&r|i[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let n=e[0]+t[0];e[0]=65535&n;for(let i=1;i<8;i++)n=(e[i]+t[i]|0)+(n>>>16)|0,e[i]=65535&n;Oe(i)}update(e){Ee(this);const{buffer:t,blockLen:i}=this,s=(e=Ne(e)).length;for(let r=0;r<s;){const n=Math.min(i-this.pos,s-r);if(n!==i)t.set(e.subarray(r,r+n),this.pos),this.pos+=n,r+=n,this.pos===i&&(this.process(t,0,!1),this.pos=0);else for(;i<=s-r;r+=i)this.process(e,r)}return this}destroy(){Oe(this.h,this.r,this.buffer,this.pad)}digestInto(e){Ee(this),function(e,t){Ie(e);const i=t.outputLen;if(e.length<i)throw new Error("digestInto() expects output buffer of length at least "+i)}(e,this),this.finished=!0;const{buffer:t,h:i}=this;let{pos:s}=this;if(s){for(t[s++]=1;s<16;s++)t[s]=0;this.process(t,0,!0)}this.finalize();let r=0;for(let t=0;t<8;t++)e[r++]=i[t]>>>0,e[r++]=i[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}}const Be=function(e){const t=(t,i)=>e(i).update(Ne(t)).digest(),i=e(new Uint8Array(32));return t.outputLen=i.outputLen,t.blockLen=i.blockLen,t.create=t=>e(t),t}(e=>new $e(e)),ze=function(e){const{allowShortKeys:t,extendNonceFn:i,counterLength:s,counterRight:r,rounds:n}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t)}(0,{counterRight:!1,counterLength:4,allowShortKeys:!1});return we(s),we(n),_e(r),_e(t),(o,a,c,h,d=0)=>{Ie(o),Ie(a),Ie(c);const l=c.length;if(void 0===h&&(h=new Uint8Array(l)),Ie(h),we(d),d<0||d>=je)throw new Error("arx: counter overflow");if(h.length<l)throw new Error(`arx: output (${h.length}) is shorter than data (${l})`);const u=[];let p,f,g=o.length;if(32===g)u.push(p=Pe(o)),f=Me;else{if(16!==g||!t)throw new Error(`arx: invalid 32-byte key, got length=${g}`);p=new Uint8Array(32),p.set(o),p.set(o,16),f=Re,u.push(p)}De(a)||u.push(a=Pe(a));const m=Ae(p);if(i){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");i(f,m,Ae(a.subarray(0,16)),m),a=a.subarray(16)}const b=16-s;if(b!==a.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(12!==b){const e=new Uint8Array(12);e.set(a,r?0:12-a.length),a=e,u.push(a)}const y=Ae(a);return function(e,t,i,s,r,n,o,a){const c=r.length,h=new Uint8Array(64),d=Ae(h),l=De(r)&&De(n),u=l?Ae(r):Le,p=l?Ae(n):Le;for(let f=0;f<c;o++){if(e(t,i,s,d,o,a),o>=je)throw new Error("arx: counter overflow");const g=Math.min(64,c-f);if(l&&64===g){const e=f/4;if(f%4!=0)throw new Error("arx: invalid block position");for(let t,i=0;i<16;i++)t=e+i,p[t]=u[t]^d[i];f+=64;continue}for(let e,t=0;t<g;t++)e=f+t,n[e]=r[e]^h[t];f+=g}}(e,f,m,y,c,h,d,n),Oe(...u),h}}(function(e,t,i,s,r,n=20){let o=e[0],a=e[1],c=e[2],h=e[3],d=t[0],l=t[1],u=t[2],p=t[3],f=t[4],g=t[5],m=t[6],b=t[7],y=r,w=i[0],v=i[1],I=i[2],E=o,_=a,A=c,N=h,C=d,S=l,P=u,O=p,T=f,x=g,k=m,R=b,M=y,U=w,D=v,j=I;for(let e=0;e<n;e+=2)E=E+C|0,M=Ue(M^E,16),T=T+M|0,C=Ue(C^T,12),E=E+C|0,M=Ue(M^E,8),T=T+M|0,C=Ue(C^T,7),_=_+S|0,U=Ue(U^_,16),x=x+U|0,S=Ue(S^x,12),_=_+S|0,U=Ue(U^_,8),x=x+U|0,S=Ue(S^x,7),A=A+P|0,D=Ue(D^A,16),k=k+D|0,P=Ue(P^k,12),A=A+P|0,D=Ue(D^A,8),k=k+D|0,P=Ue(P^k,7),N=N+O|0,j=Ue(j^N,16),R=R+j|0,O=Ue(O^R,12),N=N+O|0,j=Ue(j^N,8),R=R+j|0,O=Ue(O^R,7),E=E+S|0,j=Ue(j^E,16),k=k+j|0,S=Ue(S^k,12),E=E+S|0,j=Ue(j^E,8),k=k+j|0,S=Ue(S^k,7),_=_+P|0,M=Ue(M^_,16),R=R+M|0,P=Ue(P^R,12),_=_+P|0,M=Ue(M^_,8),R=R+M|0,P=Ue(P^R,7),A=A+O|0,U=Ue(U^A,16),T=T+U|0,O=Ue(O^T,12),A=A+O|0,U=Ue(U^A,8),T=T+U|0,O=Ue(O^T,7),N=N+C|0,D=Ue(D^N,16),x=x+D|0,C=Ue(C^x,12),N=N+C|0,D=Ue(D^N,8),x=x+D|0,C=Ue(C^x,7);let L=0;s[L++]=o+E|0,s[L++]=a+_|0,s[L++]=c+A|0,s[L++]=h+N|0,s[L++]=d+C|0,s[L++]=l+S|0,s[L++]=u+P|0,s[L++]=p+O|0,s[L++]=f+T|0,s[L++]=g+x|0,s[L++]=m+k|0,s[L++]=b+R|0,s[L++]=y+M|0,s[L++]=w+U|0,s[L++]=v+D|0,s[L++]=I+j|0}),He=new Uint8Array(16),We=(e,t)=>{e.update(t);const i=t.length%16;i&&e.update(He.subarray(i))},Ve=new Uint8Array(32);function Fe(e,t,i,s,r){const n=e(t,i,Ve),o=Be.create(n);r&&We(o,r),We(o,s);const a=new Uint8Array(16),c=(e=>new DataView(e.buffer,e.byteOffset,e.byteLength))(a);Se(c,0,BigInt(r?r.length:0),!0),Se(c,8,BigInt(s.length),!0),o.update(a);const h=o.digest();return Oe(n,a),h}const Ke=((e,t)=>{function i(i,...s){if(Ie(i),void 0!==e.nonceLength){const t=s[0];if(!t)throw new Error("nonce / iv required");e.varSizeNonce?Ie(t):Ie(t,e.nonceLength)}const r=e.tagLength;r&&void 0!==s[1]&&Ie(s[1]);const n=t(i,...s),o=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");Ie(t)}};let a=!1;return{encrypt(e,t){if(a)throw new Error("cannot encrypt() twice with same key + nonce");return a=!0,Ie(e),o(n.encrypt.length,t),n.encrypt(e,t)},decrypt(e,t){if(Ie(e),r&&e.length<r)throw new Error("invalid ciphertext length: smaller than tagLength="+r);return o(n.decrypt.length,t),n.decrypt(e,t)}}}return Object.assign(i,e),i})({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,i,s)=>({encrypt(r,n){const o=r.length;(n=Ce(o+16,n,!1)).set(r);const a=n.subarray(0,-16);e(t,i,a,a,1);const c=Fe(e,t,i,a,s);return n.set(c,o),Oe(c),n},decrypt(r,n){n=Ce(r.length-16,n,!1);const o=r.subarray(0,-16),a=r.subarray(-16),c=Fe(e,t,i,o,s);if(!function(e,t){if(e.length!==t.length)return!1;let i=0;for(let s=0;s<e.length;s++)i|=e[s]^t[s];return 0===i}(a,c))throw new Error("invalid tag");return n.set(r.subarray(0,-16)),e(t,i,n,n,1),Oe(c),n}}))(ze));class Ge extends ie{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,H(e);const i=te(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,r=new Uint8Array(s);r.set(i.length>s?e.create().update(i).digest():i);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),r.fill(0)}update(e){return W(this),this.iHash.update(e),this}digestInto(e){W(this),z(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:i,finished:s,destroyed:r,blockLen:n,outputLen:o}=this;return e.finished=s,e.destroyed=r,e.blockLen=n,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Je=(e,t,i)=>new Ge(e,t).update(i).digest();Je.create=(e,t)=>new Ge(e,t);const Ye=new Uint8Array([0]),Xe=new Uint8Array,Qe=(e,t,i,s,r)=>function(e,t,i,s=32){if(H(e),B(s),s>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const r=Math.ceil(s/e.outputLen);void 0===i&&(i=Xe);const n=new Uint8Array(r*e.outputLen),o=Je.create(e,t),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let t=0;t<r;t++)Ye[0]=t+1,a.update(0===t?Xe:c).update(i).update(Ye).digestInto(c),n.set(c,e.outputLen*t),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),Ye.fill(0),n.slice(0,s)}(e,function(e,t,i){return H(e),void 0===i&&(i=new Uint8Array(e.outputLen)),Je(e,te(i),te(t))}(e,t,i),s,r);function Ze(e,t,i){return e&t^~e&i}function et(e,t,i){return e&t^e&i^t&i}class tt extends ie{constructor(e,t,i,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Y(this.buffer)}update(e){W(this);const{view:t,buffer:i,blockLen:s}=this,r=(e=te(e)).length;for(let n=0;n<r;){const o=Math.min(s-this.pos,r-n);if(o===s){const t=Y(e);for(;s<=r-n;n+=s)this.process(t,n);continue}i.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){W(this),V(e,this),this.finished=!0;const{buffer:t,view:i,blockLen:s,isLE:r}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>s-n&&(this.process(i,0),n=0);for(let e=n;e<s;e++)t[e]=0;(function(e,t,i,s){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,i,s);const r=BigInt(32),n=BigInt(4294967295),o=Number(i>>r&n),a=Number(i&n),c=s?4:0,h=s?0:4;e.setUint32(t+c,o,s),e.setUint32(t+h,a,s)})(i,s-8,BigInt(8*this.length),r),this.process(i,0);const o=Y(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,h[e],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:i,length:s,finished:r,destroyed:n,pos:o}=this;return e.length=s,e.pos=o,e.finished=r,e.destroyed=n,s%t&&e.buffer.set(i),e}}const it=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),st=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),rt=new Uint32Array(64);class nt extends tt{constructor(){super(64,32,8,!1),this.A=0|st[0],this.B=0|st[1],this.C=0|st[2],this.D=0|st[3],this.E=0|st[4],this.F=0|st[5],this.G=0|st[6],this.H=0|st[7]}get(){const{A:e,B:t,C:i,D:s,E:r,F:n,G:o,H:a}=this;return[e,t,i,s,r,n,o,a]}set(e,t,i,s,r,n,o,a){this.A=0|e,this.B=0|t,this.C=0|i,this.D=0|s,this.E=0|r,this.F=0|n,this.G=0|o,this.H=0|a}process(e,t){for(let i=0;i<16;i++,t+=4)rt[i]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=rt[e-15],i=rt[e-2],s=X(t,7)^X(t,18)^t>>>3,r=X(i,17)^X(i,19)^i>>>10;rt[e]=r+rt[e-7]+s+rt[e-16]|0}let{A:i,B:s,C:r,D:n,E:o,F:a,G:c,H:h}=this;for(let e=0;e<64;e++){const t=h+(X(o,6)^X(o,11)^X(o,25))+Ze(o,a,c)+it[e]+rt[e]|0,d=(X(i,2)^X(i,13)^X(i,22))+et(i,s,r)|0;h=c,c=a,a=o,o=n+t|0,n=r,r=s,s=i,i=t+d|0}i=i+this.A|0,s=s+this.B|0,r=r+this.C|0,n=n+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(i,s,r,n,o,a,c,h)}roundClean(){rt.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const ot=se(()=>new nt),at=BigInt(0);function ct(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function ht(e){if(!ct(e))throw new Error("Uint8Array expected")}const dt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function lt(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function ut(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,i=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const s=new Uint8Array(i);for(let t=0,r=0;t<i;t++,r+=2){const i=lt(e.charCodeAt(r)),n=lt(e.charCodeAt(r+1));if(void 0===i||void 0===n){const t=e[r]+e[r+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+r)}s[t]=16*i+n}return s}function pt(e){return ht(e),function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?at:BigInt("0x"+e)}(function(e){ht(e);let t="";for(let i=0;i<e.length;i++)t+=dt[e[i]];return t}(Uint8Array.from(e).reverse()))}function ft(e,t,i){let s;if("string"==typeof t)try{s=ut(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!ct(t))throw new Error(e+" must be hex string or Uint8Array");s=Uint8Array.from(t)}const r=s.length;if("number"==typeof i&&r!==i)throw new Error(e+" of length "+i+" expected, got "+r);return s}const gt=e=>"bigint"==typeof e&&at<=e;function mt(e,t,i,s){if(!function(e,t,i){return gt(e)&>(t)&>(i)&&t<=e&&e<i}(t,i,s))throw new Error("expected valid "+e+": "+i+" <= n < "+s+", got "+t)}const bt={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||ct(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)},yt=BigInt(0),wt=BigInt(1);function vt(e,t){const i=e%t;return i>=yt?i:t+i}function It(e,t,i){let s=e;for(;t-- >yt;)s*=s,s%=i;return s}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const Et=BigInt(0),_t=BigInt(1);const At=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const Nt=BigInt(1),Ct=BigInt(2),St=BigInt(3),Pt=BigInt(5);BigInt(8);const Ot=function(e){const t=function(e){return function(e,t,i={}){const s=(t,i,s)=>{const r=bt[i];if("function"!=typeof r)throw new Error("invalid validator function");const n=e[t];if(!(s&&void 0===n||r(n,e)))throw new Error("param "+String(t)+" is invalid. Expected "+i+", got "+n)};for(const[e,i]of Object.entries(t))s(e,i,!1);for(const[e,t]of Object.entries(i))s(e,t,!0)}(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:i}=t,s=e=>vt(e,i),r=t.montgomeryBits,n=Math.ceil(r/8),o=t.nByteLength,a=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>function(e,t,i){if(t<yt)throw new Error("invalid exponent, negatives unsupported");if(i<=yt)throw new Error("invalid modulus");if(i===wt)return yt;let s=wt;for(;t>yt;)t&wt&&(s=s*e%i),e=e*e%i,t>>=wt;return s}(e,i-BigInt(2),i));function h(e,t,i){const r=s(e*(t-i));return[t=s(t-r),i=s(i+r)]}const d=(t.a-BigInt(2))/BigInt(4);function l(e){return function(e,t){return function(e,t){return ut(e.toString(16).padStart(2*t,"0"))}(e,t).reverse()}(s(e),n)}function u(e,t){const u=function(e){const t=ft("u coordinate",e,n);return 32===o&&(t[31]&=127),pt(t)}(t),p=function(e){const t=ft("scalar",e),i=t.length;if(i!==n&&i!==o)throw new Error("invalid scalar, expected "+n+" or "+o+" bytes, got "+i);return pt(a(t))}(e),f=function(e,t){mt("u",e,Et,i),mt("scalar",t,Et,i);const n=t,o=e;let a,l=_t,u=Et,p=e,f=_t,g=Et;for(let e=BigInt(r-1);e>=Et;e--){const t=n>>e&_t;g^=t,a=h(g,l,p),l=a[0],p=a[1],a=h(g,u,f),u=a[0],f=a[1],g=t;const i=l+u,r=s(i*i),c=l-u,m=s(c*c),b=r-m,y=p+f,w=s((p-f)*i),v=s(y*c),I=w+v,E=w-v;p=s(I*I),f=s(o*s(E*E)),l=s(r*m),u=s(b*(r+s(d*b)))}a=h(g,l,p),l=a[0],p=a[1],a=h(g,u,f),u=a[0],f=a[1];const m=c(u);return s(l*m)}(u,p);if(f===Et)throw new Error("invalid private or public key received");return l(f)}const p=l(t.Gu);function f(e){return u(e,p)}return{scalarMult:u,scalarMultBase:f,getSharedSecret:(e,t)=>u(e,t),getPublicKey:e=>f(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:p}}({P:At,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=At,{pow_p_5_8:i,b2:s}=function(e){const t=BigInt(10),i=BigInt(20),s=BigInt(40),r=BigInt(80),n=At,o=e*e%n*e%n,a=It(o,Ct,n)*o%n,c=It(a,Nt,n)*e%n,h=It(c,Pt,n)*c%n,d=It(h,t,n)*h%n,l=It(d,i,n)*d%n,u=It(l,s,n)*l%n,p=It(u,r,n)*u%n,f=It(p,r,n)*u%n,g=It(f,t,n)*h%n;return{pow_p_5_8:It(g,Ct,n)*e%n,b2:o}}(e);return vt(It(i,St,t)*s,t)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},randomBytes:re}),Tt="base10",xt="base16",kt="base64pad",Rt="utf8",Mt=0,Ut=1,Dt=2,jt=0,Lt=1,qt=12,$t=32;function Bt(){const e=Ot.utils.randomPrivateKey(),t=Ot.getPublicKey(e);return{privateKey:(0,c.dI)(e,xt),publicKey:(0,c.dI)(t,xt)}}function zt(){const e=re($t);return(0,c.dI)(e,xt)}function Ht(e,t){const i=Ot.getSharedSecret((0,c.sH)(e,xt),(0,c.sH)(t,xt)),s=Qe(ot,i,void 0,void 0,$t);return(0,c.dI)(s,xt)}function Wt(e){const t=ot((0,c.sH)(e,xt));return(0,c.dI)(t,xt)}function Vt(e){const t=ot((0,c.sH)(e,Rt));return(0,c.dI)(t,xt)}function Ft(e){return(0,c.sH)(`${e}`,Tt)}function Kt(e){return Number((0,c.dI)(e,Tt))}function Gt(e){const t=Ft(typeof e.type<"u"?e.type:Mt);if(Kt(t)===Ut&&typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const i=typeof e.senderPublicKey<"u"?(0,c.sH)(e.senderPublicKey,xt):void 0,s=typeof e.iv<"u"?(0,c.sH)(e.iv,xt):re(qt),r=(0,c.sH)(e.symKey,xt);return Qt({type:t,sealed:Ke(r,s).encrypt((0,c.sH)(e.message,Rt)),iv:s,senderPublicKey:i,encoding:e.encoding})}function Jt(e){const t=(0,c.sH)(e.symKey,xt),{sealed:i,iv:s}=Zt(e),r=Ke(t,s).decrypt(i);if(null===r)throw new Error("Failed to decrypt");return(0,c.dI)(r,Rt)}function Yt(e,t){const i=Ft(Dt),s=re(qt);return Qt({type:i,sealed:(0,c.sH)(e,Rt),iv:s,encoding:t})}function Xt(e,t){const{sealed:i}=Zt({encoded:e,encoding:t});return(0,c.dI)(i,Rt)}function Qt(e){const{encoding:t=kt}=e;if(Kt(e.type)===Dt)return(0,c.dI)((0,c.xW)([e.type,e.sealed]),t);if(Kt(e.type)===Ut){if(typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return(0,c.dI)((0,c.xW)([e.type,e.senderPublicKey,e.iv,e.sealed]),t)}return(0,c.dI)((0,c.xW)([e.type,e.iv,e.sealed]),t)}function Zt(e){const{encoded:t,encoding:i=kt}=e,s=(0,c.sH)(t,i),r=s.slice(jt,Lt),n=Lt;if(Kt(r)===Ut){const e=n+$t,t=e+qt,i=s.slice(n,e),o=s.slice(e,t);return{type:r,sealed:s.slice(t),iv:o,senderPublicKey:i}}if(Kt(r)===Dt)return{type:r,sealed:s.slice(n),iv:re(qt)};const o=n+qt,a=s.slice(n,o);return{type:r,sealed:s.slice(o),iv:a}}function ei(e,t){const i=Zt({encoded:e,encoding:t?.encoding});return ti({type:Kt(i.type),senderPublicKey:typeof i.senderPublicKey<"u"?(0,c.dI)(i.senderPublicKey,xt):void 0,receiverPublicKey:t?.receiverPublicKey})}function ti(e){const t=e?.type||Mt;if(t===Ut){if(typeof e?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function ii(e){return e.type===Ut&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}function si(e){return e.type===Dt}function ri(e,t){const[i,s,r]=e.split("."),n=function(e){return u.from(function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const i=t.length%4;return i>0&&(t+="=".repeat(4-i)),t}(e),"base64")}(r);if(64!==n.length)throw new Error("Invalid signature length");const o=n.slice(0,32).toString("hex"),d=n.slice(32,64).toString("hex"),l=ot(`${i}.${s}`),p=function(e){return new h.ec("p256").keyFromPublic({x:u.from(e.x,"base64").toString("hex"),y:u.from(e.y,"base64").toString("hex")},"hex")}(t),f=(0,c.dI)(l,xt);if(!p.verify(f,{r:o,s:d}))throw new Error("Invalid signature");return(0,a.Cq)(e).payload}const ni="irn";function oi(e){return e?.relay||{protocol:ni}}function ai(e){const t=d.CG[e];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${e}`);return t}function ci(e,t="-"){const i={},s="relay"+t;return Object.keys(e).forEach(t=>{if(t.startsWith(s)){const r=t.replace(s,""),n=e[t];i[r]=n}}),i}function hi(e){if(!e.includes("wc:")){const t=q(e);null!=t&&t.includes("wc:")&&(e=t)}const t=(e=(e=e.includes("wc://")?e.replace("wc://",""):e).includes("wc:")?e.replace("wc:",""):e).indexOf(":"),i=-1!==e.indexOf("?")?e.indexOf("?"):void 0,s=e.substring(0,t),r=e.substring(t+1,i).split("@"),n=typeof i<"u"?e.substring(i):"",o=new URLSearchParams(n),a={};o.forEach((e,t)=>{a[t]=e});const c="string"==typeof a.methods?a.methods.split(","):void 0;return{protocol:s,topic:di(r[0]),version:parseInt(r[1],10),symKey:a.symKey,relay:ci(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function di(e){return e.startsWith("//")?e.substring(2):e}function li(e){const t=new URLSearchParams,i=function(e,t="-"){const i={};return Object.keys(e).forEach(s=>{const r=s,n="relay"+t+r;e[r]&&(i[n]=e[r])}),i}(e.relay);Object.keys(i).sort().forEach(e=>{t.set(e,i[e])}),t.set("symKey",e.symKey),e.expiryTimestamp&&t.set("expiryTimestamp",e.expiryTimestamp.toString()),e.methods&&t.set("methods",e.methods.join(","));const s=t.toString();return`${e.protocol}:${e.topic}@${e.version}?${s}`}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const ui={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},pi={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function fi(e,t){const{message:i,code:s}=pi[e];return{message:t?`${i} ${t}`:i,code:s}}function gi(e,t){const{message:i,code:s}=ui[e];return{message:t?`${i} ${t}`:i,code:s}}function mi(e){return typeof e>"u"}function bi(e,t){return!(!t||!mi(e))||"string"==typeof e&&!!e.trim().length}function yi(e){function t(e){try{return typeof new URL(e)<"u"}catch{return!1}}try{if(bi(e,!1))return!!t(e)||t(q(e))}catch{}return!1}function wi(e){var t;return null==(t=e?.proposer)?void 0:t.publicKey}function vi(e){return e?.topic}function Ii(e){return typeof e<"u"&&null!==typeof e}function Ei(){const e=I();return new Promise(t=>{switch(e){case f.browser:t(v()&&navigator?.onLine);break;case f.reactNative:t(async function(){if(b()&&typeof i.g<"u"&&null!=i.g&&i.g.NetInfo){const e=await(null==i.g?void 0:i.g.NetInfo.fetch());return e?.isConnected}return!0}());break;case f.node:default:t(!0)}})}function _i(e){switch(I()){case f.browser:!function(e){!b()&&v()&&(window.addEventListener("online",()=>e(!0)),window.addEventListener("offline",()=>e(!1)))}(e);break;case f.reactNative:!function(e){b()&&typeof i.g<"u"&&null!=i.g&&i.g.NetInfo&&i.g?.NetInfo.addEventListener(t=>e(t?.isConnected))}(e);case f.node:}}},49009:(e,t,i)=>{i.d(t,{Q:()=>s});const s=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}]},50047:(e,t,i)=>{i.d(t,{R:()=>s});const s=(0,i(40149).x)({id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",deprecatedCaipNetworkId:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"})},50536:(e,t,i)=>{var s=i(70461),r=i(32191),n=i(600),o=i(7784),a=s.sum32,c=s.sum32_4,h=s.sum32_5,d=n.ch32,l=n.maj32,u=n.s0_256,p=n.s1_256,f=n.g0_256,g=n.g1_256,m=r.BlockHash,b=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298];function y(){if(!(this instanceof y))return new y;m.call(this),this.h=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],this.k=b,this.W=new Array(64)}s.inherits(y,m),e.exports=y,y.blockSize=512,y.outSize=256,y.hmacStrength=192,y.padLength=64,y.prototype._update=function(e,t){for(var i=this.W,s=0;s<16;s++)i[s]=e[t+s];for(;s<i.length;s++)i[s]=c(g(i[s-2]),i[s-7],f(i[s-15]),i[s-16]);var r=this.h[0],n=this.h[1],m=this.h[2],b=this.h[3],y=this.h[4],w=this.h[5],v=this.h[6],I=this.h[7];for(o(this.k.length===i.length),s=0;s<i.length;s++){var E=h(I,p(y),d(y,w,v),this.k[s],i[s]),_=a(u(r),l(r,n,m));I=v,v=w,w=y,y=a(b,E),b=m,m=n,n=r,r=a(E,_)}this.h[0]=a(this.h[0],r),this.h[1]=a(this.h[1],n),this.h[2]=a(this.h[2],m),this.h[3]=a(this.h[3],b),this.h[4]=a(this.h[4],y),this.h[5]=a(this.h[5],w),this.h[6]=a(this.h[6],v),this.h[7]=a(this.h[7],I)},y.prototype._digest=function(e){return"hex"===e?s.toHex32(this.h,"big"):s.split32(this.h,"big")}},50731:(e,t,i)=>{i.d(t,{a:()=>m});var s=i(89168),r=i(39150),n=i(95191),o=i(11807),a=i(26097),c=i(11553),h=i(40868),d=i(99013),l=i(16158),u=i(42831),p=i(26545);const f={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0},g=(0,s.BX)({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:{...f}}),m={state:g,subscribe:e=>(0,s.B1)(g,()=>{e(g)}),subscribeKey:(e,t)=>(0,r.u$)(g,e,t),initialize(e){e.forEach(e=>{const t=c.i.getConnectedConnectorId(e);t&&this.setConnectorId(t,e)})},setActiveConnector(e){e&&(g.activeConnector=(0,s.KR)(e))},setConnectors(e){e.filter(e=>!g.allConnectors.some(t=>t.id===e.id&&this.getConnectorName(t.name)===this.getConnectorName(e.name)&&t.chain===e.chain)).forEach(e=>{"MULTI_CHAIN"!==e.type&&g.allConnectors.push((0,s.KR)(e))}),g.connectors=this.mergeMultiChainConnectors(g.allConnectors)},removeAdapter(e){g.allConnectors=g.allConnectors.filter(t=>t.chain!==e),g.connectors=this.mergeMultiChainConnectors(g.allConnectors)},mergeMultiChainConnectors(e){const t=this.generateConnectorMapByName(e),i=[];return t.forEach(e=>{const t=e[0],s=t?.id===n.o.CONNECTOR_ID.AUTH;e.length>1&&t?i.push({name:t.name,imageUrl:t.imageUrl,imageId:t.imageId,connectors:[...e],type:s?"AUTH":"MULTI_CHAIN",chain:"eip155",id:t?.id||""}):t&&i.push(t)}),i},generateConnectorMapByName(e){const t=new Map;return e.forEach(e=>{const{name:i}=e,s=this.getConnectorName(i);if(!s)return;const r=t.get(s)||[];r.find(t=>t.chain===e.chain)||r.push(e),t.set(s,r)}),t},getConnectorName:e=>e&&{"Trust Wallet":"Trust"}[e]||e,getUniqueConnectorsByName(e){const t=[];return e.forEach(e=>{t.find(t=>t.chain===e.chain)||t.push(e)}),t},addConnector(e){if(e.id===n.o.CONNECTOR_ID.AUTH){const t=e,i=(0,s.P9)(l.H.state),r=p.W.getSnapshot().themeMode,n=p.W.getSnapshot().themeVariables;t?.provider?.syncDappData?.({metadata:i.metadata,sdkVersion:i.sdkVersion,projectId:i.projectId,sdkType:i.sdkType}),t?.provider?.syncTheme({themeMode:r,themeVariables:n,w3mThemeVariables:(0,o.o)(n,r)}),this.setConnectors([e])}else this.setConnectors([e])},getAuthConnector(e){const t=e||d.W.state.activeChain,i=g.connectors.find(e=>e.id===n.o.CONNECTOR_ID.AUTH);if(i)return i?.connectors?.length?i.connectors.find(e=>e.chain===t):i},getAnnouncedConnectorRdns:()=>g.connectors.filter(e=>"ANNOUNCED"===e.type).map(e=>e.info?.rdns),getConnectorById:e=>g.allConnectors.find(t=>t.id===e),getConnector:(e,t)=>g.allConnectors.filter(e=>e.chain===d.W.state.activeChain).find(i=>i.explorerId===e||i.info?.rdns===t),syncIfAuthConnector(e){if("ID_AUTH"!==e.id)return;const t=e,i=(0,s.P9)(l.H.state),r=p.W.getSnapshot().themeMode,n=p.W.getSnapshot().themeVariables;t?.provider?.syncDappData?.({metadata:i.metadata,sdkVersion:i.sdkVersion,sdkType:i.sdkType,projectId:i.projectId}),t.provider.syncTheme({themeMode:r,themeVariables:n,w3mThemeVariables:(0,o.o)(n,r)})},getConnectorsByNamespace(e){const t=g.allConnectors.filter(t=>t.chain===e);return this.mergeMultiChainConnectors(t)},selectWalletConnector(e){const t=m.getConnector(e.id,e.rdns);d.W.state.activeChain===n.o.CHAIN.SOLANA&&a.W.handleSolanaDeeplinkRedirect(t?.name||e.name||""),t?u.I.push("ConnectingExternal",{connector:t}):u.I.push("ConnectingWalletConnect",{wallet:e})},getConnectors(e){return e?this.getConnectorsByNamespace(e):this.mergeMultiChainConnectors(g.allConnectors)},setFilterByNamespace(e){g.filterByNamespace=e,g.connectors=this.getConnectors(e),h.N.setFilterByNamespace(e)},setConnectorId(e,t){e&&(g.activeConnectorIds={...g.activeConnectorIds,[t]:e},c.i.setConnectedConnectorId(t,e))},removeConnectorId(e){g.activeConnectorIds={...g.activeConnectorIds,[e]:void 0},c.i.deleteConnectedConnectorId(e)},getConnectorId(e){if(e)return g.activeConnectorIds[e]},isConnected:e=>e?Boolean(g.activeConnectorIds[e]):Object.values(g.activeConnectorIds).some(e=>Boolean(e)),resetConnectorIds(){g.activeConnectorIds={...f}}}},51493:(e,t,i)=>{},52059:(e,t,i)=>{i.d(t,{W:()=>u});var s=i(89168),r=i(9663),n=i(16279),o=i(27006),a=i(99013),c=i(14479),h=i(16158),d=i(41430);const l=(0,s.BX)({transactions:[],coinbaseTransactions:{},transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),u={state:l,subscribe:e=>(0,s.B1)(l,()=>e(l)),setLastNetworkInView(e){l.lastNetworkInView=e},async fetchTransactions(e,t){if(!e)throw new Error("Transactions can't be fetched without an accountAddress");l.loading=!0;try{const i=await o.T.fetchTransactions({account:e,cursor:l.next,onramp:t,cache:"coinbase"===t?"no-cache":void 0,chainId:a.W.state.activeCaipNetwork?.caipNetworkId}),s=this.filterSpamTransactions(i.data),r=this.filterByConnectedChain(s),n=[...l.transactions,...r];l.loading=!1,"coinbase"===t?l.coinbaseTransactions=this.groupTransactionsByYearAndMonth(l.coinbaseTransactions,i.data):(l.transactions=n,l.transactionsByYear=this.groupTransactionsByYearAndMonth(l.transactionsByYear,r)),l.empty=0===n.length,l.next=i.next?i.next:void 0}catch(t){c.E.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:e,projectId:h.H.state.projectId,cursor:l.next,isSmartAccount:n.U.state.preferredAccountType===r.Vl.ACCOUNT_TYPES.SMART_ACCOUNT}}),d.P.showError("Failed to fetch transactions"),l.loading=!1,l.empty=!0,l.next=void 0}},groupTransactionsByYearAndMonth(e={},t=[]){const i=e;return t.forEach(e=>{const t=new Date(e.metadata.minedAt).getFullYear(),s=new Date(e.metadata.minedAt).getMonth(),r=i[t]??{},n=(r[s]??[]).filter(t=>t.id!==e.id);i[t]={...r,[s]:[...n,e].sort((e,t)=>new Date(t.metadata.minedAt).getTime()-new Date(e.metadata.minedAt).getTime())}}),i},filterSpamTransactions:e=>e.filter(e=>!e.transfers.every(e=>!0===e.nft_info?.flags.is_spam)),filterByConnectedChain(e){const t=a.W.state.activeCaipNetwork?.caipNetworkId;return e.filter(e=>e.metadata.chain===t)},clearCursor(){l.next=void 0},resetTransactions(){l.transactions=[],l.transactionsByYear={},l.lastNetworkInView=void 0,l.loading=!1,l.empty=!1,l.next=void 0}}},54672:(e,t,i)=>{var s=i(41874),r=s.assert,n=s.parseBytes,o=s.cachedProperty;function a(e,t){this.eddsa=e,this._secret=n(t.secret),e.isPoint(t.pub)?this._pub=t.pub:this._pubBytes=n(t.pub)}a.fromPublic=function(e,t){return t instanceof a?t:new a(e,{pub:t})},a.fromSecret=function(e,t){return t instanceof a?t:new a(e,{secret:t})},a.prototype.secret=function(){return this._secret},o(a,"pubBytes",function(){return this.eddsa.encodePoint(this.pub())}),o(a,"pub",function(){return this._pubBytes?this.eddsa.decodePoint(this._pubBytes):this.eddsa.g.mul(this.priv())}),o(a,"privBytes",function(){var e=this.eddsa,t=this.hash(),i=e.encodingLength-1,s=t.slice(0,e.encodingLength);return s[0]&=248,s[i]&=127,s[i]|=64,s}),o(a,"priv",function(){return this.eddsa.decodeInt(this.privBytes())}),o(a,"hash",function(){return this.eddsa.hash().update(this.secret()).digest()}),o(a,"messagePrefix",function(){return this.hash().slice(this.eddsa.encodingLength)}),a.prototype.sign=function(e){return r(this._secret,"KeyPair can only verify"),this.eddsa.sign(e,this)},a.prototype.verify=function(e,t){return this.eddsa.verify(e,t,this)},a.prototype.getSecret=function(e){return r(this._secret,"KeyPair is public only"),s.encode(this.secret(),e)},a.prototype.getPublic=function(e){return s.encode(this.pubBytes(),e)},e.exports=a},55164:(e,t,i)=>{i.d(t,{Rn0:()=>s.Rn,gTy:()=>s.gT,tWt:()=>s.tW});var s=i(14133);i(95642)},55770:(e,t,i)=>{i.d(t,{r:()=>s});const s=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}]},57782:(e,t,i)=>{var s=i(64845),r=i(41874),n=r.assert;function o(e,t){if(e instanceof o)return e;this._importDER(e,t)||(n(e.r&&e.s,"Signature without r or s"),this.r=new s(e.r,16),this.s=new s(e.s,16),void 0===e.recoveryParam?this.recoveryParam=null:this.recoveryParam=e.recoveryParam)}function a(){this.place=0}function c(e,t){var i=e[t.place++];if(!(128&i))return i;var s=15&i;if(0===s||s>4)return!1;if(0===e[t.place])return!1;for(var r=0,n=0,o=t.place;n<s;n++,o++)r<<=8,r|=e[o],r>>>=0;return!(r<=127)&&(t.place=o,r)}function h(e){for(var t=0,i=e.length-1;!e[t]&&!(128&e[t+1])&&t<i;)t++;return 0===t?e:e.slice(t)}function d(e,t){if(t<128)e.push(t);else{var i=1+(Math.log(t)/Math.LN2>>>3);for(e.push(128|i);--i;)e.push(t>>>(i<<3)&255);e.push(t)}}e.exports=o,o.prototype._importDER=function(e,t){e=r.toArray(e,t);var i=new a;if(48!==e[i.place++])return!1;var n=c(e,i);if(!1===n)return!1;if(n+i.place!==e.length)return!1;if(2!==e[i.place++])return!1;var o=c(e,i);if(!1===o)return!1;if(128&e[i.place])return!1;var h=e.slice(i.place,o+i.place);if(i.place+=o,2!==e[i.place++])return!1;var d=c(e,i);if(!1===d)return!1;if(e.length!==d+i.place)return!1;if(128&e[i.place])return!1;var l=e.slice(i.place,d+i.place);if(0===h[0]){if(!(128&h[1]))return!1;h=h.slice(1)}if(0===l[0]){if(!(128&l[1]))return!1;l=l.slice(1)}return this.r=new s(h),this.s=new s(l),this.recoveryParam=null,!0},o.prototype.toDER=function(e){var t=this.r.toArray(),i=this.s.toArray();for(128&t[0]&&(t=[0].concat(t)),128&i[0]&&(i=[0].concat(i)),t=h(t),i=h(i);!(i[0]||128&i[1]);)i=i.slice(1);var s=[2];d(s,t.length),(s=s.concat(t)).push(2),d(s,i.length);var n=s.concat(i),o=[48];return d(o,n.length),o=o.concat(n),r.encode(o,e)}},58906:(e,t,i)=>{i.d(t,{i:()=>s});const s="1.7.2"},59677:(e,t,i)=>{i.d(t,{C:()=>s});const s={validateCaipAddress(e){if(3!==e.split(":")?.length)throw new Error("Invalid CAIP Address");return e},parseCaipAddress(e){const t=e.split(":");if(3!==t.length)throw new Error(`Invalid CAIP-10 address: ${e}`);const[i,s,r]=t;if(!i||!s||!r)throw new Error(`Invalid CAIP-10 address: ${e}`);return{chainNamespace:i,chainId:s,address:r}},parseCaipNetworkId(e){const t=e.split(":");if(2!==t.length)throw new Error(`Invalid CAIP-2 network id: ${e}`);const[i,s]=t;if(!i||!s)throw new Error(`Invalid CAIP-2 network id: ${e}`);return{chainNamespace:i,chainId:s}}}},60277:(e,t,i)=>{var s=i(41874),r=i(64845),n=i(35615),o=i(85174),a=s.assert;function c(e){o.call(this,"short",e),this.a=new r(e.a,16).toRed(this.red),this.b=new r(e.b,16).toRed(this.red),this.tinv=this.two.redInvm(),this.zeroA=0===this.a.fromRed().cmpn(0),this.threeA=0===this.a.fromRed().sub(this.p).cmpn(-3),this.endo=this._getEndomorphism(e),this._endoWnafT1=new Array(4),this._endoWnafT2=new Array(4)}function h(e,t,i,s){o.BasePoint.call(this,e,"affine"),null===t&&null===i?(this.x=null,this.y=null,this.inf=!0):(this.x=new r(t,16),this.y=new r(i,16),s&&(this.x.forceRed(this.curve.red),this.y.forceRed(this.curve.red)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.inf=!1)}function d(e,t,i,s){o.BasePoint.call(this,e,"jacobian"),null===t&&null===i&&null===s?(this.x=this.curve.one,this.y=this.curve.one,this.z=new r(0)):(this.x=new r(t,16),this.y=new r(i,16),this.z=new r(s,16)),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.y.red||(this.y=this.y.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)),this.zOne=this.z===this.curve.one}n(c,o),e.exports=c,c.prototype._getEndomorphism=function(e){if(this.zeroA&&this.g&&this.n&&1===this.p.modn(3)){var t,i;if(e.beta)t=new r(e.beta,16).toRed(this.red);else{var s=this._getEndoRoots(this.p);t=(t=s[0].cmp(s[1])<0?s[0]:s[1]).toRed(this.red)}if(e.lambda)i=new r(e.lambda,16);else{var n=this._getEndoRoots(this.n);0===this.g.mul(n[0]).x.cmp(this.g.x.redMul(t))?i=n[0]:(i=n[1],a(0===this.g.mul(i).x.cmp(this.g.x.redMul(t))))}return{beta:t,lambda:i,basis:e.basis?e.basis.map(function(e){return{a:new r(e.a,16),b:new r(e.b,16)}}):this._getEndoBasis(i)}}},c.prototype._getEndoRoots=function(e){var t=e===this.p?this.red:r.mont(e),i=new r(2).toRed(t).redInvm(),s=i.redNeg(),n=new r(3).toRed(t).redNeg().redSqrt().redMul(i);return[s.redAdd(n).fromRed(),s.redSub(n).fromRed()]},c.prototype._getEndoBasis=function(e){for(var t,i,s,n,o,a,c,h,d,l=this.n.ushrn(Math.floor(this.n.bitLength()/2)),u=e,p=this.n.clone(),f=new r(1),g=new r(0),m=new r(0),b=new r(1),y=0;0!==u.cmpn(0);){var w=p.div(u);h=p.sub(w.mul(u)),d=m.sub(w.mul(f));var v=b.sub(w.mul(g));if(!s&&h.cmp(l)<0)t=c.neg(),i=f,s=h.neg(),n=d;else if(s&&2===++y)break;c=h,p=u,u=h,m=f,f=d,b=g,g=v}o=h.neg(),a=d;var I=s.sqr().add(n.sqr());return o.sqr().add(a.sqr()).cmp(I)>=0&&(o=t,a=i),s.negative&&(s=s.neg(),n=n.neg()),o.negative&&(o=o.neg(),a=a.neg()),[{a:s,b:n},{a:o,b:a}]},c.prototype._endoSplit=function(e){var t=this.endo.basis,i=t[0],s=t[1],r=s.b.mul(e).divRound(this.n),n=i.b.neg().mul(e).divRound(this.n),o=r.mul(i.a),a=n.mul(s.a),c=r.mul(i.b),h=n.mul(s.b);return{k1:e.sub(o).sub(a),k2:c.add(h).neg()}},c.prototype.pointFromX=function(e,t){(e=new r(e,16)).red||(e=e.toRed(this.red));var i=e.redSqr().redMul(e).redIAdd(e.redMul(this.a)).redIAdd(this.b),s=i.redSqrt();if(0!==s.redSqr().redSub(i).cmp(this.zero))throw new Error("invalid point");var n=s.fromRed().isOdd();return(t&&!n||!t&&n)&&(s=s.redNeg()),this.point(e,s)},c.prototype.validate=function(e){if(e.inf)return!0;var t=e.x,i=e.y,s=this.a.redMul(t),r=t.redSqr().redMul(t).redIAdd(s).redIAdd(this.b);return 0===i.redSqr().redISub(r).cmpn(0)},c.prototype._endoWnafMulAdd=function(e,t,i){for(var s=this._endoWnafT1,r=this._endoWnafT2,n=0;n<e.length;n++){var o=this._endoSplit(t[n]),a=e[n],c=a._getBeta();o.k1.negative&&(o.k1.ineg(),a=a.neg(!0)),o.k2.negative&&(o.k2.ineg(),c=c.neg(!0)),s[2*n]=a,s[2*n+1]=c,r[2*n]=o.k1,r[2*n+1]=o.k2}for(var h=this._wnafMulAdd(1,s,r,2*n,i),d=0;d<2*n;d++)s[d]=null,r[d]=null;return h},n(h,o.BasePoint),c.prototype.point=function(e,t,i){return new h(this,e,t,i)},c.prototype.pointFromJSON=function(e,t){return h.fromJSON(this,e,t)},h.prototype._getBeta=function(){if(this.curve.endo){var e=this.precomputed;if(e&&e.beta)return e.beta;var t=this.curve.point(this.x.redMul(this.curve.endo.beta),this.y);if(e){var i=this.curve,s=function(e){return i.point(e.x.redMul(i.endo.beta),e.y)};e.beta=t,t.precomputed={beta:null,naf:e.naf&&{wnd:e.naf.wnd,points:e.naf.points.map(s)},doubles:e.doubles&&{step:e.doubles.step,points:e.doubles.points.map(s)}}}return t}},h.prototype.toJSON=function(){return this.precomputed?[this.x,this.y,this.precomputed&&{doubles:this.precomputed.doubles&&{step:this.precomputed.doubles.step,points:this.precomputed.doubles.points.slice(1)},naf:this.precomputed.naf&&{wnd:this.precomputed.naf.wnd,points:this.precomputed.naf.points.slice(1)}}]:[this.x,this.y]},h.fromJSON=function(e,t,i){"string"==typeof t&&(t=JSON.parse(t));var s=e.point(t[0],t[1],i);if(!t[2])return s;function r(t){return e.point(t[0],t[1],i)}var n=t[2];return s.precomputed={beta:null,doubles:n.doubles&&{step:n.doubles.step,points:[s].concat(n.doubles.points.map(r))},naf:n.naf&&{wnd:n.naf.wnd,points:[s].concat(n.naf.points.map(r))}},s},h.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" y: "+this.y.fromRed().toString(16,2)+">"},h.prototype.isInfinity=function(){return this.inf},h.prototype.add=function(e){if(this.inf)return e;if(e.inf)return this;if(this.eq(e))return this.dbl();if(this.neg().eq(e))return this.curve.point(null,null);if(0===this.x.cmp(e.x))return this.curve.point(null,null);var t=this.y.redSub(e.y);0!==t.cmpn(0)&&(t=t.redMul(this.x.redSub(e.x).redInvm()));var i=t.redSqr().redISub(this.x).redISub(e.x),s=t.redMul(this.x.redSub(i)).redISub(this.y);return this.curve.point(i,s)},h.prototype.dbl=function(){if(this.inf)return this;var e=this.y.redAdd(this.y);if(0===e.cmpn(0))return this.curve.point(null,null);var t=this.curve.a,i=this.x.redSqr(),s=e.redInvm(),r=i.redAdd(i).redIAdd(i).redIAdd(t).redMul(s),n=r.redSqr().redISub(this.x.redAdd(this.x)),o=r.redMul(this.x.redSub(n)).redISub(this.y);return this.curve.point(n,o)},h.prototype.getX=function(){return this.x.fromRed()},h.prototype.getY=function(){return this.y.fromRed()},h.prototype.mul=function(e){return e=new r(e,16),this.isInfinity()?this:this._hasDoubles(e)?this.curve._fixedNafMul(this,e):this.curve.endo?this.curve._endoWnafMulAdd([this],[e]):this.curve._wnafMul(this,e)},h.prototype.mulAdd=function(e,t,i){var s=[this,t],r=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(s,r):this.curve._wnafMulAdd(1,s,r,2)},h.prototype.jmulAdd=function(e,t,i){var s=[this,t],r=[e,i];return this.curve.endo?this.curve._endoWnafMulAdd(s,r,!0):this.curve._wnafMulAdd(1,s,r,2,!0)},h.prototype.eq=function(e){return this===e||this.inf===e.inf&&(this.inf||0===this.x.cmp(e.x)&&0===this.y.cmp(e.y))},h.prototype.neg=function(e){if(this.inf)return this;var t=this.curve.point(this.x,this.y.redNeg());if(e&&this.precomputed){var i=this.precomputed,s=function(e){return e.neg()};t.precomputed={naf:i.naf&&{wnd:i.naf.wnd,points:i.naf.points.map(s)},doubles:i.doubles&&{step:i.doubles.step,points:i.doubles.points.map(s)}}}return t},h.prototype.toJ=function(){return this.inf?this.curve.jpoint(null,null,null):this.curve.jpoint(this.x,this.y,this.curve.one)},n(d,o.BasePoint),c.prototype.jpoint=function(e,t,i){return new d(this,e,t,i)},d.prototype.toP=function(){if(this.isInfinity())return this.curve.point(null,null);var e=this.z.redInvm(),t=e.redSqr(),i=this.x.redMul(t),s=this.y.redMul(t).redMul(e);return this.curve.point(i,s)},d.prototype.neg=function(){return this.curve.jpoint(this.x,this.y.redNeg(),this.z)},d.prototype.add=function(e){if(this.isInfinity())return e;if(e.isInfinity())return this;var t=e.z.redSqr(),i=this.z.redSqr(),s=this.x.redMul(t),r=e.x.redMul(i),n=this.y.redMul(t.redMul(e.z)),o=e.y.redMul(i.redMul(this.z)),a=s.redSub(r),c=n.redSub(o);if(0===a.cmpn(0))return 0!==c.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var h=a.redSqr(),d=h.redMul(a),l=s.redMul(h),u=c.redSqr().redIAdd(d).redISub(l).redISub(l),p=c.redMul(l.redISub(u)).redISub(n.redMul(d)),f=this.z.redMul(e.z).redMul(a);return this.curve.jpoint(u,p,f)},d.prototype.mixedAdd=function(e){if(this.isInfinity())return e.toJ();if(e.isInfinity())return this;var t=this.z.redSqr(),i=this.x,s=e.x.redMul(t),r=this.y,n=e.y.redMul(t).redMul(this.z),o=i.redSub(s),a=r.redSub(n);if(0===o.cmpn(0))return 0!==a.cmpn(0)?this.curve.jpoint(null,null,null):this.dbl();var c=o.redSqr(),h=c.redMul(o),d=i.redMul(c),l=a.redSqr().redIAdd(h).redISub(d).redISub(d),u=a.redMul(d.redISub(l)).redISub(r.redMul(h)),p=this.z.redMul(o);return this.curve.jpoint(l,u,p)},d.prototype.dblp=function(e){if(0===e)return this;if(this.isInfinity())return this;if(!e)return this.dbl();var t;if(this.curve.zeroA||this.curve.threeA){var i=this;for(t=0;t<e;t++)i=i.dbl();return i}var s=this.curve.a,r=this.curve.tinv,n=this.x,o=this.y,a=this.z,c=a.redSqr().redSqr(),h=o.redAdd(o);for(t=0;t<e;t++){var d=n.redSqr(),l=h.redSqr(),u=l.redSqr(),p=d.redAdd(d).redIAdd(d).redIAdd(s.redMul(c)),f=n.redMul(l),g=p.redSqr().redISub(f.redAdd(f)),m=f.redISub(g),b=p.redMul(m);b=b.redIAdd(b).redISub(u);var y=h.redMul(a);t+1<e&&(c=c.redMul(u)),n=g,a=y,h=b}return this.curve.jpoint(n,h.redMul(r),a)},d.prototype.dbl=function(){return this.isInfinity()?this:this.curve.zeroA?this._zeroDbl():this.curve.threeA?this._threeDbl():this._dbl()},d.prototype._zeroDbl=function(){var e,t,i;if(this.zOne){var s=this.x.redSqr(),r=this.y.redSqr(),n=r.redSqr(),o=this.x.redAdd(r).redSqr().redISub(s).redISub(n);o=o.redIAdd(o);var a=s.redAdd(s).redIAdd(s),c=a.redSqr().redISub(o).redISub(o),h=n.redIAdd(n);h=(h=h.redIAdd(h)).redIAdd(h),e=c,t=a.redMul(o.redISub(c)).redISub(h),i=this.y.redAdd(this.y)}else{var d=this.x.redSqr(),l=this.y.redSqr(),u=l.redSqr(),p=this.x.redAdd(l).redSqr().redISub(d).redISub(u);p=p.redIAdd(p);var f=d.redAdd(d).redIAdd(d),g=f.redSqr(),m=u.redIAdd(u);m=(m=m.redIAdd(m)).redIAdd(m),e=g.redISub(p).redISub(p),t=f.redMul(p.redISub(e)).redISub(m),i=(i=this.y.redMul(this.z)).redIAdd(i)}return this.curve.jpoint(e,t,i)},d.prototype._threeDbl=function(){var e,t,i;if(this.zOne){var s=this.x.redSqr(),r=this.y.redSqr(),n=r.redSqr(),o=this.x.redAdd(r).redSqr().redISub(s).redISub(n);o=o.redIAdd(o);var a=s.redAdd(s).redIAdd(s).redIAdd(this.curve.a),c=a.redSqr().redISub(o).redISub(o);e=c;var h=n.redIAdd(n);h=(h=h.redIAdd(h)).redIAdd(h),t=a.redMul(o.redISub(c)).redISub(h),i=this.y.redAdd(this.y)}else{var d=this.z.redSqr(),l=this.y.redSqr(),u=this.x.redMul(l),p=this.x.redSub(d).redMul(this.x.redAdd(d));p=p.redAdd(p).redIAdd(p);var f=u.redIAdd(u),g=(f=f.redIAdd(f)).redAdd(f);e=p.redSqr().redISub(g),i=this.y.redAdd(this.z).redSqr().redISub(l).redISub(d);var m=l.redSqr();m=(m=(m=m.redIAdd(m)).redIAdd(m)).redIAdd(m),t=p.redMul(f.redISub(e)).redISub(m)}return this.curve.jpoint(e,t,i)},d.prototype._dbl=function(){var e=this.curve.a,t=this.x,i=this.y,s=this.z,r=s.redSqr().redSqr(),n=t.redSqr(),o=i.redSqr(),a=n.redAdd(n).redIAdd(n).redIAdd(e.redMul(r)),c=t.redAdd(t),h=(c=c.redIAdd(c)).redMul(o),d=a.redSqr().redISub(h.redAdd(h)),l=h.redISub(d),u=o.redSqr();u=(u=(u=u.redIAdd(u)).redIAdd(u)).redIAdd(u);var p=a.redMul(l).redISub(u),f=i.redAdd(i).redMul(s);return this.curve.jpoint(d,p,f)},d.prototype.trpl=function(){if(!this.curve.zeroA)return this.dbl().add(this);var e=this.x.redSqr(),t=this.y.redSqr(),i=this.z.redSqr(),s=t.redSqr(),r=e.redAdd(e).redIAdd(e),n=r.redSqr(),o=this.x.redAdd(t).redSqr().redISub(e).redISub(s),a=(o=(o=(o=o.redIAdd(o)).redAdd(o).redIAdd(o)).redISub(n)).redSqr(),c=s.redIAdd(s);c=(c=(c=c.redIAdd(c)).redIAdd(c)).redIAdd(c);var h=r.redIAdd(o).redSqr().redISub(n).redISub(a).redISub(c),d=t.redMul(h);d=(d=d.redIAdd(d)).redIAdd(d);var l=this.x.redMul(a).redISub(d);l=(l=l.redIAdd(l)).redIAdd(l);var u=this.y.redMul(h.redMul(c.redISub(h)).redISub(o.redMul(a)));u=(u=(u=u.redIAdd(u)).redIAdd(u)).redIAdd(u);var p=this.z.redAdd(o).redSqr().redISub(i).redISub(a);return this.curve.jpoint(l,u,p)},d.prototype.mul=function(e,t){return e=new r(e,t),this.curve._wnafMul(this,e)},d.prototype.eq=function(e){if("affine"===e.type)return this.eq(e.toJ());if(this===e)return!0;var t=this.z.redSqr(),i=e.z.redSqr();if(0!==this.x.redMul(i).redISub(e.x.redMul(t)).cmpn(0))return!1;var s=t.redMul(this.z),r=i.redMul(e.z);return 0===this.y.redMul(r).redISub(e.y.redMul(s)).cmpn(0)},d.prototype.eqXToP=function(e){var t=this.z.redSqr(),i=e.toRed(this.curve.red).redMul(t);if(0===this.x.cmp(i))return!0;for(var s=e.clone(),r=this.curve.redN.redMul(t);;){if(s.iadd(this.curve.n),s.cmp(this.curve.p)>=0)return!1;if(i.redIAdd(r),0===this.x.cmp(i))return!0}},d.prototype.inspect=function(){return this.isInfinity()?"<EC JPoint Infinity>":"<EC JPoint x: "+this.x.toString(16,2)+" y: "+this.y.toString(16,2)+" z: "+this.z.toString(16,2)+">"},d.prototype.isInfinity=function(){return 0===this.z.cmpn(0)}},63245:(e,t,i)=>{var s=i(64845),r=i(35615),n=i(85174),o=i(41874);function a(e){n.call(this,"mont",e),this.a=new s(e.a,16).toRed(this.red),this.b=new s(e.b,16).toRed(this.red),this.i4=new s(4).toRed(this.red).redInvm(),this.two=new s(2).toRed(this.red),this.a24=this.i4.redMul(this.a.redAdd(this.two))}function c(e,t,i){n.BasePoint.call(this,e,"projective"),null===t&&null===i?(this.x=this.curve.one,this.z=this.curve.zero):(this.x=new s(t,16),this.z=new s(i,16),this.x.red||(this.x=this.x.toRed(this.curve.red)),this.z.red||(this.z=this.z.toRed(this.curve.red)))}r(a,n),e.exports=a,a.prototype.validate=function(e){var t=e.normalize().x,i=t.redSqr(),s=i.redMul(t).redAdd(i.redMul(this.a)).redAdd(t);return 0===s.redSqrt().redSqr().cmp(s)},r(c,n.BasePoint),a.prototype.decodePoint=function(e,t){return this.point(o.toArray(e,t),1)},a.prototype.point=function(e,t){return new c(this,e,t)},a.prototype.pointFromJSON=function(e){return c.fromJSON(this,e)},c.prototype.precompute=function(){},c.prototype._encode=function(){return this.getX().toArray("be",this.curve.p.byteLength())},c.fromJSON=function(e,t){return new c(e,t[0],t[1]||e.one)},c.prototype.inspect=function(){return this.isInfinity()?"<EC Point Infinity>":"<EC Point x: "+this.x.fromRed().toString(16,2)+" z: "+this.z.fromRed().toString(16,2)+">"},c.prototype.isInfinity=function(){return 0===this.z.cmpn(0)},c.prototype.dbl=function(){var e=this.x.redAdd(this.z).redSqr(),t=this.x.redSub(this.z).redSqr(),i=e.redSub(t),s=e.redMul(t),r=i.redMul(t.redAdd(this.curve.a24.redMul(i)));return this.curve.point(s,r)},c.prototype.add=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.diffAdd=function(e,t){var i=this.x.redAdd(this.z),s=this.x.redSub(this.z),r=e.x.redAdd(e.z),n=e.x.redSub(e.z).redMul(i),o=r.redMul(s),a=t.z.redMul(n.redAdd(o).redSqr()),c=t.x.redMul(n.redISub(o).redSqr());return this.curve.point(a,c)},c.prototype.mul=function(e){for(var t=e.clone(),i=this,s=this.curve.point(null,null),r=[];0!==t.cmpn(0);t.iushrn(1))r.push(t.andln(1));for(var n=r.length-1;n>=0;n--)0===r[n]?(i=i.diffAdd(s,this),s=s.dbl()):(s=i.diffAdd(s,this),i=i.dbl());return s},c.prototype.mulAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.jumlAdd=function(){throw new Error("Not supported on Montgomery curve")},c.prototype.eq=function(e){return 0===this.getX().cmp(e.getX())},c.prototype.normalize=function(){return this.x=this.x.redMul(this.z.redInvm()),this.z=this.curve.one,this},c.prototype.getX=function(){return this.normalize(),this.x.fromRed()}},63789:(e,t,i)=>{i.d(t,{Z:()=>s});const s={getSpacingStyles:(e,t)=>Array.isArray(e)?e[t]?`var(--wui-spacing-${e[t]})`:void 0:"string"==typeof e?`var(--wui-spacing-${e})`:void 0,getFormattedDate:e=>new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(e),getHostName(e){try{return new URL(e).hostname}catch(e){return""}},getTruncateString:({string:e,charsStart:t,charsEnd:i,truncate:s})=>e.length<=t+i?e:"end"===s?`${e.substring(0,t)}...`:"start"===s?`...${e.substring(e.length-i)}`:`${e.substring(0,Math.floor(t))}...${e.substring(e.length-Math.floor(i))}`,generateAvatarColors(e){const t=e.toLowerCase().replace(/^0x/iu,"").replace(/[^a-f0-9]/gu,"").substring(0,6).padEnd(6,"0"),i=this.hexToRgb(t),s=getComputedStyle(document.documentElement).getPropertyValue("--w3m-border-radius-master"),r=100-3*Number(s?.replace("px","")),n=`${r}% ${r}% at 65% 40%`,o=[];for(let e=0;e<5;e+=1){const t=this.tintColor(i,.15*e);o.push(`rgb(${t[0]}, ${t[1]}, ${t[2]})`)}return`\n --local-color-1: ${o[0]};\n --local-color-2: ${o[1]};\n --local-color-3: ${o[2]};\n --local-color-4: ${o[3]};\n --local-color-5: ${o[4]};\n --local-radial-circle: ${n}\n `},hexToRgb(e){const t=parseInt(e,16);return[t>>16&255,t>>8&255,255&t]},tintColor(e,t){const[i,s,r]=e;return[Math.round(i+(255-i)*t),Math.round(s+(255-s)*t),Math.round(r+(255-r)*t)]},isNumber:e=>/^[0-9]+$/u.test(e),getColorTheme:e=>e||("undefined"!=typeof window&&window.matchMedia?window.matchMedia("(prefers-color-scheme: dark)")?.matches?"dark":"light":"dark"),splitBalance(e){const t=e.split(".");return 2===t.length?[t[0],t[1]]:["0","00"]},roundNumber:(e,t,i)=>e.toString().length>=t?Number(e).toFixed(i):e,formatNumberToLocalString:(e,t=2)=>void 0===e?"0.00":"number"==typeof e?e.toLocaleString("en-US",{maximumFractionDigits:t,minimumFractionDigits:t}):parseFloat(e).toLocaleString("en-US",{maximumFractionDigits:t,minimumFractionDigits:t})}},64845:function(e,t,i){!function(e,t){function s(e,t){if(!e)throw new Error(t||"Assertion failed")}function r(e,t){e.super_=t;var i=function(){};i.prototype=t.prototype,e.prototype=new i,e.prototype.constructor=e}function n(e,t,i){if(n.isBN(e))return e;this.negative=0,this.words=null,this.length=0,this.red=null,null!==e&&("le"!==t&&"be"!==t||(i=t,t=10),this._init(e||0,t||10,i||"be"))}var o;"object"==typeof e?e.exports=n:t.BN=n,n.BN=n,n.wordSize=26;try{o="undefined"!=typeof window&&void 0!==window.Buffer?window.Buffer:i(52661).Buffer}catch(e){}function a(e,t){var i=e.charCodeAt(t);return i>=65&&i<=70?i-55:i>=97&&i<=102?i-87:i-48&15}function c(e,t,i){var s=a(e,i);return i-1>=t&&(s|=a(e,i-1)<<4),s}function h(e,t,i,s){for(var r=0,n=Math.min(e.length,i),o=t;o<n;o++){var a=e.charCodeAt(o)-48;r*=s,r+=a>=49?a-49+10:a>=17?a-17+10:a}return r}n.isBN=function(e){return e instanceof n||null!==e&&"object"==typeof e&&e.constructor.wordSize===n.wordSize&&Array.isArray(e.words)},n.max=function(e,t){return e.cmp(t)>0?e:t},n.min=function(e,t){return e.cmp(t)<0?e:t},n.prototype._init=function(e,t,i){if("number"==typeof e)return this._initNumber(e,t,i);if("object"==typeof e)return this._initArray(e,t,i);"hex"===t&&(t=16),s(t===(0|t)&&t>=2&&t<=36);var r=0;"-"===(e=e.toString().replace(/\s+/g,""))[0]&&(r++,this.negative=1),r<e.length&&(16===t?this._parseHex(e,r,i):(this._parseBase(e,t,r),"le"===i&&this._initArray(this.toArray(),t,i)))},n.prototype._initNumber=function(e,t,i){e<0&&(this.negative=1,e=-e),e<67108864?(this.words=[67108863&e],this.length=1):e<4503599627370496?(this.words=[67108863&e,e/67108864&67108863],this.length=2):(s(e<9007199254740992),this.words=[67108863&e,e/67108864&67108863,1],this.length=3),"le"===i&&this._initArray(this.toArray(),t,i)},n.prototype._initArray=function(e,t,i){if(s("number"==typeof e.length),e.length<=0)return this.words=[0],this.length=1,this;this.length=Math.ceil(e.length/3),this.words=new Array(this.length);for(var r=0;r<this.length;r++)this.words[r]=0;var n,o,a=0;if("be"===i)for(r=e.length-1,n=0;r>=0;r-=3)o=e[r]|e[r-1]<<8|e[r-2]<<16,this.words[n]|=o<<a&67108863,this.words[n+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,n++);else if("le"===i)for(r=0,n=0;r<e.length;r+=3)o=e[r]|e[r+1]<<8|e[r+2]<<16,this.words[n]|=o<<a&67108863,this.words[n+1]=o>>>26-a&67108863,(a+=24)>=26&&(a-=26,n++);return this.strip()},n.prototype._parseHex=function(e,t,i){this.length=Math.ceil((e.length-t)/6),this.words=new Array(this.length);for(var s=0;s<this.length;s++)this.words[s]=0;var r,n=0,o=0;if("be"===i)for(s=e.length-1;s>=t;s-=2)r=c(e,t,s)<<n,this.words[o]|=67108863&r,n>=18?(n-=18,o+=1,this.words[o]|=r>>>26):n+=8;else for(s=(e.length-t)%2==0?t+1:t;s<e.length;s+=2)r=c(e,t,s)<<n,this.words[o]|=67108863&r,n>=18?(n-=18,o+=1,this.words[o]|=r>>>26):n+=8;this.strip()},n.prototype._parseBase=function(e,t,i){this.words=[0],this.length=1;for(var s=0,r=1;r<=67108863;r*=t)s++;s--,r=r/t|0;for(var n=e.length-i,o=n%s,a=Math.min(n,n-o)+i,c=0,d=i;d<a;d+=s)c=h(e,d,d+s,t),this.imuln(r),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c);if(0!==o){var l=1;for(c=h(e,d,e.length,t),d=0;d<o;d++)l*=t;this.imuln(l),this.words[0]+c<67108864?this.words[0]+=c:this._iaddn(c)}this.strip()},n.prototype.copy=function(e){e.words=new Array(this.length);for(var t=0;t<this.length;t++)e.words[t]=this.words[t];e.length=this.length,e.negative=this.negative,e.red=this.red},n.prototype.clone=function(){var e=new n(null);return this.copy(e),e},n.prototype._expand=function(e){for(;this.length<e;)this.words[this.length++]=0;return this},n.prototype.strip=function(){for(;this.length>1&&0===this.words[this.length-1];)this.length--;return this._normSign()},n.prototype._normSign=function(){return 1===this.length&&0===this.words[0]&&(this.negative=0),this},n.prototype.inspect=function(){return(this.red?"<BN-R: ":"<BN: ")+this.toString(16)+">"};var d=["","0","00","000","0000","00000","000000","0000000","00000000","000000000","0000000000","00000000000","000000000000","0000000000000","00000000000000","000000000000000","0000000000000000","00000000000000000","000000000000000000","0000000000000000000","00000000000000000000","000000000000000000000","0000000000000000000000","00000000000000000000000","000000000000000000000000","0000000000000000000000000"],l=[0,0,25,16,12,11,10,9,8,8,7,7,7,7,6,6,6,6,6,6,6,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5,5],u=[0,0,33554432,43046721,16777216,48828125,60466176,40353607,16777216,43046721,1e7,19487171,35831808,62748517,7529536,11390625,16777216,24137569,34012224,47045881,64e6,4084101,5153632,6436343,7962624,9765625,11881376,14348907,17210368,20511149,243e5,28629151,33554432,39135393,45435424,52521875,60466176];function p(e,t,i){i.negative=t.negative^e.negative;var s=e.length+t.length|0;i.length=s,s=s-1|0;var r=0|e.words[0],n=0|t.words[0],o=r*n,a=67108863&o,c=o/67108864|0;i.words[0]=a;for(var h=1;h<s;h++){for(var d=c>>>26,l=67108863&c,u=Math.min(h,t.length-1),p=Math.max(0,h-e.length+1);p<=u;p++){var f=h-p|0;d+=(o=(r=0|e.words[f])*(n=0|t.words[p])+l)/67108864|0,l=67108863&o}i.words[h]=0|l,c=0|d}return 0!==c?i.words[h]=0|c:i.length--,i.strip()}n.prototype.toString=function(e,t){var i;if(t=0|t||1,16===(e=e||10)||"hex"===e){i="";for(var r=0,n=0,o=0;o<this.length;o++){var a=this.words[o],c=(16777215&(a<<r|n)).toString(16);n=a>>>24-r&16777215,(r+=2)>=26&&(r-=26,o--),i=0!==n||o!==this.length-1?d[6-c.length]+c+i:c+i}for(0!==n&&(i=n.toString(16)+i);i.length%t!==0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}if(e===(0|e)&&e>=2&&e<=36){var h=l[e],p=u[e];i="";var f=this.clone();for(f.negative=0;!f.isZero();){var g=f.modn(p).toString(e);i=(f=f.idivn(p)).isZero()?g+i:d[h-g.length]+g+i}for(this.isZero()&&(i="0"+i);i.length%t!==0;)i="0"+i;return 0!==this.negative&&(i="-"+i),i}s(!1,"Base should be between 2 and 36")},n.prototype.toNumber=function(){var e=this.words[0];return 2===this.length?e+=67108864*this.words[1]:3===this.length&&1===this.words[2]?e+=4503599627370496+67108864*this.words[1]:this.length>2&&s(!1,"Number can only safely store up to 53 bits"),0!==this.negative?-e:e},n.prototype.toJSON=function(){return this.toString(16)},n.prototype.toBuffer=function(e,t){return s(void 0!==o),this.toArrayLike(o,e,t)},n.prototype.toArray=function(e,t){return this.toArrayLike(Array,e,t)},n.prototype.toArrayLike=function(e,t,i){var r=this.byteLength(),n=i||Math.max(1,r);s(r<=n,"byte array longer than desired length"),s(n>0,"Requested array length <= 0"),this.strip();var o,a,c="le"===t,h=new e(n),d=this.clone();if(c){for(a=0;!d.isZero();a++)o=d.andln(255),d.iushrn(8),h[a]=o;for(;a<n;a++)h[a]=0}else{for(a=0;a<n-r;a++)h[a]=0;for(a=0;!d.isZero();a++)o=d.andln(255),d.iushrn(8),h[n-a-1]=o}return h},Math.clz32?n.prototype._countBits=function(e){return 32-Math.clz32(e)}:n.prototype._countBits=function(e){var t=e,i=0;return t>=4096&&(i+=13,t>>>=13),t>=64&&(i+=7,t>>>=7),t>=8&&(i+=4,t>>>=4),t>=2&&(i+=2,t>>>=2),i+t},n.prototype._zeroBits=function(e){if(0===e)return 26;var t=e,i=0;return 8191&t||(i+=13,t>>>=13),127&t||(i+=7,t>>>=7),15&t||(i+=4,t>>>=4),3&t||(i+=2,t>>>=2),1&t||i++,i},n.prototype.bitLength=function(){var e=this.words[this.length-1],t=this._countBits(e);return 26*(this.length-1)+t},n.prototype.zeroBits=function(){if(this.isZero())return 0;for(var e=0,t=0;t<this.length;t++){var i=this._zeroBits(this.words[t]);if(e+=i,26!==i)break}return e},n.prototype.byteLength=function(){return Math.ceil(this.bitLength()/8)},n.prototype.toTwos=function(e){return 0!==this.negative?this.abs().inotn(e).iaddn(1):this.clone()},n.prototype.fromTwos=function(e){return this.testn(e-1)?this.notn(e).iaddn(1).ineg():this.clone()},n.prototype.isNeg=function(){return 0!==this.negative},n.prototype.neg=function(){return this.clone().ineg()},n.prototype.ineg=function(){return this.isZero()||(this.negative^=1),this},n.prototype.iuor=function(e){for(;this.length<e.length;)this.words[this.length++]=0;for(var t=0;t<e.length;t++)this.words[t]=this.words[t]|e.words[t];return this.strip()},n.prototype.ior=function(e){return s(0===(this.negative|e.negative)),this.iuor(e)},n.prototype.or=function(e){return this.length>e.length?this.clone().ior(e):e.clone().ior(this)},n.prototype.uor=function(e){return this.length>e.length?this.clone().iuor(e):e.clone().iuor(this)},n.prototype.iuand=function(e){var t;t=this.length>e.length?e:this;for(var i=0;i<t.length;i++)this.words[i]=this.words[i]&e.words[i];return this.length=t.length,this.strip()},n.prototype.iand=function(e){return s(0===(this.negative|e.negative)),this.iuand(e)},n.prototype.and=function(e){return this.length>e.length?this.clone().iand(e):e.clone().iand(this)},n.prototype.uand=function(e){return this.length>e.length?this.clone().iuand(e):e.clone().iuand(this)},n.prototype.iuxor=function(e){var t,i;this.length>e.length?(t=this,i=e):(t=e,i=this);for(var s=0;s<i.length;s++)this.words[s]=t.words[s]^i.words[s];if(this!==t)for(;s<t.length;s++)this.words[s]=t.words[s];return this.length=t.length,this.strip()},n.prototype.ixor=function(e){return s(0===(this.negative|e.negative)),this.iuxor(e)},n.prototype.xor=function(e){return this.length>e.length?this.clone().ixor(e):e.clone().ixor(this)},n.prototype.uxor=function(e){return this.length>e.length?this.clone().iuxor(e):e.clone().iuxor(this)},n.prototype.inotn=function(e){s("number"==typeof e&&e>=0);var t=0|Math.ceil(e/26),i=e%26;this._expand(t),i>0&&t--;for(var r=0;r<t;r++)this.words[r]=67108863&~this.words[r];return i>0&&(this.words[r]=~this.words[r]&67108863>>26-i),this.strip()},n.prototype.notn=function(e){return this.clone().inotn(e)},n.prototype.setn=function(e,t){s("number"==typeof e&&e>=0);var i=e/26|0,r=e%26;return this._expand(i+1),this.words[i]=t?this.words[i]|1<<r:this.words[i]&~(1<<r),this.strip()},n.prototype.iadd=function(e){var t,i,s;if(0!==this.negative&&0===e.negative)return this.negative=0,t=this.isub(e),this.negative^=1,this._normSign();if(0===this.negative&&0!==e.negative)return e.negative=0,t=this.isub(e),e.negative=1,t._normSign();this.length>e.length?(i=this,s=e):(i=e,s=this);for(var r=0,n=0;n<s.length;n++)t=(0|i.words[n])+(0|s.words[n])+r,this.words[n]=67108863&t,r=t>>>26;for(;0!==r&&n<i.length;n++)t=(0|i.words[n])+r,this.words[n]=67108863&t,r=t>>>26;if(this.length=i.length,0!==r)this.words[this.length]=r,this.length++;else if(i!==this)for(;n<i.length;n++)this.words[n]=i.words[n];return this},n.prototype.add=function(e){var t;return 0!==e.negative&&0===this.negative?(e.negative=0,t=this.sub(e),e.negative^=1,t):0===e.negative&&0!==this.negative?(this.negative=0,t=e.sub(this),this.negative=1,t):this.length>e.length?this.clone().iadd(e):e.clone().iadd(this)},n.prototype.isub=function(e){if(0!==e.negative){e.negative=0;var t=this.iadd(e);return e.negative=1,t._normSign()}if(0!==this.negative)return this.negative=0,this.iadd(e),this.negative=1,this._normSign();var i,s,r=this.cmp(e);if(0===r)return this.negative=0,this.length=1,this.words[0]=0,this;r>0?(i=this,s=e):(i=e,s=this);for(var n=0,o=0;o<s.length;o++)n=(t=(0|i.words[o])-(0|s.words[o])+n)>>26,this.words[o]=67108863&t;for(;0!==n&&o<i.length;o++)n=(t=(0|i.words[o])+n)>>26,this.words[o]=67108863&t;if(0===n&&o<i.length&&i!==this)for(;o<i.length;o++)this.words[o]=i.words[o];return this.length=Math.max(this.length,o),i!==this&&(this.negative=1),this.strip()},n.prototype.sub=function(e){return this.clone().isub(e)};var f=function(e,t,i){var s,r,n,o=e.words,a=t.words,c=i.words,h=0,d=0|o[0],l=8191&d,u=d>>>13,p=0|o[1],f=8191&p,g=p>>>13,m=0|o[2],b=8191&m,y=m>>>13,w=0|o[3],v=8191&w,I=w>>>13,E=0|o[4],_=8191&E,A=E>>>13,N=0|o[5],C=8191&N,S=N>>>13,P=0|o[6],O=8191&P,T=P>>>13,x=0|o[7],k=8191&x,R=x>>>13,M=0|o[8],U=8191&M,D=M>>>13,j=0|o[9],L=8191&j,q=j>>>13,$=0|a[0],B=8191&$,z=$>>>13,H=0|a[1],W=8191&H,V=H>>>13,F=0|a[2],K=8191&F,G=F>>>13,J=0|a[3],Y=8191&J,X=J>>>13,Q=0|a[4],Z=8191&Q,ee=Q>>>13,te=0|a[5],ie=8191&te,se=te>>>13,re=0|a[6],ne=8191&re,oe=re>>>13,ae=0|a[7],ce=8191&ae,he=ae>>>13,de=0|a[8],le=8191&de,ue=de>>>13,pe=0|a[9],fe=8191&pe,ge=pe>>>13;i.negative=e.negative^t.negative,i.length=19;var me=(h+(s=Math.imul(l,B))|0)+((8191&(r=(r=Math.imul(l,z))+Math.imul(u,B)|0))<<13)|0;h=((n=Math.imul(u,z))+(r>>>13)|0)+(me>>>26)|0,me&=67108863,s=Math.imul(f,B),r=(r=Math.imul(f,z))+Math.imul(g,B)|0,n=Math.imul(g,z);var be=(h+(s=s+Math.imul(l,W)|0)|0)+((8191&(r=(r=r+Math.imul(l,V)|0)+Math.imul(u,W)|0))<<13)|0;h=((n=n+Math.imul(u,V)|0)+(r>>>13)|0)+(be>>>26)|0,be&=67108863,s=Math.imul(b,B),r=(r=Math.imul(b,z))+Math.imul(y,B)|0,n=Math.imul(y,z),s=s+Math.imul(f,W)|0,r=(r=r+Math.imul(f,V)|0)+Math.imul(g,W)|0,n=n+Math.imul(g,V)|0;var ye=(h+(s=s+Math.imul(l,K)|0)|0)+((8191&(r=(r=r+Math.imul(l,G)|0)+Math.imul(u,K)|0))<<13)|0;h=((n=n+Math.imul(u,G)|0)+(r>>>13)|0)+(ye>>>26)|0,ye&=67108863,s=Math.imul(v,B),r=(r=Math.imul(v,z))+Math.imul(I,B)|0,n=Math.imul(I,z),s=s+Math.imul(b,W)|0,r=(r=r+Math.imul(b,V)|0)+Math.imul(y,W)|0,n=n+Math.imul(y,V)|0,s=s+Math.imul(f,K)|0,r=(r=r+Math.imul(f,G)|0)+Math.imul(g,K)|0,n=n+Math.imul(g,G)|0;var we=(h+(s=s+Math.imul(l,Y)|0)|0)+((8191&(r=(r=r+Math.imul(l,X)|0)+Math.imul(u,Y)|0))<<13)|0;h=((n=n+Math.imul(u,X)|0)+(r>>>13)|0)+(we>>>26)|0,we&=67108863,s=Math.imul(_,B),r=(r=Math.imul(_,z))+Math.imul(A,B)|0,n=Math.imul(A,z),s=s+Math.imul(v,W)|0,r=(r=r+Math.imul(v,V)|0)+Math.imul(I,W)|0,n=n+Math.imul(I,V)|0,s=s+Math.imul(b,K)|0,r=(r=r+Math.imul(b,G)|0)+Math.imul(y,K)|0,n=n+Math.imul(y,G)|0,s=s+Math.imul(f,Y)|0,r=(r=r+Math.imul(f,X)|0)+Math.imul(g,Y)|0,n=n+Math.imul(g,X)|0;var ve=(h+(s=s+Math.imul(l,Z)|0)|0)+((8191&(r=(r=r+Math.imul(l,ee)|0)+Math.imul(u,Z)|0))<<13)|0;h=((n=n+Math.imul(u,ee)|0)+(r>>>13)|0)+(ve>>>26)|0,ve&=67108863,s=Math.imul(C,B),r=(r=Math.imul(C,z))+Math.imul(S,B)|0,n=Math.imul(S,z),s=s+Math.imul(_,W)|0,r=(r=r+Math.imul(_,V)|0)+Math.imul(A,W)|0,n=n+Math.imul(A,V)|0,s=s+Math.imul(v,K)|0,r=(r=r+Math.imul(v,G)|0)+Math.imul(I,K)|0,n=n+Math.imul(I,G)|0,s=s+Math.imul(b,Y)|0,r=(r=r+Math.imul(b,X)|0)+Math.imul(y,Y)|0,n=n+Math.imul(y,X)|0,s=s+Math.imul(f,Z)|0,r=(r=r+Math.imul(f,ee)|0)+Math.imul(g,Z)|0,n=n+Math.imul(g,ee)|0;var Ie=(h+(s=s+Math.imul(l,ie)|0)|0)+((8191&(r=(r=r+Math.imul(l,se)|0)+Math.imul(u,ie)|0))<<13)|0;h=((n=n+Math.imul(u,se)|0)+(r>>>13)|0)+(Ie>>>26)|0,Ie&=67108863,s=Math.imul(O,B),r=(r=Math.imul(O,z))+Math.imul(T,B)|0,n=Math.imul(T,z),s=s+Math.imul(C,W)|0,r=(r=r+Math.imul(C,V)|0)+Math.imul(S,W)|0,n=n+Math.imul(S,V)|0,s=s+Math.imul(_,K)|0,r=(r=r+Math.imul(_,G)|0)+Math.imul(A,K)|0,n=n+Math.imul(A,G)|0,s=s+Math.imul(v,Y)|0,r=(r=r+Math.imul(v,X)|0)+Math.imul(I,Y)|0,n=n+Math.imul(I,X)|0,s=s+Math.imul(b,Z)|0,r=(r=r+Math.imul(b,ee)|0)+Math.imul(y,Z)|0,n=n+Math.imul(y,ee)|0,s=s+Math.imul(f,ie)|0,r=(r=r+Math.imul(f,se)|0)+Math.imul(g,ie)|0,n=n+Math.imul(g,se)|0;var Ee=(h+(s=s+Math.imul(l,ne)|0)|0)+((8191&(r=(r=r+Math.imul(l,oe)|0)+Math.imul(u,ne)|0))<<13)|0;h=((n=n+Math.imul(u,oe)|0)+(r>>>13)|0)+(Ee>>>26)|0,Ee&=67108863,s=Math.imul(k,B),r=(r=Math.imul(k,z))+Math.imul(R,B)|0,n=Math.imul(R,z),s=s+Math.imul(O,W)|0,r=(r=r+Math.imul(O,V)|0)+Math.imul(T,W)|0,n=n+Math.imul(T,V)|0,s=s+Math.imul(C,K)|0,r=(r=r+Math.imul(C,G)|0)+Math.imul(S,K)|0,n=n+Math.imul(S,G)|0,s=s+Math.imul(_,Y)|0,r=(r=r+Math.imul(_,X)|0)+Math.imul(A,Y)|0,n=n+Math.imul(A,X)|0,s=s+Math.imul(v,Z)|0,r=(r=r+Math.imul(v,ee)|0)+Math.imul(I,Z)|0,n=n+Math.imul(I,ee)|0,s=s+Math.imul(b,ie)|0,r=(r=r+Math.imul(b,se)|0)+Math.imul(y,ie)|0,n=n+Math.imul(y,se)|0,s=s+Math.imul(f,ne)|0,r=(r=r+Math.imul(f,oe)|0)+Math.imul(g,ne)|0,n=n+Math.imul(g,oe)|0;var _e=(h+(s=s+Math.imul(l,ce)|0)|0)+((8191&(r=(r=r+Math.imul(l,he)|0)+Math.imul(u,ce)|0))<<13)|0;h=((n=n+Math.imul(u,he)|0)+(r>>>13)|0)+(_e>>>26)|0,_e&=67108863,s=Math.imul(U,B),r=(r=Math.imul(U,z))+Math.imul(D,B)|0,n=Math.imul(D,z),s=s+Math.imul(k,W)|0,r=(r=r+Math.imul(k,V)|0)+Math.imul(R,W)|0,n=n+Math.imul(R,V)|0,s=s+Math.imul(O,K)|0,r=(r=r+Math.imul(O,G)|0)+Math.imul(T,K)|0,n=n+Math.imul(T,G)|0,s=s+Math.imul(C,Y)|0,r=(r=r+Math.imul(C,X)|0)+Math.imul(S,Y)|0,n=n+Math.imul(S,X)|0,s=s+Math.imul(_,Z)|0,r=(r=r+Math.imul(_,ee)|0)+Math.imul(A,Z)|0,n=n+Math.imul(A,ee)|0,s=s+Math.imul(v,ie)|0,r=(r=r+Math.imul(v,se)|0)+Math.imul(I,ie)|0,n=n+Math.imul(I,se)|0,s=s+Math.imul(b,ne)|0,r=(r=r+Math.imul(b,oe)|0)+Math.imul(y,ne)|0,n=n+Math.imul(y,oe)|0,s=s+Math.imul(f,ce)|0,r=(r=r+Math.imul(f,he)|0)+Math.imul(g,ce)|0,n=n+Math.imul(g,he)|0;var Ae=(h+(s=s+Math.imul(l,le)|0)|0)+((8191&(r=(r=r+Math.imul(l,ue)|0)+Math.imul(u,le)|0))<<13)|0;h=((n=n+Math.imul(u,ue)|0)+(r>>>13)|0)+(Ae>>>26)|0,Ae&=67108863,s=Math.imul(L,B),r=(r=Math.imul(L,z))+Math.imul(q,B)|0,n=Math.imul(q,z),s=s+Math.imul(U,W)|0,r=(r=r+Math.imul(U,V)|0)+Math.imul(D,W)|0,n=n+Math.imul(D,V)|0,s=s+Math.imul(k,K)|0,r=(r=r+Math.imul(k,G)|0)+Math.imul(R,K)|0,n=n+Math.imul(R,G)|0,s=s+Math.imul(O,Y)|0,r=(r=r+Math.imul(O,X)|0)+Math.imul(T,Y)|0,n=n+Math.imul(T,X)|0,s=s+Math.imul(C,Z)|0,r=(r=r+Math.imul(C,ee)|0)+Math.imul(S,Z)|0,n=n+Math.imul(S,ee)|0,s=s+Math.imul(_,ie)|0,r=(r=r+Math.imul(_,se)|0)+Math.imul(A,ie)|0,n=n+Math.imul(A,se)|0,s=s+Math.imul(v,ne)|0,r=(r=r+Math.imul(v,oe)|0)+Math.imul(I,ne)|0,n=n+Math.imul(I,oe)|0,s=s+Math.imul(b,ce)|0,r=(r=r+Math.imul(b,he)|0)+Math.imul(y,ce)|0,n=n+Math.imul(y,he)|0,s=s+Math.imul(f,le)|0,r=(r=r+Math.imul(f,ue)|0)+Math.imul(g,le)|0,n=n+Math.imul(g,ue)|0;var Ne=(h+(s=s+Math.imul(l,fe)|0)|0)+((8191&(r=(r=r+Math.imul(l,ge)|0)+Math.imul(u,fe)|0))<<13)|0;h=((n=n+Math.imul(u,ge)|0)+(r>>>13)|0)+(Ne>>>26)|0,Ne&=67108863,s=Math.imul(L,W),r=(r=Math.imul(L,V))+Math.imul(q,W)|0,n=Math.imul(q,V),s=s+Math.imul(U,K)|0,r=(r=r+Math.imul(U,G)|0)+Math.imul(D,K)|0,n=n+Math.imul(D,G)|0,s=s+Math.imul(k,Y)|0,r=(r=r+Math.imul(k,X)|0)+Math.imul(R,Y)|0,n=n+Math.imul(R,X)|0,s=s+Math.imul(O,Z)|0,r=(r=r+Math.imul(O,ee)|0)+Math.imul(T,Z)|0,n=n+Math.imul(T,ee)|0,s=s+Math.imul(C,ie)|0,r=(r=r+Math.imul(C,se)|0)+Math.imul(S,ie)|0,n=n+Math.imul(S,se)|0,s=s+Math.imul(_,ne)|0,r=(r=r+Math.imul(_,oe)|0)+Math.imul(A,ne)|0,n=n+Math.imul(A,oe)|0,s=s+Math.imul(v,ce)|0,r=(r=r+Math.imul(v,he)|0)+Math.imul(I,ce)|0,n=n+Math.imul(I,he)|0,s=s+Math.imul(b,le)|0,r=(r=r+Math.imul(b,ue)|0)+Math.imul(y,le)|0,n=n+Math.imul(y,ue)|0;var Ce=(h+(s=s+Math.imul(f,fe)|0)|0)+((8191&(r=(r=r+Math.imul(f,ge)|0)+Math.imul(g,fe)|0))<<13)|0;h=((n=n+Math.imul(g,ge)|0)+(r>>>13)|0)+(Ce>>>26)|0,Ce&=67108863,s=Math.imul(L,K),r=(r=Math.imul(L,G))+Math.imul(q,K)|0,n=Math.imul(q,G),s=s+Math.imul(U,Y)|0,r=(r=r+Math.imul(U,X)|0)+Math.imul(D,Y)|0,n=n+Math.imul(D,X)|0,s=s+Math.imul(k,Z)|0,r=(r=r+Math.imul(k,ee)|0)+Math.imul(R,Z)|0,n=n+Math.imul(R,ee)|0,s=s+Math.imul(O,ie)|0,r=(r=r+Math.imul(O,se)|0)+Math.imul(T,ie)|0,n=n+Math.imul(T,se)|0,s=s+Math.imul(C,ne)|0,r=(r=r+Math.imul(C,oe)|0)+Math.imul(S,ne)|0,n=n+Math.imul(S,oe)|0,s=s+Math.imul(_,ce)|0,r=(r=r+Math.imul(_,he)|0)+Math.imul(A,ce)|0,n=n+Math.imul(A,he)|0,s=s+Math.imul(v,le)|0,r=(r=r+Math.imul(v,ue)|0)+Math.imul(I,le)|0,n=n+Math.imul(I,ue)|0;var Se=(h+(s=s+Math.imul(b,fe)|0)|0)+((8191&(r=(r=r+Math.imul(b,ge)|0)+Math.imul(y,fe)|0))<<13)|0;h=((n=n+Math.imul(y,ge)|0)+(r>>>13)|0)+(Se>>>26)|0,Se&=67108863,s=Math.imul(L,Y),r=(r=Math.imul(L,X))+Math.imul(q,Y)|0,n=Math.imul(q,X),s=s+Math.imul(U,Z)|0,r=(r=r+Math.imul(U,ee)|0)+Math.imul(D,Z)|0,n=n+Math.imul(D,ee)|0,s=s+Math.imul(k,ie)|0,r=(r=r+Math.imul(k,se)|0)+Math.imul(R,ie)|0,n=n+Math.imul(R,se)|0,s=s+Math.imul(O,ne)|0,r=(r=r+Math.imul(O,oe)|0)+Math.imul(T,ne)|0,n=n+Math.imul(T,oe)|0,s=s+Math.imul(C,ce)|0,r=(r=r+Math.imul(C,he)|0)+Math.imul(S,ce)|0,n=n+Math.imul(S,he)|0,s=s+Math.imul(_,le)|0,r=(r=r+Math.imul(_,ue)|0)+Math.imul(A,le)|0,n=n+Math.imul(A,ue)|0;var Pe=(h+(s=s+Math.imul(v,fe)|0)|0)+((8191&(r=(r=r+Math.imul(v,ge)|0)+Math.imul(I,fe)|0))<<13)|0;h=((n=n+Math.imul(I,ge)|0)+(r>>>13)|0)+(Pe>>>26)|0,Pe&=67108863,s=Math.imul(L,Z),r=(r=Math.imul(L,ee))+Math.imul(q,Z)|0,n=Math.imul(q,ee),s=s+Math.imul(U,ie)|0,r=(r=r+Math.imul(U,se)|0)+Math.imul(D,ie)|0,n=n+Math.imul(D,se)|0,s=s+Math.imul(k,ne)|0,r=(r=r+Math.imul(k,oe)|0)+Math.imul(R,ne)|0,n=n+Math.imul(R,oe)|0,s=s+Math.imul(O,ce)|0,r=(r=r+Math.imul(O,he)|0)+Math.imul(T,ce)|0,n=n+Math.imul(T,he)|0,s=s+Math.imul(C,le)|0,r=(r=r+Math.imul(C,ue)|0)+Math.imul(S,le)|0,n=n+Math.imul(S,ue)|0;var Oe=(h+(s=s+Math.imul(_,fe)|0)|0)+((8191&(r=(r=r+Math.imul(_,ge)|0)+Math.imul(A,fe)|0))<<13)|0;h=((n=n+Math.imul(A,ge)|0)+(r>>>13)|0)+(Oe>>>26)|0,Oe&=67108863,s=Math.imul(L,ie),r=(r=Math.imul(L,se))+Math.imul(q,ie)|0,n=Math.imul(q,se),s=s+Math.imul(U,ne)|0,r=(r=r+Math.imul(U,oe)|0)+Math.imul(D,ne)|0,n=n+Math.imul(D,oe)|0,s=s+Math.imul(k,ce)|0,r=(r=r+Math.imul(k,he)|0)+Math.imul(R,ce)|0,n=n+Math.imul(R,he)|0,s=s+Math.imul(O,le)|0,r=(r=r+Math.imul(O,ue)|0)+Math.imul(T,le)|0,n=n+Math.imul(T,ue)|0;var Te=(h+(s=s+Math.imul(C,fe)|0)|0)+((8191&(r=(r=r+Math.imul(C,ge)|0)+Math.imul(S,fe)|0))<<13)|0;h=((n=n+Math.imul(S,ge)|0)+(r>>>13)|0)+(Te>>>26)|0,Te&=67108863,s=Math.imul(L,ne),r=(r=Math.imul(L,oe))+Math.imul(q,ne)|0,n=Math.imul(q,oe),s=s+Math.imul(U,ce)|0,r=(r=r+Math.imul(U,he)|0)+Math.imul(D,ce)|0,n=n+Math.imul(D,he)|0,s=s+Math.imul(k,le)|0,r=(r=r+Math.imul(k,ue)|0)+Math.imul(R,le)|0,n=n+Math.imul(R,ue)|0;var xe=(h+(s=s+Math.imul(O,fe)|0)|0)+((8191&(r=(r=r+Math.imul(O,ge)|0)+Math.imul(T,fe)|0))<<13)|0;h=((n=n+Math.imul(T,ge)|0)+(r>>>13)|0)+(xe>>>26)|0,xe&=67108863,s=Math.imul(L,ce),r=(r=Math.imul(L,he))+Math.imul(q,ce)|0,n=Math.imul(q,he),s=s+Math.imul(U,le)|0,r=(r=r+Math.imul(U,ue)|0)+Math.imul(D,le)|0,n=n+Math.imul(D,ue)|0;var ke=(h+(s=s+Math.imul(k,fe)|0)|0)+((8191&(r=(r=r+Math.imul(k,ge)|0)+Math.imul(R,fe)|0))<<13)|0;h=((n=n+Math.imul(R,ge)|0)+(r>>>13)|0)+(ke>>>26)|0,ke&=67108863,s=Math.imul(L,le),r=(r=Math.imul(L,ue))+Math.imul(q,le)|0,n=Math.imul(q,ue);var Re=(h+(s=s+Math.imul(U,fe)|0)|0)+((8191&(r=(r=r+Math.imul(U,ge)|0)+Math.imul(D,fe)|0))<<13)|0;h=((n=n+Math.imul(D,ge)|0)+(r>>>13)|0)+(Re>>>26)|0,Re&=67108863;var Me=(h+(s=Math.imul(L,fe))|0)+((8191&(r=(r=Math.imul(L,ge))+Math.imul(q,fe)|0))<<13)|0;return h=((n=Math.imul(q,ge))+(r>>>13)|0)+(Me>>>26)|0,Me&=67108863,c[0]=me,c[1]=be,c[2]=ye,c[3]=we,c[4]=ve,c[5]=Ie,c[6]=Ee,c[7]=_e,c[8]=Ae,c[9]=Ne,c[10]=Ce,c[11]=Se,c[12]=Pe,c[13]=Oe,c[14]=Te,c[15]=xe,c[16]=ke,c[17]=Re,c[18]=Me,0!==h&&(c[19]=h,i.length++),i};function g(e,t,i){return(new m).mulp(e,t,i)}function m(e,t){this.x=e,this.y=t}Math.imul||(f=p),n.prototype.mulTo=function(e,t){var i,s=this.length+e.length;return i=10===this.length&&10===e.length?f(this,e,t):s<63?p(this,e,t):s<1024?function(e,t,i){i.negative=t.negative^e.negative,i.length=e.length+t.length;for(var s=0,r=0,n=0;n<i.length-1;n++){var o=r;r=0;for(var a=67108863&s,c=Math.min(n,t.length-1),h=Math.max(0,n-e.length+1);h<=c;h++){var d=n-h,l=(0|e.words[d])*(0|t.words[h]),u=67108863&l;a=67108863&(u=u+a|0),r+=(o=(o=o+(l/67108864|0)|0)+(u>>>26)|0)>>>26,o&=67108863}i.words[n]=a,s=o,o=r}return 0!==s?i.words[n]=s:i.length--,i.strip()}(this,e,t):g(this,e,t),i},m.prototype.makeRBT=function(e){for(var t=new Array(e),i=n.prototype._countBits(e)-1,s=0;s<e;s++)t[s]=this.revBin(s,i,e);return t},m.prototype.revBin=function(e,t,i){if(0===e||e===i-1)return e;for(var s=0,r=0;r<t;r++)s|=(1&e)<<t-r-1,e>>=1;return s},m.prototype.permute=function(e,t,i,s,r,n){for(var o=0;o<n;o++)s[o]=t[e[o]],r[o]=i[e[o]]},m.prototype.transform=function(e,t,i,s,r,n){this.permute(n,e,t,i,s,r);for(var o=1;o<r;o<<=1)for(var a=o<<1,c=Math.cos(2*Math.PI/a),h=Math.sin(2*Math.PI/a),d=0;d<r;d+=a)for(var l=c,u=h,p=0;p<o;p++){var f=i[d+p],g=s[d+p],m=i[d+p+o],b=s[d+p+o],y=l*m-u*b;b=l*b+u*m,m=y,i[d+p]=f+m,s[d+p]=g+b,i[d+p+o]=f-m,s[d+p+o]=g-b,p!==a&&(y=c*l-h*u,u=c*u+h*l,l=y)}},m.prototype.guessLen13b=function(e,t){var i=1|Math.max(t,e),s=1&i,r=0;for(i=i/2|0;i;i>>>=1)r++;return 1<<r+1+s},m.prototype.conjugate=function(e,t,i){if(!(i<=1))for(var s=0;s<i/2;s++){var r=e[s];e[s]=e[i-s-1],e[i-s-1]=r,r=t[s],t[s]=-t[i-s-1],t[i-s-1]=-r}},m.prototype.normalize13b=function(e,t){for(var i=0,s=0;s<t/2;s++){var r=8192*Math.round(e[2*s+1]/t)+Math.round(e[2*s]/t)+i;e[s]=67108863&r,i=r<67108864?0:r/67108864|0}return e},m.prototype.convert13b=function(e,t,i,r){for(var n=0,o=0;o<t;o++)n+=0|e[o],i[2*o]=8191&n,n>>>=13,i[2*o+1]=8191&n,n>>>=13;for(o=2*t;o<r;++o)i[o]=0;s(0===n),s(!(-8192&n))},m.prototype.stub=function(e){for(var t=new Array(e),i=0;i<e;i++)t[i]=0;return t},m.prototype.mulp=function(e,t,i){var s=2*this.guessLen13b(e.length,t.length),r=this.makeRBT(s),n=this.stub(s),o=new Array(s),a=new Array(s),c=new Array(s),h=new Array(s),d=new Array(s),l=new Array(s),u=i.words;u.length=s,this.convert13b(e.words,e.length,o,s),this.convert13b(t.words,t.length,h,s),this.transform(o,n,a,c,s,r),this.transform(h,n,d,l,s,r);for(var p=0;p<s;p++){var f=a[p]*d[p]-c[p]*l[p];c[p]=a[p]*l[p]+c[p]*d[p],a[p]=f}return this.conjugate(a,c,s),this.transform(a,c,u,n,s,r),this.conjugate(u,n,s),this.normalize13b(u,s),i.negative=e.negative^t.negative,i.length=e.length+t.length,i.strip()},n.prototype.mul=function(e){var t=new n(null);return t.words=new Array(this.length+e.length),this.mulTo(e,t)},n.prototype.mulf=function(e){var t=new n(null);return t.words=new Array(this.length+e.length),g(this,e,t)},n.prototype.imul=function(e){return this.clone().mulTo(e,this)},n.prototype.imuln=function(e){s("number"==typeof e),s(e<67108864);for(var t=0,i=0;i<this.length;i++){var r=(0|this.words[i])*e,n=(67108863&r)+(67108863&t);t>>=26,t+=r/67108864|0,t+=n>>>26,this.words[i]=67108863&n}return 0!==t&&(this.words[i]=t,this.length++),this.length=0===e?1:this.length,this},n.prototype.muln=function(e){return this.clone().imuln(e)},n.prototype.sqr=function(){return this.mul(this)},n.prototype.isqr=function(){return this.imul(this.clone())},n.prototype.pow=function(e){var t=function(e){for(var t=new Array(e.bitLength()),i=0;i<t.length;i++){var s=i/26|0,r=i%26;t[i]=(e.words[s]&1<<r)>>>r}return t}(e);if(0===t.length)return new n(1);for(var i=this,s=0;s<t.length&&0===t[s];s++,i=i.sqr());if(++s<t.length)for(var r=i.sqr();s<t.length;s++,r=r.sqr())0!==t[s]&&(i=i.mul(r));return i},n.prototype.iushln=function(e){s("number"==typeof e&&e>=0);var t,i=e%26,r=(e-i)/26,n=67108863>>>26-i<<26-i;if(0!==i){var o=0;for(t=0;t<this.length;t++){var a=this.words[t]&n,c=(0|this.words[t])-a<<i;this.words[t]=c|o,o=a>>>26-i}o&&(this.words[t]=o,this.length++)}if(0!==r){for(t=this.length-1;t>=0;t--)this.words[t+r]=this.words[t];for(t=0;t<r;t++)this.words[t]=0;this.length+=r}return this.strip()},n.prototype.ishln=function(e){return s(0===this.negative),this.iushln(e)},n.prototype.iushrn=function(e,t,i){var r;s("number"==typeof e&&e>=0),r=t?(t-t%26)/26:0;var n=e%26,o=Math.min((e-n)/26,this.length),a=67108863^67108863>>>n<<n,c=i;if(r-=o,r=Math.max(0,r),c){for(var h=0;h<o;h++)c.words[h]=this.words[h];c.length=o}if(0===o);else if(this.length>o)for(this.length-=o,h=0;h<this.length;h++)this.words[h]=this.words[h+o];else this.words[0]=0,this.length=1;var d=0;for(h=this.length-1;h>=0&&(0!==d||h>=r);h--){var l=0|this.words[h];this.words[h]=d<<26-n|l>>>n,d=l&a}return c&&0!==d&&(c.words[c.length++]=d),0===this.length&&(this.words[0]=0,this.length=1),this.strip()},n.prototype.ishrn=function(e,t,i){return s(0===this.negative),this.iushrn(e,t,i)},n.prototype.shln=function(e){return this.clone().ishln(e)},n.prototype.ushln=function(e){return this.clone().iushln(e)},n.prototype.shrn=function(e){return this.clone().ishrn(e)},n.prototype.ushrn=function(e){return this.clone().iushrn(e)},n.prototype.testn=function(e){s("number"==typeof e&&e>=0);var t=e%26,i=(e-t)/26,r=1<<t;return!(this.length<=i||!(this.words[i]&r))},n.prototype.imaskn=function(e){s("number"==typeof e&&e>=0);var t=e%26,i=(e-t)/26;if(s(0===this.negative,"imaskn works only with positive numbers"),this.length<=i)return this;if(0!==t&&i++,this.length=Math.min(i,this.length),0!==t){var r=67108863^67108863>>>t<<t;this.words[this.length-1]&=r}return this.strip()},n.prototype.maskn=function(e){return this.clone().imaskn(e)},n.prototype.iaddn=function(e){return s("number"==typeof e),s(e<67108864),e<0?this.isubn(-e):0!==this.negative?1===this.length&&(0|this.words[0])<e?(this.words[0]=e-(0|this.words[0]),this.negative=0,this):(this.negative=0,this.isubn(e),this.negative=1,this):this._iaddn(e)},n.prototype._iaddn=function(e){this.words[0]+=e;for(var t=0;t<this.length&&this.words[t]>=67108864;t++)this.words[t]-=67108864,t===this.length-1?this.words[t+1]=1:this.words[t+1]++;return this.length=Math.max(this.length,t+1),this},n.prototype.isubn=function(e){if(s("number"==typeof e),s(e<67108864),e<0)return this.iaddn(-e);if(0!==this.negative)return this.negative=0,this.iaddn(e),this.negative=1,this;if(this.words[0]-=e,1===this.length&&this.words[0]<0)this.words[0]=-this.words[0],this.negative=1;else for(var t=0;t<this.length&&this.words[t]<0;t++)this.words[t]+=67108864,this.words[t+1]-=1;return this.strip()},n.prototype.addn=function(e){return this.clone().iaddn(e)},n.prototype.subn=function(e){return this.clone().isubn(e)},n.prototype.iabs=function(){return this.negative=0,this},n.prototype.abs=function(){return this.clone().iabs()},n.prototype._ishlnsubmul=function(e,t,i){var r,n,o=e.length+i;this._expand(o);var a=0;for(r=0;r<e.length;r++){n=(0|this.words[r+i])+a;var c=(0|e.words[r])*t;a=((n-=67108863&c)>>26)-(c/67108864|0),this.words[r+i]=67108863&n}for(;r<this.length-i;r++)a=(n=(0|this.words[r+i])+a)>>26,this.words[r+i]=67108863&n;if(0===a)return this.strip();for(s(-1===a),a=0,r=0;r<this.length;r++)a=(n=-(0|this.words[r])+a)>>26,this.words[r]=67108863&n;return this.negative=1,this.strip()},n.prototype._wordDiv=function(e,t){var i=(this.length,e.length),s=this.clone(),r=e,o=0|r.words[r.length-1];0!=(i=26-this._countBits(o))&&(r=r.ushln(i),s.iushln(i),o=0|r.words[r.length-1]);var a,c=s.length-r.length;if("mod"!==t){(a=new n(null)).length=c+1,a.words=new Array(a.length);for(var h=0;h<a.length;h++)a.words[h]=0}var d=s.clone()._ishlnsubmul(r,1,c);0===d.negative&&(s=d,a&&(a.words[c]=1));for(var l=c-1;l>=0;l--){var u=67108864*(0|s.words[r.length+l])+(0|s.words[r.length+l-1]);for(u=Math.min(u/o|0,67108863),s._ishlnsubmul(r,u,l);0!==s.negative;)u--,s.negative=0,s._ishlnsubmul(r,1,l),s.isZero()||(s.negative^=1);a&&(a.words[l]=u)}return a&&a.strip(),s.strip(),"div"!==t&&0!==i&&s.iushrn(i),{div:a||null,mod:s}},n.prototype.divmod=function(e,t,i){return s(!e.isZero()),this.isZero()?{div:new n(0),mod:new n(0)}:0!==this.negative&&0===e.negative?(a=this.neg().divmod(e,t),"mod"!==t&&(r=a.div.neg()),"div"!==t&&(o=a.mod.neg(),i&&0!==o.negative&&o.iadd(e)),{div:r,mod:o}):0===this.negative&&0!==e.negative?(a=this.divmod(e.neg(),t),"mod"!==t&&(r=a.div.neg()),{div:r,mod:a.mod}):0!==(this.negative&e.negative)?(a=this.neg().divmod(e.neg(),t),"div"!==t&&(o=a.mod.neg(),i&&0!==o.negative&&o.isub(e)),{div:a.div,mod:o}):e.length>this.length||this.cmp(e)<0?{div:new n(0),mod:this}:1===e.length?"div"===t?{div:this.divn(e.words[0]),mod:null}:"mod"===t?{div:null,mod:new n(this.modn(e.words[0]))}:{div:this.divn(e.words[0]),mod:new n(this.modn(e.words[0]))}:this._wordDiv(e,t);var r,o,a},n.prototype.div=function(e){return this.divmod(e,"div",!1).div},n.prototype.mod=function(e){return this.divmod(e,"mod",!1).mod},n.prototype.umod=function(e){return this.divmod(e,"mod",!0).mod},n.prototype.divRound=function(e){var t=this.divmod(e);if(t.mod.isZero())return t.div;var i=0!==t.div.negative?t.mod.isub(e):t.mod,s=e.ushrn(1),r=e.andln(1),n=i.cmp(s);return n<0||1===r&&0===n?t.div:0!==t.div.negative?t.div.isubn(1):t.div.iaddn(1)},n.prototype.modn=function(e){s(e<=67108863);for(var t=(1<<26)%e,i=0,r=this.length-1;r>=0;r--)i=(t*i+(0|this.words[r]))%e;return i},n.prototype.idivn=function(e){s(e<=67108863);for(var t=0,i=this.length-1;i>=0;i--){var r=(0|this.words[i])+67108864*t;this.words[i]=r/e|0,t=r%e}return this.strip()},n.prototype.divn=function(e){return this.clone().idivn(e)},n.prototype.egcd=function(e){s(0===e.negative),s(!e.isZero());var t=this,i=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r=new n(1),o=new n(0),a=new n(0),c=new n(1),h=0;t.isEven()&&i.isEven();)t.iushrn(1),i.iushrn(1),++h;for(var d=i.clone(),l=t.clone();!t.isZero();){for(var u=0,p=1;0===(t.words[0]&p)&&u<26;++u,p<<=1);if(u>0)for(t.iushrn(u);u-- >0;)(r.isOdd()||o.isOdd())&&(r.iadd(d),o.isub(l)),r.iushrn(1),o.iushrn(1);for(var f=0,g=1;0===(i.words[0]&g)&&f<26;++f,g<<=1);if(f>0)for(i.iushrn(f);f-- >0;)(a.isOdd()||c.isOdd())&&(a.iadd(d),c.isub(l)),a.iushrn(1),c.iushrn(1);t.cmp(i)>=0?(t.isub(i),r.isub(a),o.isub(c)):(i.isub(t),a.isub(r),c.isub(o))}return{a,b:c,gcd:i.iushln(h)}},n.prototype._invmp=function(e){s(0===e.negative),s(!e.isZero());var t=this,i=e.clone();t=0!==t.negative?t.umod(e):t.clone();for(var r,o=new n(1),a=new n(0),c=i.clone();t.cmpn(1)>0&&i.cmpn(1)>0;){for(var h=0,d=1;0===(t.words[0]&d)&&h<26;++h,d<<=1);if(h>0)for(t.iushrn(h);h-- >0;)o.isOdd()&&o.iadd(c),o.iushrn(1);for(var l=0,u=1;0===(i.words[0]&u)&&l<26;++l,u<<=1);if(l>0)for(i.iushrn(l);l-- >0;)a.isOdd()&&a.iadd(c),a.iushrn(1);t.cmp(i)>=0?(t.isub(i),o.isub(a)):(i.isub(t),a.isub(o))}return(r=0===t.cmpn(1)?o:a).cmpn(0)<0&&r.iadd(e),r},n.prototype.gcd=function(e){if(this.isZero())return e.abs();if(e.isZero())return this.abs();var t=this.clone(),i=e.clone();t.negative=0,i.negative=0;for(var s=0;t.isEven()&&i.isEven();s++)t.iushrn(1),i.iushrn(1);for(;;){for(;t.isEven();)t.iushrn(1);for(;i.isEven();)i.iushrn(1);var r=t.cmp(i);if(r<0){var n=t;t=i,i=n}else if(0===r||0===i.cmpn(1))break;t.isub(i)}return i.iushln(s)},n.prototype.invm=function(e){return this.egcd(e).a.umod(e)},n.prototype.isEven=function(){return!(1&this.words[0])},n.prototype.isOdd=function(){return!(1&~this.words[0])},n.prototype.andln=function(e){return this.words[0]&e},n.prototype.bincn=function(e){s("number"==typeof e);var t=e%26,i=(e-t)/26,r=1<<t;if(this.length<=i)return this._expand(i+1),this.words[i]|=r,this;for(var n=r,o=i;0!==n&&o<this.length;o++){var a=0|this.words[o];n=(a+=n)>>>26,a&=67108863,this.words[o]=a}return 0!==n&&(this.words[o]=n,this.length++),this},n.prototype.isZero=function(){return 1===this.length&&0===this.words[0]},n.prototype.cmpn=function(e){var t,i=e<0;if(0!==this.negative&&!i)return-1;if(0===this.negative&&i)return 1;if(this.strip(),this.length>1)t=1;else{i&&(e=-e),s(e<=67108863,"Number is too big");var r=0|this.words[0];t=r===e?0:r<e?-1:1}return 0!==this.negative?0|-t:t},n.prototype.cmp=function(e){if(0!==this.negative&&0===e.negative)return-1;if(0===this.negative&&0!==e.negative)return 1;var t=this.ucmp(e);return 0!==this.negative?0|-t:t},n.prototype.ucmp=function(e){if(this.length>e.length)return 1;if(this.length<e.length)return-1;for(var t=0,i=this.length-1;i>=0;i--){var s=0|this.words[i],r=0|e.words[i];if(s!==r){s<r?t=-1:s>r&&(t=1);break}}return t},n.prototype.gtn=function(e){return 1===this.cmpn(e)},n.prototype.gt=function(e){return 1===this.cmp(e)},n.prototype.gten=function(e){return this.cmpn(e)>=0},n.prototype.gte=function(e){return this.cmp(e)>=0},n.prototype.ltn=function(e){return-1===this.cmpn(e)},n.prototype.lt=function(e){return-1===this.cmp(e)},n.prototype.lten=function(e){return this.cmpn(e)<=0},n.prototype.lte=function(e){return this.cmp(e)<=0},n.prototype.eqn=function(e){return 0===this.cmpn(e)},n.prototype.eq=function(e){return 0===this.cmp(e)},n.red=function(e){return new _(e)},n.prototype.toRed=function(e){return s(!this.red,"Already a number in reduction context"),s(0===this.negative,"red works only with positives"),e.convertTo(this)._forceRed(e)},n.prototype.fromRed=function(){return s(this.red,"fromRed works only with numbers in reduction context"),this.red.convertFrom(this)},n.prototype._forceRed=function(e){return this.red=e,this},n.prototype.forceRed=function(e){return s(!this.red,"Already a number in reduction context"),this._forceRed(e)},n.prototype.redAdd=function(e){return s(this.red,"redAdd works only with red numbers"),this.red.add(this,e)},n.prototype.redIAdd=function(e){return s(this.red,"redIAdd works only with red numbers"),this.red.iadd(this,e)},n.prototype.redSub=function(e){return s(this.red,"redSub works only with red numbers"),this.red.sub(this,e)},n.prototype.redISub=function(e){return s(this.red,"redISub works only with red numbers"),this.red.isub(this,e)},n.prototype.redShl=function(e){return s(this.red,"redShl works only with red numbers"),this.red.shl(this,e)},n.prototype.redMul=function(e){return s(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.mul(this,e)},n.prototype.redIMul=function(e){return s(this.red,"redMul works only with red numbers"),this.red._verify2(this,e),this.red.imul(this,e)},n.prototype.redSqr=function(){return s(this.red,"redSqr works only with red numbers"),this.red._verify1(this),this.red.sqr(this)},n.prototype.redISqr=function(){return s(this.red,"redISqr works only with red numbers"),this.red._verify1(this),this.red.isqr(this)},n.prototype.redSqrt=function(){return s(this.red,"redSqrt works only with red numbers"),this.red._verify1(this),this.red.sqrt(this)},n.prototype.redInvm=function(){return s(this.red,"redInvm works only with red numbers"),this.red._verify1(this),this.red.invm(this)},n.prototype.redNeg=function(){return s(this.red,"redNeg works only with red numbers"),this.red._verify1(this),this.red.neg(this)},n.prototype.redPow=function(e){return s(this.red&&!e.red,"redPow(normalNum)"),this.red._verify1(this),this.red.pow(this,e)};var b={k256:null,p224:null,p192:null,p25519:null};function y(e,t){this.name=e,this.p=new n(t,16),this.n=this.p.bitLength(),this.k=new n(1).iushln(this.n).isub(this.p),this.tmp=this._tmp()}function w(){y.call(this,"k256","ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f")}function v(){y.call(this,"p224","ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001")}function I(){y.call(this,"p192","ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff")}function E(){y.call(this,"25519","7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed")}function _(e){if("string"==typeof e){var t=n._prime(e);this.m=t.p,this.prime=t}else s(e.gtn(1),"modulus must be greater than 1"),this.m=e,this.prime=null}function A(e){_.call(this,e),this.shift=this.m.bitLength(),this.shift%26!=0&&(this.shift+=26-this.shift%26),this.r=new n(1).iushln(this.shift),this.r2=this.imod(this.r.sqr()),this.rinv=this.r._invmp(this.m),this.minv=this.rinv.mul(this.r).isubn(1).div(this.m),this.minv=this.minv.umod(this.r),this.minv=this.r.sub(this.minv)}y.prototype._tmp=function(){var e=new n(null);return e.words=new Array(Math.ceil(this.n/13)),e},y.prototype.ireduce=function(e){var t,i=e;do{this.split(i,this.tmp),t=(i=(i=this.imulK(i)).iadd(this.tmp)).bitLength()}while(t>this.n);var s=t<this.n?-1:i.ucmp(this.p);return 0===s?(i.words[0]=0,i.length=1):s>0?i.isub(this.p):void 0!==i.strip?i.strip():i._strip(),i},y.prototype.split=function(e,t){e.iushrn(this.n,0,t)},y.prototype.imulK=function(e){return e.imul(this.k)},r(w,y),w.prototype.split=function(e,t){for(var i=4194303,s=Math.min(e.length,9),r=0;r<s;r++)t.words[r]=e.words[r];if(t.length=s,e.length<=9)return e.words[0]=0,void(e.length=1);var n=e.words[9];for(t.words[t.length++]=n&i,r=10;r<e.length;r++){var o=0|e.words[r];e.words[r-10]=(o&i)<<4|n>>>22,n=o}n>>>=22,e.words[r-10]=n,0===n&&e.length>10?e.length-=10:e.length-=9},w.prototype.imulK=function(e){e.words[e.length]=0,e.words[e.length+1]=0,e.length+=2;for(var t=0,i=0;i<e.length;i++){var s=0|e.words[i];t+=977*s,e.words[i]=67108863&t,t=64*s+(t/67108864|0)}return 0===e.words[e.length-1]&&(e.length--,0===e.words[e.length-1]&&e.length--),e},r(v,y),r(I,y),r(E,y),E.prototype.imulK=function(e){for(var t=0,i=0;i<e.length;i++){var s=19*(0|e.words[i])+t,r=67108863&s;s>>>=26,e.words[i]=r,t=s}return 0!==t&&(e.words[e.length++]=t),e},n._prime=function(e){if(b[e])return b[e];var t;if("k256"===e)t=new w;else if("p224"===e)t=new v;else if("p192"===e)t=new I;else{if("p25519"!==e)throw new Error("Unknown prime "+e);t=new E}return b[e]=t,t},_.prototype._verify1=function(e){s(0===e.negative,"red works only with positives"),s(e.red,"red works only with red numbers")},_.prototype._verify2=function(e,t){s(0===(e.negative|t.negative),"red works only with positives"),s(e.red&&e.red===t.red,"red works only with red numbers")},_.prototype.imod=function(e){return this.prime?this.prime.ireduce(e)._forceRed(this):e.umod(this.m)._forceRed(this)},_.prototype.neg=function(e){return e.isZero()?e.clone():this.m.sub(e)._forceRed(this)},_.prototype.add=function(e,t){this._verify2(e,t);var i=e.add(t);return i.cmp(this.m)>=0&&i.isub(this.m),i._forceRed(this)},_.prototype.iadd=function(e,t){this._verify2(e,t);var i=e.iadd(t);return i.cmp(this.m)>=0&&i.isub(this.m),i},_.prototype.sub=function(e,t){this._verify2(e,t);var i=e.sub(t);return i.cmpn(0)<0&&i.iadd(this.m),i._forceRed(this)},_.prototype.isub=function(e,t){this._verify2(e,t);var i=e.isub(t);return i.cmpn(0)<0&&i.iadd(this.m),i},_.prototype.shl=function(e,t){return this._verify1(e),this.imod(e.ushln(t))},_.prototype.imul=function(e,t){return this._verify2(e,t),this.imod(e.imul(t))},_.prototype.mul=function(e,t){return this._verify2(e,t),this.imod(e.mul(t))},_.prototype.isqr=function(e){return this.imul(e,e.clone())},_.prototype.sqr=function(e){return this.mul(e,e)},_.prototype.sqrt=function(e){if(e.isZero())return e.clone();var t=this.m.andln(3);if(s(t%2==1),3===t){var i=this.m.add(new n(1)).iushrn(2);return this.pow(e,i)}for(var r=this.m.subn(1),o=0;!r.isZero()&&0===r.andln(1);)o++,r.iushrn(1);s(!r.isZero());var a=new n(1).toRed(this),c=a.redNeg(),h=this.m.subn(1).iushrn(1),d=this.m.bitLength();for(d=new n(2*d*d).toRed(this);0!==this.pow(d,h).cmp(c);)d.redIAdd(c);for(var l=this.pow(d,r),u=this.pow(e,r.addn(1).iushrn(1)),p=this.pow(e,r),f=o;0!==p.cmp(a);){for(var g=p,m=0;0!==g.cmp(a);m++)g=g.redSqr();s(m<f);var b=this.pow(l,new n(1).iushln(f-m-1));u=u.redMul(b),l=b.redSqr(),p=p.redMul(l),f=m}return u},_.prototype.invm=function(e){var t=e._invmp(this.m);return 0!==t.negative?(t.negative=0,this.imod(t).redNeg()):this.imod(t)},_.prototype.pow=function(e,t){if(t.isZero())return new n(1).toRed(this);if(0===t.cmpn(1))return e.clone();var i=new Array(16);i[0]=new n(1).toRed(this),i[1]=e;for(var s=2;s<i.length;s++)i[s]=this.mul(i[s-1],e);var r=i[0],o=0,a=0,c=t.bitLength()%26;for(0===c&&(c=26),s=t.length-1;s>=0;s--){for(var h=t.words[s],d=c-1;d>=0;d--){var l=h>>d&1;r!==i[0]&&(r=this.sqr(r)),0!==l||0!==o?(o<<=1,o|=l,(4===++a||0===s&&0===d)&&(r=this.mul(r,i[o]),a=0,o=0)):a=0}c=26}return r},_.prototype.convertTo=function(e){var t=e.umod(this.m);return t===e?t.clone():t},_.prototype.convertFrom=function(e){var t=e.clone();return t.red=null,t},n.mont=function(e){return new A(e)},r(A,_),A.prototype.convertTo=function(e){return this.imod(e.ushln(this.shift))},A.prototype.convertFrom=function(e){var t=this.imod(e.mul(this.rinv));return t.red=null,t},A.prototype.imul=function(e,t){if(e.isZero()||t.isZero())return e.words[0]=0,e.length=1,e;var i=e.imul(t),s=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),r=i.isub(s).iushrn(this.shift),n=r;return r.cmp(this.m)>=0?n=r.isub(this.m):r.cmpn(0)<0&&(n=r.iadd(this.m)),n._forceRed(this)},A.prototype.mul=function(e,t){if(e.isZero()||t.isZero())return new n(0)._forceRed(this);var i=e.mul(t),s=i.maskn(this.shift).mul(this.minv).imaskn(this.shift).mul(this.m),r=i.isub(s).iushrn(this.shift),o=r;return r.cmp(this.m)>=0?o=r.isub(this.m):r.cmpn(0)<0&&(o=r.iadd(this.m)),o._forceRed(this)},A.prototype.invm=function(e){return this.imod(e._invmp(this.m).mul(this.r2))._forceRed(this)}}(e=i.nmd(e),this)},66715:(e,t,i)=>{i.d(t,{f:()=>b});var s=i(53834),r=i(73821),n=i(3834),o=i(40446),a=i(76754),c=i(48336),h=i(30544),d=i(33244),l=i(96759),u=i(84320),p=i(41276),f=i(89351),g=i(85445),m=i(48526).hp;class b{_UniversalProvider;_session;_modal;_projectId;_network;_ConnectQueueResolver;constructor(e){if(this.initClient(e.options),this._network=e.network,!e.options.projectId)throw Error("WalletConnect Adapter: Project ID is undefined");this._projectId=e.options.projectId}async connect(){if(this._UniversalProvider||await new Promise(e=>{this._ConnectQueueResolver=e}),!this._UniversalProvider)throw new Error("WalletConnect Adapter - Universal Provider was undefined while calling 'connect()'");if(this._UniversalProvider.session){this._session=this._UniversalProvider.session;const e=(0,f.hJ)(this._session,this._network);return this._network=e,this._UniversalProvider.setDefaultChain(e),{publicKey:this.publicKey}}await this.initModal();const e=(0,f.lC)(this._network);this._modal?.open();const t=new AbortController,i=t.signal;this._modal?.subscribeState(e=>{e.open||t.abort(new g.K)});try{const t=await Promise.race([this._UniversalProvider?.connect(e),new Promise((e,t)=>{i.addEventListener("abort",()=>{t(i.reason)})})]);if(this._modal?.close(),this._session=t,!t)throw new s.Y6;const r=(0,f.hJ)(t,this._network);return this._network=r,this._UniversalProvider?.setDefaultChain(r),{publicKey:this.publicKey}}catch(e){throw this._modal?.close(),e}}async disconnect(){if(!this._UniversalProvider?.session)throw new u.r;if(await this.initModal(),!this._modal)throw Error("WalletConnect Adapter -Modal is undefined: unable to disconnect");await this.client.disconnect(),this._session=void 0}get client(){if(this._UniversalProvider)return this._UniversalProvider;throw new u.r}get session(){if(!this._session)throw new u.r;return this._session}get publicKey(){if(this._UniversalProvider?.session&&this._session){const{address:e}=(0,a.cK)(this._session?.namespaces.solana?.accounts[0]??"");return new n.PublicKey(e)}throw new u.r}async signTransaction(e){this.checkIfWalletSupportsMethod(l.jD.signTransaction);const t=(0,r.Y)(e),i=t?{}:e,{signature:s,transaction:n}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:l.jD.signTransaction,params:{...i,transaction:this.serialize(e)}}});return n?this.deserialize(n,t):(e.addSignature(this.publicKey,m.from(d.A.decode(s))),e)}async signMessage(e){this.checkIfWalletSupportsMethod(l.jD.signMessage);const{signature:t}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:l.jD.signMessage,params:{pubkey:this.publicKey.toString(),message:d.A.encode(e)}}});return d.A.decode(t)}async signAndSendTransaction(e){this.checkIfWalletSupportsMethod(l.jD.signAndSendTransaction);const{signature:t}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:l.jD.signAndSendTransaction,params:{transaction:this.serialize(e)}}});return t}async signAllTransactions(e){try{this.checkIfWalletSupportsMethod(l.jD.signAllTransactions);const t=e.map(e=>this.serialize(e)),{transactions:i}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:l.jD.signAllTransactions,params:{transactions:t}}});return e.map((e,t)=>(0,r.Y)(e)?this.deserialize(i[t]??"",!0):this.deserialize(i[t]??""))}catch(t){if(t instanceof p.f){const t=e.map(e=>this.signTransaction(e));return await Promise.all(t)}throw t}}async initClient(e){const t=await o.l.init(e);this._UniversalProvider=t,this._ConnectQueueResolver&&this._ConnectQueueResolver(!0)}async initModal(){if(!this._modal){if(!this._UniversalProvider)throw new Error("WalletConnect Adapter - cannot init modal when Universal Provider is undefined");this._modal=(0,c.s)({projectId:this._projectId,universalProvider:this._UniversalProvider,networks:[h.tWt,h.Rn0,h.gTy],manualWCControl:!0})}}serialize(e){return m.from(e.serialize({verifySignatures:!1})).toString("base64")}deserialize(e,t=!1){return t?n.VersionedTransaction.deserialize(m.from(e,"base64")):n.Transaction.from(m.from(e,"base64"))}checkIfWalletSupportsMethod(e){if(!this.session.namespaces.solana?.methods.includes(e))throw new p.f(e)}}},69033:(e,t,i)=>{i.d(t,{k:()=>o});var s=i(29864),r=i(55164);const n={solana:["solana_signMessage","solana_signTransaction","solana_requestAccounts","solana_getAccounts","solana_signAllTransactions","solana_signAndSendTransaction"],eip155:["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_showCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"],bip122:["sendTransfer","signMessage","signPsbt","getAccountAddresses"]},o={getMethodsByChainNamespace:e=>n[e]||[],createDefaultNamespace(e){return{methods:this.getMethodsByChainNamespace(e),events:["accountsChanged","chainChanged"],chains:[],rpcMap:{}}},applyNamespaceOverrides(e,t){if(!t)return{...e};const i={...e},s=new Set;if(t.methods&&Object.keys(t.methods).forEach(e=>s.add(e)),t.chains&&Object.keys(t.chains).forEach(e=>s.add(e)),t.events&&Object.keys(t.events).forEach(e=>s.add(e)),t.rpcMap&&Object.keys(t.rpcMap).forEach(e=>{const[t]=e.split(":");t&&s.add(t)}),s.forEach(e=>{i[e]||(i[e]=this.createDefaultNamespace(e))}),t.methods&&Object.entries(t.methods).forEach(([e,t])=>{i[e]&&(i[e].methods=t)}),t.chains&&Object.entries(t.chains).forEach(([e,t])=>{i[e]&&(i[e].chains=t)}),t.events&&Object.entries(t.events).forEach(([e,t])=>{i[e]&&(i[e].events=t)}),t.rpcMap){const e=new Set;Object.entries(t.rpcMap).forEach(([t,s])=>{const[r,n]=t.split(":");r&&n&&i[r]&&(i[r].rpcMap||(i[r].rpcMap={}),e.has(r)||(i[r].rpcMap={},e.add(r)),i[r].rpcMap[n]=s)})}return i},createNamespaces(e,t){const i=e.reduce((e,t)=>{const{id:i,chainNamespace:s,rpcUrls:n}=t,o=n.default.http[0];e[s]||(e[s]=this.createDefaultNamespace(s));const a=`${s}:${i}`,c=e[s];switch(c.chains.push(a),a){case r.tWt.caipNetworkId:c.chains.push(r.tWt.deprecatedCaipNetworkId);break;case r.Rn0.caipNetworkId:c.chains.push(r.Rn0.deprecatedCaipNetworkId)}return c?.rpcMap&&o&&(c.rpcMap[i]=o),e},{});return this.applyNamespaceOverrides(i,t)},resolveReownName:async e=>{const t=await s.f.resolveName(e),i=Object.values(t?.addresses)||[];return i[0]?.address||!1},getChainsFromNamespaces:(e={})=>Object.values(e).flatMap(e=>{const t=e.chains||[],i=e.accounts.map(e=>{const[t,i]=e.split(":");return`${t}:${i}`});return Array.from(new Set([...t,...i]))}),isSessionEventData:e=>"object"==typeof e&&null!==e&&"id"in e&&"topic"in e&&"params"in e&&"object"==typeof e.params&&null!==e.params&&"chainId"in e.params&&"event"in e.params&&"object"==typeof e.params.event&&null!==e.params.event}},70461:(e,t,i)=>{var s=i(7784),r=i(35615);function n(e,t){return 55296==(64512&e.charCodeAt(t))&&!(t<0||t+1>=e.length)&&56320==(64512&e.charCodeAt(t+1))}function o(e){return(e>>>24|e>>>8&65280|e<<8&16711680|(255&e)<<24)>>>0}function a(e){return 1===e.length?"0"+e:e}function c(e){return 7===e.length?"0"+e:6===e.length?"00"+e:5===e.length?"000"+e:4===e.length?"0000"+e:3===e.length?"00000"+e:2===e.length?"000000"+e:1===e.length?"0000000"+e:e}t.inherits=r,t.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var i=[];if("string"==typeof e)if(t){if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),r=0;r<e.length;r+=2)i.push(parseInt(e[r]+e[r+1],16))}else for(var s=0,r=0;r<e.length;r++){var o=e.charCodeAt(r);o<128?i[s++]=o:o<2048?(i[s++]=o>>6|192,i[s++]=63&o|128):n(e,r)?(o=65536+((1023&o)<<10)+(1023&e.charCodeAt(++r)),i[s++]=o>>18|240,i[s++]=o>>12&63|128,i[s++]=o>>6&63|128,i[s++]=63&o|128):(i[s++]=o>>12|224,i[s++]=o>>6&63|128,i[s++]=63&o|128)}else for(r=0;r<e.length;r++)i[r]=0|e[r];return i},t.toHex=function(e){for(var t="",i=0;i<e.length;i++)t+=a(e[i].toString(16));return t},t.htonl=o,t.toHex32=function(e,t){for(var i="",s=0;s<e.length;s++){var r=e[s];"little"===t&&(r=o(r)),i+=c(r.toString(16))}return i},t.zero2=a,t.zero8=c,t.join32=function(e,t,i,r){var n=i-t;s(n%4==0);for(var o=new Array(n/4),a=0,c=t;a<o.length;a++,c+=4){var h;h="big"===r?e[c]<<24|e[c+1]<<16|e[c+2]<<8|e[c+3]:e[c+3]<<24|e[c+2]<<16|e[c+1]<<8|e[c],o[a]=h>>>0}return o},t.split32=function(e,t){for(var i=new Array(4*e.length),s=0,r=0;s<e.length;s++,r+=4){var n=e[s];"big"===t?(i[r]=n>>>24,i[r+1]=n>>>16&255,i[r+2]=n>>>8&255,i[r+3]=255&n):(i[r+3]=n>>>24,i[r+2]=n>>>16&255,i[r+1]=n>>>8&255,i[r]=255&n)}return i},t.rotr32=function(e,t){return e>>>t|e<<32-t},t.rotl32=function(e,t){return e<<t|e>>>32-t},t.sum32=function(e,t){return e+t>>>0},t.sum32_3=function(e,t,i){return e+t+i>>>0},t.sum32_4=function(e,t,i,s){return e+t+i+s>>>0},t.sum32_5=function(e,t,i,s,r){return e+t+i+s+r>>>0},t.sum64=function(e,t,i,s){var r=e[t],n=s+e[t+1]>>>0,o=(n<s?1:0)+i+r;e[t]=o>>>0,e[t+1]=n},t.sum64_hi=function(e,t,i,s){return(t+s>>>0<t?1:0)+e+i>>>0},t.sum64_lo=function(e,t,i,s){return t+s>>>0},t.sum64_4_hi=function(e,t,i,s,r,n,o,a){var c=0,h=t;return c+=(h=h+s>>>0)<t?1:0,c+=(h=h+n>>>0)<n?1:0,e+i+r+o+(c+=(h=h+a>>>0)<a?1:0)>>>0},t.sum64_4_lo=function(e,t,i,s,r,n,o,a){return t+s+n+a>>>0},t.sum64_5_hi=function(e,t,i,s,r,n,o,a,c,h){var d=0,l=t;return d+=(l=l+s>>>0)<t?1:0,d+=(l=l+n>>>0)<n?1:0,d+=(l=l+a>>>0)<a?1:0,e+i+r+o+c+(d+=(l=l+h>>>0)<h?1:0)>>>0},t.sum64_5_lo=function(e,t,i,s,r,n,o,a,c,h){return t+s+n+a+h>>>0},t.rotr64_hi=function(e,t,i){return(t<<32-i|e>>>i)>>>0},t.rotr64_lo=function(e,t,i){return(e<<32-i|t>>>i)>>>0},t.shr64_hi=function(e,t,i){return e>>>i},t.shr64_lo=function(e,t,i){return(e<<32-i|t>>>i)>>>0}},72931:(e,t,i)=>{i(3496),i(63789)},74091:(e,t,i)=>{i.d(t,{o:()=>r});var s=i(39907);const r={ACCOUNT_TABS:[{label:"Tokens"},{label:"NFTs"},{label:"Activity"}],SECURE_SITE_ORIGIN:(void 0!==s&&void 0!==s.env?s.env.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",VIEW_DIRECTION:{Next:"next",Prev:"prev"},DEFAULT_CONNECT_METHOD_ORDER:["email","social","wallet"],ANIMATION_DURATIONS:{HeaderText:120,ModalHeight:150,ViewTransition:150}}},74169:(e,t,i)=>{var s=i(70461),r=i(32191),n=s.rotl32,o=s.sum32,a=s.sum32_3,c=s.sum32_4,h=r.BlockHash;function d(){if(!(this instanceof d))return new d;h.call(this),this.h=[1732584193,4023233417,2562383102,271733878,3285377520],this.endian="little"}function l(e,t,i,s){return e<=15?t^i^s:e<=31?t&i|~t&s:e<=47?(t|~i)^s:e<=63?t&s|i&~s:t^(i|~s)}function u(e){return e<=15?0:e<=31?1518500249:e<=47?1859775393:e<=63?2400959708:2840853838}function p(e){return e<=15?1352829926:e<=31?1548603684:e<=47?1836072691:e<=63?2053994217:0}s.inherits(d,h),t.ripemd160=d,d.blockSize=512,d.outSize=160,d.hmacStrength=192,d.padLength=64,d.prototype._update=function(e,t){for(var i=this.h[0],s=this.h[1],r=this.h[2],h=this.h[3],d=this.h[4],y=i,w=s,v=r,I=h,E=d,_=0;_<80;_++){var A=o(n(c(i,l(_,s,r,h),e[f[_]+t],u(_)),m[_]),d);i=d,d=h,h=n(r,10),r=s,s=A,A=o(n(c(y,l(79-_,w,v,I),e[g[_]+t],p(_)),b[_]),E),y=E,E=I,I=n(v,10),v=w,w=A}A=a(this.h[1],r,I),this.h[1]=a(this.h[2],h,E),this.h[2]=a(this.h[3],d,y),this.h[3]=a(this.h[4],i,w),this.h[4]=a(this.h[0],s,v),this.h[0]=A},d.prototype._digest=function(e){return"hex"===e?s.toHex32(this.h,"little"):s.split32(this.h,"little")};var f=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],g=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],m=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],b=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11]},75393:(e,t,i)=>{var s=i(70461),r=i(50536);function n(){if(!(this instanceof n))return new n;r.call(this),this.h=[3238371032,914150663,812702999,4144912697,4290775857,1750603025,1694076839,3204075428]}s.inherits(n,r),e.exports=n,n.blockSize=512,n.outSize=224,n.hmacStrength=192,n.padLength=64,n.prototype._digest=function(e){return"hex"===e?s.toHex32(this.h.slice(0,7),"big"):s.split32(this.h.slice(0,7),"big")}},75746:(e,t,i)=>{t.sha1=i(12986),t.sha224=i(75393),t.sha256=i(50536),t.sha384=i(29967),t.sha512=i(92157)},76020:(e,t,i)=>{i.d(t,{L:()=>s});const s={caipNetworkIdToNumber:e=>e?Number(e.split(":")[1]):void 0,parseEvmChainId(e){return"string"==typeof e?this.caipNetworkIdToNumber(e):e},getNetworksByNamespace:(e,t)=>e?.filter(e=>e.chainNamespace===t)||[],getFirstNetworkByNamespace(e,t){return this.getNetworksByNamespace(e,t)[0]}}},76663:(e,t,i)=>{i.d(t,{F:()=>c}),i(23438);var s=i(95191),r=i(16158),n=i(24537),o=i(40770),a=i(86808);class c{constructor({provider:e,caipNetworks:t,namespace:i}){this.id=s.o.CONNECTOR_ID.WALLET_CONNECT,this.name=o.L.ConnectorNamesMap[s.o.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=o.L.ConnectorImageIds[s.o.CONNECTOR_ID.WALLET_CONNECT],this.caipNetworks=t,this.provider=e,this.chain=i}get chains(){return this.caipNetworks}async connectWalletConnect(){if(!await this.authenticate()){const e=r.H.state.universalProviderConfigOverride,t=a.kl.createNamespaces(this.caipNetworks,e);await this.provider.connect({optionalNamespaces:t})}return{clientId:await this.provider.client.core.crypto.getClientId(),session:this.provider.session}}async disconnect(){await this.provider.disconnect()}async authenticate(){const e=this.chains.map(e=>e.caipNetworkId);return n.U.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:h})}}const h=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"]},76754:(e,t,i)=>{i.d(t,{$Bq:()=>Ji,$hI:()=>F,ADD:()=>j,ALl:()=>Pi,AYU:()=>ls,Alu:()=>Is,AwN:()=>Li,BdH:()=>N,C5G:()=>ji,CTo:()=>us,EHS:()=>wi,EN$:()=>Si,EWt:()=>fi,F$L:()=>Mi,FR8:()=>Cs,FiO:()=>ys,GuA:()=>is,HNf:()=>hs,Hbs:()=>ks,Hjj:()=>ss,IjX:()=>We,K3g:()=>U,Lln:()=>I,Lp_:()=>yi,M8n:()=>Ns,OP1:()=>rs,PUk:()=>R,Pa8:()=>gi,QJh:()=>Gi,Qhg:()=>as,R7U:()=>S,TRk:()=>H,TZl:()=>Ai,TeY:()=>Es,Tw2:()=>Ri,U0i:()=>Bi,V7m:()=>qi,V9G:()=>vs,VBM:()=>et,Van:()=>Zi,WWN:()=>Ze,Wx8:()=>M,X3c:()=>_s,XqR:()=>Ts,Xw0:()=>$,YcA:()=>ki,_Yb:()=>g,_dF:()=>B,aF0:()=>ns,aRZ:()=>A,aa1:()=>Wi,b07:()=>os,bEt:()=>pi,c82:()=>q,cK:()=>m,e8_:()=>Ye,esh:()=>bs,gOF:()=>L,gZm:()=>K,h0Y:()=>k,hEn:()=>z,hVC:()=>Xe,hwK:()=>Ve,iV1:()=>As,iui:()=>Di,jTh:()=>V,jUZ:()=>T,kob:()=>Qi,kuU:()=>ws,lFF:()=>P,lVv:()=>E,m01:()=>_,mr0:()=>ps,n3s:()=>W,n6V:()=>Hi,nWe:()=>Xi,nyL:()=>Ds,oKp:()=>Ps,ojD:()=>O,ovp:()=>Ci,ps1:()=>$i,q_h:()=>He,sc7:()=>Rs,sc_:()=>Qe,tLy:()=>Ss,tk0:()=>fs,two:()=>Ni,uym:()=>Ms,w8K:()=>G,wYp:()=>Fi,wa2:()=>xi,x0t:()=>Ti,xkc:()=>ze,yy4:()=>Y,z2N:()=>Os});var s=i(24661),r=i(91315),n=i(20635),o=i(67822),a=i(71268),c=i(97353),h=i(1030),d=i(13360),l=i(17367),u=i(39907),p=i(48526).hp;const f=":";function g(e){const[t,i]=e.split(f);return{namespace:t,reference:i}}function m(e){const[t,i,s]=e.split(f);return{namespace:t,reference:i,address:s}}function b(e,t){return e.includes(":")?[e]:t.chains||[]}const y="ReactNative",w={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},v="js";function I(){return typeof u<"u"&&typeof u.versions<"u"&&typeof u.versions.node<"u"}function E(){return!(0,n.getDocument)()&&!!(0,n.getNavigator)()&&navigator.product===y}function _(){return E()&&typeof i.g<"u"&&typeof(null==i.g?void 0:i.g.Platform)<"u"&&"android"===(null==i.g?void 0:i.g.Platform.OS)}function A(){return E()&&typeof i.g<"u"&&typeof(null==i.g?void 0:i.g.Platform)<"u"&&"ios"===(null==i.g?void 0:i.g.Platform.OS)}function N(){return!I()&&!!(0,n.getNavigator)()&&!!(0,n.getDocument)()}function C(){return E()?w.reactNative:I()?w.node:N()?w.browser:w.unknown}function S(){var e;try{return E()&&typeof i.g<"u"&&typeof(null==i.g?void 0:i.g.Application)<"u"?null==(e=i.g.Application)?void 0:e.applicationId:void 0}catch{return}}function P(){return(0,o.g)()||{name:"",description:"",url:"",icons:[""]}}function O(e,t,r){const o=function(){if(C()===w.reactNative&&typeof i.g<"u"&&typeof(null==i.g?void 0:i.g.Platform)<"u"){const{OS:e,Version:t}=i.g.Platform;return[e,t].join("-")}const e=(0,s.o0)();if(null===e)return"unknown";const t=e.os?e.os.replace(" ","").toLowerCase():"unknown";return"browser"===e.type?[t,e.name,e.version].join("-"):[t,e.version].join("-")}(),a=function(){var e;const t=C();return t===w.browser?[t,(null==(e=(0,n.getLocation)())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),[v,r].join("-"),o,a].join("/")}function T({protocol:e,version:t,relayUrl:i,sdkVersion:s,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:c}){const h=i.split("?"),d={auth:r,ua:O(e,t,s),projectId:n,useOnCloseEvent:o||void 0,packageName:c||void 0,bundleId:a||void 0},l=function(e,t){const i=new URLSearchParams(e);for(const e of Object.keys(t).sort())if(t.hasOwnProperty(e)){const s=t[e];void 0!==s&&i.set(e,s)}return i.toString()}(h[1]||"",d);return h[0]+"?"+l}function x(e,t){return e.filter(e=>t.includes(e)).length===e.length}function k(e){return Object.fromEntries(e.entries())}function R(e){return new Map(Object.entries(e))}function M(e=r.FIVE_MINUTES,t){const i=(0,r.toMiliseconds)(e||r.FIVE_MINUTES);let s,n,o,a;return{resolve:e=>{o&&s&&(clearTimeout(o),s(e),a=Promise.resolve(e))},reject:e=>{o&&n&&(clearTimeout(o),n(e))},done:()=>new Promise((e,r)=>{if(a)return e(a);o=setTimeout(()=>{const e=new Error(t);a=Promise.reject(e),r(e)},i),s=e,n=r})}}function U(e,t,i){return new Promise(async(s,r)=>{const n=setTimeout(()=>r(new Error(i)),t);try{s(await e)}catch(e){r(e)}clearTimeout(n)})}function D(e,t){if("string"==typeof t&&t.startsWith(`${e}:`))return t;if("topic"===e.toLowerCase()){if("string"!=typeof t)throw new Error('Value must be "string" for expirer target type: topic');return`topic:${t}`}if("id"===e.toLowerCase()){if("number"!=typeof t)throw new Error('Value must be "number" for expirer target type: id');return`id:${t}`}throw new Error(`Unknown expirer target type: ${e}`)}function j(e){return D("topic",e)}function L(e){return D("id",e)}function q(e){const[t,i]=e.split(":"),s={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof i)s.topic=i;else{if("id"!==t||!Number.isInteger(Number(i)))throw new Error(`Invalid target, expected id:number or topic:string, got ${t}:${i}`);s.id=Number(i)}return s}function $(e,t){return(0,r.fromMiliseconds)((t||Date.now())+(0,r.toMiliseconds)(e))}function B(e){return Date.now()>=(0,r.toMiliseconds)(e)}function z(e,t){return`${e}${t?`:${t}`:""}`}function H(e=[],t=[]){return[...new Set([...e,...t])]}async function W({id:e,topic:t,wcDeepLink:s}){var r;try{if(!s)return;const o="string"==typeof s?JSON.parse(s):s,a=o?.href;if("string"!=typeof a)return;const c=function(e,t,i){const s=`requestId=${t}&sessionTopic=${i}`;e.endsWith("/")&&(e=e.slice(0,-1));let r=`${e}`;return r=e.startsWith("https://t.me")?`${r}${e.includes("?")?"&startapp=":"?startapp="}${function(e,t=!1){const i=p.from(e).toString("base64");return t?i.replace(/[=]/g,""):i}(s,!0)}`:`${r}/wc?${s}`,r}(a,e,t),h=C();if(h===w.browser){if(null==(r=(0,n.getDocument)())||!r.hasFocus())return void console.warn("Document does not have focus, skipping deeplink.");!function(e){let t="_self";!function(){try{return window.self!==window.top}catch{return!1}}()?(typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)||e.startsWith("https://")||e.startsWith("http://"))&&(t="_blank"):t="_top",window.open(e,t,"noreferrer noopener")}(c)}else h===w.reactNative&&typeof(null==i.g?void 0:i.g.Linking)<"u"&&await i.g.Linking.openURL(c)}catch(e){console.error(e)}}async function V(e,t){let i="";try{if(N()&&(i=localStorage.getItem(t),i))return i;i=await e.getItem(t)}catch(e){console.error(e)}return i}function F(e,t){if(!e.includes(t))return null;const i=e.split(/([&,?,=])/),s=i.indexOf(t);return i[s+2]}function K(){return typeof crypto<"u"&&null!=crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function G(){return typeof u<"u"&&"true"===u.env.IS_VITEST}function J(e){return p.from(e,"base64").toString("utf-8")}function Y(e){return new Promise(t=>setTimeout(t,e))}function X(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Q(e,...t){if(!function(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Z(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");X(e.outputLen),X(e.blockLen)}function ee(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function te(e,t){Q(e);const i=t.outputLen;if(e.length<i)throw new Error("digestInto() expects output buffer of length at least "+i)}const ie=BigInt(2**32-1),se=BigInt(32);function re(e,t=!1){return t?{h:Number(e&ie),l:Number(e>>se&ie)}:{h:0|Number(e>>se&ie),l:0|Number(e&ie)}}const ne="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function oe(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ae(e,t){return e<<32-t|e>>>t}const ce=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function he(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function de(e){for(let t=0;t<e.length;t++)e[t]=he(e[t])}function le(e){return"string"==typeof e&&(e=function(e){if("string"!=typeof e)throw new Error("utf8ToBytes expected string, got "+typeof e);return new Uint8Array((new TextEncoder).encode(e))}(e)),Q(e),e}class ue{clone(){return this._cloneInto()}}function pe(e){const t=t=>e().update(le(t)).digest(),i=e();return t.outputLen=i.outputLen,t.blockLen=i.blockLen,t.create=()=>e(),t}function fe(e=32){if(ne&&"function"==typeof ne.getRandomValues)return ne.getRandomValues(new Uint8Array(e));if(ne&&"function"==typeof ne.randomBytes)return ne.randomBytes(e);throw new Error("crypto.getRandomValues must be defined")}const ge=[],me=[],be=[],ye=BigInt(0),we=BigInt(1),ve=BigInt(2),Ie=BigInt(7),Ee=BigInt(256),_e=BigInt(113);for(let e=0,t=we,i=1,s=0;e<24;e++){[i,s]=[s,(2*i+3*s)%5],ge.push(2*(5*s+i)),me.push((e+1)*(e+2)/2%64);let r=ye;for(let e=0;e<7;e++)t=(t<<we^(t>>Ie)*_e)%Ee,t&ve&&(r^=we<<(we<<BigInt(e))-we);be.push(r)}const[Ae,Ne]=function(e,t=!1){let i=new Uint32Array(e.length),s=new Uint32Array(e.length);for(let r=0;r<e.length;r++){const{h:n,l:o}=re(e[r],t);[i[r],s[r]]=[n,o]}return[i,s]}(be,!0),Ce=(e,t,i)=>i>32?((e,t,i)=>t<<i-32|e>>>64-i)(e,t,i):((e,t,i)=>e<<i|t>>>32-i)(e,t,i),Se=(e,t,i)=>i>32?((e,t,i)=>e<<i-32|t>>>64-i)(e,t,i):((e,t,i)=>t<<i|e>>>32-i)(e,t,i);class Pe extends ue{constructor(e,t,i,s=!1,r=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=s,this.rounds=r,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,X(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var n;this.state=new Uint8Array(200),this.state32=(n=this.state,new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)))}keccak(){ce||de(this.state32),function(e,t=24){const i=new Uint32Array(10);for(let s=24-t;s<24;s++){for(let t=0;t<10;t++)i[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){const s=(t+8)%10,r=(t+2)%10,n=i[r],o=i[r+1],a=Ce(n,o,1)^i[s],c=Se(n,o,1)^i[s+1];for(let i=0;i<50;i+=10)e[t+i]^=a,e[t+i+1]^=c}let t=e[2],r=e[3];for(let i=0;i<24;i++){const s=me[i],n=Ce(t,r,s),o=Se(t,r,s),a=ge[i];t=e[a],r=e[a+1],e[a]=n,e[a+1]=o}for(let t=0;t<50;t+=10){for(let s=0;s<10;s++)i[s]=e[t+s];for(let s=0;s<10;s++)e[t+s]^=~i[(s+2)%10]&i[(s+4)%10]}e[0]^=Ae[s],e[1]^=Ne[s]}i.fill(0)}(this.state32,this.rounds),ce||de(this.state32),this.posOut=0,this.pos=0}update(e){ee(this);const{blockLen:t,state:i}=this,s=(e=le(e)).length;for(let r=0;r<s;){const n=Math.min(t-this.pos,s-r);for(let t=0;t<n;t++)i[this.pos++]^=e[r++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:s}=this;e[i]^=t,!!(128&t)&&i===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){ee(this,!1),Q(e),this.finish();const t=this.state,{blockLen:i}=this;for(let s=0,r=e.length;s<r;){this.posOut>=i&&this.keccak();const n=Math.min(i-this.posOut,r-s);e.set(t.subarray(this.posOut,this.posOut+n),s),this.posOut+=n,s+=n}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return X(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(te(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:s,rounds:r,enableXOF:n}=this;return e||(e=new Pe(t,i,s,n,r)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=r,e.suffix=i,e.outputLen=s,e.enableXOF=n,e.destroyed=this.destroyed,e}}const Oe=pe(()=>new Pe(136,1,32)),Te="https://rpc.walletconnect.org/v1";function xe(e){const t=`Ethereum Signed Message:\n${e.length}`,i=(new TextEncoder).encode(t+e);return"0x"+p.from(Oe(i)).toString("hex")}var ke=Object.defineProperty,Re=Object.defineProperties,Me=Object.getOwnPropertyDescriptors,Ue=Object.getOwnPropertySymbols,De=Object.prototype.hasOwnProperty,je=Object.prototype.propertyIsEnumerable,Le=(e,t,i)=>t in e?ke(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,qe=(e,t)=>{for(var i in t||(t={}))De.call(t,i)&&Le(e,i,t[i]);if(Ue)for(var i of Ue(t))je.call(t,i)&&Le(e,i,t[i]);return e},$e=(e,t)=>Re(e,Me(t));const Be=e=>e?.split(":"),ze=e=>{const t=e&&Be(e);if(t)return t[2]+":"+t[3]},He=e=>{const t=e&&Be(e);if(t)return t.pop()};async function We(e){const{cacao:t,projectId:i}=e,{s,p:r}=t,n=Ve(r,r.iss),o=He(r.iss);return await async function(e,t,i,s,r,n){switch(i.t){case"eip191":return await async function(e,t,i){return(await(0,a.x)({hash:xe(t),signature:i})).toLowerCase()===e.toLowerCase()}(e,t,i.s);case"eip1271":return await async function(e,t,i,s,r,n){const o=g(s);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${s}`);try{const o="0x1626ba7e",a="0000000000000000000000000000000000000000000000000000000000000040",c="0000000000000000000000000000000000000000000000000000000000000041",h=i.substring(2),d=o+xe(t).substring(2)+a+c+h,l=await fetch(`${n||Te}/?chainId=${s}&projectId=${r}`,{method:"POST",body:JSON.stringify({id:Date.now()+Math.floor(1e3*Math.random()),jsonrpc:"2.0",method:"eth_call",params:[{to:e,data:d},"latest"]})}),{result:u}=await l.json();return!!u&&u.slice(0,o.length).toLowerCase()===o.toLowerCase()}catch(e){return console.error("isValidEip1271Signature: ",e),!1}}(e,t,i.s,s,r,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${i.t}`)}}(o,n,s,ze(r.iss),i)}const Ve=(e,t)=>{const i=`${e.domain} wants you to sign in with your Ethereum account:`,s=He(t);if(!e.aud&&!e.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let r=e.statement||void 0;const n=`URI: ${e.aud||e.uri}`,o=`Version: ${e.version}`,a=`Chain ID: ${(e=>{const t=e&&Be(e);if(t)return e.includes("did:pkh:")?t[3]:t[1]})(t)}`,c=`Nonce: ${e.nonce}`,h=`Issued At: ${e.iat}`,d=e.exp?`Expiration Time: ${e.exp}`:void 0,l=e.nbf?`Not Before: ${e.nbf}`:void 0,u=e.requestId?`Request ID: ${e.requestId}`:void 0,p=e.resources?`Resources:${e.resources.map(e=>`\n- ${e}`).join("")}`:void 0,f=et(e.resources);return f&&(r=function(e="",t){Fe(t);const i="I further authorize the stated URI to perform the following actions on my behalf: ";if(e.includes(i))return e;const s=[];let r=0;return Object.keys(t.att).forEach(e=>{const i=Object.keys(t.att[e]).map(e=>({ability:e.split("/")[0],action:e.split("/")[1]}));i.sort((e,t)=>e.action.localeCompare(t.action));const n={};i.forEach(e=>{n[e.ability]||(n[e.ability]=[]),n[e.ability].push(e.action)});const o=Object.keys(n).map(t=>(r++,`(${r}) '${t}': '${n[t].join("', '")}' for '${e}'.`));s.push(o.join(", ").replace(".,","."))}),`${e?e+" ":""}${i}${s.join(" ")}`}(r,Je(f))),[i,s,"",r,"",n,o,a,c,h,d,l,u,p].filter(e=>null!=e).join("\n")};function Fe(e){if(!e)throw new Error("No recap provided, value is undefined");if(!e.att)throw new Error("No `att` property found");const t=Object.keys(e.att);if(null==t||!t.length)throw new Error("No resources found in `att` property");t.forEach(t=>{const i=e.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if("object"!=typeof i)throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(e=>{const t=i[e];if(!Array.isArray(t))throw new Error(`Ability limits ${e} must be an array of objects, found: ${t}`);if(!t.length)throw new Error(`Value of ${e} is empty array, must be an array with objects`);t.forEach(t=>{if("object"!=typeof t)throw new Error(`Ability limits (${e}) must be an array of objects, found: ${t}`)})})})}function Ke(e,t,i={}){t=t?.sort((e,t)=>e.localeCompare(t));const s=t.map(t=>({[`${e}/${t}`]:[i]}));return Object.assign({},...s)}function Ge(e){return Fe(e),`urn:recap:${function(e){return p.from(JSON.stringify(e)).toString("base64")}(e).replace(/=/g,"")}`}function Je(e){const t=function(e){return JSON.parse(p.from(e,"base64").toString("utf-8"))}(e.replace("urn:recap:",""));return Fe(t),t}function Ye(e,t,i){const s=function(e,t,i,s={}){return i?.sort((e,t)=>e.localeCompare(t)),{att:{[e]:Ke(t,i,s)}}}(e,t,i);return Ge(s)}function Xe(e,t){const i=function(e,t){Fe(e),Fe(t);const i=Object.keys(e.att).concat(Object.keys(t.att)).sort((e,t)=>e.localeCompare(t)),s={att:{}};return i.forEach(i=>{var r,n;Object.keys((null==(r=e.att)?void 0:r[i])||{}).concat(Object.keys((null==(n=t.att)?void 0:n[i])||{})).sort((e,t)=>e.localeCompare(t)).forEach(r=>{var n,o;s.att[i]=$e(qe({},s.att[i]),{[r]:(null==(n=e.att[i])?void 0:n[r])||(null==(o=t.att[i])?void 0:o[r])})})}),s}(Je(e),Je(t));return Ge(i)}function Qe(e){var t;const i=Je(e);Fe(i);const s=null==(t=i.att)?void 0:t.eip155;return s?Object.keys(s).map(e=>e.split("/")[1]):[]}function Ze(e){const t=Je(e);Fe(t);const i=[];return Object.values(t.att).forEach(e=>{Object.values(e).forEach(e=>{var t;null!=(t=e?.[0])&&t.chains&&i.push(e[0].chains)})}),[...new Set(i.flat())]}function et(e){if(!e)return;const t=e?.[e.length-1];return function(e){return e&&e.includes("urn:recap:")}(t)?t:void 0}function tt(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function it(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function st(e,...t){if(!it(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function rt(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function nt(e){if("boolean"!=typeof e)throw new Error(`boolean expected, not ${e}`)}const ot=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4));if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function at(e){if("string"==typeof e)e=function(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}(e);else{if(!it(e))throw new Error("Uint8Array expected, got "+typeof e);e=dt(e)}return e}function ct(e,t,i=!0){if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(i&&!function(e){return e.byteOffset%4==0}(t))throw new Error("invalid output, must be aligned");return t}function ht(e,t,i,s){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,i,s);const r=BigInt(32),n=BigInt(4294967295),o=Number(i>>r&n),a=Number(i&n),c=s?4:0,h=s?0:4;e.setUint32(t+c,o,s),e.setUint32(t+h,a,s)}function dt(e){return Uint8Array.from(e)}function lt(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}const ut=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),pt=ut("expand 16-byte k"),ft=ut("expand 32-byte k"),gt=ot(pt),mt=ot(ft);function bt(e,t){return e<<t|e>>>32-t}function yt(e){return e.byteOffset%4==0}const wt=2**32-1,vt=new Uint32Array,It=(e,t)=>255&e[t++]|(255&e[t++])<<8;class Et{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,st(e=at(e),32);const t=It(e,0),i=It(e,2),s=It(e,4),r=It(e,6),n=It(e,8),o=It(e,10),a=It(e,12),c=It(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|i<<3),this.r[2]=7939&(i>>>10|s<<6),this.r[3]=8191&(s>>>7|r<<9),this.r[4]=255&(r>>>4|n<<12),this.r[5]=n>>>1&8190,this.r[6]=8191&(n>>>14|o<<2),this.r[7]=8065&(o>>>11|a<<5),this.r[8]=8191&(a>>>8|c<<8),this.r[9]=c>>>5&127;for(let t=0;t<8;t++)this.pad[t]=It(e,16+2*t)}process(e,t,i=!1){const s=i?0:2048,{h:r,r:n}=this,o=n[0],a=n[1],c=n[2],h=n[3],d=n[4],l=n[5],u=n[6],p=n[7],f=n[8],g=n[9],m=It(e,t+0),b=It(e,t+2),y=It(e,t+4),w=It(e,t+6),v=It(e,t+8),I=It(e,t+10),E=It(e,t+12),_=It(e,t+14);let A=r[0]+(8191&m),N=r[1]+(8191&(m>>>13|b<<3)),C=r[2]+(8191&(b>>>10|y<<6)),S=r[3]+(8191&(y>>>7|w<<9)),P=r[4]+(8191&(w>>>4|v<<12)),O=r[5]+(v>>>1&8191),T=r[6]+(8191&(v>>>14|I<<2)),x=r[7]+(8191&(I>>>11|E<<5)),k=r[8]+(8191&(E>>>8|_<<8)),R=r[9]+(_>>>5|s),M=0,U=M+A*o+N*(5*g)+C*(5*f)+S*(5*p)+P*(5*u);M=U>>>13,U&=8191,U+=O*(5*l)+T*(5*d)+x*(5*h)+k*(5*c)+R*(5*a),M+=U>>>13,U&=8191;let D=M+A*a+N*o+C*(5*g)+S*(5*f)+P*(5*p);M=D>>>13,D&=8191,D+=O*(5*u)+T*(5*l)+x*(5*d)+k*(5*h)+R*(5*c),M+=D>>>13,D&=8191;let j=M+A*c+N*a+C*o+S*(5*g)+P*(5*f);M=j>>>13,j&=8191,j+=O*(5*p)+T*(5*u)+x*(5*l)+k*(5*d)+R*(5*h),M+=j>>>13,j&=8191;let L=M+A*h+N*c+C*a+S*o+P*(5*g);M=L>>>13,L&=8191,L+=O*(5*f)+T*(5*p)+x*(5*u)+k*(5*l)+R*(5*d),M+=L>>>13,L&=8191;let q=M+A*d+N*h+C*c+S*a+P*o;M=q>>>13,q&=8191,q+=O*(5*g)+T*(5*f)+x*(5*p)+k*(5*u)+R*(5*l),M+=q>>>13,q&=8191;let $=M+A*l+N*d+C*h+S*c+P*a;M=$>>>13,$&=8191,$+=O*o+T*(5*g)+x*(5*f)+k*(5*p)+R*(5*u),M+=$>>>13,$&=8191;let B=M+A*u+N*l+C*d+S*h+P*c;M=B>>>13,B&=8191,B+=O*a+T*o+x*(5*g)+k*(5*f)+R*(5*p),M+=B>>>13,B&=8191;let z=M+A*p+N*u+C*l+S*d+P*h;M=z>>>13,z&=8191,z+=O*c+T*a+x*o+k*(5*g)+R*(5*f),M+=z>>>13,z&=8191;let H=M+A*f+N*p+C*u+S*l+P*d;M=H>>>13,H&=8191,H+=O*h+T*c+x*a+k*o+R*(5*g),M+=H>>>13,H&=8191;let W=M+A*g+N*f+C*p+S*u+P*l;M=W>>>13,W&=8191,W+=O*d+T*h+x*c+k*a+R*o,M+=W>>>13,W&=8191,M=(M<<2)+M|0,M=M+U|0,U=8191&M,M>>>=13,D+=M,r[0]=U,r[1]=D,r[2]=j,r[3]=L,r[4]=q,r[5]=$,r[6]=B,r[7]=z,r[8]=H,r[9]=W}finalize(){const{h:e,pad:t}=this,i=new Uint16Array(10);let s=e[1]>>>13;e[1]&=8191;for(let t=2;t<10;t++)e[t]+=s,s=e[t]>>>13,e[t]&=8191;e[0]+=5*s,s=e[0]>>>13,e[0]&=8191,e[1]+=s,s=e[1]>>>13,e[1]&=8191,e[2]+=s,i[0]=e[0]+5,s=i[0]>>>13,i[0]&=8191;for(let t=1;t<10;t++)i[t]=e[t]+s,s=i[t]>>>13,i[t]&=8191;i[9]-=8192;let r=(1^s)-1;for(let e=0;e<10;e++)i[e]&=r;r=~r;for(let t=0;t<10;t++)e[t]=e[t]&r|i[t];e[0]=65535&(e[0]|e[1]<<13),e[1]=65535&(e[1]>>>3|e[2]<<10),e[2]=65535&(e[2]>>>6|e[3]<<7),e[3]=65535&(e[3]>>>9|e[4]<<4),e[4]=65535&(e[4]>>>12|e[5]<<1|e[6]<<14),e[5]=65535&(e[6]>>>2|e[7]<<11),e[6]=65535&(e[7]>>>5|e[8]<<8),e[7]=65535&(e[8]>>>8|e[9]<<5);let n=e[0]+t[0];e[0]=65535&n;for(let i=1;i<8;i++)n=(e[i]+t[i]|0)+(n>>>16)|0,e[i]=65535&n;lt(i)}update(e){rt(this);const{buffer:t,blockLen:i}=this,s=(e=at(e)).length;for(let r=0;r<s;){const n=Math.min(i-this.pos,s-r);if(n!==i)t.set(e.subarray(r,r+n),this.pos),this.pos+=n,r+=n,this.pos===i&&(this.process(t,0,!1),this.pos=0);else for(;i<=s-r;r+=i)this.process(e,r)}return this}destroy(){lt(this.h,this.r,this.buffer,this.pad)}digestInto(e){rt(this),function(e,t){st(e);const i=t.outputLen;if(e.length<i)throw new Error("digestInto() expects output buffer of length at least "+i)}(e,this),this.finished=!0;const{buffer:t,h:i}=this;let{pos:s}=this;if(s){for(t[s++]=1;s<16;s++)t[s]=0;this.process(t,0,!0)}this.finalize();let r=0;for(let t=0;t<8;t++)e[r++]=i[t]>>>0,e[r++]=i[t]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}}const _t=function(e){const t=(t,i)=>e(i).update(at(t)).digest(),i=e(new Uint8Array(32));return t.outputLen=i.outputLen,t.blockLen=i.blockLen,t.create=t=>e(t),t}(e=>new Et(e)),At=function(e){const{allowShortKeys:t,extendNonceFn:i,counterLength:s,counterRight:r,rounds:n}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t)}(0,{counterRight:!1,counterLength:4,allowShortKeys:!1});return tt(s),tt(n),nt(r),nt(t),(o,a,c,h,d=0)=>{st(o),st(a),st(c);const l=c.length;if(void 0===h&&(h=new Uint8Array(l)),st(h),tt(d),d<0||d>=wt)throw new Error("arx: counter overflow");if(h.length<l)throw new Error(`arx: output (${h.length}) is shorter than data (${l})`);const u=[];let p,f,g=o.length;if(32===g)u.push(p=dt(o)),f=mt;else{if(16!==g||!t)throw new Error(`arx: invalid 32-byte key, got length=${g}`);p=new Uint8Array(32),p.set(o),p.set(o,16),f=gt,u.push(p)}yt(a)||u.push(a=dt(a));const m=ot(p);if(i){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");i(f,m,ot(a.subarray(0,16)),m),a=a.subarray(16)}const b=16-s;if(b!==a.length)throw new Error(`arx: nonce must be ${b} or 16 bytes`);if(12!==b){const e=new Uint8Array(12);e.set(a,r?0:12-a.length),a=e,u.push(a)}const y=ot(a);return function(e,t,i,s,r,n,o,a){const c=r.length,h=new Uint8Array(64),d=ot(h),l=yt(r)&&yt(n),u=l?ot(r):vt,p=l?ot(n):vt;for(let f=0;f<c;o++){if(e(t,i,s,d,o,a),o>=wt)throw new Error("arx: counter overflow");const g=Math.min(64,c-f);if(l&&64===g){const e=f/4;if(f%4!=0)throw new Error("arx: invalid block position");for(let t,i=0;i<16;i++)t=e+i,p[t]=u[t]^d[i];f+=64;continue}for(let e,t=0;t<g;t++)e=f+t,n[e]=r[e]^h[t];f+=g}}(e,f,m,y,c,h,d,n),lt(...u),h}}(function(e,t,i,s,r,n=20){let o=e[0],a=e[1],c=e[2],h=e[3],d=t[0],l=t[1],u=t[2],p=t[3],f=t[4],g=t[5],m=t[6],b=t[7],y=r,w=i[0],v=i[1],I=i[2],E=o,_=a,A=c,N=h,C=d,S=l,P=u,O=p,T=f,x=g,k=m,R=b,M=y,U=w,D=v,j=I;for(let e=0;e<n;e+=2)E=E+C|0,M=bt(M^E,16),T=T+M|0,C=bt(C^T,12),E=E+C|0,M=bt(M^E,8),T=T+M|0,C=bt(C^T,7),_=_+S|0,U=bt(U^_,16),x=x+U|0,S=bt(S^x,12),_=_+S|0,U=bt(U^_,8),x=x+U|0,S=bt(S^x,7),A=A+P|0,D=bt(D^A,16),k=k+D|0,P=bt(P^k,12),A=A+P|0,D=bt(D^A,8),k=k+D|0,P=bt(P^k,7),N=N+O|0,j=bt(j^N,16),R=R+j|0,O=bt(O^R,12),N=N+O|0,j=bt(j^N,8),R=R+j|0,O=bt(O^R,7),E=E+S|0,j=bt(j^E,16),k=k+j|0,S=bt(S^k,12),E=E+S|0,j=bt(j^E,8),k=k+j|0,S=bt(S^k,7),_=_+P|0,M=bt(M^_,16),R=R+M|0,P=bt(P^R,12),_=_+P|0,M=bt(M^_,8),R=R+M|0,P=bt(P^R,7),A=A+O|0,U=bt(U^A,16),T=T+U|0,O=bt(O^T,12),A=A+O|0,U=bt(U^A,8),T=T+U|0,O=bt(O^T,7),N=N+C|0,D=bt(D^N,16),x=x+D|0,C=bt(C^x,12),N=N+C|0,D=bt(D^N,8),x=x+D|0,C=bt(C^x,7);let L=0;s[L++]=o+E|0,s[L++]=a+_|0,s[L++]=c+A|0,s[L++]=h+N|0,s[L++]=d+C|0,s[L++]=l+S|0,s[L++]=u+P|0,s[L++]=p+O|0,s[L++]=f+T|0,s[L++]=g+x|0,s[L++]=m+k|0,s[L++]=b+R|0,s[L++]=y+M|0,s[L++]=w+U|0,s[L++]=v+D|0,s[L++]=I+j|0}),Nt=new Uint8Array(16),Ct=(e,t)=>{e.update(t);const i=t.length%16;i&&e.update(Nt.subarray(i))},St=new Uint8Array(32);function Pt(e,t,i,s,r){const n=e(t,i,St),o=_t.create(n);r&&Ct(o,r),Ct(o,s);const a=new Uint8Array(16),c=(e=>new DataView(e.buffer,e.byteOffset,e.byteLength))(a);ht(c,0,BigInt(r?r.length:0),!0),ht(c,8,BigInt(s.length),!0),o.update(a);const h=o.digest();return lt(n,a),h}const Ot=((e,t)=>{function i(i,...s){if(st(i),void 0!==e.nonceLength){const t=s[0];if(!t)throw new Error("nonce / iv required");e.varSizeNonce?st(t):st(t,e.nonceLength)}const r=e.tagLength;r&&void 0!==s[1]&&st(s[1]);const n=t(i,...s),o=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");st(t)}};let a=!1;return{encrypt(e,t){if(a)throw new Error("cannot encrypt() twice with same key + nonce");return a=!0,st(e),o(n.encrypt.length,t),n.encrypt(e,t)},decrypt(e,t){if(st(e),r&&e.length<r)throw new Error("invalid ciphertext length: smaller than tagLength="+r);return o(n.decrypt.length,t),n.decrypt(e,t)}}}return Object.assign(i,e),i})({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,i,s)=>({encrypt(r,n){const o=r.length;(n=ct(o+16,n,!1)).set(r);const a=n.subarray(0,-16);e(t,i,a,a,1);const c=Pt(e,t,i,a,s);return n.set(c,o),lt(c),n},decrypt(r,n){n=ct(r.length-16,n,!1);const o=r.subarray(0,-16),a=r.subarray(-16),c=Pt(e,t,i,o,s);if(!function(e,t){if(e.length!==t.length)return!1;let i=0;for(let s=0;s<e.length;s++)i|=e[s]^t[s];return 0===i}(a,c))throw new Error("invalid tag");return n.set(r.subarray(0,-16)),e(t,i,n,n,1),lt(c),n}}))(At));class Tt extends ue{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Z(e);const i=le(t);if(this.iHash=e.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,r=new Uint8Array(s);r.set(i.length>s?e.create().update(i).digest():i);for(let e=0;e<r.length;e++)r[e]^=54;this.iHash.update(r),this.oHash=e.create();for(let e=0;e<r.length;e++)r[e]^=106;this.oHash.update(r),r.fill(0)}update(e){return ee(this),this.iHash.update(e),this}digestInto(e){ee(this),Q(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:i,finished:s,destroyed:r,blockLen:n,outputLen:o}=this;return e.finished=s,e.destroyed=r,e.blockLen=n,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const xt=(e,t,i)=>new Tt(e,t).update(i).digest();xt.create=(e,t)=>new Tt(e,t);const kt=new Uint8Array([0]),Rt=new Uint8Array,Mt=(e,t,i,s,r)=>function(e,t,i,s=32){if(Z(e),X(s),s>255*e.outputLen)throw new Error("Length should be <= 255*HashLen");const r=Math.ceil(s/e.outputLen);void 0===i&&(i=Rt);const n=new Uint8Array(r*e.outputLen),o=xt.create(e,t),a=o._cloneInto(),c=new Uint8Array(o.outputLen);for(let t=0;t<r;t++)kt[0]=t+1,a.update(0===t?Rt:c).update(i).update(kt).digestInto(c),n.set(c,e.outputLen*t),o._cloneInto(a);return o.destroy(),a.destroy(),c.fill(0),kt.fill(0),n.slice(0,s)}(e,function(e,t,i){return Z(e),void 0===i&&(i=new Uint8Array(e.outputLen)),xt(e,le(i),le(t))}(e,t,i),s,r);function Ut(e,t,i){return e&t^~e&i}function Dt(e,t,i){return e&t^e&i^t&i}class jt extends ue{constructor(e,t,i,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=oe(this.buffer)}update(e){ee(this);const{view:t,buffer:i,blockLen:s}=this,r=(e=le(e)).length;for(let n=0;n<r;){const o=Math.min(s-this.pos,r-n);if(o===s){const t=oe(e);for(;s<=r-n;n+=s)this.process(t,n);continue}i.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){ee(this),te(e,this),this.finished=!0;const{buffer:t,view:i,blockLen:s,isLE:r}=this;let{pos:n}=this;t[n++]=128,this.buffer.subarray(n).fill(0),this.padOffset>s-n&&(this.process(i,0),n=0);for(let e=n;e<s;e++)t[e]=0;(function(e,t,i,s){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,i,s);const r=BigInt(32),n=BigInt(4294967295),o=Number(i>>r&n),a=Number(i&n),c=s?4:0,h=s?0:4;e.setUint32(t+c,o,s),e.setUint32(t+h,a,s)})(i,s-8,BigInt(8*this.length),r),this.process(i,0);const o=oe(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let e=0;e<c;e++)o.setUint32(4*e,h[e],r)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:i,length:s,finished:r,destroyed:n,pos:o}=this;return e.length=s,e.pos=o,e.finished=r,e.destroyed=n,s%t&&e.buffer.set(i),e}}const Lt=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),qt=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),$t=new Uint32Array(64);class Bt extends jt{constructor(){super(64,32,8,!1),this.A=0|qt[0],this.B=0|qt[1],this.C=0|qt[2],this.D=0|qt[3],this.E=0|qt[4],this.F=0|qt[5],this.G=0|qt[6],this.H=0|qt[7]}get(){const{A:e,B:t,C:i,D:s,E:r,F:n,G:o,H:a}=this;return[e,t,i,s,r,n,o,a]}set(e,t,i,s,r,n,o,a){this.A=0|e,this.B=0|t,this.C=0|i,this.D=0|s,this.E=0|r,this.F=0|n,this.G=0|o,this.H=0|a}process(e,t){for(let i=0;i<16;i++,t+=4)$t[i]=e.getUint32(t,!1);for(let e=16;e<64;e++){const t=$t[e-15],i=$t[e-2],s=ae(t,7)^ae(t,18)^t>>>3,r=ae(i,17)^ae(i,19)^i>>>10;$t[e]=r+$t[e-7]+s+$t[e-16]|0}let{A:i,B:s,C:r,D:n,E:o,F:a,G:c,H:h}=this;for(let e=0;e<64;e++){const t=h+(ae(o,6)^ae(o,11)^ae(o,25))+Ut(o,a,c)+Lt[e]+$t[e]|0,d=(ae(i,2)^ae(i,13)^ae(i,22))+Dt(i,s,r)|0;h=c,c=a,a=o,o=n+t|0,n=r,r=s,s=i,i=t+d|0}i=i+this.A|0,s=s+this.B|0,r=r+this.C|0,n=n+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(i,s,r,n,o,a,c,h)}roundClean(){$t.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const zt=pe(()=>new Bt),Ht=BigInt(0);function Wt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Vt(e){if(!Wt(e))throw new Error("Uint8Array expected")}const Ft=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Kt(e){return e>=48&&e<=57?e-48:e>=65&&e<=70?e-55:e>=97&&e<=102?e-87:void 0}function Gt(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);const t=e.length,i=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const s=new Uint8Array(i);for(let t=0,r=0;t<i;t++,r+=2){const i=Kt(e.charCodeAt(r)),n=Kt(e.charCodeAt(r+1));if(void 0===i||void 0===n){const t=e[r]+e[r+1];throw new Error('hex string expected, got non-hex character "'+t+'" at index '+r)}s[t]=16*i+n}return s}function Jt(e){return Vt(e),function(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?Ht:BigInt("0x"+e)}(function(e){Vt(e);let t="";for(let i=0;i<e.length;i++)t+=Ft[e[i]];return t}(Uint8Array.from(e).reverse()))}function Yt(e,t,i){let s;if("string"==typeof t)try{s=Gt(t)}catch(t){throw new Error(e+" must be hex string or Uint8Array, cause: "+t)}else{if(!Wt(t))throw new Error(e+" must be hex string or Uint8Array");s=Uint8Array.from(t)}const r=s.length;if("number"==typeof i&&r!==i)throw new Error(e+" of length "+i+" expected, got "+r);return s}const Xt=e=>"bigint"==typeof e&&Ht<=e;function Qt(e,t,i,s){if(!function(e,t,i){return Xt(e)&&Xt(t)&&Xt(i)&&t<=e&&e<i}(t,i,s))throw new Error("expected valid "+e+": "+i+" <= n < "+s+", got "+t)}const Zt={bigint:e=>"bigint"==typeof e,function:e=>"function"==typeof e,boolean:e=>"boolean"==typeof e,string:e=>"string"==typeof e,stringOrUint8Array:e=>"string"==typeof e||Wt(e),isSafeInteger:e=>Number.isSafeInteger(e),array:e=>Array.isArray(e),field:(e,t)=>t.Fp.isValid(e),hash:e=>"function"==typeof e&&Number.isSafeInteger(e.outputLen)},ei=BigInt(0),ti=BigInt(1);function ii(e,t){const i=e%t;return i>=ei?i:t+i}function si(e,t,i){let s=e;for(;t-- >ei;)s*=s,s%=i;return s}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const ri=BigInt(0),ni=BigInt(1);const oi=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const ai=BigInt(1),ci=BigInt(2),hi=BigInt(3),di=BigInt(5);BigInt(8);const li=function(e){const t=function(e){return function(e,t,i={}){const s=(t,i,s)=>{const r=Zt[i];if("function"!=typeof r)throw new Error("invalid validator function");const n=e[t];if(!(s&&void 0===n||r(n,e)))throw new Error("param "+String(t)+" is invalid. Expected "+i+", got "+n)};for(const[e,i]of Object.entries(t))s(e,i,!1);for(const[e,t]of Object.entries(i))s(e,t,!0)}(e,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...e})}(e),{P:i}=t,s=e=>ii(e,i),r=t.montgomeryBits,n=Math.ceil(r/8),o=t.nByteLength,a=t.adjustScalarBytes||(e=>e),c=t.powPminus2||(e=>function(e,t,i){if(t<ei)throw new Error("invalid exponent, negatives unsupported");if(i<=ei)throw new Error("invalid modulus");if(i===ti)return ei;let s=ti;for(;t>ei;)t&ti&&(s=s*e%i),e=e*e%i,t>>=ti;return s}(e,i-BigInt(2),i));function h(e,t,i){const r=s(e*(t-i));return[t=s(t-r),i=s(i+r)]}const d=(t.a-BigInt(2))/BigInt(4);function l(e){return function(e,t){return function(e,t){return Gt(e.toString(16).padStart(2*t,"0"))}(e,t).reverse()}(s(e),n)}function u(e,t){const u=function(e){const t=Yt("u coordinate",e,n);return 32===o&&(t[31]&=127),Jt(t)}(t),p=function(e){const t=Yt("scalar",e),i=t.length;if(i!==n&&i!==o)throw new Error("invalid scalar, expected "+n+" or "+o+" bytes, got "+i);return Jt(a(t))}(e),f=function(e,t){Qt("u",e,ri,i),Qt("scalar",t,ri,i);const n=t,o=e;let a,l=ni,u=ri,p=e,f=ni,g=ri;for(let e=BigInt(r-1);e>=ri;e--){const t=n>>e∋g^=t,a=h(g,l,p),l=a[0],p=a[1],a=h(g,u,f),u=a[0],f=a[1],g=t;const i=l+u,r=s(i*i),c=l-u,m=s(c*c),b=r-m,y=p+f,w=s((p-f)*i),v=s(y*c),I=w+v,E=w-v;p=s(I*I),f=s(o*s(E*E)),l=s(r*m),u=s(b*(r+s(d*b)))}a=h(g,l,p),l=a[0],p=a[1],a=h(g,u,f),u=a[0],f=a[1];const m=c(u);return s(l*m)}(u,p);if(f===ri)throw new Error("invalid private or public key received");return l(f)}const p=l(t.Gu);function f(e){return u(e,p)}return{scalarMult:u,scalarMultBase:f,getSharedSecret:(e,t)=>u(e,t),getPublicKey:e=>f(e),utils:{randomPrivateKey:()=>t.randomBytes(t.nByteLength)},GuBytes:p}}({P:oi,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:e=>{const t=oi,{pow_p_5_8:i,b2:s}=function(e){const t=BigInt(10),i=BigInt(20),s=BigInt(40),r=BigInt(80),n=oi,o=e*e%n*e%n,a=si(o,ci,n)*o%n,c=si(a,ai,n)*e%n,h=si(c,di,n)*c%n,d=si(h,t,n)*h%n,l=si(d,i,n)*d%n,u=si(l,s,n)*l%n,p=si(u,r,n)*u%n,f=si(p,r,n)*u%n,g=si(f,t,n)*h%n;return{pow_p_5_8:si(g,ci,n)*e%n,b2:o}}(e);return ii(si(i,hi,t)*s,t)},adjustScalarBytes:function(e){return e[0]&=248,e[31]&=127,e[31]|=64,e},randomBytes:fe}),ui="base10",pi="base16",fi="base64pad",gi="base64url",mi="utf8",bi=0,yi=1,wi=2,vi=0,Ii=1,Ei=12,_i=32;function Ai(){const e=li.utils.randomPrivateKey(),t=li.getPublicKey(e);return{privateKey:(0,h.dI)(e,pi),publicKey:(0,h.dI)(t,pi)}}function Ni(){const e=fe(_i);return(0,h.dI)(e,pi)}function Ci(e,t){const i=li.getSharedSecret((0,h.sH)(e,pi),(0,h.sH)(t,pi)),s=Mt(zt,i,void 0,void 0,_i);return(0,h.dI)(s,pi)}function Si(e){const t=zt((0,h.sH)(e,pi));return(0,h.dI)(t,pi)}function Pi(e){const t=zt((0,h.sH)(e,mi));return(0,h.dI)(t,pi)}function Oi(e){return(0,h.sH)(`${e}`,ui)}function Ti(e){return Number((0,h.dI)(e,ui))}function xi(e){const t=Oi(typeof e.type<"u"?e.type:bi);if(Ti(t)===yi&&typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const i=typeof e.senderPublicKey<"u"?(0,h.sH)(e.senderPublicKey,pi):void 0,s=typeof e.iv<"u"?(0,h.sH)(e.iv,pi):fe(Ei),r=(0,h.sH)(e.symKey,pi);return Ui({type:t,sealed:Ot(r,s).encrypt((0,h.sH)(e.message,mi)),iv:s,senderPublicKey:i,encoding:e.encoding})}function ki(e){const t=(0,h.sH)(e.symKey,pi),{sealed:i,iv:s}=Di(e),r=Ot(t,s).decrypt(i);if(null===r)throw new Error("Failed to decrypt");return(0,h.dI)(r,mi)}function Ri(e,t){const i=Oi(wi),s=fe(Ei);return Ui({type:i,sealed:(0,h.sH)(e,mi),iv:s,encoding:t})}function Mi(e,t){const{sealed:i}=Di({encoded:e,encoding:t});return(0,h.dI)(i,mi)}function Ui(e){const{encoding:t=fi}=e;if(Ti(e.type)===wi)return(0,h.dI)((0,h.xW)([e.type,e.sealed]),t);if(Ti(e.type)===yi){if(typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return(0,h.dI)((0,h.xW)([e.type,e.senderPublicKey,e.iv,e.sealed]),t)}return(0,h.dI)((0,h.xW)([e.type,e.iv,e.sealed]),t)}function Di(e){const{encoded:t,encoding:i=fi}=e,s=(0,h.sH)(t,i),r=s.slice(vi,Ii),n=Ii;if(Ti(r)===yi){const e=n+_i,t=e+Ei,i=s.slice(n,e),o=s.slice(e,t);return{type:r,sealed:s.slice(t),iv:o,senderPublicKey:i}}if(Ti(r)===wi)return{type:r,sealed:s.slice(n),iv:fe(Ei)};const o=n+Ei,a=s.slice(n,o);return{type:r,sealed:s.slice(o),iv:a}}function ji(e,t){const i=Di({encoded:e,encoding:t?.encoding});return Li({type:Ti(i.type),senderPublicKey:typeof i.senderPublicKey<"u"?(0,h.dI)(i.senderPublicKey,pi):void 0,receiverPublicKey:t?.receiverPublicKey})}function Li(e){const t=e?.type||bi;if(t===yi){if(typeof e?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof e?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:e?.senderPublicKey,receiverPublicKey:e?.receiverPublicKey}}function qi(e){return e.type===yi&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}function $i(e){return e.type===wi}function Bi(e,t){const[i,s,r]=e.split("."),n=function(e){return p.from(function(e){let t=e.replace(/-/g,"+").replace(/_/g,"/");const i=t.length%4;return i>0&&(t+="=".repeat(4-i)),t}(e),"base64")}(r);if(64!==n.length)throw new Error("Invalid signature length");const o=n.slice(0,32).toString("hex"),a=n.slice(32,64).toString("hex"),l=zt(`${i}.${s}`),u=function(e){return new d.ec("p256").keyFromPublic({x:p.from(e.x,"base64").toString("hex"),y:p.from(e.y,"base64").toString("hex")},"hex")}(t),f=(0,h.dI)(l,pi);if(!u.verify(f,{r:o,s:a}))throw new Error("Invalid signature");return(0,c.Cq)(e).payload}const zi="irn";function Hi(e){return e?.relay||{protocol:zi}}function Wi(e){const t=l.CG[e];if(typeof t>"u")throw new Error(`Relay Protocol not supported: ${e}`);return t}function Vi(e,t="-"){const i={},s="relay"+t;return Object.keys(e).forEach(t=>{if(t.startsWith(s)){const r=t.replace(s,""),n=e[t];i[r]=n}}),i}function Fi(e){if(!e.includes("wc:")){const t=J(e);null!=t&&t.includes("wc:")&&(e=t)}const t=(e=(e=e.includes("wc://")?e.replace("wc://",""):e).includes("wc:")?e.replace("wc:",""):e).indexOf(":"),i=-1!==e.indexOf("?")?e.indexOf("?"):void 0,s=e.substring(0,t),r=e.substring(t+1,i).split("@"),n=typeof i<"u"?e.substring(i):"",o=new URLSearchParams(n),a={};o.forEach((e,t)=>{a[t]=e});const c="string"==typeof a.methods?a.methods.split(","):void 0;return{protocol:s,topic:Ki(r[0]),version:parseInt(r[1],10),symKey:a.symKey,relay:Vi(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function Ki(e){return e.startsWith("//")?e.substring(2):e}function Gi(e){const t=new URLSearchParams,i=function(e,t="-"){const i={};return Object.keys(e).forEach(s=>{const r=s,n="relay"+t+r;e[r]&&(i[n]=e[r])}),i}(e.relay);Object.keys(i).sort().forEach(e=>{t.set(e,i[e])}),t.set("symKey",e.symKey),e.expiryTimestamp&&t.set("expiryTimestamp",e.expiryTimestamp.toString()),e.methods&&t.set("methods",e.methods.join(","));const s=t.toString();return`${e.protocol}:${e.topic}@${e.version}?${s}`}function Ji(e,t,i){return`${e}?wc_ev=${i}&topic=${t}`}function Yi(e){const t=[];return e.forEach(e=>{const[i,s]=e.split(":");t.push(`${i}:${s}`)}),t}function Xi(e){return e.includes(":")}function Qi(e){return Xi(e)?e.split(":")[0]:e}function Zi(e,t){const i=function(e){const t={};return e?.forEach(e=>{var i;const[s,r]=e.split(":");t[s]||(t[s]={accounts:[],chains:[],events:[],methods:[]}),t[s].accounts.push(e),null==(i=t[s].chains)||i.push(`${s}:${r}`)}),t}(t=t.map(e=>e.replace("did:pkh:","")));for(const[t,s]of Object.entries(i))s.methods?s.methods=H(s.methods,e):s.methods=e,s.events=["chainChanged","accountsChanged"];return i}Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable;const es={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},ts={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function is(e,t){const{message:i,code:s}=ts[e];return{message:t?`${i} ${t}`:i,code:s}}function ss(e,t){const{message:i,code:s}=es[e];return{message:t?`${i} ${t}`:i,code:s}}function rs(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function ns(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function os(e){return typeof e>"u"}function as(e,t){return!(!t||!os(e))||"string"==typeof e&&!!e.trim().length}function cs(e,t){return!(!t||!os(e))||"number"==typeof e&&!isNaN(e)}function hs(e,t){const{requiredNamespaces:i}=t,s=Object.keys(e.namespaces),r=Object.keys(i);let n=!0;return!!x(r,s)&&(s.forEach(t=>{const{accounts:s,methods:r,events:o}=e.namespaces[t],a=Yi(s),c=i[t];x(b(t,c),a)&&x(c.methods,r)&&x(c.events,o)||(n=!1)}),n)}function ds(e){return!(!as(e,!1)||!e.includes(":"))&&2===e.split(":").length}function ls(e){function t(e){try{return typeof new URL(e)<"u"}catch{return!1}}try{if(as(e,!1))return!!t(e)||t(J(e))}catch{}return!1}function us(e){var t;return null==(t=e?.proposer)?void 0:t.publicKey}function ps(e){return e?.topic}function fs(e,t){let i=null;return as(e?.publicKey,!1)||(i=is("MISSING_OR_INVALID",`${t} controller public key should be a string`)),i}function gs(e){let t=!0;return rs(e)?e.length&&(t=e.every(e=>as(e,!1))):t=!1,t}function ms(e,t){let i=null;return Object.values(e).forEach(e=>{if(i)return;const s=function(e,t){let i=null;return gs(e?.methods)?gs(e?.events)||(i=ss("UNSUPPORTED_EVENTS",`${t}, events should be an array of strings or empty array for no events`)):i=ss("UNSUPPORTED_METHODS",`${t}, methods should be an array of strings or empty array for no methods`),i}(e,`${t}, namespace`);s&&(i=s)}),i}function bs(e,t,i){let s=null;if(e&&ns(e)){const r=ms(e,t);r&&(s=r);const n=function(e,t,i){let s=null;return Object.entries(e).forEach(([e,r])=>{if(s)return;const n=function(e,t,i){let s=null;return rs(t)&&t.length?t.forEach(e=>{s||ds(e)||(s=ss("UNSUPPORTED_CHAINS",`${i}, chain ${e} should be a string and conform to "namespace:chainId" format`))}):ds(e)||(s=ss("UNSUPPORTED_CHAINS",`${i}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),s}(e,b(e,r),`${t} ${i}`);n&&(s=n)}),s}(e,t,i);n&&(s=n)}else s=is("MISSING_OR_INVALID",`${t}, ${i} should be an object with data`);return s}function ys(e,t){let i=null;if(e&&ns(e)){const s=ms(e,t);s&&(i=s);const r=function(e,t){let i=null;return Object.values(e).forEach(e=>{if(i)return;const s=function(e,t){let i=null;return rs(e)?e.forEach(e=>{i||function(e){if(as(e,!1)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&ds(e)}}return!1}(e)||(i=ss("UNSUPPORTED_ACCOUNTS",`${t}, account ${e} should be a string and conform to "namespace:chainId:address" format`))}):i=ss("UNSUPPORTED_ACCOUNTS",`${t}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),i}(e?.accounts,`${t} namespace`);s&&(i=s)}),i}(e,t);r&&(i=r)}else i=is("MISSING_OR_INVALID",`${t}, namespaces should be an object with data`);return i}function ws(e){return as(e.protocol,!0)}function vs(e,t){let i=!1;return t&&!e?i=!0:e&&rs(e)&&e.length&&e.forEach(e=>{i=ws(e)}),i}function Is(e){return"number"==typeof e}function Es(e){return typeof e<"u"&&null!==typeof e}function _s(e){return!!(e&&"object"==typeof e&&e.code&&cs(e.code,!1)&&e.message&&as(e.message,!1))}function As(e){return!(os(e)||!as(e.method,!1))}function Ns(e){return!(os(e)||os(e.result)&&os(e.error)||!cs(e.id,!1)||!as(e.jsonrpc,!1))}function Cs(e){return!(os(e)||!as(e.name,!1))}function Ss(e,t){return!(!ds(t)||!function(e){const t=[];return Object.values(e).forEach(e=>{t.push(...Yi(e.accounts))}),t}(e).includes(t))}function Ps(e,t,i){return!!as(i,!1)&&function(e,t){const i=[];return Object.values(e).forEach(e=>{Yi(e.accounts).includes(t)&&i.push(...e.methods)}),i}(e,t).includes(i)}function Os(e,t,i){return!!as(i,!1)&&function(e,t){const i=[];return Object.values(e).forEach(e=>{Yi(e.accounts).includes(t)&&i.push(...e.events)}),i}(e,t).includes(i)}function Ts(e,t,i){let s=null;const r=function(e){const t={};return Object.keys(e).forEach(i=>{var s;i.includes(":")?t[i]=e[i]:null==(s=e[i].chains)||s.forEach(s=>{t[s]={methods:e[i].methods,events:e[i].events}})}),t}(e),n=function(e){const t={};return Object.keys(e).forEach(i=>{if(i.includes(":"))t[i]=e[i];else{const s=Yi(e[i].accounts);s?.forEach(s=>{t[s]={accounts:e[i].accounts.filter(e=>e.includes(`${s}:`)),methods:e[i].methods,events:e[i].events}})}}),t}(t),o=Object.keys(r),a=Object.keys(n),c=xs(Object.keys(e)),h=xs(Object.keys(t)),d=c.filter(e=>!h.includes(e));return d.length&&(s=is("NON_CONFORMING_NAMESPACES",`${i} namespaces keys don't satisfy requiredNamespaces.\n Required: ${d.toString()}\n Received: ${Object.keys(t).toString()}`)),x(o,a)||(s=is("NON_CONFORMING_NAMESPACES",`${i} namespaces chains don't satisfy required namespaces.\n Required: ${o.toString()}\n Approved: ${a.toString()}`)),Object.keys(t).forEach(e=>{if(!e.includes(":")||s)return;const r=Yi(t[e].accounts);r.includes(e)||(s=is("NON_CONFORMING_NAMESPACES",`${i} namespaces accounts don't satisfy namespace accounts for ${e}\n Required: ${e}\n Approved: ${r.toString()}`))}),o.forEach(e=>{s||(x(r[e].methods,n[e].methods)?x(r[e].events,n[e].events)||(s=is("NON_CONFORMING_NAMESPACES",`${i} namespaces events don't satisfy namespace events for ${e}`)):s=is("NON_CONFORMING_NAMESPACES",`${i} namespaces methods don't satisfy namespace methods for ${e}`))}),s}function xs(e){return[...new Set(e.map(e=>e.includes(":")?e.split(":")[0]:e))]}function ks(e,t){return cs(e,!1)&&e<=t.max&&e>=t.min}function Rs(){const e=C();return new Promise(t=>{switch(e){case w.browser:t(N()&&navigator?.onLine);break;case w.reactNative:t(async function(){if(E()&&typeof i.g<"u"&&null!=i.g&&i.g.NetInfo){const e=await(null==i.g?void 0:i.g.NetInfo.fetch());return e?.isConnected}return!0}());break;case w.node:default:t(!0)}})}function Ms(e){switch(C()){case w.browser:!function(e){!E()&&N()&&(window.addEventListener("online",()=>e(!0)),window.addEventListener("offline",()=>e(!1)))}(e);break;case w.reactNative:!function(e){E()&&typeof i.g<"u"&&null!=i.g&&i.g.NetInfo&&i.g?.NetInfo.addEventListener(t=>e(t?.isConnected))}(e);case w.node:}}const Us={};class Ds{static get(e){return Us[e]}static set(e,t){Us[e]=t}static delete(e){delete Us[e]}}},78760:(e,t,i)=>{i.d(t,{p:()=>r});const s=2147483648,r={convertEVMChainIdToCoinType(e){if(e>=s)throw new Error("Invalid chainId");return(s|e)>>>0}}},79473:(e,t,i)=>{i.d(t,{A:()=>a});var s=i(89168),r=i(39150);const n={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0},o=(0,s.BX)({providers:{...n},providerIds:{...n}}),a={state:o,subscribeKey:(e,t)=>(0,r.u$)(o,e,t),subscribe:e=>(0,s.B1)(o,()=>{e(o)}),subscribeProviders:e=>(0,s.B1)(o.providers,()=>e(o.providers)),setProvider(e,t){t&&(o.providers[e]=(0,s.KR)(t))},getProvider:e=>o.providers[e],setProviderId(e,t){t&&(o.providerIds[e]=t)},getProviderId(e){if(e)return o.providerIds[e]},reset(){o.providers={...n},o.providerIds={...n}},resetChain(e){o.providers[e]=void 0,o.providerIds[e]=void 0}}},82420:(e,t,i)=>{i.d(t,{R:()=>s});const s={UniversalProviderErrors:{UNAUTHORIZED_DOMAIN_NOT_ALLOWED:{message:"Unauthorized: origin not allowed",alertErrorKey:"INVALID_APP_CONFIGURATION"},JWT_VALIDATION_ERROR:{message:"JWT validation error: JWT Token is not yet valid",alertErrorKey:"JWT_TOKEN_NOT_VALID"},INVALID_KEY:{message:"Unauthorized: invalid key",alertErrorKey:"INVALID_PROJECT_ID"}},ALERT_ERRORS:{SWITCH_NETWORK_NOT_FOUND:{shortMessage:"Network Not Found",longMessage:"Network not found - please make sure it is included in 'networks' array in createAppKit function"},INVALID_APP_CONFIGURATION:{shortMessage:"Invalid App Configuration",longMessage:()=>`Origin ${"undefined"!=typeof window?window.origin:"unknown"} not found on Allowlist - update configuration on cloud.reown.com`},SOCIALS_TIMEOUT:{shortMessage:"Invalid App Configuration",longMessage:()=>"There was an issue loading the embedded wallet. Please verify that your domain is allowed at cloud.reown.com"},JWT_TOKEN_NOT_VALID:{shortMessage:"Session Expired",longMessage:"Invalid session found on UniversalProvider - please check your time settings and connect again"},INVALID_PROJECT_ID:{shortMessage:"Invalid App Configuration",longMessage:"Invalid Project ID - update configuration"},PROJECT_ID_NOT_CONFIGURED:{shortMessage:"Project ID Not Configured",longMessage:"Project ID Not Configured - update configuration on cloud.reown.com"}}}},83986:e=>{e.exports={doubles:{step:4,points:[["e60fce93b59e9ec53011aabc21c23e97b2a31369b87a5ae9c44ee89e2a6dec0a","f7e3507399e595929db99f34f57937101296891e44d23f0be1f32cce69616821"],["8282263212c609d9ea2a6e3e172de238d8c39cabd5ac1ca10646e23fd5f51508","11f8a8098557dfe45e8256e830b60ace62d613ac2f7b17bed31b6eaff6e26caf"],["175e159f728b865a72f99cc6c6fc846de0b93833fd2222ed73fce5b551e5b739","d3506e0d9e3c79eba4ef97a51ff71f5eacb5955add24345c6efa6ffee9fed695"],["363d90d447b00c9c99ceac05b6262ee053441c7e55552ffe526bad8f83ff4640","4e273adfc732221953b445397f3363145b9a89008199ecb62003c7f3bee9de9"],["8b4b5f165df3c2be8c6244b5b745638843e4a781a15bcd1b69f79a55dffdf80c","4aad0a6f68d308b4b3fbd7813ab0da04f9e336546162ee56b3eff0c65fd4fd36"],["723cbaa6e5db996d6bf771c00bd548c7b700dbffa6c0e77bcb6115925232fcda","96e867b5595cc498a921137488824d6e2660a0653779494801dc069d9eb39f5f"],["eebfa4d493bebf98ba5feec812c2d3b50947961237a919839a533eca0e7dd7fa","5d9a8ca3970ef0f269ee7edaf178089d9ae4cdc3a711f712ddfd4fdae1de8999"],["100f44da696e71672791d0a09b7bde459f1215a29b3c03bfefd7835b39a48db0","cdd9e13192a00b772ec8f3300c090666b7ff4a18ff5195ac0fbd5cd62bc65a09"],["e1031be262c7ed1b1dc9227a4a04c017a77f8d4464f3b3852c8acde6e534fd2d","9d7061928940405e6bb6a4176597535af292dd419e1ced79a44f18f29456a00d"],["feea6cae46d55b530ac2839f143bd7ec5cf8b266a41d6af52d5e688d9094696d","e57c6b6c97dce1bab06e4e12bf3ecd5c981c8957cc41442d3155debf18090088"],["da67a91d91049cdcb367be4be6ffca3cfeed657d808583de33fa978bc1ec6cb1","9bacaa35481642bc41f463f7ec9780e5dec7adc508f740a17e9ea8e27a68be1d"],["53904faa0b334cdda6e000935ef22151ec08d0f7bb11069f57545ccc1a37b7c0","5bc087d0bc80106d88c9eccac20d3c1c13999981e14434699dcb096b022771c8"],["8e7bcd0bd35983a7719cca7764ca906779b53a043a9b8bcaeff959f43ad86047","10b7770b2a3da4b3940310420ca9514579e88e2e47fd68b3ea10047e8460372a"],["385eed34c1cdff21e6d0818689b81bde71a7f4f18397e6690a841e1599c43862","283bebc3e8ea23f56701de19e9ebf4576b304eec2086dc8cc0458fe5542e5453"],["6f9d9b803ecf191637c73a4413dfa180fddf84a5947fbc9c606ed86c3fac3a7","7c80c68e603059ba69b8e2a30e45c4d47ea4dd2f5c281002d86890603a842160"],["3322d401243c4e2582a2147c104d6ecbf774d163db0f5e5313b7e0e742d0e6bd","56e70797e9664ef5bfb019bc4ddaf9b72805f63ea2873af624f3a2e96c28b2a0"],["85672c7d2de0b7da2bd1770d89665868741b3f9af7643397721d74d28134ab83","7c481b9b5b43b2eb6374049bfa62c2e5e77f17fcc5298f44c8e3094f790313a6"],["948bf809b1988a46b06c9f1919413b10f9226c60f668832ffd959af60c82a0a","53a562856dcb6646dc6b74c5d1c3418c6d4dff08c97cd2bed4cb7f88d8c8e589"],["6260ce7f461801c34f067ce0f02873a8f1b0e44dfc69752accecd819f38fd8e8","bc2da82b6fa5b571a7f09049776a1ef7ecd292238051c198c1a84e95b2b4ae17"],["e5037de0afc1d8d43d8348414bbf4103043ec8f575bfdc432953cc8d2037fa2d","4571534baa94d3b5f9f98d09fb990bddbd5f5b03ec481f10e0e5dc841d755bda"],["e06372b0f4a207adf5ea905e8f1771b4e7e8dbd1c6a6c5b725866a0ae4fce725","7a908974bce18cfe12a27bb2ad5a488cd7484a7787104870b27034f94eee31dd"],["213c7a715cd5d45358d0bbf9dc0ce02204b10bdde2a3f58540ad6908d0559754","4b6dad0b5ae462507013ad06245ba190bb4850f5f36a7eeddff2c27534b458f2"],["4e7c272a7af4b34e8dbb9352a5419a87e2838c70adc62cddf0cc3a3b08fbd53c","17749c766c9d0b18e16fd09f6def681b530b9614bff7dd33e0b3941817dcaae6"],["fea74e3dbe778b1b10f238ad61686aa5c76e3db2be43057632427e2840fb27b6","6e0568db9b0b13297cf674deccb6af93126b596b973f7b77701d3db7f23cb96f"],["76e64113f677cf0e10a2570d599968d31544e179b760432952c02a4417bdde39","c90ddf8dee4e95cf577066d70681f0d35e2a33d2b56d2032b4b1752d1901ac01"],["c738c56b03b2abe1e8281baa743f8f9a8f7cc643df26cbee3ab150242bcbb891","893fb578951ad2537f718f2eacbfbbbb82314eef7880cfe917e735d9699a84c3"],["d895626548b65b81e264c7637c972877d1d72e5f3a925014372e9f6588f6c14b","febfaa38f2bc7eae728ec60818c340eb03428d632bb067e179363ed75d7d991f"],["b8da94032a957518eb0f6433571e8761ceffc73693e84edd49150a564f676e03","2804dfa44805a1e4d7c99cc9762808b092cc584d95ff3b511488e4e74efdf6e7"],["e80fea14441fb33a7d8adab9475d7fab2019effb5156a792f1a11778e3c0df5d","eed1de7f638e00771e89768ca3ca94472d155e80af322ea9fcb4291b6ac9ec78"],["a301697bdfcd704313ba48e51d567543f2a182031efd6915ddc07bbcc4e16070","7370f91cfb67e4f5081809fa25d40f9b1735dbf7c0a11a130c0d1a041e177ea1"],["90ad85b389d6b936463f9d0512678de208cc330b11307fffab7ac63e3fb04ed4","e507a3620a38261affdcbd9427222b839aefabe1582894d991d4d48cb6ef150"],["8f68b9d2f63b5f339239c1ad981f162ee88c5678723ea3351b7b444c9ec4c0da","662a9f2dba063986de1d90c2b6be215dbbea2cfe95510bfdf23cbf79501fff82"],["e4f3fb0176af85d65ff99ff9198c36091f48e86503681e3e6686fd5053231e11","1e63633ad0ef4f1c1661a6d0ea02b7286cc7e74ec951d1c9822c38576feb73bc"],["8c00fa9b18ebf331eb961537a45a4266c7034f2f0d4e1d0716fb6eae20eae29e","efa47267fea521a1a9dc343a3736c974c2fadafa81e36c54e7d2a4c66702414b"],["e7a26ce69dd4829f3e10cec0a9e98ed3143d084f308b92c0997fddfc60cb3e41","2a758e300fa7984b471b006a1aafbb18d0a6b2c0420e83e20e8a9421cf2cfd51"],["b6459e0ee3662ec8d23540c223bcbdc571cbcb967d79424f3cf29eb3de6b80ef","67c876d06f3e06de1dadf16e5661db3c4b3ae6d48e35b2ff30bf0b61a71ba45"],["d68a80c8280bb840793234aa118f06231d6f1fc67e73c5a5deda0f5b496943e8","db8ba9fff4b586d00c4b1f9177b0e28b5b0e7b8f7845295a294c84266b133120"],["324aed7df65c804252dc0270907a30b09612aeb973449cea4095980fc28d3d5d","648a365774b61f2ff130c0c35aec1f4f19213b0c7e332843967224af96ab7c84"],["4df9c14919cde61f6d51dfdbe5fee5dceec4143ba8d1ca888e8bd373fd054c96","35ec51092d8728050974c23a1d85d4b5d506cdc288490192ebac06cad10d5d"],["9c3919a84a474870faed8a9c1cc66021523489054d7f0308cbfc99c8ac1f98cd","ddb84f0f4a4ddd57584f044bf260e641905326f76c64c8e6be7e5e03d4fc599d"],["6057170b1dd12fdf8de05f281d8e06bb91e1493a8b91d4cc5a21382120a959e5","9a1af0b26a6a4807add9a2daf71df262465152bc3ee24c65e899be932385a2a8"],["a576df8e23a08411421439a4518da31880cef0fba7d4df12b1a6973eecb94266","40a6bf20e76640b2c92b97afe58cd82c432e10a7f514d9f3ee8be11ae1b28ec8"],["7778a78c28dec3e30a05fe9629de8c38bb30d1f5cf9a3a208f763889be58ad71","34626d9ab5a5b22ff7098e12f2ff580087b38411ff24ac563b513fc1fd9f43ac"],["928955ee637a84463729fd30e7afd2ed5f96274e5ad7e5cb09eda9c06d903ac","c25621003d3f42a827b78a13093a95eeac3d26efa8a8d83fc5180e935bcd091f"],["85d0fef3ec6db109399064f3a0e3b2855645b4a907ad354527aae75163d82751","1f03648413a38c0be29d496e582cf5663e8751e96877331582c237a24eb1f962"],["ff2b0dce97eece97c1c9b6041798b85dfdfb6d8882da20308f5404824526087e","493d13fef524ba188af4c4dc54d07936c7b7ed6fb90e2ceb2c951e01f0c29907"],["827fbbe4b1e880ea9ed2b2e6301b212b57f1ee148cd6dd28780e5e2cf856e241","c60f9c923c727b0b71bef2c67d1d12687ff7a63186903166d605b68baec293ec"],["eaa649f21f51bdbae7be4ae34ce6e5217a58fdce7f47f9aa7f3b58fa2120e2b3","be3279ed5bbbb03ac69a80f89879aa5a01a6b965f13f7e59d47a5305ba5ad93d"],["e4a42d43c5cf169d9391df6decf42ee541b6d8f0c9a137401e23632dda34d24f","4d9f92e716d1c73526fc99ccfb8ad34ce886eedfa8d8e4f13a7f7131deba9414"],["1ec80fef360cbdd954160fadab352b6b92b53576a88fea4947173b9d4300bf19","aeefe93756b5340d2f3a4958a7abbf5e0146e77f6295a07b671cdc1cc107cefd"],["146a778c04670c2f91b00af4680dfa8bce3490717d58ba889ddb5928366642be","b318e0ec3354028add669827f9d4b2870aaa971d2f7e5ed1d0b297483d83efd0"],["fa50c0f61d22e5f07e3acebb1aa07b128d0012209a28b9776d76a8793180eef9","6b84c6922397eba9b72cd2872281a68a5e683293a57a213b38cd8d7d3f4f2811"],["da1d61d0ca721a11b1a5bf6b7d88e8421a288ab5d5bba5220e53d32b5f067ec2","8157f55a7c99306c79c0766161c91e2966a73899d279b48a655fba0f1ad836f1"],["a8e282ff0c9706907215ff98e8fd416615311de0446f1e062a73b0610d064e13","7f97355b8db81c09abfb7f3c5b2515888b679a3e50dd6bd6cef7c73111f4cc0c"],["174a53b9c9a285872d39e56e6913cab15d59b1fa512508c022f382de8319497c","ccc9dc37abfc9c1657b4155f2c47f9e6646b3a1d8cb9854383da13ac079afa73"],["959396981943785c3d3e57edf5018cdbe039e730e4918b3d884fdff09475b7ba","2e7e552888c331dd8ba0386a4b9cd6849c653f64c8709385e9b8abf87524f2fd"],["d2a63a50ae401e56d645a1153b109a8fcca0a43d561fba2dbb51340c9d82b151","e82d86fb6443fcb7565aee58b2948220a70f750af484ca52d4142174dcf89405"],["64587e2335471eb890ee7896d7cfdc866bacbdbd3839317b3436f9b45617e073","d99fcdd5bf6902e2ae96dd6447c299a185b90a39133aeab358299e5e9faf6589"],["8481bde0e4e4d885b3a546d3e549de042f0aa6cea250e7fd358d6c86dd45e458","38ee7b8cba5404dd84a25bf39cecb2ca900a79c42b262e556d64b1b59779057e"],["13464a57a78102aa62b6979ae817f4637ffcfed3c4b1ce30bcd6303f6caf666b","69be159004614580ef7e433453ccb0ca48f300a81d0942e13f495a907f6ecc27"],["bc4a9df5b713fe2e9aef430bcc1dc97a0cd9ccede2f28588cada3a0d2d83f366","d3a81ca6e785c06383937adf4b798caa6e8a9fbfa547b16d758d666581f33c1"],["8c28a97bf8298bc0d23d8c749452a32e694b65e30a9472a3954ab30fe5324caa","40a30463a3305193378fedf31f7cc0eb7ae784f0451cb9459e71dc73cbef9482"],["8ea9666139527a8c1dd94ce4f071fd23c8b350c5a4bb33748c4ba111faccae0","620efabbc8ee2782e24e7c0cfb95c5d735b783be9cf0f8e955af34a30e62b945"],["dd3625faef5ba06074669716bbd3788d89bdde815959968092f76cc4eb9a9787","7a188fa3520e30d461da2501045731ca941461982883395937f68d00c644a573"],["f710d79d9eb962297e4f6232b40e8f7feb2bc63814614d692c12de752408221e","ea98e67232d3b3295d3b535532115ccac8612c721851617526ae47a9c77bfc82"]]},naf:{wnd:7,points:[["f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9","388f7b0f632de8140fe337e62a37f3566500a99934c2231b6cb9fd7584b8e672"],["2f8bde4d1a07209355b4a7250a5c5128e88b84bddc619ab7cba8d569b240efe4","d8ac222636e5e3d6d4dba9dda6c9c426f788271bab0d6840dca87d3aa6ac62d6"],["5cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc","6aebca40ba255960a3178d6d861a54dba813d0b813fde7b5a5082628087264da"],["acd484e2f0c7f65309ad178a9f559abde09796974c57e714c35f110dfc27ccbe","cc338921b0a7d9fd64380971763b61e9add888a4375f8e0f05cc262ac64f9c37"],["774ae7f858a9411e5ef4246b70c65aac5649980be5c17891bbec17895da008cb","d984a032eb6b5e190243dd56d7b7b365372db1e2dff9d6a8301d74c9c953c61b"],["f28773c2d975288bc7d1d205c3748651b075fbc6610e58cddeeddf8f19405aa8","ab0902e8d880a89758212eb65cdaf473a1a06da521fa91f29b5cb52db03ed81"],["d7924d4f7d43ea965a465ae3095ff41131e5946f3c85f79e44adbcf8e27e080e","581e2872a86c72a683842ec228cc6defea40af2bd896d3a5c504dc9ff6a26b58"],["defdea4cdb677750a420fee807eacf21eb9898ae79b9768766e4faa04a2d4a34","4211ab0694635168e997b0ead2a93daeced1f4a04a95c0f6cfb199f69e56eb77"],["2b4ea0a797a443d293ef5cff444f4979f06acfebd7e86d277475656138385b6c","85e89bc037945d93b343083b5a1c86131a01f60c50269763b570c854e5c09b7a"],["352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5","321eb4075348f534d59c18259dda3e1f4a1b3b2e71b1039c67bd3d8bcf81998c"],["2fa2104d6b38d11b0230010559879124e42ab8dfeff5ff29dc9cdadd4ecacc3f","2de1068295dd865b64569335bd5dd80181d70ecfc882648423ba76b532b7d67"],["9248279b09b4d68dab21a9b066edda83263c3d84e09572e269ca0cd7f5453714","73016f7bf234aade5d1aa71bdea2b1ff3fc0de2a887912ffe54a32ce97cb3402"],["daed4f2be3a8bf278e70132fb0beb7522f570e144bf615c07e996d443dee8729","a69dce4a7d6c98e8d4a1aca87ef8d7003f83c230f3afa726ab40e52290be1c55"],["c44d12c7065d812e8acf28d7cbb19f9011ecd9e9fdf281b0e6a3b5e87d22e7db","2119a460ce326cdc76c45926c982fdac0e106e861edf61c5a039063f0e0e6482"],["6a245bf6dc698504c89a20cfded60853152b695336c28063b61c65cbd269e6b4","e022cf42c2bd4a708b3f5126f16a24ad8b33ba48d0423b6efd5e6348100d8a82"],["1697ffa6fd9de627c077e3d2fe541084ce13300b0bec1146f95ae57f0d0bd6a5","b9c398f186806f5d27561506e4557433a2cf15009e498ae7adee9d63d01b2396"],["605bdb019981718b986d0f07e834cb0d9deb8360ffb7f61df982345ef27a7479","2972d2de4f8d20681a78d93ec96fe23c26bfae84fb14db43b01e1e9056b8c49"],["62d14dab4150bf497402fdc45a215e10dcb01c354959b10cfe31c7e9d87ff33d","80fc06bd8cc5b01098088a1950eed0db01aa132967ab472235f5642483b25eaf"],["80c60ad0040f27dade5b4b06c408e56b2c50e9f56b9b8b425e555c2f86308b6f","1c38303f1cc5c30f26e66bad7fe72f70a65eed4cbe7024eb1aa01f56430bd57a"],["7a9375ad6167ad54aa74c6348cc54d344cc5dc9487d847049d5eabb0fa03c8fb","d0e3fa9eca8726909559e0d79269046bdc59ea10c70ce2b02d499ec224dc7f7"],["d528ecd9b696b54c907a9ed045447a79bb408ec39b68df504bb51f459bc3ffc9","eecf41253136e5f99966f21881fd656ebc4345405c520dbc063465b521409933"],["49370a4b5f43412ea25f514e8ecdad05266115e4a7ecb1387231808f8b45963","758f3f41afd6ed428b3081b0512fd62a54c3f3afbb5b6764b653052a12949c9a"],["77f230936ee88cbbd73df930d64702ef881d811e0e1498e2f1c13eb1fc345d74","958ef42a7886b6400a08266e9ba1b37896c95330d97077cbbe8eb3c7671c60d6"],["f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530","e0dedc9b3b2f8dad4da1f32dec2531df9eb5fbeb0598e4fd1a117dba703a3c37"],["463b3d9f662621fb1b4be8fbbe2520125a216cdfc9dae3debcba4850c690d45b","5ed430d78c296c3543114306dd8622d7c622e27c970a1de31cb377b01af7307e"],["f16f804244e46e2a09232d4aff3b59976b98fac14328a2d1a32496b49998f247","cedabd9b82203f7e13d206fcdf4e33d92a6c53c26e5cce26d6579962c4e31df6"],["caf754272dc84563b0352b7a14311af55d245315ace27c65369e15f7151d41d1","cb474660ef35f5f2a41b643fa5e460575f4fa9b7962232a5c32f908318a04476"],["2600ca4b282cb986f85d0f1709979d8b44a09c07cb86d7c124497bc86f082120","4119b88753c15bd6a693b03fcddbb45d5ac6be74ab5f0ef44b0be9475a7e4b40"],["7635ca72d7e8432c338ec53cd12220bc01c48685e24f7dc8c602a7746998e435","91b649609489d613d1d5e590f78e6d74ecfc061d57048bad9e76f302c5b9c61"],["754e3239f325570cdbbf4a87deee8a66b7f2b33479d468fbc1a50743bf56cc18","673fb86e5bda30fb3cd0ed304ea49a023ee33d0197a695d0c5d98093c536683"],["e3e6bd1071a1e96aff57859c82d570f0330800661d1c952f9fe2694691d9b9e8","59c9e0bba394e76f40c0aa58379a3cb6a5a2283993e90c4167002af4920e37f5"],["186b483d056a033826ae73d88f732985c4ccb1f32ba35f4b4cc47fdcf04aa6eb","3b952d32c67cf77e2e17446e204180ab21fb8090895138b4a4a797f86e80888b"],["df9d70a6b9876ce544c98561f4be4f725442e6d2b737d9c91a8321724ce0963f","55eb2dafd84d6ccd5f862b785dc39d4ab157222720ef9da217b8c45cf2ba2417"],["5edd5cc23c51e87a497ca815d5dce0f8ab52554f849ed8995de64c5f34ce7143","efae9c8dbc14130661e8cec030c89ad0c13c66c0d17a2905cdc706ab7399a868"],["290798c2b6476830da12fe02287e9e777aa3fba1c355b17a722d362f84614fba","e38da76dcd440621988d00bcf79af25d5b29c094db2a23146d003afd41943e7a"],["af3c423a95d9f5b3054754efa150ac39cd29552fe360257362dfdecef4053b45","f98a3fd831eb2b749a93b0e6f35cfb40c8cd5aa667a15581bc2feded498fd9c6"],["766dbb24d134e745cccaa28c99bf274906bb66b26dcf98df8d2fed50d884249a","744b1152eacbe5e38dcc887980da38b897584a65fa06cedd2c924f97cbac5996"],["59dbf46f8c94759ba21277c33784f41645f7b44f6c596a58ce92e666191abe3e","c534ad44175fbc300f4ea6ce648309a042ce739a7919798cd85e216c4a307f6e"],["f13ada95103c4537305e691e74e9a4a8dd647e711a95e73cb62dc6018cfd87b8","e13817b44ee14de663bf4bc808341f326949e21a6a75c2570778419bdaf5733d"],["7754b4fa0e8aced06d4167a2c59cca4cda1869c06ebadfb6488550015a88522c","30e93e864e669d82224b967c3020b8fa8d1e4e350b6cbcc537a48b57841163a2"],["948dcadf5990e048aa3874d46abef9d701858f95de8041d2a6828c99e2262519","e491a42537f6e597d5d28a3224b1bc25df9154efbd2ef1d2cbba2cae5347d57e"],["7962414450c76c1689c7b48f8202ec37fb224cf5ac0bfa1570328a8a3d7c77ab","100b610ec4ffb4760d5c1fc133ef6f6b12507a051f04ac5760afa5b29db83437"],["3514087834964b54b15b160644d915485a16977225b8847bb0dd085137ec47ca","ef0afbb2056205448e1652c48e8127fc6039e77c15c2378b7e7d15a0de293311"],["d3cc30ad6b483e4bc79ce2c9dd8bc54993e947eb8df787b442943d3f7b527eaf","8b378a22d827278d89c5e9be8f9508ae3c2ad46290358630afb34db04eede0a4"],["1624d84780732860ce1c78fcbfefe08b2b29823db913f6493975ba0ff4847610","68651cf9b6da903e0914448c6cd9d4ca896878f5282be4c8cc06e2a404078575"],["733ce80da955a8a26902c95633e62a985192474b5af207da6df7b4fd5fc61cd4","f5435a2bd2badf7d485a4d8b8db9fcce3e1ef8e0201e4578c54673bc1dc5ea1d"],["15d9441254945064cf1a1c33bbd3b49f8966c5092171e699ef258dfab81c045c","d56eb30b69463e7234f5137b73b84177434800bacebfc685fc37bbe9efe4070d"],["a1d0fcf2ec9de675b612136e5ce70d271c21417c9d2b8aaaac138599d0717940","edd77f50bcb5a3cab2e90737309667f2641462a54070f3d519212d39c197a629"],["e22fbe15c0af8ccc5780c0735f84dbe9a790badee8245c06c7ca37331cb36980","a855babad5cd60c88b430a69f53a1a7a38289154964799be43d06d77d31da06"],["311091dd9860e8e20ee13473c1155f5f69635e394704eaa74009452246cfa9b3","66db656f87d1f04fffd1f04788c06830871ec5a64feee685bd80f0b1286d8374"],["34c1fd04d301be89b31c0442d3e6ac24883928b45a9340781867d4232ec2dbdf","9414685e97b1b5954bd46f730174136d57f1ceeb487443dc5321857ba73abee"],["f219ea5d6b54701c1c14de5b557eb42a8d13f3abbcd08affcc2a5e6b049b8d63","4cb95957e83d40b0f73af4544cccf6b1f4b08d3c07b27fb8d8c2962a400766d1"],["d7b8740f74a8fbaab1f683db8f45de26543a5490bca627087236912469a0b448","fa77968128d9c92ee1010f337ad4717eff15db5ed3c049b3411e0315eaa4593b"],["32d31c222f8f6f0ef86f7c98d3a3335ead5bcd32abdd94289fe4d3091aa824bf","5f3032f5892156e39ccd3d7915b9e1da2e6dac9e6f26e961118d14b8462e1661"],["7461f371914ab32671045a155d9831ea8793d77cd59592c4340f86cbc18347b5","8ec0ba238b96bec0cbdddcae0aa442542eee1ff50c986ea6b39847b3cc092ff6"],["ee079adb1df1860074356a25aa38206a6d716b2c3e67453d287698bad7b2b2d6","8dc2412aafe3be5c4c5f37e0ecc5f9f6a446989af04c4e25ebaac479ec1c8c1e"],["16ec93e447ec83f0467b18302ee620f7e65de331874c9dc72bfd8616ba9da6b5","5e4631150e62fb40d0e8c2a7ca5804a39d58186a50e497139626778e25b0674d"],["eaa5f980c245f6f038978290afa70b6bd8855897f98b6aa485b96065d537bd99","f65f5d3e292c2e0819a528391c994624d784869d7e6ea67fb18041024edc07dc"],["78c9407544ac132692ee1910a02439958ae04877151342ea96c4b6b35a49f51","f3e0319169eb9b85d5404795539a5e68fa1fbd583c064d2462b675f194a3ddb4"],["494f4be219a1a77016dcd838431aea0001cdc8ae7a6fc688726578d9702857a5","42242a969283a5f339ba7f075e36ba2af925ce30d767ed6e55f4b031880d562c"],["a598a8030da6d86c6bc7f2f5144ea549d28211ea58faa70ebf4c1e665c1fe9b5","204b5d6f84822c307e4b4a7140737aec23fc63b65b35f86a10026dbd2d864e6b"],["c41916365abb2b5d09192f5f2dbeafec208f020f12570a184dbadc3e58595997","4f14351d0087efa49d245b328984989d5caf9450f34bfc0ed16e96b58fa9913"],["841d6063a586fa475a724604da03bc5b92a2e0d2e0a36acfe4c73a5514742881","73867f59c0659e81904f9a1c7543698e62562d6744c169ce7a36de01a8d6154"],["5e95bb399a6971d376026947f89bde2f282b33810928be4ded112ac4d70e20d5","39f23f366809085beebfc71181313775a99c9aed7d8ba38b161384c746012865"],["36e4641a53948fd476c39f8a99fd974e5ec07564b5315d8bf99471bca0ef2f66","d2424b1b1abe4eb8164227b085c9aa9456ea13493fd563e06fd51cf5694c78fc"],["336581ea7bfbbb290c191a2f507a41cf5643842170e914faeab27c2c579f726","ead12168595fe1be99252129b6e56b3391f7ab1410cd1e0ef3dcdcabd2fda224"],["8ab89816dadfd6b6a1f2634fcf00ec8403781025ed6890c4849742706bd43ede","6fdcef09f2f6d0a044e654aef624136f503d459c3e89845858a47a9129cdd24e"],["1e33f1a746c9c5778133344d9299fcaa20b0938e8acff2544bb40284b8c5fb94","60660257dd11b3aa9c8ed618d24edff2306d320f1d03010e33a7d2057f3b3b6"],["85b7c1dcb3cec1b7ee7f30ded79dd20a0ed1f4cc18cbcfcfa410361fd8f08f31","3d98a9cdd026dd43f39048f25a8847f4fcafad1895d7a633c6fed3c35e999511"],["29df9fbd8d9e46509275f4b125d6d45d7fbe9a3b878a7af872a2800661ac5f51","b4c4fe99c775a606e2d8862179139ffda61dc861c019e55cd2876eb2a27d84b"],["a0b1cae06b0a847a3fea6e671aaf8adfdfe58ca2f768105c8082b2e449fce252","ae434102edde0958ec4b19d917a6a28e6b72da1834aff0e650f049503a296cf2"],["4e8ceafb9b3e9a136dc7ff67e840295b499dfb3b2133e4ba113f2e4c0e121e5","cf2174118c8b6d7a4b48f6d534ce5c79422c086a63460502b827ce62a326683c"],["d24a44e047e19b6f5afb81c7ca2f69080a5076689a010919f42725c2b789a33b","6fb8d5591b466f8fc63db50f1c0f1c69013f996887b8244d2cdec417afea8fa3"],["ea01606a7a6c9cdd249fdfcfacb99584001edd28abbab77b5104e98e8e3b35d4","322af4908c7312b0cfbfe369f7a7b3cdb7d4494bc2823700cfd652188a3ea98d"],["af8addbf2b661c8a6c6328655eb96651252007d8c5ea31be4ad196de8ce2131f","6749e67c029b85f52a034eafd096836b2520818680e26ac8f3dfbcdb71749700"],["e3ae1974566ca06cc516d47e0fb165a674a3dabcfca15e722f0e3450f45889","2aeabe7e4531510116217f07bf4d07300de97e4874f81f533420a72eeb0bd6a4"],["591ee355313d99721cf6993ffed1e3e301993ff3ed258802075ea8ced397e246","b0ea558a113c30bea60fc4775460c7901ff0b053d25ca2bdeee98f1a4be5d196"],["11396d55fda54c49f19aa97318d8da61fa8584e47b084945077cf03255b52984","998c74a8cd45ac01289d5833a7beb4744ff536b01b257be4c5767bea93ea57a4"],["3c5d2a1ba39c5a1790000738c9e0c40b8dcdfd5468754b6405540157e017aa7a","b2284279995a34e2f9d4de7396fc18b80f9b8b9fdd270f6661f79ca4c81bd257"],["cc8704b8a60a0defa3a99a7299f2e9c3fbc395afb04ac078425ef8a1793cc030","bdd46039feed17881d1e0862db347f8cf395b74fc4bcdc4e940b74e3ac1f1b13"],["c533e4f7ea8555aacd9777ac5cad29b97dd4defccc53ee7ea204119b2889b197","6f0a256bc5efdf429a2fb6242f1a43a2d9b925bb4a4b3a26bb8e0f45eb596096"],["c14f8f2ccb27d6f109f6d08d03cc96a69ba8c34eec07bbcf566d48e33da6593","c359d6923bb398f7fd4473e16fe1c28475b740dd098075e6c0e8649113dc3a38"],["a6cbc3046bc6a450bac24789fa17115a4c9739ed75f8f21ce441f72e0b90e6ef","21ae7f4680e889bb130619e2c0f95a360ceb573c70603139862afd617fa9b9f"],["347d6d9a02c48927ebfb86c1359b1caf130a3c0267d11ce6344b39f99d43cc38","60ea7f61a353524d1c987f6ecec92f086d565ab687870cb12689ff1e31c74448"],["da6545d2181db8d983f7dcb375ef5866d47c67b1bf31c8cf855ef7437b72656a","49b96715ab6878a79e78f07ce5680c5d6673051b4935bd897fea824b77dc208a"],["c40747cc9d012cb1a13b8148309c6de7ec25d6945d657146b9d5994b8feb1111","5ca560753be2a12fc6de6caf2cb489565db936156b9514e1bb5e83037e0fa2d4"],["4e42c8ec82c99798ccf3a610be870e78338c7f713348bd34c8203ef4037f3502","7571d74ee5e0fb92a7a8b33a07783341a5492144cc54bcc40a94473693606437"],["3775ab7089bc6af823aba2e1af70b236d251cadb0c86743287522a1b3b0dedea","be52d107bcfa09d8bcb9736a828cfa7fac8db17bf7a76a2c42ad961409018cf7"],["cee31cbf7e34ec379d94fb814d3d775ad954595d1314ba8846959e3e82f74e26","8fd64a14c06b589c26b947ae2bcf6bfa0149ef0be14ed4d80f448a01c43b1c6d"],["b4f9eaea09b6917619f6ea6a4eb5464efddb58fd45b1ebefcdc1a01d08b47986","39e5c9925b5a54b07433a4f18c61726f8bb131c012ca542eb24a8ac07200682a"],["d4263dfc3d2df923a0179a48966d30ce84e2515afc3dccc1b77907792ebcc60e","62dfaf07a0f78feb30e30d6295853ce189e127760ad6cf7fae164e122a208d54"],["48457524820fa65a4f8d35eb6930857c0032acc0a4a2de422233eeda897612c4","25a748ab367979d98733c38a1fa1c2e7dc6cc07db2d60a9ae7a76aaa49bd0f77"],["dfeeef1881101f2cb11644f3a2afdfc2045e19919152923f367a1767c11cceda","ecfb7056cf1de042f9420bab396793c0c390bde74b4bbdff16a83ae09a9a7517"],["6d7ef6b17543f8373c573f44e1f389835d89bcbc6062ced36c82df83b8fae859","cd450ec335438986dfefa10c57fea9bcc521a0959b2d80bbf74b190dca712d10"],["e75605d59102a5a2684500d3b991f2e3f3c88b93225547035af25af66e04541f","f5c54754a8f71ee540b9b48728473e314f729ac5308b06938360990e2bfad125"],["eb98660f4c4dfaa06a2be453d5020bc99a0c2e60abe388457dd43fefb1ed620c","6cb9a8876d9cb8520609af3add26cd20a0a7cd8a9411131ce85f44100099223e"],["13e87b027d8514d35939f2e6892b19922154596941888336dc3563e3b8dba942","fef5a3c68059a6dec5d624114bf1e91aac2b9da568d6abeb2570d55646b8adf1"],["ee163026e9fd6fe017c38f06a5be6fc125424b371ce2708e7bf4491691e5764a","1acb250f255dd61c43d94ccc670d0f58f49ae3fa15b96623e5430da0ad6c62b2"],["b268f5ef9ad51e4d78de3a750c2dc89b1e626d43505867999932e5db33af3d80","5f310d4b3c99b9ebb19f77d41c1dee018cf0d34fd4191614003e945a1216e423"],["ff07f3118a9df035e9fad85eb6c7bfe42b02f01ca99ceea3bf7ffdba93c4750d","438136d603e858a3a5c440c38eccbaddc1d2942114e2eddd4740d098ced1f0d8"],["8d8b9855c7c052a34146fd20ffb658bea4b9f69e0d825ebec16e8c3ce2b526a1","cdb559eedc2d79f926baf44fb84ea4d44bcf50fee51d7ceb30e2e7f463036758"],["52db0b5384dfbf05bfa9d472d7ae26dfe4b851ceca91b1eba54263180da32b63","c3b997d050ee5d423ebaf66a6db9f57b3180c902875679de924b69d84a7b375"],["e62f9490d3d51da6395efd24e80919cc7d0f29c3f3fa48c6fff543becbd43352","6d89ad7ba4876b0b22c2ca280c682862f342c8591f1daf5170e07bfd9ccafa7d"],["7f30ea2476b399b4957509c88f77d0191afa2ff5cb7b14fd6d8e7d65aaab1193","ca5ef7d4b231c94c3b15389a5f6311e9daff7bb67b103e9880ef4bff637acaec"],["5098ff1e1d9f14fb46a210fada6c903fef0fb7b4a1dd1d9ac60a0361800b7a00","9731141d81fc8f8084d37c6e7542006b3ee1b40d60dfe5362a5b132fd17ddc0"],["32b78c7de9ee512a72895be6b9cbefa6e2f3c4ccce445c96b9f2c81e2778ad58","ee1849f513df71e32efc3896ee28260c73bb80547ae2275ba497237794c8753c"],["e2cb74fddc8e9fbcd076eef2a7c72b0ce37d50f08269dfc074b581550547a4f7","d3aa2ed71c9dd2247a62df062736eb0baddea9e36122d2be8641abcb005cc4a4"],["8438447566d4d7bedadc299496ab357426009a35f235cb141be0d99cd10ae3a8","c4e1020916980a4da5d01ac5e6ad330734ef0d7906631c4f2390426b2edd791f"],["4162d488b89402039b584c6fc6c308870587d9c46f660b878ab65c82c711d67e","67163e903236289f776f22c25fb8a3afc1732f2b84b4e95dbda47ae5a0852649"],["3fad3fa84caf0f34f0f89bfd2dcf54fc175d767aec3e50684f3ba4a4bf5f683d","cd1bc7cb6cc407bb2f0ca647c718a730cf71872e7d0d2a53fa20efcdfe61826"],["674f2600a3007a00568c1a7ce05d0816c1fb84bf1370798f1c69532faeb1a86b","299d21f9413f33b3edf43b257004580b70db57da0b182259e09eecc69e0d38a5"],["d32f4da54ade74abb81b815ad1fb3b263d82d6c692714bcff87d29bd5ee9f08f","f9429e738b8e53b968e99016c059707782e14f4535359d582fc416910b3eea87"],["30e4e670435385556e593657135845d36fbb6931f72b08cb1ed954f1e3ce3ff6","462f9bce619898638499350113bbc9b10a878d35da70740dc695a559eb88db7b"],["be2062003c51cc3004682904330e4dee7f3dcd10b01e580bf1971b04d4cad297","62188bc49d61e5428573d48a74e1c655b1c61090905682a0d5558ed72dccb9bc"],["93144423ace3451ed29e0fb9ac2af211cb6e84a601df5993c419859fff5df04a","7c10dfb164c3425f5c71a3f9d7992038f1065224f72bb9d1d902a6d13037b47c"],["b015f8044f5fcbdcf21ca26d6c34fb8197829205c7b7d2a7cb66418c157b112c","ab8c1e086d04e813744a655b2df8d5f83b3cdc6faa3088c1d3aea1454e3a1d5f"],["d5e9e1da649d97d89e4868117a465a3a4f8a18de57a140d36b3f2af341a21b52","4cb04437f391ed73111a13cc1d4dd0db1693465c2240480d8955e8592f27447a"],["d3ae41047dd7ca065dbf8ed77b992439983005cd72e16d6f996a5316d36966bb","bd1aeb21ad22ebb22a10f0303417c6d964f8cdd7df0aca614b10dc14d125ac46"],["463e2763d885f958fc66cdd22800f0a487197d0a82e377b49f80af87c897b065","bfefacdb0e5d0fd7df3a311a94de062b26b80c61fbc97508b79992671ef7ca7f"],["7985fdfd127c0567c6f53ec1bb63ec3158e597c40bfe747c83cddfc910641917","603c12daf3d9862ef2b25fe1de289aed24ed291e0ec6708703a5bd567f32ed03"],["74a1ad6b5f76e39db2dd249410eac7f99e74c59cb83d2d0ed5ff1543da7703e9","cc6157ef18c9c63cd6193d83631bbea0093e0968942e8c33d5737fd790e0db08"],["30682a50703375f602d416664ba19b7fc9bab42c72747463a71d0896b22f6da3","553e04f6b018b4fa6c8f39e7f311d3176290d0e0f19ca73f17714d9977a22ff8"],["9e2158f0d7c0d5f26c3791efefa79597654e7a2b2464f52b1ee6c1347769ef57","712fcdd1b9053f09003a3481fa7762e9ffd7c8ef35a38509e2fbf2629008373"],["176e26989a43c9cfeba4029c202538c28172e566e3c4fce7322857f3be327d66","ed8cc9d04b29eb877d270b4878dc43c19aefd31f4eee09ee7b47834c1fa4b1c3"],["75d46efea3771e6e68abb89a13ad747ecf1892393dfc4f1b7004788c50374da8","9852390a99507679fd0b86fd2b39a868d7efc22151346e1a3ca4726586a6bed8"],["809a20c67d64900ffb698c4c825f6d5f2310fb0451c869345b7319f645605721","9e994980d9917e22b76b061927fa04143d096ccc54963e6a5ebfa5f3f8e286c1"],["1b38903a43f7f114ed4500b4eac7083fdefece1cf29c63528d563446f972c180","4036edc931a60ae889353f77fd53de4a2708b26b6f5da72ad3394119daf408f9"]]}}},84253:(e,t,i)=>{i.d(t,{oU:()=>n});var s=i(39907);const r=(void 0!==s&&void 0!==s.env?s.env.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",n={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,FIVE_SEC_MS:5e3,THREE_SEC_MS:3e3,ONE_SEC_MS:1e3,SECURE_SITE:r,SECURE_SITE_DASHBOARD:`${r}/dashboard`,SECURE_SITE_FAVICON:`${r}/images/favicon.png`,RESTRICTED_TIMEZONES:["ASIA/SHANGHAI","ASIA/URUMQI","ASIA/CHONGQING","ASIA/HARBIN","ASIA/KASHGAR","ASIA/MACAU","ASIA/HONG_KONG","ASIA/MACAO","ASIA/BEIJING","ASIA/HARBIN"],WC_COINBASE_PAY_SDK_CHAINS:["ethereum","arbitrum","polygon","berachain","avalanche-c-chain","optimism","celo","base"],WC_COINBASE_PAY_SDK_FALLBACK_CHAIN:"ethereum",WC_COINBASE_PAY_SDK_CHAIN_NAME_MAP:{Ethereum:"ethereum","Arbitrum One":"arbitrum",Polygon:"polygon",Berachain:"berachain",Avalanche:"avalanche-c-chain","OP Mainnet":"optimism",Celo:"celo",Base:"base"},WC_COINBASE_ONRAMP_APP_ID:"bf18c88d-495a-463b-b249-0b9d3656cf5e",SWAP_SUGGESTED_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP"],SWAP_POPULAR_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP","METAL","DAI","CHAMP","WOLF","SALE","BAL","BUSD","MUST","BTCpx","ROUTE","HEX","WELT","amDAI","VSQ","VISION","AURUM","pSP","SNX","VC","LINK","CHP","amUSDT","SPHERE","FOX","GIDDY","GFC","OMEN","OX_OLD","DE","WNT"],BALANCE_SUPPORTED_CHAINS:["eip155","solana"],SWAP_SUPPORTED_NETWORKS:["eip155:1","eip155:42161","eip155:10","eip155:324","eip155:8453","eip155:56","eip155:137","eip155:100","eip155:43114","eip155:250","eip155:8217","eip155:1313161554"],NAMES_SUPPORTED_CHAIN_NAMESPACES:["eip155"],ONRAMP_SUPPORTED_CHAIN_NAMESPACES:["eip155","solana"],ACTIVITY_ENABLED_CHAIN_NAMESPACES:["eip155","solana"],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in a new browser tab"},DEFAULT_FEATURES:{swaps:!0,onramp:!0,receive:!0,send:!0,email:!0,emailShowWallets:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],history:!0,analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0},DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",BITCOIN:"bitcoin"}}},84320:(e,t,i)=>{i.d(t,{r:()=>s});class s extends Error{constructor(){super(),Object.setPrototypeOf(this,s.prototype)}}},84742:(e,t,i)=>{var s=i(99499),r=i(89042),n=i(7784);function o(e){if(!(this instanceof o))return new o(e);this.hash=e.hash,this.predResist=!!e.predResist,this.outLen=this.hash.outSize,this.minEntropy=e.minEntropy||this.hash.hmacStrength,this._reseed=null,this.reseedInterval=null,this.K=null,this.V=null;var t=r.toArray(e.entropy,e.entropyEnc||"hex"),i=r.toArray(e.nonce,e.nonceEnc||"hex"),s=r.toArray(e.pers,e.persEnc||"hex");n(t.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._init(t,i,s)}e.exports=o,o.prototype._init=function(e,t,i){var s=e.concat(t).concat(i);this.K=new Array(this.outLen/8),this.V=new Array(this.outLen/8);for(var r=0;r<this.V.length;r++)this.K[r]=0,this.V[r]=1;this._update(s),this._reseed=1,this.reseedInterval=281474976710656},o.prototype._hmac=function(){return new s.hmac(this.hash,this.K)},o.prototype._update=function(e){var t=this._hmac().update(this.V).update([0]);e&&(t=t.update(e)),this.K=t.digest(),this.V=this._hmac().update(this.V).digest(),e&&(this.K=this._hmac().update(this.V).update([1]).update(e).digest(),this.V=this._hmac().update(this.V).digest())},o.prototype.reseed=function(e,t,i,s){"string"!=typeof t&&(s=i,i=t,t=null),e=r.toArray(e,t),i=r.toArray(i,s),n(e.length>=this.minEntropy/8,"Not enough entropy. Minimum is: "+this.minEntropy+" bits"),this._update(e.concat(i||[])),this._reseed=1},o.prototype.generate=function(e,t,i,s){if(this._reseed>this.reseedInterval)throw new Error("Reseed is required");"string"!=typeof t&&(s=i,i=t,t=null),i&&(i=r.toArray(i,s||"hex"),this._update(i));for(var n=[];n.length<e;)this.V=this._hmac().update(this.V).digest(),n=n.concat(this.V);var o=n.slice(0,e);return this._update(i),this._reseed++,r.encode(o,t)}},84807:(e,t,i)=>{var s=i(99499),r=i(86443),n=i(41874),o=n.assert,a=n.parseBytes,c=i(54672),h=i(18401);function d(e){if(o("ed25519"===e,"only tested with ed25519 so far"),!(this instanceof d))return new d(e);e=r[e].curve,this.curve=e,this.g=e.g,this.g.precompute(e.n.bitLength()+1),this.pointClass=e.point().constructor,this.encodingLength=Math.ceil(e.n.bitLength()/8),this.hash=s.sha512}e.exports=d,d.prototype.sign=function(e,t){e=a(e);var i=this.keyFromSecret(t),s=this.hashInt(i.messagePrefix(),e),r=this.g.mul(s),n=this.encodePoint(r),o=this.hashInt(n,i.pubBytes(),e).mul(i.priv()),c=s.add(o).umod(this.curve.n);return this.makeSignature({R:r,S:c,Rencoded:n})},d.prototype.verify=function(e,t,i){if(e=a(e),(t=this.makeSignature(t)).S().gte(t.eddsa.curve.n)||t.S().isNeg())return!1;var s=this.keyFromPublic(i),r=this.hashInt(t.Rencoded(),s.pubBytes(),e),n=this.g.mul(t.S());return t.R().add(s.pub().mul(r)).eq(n)},d.prototype.hashInt=function(){for(var e=this.hash(),t=0;t<arguments.length;t++)e.update(arguments[t]);return n.intFromLE(e.digest()).umod(this.curve.n)},d.prototype.keyFromPublic=function(e){return c.fromPublic(this,e)},d.prototype.keyFromSecret=function(e){return c.fromSecret(this,e)},d.prototype.makeSignature=function(e){return e instanceof h?e:new h(this,e)},d.prototype.encodePoint=function(e){var t=e.getY().toArray("le",this.encodingLength);return t[this.encodingLength-1]|=e.getX().isOdd()?128:0,t},d.prototype.decodePoint=function(e){var t=(e=n.parseBytes(e)).length-1,i=e.slice(0,t).concat(-129&e[t]),s=!!(128&e[t]),r=n.intFromLE(i);return this.curve.pointFromY(r,s)},d.prototype.encodeInt=function(e){return e.toArray("le",this.encodingLength)},d.prototype.decodeInt=function(e){return n.intFromLE(e)},d.prototype.isPoint=function(e){return e instanceof this.pointClass}},85174:(e,t,i)=>{var s=i(64845),r=i(41874),n=r.getNAF,o=r.getJSF,a=r.assert;function c(e,t){this.type=e,this.p=new s(t.p,16),this.red=t.prime?s.red(t.prime):s.mont(this.p),this.zero=new s(0).toRed(this.red),this.one=new s(1).toRed(this.red),this.two=new s(2).toRed(this.red),this.n=t.n&&new s(t.n,16),this.g=t.g&&this.pointFromJSON(t.g,t.gRed),this._wnafT1=new Array(4),this._wnafT2=new Array(4),this._wnafT3=new Array(4),this._wnafT4=new Array(4),this._bitLength=this.n?this.n.bitLength():0;var i=this.n&&this.p.div(this.n);!i||i.cmpn(100)>0?this.redN=null:(this._maxwellTrick=!0,this.redN=this.n.toRed(this.red))}function h(e,t){this.curve=e,this.type=t,this.precomputed=null}e.exports=c,c.prototype.point=function(){throw new Error("Not implemented")},c.prototype.validate=function(){throw new Error("Not implemented")},c.prototype._fixedNafMul=function(e,t){a(e.precomputed);var i=e._getDoubles(),s=n(t,1,this._bitLength),r=(1<<i.step+1)-(i.step%2==0?2:1);r/=3;var o,c,h=[];for(o=0;o<s.length;o+=i.step){c=0;for(var d=o+i.step-1;d>=o;d--)c=(c<<1)+s[d];h.push(c)}for(var l=this.jpoint(null,null,null),u=this.jpoint(null,null,null),p=r;p>0;p--){for(o=0;o<h.length;o++)(c=h[o])===p?u=u.mixedAdd(i.points[o]):c===-p&&(u=u.mixedAdd(i.points[o].neg()));l=l.add(u)}return l.toP()},c.prototype._wnafMul=function(e,t){var i=4,s=e._getNAFPoints(i);i=s.wnd;for(var r=s.points,o=n(t,i,this._bitLength),c=this.jpoint(null,null,null),h=o.length-1;h>=0;h--){for(var d=0;h>=0&&0===o[h];h--)d++;if(h>=0&&d++,c=c.dblp(d),h<0)break;var l=o[h];a(0!==l),c="affine"===e.type?l>0?c.mixedAdd(r[l-1>>1]):c.mixedAdd(r[-l-1>>1].neg()):l>0?c.add(r[l-1>>1]):c.add(r[-l-1>>1].neg())}return"affine"===e.type?c.toP():c},c.prototype._wnafMulAdd=function(e,t,i,s,r){var a,c,h,d=this._wnafT1,l=this._wnafT2,u=this._wnafT3,p=0;for(a=0;a<s;a++){var f=(h=t[a])._getNAFPoints(e);d[a]=f.wnd,l[a]=f.points}for(a=s-1;a>=1;a-=2){var g=a-1,m=a;if(1===d[g]&&1===d[m]){var b=[t[g],null,null,t[m]];0===t[g].y.cmp(t[m].y)?(b[1]=t[g].add(t[m]),b[2]=t[g].toJ().mixedAdd(t[m].neg())):0===t[g].y.cmp(t[m].y.redNeg())?(b[1]=t[g].toJ().mixedAdd(t[m]),b[2]=t[g].add(t[m].neg())):(b[1]=t[g].toJ().mixedAdd(t[m]),b[2]=t[g].toJ().mixedAdd(t[m].neg()));var y=[-3,-1,-5,-7,0,7,5,1,3],w=o(i[g],i[m]);for(p=Math.max(w[0].length,p),u[g]=new Array(p),u[m]=new Array(p),c=0;c<p;c++){var v=0|w[0][c],I=0|w[1][c];u[g][c]=y[3*(v+1)+(I+1)],u[m][c]=0,l[g]=b}}else u[g]=n(i[g],d[g],this._bitLength),u[m]=n(i[m],d[m],this._bitLength),p=Math.max(u[g].length,p),p=Math.max(u[m].length,p)}var E=this.jpoint(null,null,null),_=this._wnafT4;for(a=p;a>=0;a--){for(var A=0;a>=0;){var N=!0;for(c=0;c<s;c++)_[c]=0|u[c][a],0!==_[c]&&(N=!1);if(!N)break;A++,a--}if(a>=0&&A++,E=E.dblp(A),a<0)break;for(c=0;c<s;c++){var C=_[c];0!==C&&(C>0?h=l[c][C-1>>1]:C<0&&(h=l[c][-C-1>>1].neg()),E="affine"===h.type?E.mixedAdd(h):E.add(h))}}for(a=0;a<s;a++)l[a]=null;return r?E:E.toP()},c.BasePoint=h,h.prototype.eq=function(){throw new Error("Not implemented")},h.prototype.validate=function(){return this.curve.validate(this)},c.prototype.decodePoint=function(e,t){e=r.toArray(e,t);var i=this.p.byteLength();if((4===e[0]||6===e[0]||7===e[0])&&e.length-1==2*i)return 6===e[0]?a(e[e.length-1]%2==0):7===e[0]&&a(e[e.length-1]%2==1),this.point(e.slice(1,1+i),e.slice(1+i,1+2*i));if((2===e[0]||3===e[0])&&e.length-1===i)return this.pointFromX(e.slice(1,1+i),3===e[0]);throw new Error("Unknown point format")},h.prototype.encodeCompressed=function(e){return this.encode(e,!0)},h.prototype._encode=function(e){var t=this.curve.p.byteLength(),i=this.getX().toArray("be",t);return e?[this.getY().isEven()?2:3].concat(i):[4].concat(i,this.getY().toArray("be",t))},h.prototype.encode=function(e,t){return r.encode(this._encode(t),e)},h.prototype.precompute=function(e){if(this.precomputed)return this;var t={doubles:null,naf:null,beta:null};return t.naf=this._getNAFPoints(8),t.doubles=this._getDoubles(4,e),t.beta=this._getBeta(),this.precomputed=t,this},h.prototype._hasDoubles=function(e){if(!this.precomputed)return!1;var t=this.precomputed.doubles;return!!t&&t.points.length>=Math.ceil((e.bitLength()+1)/t.step)},h.prototype._getDoubles=function(e,t){if(this.precomputed&&this.precomputed.doubles)return this.precomputed.doubles;for(var i=[this],s=this,r=0;r<t;r+=e){for(var n=0;n<e;n++)s=s.dbl();i.push(s)}return{step:e,points:i}},h.prototype._getNAFPoints=function(e){if(this.precomputed&&this.precomputed.naf)return this.precomputed.naf;for(var t=[this],i=(1<<e)-1,s=1===i?null:this.dbl(),r=1;r<i;r++)t[r]=t[r-1].add(s);return{wnd:e,points:t}},h.prototype._getBeta=function(){return null},h.prototype.dblp=function(e){for(var t=this,i=0;i<e;i++)t=t.dbl();return t}},85445:(e,t,i)=>{i.d(t,{K:()=>s});class s extends Error{constructor(){super("QR Code Modal was closed by user"),Object.setPrototypeOf(this,s.prototype),this.name="QRCodeModalError"}}},86443:(e,t,i)=>{var s,r=t,n=i(99499),o=i(7131),a=i(41874).assert;function c(e){"short"===e.type?this.curve=new o.short(e):"edwards"===e.type?this.curve=new o.edwards(e):this.curve=new o.mont(e),this.g=this.curve.g,this.n=this.curve.n,this.hash=e.hash,a(this.g.validate(),"Invalid curve"),a(this.g.mul(this.n).isInfinity(),"Invalid curve, G*N != O")}function h(e,t){Object.defineProperty(r,e,{configurable:!0,enumerable:!0,get:function(){var i=new c(t);return Object.defineProperty(r,e,{configurable:!0,enumerable:!0,value:i}),i}})}r.PresetCurve=c,h("p192",{type:"short",prime:"p192",p:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff",a:"ffffffff ffffffff ffffffff fffffffe ffffffff fffffffc",b:"64210519 e59c80e7 0fa7e9ab 72243049 feb8deec c146b9b1",n:"ffffffff ffffffff ffffffff 99def836 146bc9b1 b4d22831",hash:n.sha256,gRed:!1,g:["188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012","07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811"]}),h("p224",{type:"short",prime:"p224",p:"ffffffff ffffffff ffffffff ffffffff 00000000 00000000 00000001",a:"ffffffff ffffffff ffffffff fffffffe ffffffff ffffffff fffffffe",b:"b4050a85 0c04b3ab f5413256 5044b0b7 d7bfd8ba 270b3943 2355ffb4",n:"ffffffff ffffffff ffffffff ffff16a2 e0b8f03e 13dd2945 5c5c2a3d",hash:n.sha256,gRed:!1,g:["b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21","bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34"]}),h("p256",{type:"short",prime:null,p:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff ffffffff",a:"ffffffff 00000001 00000000 00000000 00000000 ffffffff ffffffff fffffffc",b:"5ac635d8 aa3a93e7 b3ebbd55 769886bc 651d06b0 cc53b0f6 3bce3c3e 27d2604b",n:"ffffffff 00000000 ffffffff ffffffff bce6faad a7179e84 f3b9cac2 fc632551",hash:n.sha256,gRed:!1,g:["6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296","4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5"]}),h("p384",{type:"short",prime:null,p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 ffffffff",a:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe ffffffff 00000000 00000000 fffffffc",b:"b3312fa7 e23ee7e4 988e056b e3f82d19 181d9c6e fe814112 0314088f 5013875a c656398d 8a2ed19d 2a85c8ed d3ec2aef",n:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff c7634d81 f4372ddf 581a0db2 48b0a77a ecec196a ccc52973",hash:n.sha384,gRed:!1,g:["aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 5502f25d bf55296c 3a545e38 72760ab7","3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 0a60b1ce 1d7e819d 7a431d7c 90ea0e5f"]}),h("p521",{type:"short",prime:null,p:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff",a:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffc",b:"00000051 953eb961 8e1c9a1f 929a21a0 b68540ee a2da725b 99b315f3 b8b48991 8ef109e1 56193951 ec7e937b 1652c0bd 3bb1bf07 3573df88 3d2c34f1 ef451fd4 6b503f00",n:"000001ff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffa 51868783 bf2f966b 7fcc0148 f709a5d0 3bb5c9b8 899c47ae bb6fb71e 91386409",hash:n.sha512,gRed:!1,g:["000000c6 858e06b7 0404e9cd 9e3ecb66 2395b442 9c648139 053fb521 f828af60 6b4d3dba a14b5e77 efe75928 fe1dc127 a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66","00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 3fad0761 353c7086 a272c240 88be9476 9fd16650"]}),h("curve25519",{type:"mont",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"76d06",b:"1",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:n.sha256,gRed:!1,g:["9"]}),h("ed25519",{type:"edwards",prime:"p25519",p:"7fffffffffffffff ffffffffffffffff ffffffffffffffff ffffffffffffffed",a:"-1",c:"1",d:"52036cee2b6ffe73 8cc740797779e898 00700a4d4141d8ab 75eb4dca135978a3",n:"1000000000000000 0000000000000000 14def9dea2f79cd6 5812631a5cf5d3ed",hash:n.sha256,gRed:!1,g:["216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a","6666666666666666666666666666666666666666666666666666666666666658"]});try{s=i(83986)}catch(e){s=void 0}h("secp256k1",{type:"short",prime:"k256",p:"ffffffff ffffffff ffffffff ffffffff ffffffff ffffffff fffffffe fffffc2f",a:"0",b:"7",n:"ffffffff ffffffff ffffffff fffffffe baaedce6 af48a03b bfd25e8c d0364141",h:"1",hash:n.sha256,beta:"7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee",lambda:"5363ad4cc05c30e0a5261c028812645a122e22ea20816678df02967c1b23bd72",basis:[{a:"3086d221a7d46bcde86c90e49284eb15",b:"-e4437ed6010e88286f547fa90abfe4c3"},{a:"114ca50f7a8e2f3f657c1108d9d44cfd8",b:"3086d221a7d46bcde86c90e49284eb15"}],gRed:!1,g:["79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8",s]})},86808:(e,t,i)=>{i.d(t,{kl:()=>s.k}),i(24529);var s=i(69033)},87201:(e,t,i)=>{i.d(t,{WalletConnectWalletAdapter:()=>h});var s=i(80110),r=i(53834),n=i(68559),o=i(13324),a=i(96759),c=i(66715);class h extends n.Kl{name="WalletConnect";url="https://walletconnect.org";icon="data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4NSIgdmlld0JveD0iMCAwIDMwMCAxODUiIHdpZHRoPSIzMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTYxLjQzODU0MjkgMzYuMjU2MjYxMmM0OC45MTEyMjQxLTQ3Ljg4ODE2NjMgMTI4LjIxMTk4NzEtNDcuODg4MTY2MyAxNzcuMTIzMjA5MSAwbDUuODg2NTQ1IDUuNzYzNDE3NGMyLjQ0NTU2MSAyLjM5NDQwODEgMi40NDU1NjEgNi4yNzY1MTEyIDAgOC42NzA5MjA0bC0yMC4xMzY2OTUgMTkuNzE1NTAzYy0xLjIyMjc4MSAxLjE5NzIwNTEtMy4yMDUzIDEuMTk3MjA1MS00LjQyODA4MSAwbC04LjEwMDU4NC03LjkzMTE0NzljLTM0LjEyMTY5Mi0zMy40MDc5ODE3LTg5LjQ0Mzg4Ni0zMy40MDc5ODE3LTEyMy41NjU1Nzg4IDBsLTguNjc1MDU2MiA4LjQ5MzYwNTFjLTEuMjIyNzgxNiAxLjE5NzIwNDEtMy4yMDUzMDEgMS4xOTcyMDQxLTQuNDI4MDgwNiAwbC0yMC4xMzY2OTQ5LTE5LjcxNTUwMzFjLTIuNDQ1NTYxMi0yLjM5NDQwOTItMi40NDU1NjEyLTYuMjc2NTEyMiAwLTguNjcwOTIwNHptMjE4Ljc2Nzc5NjEgNDAuNzczNzQ0OSAxNy45MjE2OTcgMTcuNTQ2ODk3YzIuNDQ1NTQ5IDIuMzk0Mzk2OSAyLjQ0NTU2MyA2LjI3NjQ3NjkuMDAwMDMxIDguNjcwODg5OWwtODAuODEwMTcxIDc5LjEyMTEzNGMtMi40NDU1NDQgMi4zOTQ0MjYtNi40MTA1ODIgMi4zOTQ0NTMtOC44NTYxNi4wMDAwNjItLjAwMDAxLS4wMDAwMS0uMDAwMDIyLS4wMDAwMjItLjAwMDAzMi0uMDAwMDMybC01Ny4zNTQxNDMtNTYuMTU0NTcyYy0uNjExMzktLjU5ODYwMi0xLjYwMjY1LS41OTg2MDItMi4yMTQwNCAwLS4wMDAwMDQuMDAwMDA0LS4wMDAwMDcuMDAwMDA4LS4wMDAwMTEuMDAwMDExbC01Ny4zNTI5MjEyIDU2LjE1NDUzMWMtMi40NDU1MzY4IDIuMzk0NDMyLTYuNDEwNTc1NSAyLjM5NDQ3Mi04Ljg1NjE2MTIuMDAwMDg3LS4wMDAwMTQzLS4wMDAwMTQtLjAwMDAyOTYtLjAwMDAyOC0uMDAwMDQ0OS0uMDAwMDQ0bC04MC44MTI0MTk0My03OS4xMjIxODVjLTIuNDQ1NTYwMjEtMi4zOTQ0MDgtMi40NDU1NjAyMS02LjI3NjUxMTUgMC04LjY3MDkxOTdsMTcuOTIxNzI5NjMtMTcuNTQ2ODY3M2MyLjQ0NTU2MDItMi4zOTQ0MDgyIDYuNDEwNTk4OS0yLjM5NDQwODIgOC44NTYxNjAyIDBsNTcuMzU0OTc3NSA1Ni4xNTUzNTdjLjYxMTM5MDguNTk4NjAyIDEuNjAyNjQ5LjU5ODYwMiAyLjIxNDAzOTggMCAuMDAwMDA5Mi0uMDAwMDA5LjAwMDAxNzQtLjAwMDAxNy4wMDAwMjY1LS4wMDAwMjRsNTcuMzUyMTAzMS01Ni4xNTUzMzNjMi40NDU1MDUtMi4zOTQ0NjMzIDYuNDEwNTQ0LTIuMzk0NTUzMSA4Ljg1NjE2MS0uMDAwMi4wMDAwMzQuMDAwMDMzNi4wMDAwNjguMDAwMDY3My4wMDAxMDEuMDAwMTAxbDU3LjM1NDkwMiA1Ni4xNTU0MzJjLjYxMTM5LjU5ODYwMSAxLjYwMjY1LjU5ODYwMSAyLjIxNDA0IDBsNTcuMzUzOTc1LTU2LjE1NDMyNDljMi40NDU1NjEtMi4zOTQ0MDkyIDYuNDEwNTk5LTIuMzk0NDA5MiA4Ljg1NjE2IDB6IiBmaWxsPSIjM2I5OWZjIi8+PC9zdmc+";supportedTransactionVersions=new Set(["legacy",0]);_publicKey;_connecting;_wallet;_config;_readyState;_onDisconnect;constructor(e){super(),this._publicKey=null,this._connecting=!1,this._config=e,this._wallet=null,this._readyState="undefined"==typeof window?s.Ok.Unsupported:s.Ok.Loadable,this._onDisconnect=this.disconnect.bind(this)}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==s.Ok.Loadable)throw new r.AE;this._connecting=!0,this._wallet=new c.f({network:this._config.network===o.B.Mainnet?a.aj.Mainnet:a.aj.Devnet,options:this._config.options});const{publicKey:e}=await this._wallet.connect();this._publicKey=e,this.emit("connect",e),this._wallet.client.on("session_delete",this._onDisconnect)}catch(e){if("QRCodeModalError"===e.constructor.name||e instanceof Error&&"QRCodeModalError"===e.name)throw new r.KL;throw this._connecting=!1,e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){e.client.off("session_delete",this._onDisconnect),this._publicKey=null;try{e.client.session&&await e.disconnect()}catch(e){console.error("WalletConnectWalletAdapter: disconnect error",e),this.emit("error",new r.Y8(e?.message,e))}}this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new r.kW;try{return await t.signTransaction(e)}catch(e){throw new r.z4(e?.message,e)}}catch(e){throw this.emit("error",e),e}}async signMessage(e){try{const t=this._wallet;if(!t)throw new r.kW;try{return await t.signMessage(e)}catch(e){throw new r.K3(e?.message,e)}}catch(e){throw this.emit("error",e),e}}async signAndSendTransaction(e){try{const t=this._wallet;if(!t)throw new r.kW;try{return await t.signAndSendTransaction(e)}catch(e){throw new r.z4(e?.message,e)}}catch(e){throw this.emit("error",e),e}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new r.kW;try{return await t.signAllTransactions(e)}catch(e){throw new r.z4(e?.message,e)}}catch(e){throw this.emit("error",e),e}}}},87841:(e,t,i)=>{i.d(t,{g:()=>o});var s=i(95191),r=i(99013),n=i(93927);function o(e){const t=Array.from(r.W.state.chains.keys());let i=[];return e?(i.push([e,r.W.state.chains.get(e)]),(0,n.Q)(e,s.o.CONNECTOR_ID.WALLET_CONNECT)?t.forEach(t=>{t!==e&&(0,n.Q)(t,s.o.CONNECTOR_ID.WALLET_CONNECT)&&i.push([t,r.W.state.chains.get(t)])}):(0,n.Q)(e,s.o.CONNECTOR_ID.AUTH)&&t.forEach(t=>{t!==e&&(0,n.Q)(t,s.o.CONNECTOR_ID.AUTH)&&i.push([t,r.W.state.chains.get(t)])})):i=Array.from(r.W.state.chains.entries()),i}},88315:(e,t,i)=>{i.d(t,{_:()=>h});var s=i(89058),r=i(50731),n=i(16158),o=i(5813),a=i(41977);let c=!1;class h extends a._{async open(e){r.a.isConnected()||await super.open(e)}async close(){await super.close(),this.options.manualWCControl&&s.x.finalizeWcConnection()}async syncIdentity(e){return Promise.resolve()}async syncBalance(e){return Promise.resolve()}async injectModalUi(){if(!c&&o.w.isClient()){if(await Promise.all([i.e(6484),i.e(4194),i.e(4379)]).then(i.bind(i,34379)),await Promise.all([i.e(4194),i.e(5972)]).then(i.bind(i,45972)),!document.querySelector("w3m-modal")){const e=document.createElement("w3m-modal");n.H.state.disableAppend||n.H.state.enableEmbedded||document.body.insertAdjacentElement("beforeend",e)}c=!0}}}},89042:(e,t)=>{var i=t;function s(e){return 1===e.length?"0"+e:e}function r(e){for(var t="",i=0;i<e.length;i++)t+=s(e[i].toString(16));return t}i.toArray=function(e,t){if(Array.isArray(e))return e.slice();if(!e)return[];var i=[];if("string"!=typeof e){for(var s=0;s<e.length;s++)i[s]=0|e[s];return i}if("hex"===t)for((e=e.replace(/[^a-z0-9]+/gi,"")).length%2!=0&&(e="0"+e),s=0;s<e.length;s+=2)i.push(parseInt(e[s]+e[s+1],16));else for(s=0;s<e.length;s++){var r=e.charCodeAt(s),n=r>>8,o=255&r;n?i.push(n,o):i.push(o)}return i},i.zero2=s,i.toHex=r,i.encode=function(e,t){return"hex"===t?r(e):e}},89058:(e,t,i)=>{i.d(t,{x:()=>m});var s=i(89168),r=i(39150),n=i(5813),o=i(24537),a=i(11553),c=i(99013),h=i(50731),d=i(14479),l=i(44637),u=i(42831),p=i(52059);const f=(0,s.BX)({wcError:!1,buffering:!1,status:"disconnected"});let g;const m={state:f,subscribeKey:(e,t)=>(0,r.u$)(f,e,t),_getClient:()=>f._client,setClient(e){f._client=(0,s.KR)(e)},async connectWalletConnect(){if(n.w.isTelegram()||n.w.isSafari()&&n.w.isIos()){if(g)return await g,void(g=void 0);if(!n.w.isPairingExpired(f?.wcPairingExpiry)){const e=f.wcUri;return void(f.wcUri=e)}g=this._getClient()?.connectWalletConnect?.().catch(()=>{}),this.state.status="connecting",await g,g=void 0,f.wcPairingExpiry=void 0,this.state.status="connected"}else await(this._getClient()?.connectWalletConnect?.())},async connectExternal(e,t,i=!0){await(this._getClient()?.connectExternal?.(e)),i&&c.W.setActiveNamespace(t)},async reconnectExternal(e){await(this._getClient()?.reconnectExternal?.(e));const t=e.chain||c.W.state.activeChain;t&&h.a.setConnectorId(e.id,t)},async setPreferredAccountType(e){l.W.setLoading(!0,c.W.state.activeChain);const t=h.a.getAuthConnector();t&&(await(t?.provider.setPreferredAccount(e)),await this.reconnectExternal(t),l.W.setLoading(!1,c.W.state.activeChain),d.E.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:e,network:c.W.state.activeCaipNetwork?.caipNetworkId||""}}))},async signMessage(e){return this._getClient()?.signMessage(e)},parseUnits(e,t){return this._getClient()?.parseUnits(e,t)},formatUnits(e,t){return this._getClient()?.formatUnits(e,t)},async sendTransaction(e){return this._getClient()?.sendTransaction(e)},async getCapabilities(e){return this._getClient()?.getCapabilities(e)},async grantPermissions(e){return this._getClient()?.grantPermissions(e)},async walletGetAssets(e){return this._getClient()?.walletGetAssets(e)??{}},async estimateGas(e){return this._getClient()?.estimateGas(e)},async writeContract(e){return this._getClient()?.writeContract(e)},async getEnsAddress(e){return this._getClient()?.getEnsAddress(e)},async getEnsAvatar(e){return this._getClient()?.getEnsAvatar(e)},checkInstalled(e){return this._getClient()?.checkInstalled?.(e)||!1},resetWcConnection(){f.wcUri=void 0,f.wcPairingExpiry=void 0,f.wcLinking=void 0,f.recentWallet=void 0,f.status="disconnected",p.W.resetTransactions(),a.i.deleteWalletConnectDeepLink()},resetUri(){f.wcUri=void 0,f.wcPairingExpiry=void 0},finalizeWcConnection(){const{wcLinking:e,recentWallet:t}=m.state;e&&a.i.setWalletConnectDeepLink(e),t&&a.i.setAppKitRecent(t),d.E.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:e?"mobile":"qrcode",name:u.I.state.data?.wallet?.name||"Unknown"}})},setWcBasic(e){f.wcBasic=e},setUri(e){f.wcUri=e,f.wcPairingExpiry=n.w.getPairingExpiry()},setWcLinking(e){f.wcLinking=e},setWcError(e){f.wcError=e,f.buffering=!1},setRecentWallet(e){f.recentWallet=e},setBuffering(e){f.buffering=e},setStatus(e){f.status=e},async disconnect(e){try{l.W.setLoading(!0,e),await o.U.clearSessions(),await c.W.disconnect(e),l.W.setLoading(!1,e),h.a.setFilterByNamespace(void 0)}catch(e){throw new Error("Failed to disconnect")}}}},89351:(e,t,i)=>{i.d(t,{hJ:()=>n,lC:()=>o});var s=i(96759);const r={mainnet:`You are using a deprecated chain ID for Solana Mainnet, please use ${s.ac.Mainnet} instead.`,devnet:`You are using a deprecated chain ID for Solana Devnet, please use ${s.ac.Devnet} instead.`,wallet:"The connected wallet is using a deprecated chain ID for Solana. Please, contact them to upgrade. You can learn more at https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip10.md#chain-ids"};function n(e,t){const i=e.namespaces.solana?.accounts.map(e=>`solana:${e.split(":")[1]}`);if(t===s.ac.Mainnet)return i?.find(e=>e===s.ac.Mainnet)?s.ac.Mainnet:(console.warn(r.wallet),s.ac.Deprecated_Mainnet);if(t===s.ac.Devnet)return i?.find(e=>e===s.ac.Devnet)?s.ac.Devnet:(console.warn(r.wallet),s.ac.Deprecated_Devnet);throw Error("WalletConnect Solana Adapter: Unable to get a default chain from the session.")}function o(e){const t=function(e){let t=[e];return e===s.ac.Mainnet||e===s.ac.Deprecated_Mainnet?(t=[s.ac.Mainnet,s.ac.Deprecated_Mainnet],e===s.ac.Deprecated_Mainnet&&console.warn(r.mainnet)):e!==s.ac.Deprecated_Devnet&&e!==s.ac.Devnet||(t=[s.ac.Devnet,s.ac.Deprecated_Devnet],s.ac.Deprecated_Devnet&&console.warn(r.devnet)),t}(e);return{optionalNamespaces:{solana:{chains:t,methods:[s.jD.signTransaction,s.jD.signMessage],events:[]}}}}},91310:(e,t,i)=>{i.d(t,{D:()=>n});var s=i(84253),r=i(5813);const n={getFeatureValue(e,t){const i=t?.[e];return void 0===i?s.oU.DEFAULT_FEATURES[e]:i},filterSocialsByPlatform(e){if(!e||!e.length)return e;if(r.w.isTelegram()){if(r.w.isIos())return e.filter(e=>"google"!==e);if(r.w.isMac())return e.filter(e=>"x"!==e);if(r.w.isAndroid())return e.filter(e=>!["facebook","x"].includes(e))}return e}}},92157:(e,t,i)=>{var s=i(70461),r=i(32191),n=i(7784),o=s.rotr64_hi,a=s.rotr64_lo,c=s.shr64_hi,h=s.shr64_lo,d=s.sum64,l=s.sum64_hi,u=s.sum64_lo,p=s.sum64_4_hi,f=s.sum64_4_lo,g=s.sum64_5_hi,m=s.sum64_5_lo,b=r.BlockHash,y=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591];function w(){if(!(this instanceof w))return new w;b.call(this),this.h=[1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209],this.k=y,this.W=new Array(160)}function v(e,t,i,s,r){var n=e&i^~e&r;return n<0&&(n+=4294967296),n}function I(e,t,i,s,r,n){var o=t&s^~t&n;return o<0&&(o+=4294967296),o}function E(e,t,i,s,r){var n=e&i^e&r^i&r;return n<0&&(n+=4294967296),n}function _(e,t,i,s,r,n){var o=t&s^t&n^s&n;return o<0&&(o+=4294967296),o}function A(e,t){var i=o(e,t,28)^o(t,e,2)^o(t,e,7);return i<0&&(i+=4294967296),i}function N(e,t){var i=a(e,t,28)^a(t,e,2)^a(t,e,7);return i<0&&(i+=4294967296),i}function C(e,t){var i=o(e,t,14)^o(e,t,18)^o(t,e,9);return i<0&&(i+=4294967296),i}function S(e,t){var i=a(e,t,14)^a(e,t,18)^a(t,e,9);return i<0&&(i+=4294967296),i}function P(e,t){var i=o(e,t,1)^o(e,t,8)^c(e,t,7);return i<0&&(i+=4294967296),i}function O(e,t){var i=a(e,t,1)^a(e,t,8)^h(e,t,7);return i<0&&(i+=4294967296),i}function T(e,t){var i=o(e,t,19)^o(t,e,29)^c(e,t,6);return i<0&&(i+=4294967296),i}function x(e,t){var i=a(e,t,19)^a(t,e,29)^h(e,t,6);return i<0&&(i+=4294967296),i}s.inherits(w,b),e.exports=w,w.blockSize=1024,w.outSize=512,w.hmacStrength=192,w.padLength=128,w.prototype._prepareBlock=function(e,t){for(var i=this.W,s=0;s<32;s++)i[s]=e[t+s];for(;s<i.length;s+=2){var r=T(i[s-4],i[s-3]),n=x(i[s-4],i[s-3]),o=i[s-14],a=i[s-13],c=P(i[s-30],i[s-29]),h=O(i[s-30],i[s-29]),d=i[s-32],l=i[s-31];i[s]=p(r,n,o,a,c,h,d,l),i[s+1]=f(r,n,o,a,c,h,d,l)}},w.prototype._update=function(e,t){this._prepareBlock(e,t);var i=this.W,s=this.h[0],r=this.h[1],o=this.h[2],a=this.h[3],c=this.h[4],h=this.h[5],p=this.h[6],f=this.h[7],b=this.h[8],y=this.h[9],w=this.h[10],P=this.h[11],O=this.h[12],T=this.h[13],x=this.h[14],k=this.h[15];n(this.k.length===i.length);for(var R=0;R<i.length;R+=2){var M=x,U=k,D=C(b,y),j=S(b,y),L=v(b,0,w,0,O),q=I(0,y,0,P,0,T),$=this.k[R],B=this.k[R+1],z=i[R],H=i[R+1],W=g(M,U,D,j,L,q,$,B,z,H),V=m(M,U,D,j,L,q,$,B,z,H);M=A(s,r),U=N(s,r),D=E(s,0,o,0,c),j=_(0,r,0,a,0,h);var F=l(M,U,D,j),K=u(M,U,D,j);x=O,k=T,O=w,T=P,w=b,P=y,b=l(p,f,W,V),y=u(f,f,W,V),p=c,f=h,c=o,h=a,o=s,a=r,s=l(W,V,F,K),r=u(W,V,F,K)}d(this.h,0,s,r),d(this.h,2,o,a),d(this.h,4,c,h),d(this.h,6,p,f),d(this.h,8,b,y),d(this.h,10,w,P),d(this.h,12,O,T),d(this.h,14,x,k)},w.prototype._digest=function(e){return"hex"===e?s.toHex32(this.h,"big"):s.split32(this.h,"big")}},93224:(e,t,i)=>{i.d(t,{$:()=>c});var s=i(89168),r=i(40868),n=i(12472);const o={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00"},a=(0,s.BX)({networkImagePromises:{}}),c={async fetchWalletImage(e){if(e)return await r.N._fetchWalletImage(e),this.getWalletImageById(e)},async fetchNetworkImage(e){if(!e)return;return this.getNetworkImageById(e)||(a.networkImagePromises[e]||(a.networkImagePromises[e]=r.N._fetchNetworkImage(e)),await a.networkImagePromises[e],this.getNetworkImageById(e))},getWalletImageById(e){if(e)return n.j.state.walletImages[e]},getWalletImage:e=>e?.image_url?e?.image_url:e?.image_id?n.j.state.walletImages[e.image_id]:void 0,getNetworkImage:e=>e?.assets?.imageUrl?e?.assets?.imageUrl:e?.assets?.imageId?n.j.state.networkImages[e.assets.imageId]:void 0,getNetworkImageById(e){if(e)return n.j.state.networkImages[e]},getConnectorImage:e=>e?.imageUrl?e.imageUrl:e?.imageId?n.j.state.connectorImages[e.imageId]:void 0,getChainImage:e=>n.j.state.networkImages[o[e]]}},93927:(e,t,i)=>{i.d(t,{Q:()=>r});var s=i(50731);function r(e,t){return s.a.getConnectorId(e)===t}},94768:(e,t,i)=>{i.d(t,{EM:()=>n.E,JX:()=>s.JX,RF:()=>s.RF,Zv:()=>r.Z,ds:()=>s.ds}),i(51493);var s=i(24210),r=i(63789),n=(i(72931),i(27305))},95191:(e,t,i)=>{i.d(t,{o:()=>s});const s={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"ID_AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122"},CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],HTTP_STATUS_CODES:{SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network"}},95642:(e,t,i)=>{var s=i(40149);(0,s.x)({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}}),(0,s.x)({id:"000000000933ea01ad0ee984209779ba",caipNetworkId:"bip122:000000000933ea01ad0ee984209779ba",chainNamespace:"bip122",name:"Bitcoin Testnet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},testnet:!0})},96759:(e,t,i)=>{var s,r;i.d(t,{ac:()=>n,aj:()=>s,jD:()=>r}),function(e){e.Mainnet="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",e.Devnet="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",e.Deprecated_Mainnet="solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",e.Deprecated_Devnet="solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"}(s||(s={})),function(e){e.signTransaction="solana_signTransaction",e.signMessage="solana_signMessage",e.signAndSendTransaction="solana_signAndSendTransaction",e.signAndSendAllTransactions="solana_signAndSendAllTransactions",e.signAllTransactions="solana_signAllTransactions"}(r||(r={}));const n={Mainnet:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",Devnet:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",Deprecated_Mainnet:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",Deprecated_Devnet:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"}},98207:(e,t,i)=>{i.d(t,{o:()=>s});const s={METMASK_CONNECTOR_NAME:"MetaMask",TRUST_CONNECTOR_NAME:"Trust Wallet",SOLFLARE_CONNECTOR_NAME:"Solflare",PHANTOM_CONNECTOR_NAME:"Phantom",COIN98_CONNECTOR_NAME:"Coin98",MAGIC_EDEN_CONNECTOR_NAME:"Magic Eden",BACKPACK_CONNECTOR_NAME:"Backpack",BITGET_CONNECTOR_NAME:"Bitget Wallet",FRONTIER_CONNECTOR_NAME:"Frontier",XVERSE_CONNECTOR_NAME:"Xverse Wallet",LEATHER_CONNECTOR_NAME:"Leather",EIP155:"eip155",ADD_CHAIN_METHOD:"wallet_addEthereumChain",EIP6963_ANNOUNCE_EVENT:"eip6963:announceProvider",EIP6963_REQUEST_EVENT:"eip6963:requestProvider",CONNECTOR_RDNS_MAP:{coinbaseWallet:"com.coinbase.wallet",coinbaseWalletSDK:"com.coinbase.wallet"},CONNECTOR_TYPE_EXTERNAL:"EXTERNAL",CONNECTOR_TYPE_WALLET_CONNECT:"WALLET_CONNECT",CONNECTOR_TYPE_INJECTED:"INJECTED",CONNECTOR_TYPE_ANNOUNCED:"ANNOUNCED",CONNECTOR_TYPE_AUTH:"AUTH",CONNECTOR_TYPE_MULTI_CHAIN:"MULTI_CHAIN",CONNECTOR_TYPE_W3M_AUTH:"ID_AUTH"}},98752:(e,t,i)=>{i.d(t,{$I:()=>Y,$w:()=>G,Jf:()=>S,S$:()=>J,Tn:()=>Z,U:()=>X,U$:()=>Q,WB:()=>V,cV:()=>R,iJ:()=>hs,il:()=>xi,sD:()=>N,wn:()=>H,zN:()=>q});var s=i(50046),r=i.n(s),n=i(37147),o=i(81030),a=i(70255),c=i(21910),h=i(91315),d=i(25607),l=i(97353),u=i(48851),p=i(1030),f=i(93786),g=i(14350),m=i(63342),b=i(20635),y=i(48526).hp;const w="core",v=`wc@2:${w}:`,I={database:":memory:"},E="client_ed25519_seed",_=h.ONE_DAY,A=h.SIX_HOURS,N="irn",C="wss://relay.walletconnect.org",S={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},P="payload",O="connect",T="disconnect",x="error",k="2.19.1",R={link_mode:"link_mode",relay:"relay"},M="inbound",U="WALLETCONNECT_LINK_MODE_APPS",D="subscription_created",j="subscription_deleted",L=(h.FIVE_SECONDS,{wc_pairingDelete:{req:{ttl:h.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:h.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:h.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:h.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:h.ONE_DAY,prompt:!1,tag:0},res:{ttl:h.ONE_DAY,prompt:!1,tag:0}}}),q={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},$="history_created",B="history_updated",z="history_deleted",H={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},W="https://verify.walletconnect.org",V=W,F=`${V}/v3`,K=["https://verify.walletconnect.com",W],G={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},J={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},Y={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},X={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Q={authenticated_session_approve_started:"authenticated_session_approve_started",authenticated_session_not_expired:"authenticated_session_not_expired",chains_caip2_compliant:"chains_caip2_compliant",chains_evm_compliant:"chains_evm_compliant",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve",authenticated_session_approve_publish_success:"authenticated_session_approve_publish_success"},Z={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",missing_session_authenticate_request:"missing_session_authenticate_request",session_authenticate_request_expired:"session_authenticate_request_expired",chains_caip2_compliant_failure:"chains_caip2_compliant_failure",chains_evm_compliant_failure:"chains_evm_compliant_failure",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"};const ee=e=>{if(e instanceof Uint8Array&&"Uint8Array"===e.constructor.name)return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")};class te{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class ie{constructor(e,t,i){if(this.name=e,this.prefix=t,void 0===t.codePointAt(0))throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return re(this,e)}}class se{constructor(e){this.decoders=e}or(e){return re(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const re=(e,t)=>new se({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});class ne{constructor(e,t,i,s){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=s,this.encoder=new te(e,t,i),this.decoder=new ie(e,t,s)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const oe=({name:e,prefix:t,encode:i,decode:s})=>new ne(e,t,i,s),ae=({prefix:e,name:t,alphabet:i})=>{const{encode:s,decode:r}=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var i=new Uint8Array(256),s=0;s<i.length;s++)i[s]=255;for(var r=0;r<e.length;r++){var n=e.charAt(r),o=n.charCodeAt(0);if(255!==i[o])throw new TypeError(n+" is ambiguous");i[o]=r}var a=e.length,c=e.charAt(0),h=Math.log(a)/Math.log(256),d=Math.log(256)/Math.log(a);function l(e){if("string"!=typeof e)throw new TypeError("Expected String");if(0===e.length)return new Uint8Array;var t=0;if(" "!==e[t]){for(var s=0,r=0;e[t]===c;)s++,t++;for(var n=(e.length-t)*h+1>>>0,o=new Uint8Array(n);e[t];){var d=i[e.charCodeAt(t)];if(255===d)return;for(var l=0,u=n-1;(0!==d||l<r)&&-1!==u;u--,l++)d+=a*o[u]>>>0,o[u]=d%256>>>0,d=d/256>>>0;if(0!==d)throw new Error("Non-zero carry");r=l,t++}if(" "!==e[t]){for(var p=n-r;p!==n&&0===o[p];)p++;for(var f=new Uint8Array(s+(n-p)),g=s;p!==n;)f[g++]=o[p++];return f}}}return{encode:function(t){if(t instanceof Uint8Array||(ArrayBuffer.isView(t)?t=new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Array.isArray(t)&&(t=Uint8Array.from(t))),!(t instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===t.length)return"";for(var i=0,s=0,r=0,n=t.length;r!==n&&0===t[r];)r++,i++;for(var o=(n-r)*d+1>>>0,h=new Uint8Array(o);r!==n;){for(var l=t[r],u=0,p=o-1;(0!==l||u<s)&&-1!==p;p--,u++)l+=256*h[p]>>>0,h[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");s=u,r++}for(var f=o-s;f!==o&&0===h[f];)f++;for(var g=c.repeat(i);f<o;++f)g+=e.charAt(h[f]);return g},decodeUnsafe:l,decode:function(e){var i=l(e);if(i)return i;throw new Error(`Non-${t} character`)}}}(i,t);return oe({prefix:e,name:t,encode:s,decode:e=>ee(r(e))})},ce=({name:e,prefix:t,bitsPerChar:i,alphabet:s})=>oe({prefix:t,name:e,encode:e=>((e,t,i)=>{const s="="===t[t.length-1],r=(1<<i)-1;let n="",o=0,a=0;for(let s=0;s<e.length;++s)for(a=a<<8|e[s],o+=8;o>i;)o-=i,n+=t[r&a>>o];if(o&&(n+=t[r&a<<i-o]),s)for(;n.length*i&7;)n+="=";return n})(e,s,i),decode:t=>((e,t,i,s)=>{const r={};for(let e=0;e<t.length;++e)r[t[e]]=e;let n=e.length;for(;"="===e[n-1];)--n;const o=new Uint8Array(n*i/8|0);let a=0,c=0,h=0;for(let t=0;t<n;++t){const n=r[e[t]];if(void 0===n)throw new SyntaxError(`Non-${s} character`);c=c<<i|n,a+=i,a>=8&&(a-=8,o[h++]=255&c>>a)}if(a>=i||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(t,s,i,e)}),he=oe({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var de=Object.freeze({__proto__:null,identity:he});const le=ce({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var ue=Object.freeze({__proto__:null,base2:le});const pe=ce({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var fe=Object.freeze({__proto__:null,base8:pe});const ge=ae({prefix:"9",name:"base10",alphabet:"0123456789"});var me=Object.freeze({__proto__:null,base10:ge});const be=ce({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),ye=ce({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var we=Object.freeze({__proto__:null,base16:be,base16upper:ye});const ve=ce({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Ie=ce({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Ee=ce({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),_e=ce({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ae=ce({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Ne=ce({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ce=ce({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Se=ce({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Pe=ce({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Oe=Object.freeze({__proto__:null,base32:ve,base32upper:Ie,base32pad:Ee,base32padupper:_e,base32hex:Ae,base32hexupper:Ne,base32hexpad:Ce,base32hexpadupper:Se,base32z:Pe});const Te=ae({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),xe=ae({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var ke=Object.freeze({__proto__:null,base36:Te,base36upper:xe});const Re=ae({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Me=ae({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Ue=Object.freeze({__proto__:null,base58btc:Re,base58flickr:Me});const De=ce({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),je=ce({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Le=ce({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),qe=ce({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var $e=Object.freeze({__proto__:null,base64:De,base64pad:je,base64url:Le,base64urlpad:qe});const Be=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),ze=Be.reduce((e,t,i)=>(e[i]=t,e),[]),He=Be.reduce((e,t,i)=>(e[t.codePointAt(0)]=i,e),[]),We=oe({prefix:"🚀",name:"base256emoji",encode:function(e){return e.reduce((e,t)=>e+ze[t],"")},decode:function(e){const t=[];for(const i of e){const e=He[i.codePointAt(0)];if(void 0===e)throw new Error(`Non-base256emoji character: ${i}`);t.push(e)}return new Uint8Array(t)}});var Ve=Object.freeze({__proto__:null,base256emoji:We}),Fe=128,Ke=-128,Ge=Math.pow(2,31),Je=Math.pow(2,7),Ye=Math.pow(2,14),Xe=Math.pow(2,21),Qe=Math.pow(2,28),Ze=Math.pow(2,35),et=Math.pow(2,42),tt=Math.pow(2,49),it=Math.pow(2,56),st=Math.pow(2,63),rt=function e(t,i,s){i=i||[];for(var r=s=s||0;t>=Ge;)i[s++]=255&t|Fe,t/=128;for(;t&Ke;)i[s++]=255&t|Fe,t>>>=7;return i[s]=0|t,e.bytes=s-r+1,i},nt=function(e){return e<Je?1:e<Ye?2:e<Xe?3:e<Qe?4:e<Ze?5:e<et?6:e<tt?7:e<it?8:e<st?9:10};const ot=(e,t,i=0)=>(rt(e,t,i),t),at=e=>nt(e),ct=(e,t)=>{const i=t.byteLength,s=at(e),r=s+at(i),n=new Uint8Array(r+i);return ot(e,n,0),ot(i,n,s),n.set(t,r),new ht(e,i,t,n)};class ht{constructor(e,t,i,s){this.code=e,this.size=t,this.digest=i,this.bytes=s}}const dt=({name:e,code:t,encode:i})=>new lt(e,t,i);class lt{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?ct(this.code,t):t.then(e=>ct(this.code,e))}throw Error("Unknown type, must be binary type")}}const ut=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),pt=dt({name:"sha2-256",code:18,encode:ut("SHA-256")}),ft=dt({name:"sha2-512",code:19,encode:ut("SHA-512")});Object.freeze({__proto__:null,sha256:pt,sha512:ft});const gt=ee,mt={code:0,name:"identity",encode:gt,digest:e=>ct(0,gt(e))};Object.freeze({__proto__:null,identity:mt}),new TextEncoder,new TextDecoder;const bt={...de,...ue,...fe,...me,...we,...Oe,...ke,...Ue,...$e,...Ve};function yt(e,t,i,s){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:i},decoder:{decode:s}}}const wt=yt("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>(new TextEncoder).encode(e.substring(1))),vt=yt("ascii","a",e=>{let t="a";for(let i=0;i<e.length;i++)t+=String.fromCharCode(e[i]);return t},e=>{const t=function(e=0){return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?globalThis.Buffer.allocUnsafe(e):new Uint8Array(e)}((e=e.substring(1)).length);for(let i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}),It={utf8:wt,"utf-8":wt,hex:bt.base16,latin1:vt,ascii:vt,binary:vt,...bt};var Et=Object.defineProperty,_t=(e,t,i)=>((e,t,i)=>t in e?Et(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class At{constructor(e,t){this.core=e,this.logger=t,_t(this,"keychain",new Map),_t(this,"name","keychain"),_t(this,"version","0.3"),_t(this,"initialized",!1),_t(this,"storagePrefix",v),_t(this,"init",async()=>{if(!this.initialized){const e=await this.getKeyChain();typeof e<"u"&&(this.keychain=e),this.initialized=!0}}),_t(this,"has",e=>(this.isInitialized(),this.keychain.has(e))),_t(this,"set",async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()}),_t(this,"get",e=>{this.isInitialized();const t=this.keychain.get(e);if(typeof t>"u"){const{message:t}=(0,u.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}),_t(this,"del",async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()}),this.core=e,this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,(0,u.h0Y)(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?(0,u.PUk)(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Nt=Object.defineProperty,Ct=(e,t,i)=>((e,t,i)=>t in e?Nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class St{constructor(e,t,i){this.core=e,this.logger=t,Ct(this,"name","crypto"),Ct(this,"keychain"),Ct(this,"randomSessionIdentifier",(0,u.two)()),Ct(this,"initialized",!1),Ct(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Ct(this,"hasKeys",e=>(this.isInitialized(),this.keychain.has(e))),Ct(this,"getClientId",async()=>{this.isInitialized();const e=await this.getClientSeed(),t=l.TZ(e);return l.UF(t.publicKey)}),Ct(this,"generateKeyPair",()=>{this.isInitialized();const e=(0,u.TZl)();return this.setPrivateKey(e.publicKey,e.privateKey)}),Ct(this,"signJWT",async e=>{this.isInitialized();const t=await this.getClientSeed(),i=l.TZ(t),s=this.randomSessionIdentifier,r=_;return await l.FA(s,e,r,i)}),Ct(this,"generateSharedKey",(e,t,i)=>{this.isInitialized();const s=this.getPrivateKey(e),r=(0,u.ovp)(s,t);return this.setSymKey(r,i)}),Ct(this,"setSymKey",async(e,t)=>{this.isInitialized();const i=t||(0,u.EN$)(e);return await this.keychain.set(i,e),i}),Ct(this,"deleteKeyPair",async e=>{this.isInitialized(),await this.keychain.del(e)}),Ct(this,"deleteSymKey",async e=>{this.isInitialized(),await this.keychain.del(e)}),Ct(this,"encode",async(e,t,i)=>{this.isInitialized();const s=(0,u.AwN)(i),r=(0,d.h)(t);if((0,u.ps1)(s))return(0,u.Tw2)(r,i?.encoding);if((0,u.V7m)(s)){const t=s.senderPublicKey,i=s.receiverPublicKey;e=await this.generateSharedKey(t,i)}const n=this.getSymKey(e),{type:o,senderPublicKey:a}=s;return(0,u.wa2)({type:o,symKey:n,message:r,senderPublicKey:a,encoding:i?.encoding})}),Ct(this,"decode",async(e,t,i)=>{this.isInitialized();const s=(0,u.C5G)(t,i);if((0,u.ps1)(s)){const e=(0,u.F$L)(t,i?.encoding);return(0,d.j)(e)}if((0,u.V7m)(s)){const t=s.receiverPublicKey,i=s.senderPublicKey;e=await this.generateSharedKey(t,i)}try{const s=this.getSymKey(e),r=(0,u.YcA)({symKey:s,encoded:t,encoding:i?.encoding});return(0,d.j)(r)}catch(t){this.logger.error(`Failed to decode message from topic: '${e}', clientId: '${await this.getClientId()}'`),this.logger.error(t)}}),Ct(this,"getPayloadType",(e,t=u.EWt)=>{const i=(0,u.iui)({encoded:e,encoding:t});return(0,u.x0t)(i.type)}),Ct(this,"getPayloadSenderPublicKey",(e,t=u.EWt)=>{const i=(0,u.iui)({encoded:e,encoding:t});return i.senderPublicKey?(0,p.dI)(i.senderPublicKey,u.bEt):void 0}),this.core=e,this.logger=(0,a.U5)(t,this.name),this.keychain=i||new At(this.core,this.logger)}get context(){return(0,a.oI)(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(E)}catch{e=(0,u.two)(),await this.keychain.set(E,e)}return function(e,t="utf8"){const i=It[t];if(!i)throw new Error(`Unsupported encoding "${t}"`);return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?i.decoder.decode(`${i.prefix}${e}`):globalThis.Buffer.from(e,"utf8")}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Pt=Object.defineProperty,Ot=Object.defineProperties,Tt=Object.getOwnPropertyDescriptors,xt=Object.getOwnPropertySymbols,kt=Object.prototype.hasOwnProperty,Rt=Object.prototype.propertyIsEnumerable,Mt=(e,t,i)=>t in e?Pt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Ut=(e,t,i)=>Mt(e,"symbol"!=typeof t?t+"":t,i);class Dt extends c.dQ{constructor(e,t){super(e,t),this.logger=e,this.core=t,Ut(this,"messages",new Map),Ut(this,"messagesWithoutClientAck",new Map),Ut(this,"name","messages"),Ut(this,"version","0.3"),Ut(this,"initialized",!1),Ut(this,"storagePrefix",v),Ut(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const e=await this.getRelayerMessages();typeof e<"u"&&(this.messages=e);const t=await this.getRelayerMessagesWithoutClientAck();typeof t<"u"&&(this.messagesWithoutClientAck=t),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}finally{this.initialized=!0}}}),Ut(this,"set",async(e,t,i)=>{this.isInitialized();const s=(0,u.ALl)(t);let r=this.messages.get(e);if(typeof r>"u"&&(r={}),typeof r[s]<"u")return s;if(r[s]=t,this.messages.set(e,r),i===M){const i=this.messagesWithoutClientAck.get(e)||{};this.messagesWithoutClientAck.set(e,((e,t)=>Ot(e,Tt(t)))(((e,t)=>{for(var i in t||(t={}))kt.call(t,i)&&Mt(e,i,t[i]);if(xt)for(var i of xt(t))Rt.call(t,i)&&Mt(e,i,t[i]);return e})({},i),{[s]:t}))}return await this.persist(),s}),Ut(this,"get",e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t}),Ut(this,"getWithoutAck",e=>{this.isInitialized();const t={};for(const i of e){const e=this.messagesWithoutClientAck.get(i)||{};t[i]=Object.values(e)}return t}),Ut(this,"has",(e,t)=>(this.isInitialized(),typeof this.get(e)[(0,u.ALl)(t)]<"u")),Ut(this,"ack",async(e,t)=>{this.isInitialized();const i=this.messagesWithoutClientAck.get(e);typeof i>"u"||(delete i[(0,u.ALl)(t)],0===Object.keys(i).length?this.messagesWithoutClientAck.delete(e):this.messagesWithoutClientAck.set(e,i),await this.persist())}),Ut(this,"del",async e=>{this.isInitialized(),this.messages.delete(e),this.messagesWithoutClientAck.delete(e),await this.persist()}),this.logger=(0,a.U5)(e,this.name),this.core=t}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,(0,u.h0Y)(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,(0,u.h0Y)(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?(0,u.PUk)(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?(0,u.PUk)(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var jt=Object.defineProperty,Lt=Object.defineProperties,qt=Object.getOwnPropertyDescriptors,$t=Object.getOwnPropertySymbols,Bt=Object.prototype.hasOwnProperty,zt=Object.prototype.propertyIsEnumerable,Ht=(e,t,i)=>t in e?jt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Wt=(e,t)=>{for(var i in t||(t={}))Bt.call(t,i)&&Ht(e,i,t[i]);if($t)for(var i of $t(t))zt.call(t,i)&&Ht(e,i,t[i]);return e},Vt=(e,t)=>Lt(e,qt(t)),Ft=(e,t,i)=>Ht(e,"symbol"!=typeof t?t+"":t,i);class Kt extends c.qE{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,Ft(this,"events",new s.EventEmitter),Ft(this,"name","publisher"),Ft(this,"queue",new Map),Ft(this,"publishTimeout",(0,h.toMiliseconds)(h.ONE_MINUTE)),Ft(this,"initialPublishTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),Ft(this,"needsTransportRestart",!1),Ft(this,"publish",async(e,t,i)=>{var s;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:i}});const r=i?.ttl||A,n=(0,u.n6V)(i),o=i?.prompt||!1,a=i?.tag||0,c=i?.id||(0,g.getBigIntRpcId)().toString(),h={topic:e,message:t,opts:{ttl:r,relay:n,prompt:o,tag:a,id:c,attestation:i?.attestation,tvf:i?.tvf}},d=`Failed to publish payload, please try again. id:${c} tag:${a}`;try{const s=new Promise(async s=>{const n=({id:e})=>{h.opts.id===e&&(this.removeRequestFromQueue(e),this.relayer.events.removeListener(S.publish,n),s(h))};this.relayer.events.on(S.publish,n);const d=(0,u.K3g)(new Promise((s,n)=>{this.rpcPublish({topic:e,message:t,ttl:r,prompt:o,tag:a,id:c,attestation:i?.attestation,tvf:i?.tvf}).then(s).catch(e=>{this.logger.warn(e,e?.message),n(e)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${c} tag:${a}`);try{await d,this.events.removeListener(S.publish,n)}catch(e){this.queue.set(c,Vt(Wt({},h),{attempt:1})),this.logger.warn(e,e?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:c,topic:e,message:t,opts:i}}),await(0,u.K3g)(s,this.publishTimeout,d)}catch(e){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(e),null!=(s=i?.internal)&&s.throwOnFailedPublish)throw e}finally{this.queue.delete(c)}}),Ft(this,"on",(e,t)=>{this.events.on(e,t)}),Ft(this,"once",(e,t)=>{this.events.once(e,t)}),Ft(this,"off",(e,t)=>{this.events.off(e,t)}),Ft(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.relayer=e,this.logger=(0,a.U5)(t,this.name),this.registerEventListeners()}get context(){return(0,a.oI)(this.logger)}async rpcPublish(e){var t,i,s,r;const{topic:n,message:o,ttl:a=A,prompt:c,tag:h,id:d,attestation:l,tvf:p}=e,f={method:(0,u.aa1)((0,u.n6V)().protocol).publish,params:Wt({topic:n,message:o,ttl:a,prompt:c,tag:h,attestation:l},p),id:d};(0,u.b07)(null==(t=f.params)?void 0:t.prompt)&&(null==(i=f.params)||delete i.prompt),(0,u.b07)(null==(s=f.params)?void 0:s.tag)&&(null==(r=f.params)||delete r.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:f});const g=await this.relayer.request(f);return this.relayer.events.emit(S.publish,e),this.logger.debug("Successfully Published Payload"),g}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{const i=e.attempt+1;this.queue.set(t,Vt(Wt({},e),{attempt:i}));const{topic:s,message:r,opts:n,attestation:o}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish(Vt(Wt({},e),{topic:s,message:r,ttl:n.ttl,prompt:n.prompt,tag:n.tag,id:n.id,attestation:o,tvf:n.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(n.li.pulse,()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(S.connection_stalled);this.checkQueue()}),this.relayer.on(S.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var Gt=Object.defineProperty,Jt=(e,t,i)=>((e,t,i)=>t in e?Gt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Yt{constructor(){Jt(this,"map",new Map),Jt(this,"set",(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])}),Jt(this,"get",e=>this.map.get(e)||[]),Jt(this,"exists",(e,t)=>this.get(e).includes(t)),Jt(this,"delete",(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const s=i.filter(e=>e!==t);s.length?this.map.set(e,s):this.map.delete(e)}),Jt(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var Xt=Object.defineProperty,Qt=Object.defineProperties,Zt=Object.getOwnPropertyDescriptors,ei=Object.getOwnPropertySymbols,ti=Object.prototype.hasOwnProperty,ii=Object.prototype.propertyIsEnumerable,si=(e,t,i)=>t in e?Xt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,ri=(e,t)=>{for(var i in t||(t={}))ti.call(t,i)&&si(e,i,t[i]);if(ei)for(var i of ei(t))ii.call(t,i)&&si(e,i,t[i]);return e},ni=(e,t)=>Qt(e,Zt(t)),oi=(e,t,i)=>si(e,"symbol"!=typeof t?t+"":t,i);class ai extends c.mF{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,oi(this,"subscriptions",new Map),oi(this,"topicMap",new Yt),oi(this,"events",new s.EventEmitter),oi(this,"name","subscription"),oi(this,"version","0.3"),oi(this,"pending",new Map),oi(this,"cached",[]),oi(this,"initialized",!1),oi(this,"storagePrefix",v),oi(this,"subscribeTimeout",(0,h.toMiliseconds)(h.ONE_MINUTE)),oi(this,"initialSubscribeTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),oi(this,"clientId"),oi(this,"batchSubscribeTopicsLimit",500),oi(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),oi(this,"subscribe",async(e,t)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const i=(0,u.n6V)(t),s={topic:e,relay:i,transportType:t?.transportType};this.pending.set(e,s);const r=await this.rpcSubscribe(e,i,t);return"string"==typeof r&&(this.onSubscribe(r,s),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}})),r}catch(e){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(e),e}}),oi(this,"unsubscribe",async(e,t)=>{this.isInitialized(),typeof t?.id<"u"?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)}),oi(this,"isSubscribed",e=>new Promise(t=>{t(this.topicMap.topics.includes(e))})),oi(this,"isKnownTopic",e=>new Promise(t=>{t(this.topicMap.topics.includes(e)||this.pending.has(e)||this.cached.some(t=>t.topic===e))})),oi(this,"on",(e,t)=>{this.events.on(e,t)}),oi(this,"once",(e,t)=>{this.events.once(e,t)}),oi(this,"off",(e,t)=>{this.events.off(e,t)}),oi(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),oi(this,"start",async()=>{await this.onConnect()}),oi(this,"stop",async()=>{await this.onDisconnect()}),oi(this,"restart",async()=>{await this.restore(),await this.onRestart()}),oi(this,"checkPending",async()=>{if(!(0!==this.pending.size||this.initialized&&this.relayer.connected))return;const e=[];this.pending.forEach(t=>{e.push(t)}),await this.batchSubscribe(e)}),oi(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(n.li.pulse,async()=>{await this.checkPending()}),this.events.on(D,async e=>{const t=D;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(j,async e=>{const t=j;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}),this.relayer=e,this.logger=(0,a.U5)(t,this.name),this.clientId=""}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async i=>await this.unsubscribeById(e,i,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const s=(0,u.n6V)(i);await this.restartToComplete({topic:e,id:t,relay:s}),await this.rpcUnsubscribe(e,t,s);const r=(0,u.Hjj)("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,r),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(e){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(e),e}}async rpcSubscribe(e,t,i){var s;(!i||i?.transportType===R.relay)&&await this.restartToComplete({topic:e,id:e,relay:t});const r={method:(0,u.aa1)(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r});const n=null==(s=i?.internal)?void 0:s.throwOnFailedPublish;try{const t=await this.getSubscriptionId(e);if(i?.transportType===R.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(r).catch(e=>this.logger.warn(e))},(0,h.toMiliseconds)(h.ONE_SECOND)),t;const s=new Promise(async t=>{const i=s=>{s.topic===e&&(this.events.removeListener(D,i),t(s.id))};this.events.on(D,i);try{const s=await(0,u.K3g)(new Promise((e,t)=>{this.relayer.request(r).catch(e=>{this.logger.warn(e,e?.message),t(e)}).then(e)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(D,i),t(s)}catch{}}),o=await(0,u.K3g)(s,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!o&&n)throw new Error(`Subscribing to ${e} failed, please try again`);return o?t:null}catch(e){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(S.connection_stalled),n)throw e}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:(0,u.aa1)(t.protocol).batchSubscribe,params:{topics:e.map(e=>e.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await(0,u.K3g)(new Promise(e=>{this.relayer.request(i).catch(e=>this.logger.warn(e)).then(e)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(S.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,i={method:(0,u.aa1)(t.protocol).batchFetchMessages,params:{topics:e.map(e=>e.topic)}};let s;this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{s=await await(0,u.K3g)(new Promise((e,t)=>{this.relayer.request(i).catch(e=>{this.logger.warn(e),t(e)}).then(e)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(S.connection_stalled)}return s}rpcUnsubscribe(e,t,i){const s={method:(0,u.aa1)(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:s}),this.relayer.request(s)}onSubscribe(e,t){this.setSubscription(e,ni(ri({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(e=>{this.setSubscription(e.id,ri({},e)),this.pending.delete(e.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,ri({},t)),this.topicMap.set(t.topic,e),this.events.emit(D,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:t}=(0,u.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(j,ni(ri({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit("subscription_sync")}async onRestart(){if(this.cached.length){const e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<t;i++){const t=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(t)}}this.events.emit("subscription_resubscribed")}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:e}=(0,u.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async e=>ni(ri({},e),{id:await this.getSubscriptionId(e.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await(0,u.yy4)((0,h.toMiliseconds)(h.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(t.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return(0,u.ALl)(e+await this.getClientId())}}var ci=Object.defineProperty,hi=Object.getOwnPropertySymbols,di=Object.prototype.hasOwnProperty,li=Object.prototype.propertyIsEnumerable,ui=(e,t,i)=>t in e?ci(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,pi=(e,t)=>{for(var i in t||(t={}))di.call(t,i)&&ui(e,i,t[i]);if(hi)for(var i of hi(t))li.call(t,i)&&ui(e,i,t[i]);return e},fi=(e,t,i)=>ui(e,"symbol"!=typeof t?t+"":t,i);class gi extends c.m5{constructor(e){super(e),fi(this,"protocol","wc"),fi(this,"version",2),fi(this,"core"),fi(this,"logger"),fi(this,"events",new s.EventEmitter),fi(this,"provider"),fi(this,"messages"),fi(this,"subscriber"),fi(this,"publisher"),fi(this,"name","relayer"),fi(this,"transportExplicitlyClosed",!1),fi(this,"initialized",!1),fi(this,"connectionAttemptInProgress",!1),fi(this,"relayUrl"),fi(this,"projectId"),fi(this,"packageName"),fi(this,"bundleId"),fi(this,"hasExperiencedNetworkDisruption",!1),fi(this,"pingTimeout"),fi(this,"heartBeatTimeout",(0,h.toMiliseconds)(h.THIRTY_SECONDS+h.FIVE_SECONDS)),fi(this,"reconnectTimeout"),fi(this,"connectPromise"),fi(this,"reconnectInProgress",!1),fi(this,"requestsInFlight",[]),fi(this,"connectTimeout",(0,h.toMiliseconds)(15*h.ONE_SECOND)),fi(this,"request",async e=>{var t,i;this.logger.debug("Publishing Request Payload");const s=e.id||(0,g.getBigIntRpcId)().toString();await this.toEstablishConnection();try{this.logger.trace({id:s,method:e.method,topic:null==(t=e.params)?void 0:t.topic},"relayer.request - publishing...");const r=`${s}:${(null==(i=e.params)?void 0:i.tag)||""}`;this.requestsInFlight.push(r);const n=await this.provider.request(e);return this.requestsInFlight=this.requestsInFlight.filter(e=>e!==r),n}catch(e){throw this.logger.debug(`Failed to Publish Request: ${s}`),e}}),fi(this,"resetPingTimeout",()=>{(0,u.Lln)()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var e,t,i,s;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),null==(s=null==(i=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:i.terminate)||s.call(i)}catch(e){this.logger.warn(e,e?.message)}},this.heartBeatTimeout))}),fi(this,"onPayloadHandler",e=>{this.onProviderPayload(e),this.resetPingTimeout()}),fi(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(S.connect)}),fi(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),fi(this,"onProviderErrorHandler",e=>{this.logger.fatal(`Fatal socket error: ${e.message}`),this.events.emit(S.error,e),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),fi(this,"registerProviderListeners",()=>{this.provider.on(P,this.onPayloadHandler),this.provider.on(O,this.onConnectHandler),this.provider.on(T,this.onDisconnectHandler),this.provider.on(x,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&"string"!=typeof e.logger?(0,a.U5)(e.logger,this.name):(0,a.h6)((0,a.iP)({level:e.logger||"error"})),this.messages=new Dt(this.logger,e.core),this.subscriber=new ai(this,this.logger),this.publisher=new Kt(this,this.logger),this.relayUrl=e?.relayUrl||C,this.projectId=e.projectId,(0,u.m01)()?this.packageName=(0,u.R7U)():(0,u.aRZ)()&&(this.bundleId=(0,u.R7U)()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e?.message)}}get context(){return(0,a.oI)(this.logger)}get connected(){var e,t,i;return 1===(null==(i=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:i.readyState)||!1}get connecting(){var e,t,i;return 0===(null==(i=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:i.readyState)||void 0!==this.connectPromise||!1}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:R.relay},"outbound")}async subscribe(e,t){var i,s,r;this.isInitialized(),(null==t||!t.transportType||"relay"===t?.transportType)&&await this.toEstablishConnection();const n=typeof(null==(i=t?.internal)?void 0:i.throwOnFailedPublish)>"u"||(null==(s=t?.internal)?void 0:s.throwOnFailedPublish);let o,a=(null==(r=this.subscriber.topicMap.get(e))?void 0:r[0])||"";const c=t=>{t.topic===e&&(this.subscriber.off(D,c),o())};return await Promise.all([new Promise(e=>{o=e,this.subscriber.on(D,c)}),new Promise(async(i,s)=>{a=await this.subscriber.subscribe(e,pi({internal:{throwOnFailedPublish:n}},t)).catch(e=>{n&&s(e)})||a,i()})]),a}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await(0,u.K3g)(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(this.subscriber.hasAnyTopics){if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(t,i)=>{await this.connect(e).then(t).catch(i).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}else this.logger.warn("Starting WS connection skipped because the client has no topics to work with.")}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await(0,u.sc7)())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(0===e?.length)return void this.logger.trace("Batch message events is empty. Ignoring...");const t=e.sort((e,t)=>e.publishedAt-t.publishedAt);this.logger.debug(`Batch of ${t.length} message events sorted`);for(const e of t)try{await this.onMessageEvent(e)}catch(e){this.logger.warn(e,"Error while processing batch message event: "+e?.message)}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:i}=e;if(!t.sessionExists){const e={topic:i,expiry:(0,u.Xw0)(h.FIVE_MINUTES),relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,e)}this.events.emit(S.message,e),await this.recordMessageEvent(e,M)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let t=1;for(;t<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(e,t)=>{const i=()=>{t(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(T,i),await(0,u.K3g)(new Promise((e,t)=>{this.provider.connect().then(e).catch(t)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(e=>{t(e)}).finally(()=>{this.provider.off(T,i),clearTimeout(this.reconnectTimeout)}),await new Promise(async(e,t)=>{const i=()=>{t(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(T,i),await this.subscriber.start().then(e).catch(t).finally(()=>{this.provider.off(T,i)})}),this.hasExperiencedNetworkDisruption=!1,e()})}catch(e){await this.subscriber.stop();const t=e;this.logger.warn({},t.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(e=>setTimeout(e,(0,h.toMiliseconds)(1*t))),t++}}startPingTimeout(){var e,t,i,s,r;if((0,u.Lln)())try{null!=(t=null==(e=this.provider)?void 0:e.connection)&&t.socket&&(null==(r=null==(s=null==(i=this.provider)?void 0:i.connection)?void 0:s.socket)||r.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(e){this.logger.warn(e,e?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new f.F(new m.A((0,u.jUZ)({sdkVersion:k,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e,t){const{topic:i,message:s}=e;await this.messages.set(i,s,t)}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||0===i.length)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isKnownTopic(t))return this.logger.warn(`Ignoring message for unknown topic ${t}`),!0;const s=this.messages.has(t,i);return s&&this.logger.warn(`Ignoring duplicate message: ${i}`),s}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),(0,g.isJsonRpcRequest)(e)){if(!e.method.endsWith("_subscription"))return;const t=e.params,{topic:i,message:s,publishedAt:r,attestation:n}=t.data,o={topic:i,message:s,publishedAt:r,transportType:R.relay,attestation:n};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(pi({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o)}else(0,g.isJsonRpcResponse)(e)&&this.events.emit(S.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,M),this.events.emit(S.message,e))}async acknowledgePayload(e){const t=(0,g.formatJsonRpcResult)(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(P,this.onPayloadHandler),this.provider.off(O,this.onConnectHandler),this.provider.off(T,this.onDisconnectHandler),this.provider.off(x,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await(0,u.sc7)();(0,u.uym)(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(e=>this.logger.error(e,e?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(S.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},(0,h.toMiliseconds)(.1)))))}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.connect()}}function mi(){}function bi(e){if(!e||"object"!=typeof e)return!1;const t=Object.getPrototypeOf(e);return(null===t||t===Object.prototype||null===Object.getPrototypeOf(t))&&"[object Object]"===Object.prototype.toString.call(e)}function yi(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}function wi(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const vi="[object Arguments]",Ii="[object Object]";function Ei(e,t,i,s,r,n,o){const a=o(e,t,i,s,r,n);if(void 0!==a)return a;if(typeof e==typeof t)switch(typeof e){case"bigint":case"string":case"boolean":case"symbol":case"undefined":case"function":return e===t;case"number":return e===t||Object.is(e,t);case"object":return _i(e,t,n,o)}return _i(e,t,n,o)}function _i(e,t,i,s){if(Object.is(e,t))return!0;let r=wi(e),n=wi(t);if(r===vi&&(r=Ii),n===vi&&(n=Ii),r!==n)return!1;switch(r){case"[object String]":return e.toString()===t.toString();case"[object Number]":return function(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}(e.valueOf(),t.valueOf());case"[object Boolean]":case"[object Date]":case"[object Symbol]":return Object.is(e.valueOf(),t.valueOf());case"[object RegExp]":return e.source===t.source&&e.flags===t.flags;case"[object Function]":return e===t}const o=(i=i??new Map).get(e),a=i.get(t);if(null!=o&&null!=a)return o===t;i.set(e,t),i.set(t,e);try{switch(r){case"[object Map]":if(e.size!==t.size)return!1;for(const[r,n]of e.entries())if(!t.has(r)||!Ei(n,t.get(r),r,e,t,i,s))return!1;return!0;case"[object Set]":{if(e.size!==t.size)return!1;const r=Array.from(e.values()),n=Array.from(t.values());for(let o=0;o<r.length;o++){const a=r[o],c=n.findIndex(r=>Ei(a,r,void 0,e,t,i,s));if(-1===c)return!1;n.splice(c,1)}return!0}case"[object Array]":case"[object Uint8Array]":case"[object Uint8ClampedArray]":case"[object Uint16Array]":case"[object Uint32Array]":case"[object BigUint64Array]":case"[object Int8Array]":case"[object Int16Array]":case"[object Int32Array]":case"[object BigInt64Array]":case"[object Float32Array]":case"[object Float64Array]":if(typeof y<"u"&&y.isBuffer(e)!==y.isBuffer(t)||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(!Ei(e[r],t[r],r,e,t,i,s))return!1;return!0;case"[object ArrayBuffer]":return e.byteLength===t.byteLength&&_i(new Uint8Array(e),new Uint8Array(t),i,s);case"[object DataView]":return e.byteLength===t.byteLength&&e.byteOffset===t.byteOffset&&_i(new Uint8Array(e),new Uint8Array(t),i,s);case"[object Error]":return e.name===t.name&&e.message===t.message;case Ii:{if(!(_i(e.constructor,t.constructor,i,s)||bi(e)&&bi(t)))return!1;const r=[...Object.keys(e),...yi(e)],n=[...Object.keys(t),...yi(t)];if(r.length!==n.length)return!1;for(let n=0;n<r.length;n++){const o=r[n],a=e[o];if(!Object.hasOwn(t,o))return!1;if(!Ei(a,t[o],o,e,t,i,s))return!1}return!0}default:return!1}}finally{i.delete(e),i.delete(t)}}var Ai=Object.defineProperty,Ni=Object.getOwnPropertySymbols,Ci=Object.prototype.hasOwnProperty,Si=Object.prototype.propertyIsEnumerable,Pi=(e,t,i)=>t in e?Ai(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Oi=(e,t)=>{for(var i in t||(t={}))Ci.call(t,i)&&Pi(e,i,t[i]);if(Ni)for(var i of Ni(t))Si.call(t,i)&&Pi(e,i,t[i]);return e},Ti=(e,t,i)=>Pi(e,"symbol"!=typeof t?t+"":t,i);class xi extends c.pi{constructor(e,t,i,s=v,r=void 0){super(e,t,i,s),this.core=e,this.logger=t,this.name=i,Ti(this,"map",new Map),Ti(this,"version","0.3"),Ti(this,"cached",[]),Ti(this,"initialized",!1),Ti(this,"getKey"),Ti(this,"storagePrefix",v),Ti(this,"recentlyDeleted",[]),Ti(this,"recentlyDeletedLimit",200),Ti(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>{this.getKey&&null!==e&&!(0,u.b07)(e)?this.map.set(this.getKey(e),e):(0,u.CTo)(e)?this.map.set(e.id,e):(0,u.mr0)(e)&&this.map.set(e.topic,e)}),this.cached=[],this.initialized=!0)}),Ti(this,"set",async(e,t)=>{this.isInitialized(),this.map.has(e)?await this.update(e,t):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:e,value:t}),this.map.set(e,t),await this.persist())}),Ti(this,"get",e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e))),Ti(this,"getAll",e=>(this.isInitialized(),e?this.values.filter(t=>Object.keys(e).every(i=>function(e,t){return function(e,t,i){return Ei(e,t,void 0,void 0,void 0,void 0,i)}(e,t,mi)}(t[i],e[i]))):this.values)),Ti(this,"update",async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});const i=Oi(Oi({},this.getData(e)),t);this.map.set(e,i),await this.persist()}),Ti(this,"delete",async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:e,reason:t}),this.map.delete(e),this.addToRecentlyDeleted(e),await this.persist())}),this.logger=(0,a.U5)(t,this.name),this.storagePrefix=s,this.getKey=r}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:t}=(0,u.GuA)("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}const{message:t}=(0,u.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(t),new Error(t)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:e}=(0,u.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var ki=Object.defineProperty,Ri=(e,t,i)=>((e,t,i)=>t in e?ki(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Mi{constructor(e,t){this.core=e,this.logger=t,Ri(this,"name","pairing"),Ri(this,"version","0.3"),Ri(this,"events",new(r())),Ri(this,"pairings"),Ri(this,"initialized",!1),Ri(this,"storagePrefix",v),Ri(this,"ignoredPayloadTypes",[u.Lp_]),Ri(this,"registeredMethods",[]),Ri(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),Ri(this,"register",({methods:e})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...e])]}),Ri(this,"create",async e=>{this.isInitialized();const t=(0,u.two)(),i=await this.core.crypto.setSymKey(t),s=(0,u.Xw0)(h.FIVE_MINUTES),r={protocol:N},n={topic:i,expiry:s,relay:r,active:!1,methods:e?.methods},o=(0,u.QJh)({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:t,relay:r,expiryTimestamp:s,methods:e?.methods});return this.events.emit(q.create,n),this.core.expirer.set(i,s),await this.pairings.set(i,n),await this.core.relayer.subscribe(i,{transportType:e?.transportType}),{topic:i,uri:o}}),Ri(this,"pair",async e=>{this.isInitialized();const t=this.core.eventClient.createEvent({properties:{topic:e?.uri,trace:[G.pairing_started]}});this.isValidPair(e,t);const{topic:i,symKey:s,relay:r,expiryTimestamp:n,methods:o}=(0,u.wYp)(e.uri);let a;if(t.props.properties.topic=i,t.addTrace(G.pairing_uri_validation_success),t.addTrace(G.pairing_uri_not_expired),this.pairings.keys.includes(i)){if(a=this.pairings.get(i),t.addTrace(G.existing_pairing),a.active)throw t.setError(J.active_pairing_already_exists),new Error(`Pairing already exists: ${i}. Please try again with a new connection URI.`);t.addTrace(G.pairing_not_expired)}const c=n||(0,u.Xw0)(h.FIVE_MINUTES),d={topic:i,relay:r,expiry:c,active:!1,methods:o};this.core.expirer.set(i,c),await this.pairings.set(i,d),t.addTrace(G.store_new_pairing),e.activatePairing&&await this.activate({topic:i}),this.events.emit(q.create,d),t.addTrace(G.emit_inactive_pairing),this.core.crypto.keychain.has(i)||await this.core.crypto.setSymKey(s,i),t.addTrace(G.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{t.setError(J.no_internet_connection)}try{await this.core.relayer.subscribe(i,{relay:r})}catch(e){throw t.setError(J.subscribe_pairing_topic_failure),e}return t.addTrace(G.subscribe_pairing_topic_success),d}),Ri(this,"activate",async({topic:e})=>{this.isInitialized();const t=(0,u.Xw0)(h.FIVE_MINUTES);this.core.expirer.set(e,t),await this.pairings.update(e,{active:!0,expiry:t})}),Ri(this,"ping",async e=>{this.isInitialized(),await this.isValidPing(e),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:t}=e;if(this.pairings.keys.includes(t)){const e=await this.sendRequest(t,"wc_pairingPing",{}),{done:i,resolve:s,reject:r}=(0,u.Wx8)();this.events.once((0,u.hEn)("pairing_ping",e),({error:e})=>{e?r(e):s()}),await i()}}),Ri(this,"updateExpiry",async({topic:e,expiry:t})=>{this.isInitialized(),await this.pairings.update(e,{expiry:t})}),Ri(this,"updateMetadata",async({topic:e,metadata:t})=>{this.isInitialized(),await this.pairings.update(e,{peerMetadata:t})}),Ri(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),Ri(this,"disconnect",async e=>{this.isInitialized(),await this.isValidDisconnect(e);const{topic:t}=e;this.pairings.keys.includes(t)&&(await this.sendRequest(t,"wc_pairingDelete",(0,u.Hjj)("USER_DISCONNECTED")),await this.deletePairing(t))}),Ri(this,"formatUriFromPairing",e=>{this.isInitialized();const{topic:t,relay:i,expiry:s,methods:r}=e,n=this.core.crypto.keychain.get(t);return(0,u.QJh)({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:n,relay:i,expiryTimestamp:s,methods:r})}),Ri(this,"sendRequest",async(e,t,i)=>{const s=(0,g.formatJsonRpcRequest)(t,i),r=await this.core.crypto.encode(e,s),n=L[t].req;return this.core.history.set(e,s),this.core.relayer.publish(e,r,n),s.id}),Ri(this,"sendResult",async(e,t,i)=>{const s=(0,g.formatJsonRpcResult)(e,i),r=await this.core.crypto.encode(t,s),n=(await this.core.history.get(t,e)).request.method,o=L[n].res;await this.core.relayer.publish(t,r,o),await this.core.history.resolve(s)}),Ri(this,"sendError",async(e,t,i)=>{const s=(0,g.formatJsonRpcError)(e,i),r=await this.core.crypto.encode(t,s),n=(await this.core.history.get(t,e)).request.method,o=L[n]?L[n].res:L.unregistered_method.res;await this.core.relayer.publish(t,r,o),await this.core.history.resolve(s)}),Ri(this,"deletePairing",async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,(0,u.Hjj)("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])}),Ri(this,"cleanup",async()=>{const e=this.pairings.getAll().filter(e=>(0,u._dF)(e.expiry));await Promise.all(e.map(e=>this.deletePairing(e.topic)))}),Ri(this,"onRelayEventRequest",async e=>{const{topic:t,payload:i}=e;switch(i.method){case"wc_pairingPing":return await this.onPairingPingRequest(t,i);case"wc_pairingDelete":return await this.onPairingDeleteRequest(t,i);default:return await this.onUnknownRpcMethodRequest(t,i)}}),Ri(this,"onRelayEventResponse",async e=>{const{topic:t,payload:i}=e,s=(await this.core.history.get(t,i.id)).request.method;return"wc_pairingPing"===s?this.onPairingPingResponse(t,i):this.onUnknownRpcMethodResponse(s)}),Ri(this,"onPairingPingRequest",async(e,t)=>{const{id:i}=t;try{this.isValidPing({topic:e}),await this.sendResult(i,e,!0),this.events.emit(q.ping,{id:i,topic:e})}catch(t){await this.sendError(i,e,t),this.logger.error(t)}}),Ri(this,"onPairingPingResponse",(e,t)=>{const{id:i}=t;setTimeout(()=>{(0,g.isJsonRpcResult)(t)?this.events.emit((0,u.hEn)("pairing_ping",i),{}):(0,g.isJsonRpcError)(t)&&this.events.emit((0,u.hEn)("pairing_ping",i),{error:t.error})},500)}),Ri(this,"onPairingDeleteRequest",async(e,t)=>{const{id:i}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit(q.delete,{id:i,topic:e})}catch(t){await this.sendError(i,e,t),this.logger.error(t)}}),Ri(this,"onUnknownRpcMethodRequest",async(e,t)=>{const{id:i,method:s}=t;try{if(this.registeredMethods.includes(s))return;const t=(0,u.Hjj)("WC_METHOD_UNSUPPORTED",s);await this.sendError(i,e,t),this.logger.error(t)}catch(t){await this.sendError(i,e,t),this.logger.error(t)}}),Ri(this,"onUnknownRpcMethodResponse",e=>{this.registeredMethods.includes(e)||this.logger.error((0,u.Hjj)("WC_METHOD_UNSUPPORTED",e))}),Ri(this,"isValidPair",(e,t)=>{var i;if(!(0,u.TeY)(e)){const{message:i}=(0,u.GuA)("MISSING_OR_INVALID",`pair() params: ${e}`);throw t.setError(J.malformed_pairing_uri),new Error(i)}if(!(0,u.AYU)(e.uri)){const{message:i}=(0,u.GuA)("MISSING_OR_INVALID",`pair() uri: ${e.uri}`);throw t.setError(J.malformed_pairing_uri),new Error(i)}const s=(0,u.wYp)(e?.uri);if(null==(i=s?.relay)||!i.protocol){const{message:e}=(0,u.GuA)("MISSING_OR_INVALID","pair() uri#relay-protocol");throw t.setError(J.malformed_pairing_uri),new Error(e)}if(null==s||!s.symKey){const{message:e}=(0,u.GuA)("MISSING_OR_INVALID","pair() uri#symKey");throw t.setError(J.malformed_pairing_uri),new Error(e)}if(null!=s&&s.expiryTimestamp&&(0,h.toMiliseconds)(s?.expiryTimestamp)<Date.now()){t.setError(J.pairing_expired);const{message:e}=(0,u.GuA)("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(e)}}),Ri(this,"isValidPing",async e=>{if(!(0,u.TeY)(e)){const{message:t}=(0,u.GuA)("MISSING_OR_INVALID",`ping() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)}),Ri(this,"isValidDisconnect",async e=>{if(!(0,u.TeY)(e)){const{message:t}=(0,u.GuA)("MISSING_OR_INVALID",`disconnect() params: ${e}`);throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)}),Ri(this,"isValidPairingTopic",async e=>{if(!(0,u.Qhg)(e,!1)){const{message:t}=(0,u.GuA)("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.pairings.keys.includes(e)){const{message:t}=(0,u.GuA)("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if((0,u._dF)(this.pairings.get(e).expiry)){await this.deletePairing(e);const{message:t}=(0,u.GuA)("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}),this.core=e,this.logger=(0,a.U5)(t,this.name),this.pairings=new xi(this.core,this.logger,this.name,this.storagePrefix)}get context(){return(0,a.oI)(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(S.message,async e=>{const{topic:t,message:i,transportType:s}=e;if(this.pairings.keys.includes(t)&&s!==R.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))try{const e=await this.core.crypto.decode(t,i);(0,g.isJsonRpcRequest)(e)?(this.core.history.set(t,e),await this.onRelayEventRequest({topic:t,payload:e})):(0,g.isJsonRpcResponse)(e)&&(await this.core.history.resolve(e),await this.onRelayEventResponse({topic:t,payload:e}),this.core.history.delete(t,e.id)),await this.core.relayer.messages.ack(t,i)}catch(e){this.logger.error(e)}})}registerExpirerEvents(){this.core.expirer.on(H.expired,async e=>{const{topic:t}=(0,u.c82)(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(q.expire,{topic:t}))})}}var Ui=Object.defineProperty,Di=(e,t,i)=>((e,t,i)=>t in e?Ui(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class ji extends c.lZ{constructor(e,t){super(e,t),this.core=e,this.logger=t,Di(this,"records",new Map),Di(this,"events",new s.EventEmitter),Di(this,"name","history"),Di(this,"version","0.3"),Di(this,"cached",[]),Di(this,"initialized",!1),Di(this,"storagePrefix",v),Di(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.records.set(e.id,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Di(this,"set",(e,t,i)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:i}),this.records.has(t.id))return;const s={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:i,expiry:(0,u.Xw0)(h.THIRTY_DAYS)};this.records.set(s.id,s),this.persist(),this.events.emit($,s)}),Di(this,"resolve",async e=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:e}),!this.records.has(e.id))return;const t=await this.getRecord(e.id);typeof t.response>"u"&&(t.response=(0,g.isJsonRpcError)(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.persist(),this.events.emit(B,t))}),Di(this,"get",async(e,t)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:e,id:t}),await this.getRecord(t))),Di(this,"delete",(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach(i=>{if(i.topic===e){if(typeof t<"u"&&i.id!==t)return;this.records.delete(i.id),this.events.emit(z,i)}}),this.persist()}),Di(this,"exists",async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e)),Di(this,"on",(e,t)=>{this.events.on(e,t)}),Di(this,"once",(e,t)=>{this.events.once(e,t)}),Di(this,"off",(e,t)=>{this.events.off(e,t)}),Di(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:(0,g.formatJsonRpcRequest)(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:t}=(0,u.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit("history_sync")}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:e}=(0,u.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on($,e=>{const t=$;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(B,e=>{const t=B;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(z,e=>{const t=z;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(n.li.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,h.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(z,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Li=Object.defineProperty,qi=(e,t,i)=>((e,t,i)=>t in e?Li(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class $i extends c.Vx{constructor(e,t){super(e,t),this.core=e,this.logger=t,qi(this,"expirations",new Map),qi(this,"events",new s.EventEmitter),qi(this,"name","expirer"),qi(this,"version","0.3"),qi(this,"cached",[]),qi(this,"initialized",!1),qi(this,"storagePrefix",v),qi(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>this.expirations.set(e.target,e)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),qi(this,"has",e=>{try{const t=this.formatTarget(e);return typeof this.getExpiration(t)<"u"}catch{return!1}}),qi(this,"set",(e,t)=>{this.isInitialized();const i=this.formatTarget(e),s={target:i,expiry:t};this.expirations.set(i,s),this.checkExpiry(i,s),this.events.emit(H.created,{target:i,expiration:s})}),qi(this,"get",e=>{this.isInitialized();const t=this.formatTarget(e);return this.getExpiration(t)}),qi(this,"del",e=>{if(this.isInitialized(),this.has(e)){const t=this.formatTarget(e),i=this.getExpiration(t);this.expirations.delete(t),this.events.emit(H.deleted,{target:t,expiration:i})}}),qi(this,"on",(e,t)=>{this.events.on(e,t)}),qi(this,"once",(e,t)=>{this.events.once(e,t)}),qi(this,"off",(e,t)=>{this.events.off(e,t)}),qi(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,a.U5)(t,this.name)}get context(){return(0,a.oI)(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if("string"==typeof e)return(0,u.ADD)(e);if("number"==typeof e)return(0,u.gOF)(e);const{message:t}=(0,u.GuA)("UNKNOWN_TYPE","Target type: "+typeof e);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(H.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:e}=(0,u.GuA)("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:t}=(0,u.GuA)("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(t),new Error(t)}return t}checkExpiry(e,t){const{expiry:i}=t;(0,h.toMiliseconds)(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(H.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(n.li.pulse,()=>this.checkExpirations()),this.events.on(H.created,e=>{const t=H.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(H.expired,e=>{const t=H.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(H.deleted,e=>{const t=H.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=(0,u.GuA)("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Bi=Object.defineProperty,zi=(e,t,i)=>((e,t,i)=>t in e?Bi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Hi extends c.zl{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,zi(this,"name","verify-api"),zi(this,"abortController"),zi(this,"isDevEnv"),zi(this,"verifyUrlV3",F),zi(this,"storagePrefix",v),zi(this,"version",2),zi(this,"publicKey"),zi(this,"fetchPromise"),zi(this,"init",async()=>{var e;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,h.toMiliseconds)(null==(e=this.publicKey)?void 0:e.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),zi(this,"register",async e=>{if(!(0,u.BdH)()||this.isDevEnv)return;const t=window.location.origin,{id:i,decryptedId:s}=e,r=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${t}&id=${i}&decryptedId=${s}`;try{const e=(0,b.getDocument)(),t=this.startAbortTimer(5*h.ONE_SECOND),s=await new Promise((s,n)=>{const o=()=>{window.removeEventListener("message",c),e.body.removeChild(a),n("attestation aborted")};this.abortController.signal.addEventListener("abort",o);const a=e.createElement("iframe");a.src=r,a.style.display="none",a.addEventListener("error",o,{signal:this.abortController.signal});const c=r=>{if(r.data&&"string"==typeof r.data)try{const n=JSON.parse(r.data);if("verify_attestation"===n.type){if((0,l.Cq)(n.attestation).payload.id!==i)return;clearInterval(t),e.body.removeChild(a),this.abortController.signal.removeEventListener("abort",o),window.removeEventListener("message",c),s(null===n.attestation?"":n.attestation)}}catch(e){this.logger.warn(e)}};e.body.appendChild(a),window.addEventListener("message",c,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",s),s}catch(e){this.logger.warn(e)}return""}),zi(this,"resolve",async e=>{if(this.isDevEnv)return"";const{attestationId:t,hash:i,encryptedId:s}=e;if(""===t)return void this.logger.debug("resolve: attestationId is empty, skipping");if(t){if((0,l.Cq)(t).payload.id!==s)return;const e=await this.isValidJwtAttestation(t);if(e)return e.isVerified?e:void this.logger.warn("resolve: jwt attestation: origin url not verified")}if(!i)return;const r=this.getVerifyUrl(e?.verifyUrl);return this.fetchAttestation(i,r)}),zi(this,"fetchAttestation",async(e,t)=>{this.logger.debug(`resolving attestation: ${e} from url: ${t}`);const i=this.startAbortTimer(5*h.ONE_SECOND),s=await fetch(`${t}/attestation/${e}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(i),200===s.status?await s.json():void 0}),zi(this,"getVerifyUrl",e=>{let t=e||V;return K.includes(t)||(this.logger.info(`verify url: ${t}, not included in trusted list, assigning default: ${V}`),t=V),t}),zi(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const e=this.startAbortTimer(h.FIVE_SECONDS),t=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(e),await t.json()}catch(e){this.logger.warn(e)}}),zi(this,"persistPublicKey",async e=>{this.logger.debug("persisting public key to local storage",e),await this.store.setItem(this.storeKey,e),this.publicKey=e}),zi(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),zi(this,"isValidJwtAttestation",async e=>{const t=await this.getPublicKey();try{if(t)return this.validateAttestation(e,t)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}const i=await this.fetchAndPersistPublicKey();try{if(i)return this.validateAttestation(e,i)}catch(e){this.logger.error(e),this.logger.warn("error validating attestation")}}),zi(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),zi(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async e=>{const t=await this.fetchPublicKey();t&&(await this.persistPublicKey(t),e(t))});const e=await this.fetchPromise;return this.fetchPromise=void 0,e}),zi(this,"validateAttestation",(e,t)=>{const i=(0,u.U0i)(e,t.publicKey),s={hasExpired:(0,h.toMiliseconds)(i.exp)<Date.now(),payload:i};if(s.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:s.payload.origin,isScam:s.payload.isScam,isVerified:s.payload.isVerified}}),this.logger=(0,a.U5)(t,this.name),this.abortController=new AbortController,this.isDevEnv=(0,u.w8K)(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return(0,a.oI)(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),(0,h.toMiliseconds)(e))}}var Wi=Object.defineProperty,Vi=(e,t,i)=>((e,t,i)=>t in e?Wi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i)(e,"symbol"!=typeof t?t+"":t,i);class Fi extends c.GF{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,Vi(this,"context","echo"),Vi(this,"registerDeviceToken",async e=>{const{clientId:t,token:i,notificationType:s,enableEncrypted:r=!1}=e,n=`https://echo.walletconnect.com/${this.projectId}/clients`;await fetch(n,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:t,type:s,token:i,always_raw:r})})}),this.logger=(0,a.U5)(t,this.context)}}var Ki=Object.defineProperty,Gi=Object.getOwnPropertySymbols,Ji=Object.prototype.hasOwnProperty,Yi=Object.prototype.propertyIsEnumerable,Xi=(e,t,i)=>t in e?Ki(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,Qi=(e,t)=>{for(var i in t||(t={}))Ji.call(t,i)&&Xi(e,i,t[i]);if(Gi)for(var i of Gi(t))Yi.call(t,i)&&Xi(e,i,t[i]);return e},Zi=(e,t,i)=>Xi(e,"symbol"!=typeof t?t+"":t,i);class es extends c.$Q{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,Zi(this,"context","event-client"),Zi(this,"storagePrefix",v),Zi(this,"storageVersion",.1),Zi(this,"events",new Map),Zi(this,"shouldPersist",!1),Zi(this,"init",async()=>{if(!(0,u.w8K)())try{const e={eventId:(0,u.gZm)(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:(0,u.ojD)(this.core.relayer.protocol,this.core.relayer.version,k)}}};await this.sendEvent([e])}catch(e){this.logger.warn(e)}}),Zi(this,"createEvent",e=>{const{event:t="ERROR",type:i="",properties:{topic:s,trace:r}}=e,n=(0,u.gZm)(),o=this.core.projectId||"",a=Date.now(),c=Qi({eventId:n,timestamp:a,props:{event:t,type:i,properties:{topic:s,trace:r}},bundleId:o,domain:this.getAppDomain()},this.setMethods(n));return this.telemetryEnabled&&(this.events.set(n,c),this.shouldPersist=!0),c}),Zi(this,"getEvent",e=>{const{eventId:t,topic:i}=e;if(t)return this.events.get(t);const s=Array.from(this.events.values()).find(e=>e.props.properties.topic===i);return s?Qi(Qi({},s),this.setMethods(s.eventId)):void 0}),Zi(this,"deleteEvent",e=>{const{eventId:t}=e;this.events.delete(t),this.shouldPersist=!0}),Zi(this,"setEventListeners",()=>{this.core.heartbeat.on(n.li.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(e=>{(0,h.fromMiliseconds)(Date.now())-(0,h.fromMiliseconds)(e.timestamp)>86400&&(this.events.delete(e.eventId),this.shouldPersist=!0)})})}),Zi(this,"setMethods",e=>({addTrace:t=>this.addTrace(e,t),setError:t=>this.setError(e,t)})),Zi(this,"addTrace",(e,t)=>{const i=this.events.get(e);i&&(i.props.properties.trace.push(t),this.events.set(e,i),this.shouldPersist=!0)}),Zi(this,"setError",(e,t)=>{const i=this.events.get(e);i&&(i.props.type=t,i.timestamp=Date.now(),this.events.set(e,i),this.shouldPersist=!0)}),Zi(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),Zi(this,"restore",async()=>{try{const e=await this.core.storage.getItem(this.storageKey)||[];if(!e.length)return;e.forEach(e=>{this.events.set(e.eventId,Qi(Qi({},e),this.setMethods(e.eventId)))})}catch(e){this.logger.warn(e)}}),Zi(this,"submit",async()=>{if(!this.telemetryEnabled||0===this.events.size)return;const e=[];for(const[t,i]of this.events)i.props.type&&e.push(i);if(0!==e.length)try{if((await this.sendEvent(e)).ok)for(const t of e)this.events.delete(t.eventId),this.shouldPersist=!0}catch(e){this.logger.warn(e)}}),Zi(this,"sendEvent",async e=>{const t=this.getAppDomain()?"":"&sp=desktop";return await fetch(`https://pulse.walletconnect.org/batch?projectId=${this.core.projectId}&st=events_sdk&sv=js-${k}${t}`,{method:"POST",body:JSON.stringify(e)})}),Zi(this,"getAppDomain",()=>(0,u.lFF)().url),this.logger=(0,a.U5)(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var ts=Object.defineProperty,is=Object.getOwnPropertySymbols,ss=Object.prototype.hasOwnProperty,rs=Object.prototype.propertyIsEnumerable,ns=(e,t,i)=>t in e?ts(e,t,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[t]=i,os=(e,t)=>{for(var i in t||(t={}))ss.call(t,i)&&ns(e,i,t[i]);if(is)for(var i of is(t))rs.call(t,i)&&ns(e,i,t[i]);return e},as=(e,t,i)=>ns(e,"symbol"!=typeof t?t+"":t,i);class cs extends c.ZP{constructor(e){var t;super(e),as(this,"protocol","wc"),as(this,"version",2),as(this,"name",w),as(this,"relayUrl"),as(this,"projectId"),as(this,"customStoragePrefix"),as(this,"events",new s.EventEmitter),as(this,"logger"),as(this,"heartbeat"),as(this,"relayer"),as(this,"crypto"),as(this,"storage"),as(this,"history"),as(this,"expirer"),as(this,"pairing"),as(this,"verify"),as(this,"echoClient"),as(this,"linkModeSupportedApps"),as(this,"eventClient"),as(this,"initialized",!1),as(this,"logChunkController"),as(this,"on",(e,t)=>this.events.on(e,t)),as(this,"once",(e,t)=>this.events.once(e,t)),as(this,"off",(e,t)=>this.events.off(e,t)),as(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),as(this,"dispatchEnvelope",({topic:e,message:t,sessionExists:i})=>{if(!e||!t)return;const s={topic:e,message:t,publishedAt:Date.now(),transportType:R.link_mode};this.relayer.onLinkMessageEvent(s,{sessionExists:i})}),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||C,this.customStoragePrefix=null!=e&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=(0,a.iP)({level:"string"==typeof e?.logger&&e.logger?e.logger:"error",name:w}),{logger:r,chunkLoggerController:c}=(0,a.D5)({opts:i,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=c,null!=(t=this.logChunkController)&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var e,t;null!=(e=this.logChunkController)&&e.downloadLogsBlobInBrowser&&(null==(t=this.logChunkController)||t.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=(0,a.U5)(r,this.name),this.heartbeat=new n.VH,this.crypto=new St(this,this.logger,e?.keychain),this.history=new ji(this,this.logger),this.expirer=new $i(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new o.A(os(os({},I),e?.storageOptions)),this.relayer=new gi({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Mi(this,this.logger),this.verify=new Hi(this,this.logger,this.storage),this.echoClient=new Fi(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new es(this,this.logger,e?.telemetryEnabled)}static async init(e){const t=new cs(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",i),t}get context(){return(0,a.oI)(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return null==(e=this.logChunkController)?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(U,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(U)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}}const hs=cs},99013:(e,t,i)=>{i.d(t,{W:()=>_});var s=i(89168),r=i(39150),n=i(76020),o=i(95191),a=i(87841),c=i(84253),h=i(5813),d=i(11553),l=i(16279),u=i(89058),p=i(50731),f=i(14479),g=i(44637),m=i(16158),b=i(25422),y=i(42831),w=i(16652);const v={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[],user:void 0},I={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},E=(0,s.BX)({chains:(0,r.zC)(),activeCaipAddress:void 0,activeChain:void 0,activeCaipNetwork:void 0,noAdapters:!1,universalAdapter:{networkControllerClient:void 0,connectionControllerClient:void 0},isSwitchingNamespace:!1}),_={state:E,subscribe:e=>(0,s.B1)(E,()=>{e(E)}),subscribeKey:(e,t)=>(0,r.u$)(E,e,t),subscribeChainProp(e,t,i){let r;return(0,s.B1)(E.chains,()=>{const s=i||E.activeChain;if(s){const i=E.chains.get(s)?.[e];r!==i&&(r=i,t(i))}})},initialize(e,t,i){const{chainId:r,namespace:n}=d.i.getActiveNetworkProps(),o=t?.find(e=>e.id.toString()===r?.toString()),a=e.find(e=>e?.namespace===n)||e?.[0],c=new Set([...t?.map(e=>e.chainNamespace)??[]]);0!==e?.length&&a||(E.noAdapters=!0),E.noAdapters||(E.activeChain=a?.namespace,E.activeCaipNetwork=o,this.setChainNetworkData(a?.namespace,{caipNetwork:o}),E.activeChain&&b.z.set({activeChain:a?.namespace})),c.forEach(e=>{const r=t?.filter(t=>t.chainNamespace===e);_.state.chains.set(e,{namespace:e,networkState:(0,s.BX)({...I,caipNetwork:r?.[0]}),accountState:(0,s.BX)(v),caipNetworks:r??[],...i}),this.setRequestedCaipNetworks(r??[],e)})},removeAdapter(e){if(E.activeChain===e){const t=Array.from(E.chains.entries()).find(([t])=>t!==e);if(t){const e=t[1]?.caipNetworks?.[0];e&&this.setActiveCaipNetwork(e)}}E.chains.delete(e)},addAdapter(e,{networkControllerClient:t,connectionControllerClient:i},s){E.chains.set(e.namespace,{namespace:e.namespace,networkState:{...I,caipNetwork:s[0]},accountState:v,caipNetworks:s,connectionControllerClient:i,networkControllerClient:t}),this.setRequestedCaipNetworks(s?.filter(t=>t.chainNamespace===e.namespace)??[],e.namespace)},addNetwork(e){const t=E.chains.get(e.chainNamespace);if(t){const i=[...t.caipNetworks||[]];t.caipNetworks?.find(t=>t.id===e.id)||i.push(e),E.chains.set(e.chainNamespace,{...t,caipNetworks:i}),this.setRequestedCaipNetworks(i,e.chainNamespace)}},removeNetwork(e,t){const i=E.chains.get(e);if(i){const s=E.activeCaipNetwork?.id===t,r=[...i.caipNetworks?.filter(e=>e.id!==t)||[]];s&&i?.caipNetworks?.[0]&&this.setActiveCaipNetwork(i.caipNetworks[0]),E.chains.set(e,{...i,caipNetworks:r}),this.setRequestedCaipNetworks(r||[],e)}},setAdapterNetworkState(e,t){const i=E.chains.get(e);i&&(i.networkState={...i.networkState||I,...t},E.chains.set(e,i))},setChainAccountData(e,t,i=!0){if(!e)throw new Error("Chain is required to update chain account data");const s=E.chains.get(e);if(s){const i={...s.accountState||v,...t};E.chains.set(e,{...s,accountState:i}),1!==E.chains.size&&E.activeChain!==e||(t.caipAddress&&(E.activeCaipAddress=t.caipAddress),l.U.replaceState(i))}},setChainNetworkData(e,t){if(!e)return;const i=E.chains.get(e);if(i){const s={...i.networkState||I,...t};E.chains.set(e,{...i,networkState:s})}},setAccountProp(e,t,i,s=!0){this.setChainAccountData(i,{[e]:t},s),"status"===e&&"disconnected"===t&&i&&p.a.removeConnectorId(i)},setActiveNamespace(e){E.activeChain=e;const t=e?E.chains.get(e):void 0,i=t?.networkState?.caipNetwork;i?.id&&e&&(E.activeCaipAddress=t?.accountState?.caipAddress,E.activeCaipNetwork=i,this.setChainNetworkData(e,{caipNetwork:i}),d.i.setActiveCaipNetworkId(i?.caipNetworkId),b.z.set({activeChain:e,selectedNetworkId:i?.caipNetworkId}))},setActiveCaipNetwork(e){if(!e)return;E.activeChain!==e.chainNamespace&&this.setIsSwitchingNamespace(!0);const t=E.chains.get(e.chainNamespace);E.activeChain=e.chainNamespace,E.activeCaipNetwork=e,this.setChainNetworkData(e.chainNamespace,{caipNetwork:e}),E.activeCaipAddress=t?.accountState?.address?`${e.chainNamespace}:${e.id}:${t?.accountState?.address}`:void 0,this.setAccountProp("caipAddress",E.activeCaipAddress,e.chainNamespace),t&&l.U.replaceState(t.accountState),w.R.resetSend(),b.z.set({activeChain:E.activeChain,selectedNetworkId:E.activeCaipNetwork?.caipNetworkId}),d.i.setActiveCaipNetworkId(e.caipNetworkId),this.checkIfSupportedNetwork(e.chainNamespace)||!m.H.state.enableNetworkSwitch||m.H.state.allowUnsupportedChain||u.x.state.wcBasic||this.showUnsupportedChainUI()},addCaipNetwork(e){if(!e)return;const t=E.chains.get(e.chainNamespace);t&&t?.caipNetworks?.push(e)},async switchActiveNamespace(e){if(!e)return;const t=e!==_.state.activeChain,i=_.getNetworkData(e)?.caipNetwork,s=_.getCaipNetworkByNamespace(e,i?.id);t&&s&&await _.switchActiveNetwork(s)},async switchActiveNetwork(e){const t=_.state.chains.get(_.state.activeChain);!t?.caipNetworks?.some(e=>e.id===E.activeCaipNetwork?.id)&&y.I.goBack();const i=this.getNetworkControllerClient(e.chainNamespace);i&&(await i.switchCaipNetwork(e),f.E.sendEvent({type:"track",event:"SWITCH_NETWORK",properties:{network:e.caipNetworkId}}))},getNetworkControllerClient(e){const t=e||E.activeChain,i=E.chains.get(t);if(!i)throw new Error("Chain adapter not found");if(!i.networkControllerClient)throw new Error("NetworkController client not set");return i.networkControllerClient},getConnectionControllerClient(e){const t=e||E.activeChain;if(!t)throw new Error("Chain is required to get connection controller client");const i=E.chains.get(t);if(!i?.connectionControllerClient)throw new Error("ConnectionController client not set");return i.connectionControllerClient},getAccountProp(e,t){let i=E.activeChain;if(t&&(i=t),!i)return;const s=E.chains.get(i)?.accountState;return s?s[e]:void 0},getNetworkProp(e,t){const i=E.chains.get(t)?.networkState;if(i)return i[e]},getRequestedCaipNetworks(e){const t=E.chains.get(e),{approvedCaipNetworkIds:i=[],requestedCaipNetworks:s=[]}=t?.networkState||{};return h.w.sortRequestedNetworks(i,s)},getAllRequestedCaipNetworks(){const e=[];return E.chains.forEach(t=>{const i=this.getRequestedCaipNetworks(t.namespace);e.push(...i)}),e},setRequestedCaipNetworks(e,t){this.setAdapterNetworkState(t,{requestedCaipNetworks:e})},getAllApprovedCaipNetworkIds(){const e=[];return E.chains.forEach(t=>{const i=this.getApprovedCaipNetworkIds(t.namespace);e.push(...i)}),e},getActiveCaipNetwork:()=>E.activeCaipNetwork,getActiveCaipAddress:()=>E.activeCaipAddress,getApprovedCaipNetworkIds(e){const t=E.chains.get(e);return t?.networkState?.approvedCaipNetworkIds||[]},async setApprovedCaipNetworksData(e){const t=this.getNetworkControllerClient(),i=await(t?.getApprovedCaipNetworksData());this.setAdapterNetworkState(e,{approvedCaipNetworkIds:i?.approvedCaipNetworkIds,supportsAllNetworks:i?.supportsAllNetworks})},checkIfSupportedNetwork(e,t){const i=t||E.activeCaipNetwork,s=this.getRequestedCaipNetworks(e);return!s.length||s?.some(e=>e.id===i?.id)},checkIfSupportedChainId(e){if(!E.activeChain)return!0;const t=this.getRequestedCaipNetworks(E.activeChain);return t?.some(t=>t.id===e)},setSmartAccountEnabledNetworks(e,t){this.setAdapterNetworkState(t,{smartAccountEnabledNetworks:e})},checkIfSmartAccountEnabled(){const e=n.L.caipNetworkIdToNumber(E.activeCaipNetwork?.caipNetworkId),t=E.activeChain;if(!t||!e)return!1;const i=this.getNetworkProp("smartAccountEnabledNetworks",t);return Boolean(i?.includes(Number(e)))},getActiveNetworkTokenAddress(){const e=E.activeCaipNetwork?.chainNamespace||"eip155";return`${e}:${E.activeCaipNetwork?.id||1}:${c.oU.NATIVE_TOKEN_ADDRESS[e]}`},showUnsupportedChainUI(){g.W.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const e=E.activeCaipNetwork;return Boolean(e?.chainNamespace&&c.oU.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(e.chainNamespace))},resetNetwork(e){this.setAdapterNetworkState(e,{approvedCaipNetworkIds:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]})},resetAccount(e){const t=e;if(!t)throw new Error("Chain is required to set account prop");E.activeCaipAddress=void 0,this.setChainAccountData(t,{smartAccountDeployed:!1,currentTab:0,caipAddress:void 0,address:void 0,balance:void 0,balanceSymbol:void 0,profileName:void 0,profileImage:void 0,addressExplorerUrl:void 0,tokenBalance:[],connectedWalletInfo:void 0,preferredAccountType:void 0,socialProvider:void 0,socialWindow:void 0,farcasterUrl:void 0,allAccounts:[],user:void 0,status:"disconnected"}),p.a.removeConnectorId(t)},async disconnect(e){const t=(0,a.g)(e);try{w.R.resetSend();const i=await Promise.allSettled(t.map(async([e,t])=>{try{const{caipAddress:i}=this.getAccountData(e)||{};i&&t.connectionControllerClient?.disconnect&&await t.connectionControllerClient.disconnect(e),this.resetAccount(e),this.resetNetwork(e)}catch(t){throw new Error(`Failed to disconnect chain ${e}: ${t.message}`)}}));u.x.resetWcConnection();const s=i.filter(e=>"rejected"===e.status);if(s.length>0)throw new Error(s.map(e=>e.reason.message).join(", "));d.i.deleteConnectedSocialProvider(),e?p.a.removeConnectorId(e):p.a.resetConnectorIds(),f.E.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:e||"all"}})}catch(e){console.error(e.message||"Failed to disconnect chains"),f.E.sendEvent({type:"track",event:"DISCONNECT_ERROR",properties:{message:e.message||"Failed to disconnect chains"}})}},setIsSwitchingNamespace(e){E.isSwitchingNamespace=e},getFirstCaipNetworkSupportsAuthConnector(){const e=[];let t;if(E.chains.forEach(t=>{o.o.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(e=>e===t.namespace)&&t.namespace&&e.push(t.namespace)}),e.length>0){const i=e[0];return t=i?E.chains.get(i)?.caipNetworks?.[0]:void 0,t}},getAccountData:e=>e?_.state.chains.get(e)?.accountState:l.U.state,getNetworkData(e){const t=e||E.activeChain;if(t)return _.state.chains.get(t)?.networkState},getCaipNetworkByNamespace(e,t){if(!e)return;const i=_.state.chains.get(e),s=i?.caipNetworks?.find(e=>e.id===t);return s||i?.networkState?.caipNetwork||i?.caipNetworks?.[0]},getRequestedCaipNetworkIds(){const e=p.a.state.filterByNamespace;return(e?[E.chains.get(e)]:Array.from(E.chains.values())).flatMap(e=>e?.caipNetworks||[]).map(e=>e.caipNetworkId)}}},99057:(e,t,i)=>{i(70255),i(64264),i(93786),i(14350),i(50046),i(48526).hp,Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable,Object.defineProperty,Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperty,Object.defineProperties,Object.getOwnPropertyDescriptors,Object.getOwnPropertySymbols,Object.prototype.hasOwnProperty,Object.prototype.propertyIsEnumerable},99499:(e,t,i)=>{var s=t;s.utils=i(70461),s.common=i(32191),s.sha=i(75746),s.ripemd=i(74169),s.hmac=i(11825),s.sha1=s.sha.sha1,s.sha256=s.sha.sha256,s.sha224=s.sha.sha224,s.sha384=s.sha.sha384,s.sha512=s.sha.sha512,s.ripemd160=s.ripemd.ripemd160}};
|