1/*! For license information please see 2415.dcdabf21.chunk.js.LICENSE.txt */ 2(self.webpackChunkico_react=self.webpackChunkico_react||[]).push([[2415],{2641:(e,t,n)=>{"use strict";n.d(t,{b:()=>a});var i=n(24107),s=n(50390),r=n(47482),o=n(46443);const a={getConnectionStatus(e,t){const n=r.a.state.activeConnectorIds[t],i=s.x.getConnections(t);if(Boolean(n)&&e.connectorId===n)return"connected";return i.some(t=>t.connectorId.toLowerCase()===e.connectorId.toLowerCase())?"active":"disconnected"},excludeConnectorAddressFromConnections(e){let{connections:t,connectorId:n,addresses:s}=e;return t.map(e=>{if(!!n&&e.connectorId.toLowerCase()===n.toLowerCase()&&s){const t=e.accounts.filter(e=>!s.some(t=>t.toLowerCase()===e.address.toLowerCase()));return(0,i.A)((0,i.A)({},e),{},{accounts:t})}return e})},excludeExistingConnections(e,t){const n=new Set(e);return t.filter(e=>!n.has(e.connectorId))},getConnectionsByConnectorId:(e,t)=>e.filter(e=>e.connectorId.toLowerCase()===t.toLowerCase()),getConnectionsData(e){var t,n;const i=Boolean(null===(t=o.H.state.remoteFeatures)||void 0===t?void 0:t.multiWallet),c=r.a.state.activeConnectorIds[e],l=s.x.getConnections(e),d=(null!==(n=s.x.state.recentConnections.get(e))&&void 0!==n?n:[]).filter(e=>r.a.getConnectorById(e.connectorId)),h=a.excludeExistingConnections([...l.map(e=>e.connectorId),...c?[c]:[]],d);return i?{connections:l,recentConnections:h}:{connections:l.filter(e=>e.connectorId.toLowerCase()===(null===c||void 0===c?void 0:c.toLowerCase())),recentConnections:[]}}}},4791:(e,t,n)=>{"use strict";n.d(t,{h:()=>l});var i=n(18539),s=n(35574),r=n(17555),o=n(46443);const a=(0,i.BX)({message:"",variant:"info",open:!1}),c={state:a,subscribeKey:(e,t)=>(0,s.u$)(a,e,t),open(e,t){const{debug:n}=o.H.state,{code:i,displayMessage:s,debugMessage:r}=e;s&&n&&(a.message=s,a.variant=t,a.open=!0),r&&console.error("function"===typeof r?r():r,i?{code:i}:void 0)},warn(e,t,n){a.open=!0,a.message=e,a.variant="warning",t&&console.warn(t,n)},close(){a.open=!1,a.message="",a.variant="info"}},l=(0,r.X)(c)},10232:(e,t,n)=>{"use strict";n.d(t,{W:()=>_});var i=n(24107),s=n(18539),r=n(35574),o=n(10394),a=n(84873),c=n(62951),l=n(64751),d=n(78256),h=n(78854),u=n(81828),p=n(17555),f=n(50390),g=n(47482),v=n(74520),m=n(23976),y=n(46443),w=n(50067),b=n(28956),E=n(26828),C=n(62463);const A={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,user:void 0,preferredAccountType:void 0},I={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},N=(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}),S={state:N,subscribe:e=>(0,s.B1)(N,()=>{e(N)}),subscribeKey:(e,t)=>(0,r.u$)(N,e,t),subscribeAccountStateProp(e,t,n){var i;const s=n||N.activeChain;return s?(0,r.u$)((null===(i=N.chains.get(s))||void 0===i?void 0:i.accountState)||{},e,t):()=>{}},subscribeChainProp(e,t,n){let i;return(0,s.B1)(N.chains,()=>{const s=n||N.activeChain;if(s){var r;const n=null===(r=N.chains.get(s))||void 0===r?void 0:r[e];i!==n&&(i=n,t(n))}})},initialize(e,t,n){var r;const{chainId:o,namespace:a}=u.i.getActiveNetworkProps(),c=null===t||void 0===t?void 0:t.find(e=>e.id.toString()===(null===o||void 0===o?void 0:o.toString())),l=e.find(e=>(null===e||void 0===e?void 0:e.namespace)===a)||(null===e||void 0===e?void 0:e[0]),d=e.map(e=>e.namespace).filter(e=>void 0!==e),h=y.H.state.enableEmbedded?new Set([...d]):new Set([...null!==(r=null===t||void 0===t?void 0:t.map(e=>e.chainNamespace))&&void 0!==r?r:[]]);0!==(null===e||void 0===e?void 0:e.length)&&l||(N.noAdapters=!0),N.noAdapters||(N.activeChain=null===l||void 0===l?void 0:l.namespace,N.activeCaipNetwork=c,_.setChainNetworkData(null===l||void 0===l?void 0:l.namespace,{caipNetwork:c}),N.activeChain&&w.z.set({activeChain:null===l||void 0===l?void 0:l.namespace})),h.forEach(e=>{const r=null===t||void 0===t?void 0:t.filter(t=>t.chainNamespace===e),o=u.i.getPreferredAccountTypes()||{},a=(0,i.A)((0,i.A)({},y.H.state.defaultAccountTypes),o);_.state.chains.set(e,(0,i.A)({namespace:e,networkState:(0,s.BX)((0,i.A)((0,i.A)({},I),{},{caipNetwork:null===r||void 0===r?void 0:r[0]})),accountState:(0,s.BX)((0,i.A)((0,i.A)({},A),{},{preferredAccountType:a[e]})),caipNetworks:null!==r&&void 0!==r?r:[]},n)),_.setRequestedCaipNetworks(null!==r&&void 0!==r?r:[],e)})},removeAdapter(e){if(N.activeChain===e){const n=Array.from(N.chains.entries()).find(t=>{let[n]=t;return n!==e});if(n){var t;const e=null===(t=n[1])||void 0===t||null===(t=t.caipNetworks)||void 0===t?void 0:t[0];e&&_.setActiveCaipNetwork(e)}}N.chains.delete(e)},addAdapter(e,t,n){var s;let{networkControllerClient:r,connectionControllerClient:o}=t;if(!e.namespace)throw new Error("ChainController:addAdapter - adapter must have a namespace");N.chains.set(e.namespace,{namespace:e.namespace,networkState:(0,i.A)((0,i.A)({},I),{},{caipNetwork:n[0]}),accountState:(0,i.A)({},A),caipNetworks:n,connectionControllerClient:o,networkControllerClient:r}),_.setRequestedCaipNetworks(null!==(s=null===n||void 0===n?void 0:n.filter(t=>t.chainNamespace===e.namespace))&&void 0!==s?s:[],e.namespace)},addNetwork(e){const t=N.chains.get(e.chainNamespace);if(t){var n;const s=[...t.caipNetworks||[]];null!==(n=t.caipNetworks)&&void 0!==n&&n.find(t=>
2t.id===e.id)||s.push(e),N.chains.set(e.chainNamespace,(0,i.A)((0,i.A)({},t),{},{caipNetworks:s})),_.setRequestedCaipNetworks(s,e.chainNamespace),g.a.filterByNamespace(e.chainNamespace,!0)}},removeNetwork(e,t){const n=N.chains.get(e);if(n){var s,r,o;const a=(null===(s=N.activeCaipNetwork)||void 0===s?void 0:s.id)===t,c=[...(null===(r=n.caipNetworks)||void 0===r?void 0:r.filter(e=>e.id!==t))||[]];a&&null!==n&&void 0!==n&&null!==(o=n.caipNetworks)&&void 0!==o&&o[0]&&_.setActiveCaipNetwork(n.caipNetworks[0]),N.chains.set(e,(0,i.A)((0,i.A)({},n),{},{caipNetworks:c})),_.setRequestedCaipNetworks(c||[],e),0===c.length&&g.a.filterByNamespace(e,!1)}},setAdapterNetworkState(e,t){const n=N.chains.get(e);n&&(n.networkState=(0,i.A)((0,i.A)({},n.networkState||I),t),N.chains.set(e,n))},setChainAccountData(e,t){if(!e)throw new Error("Chain is required to update chain account data");const n=N.chains.get(e);if(n){const s=(0,i.A)((0,i.A)({},n.accountState||A),t);N.chains.set(e,(0,i.A)((0,i.A)({},n),{},{accountState:s})),1!==N.chains.size&&N.activeChain!==e||t.caipAddress&&(N.activeCaipAddress=t.caipAddress)}},setChainNetworkData(e,t){if(!e)return;const n=N.chains.get(e);if(n){const s=(0,i.A)((0,i.A)({},n.networkState||I),t);N.chains.set(e,(0,i.A)((0,i.A)({},n),{},{networkState:s}))}},setAccountProp(e,t,n){let i=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];_.setChainAccountData(n,{[e]:t},i)},setActiveNamespace(e){var t;N.activeChain=e;const n=e?N.chains.get(e):void 0,i=null===n||void 0===n||null===(t=n.networkState)||void 0===t?void 0:t.caipNetwork;var s;null!==i&&void 0!==i&&i.id&&e&&(N.activeCaipAddress=null===n||void 0===n||null===(s=n.accountState)||void 0===s?void 0:s.caipAddress,N.activeCaipNetwork=i,_.setChainNetworkData(e,{caipNetwork:i}),u.i.setActiveCaipNetworkId(null===i||void 0===i?void 0:i.caipNetworkId),w.z.set({activeChain:e,selectedNetworkId:null===i||void 0===i?void 0:i.caipNetworkId}))},setActiveCaipNetwork(e){var t,n;if(!e)return;const i=N.activeChain===e.chainNamespace;i||_.setIsSwitchingNamespace(!0);const s=N.chains.get(e.chainNamespace);N.activeChain=e.chainNamespace,N.activeCaipNetwork=e,_.setChainNetworkData(e.chainNamespace,{caipNetwork:e});let r=null===s||void 0===s||null===(t=s.accountState)||void 0===t?void 0:t.address;if(r)N.activeCaipAddress="".concat(e.chainNamespace,":").concat(e.id,":").concat(r);else if(i&&N.activeCaipAddress){const{address:t}=c.C.parseCaipAddress(N.activeCaipAddress);r=t,N.activeCaipAddress="".concat(e.caipNetworkId,":").concat(r)}else N.activeCaipAddress=void 0;_.setChainAccountData(e.chainNamespace,{address:r,caipAddress:N.activeCaipAddress}),E.R.resetSend(),w.z.set({activeChain:N.activeChain,selectedNetworkId:null===(n=N.activeCaipNetwork)||void 0===n?void 0:n.caipNetworkId}),u.i.setActiveCaipNetworkId(e.caipNetworkId);_.checkIfSupportedNetwork(e.chainNamespace)||!y.H.state.enableNetworkSwitch||y.H.state.allowUnsupportedChain||f.x.state.wcBasic||_.showUnsupportedChainUI()},addCaipNetwork(e){if(!e)return;const t=N.chains.get(e.chainNamespace);var n;t&&(null===t||void 0===t||null===(n=t.caipNetworks)||void 0===n||n.push(e))},async switchActiveNamespace(e){var t;if(!e)return;const n=e!==_.state.activeChain,i=null===(t=_.getNetworkData(e))||void 0===t?void 0:t.caipNetwork,s=_.getCaipNetworkByNamespace(e,null===i||void 0===i?void 0:i.id);n&&s&&await _.switchActiveNetwork(s)},async switchActiveNetwork(e){var t;let{throwOnFailure:n=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const i=_.state.activeChain;if(!i)throw new Error("ChainController:switchActiveNetwork - namespace is required");const s=_.state.chains.get(i),r=!(null!==s&&void 0!==s&&null!==(t=s.caipNetworks)&&void 0!==t&&t.some(e=>{var t;return e.id===(null===(t=N.activeCaipNetwork)||void 0===t?void 0:t.id)})),o=_.getNetworkControllerClient(e.chainNamespace);if(o){try{await o.switchCaipNetwork(e),r&&m.W.close()}catch(a){if(n)throw a;b.I.goBack()}v.E.sendEvent({type:"track",event:"SWITCH_NETWORK",properties:{network:e.caipNetworkId}})}},getNetworkControllerClient(e){const t=e||N.activeChain;if(!t)throw new Error("ChainController:getNetworkControllerClient - chain is required");const n=N.chains.get(t);if(!n)throw new Error("Chain adapter not found");if(!n.networkControllerClient)throw new Error("NetworkController client not set");return n.networkControllerClient},getConnectionControllerClient(e){const t=e||N.activeChain;if(!t)throw new Error("Chain is required to get connection controller client");const n=N.chains.get(t);if(null===n||void 0===n||!n.connectionControllerClient)throw new Error("ConnectionController client not set");return n.connectionControllerClient},getNetworkProp(e,t){var n;const i=null===(n=N.chains.get(t))||void 0===n?void 0:n.networkState;if(i)return i[e]},getRequestedCaipNetworks(e){const t=N.chains.get(e),{approvedCaipNetworkIds:n=[],requestedCaipNetworks:i=[]}=(null===t||void 0===t?void 0:t.networkState)||{};return h.w.sortRequestedNetworks(n,i).filter(e=>null===e||void 0===e?void 0:e.id)},getAllRequestedCaipNetworks(){const e=[];return N.chains.forEach(t=>{if(!t.namespace)throw new Error("ChainController:getAllRequestedCaipNetworks - chainAdapter must have a namespace");const n=_.getRequestedCaipNetworks(t.namespace);e.push(...n)}),e},setRequestedCaipNetworks(e,t){_.setAdapterNetworkState(t,{requestedCaipNetworks:e});const n=_.getAllRequestedCaipNetworks().map(e=>e.chainNamespace),i=Array.from(new Set(n));g.a.filterByNamespaces(i)},getAllApprovedCaipNetworkIds(){const e=[];return N.chains.forEach(t=>{if(!t.namespace)throw new Error("ChainController:getAllApprovedCaipNetworkIds - chainAdapter must have a namespace");const n=_.getApprovedCaipNetworkIds(t.namespace);e.push(...n)}),e},getActiveCaipNetwork(e){var t;return e?null===(t=N.chains.get(e))||void 0===t||null===(t=t.networkState)||void 0===t?void 0:t.caipNetwork:N.activeCaipNetwork},getActiveCaipAddress:()=>N.activeCaipAddress,getApprovedCaipNetworkIds(e){var t;const n=N.chains.get(e);return(null===n||void 0===n||null===(t=n.networkState)||void 0===t?void 0:t.approvedCaipNetworkIds)||[]},async setApprovedCaipNetworksData(e){const t=_.getNetworkControllerClient(),n=await(null===t||void 0===t?void 0:t.getApprovedCaipNetworksData());_.setAdapterNetworkState(e,{approvedCaipNetworkIds:null===n||void 0===n?void 0:n.approvedCaipNetworkIds,supportsAllNetworks:null===n||void 0===n?void 0:n.supportsAllNetworks})},checkIfSupportedNetwork(e,t){var n;const i=t||(null===(n=N.activeCaipNetwork)||void 0===n?void 0:n.caipNetworkId),s=_.getRequestedCaipNetworks(e);return!s.length||(null===s||void 0===s?void 0:s.some(e=>e.caipNetworkId===i))},checkIfSupportedChainId(e){if(!N.activeChain)return!0;const t=_.getRequestedCaipNetworks(N.activeChain);return null===t||void 0===t?void 0:t.some(t=>t.id===e)},setSmartAccountEnabledNetworks(e,t){_.setAdapterNetworkState(t,{smartAccountEnabledNetworks:e})},checkIfSmartAccountEnabled(){var e;const t=o.L.caipNetworkIdToNumber(null===(e=N.activeCaipNetwork)||void 0===e?void 0:e.caipNetworkId),n=N.activeChain;if(!n||!t)return!1;const i=_.getNetworkProp("smartAccountEnabledNetworks",n);return Boolean(null===i||void 0===i?void 0:i.includes(Number(t)))},showUnsupportedChainUI(){m.W.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const e=N.activeCaipNetwork;return Boolean((null===e||void 0===e?void 0:e.chainNamespace)&&d.oU.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(e.chainNamespace))},resetNetwork(e){_.setAdapterNetworkState(e,{approvedCaipNetworkIds:void 0,supportsAllNetworks:!0})},resetAccount(e){var t;const n=e;if(!n)throw new Error("Chain is required to set account prop");const i=null===(t=_.state.chains.get(n))||void 0===t||null===(t=t.accountState)||void 0===t?void 0:t.preferredAccountType,s=y.H.state.defaultAccountTypes[n];N.activeCaipAddress=void 0,_.setChainAccountData(n,{smartAccountDeployed:!1,currentTab:0,caipAddress:void 0,address:void 0,balance:void 0,balanceSymbol
2:void 0,profileName:void 0,profileImage:void 0,addressExplorerUrl:void 0,tokenBalance:[],connectedWalletInfo:void 0,preferredAccountType:s||i,socialProvider:void 0,socialWindow:void 0,farcasterUrl:void 0,user:void 0,status:"disconnected"}),g.a.removeConnectorId(n)},setIsSwitchingNamespace(e){N.isSwitchingNamespace=e},getFirstCaipNetworkSupportsAuthConnector(){const e=[];let t;if(N.chains.forEach(t=>{a.o.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(e=>e===t.namespace)&&t.namespace&&e.push(t.namespace)}),e.length>0){var n;const i=e[0];return t=i?null===(n=N.chains.get(i))||void 0===n||null===(n=n.caipNetworks)||void 0===n?void 0:n[0]:void 0,t}},getAccountData(e){var t;const n=e||N.activeChain;if(n)return null===(t=_.state.chains.get(n))||void 0===t?void 0:t.accountState},getNetworkData(e){var t;const n=e||N.activeChain;if(n)return null===(t=_.state.chains.get(n))||void 0===t?void 0:t.networkState},getCaipNetworkByNamespace(e,t){var n,i,s;if(!e)return;const r=_.state.chains.get(e),o=null===r||void 0===r||null===(n=r.caipNetworks)||void 0===n?void 0:n.find(e=>e.id===t);return o||((null===r||void 0===r||null===(i=r.networkState)||void 0===i?void 0:i.caipNetwork)||(null===r||void 0===r||null===(s=r.caipNetworks)||void 0===s?void 0:s[0]))},getRequestedCaipNetworkIds(){const e=g.a.state.filterByNamespace;return(e?[N.chains.get(e)]:Array.from(N.chains.values())).flatMap(e=>(null===e||void 0===e?void 0:e.caipNetworks)||[]).map(e=>e.caipNetworkId)},getCaipNetworks:e=>e?_.getRequestedCaipNetworks(e):_.getAllRequestedCaipNetworks(),getCaipNetworkById:(e,t)=>S.getCaipNetworks(t).find(t=>t.id.toString()===e.toString()||t.caipNetworkId.toString()===e.toString()),setLastConnectedSIWECaipNetwork(e){N.lastConnectedSIWECaipNetwork=e},getLastConnectedSIWECaipNetwork:()=>N.lastConnectedSIWECaipNetwork,async fetchTokenBalance(e){var t,n;const i=_.getAccountData();if(!i)return[];const s=null===(t=_.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId,r=null===(n=_.state.activeCaipNetwork)||void 0===n?void 0:n.chainNamespace,o=_.state.activeCaipAddress,a=o?h.w.getPlainAddress(o):void 0;if(_.setAccountProp("balanceLoading",!0,r),i.lastRetry&&!h.w.isAllowedRetry(i.lastRetry,30*d.oU.ONE_SEC_MS))return _.setAccountProp("balanceLoading",!1,r),[];try{if(a&&s&&r){const e=await l.Z.getMyTokensWithBalance();return _.setAccountProp("tokenBalance",e,r),_.setAccountProp("lastRetry",void 0,r),_.setAccountProp("balanceLoading",!1,r),e}}catch(c){_.setAccountProp("lastRetry",Date.now(),r),null===e||void 0===e||e(c),C.P.showError("Token Balance Unavailable")}finally{_.setAccountProp("balanceLoading",!1,r)}return[]},isCaipNetworkDisabled(e){var t;const n=e.chainNamespace,i=Boolean(null===(t=_.getAccountData(n))||void 0===t?void 0:t.caipAddress),s=_.getAllApprovedCaipNetworkIds(),r=!1!==_.getNetworkProp("supportsAllNetworks",n),o=g.a.getConnectorId(n),c=g.a.getAuthConnector(),l=o===a.o.CONNECTOR_ID.AUTH&&c;return!(!i||r||l)&&!(null!==s&&void 0!==s&&s.includes(e.caipNetworkId))}},_=(0,p.X)(S)},10394:(e,t,n)=>{"use strict";n.d(t,{L:()=>s,P:()=>r});var i=n(84873);const s={caipNetworkIdToNumber:e=>e?Number(e.split(":")[1]):void 0,parseEvmChainId(e){return"string"===typeof e?this.caipNetworkIdToNumber(e):e},getNetworksByNamespace:(e,t)=>(null===e||void 0===e?void 0:e.filter(e=>e.chainNamespace===t))||[],getFirstNetworkByNamespace(e,t){return this.getNetworksByNamespace(e,t)[0]},getNetworkNameByCaipNetworkId(e,t){var n;if(!t)return;const s=e.find(e=>e.caipNetworkId===t);if(s)return s.name;const[r]=t.split(":");return(null===(n=i.o.CHAIN_NAME_MAP)||void 0===n?void 0:n[r])||void 0}},r=["eip155","solana","polkadot","bip122","cosmos","sui","stacks"]},11217:(e,t,n)=>{"use strict";n.d(t,{o:()=>i});const i={ACCOUNT_TABS:[{label:"Tokens"},{label:"Activity"}],SECURE_SITE_ORIGIN:("undefined"!==typeof process?{NODE_ENV:"production",PUBLIC_URL:".",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.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},VIEWS_WITH_LEGAL_FOOTER:["Connect","ConnectWallets","OnRampTokenSelect","OnRampFiatSelect","OnRampProviders"],VIEWS_WITH_DEFAULT_FOOTER:["Networks"]}},12491:function(e){e.exports=function(){"use strict";return function(e,t,n){n.updateLocale=function(e,t){var i=n.Ls[e];
2if(i)return(t?Object.keys(t):[]).forEach(function(e){i[e]=t[e]}),i}}}()},13033:(e,t,n)=>{"use strict";n.d(t,{N:()=>b});var i=n(24107),s=n(18539),r=n(35574),o=n(84873),a=n(28577),c=n(78854),l=n(70689),d=n(84470),h=n(81828),u=n(44777),p=n(10232),f=n(47482),g=n(74520),v=n(46443);const m=c.w.getApiUrl(),y=new l.Z({baseUrl:m,clientId:null}),w=(0,s.BX)({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],filteredWallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1,explorerWallets:[],explorerFilteredWallets:[]}),b={state:w,subscribeKey:(e,t)=>(0,r.u$)(w,e,t),_getSdkProperties(){const{projectId:e,sdkType:t,sdkVersion:n}=v.H.state;return{projectId:e,st:t||"appkit",sv:n||"html-wagmi-4.2.2"}},_filterOutExtensions:e=>v.H.state.isUniversalProvider?e.filter(e=>Boolean(e.mobile_link||e.desktop_link||e.webapp_link)):e,async _fetchWalletImage(e){const t="".concat(y.baseUrl,"/getWalletImage/").concat(e),n=await y.getBlob({path:t,params:b._getSdkProperties()});u.j.setWalletImage(e,URL.createObjectURL(n))},async _fetchNetworkImage(e){const t="".concat(y.baseUrl,"/public/getAssetImage/").concat(e),n=await y.getBlob({path:t,params:b._getSdkProperties()});u.j.setNetworkImage(e,URL.createObjectURL(n))},async _fetchConnectorImage(e){const t="".concat(y.baseUrl,"/public/getAssetImage/").concat(e),n=await y.getBlob({path:t,params:b._getSdkProperties()});u.j.setConnectorImage(e,URL.createObjectURL(n))},async _fetchCurrencyImage(e){const t="".concat(y.baseUrl,"/public/getCurrencyImage/").concat(e),n=await y.getBlob({path:t,params:b._getSdkProperties()});u.j.setCurrencyImage(e,URL.createObjectURL(n))},async _fetchTokenImage(e){const t="".concat(y.baseUrl,"/public/getTokenImage/").concat(e),n=await y.getBlob({path:t,params:b._getSdkProperties()});u.j.setTokenImage(e,URL.createObjectURL(n))},_filterWalletsByPlatform(e){const t=e.length,n=c.w.isMobile()?null===e||void 0===e?void 0:e.filter(e=>{if(e.mobile_link||e.webapp_link)return!0;return Object.values(d.O).map(e=>e.id).includes(e.id)}):e;return{filteredWallets:n,mobileFilteredOutWalletsLength:t-n.length}},fetchProjectConfig:async()=>(await y.get({path:"/appkit/v1/config",params:b._getSdkProperties()})).features,async fetchAllowedOrigins(){try{const{allowedOrigins:e}=await y.get({path:"/projects/v1/origins",params:b._getSdkProperties()});return e}catch(e){if(e instanceof Error&&e.cause instanceof Response){const t=e.cause.status;if(t===o.o.HTTP_STATUS_CODES.TOO_MANY_REQUESTS)throw new Error("RATE_LIMITED",{cause:e});if(t>=o.o.HTTP_STATUS_CODES.SERVER_ERROR&&t<600)throw new Error("SERVER_ERROR",{cause:e});return[]}return[]}},async fetchNetworkImages(){const e=p.W.getAllRequestedCaipNetworks(),t=null===e||void 0===e?void 0:e.map(e=>{let{assets:t}=e;return null===t||void 0===t?void 0:t.imageId}).filter(Boolean).filter(e=>!a.$.getNetworkImageById(e));t&&await Promise.allSettled(t.map(e=>b._fetchNetworkImage(e)))},async fetchConnectorImages(){const{connectors:e}=f.a.state,t=e.map(e=>{let{imageId:t}=e;return t}).filter(Boolean);await Promise.allSettled(t.map(e=>b._fetchConnectorImage(e)))},async fetchCurrencyImages(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];await Promise.allSettled(e.map(e=>b._fetchCurrencyImage(e)))},async fetchTokenImages(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];await Promise.allSettled(e.map(e=>b._fetchTokenImage(e)))},async fetchWallets(e){var t,n;const s=null!==(t=e.exclude)&&void 0!==t?t:[];b._getSdkProperties().sv.startsWith("html-core-")&&s.push(...Object.values(d.O).map(e=>e.id));const r=await y.get({path:"/getWallets",params:(0,i.A)((0,i.A)((0,i.A)({},b._getSdkProperties()),e),{},{page:String(e.page),entries:String(e.entries),include:null===(n=e.include)||void 0===n?void 0:n.join(","),exclude:s.join(",")})}),{filteredWallets:o,mobileFilteredOutWalletsLength:a}=b._filterWalletsByPlatform(null===r||void 0===r?void 0:r.data);return{data:o||[],count:null===r||void 0===r?void 0:r.count,mobileFilteredOutWalletsLength:a}},async prefetchWalletRanks(){const e=f.a.state.connectors;if(null===e||void 0===e||!e.length)return;const t={page:1,entries:20,badge:"certified"};if(t.names=e.map(e=>e.name).join(","),p.W.state.activeChain===o.o.CHAIN.EVM){const n=[...e.flatMap(e=>{var t;return(null===(t=e.connectors)||void 0===t?void 0:t.map(e=>{var t;return null===(t=e.info)||void 0===t?void 0:t.rdns}))||[]}),...e.map(e=>{var t;return null===(t=e.info)||void 0===t?void 0:t.rdns})].filter(e=>"string"===typeof e&&e.length>0);n.length&&(t.rdns=n.join(","))}const{data:n}=await b.fetchWallets(t);w.explorerWallets=n;const i=p.W.getRequestedCaipNetworkIds().join(",");w.explorerFilteredWallets=n.filter(e=>{var t;return null===(t=e.chains)||void 0===t?void 0:t.some(e=>i.includes(e))})},async fetchFeaturedWallets(){const{featuredWalletIds:e}=v.H.state;if(null!==e&&void 0!==e&&e.length){var t;const n=(0,i.A)((0,i.A)({},b._getSdkProperties()),{},{page:1,entries:null!==(t=null===e||void 0===e?void 0:e.length)&&void 0!==t?t:4,include:e}),{data:s}=await b.fetchWallets(n),r=[...s].sort((t,n)=>e.indexOf(t.id)-e.indexOf(n.id)),o=r.map(e=>
2e.image_id).filter(Boolean);await Promise.allSettled(o.map(e=>b._fetchWalletImage(e))),w.featured=r,w.allFeatured=r}},async fetchRecommendedWallets(){try{w.isFetchingRecommendedWallets=!0;const{includeWalletIds:e,excludeWalletIds:t,featuredWalletIds:n}=v.H.state,i=[...null!==t&&void 0!==t?t:[],...null!==n&&void 0!==n?n:[]].filter(Boolean),s={page:1,entries:4,include:e,exclude:i,chains:p.W.getRequestedCaipNetworkIds().join(",")},{data:r,count:o}=await b.fetchWallets(s),a=h.i.getRecentWallets(),c=r.map(e=>e.image_id).filter(Boolean),l=a.map(e=>e.image_id).filter(Boolean);await Promise.allSettled([...c,...l].map(e=>b._fetchWalletImage(e))),w.recommended=r,w.allRecommended=r,w.count=null!==o&&void 0!==o?o:0}catch(e){}finally{w.isFetchingRecommendedWallets=!1}},async fetchWalletsByPage(e){var t;let{page:n}=e;const{includeWalletIds:i,excludeWalletIds:s,featuredWalletIds:r}=v.H.state,o=p.W.getRequestedCaipNetworkIds().join(","),a={page:n,entries:40,include:i,exclude:[...w.recommended.map(e=>{let{id:t}=e;return t}),...null!==s&&void 0!==s?s:[],...null!==r&&void 0!==r?r:[]].filter(Boolean),chains:o},{data:l,count:d,mobileFilteredOutWalletsLength:h}=await b.fetchWallets(a);w.mobileFilteredOutWalletsLength=h+(null!==(t=w.mobileFilteredOutWalletsLength)&&void 0!==t?t:0);const u=l.slice(0,20).map(e=>e.image_id).filter(Boolean);await Promise.allSettled(u.map(e=>b._fetchWalletImage(e))),w.wallets=c.w.uniqueBy([...w.wallets,...b._filterOutExtensions(l)],"id").filter(e=>{var t;return null===(t=e.chains)||void 0===t?void 0:t.some(e=>o.includes(e))}),w.count=d>w.count?d:w.count,w.page=n},async initializeExcludedWallets(e){let{ids:t}=e;const n={page:1,entries:t.length,include:t},{data:i}=await b.fetchWallets(n);i&&i.forEach(e=>{w.excludedWallets.push({rdns:e.rdns,name:e.name})})},async searchWallet(e){let{search:t,badge:n}=e;const{includeWalletIds:i,excludeWalletIds:s}=v.H.state,r=p.W.getRequestedCaipNetworkIds().join(",");w.search=[];const o={page:1,entries:100,search:null===t||void 0===t?void 0:t.trim(),badge_type:n,include:i,exclude:s,chains:r},{data:a}=await b.fetchWallets(o);g.E.sendEvent({type:"track",event:"SEARCH_WALLET",properties:{badge:null!==n&&void 0!==n?n:"",search:null!==t&&void 0!==t?t:""}});const l=a.map(e=>e.image_id).filter(Boolean);await Promise.allSettled([...l.map(e=>b._fetchWalletImage(e)),c.w.wait(300)]),w.search=b._filterOutExtensions(a)},initPromise(e,t){const n=w.promises[e];return n||(w.promises[e]=t())},prefetch(){let{fetchConnectorImages:e=!0,fetchFeaturedWallets:t=!0,fetchRecommendedWallets:n=!0,fetchNetworkImages:i=!0,fetchWalletRanks:s=!0}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const r=[e&&b.initPromise("connectorImages",b.fetchConnectorImages),t&&b.initPromise("featuredWallets",b.fetchFeaturedWallets),n&&b.initPromise("recommendedWallets",b.fetchRecommendedWallets),i&&b.initPromise("networkImages",b.fetchNetworkImages),s&&b.initPromise("walletRanks",b.prefetchWalletRanks)].filter(Boolean);return Promise.allSettled(r)},prefetchAnalyticsConfig(){var e;null!==(e=v.H.state.features)&&void 0!==e&&e.analytics&&b.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:e}=await y.get({path:"/getAnalyticsConfig",params:b._getSdkProperties()});v.H.setFeatures({analytics:e})}catch(e){v.H.setFeatures({analytics:!1})}},filterByNamespaces(e){if(null===e||void 0===e||!e.length)return w.featured=w.allFeatured,void(w.recommended=w.allRecommended);const t=p.W.getRequestedCaipNetworkIds().join(",");w.featured=w.allFeatured.filter(e=>{var n;return null===(n=e.chains)||void 0===n?void 0:n.some(e=>t.includes(e))}),w.recommended=w.allRecommended.filter(e=>{var n;return null===(n=e.chains)||void 0===n?void 0:n.some(e=>t.includes(e))}),w.filteredWallets=w.wallets.filter(e=>{var n;return null===(n=e.chains)||void 0===n?void 0:n.some(e=>t.includes(e))})},clearFilterByNamespaces(){w.filteredWallets=[]},setFilterByNamespace(e){if(!e)return w.featured=w.allFeatured,void(w.recommended=w.allRecommended);const t=p.W.getRequestedCaipNetworkIds().join(",");w.featured=w.allFeatured.filter(e=>{var n;return null===(n=e.chains)||void 0===n?void 0:n.some(e=>t.includes(e))}),w.recommended=w.allRecommended.filter(e=>{var n;return null===(n=e.chains)||void 0===n?void 0:n.some(e=>t.includes(e))}),w.filteredWallets=w.wallets.filter(e=>{var n;return null===(n=e.chains)||void 0===n?void 0:n.some(e=>t.includes(e))})}}},14640:(e,t,n)=>{"use strict";function i(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}n.d(t,{A:()=>i})}
2,16788:(e,t,n)=>{"use strict";n.d(t,{W:()=>d});var i=n(24107),s=n(18539),r=n(29025),o=n(17555),a=n(47482);const c=(0,s.BX)({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),l={state:c,subscribe:e=>(0,s.B1)(c,()=>e(c)),setThemeMode(e){c.themeMode=e;try{const t=a.a.getAuthConnector();if(t){const n=l.getSnapshot().themeVariables;t.provider.syncTheme({themeMode:e,themeVariables:n,w3mThemeVariables:(0,r.o)(n,e)})}}catch(t){console.info("Unable to sync theme to auth connector")}},setThemeVariables(e){c.themeVariables=(0,i.A)((0,i.A)({},c.themeVariables),e);try{const e=a.a.getAuthConnector();if(e){const t=l.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:t,w3mThemeVariables:(0,r.o)(c.themeVariables,c.themeMode)})}}catch(t){console.info("Unable to sync theme to auth connector")}},getSnapshot:()=>(0,s.P9)(c)},d=(0,o.X)(l)},17555:(e,t,n)=>{"use strict";n.d(t,{A:()=>p,X:()=>g});var i=n(24107),s=n(18539),r=n(35574),o=n(78854),a=n(70689),c=n(46443);const l=Object.freeze({enabled:!0,events:[]}),d=new a.Z({baseUrl:o.w.getAnalyticsUrl(),clientId:null}),h=(0,s.BX)((0,i.A)({},l)),u={state:h,subscribeKey:(e,t)=>(0,r.u$)(h,e,t),async sendError(e,t){if(!h.enabled)return;const n=Date.now();if(h.events.filter(e=>{const t=new Date(e.properties.timestamp||"").getTime();return n-t<6e4}).length>=5)return;const i={type:"error",event:t,properties:{errorType:e.name,errorMessage:e.message,stackTrace:e.stack,timestamp:(new Date).toISOString()}};h.events.push(i);try{if("undefined"===typeof window)return;const{projectId:n,sdkType:i,sdkVersion:s}=c.H.state;await d.post({path:"/e",params:{projectId:n,st:i,sv:s||"html-wagmi-4.2.2"},body:{eventId:o.w.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:(new Date).toISOString(),props:{type:"error",event:t,errorType:e.name,errorMessage:e.message,stackTrace:e.stack}}})}catch(s){}},enable(){h.enabled=!0},disable(){h.enabled=!1},clearEvents(){h.events=[]}};
2class p extends Error{constructor(e,t,n){super(e),this.originalName="AppKitError",this.name="AppKitError",this.category=t,this.originalError=n,n&&n instanceof Error&&(this.originalName=n.name),Object.setPrototypeOf(this,p.prototype);let i=!1;if(n instanceof Error&&"string"===typeof n.stack&&n.stack){const e=n.stack,t=e.indexOf("\n");if(t>-1){const n=e.substring(t+1);this.stack="".concat(this.name,": ").concat(this.message,"\n").concat(n),i=!0}}i||(Error.captureStackTrace?Error.captureStackTrace(this,p):this.stack||(this.stack="".concat(this.name,": ").concat(this.message)))}}function f(e,t){let n="";try{n=e instanceof Error?e.message:"string"===typeof e?e:"object"===typeof e&&null!==e?0===Object.keys(e).length?"Unknown error":(null===e||void 0===e?void 0:e.message)||JSON.stringify(e):String(e)}catch(s){n="Unknown error",console.error("Error parsing error message",s)}const i=e instanceof p?e:new p(n,t,e);throw u.sendError(i,i.category),i}function g(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"INTERNAL_SDK_ERROR";const n={};return Object.keys(e).forEach(i=>{const s=e[i];if("function"===typeof s){let e=s;e="AsyncFunction"===s.constructor.name?async function(){try{return await s(...arguments)}catch(e){return f(e,t)}}:function(){try{return s(...arguments)}catch(e){return f(e,t)}},n[i]=e}else n[i]=s}),n}},18539:(e,t,n)=>{"use strict";n.d(t,{BX:()=>b,KR:()=>A,P9:()=>C,B1:()=>E,h2:()=>I});Symbol();const i=Symbol();const s=Object.getPrototypeOf,r=new WeakMap,o=e=>e&&(r.has(e)?r.get(e):s(e)===Object.prototype||s(e)===Array.prototype),a=function(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];r.set(e,t)},c=e=>"object"===typeof e&&null!==e,l=(e,t)=>{const n=u.get(e);if((null==n?void 0:n[0])===t)return n[1];const i=Array.isArray(e)?[]:Object.create(Object.getPrototypeOf(e));return a(i,!0),u.set(e,[t,i]),Reflect.ownKeys(e).forEach(t=>{if(Object.getOwnPropertyDescriptor(i,t))return;const n=Reflect.get(e,t),{enumerable:s}=Reflect.getOwnPropertyDescriptor(e,t),r={value:n,enumerable:s,configurable:!0};if(h.has(n))a(n,!1);else if(d.has(n)){const[e,t]=d.get(n);r.value=l(e,t())}Object.defineProperty(i,t,r)}),Object.preventExtensions(i)},d=new WeakMap,h=new WeakSet,u=new WeakMap,p=[1],f=new WeakMap;let g=Object.is,v=(e,t)=>new Proxy(e,t),m=e=>c(e)&&!h.has(e)&&(Array.isArray(e)||!(Symbol.iterator in e))&&!(e instanceof WeakMap)&&!(e instanceof WeakSet)&&!(e instanceof Error)&&!(e instanceof Number)&&!(e instanceof Date)&&!(e instanceof String)&&!(e instanceof RegExp)&&!(e instanceof ArrayBuffer)&&!(e instanceof Promise),y=l,w=(e,t,n,s)=>({deleteProperty(e,t){const i=Reflect.get(e,t);n(t);const r=Reflect.deleteProperty(e,t);return r&&s(["delete",[t],i]),r},set(r,a,l,h){const u=!e()&&Reflect.has(r,a),p=Reflect.get(r,a,h);if(u&&(g(p,l)||f.has(l)&&g(p,f.get(l))))return!0;var v;n(a),c(l)&&(l=o(v=l)&&v[i]||null||l);const y=!d.has(l)&&m(l)?b(l):l;return t(a,y),Reflect.set(r,a,y,h),s(["set",[a],l,p]),!0}});function b(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!c(e))throw new Error("object required");const t=f.get(e);if(t)return t;let n=p[0];const i=new Set,s=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:++p[0];n!==t&&(r=n=t,i.forEach(n=>n(e,t)))};let r=n;const o=e=>(t,n)=>{const i=[...t];i[1]=[e,...i[1]],s(i,n)},a=new Map;let l=!0;const u=w(()=>l,(e,t)=>{const n=!h.has(t)&&d.get(t);if(n){if(a.has(e))throw new Error("prop listener already exists");if(i.size){const t=n[2](o(e));a.set(e,[n,t])}else a.set(e,[n])}},e=>{var t;const n=a.get(e);n&&(a.delete(e),null==(t=n[1])||t.call(n))},s),g=v(e,u);f.set(e,g);const m=[e,function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:p[0];return r!==e&&(r=e,a.forEach(t=>{let[i]=t;const s=i[1](e);s>n&&(n=s)})),n},e=>{i.add(e),1===i.size&&a.forEach((e,t)=>{let[n,i]=e;if(i)throw new Error("remove already exists");const s=n[2](o(t));a.set(t,[n,s])});return()=>{i.delete(e),0===i.size&&a.forEach((e,t)=>{let[n,i]=e;i&&(i(),a.set(t,[n]))})}}];return d.set(g,m),Reflect.ownKeys(e).forEach(t=>{const n=Object.getOwnPropertyDescriptor(e,t);"value"in n&&n.writable&&(g[t]=e[t])}),l=!1,g}function E(e,t,n){const i=d.get(e);let s;i||console.warn("Please use proxy object");const r=[],o=i[2];let a=!1;const c=o(e=>
2{r.push(e),n?t(r.splice(0)):s||(s=Promise.resolve().then(()=>{s=void 0,a&&t(r.splice(0))}))});return a=!0,()=>{a=!1,c()}}function C(e){const t=d.get(e);t||console.warn("Please use proxy object");const[n,i]=t;return y(n,i())}function A(e){return h.add(e),e}function I(){return{proxyStateMap:d,refSet:h,snapCache:u,versionHolder:p,proxyCache:f}}},20140:function(e){e.exports=function(){"use strict";return{name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}}}()},23439:(e,t,n)=>{"use strict";const i=n(66601);e.exports=o;const s=function(){function e(e){return"undefined"!==typeof e&&e}try{return"undefined"!==typeof globalThis||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch(t){return e(self)||e(window)||e(this)||{}}}().console||{},r={mapHttpRequest:u,mapHttpResponse:u,wrapRequestSerializer:p,wrapResponseSerializer:p,wrapErrorSerializer:p,req:u,res:u,err:function(e){const t={type:e.constructor.name,msg:e.message,stack:e.stack};for(const n in e)void 0===t[n]&&(t[n]=e[n]);return t}};function o(e){(e=e||{}).browser=e.browser||{};const t=e.browser.transmit;if(t&&"function"!==typeof t.send)throw Error("pino: transmit option must have a send function");const n=e.browser.write||s;e.browser.write&&(e.browser.asObject=!0);const i=e.serializers||{},r=function(e,t){if(Array.isArray(e))return e.filter(function(e){return"!stdSerializers.err"!==e});return!0===e&&Object.keys(t)}(e.browser.serialize,i);let u=e.browser.serialize;Array.isArray(e.browser.serialize)&&e.browser.serialize.indexOf("!stdSerializers.err")>-1&&(u=!1);"function"===typeof n&&(n.error=n.fatal=n.warn=n.info=n.debug=n.trace=n),!1===e.enabled&&(e.level="silent");const p=e.level||"info",g=Object.create(n);g.log||(g.log=f),Object.defineProperty(g,"levelVal",{get:function(){return"silent"===this.level?1/0:this.levels.values[this.level]}}),Object.defineProperty(g,"level",{get:function(){return this._level},set:function(e){if("silent"!==e&&!this.levels.values[e])throw Error("unknown level "+e);this._level=e,a(v,g,"error","log"),a(v,g,"fatal","error"),a(v,g,"warn","error"),a(v,g,"info","log"),a(v,g,"debug","log"),a(v,g,"trace","log")}});const v={transmit:t,serialize:r,asObject:e.browser.asObject,levels:["error","fatal","warn","info","debug","trace"],timestamp:h(e)};return g.levels=o.levels,g.level=p,g.setMaxListeners=g.getMaxListeners=g.emit=g.addListener=g.on=g.prependListener=g.once=g.prependOnceListener=g.removeListener=g.removeAllListeners=g.listeners=g.listenerCount=g.eventNames=g.write=g.flush=f,g.serializers=i,g._serialize=r,g._stdErrSerialize=u,g.child=function(n,s){if(!n)throw new Error("missing bindings for child Pino");s=s||{}
2,r&&n.serializers&&(s.serializers=n.serializers);const o=s.serializers;if(r&&o){var a=Object.assign({},i,o),h=!0===e.browser.serialize?Object.keys(a):r;delete n.serializers,c([n],h,a,this._stdErrSerialize)}function u(e){this._childLevel=1+(0|e._childLevel),this.error=l(e,n,"error"),this.fatal=l(e,n,"fatal"),this.warn=l(e,n,"warn"),this.info=l(e,n,"info"),this.debug=l(e,n,"debug"),this.trace=l(e,n,"trace"),a&&(this.serializers=a,this._serialize=h),t&&(this._logEvent=d([].concat(e._logEvent.bindings,n)))}return u.prototype=this,new u(this)},t&&(g._logEvent=d()),g}function a(e,t,n,r){const a=Object.getPrototypeOf(t);t[n]=t.levelVal>t.levels.values[n]?f:a[n]?a[n]:s[n]||s[r]||f,function(e,t,n){if(!e.transmit&&t[n]===f)return;t[n]=(r=t[n],function(){const a=e.timestamp(),l=new Array(arguments.length),h=Object.getPrototypeOf&&Object.getPrototypeOf(this)===s?s:this;for(var u=0;u<l.length;u++)l[u]=arguments[u];if(e.serialize&&!e.asObject&&c(l,this._serialize,this.serializers,this._stdErrSerialize),e.asObject?r.call(h,function(e,t,n,s){e._serialize&&c(n,e._serialize,e.serializers,e._stdErrSerialize);const r=n.slice();let a=r[0];const l={};s&&(l.time=s),l.level=o.levels.values[t];let d=1+(0|e._childLevel);if(d<1&&(d=1),null!==a&&"object"===typeof a){for(;d--&&"object"===typeof r[0];)Object.assign(l,r.shift());a=r.length?i(r.shift(),r):void 0}else"string"===typeof a&&(a=i(r.shift(),r));return void 0!==a&&(l.msg=a),l}(this,n,l,a)):r.apply(h,l),e.transmit){const i=e.transmit.level||t.level,s=o.levels.values[i],r=o.levels.values[n];if(r<s)return;!function(e,t,n){const i=t.send,s=t.ts,r=t.methodLevel,o=t.methodValue,a=t.val,l=e._logEvent.bindings;c(n,e._serialize||Object.keys(e.serializers),e.serializers,void 0===e._stdErrSerialize||e._stdErrSerialize),e._logEvent.ts=s,e._logEvent.messages=n.filter(function(e){return-1===l.indexOf(e)}),e._logEvent.level.label=r,e._logEvent.level.value=o,i(r,e._logEvent,a),e._logEvent=d(l)}(this,{ts:a,methodLevel:n,methodValue:r,transmitLevel:i,transmitValue:o.levels.values[e.transmit.level||t.level],send:e.transmit.send,val:t.levelVal},l)}});var r}(e,t,n)}function c(e,t,n,i){for(const s in e)if(i&&e[s]instanceof Error)e[s]=o.stdSerializers.err(e[s]);else if("object"===typeof e[s]&&!Array.isArray(e[s]))for(const i in e[s])t&&t.indexOf(i)>-1&&i in n&&(e[s][i]=n[i](e[s][i]))}function l(e,t,n){return function(){const i=new Array(1+arguments.length);i[0]=t;for(var s=1;s<i.length;s++)i[s]=arguments[s-1];return e[n].apply(this,i)}}function d(e){return{ts:0,messages:[],bindings:e||[],level:{label:"",value:0}}}function h(e){return"function"===typeof e.timestamp?e.timestamp:!1===e.timestamp?g:v}function u(){return{}}function p(e){return e}function f(){}function g(){return!1}function v(){return Date.now()}o.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},o.stdSerializers=r,o.stdTimeFunctions=Object.assign({},{nullTime:g,epochTime:v,unixTime:function(){return Math.round(Date.now()/1e3)},isoTime:function(){return new Date(Date.now()).toISOString()}})},23579:(e,t,n)=>{"use strict";n.d(t,{L:()=>r});var i=n(84873),s=n(27142);const r={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",[s.o.METMASK_CONNECTOR_NAME]:"c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96",[s.o.TRUST_CONNECTOR_NAME]:"4622a2b2d6af1c9844944291e5e7351a6aa24cd7b23099efac1b2fd875da31a0",[s.o.SOLFLARE_CONNECTOR_NAME]:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",[s.o.PHANTOM_CONNECTOR_NAME]:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",[s.o.COIN98_CONNECTOR_NAME]:"2a3c89040ac3b723a1972a33a125b1db11e258a6975d3a61252cd64e6ea5ea01",[s.o.MAGIC_EDEN_CONNECTOR_NAME]:"8b830a2b724a9c3fbab63af6f55ed29c9dfa8a55e732dc88c80a196a2ba136c6",[s.o.BACKPACK_CONNECTOR_NAME]:"2bd8c14e035c2d48f184aaa168559e86b0e3433228d3c4075900a221785019b0",[s.o.BITGET_CONNECTOR_NAME]:"38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",[s.o.FRONTIER_CONNECTOR_NAME]:"85db431492aa2e8672e93f4ea7acf10c88b97b867b0d373107af63dc4880f041",[s.o.XVERSE_CONNECTOR_NAME]:"2a87d74ae02e10bdd1f51f7ce6c4e1cc53cd5f2c0b6b5ad0d7b300
27d2b13de7b",[s.o.LEATHER_CONNECTOR_NAME]:"483afe1df1df63daf313109971ff3ef8356ddf1cc4e45877d205eee0b7893a13",[s.o.OKX_CONNECTOR_NAME]:"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709"},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",2741:"fc2427d1-5af9-4a9c-8da5-6f94627cd900","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","00000008819873e925422c1ff0f99f7c":"b3406e4a-bbfc-44fb-e3a6-89673c78b700"},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",[s.o.CONNECTOR_TYPE_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]}},23860:(e,t,n)=>{"use strict";n.d(t,{s:()=>l});var i=n(24107),s=n(87931),r=n(10232),o=n(50390),a=n(64751),c=n(69968);const l={async getTokenList(e){var t;const n=await s.T.fetchSwapTokens({chainId:e});return(null===n||void 0===n||null===(t=n.tokens)||void 0===t?void 0:t.map(e=>(0,i.A)((0,i.A)({},e),{},{eip2612:!1,quantity:{decimals:"0",numeric:"0"},price:0,value:0})))||[]},async fetchGasPrice(){var e;const t=r.W.state.activeCaipNetwork;if(!t)return null;try{if("solana"===t.chainNamespace){const t=null===(e=await(null===o.x||void 0===o.x?void 0:o.x.estimateGas({chainNamespace:"solana"})))||void 0===e?void 0:e.toString();return{standard:t,fast:t,instant:t}}return await s.T.fetchGasPrice({chainId:t.caipNetworkId})}catch(n){return null}},async fetchSwapAllowance(e){let{tokenAddress:t,userAddress:n,sourceTokenAmount:i,sourceTokenDecimals:r}=e;const a=await s.T.fetchSwapAllowance({tokenAddress:t,userAddress:n});if(null!==a&&void 0!==a&&a.allowance&&i&&r){const e=o.x.parseUnits(i,r)||0;return BigInt(a.allowance)>=e}return!1},async getMyTokensWithBalance(e){const t=await a.Z.getMyTokensWithBalance(e);return r.W.setAccountProp("tokenBalance",t,r.W.state.activeChain),this.mapBalancesToSwapTokens(t)},mapBalancesToSwapTokens:e=>(null===e||void 0===e?void 0:e.map(e=>(0,i.A)((0,i.A)({},e),{},{address:null!==e&&void 0!==e&&e.address?e.address:(0,c.K1)(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1})))||[],async handleSwapError(e){try{var t;const n=null===e||void 0===e?void 0:e.cause;if(null===n||void 0===n||!n.json)return;const i=await n.json(),s=null===i||void 0===i||null===(t=i.reasons)||void 0===t||null===(t=t[0])||void 0===t?void 0:t.description;return null!==s&&void 0!==s&&s.includes("insufficient liquidity")?"Insufficient liquidity":void 0}catch(n){return}}}},23976:(e,t,n)=>{"use strict";n.d(t,{W:()=>b});var i=n(18539),s=n(35574),r=n(78854),o=n(24107),a=n(84873),c=n(10232),l=n(47482),d=n(28956);const h={onSwitchNetwork(e){var t,n;let{network:i,ignoreSwitchConfirmation:s=!1}=e;const r=c.W.state.activeCaipNetwork,h=c.W.state.activeChain,u=d.I.state.data;if(i.id===(null===r||void 0===r?void 0:r.id))return;const p=Boolean(null===(t=c.W.getAccountData(h))||void 0===t?void 0:t.address),f=Boolean(null===(n=c.W.getAccountData(i.chainNamespace))||void 0===n?void 0:n.address),g=i.chainNamespace!==h,v=l.a.getConnectorId(h)===a.o.CONNECTOR_ID.AUTH,m=a.o.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(e=>e===i.chainNamespace);s||v&&m?d.I.push("SwitchNetwork",(0,o.A)((0,o.A)({},u),{},{network:i})):p&&g&&!f?d.I.push("SwitchActiveChain",{switchToChain:i.chainNamespace,navigateTo:"Connect",navigateWithReplace:!0,network:i}):d.I.push("SwitchNetwork",(0,o.A)((0,o.A)({},u),{},{network:i}))}};var u=n(17555),p=n(13033),f=n(50390),g=n(74520),v=n(46443),m=n(50067
2);const y=(0,i.BX)({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),w={state:y,subscribe:e=>(0,i.B1)(y,()=>e(y)),subscribeKey:(e,t)=>(0,s.u$)(y,e,t),async open(e){var t;const n=null===e||void 0===e?void 0:e.namespace,i=c.W.state.activeChain,s=n&&n!==i,o=null===(t=c.W.getAccountData(null===e||void 0===e?void 0:e.namespace))||void 0===t?void 0:t.caipAddress,a=c.W.state.noAdapters;if(f.x.state.wcBasic?p.N.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1,fetchWalletRanks:!1}):await p.N.prefetch(),l.a.setFilterByNamespace(null===e||void 0===e?void 0:e.namespace),b.setLoading(!0,n),n&&s){var u;const e=(null===(u=c.W.getNetworkData(n))||void 0===u?void 0:u.caipNetwork)||c.W.getRequestedCaipNetworks(n)[0];e&&(a?(await c.W.switchActiveNetwork(e),d.I.push("ConnectingWalletConnectBasic")):h.onSwitchNetwork({network:e,ignoreSwitchConfirmation:!0}))}else v.H.state.manualWCControl||a&&!o?r.w.isMobile()?d.I.reset("AllWallets"):d.I.reset("ConnectingWalletConnectBasic"):null!==e&&void 0!==e&&e.view?d.I.reset(e.view,e.data):o?d.I.reset("Account"):d.I.reset("Connect");y.open=!0,m.z.set({open:!0}),g.E.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:Boolean(o)}})},close(){const e=v.H.state.enableEmbedded,t=Boolean(c.W.state.activeCaipAddress);y.open&&g.E.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:t}}),y.open=!1,d.I.reset("Connect"),b.clearLoading(),e?t?d.I.replace("Account"):d.I.push("Connect"):m.z.set({open:!1}),f.x.resetUri()},setLoading(e,t){t&&y.loadingNamespaceMap.set(t,e),y.loading=e,m.z.set({loading:e})},clearLoading(){y.loadingNamespaceMap.clear(),y.loading=!1,m.z.set({loading:!1})},shake(){y.shake||(y.shake=!0,setTimeout(()=>{y.shake=!1},500))}},b=(0,u.X)(w)},26828:(e,t,n)=>{"use strict";n.d(t,{R:()=>N});var i=n(18539),s=n(35574),r=n(48670),o=n(59931),a=n(84873);const c=[{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"}]}],l=[{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"}]}],d=e=>a.o.USDT_CONTRACT_ADDRESSES.includes(e)?l:c;var h=n(38190),u=n(64751),p=n(69968),f=n(78256),g=n(78854),v=n(23860),m=n(17555),y=n(10232),w=n(50390),b=n(74520),E=n(28956),C=n(62463);const A=(0,i.BX)({tokenBalances:[],loading:!1}),I={state:A,subscribe:e=>(0,i.B1)(A,()=>e(A)),subscribeKey:(e,t)=>(0,s.u$)(A,e,t),setToken(e){e&&(A.token=(0,i.KR)(e))},setTokenAmount(e){A.sendTokenAmount=e},setReceiverAddress(e){A.receiverAddress=e},setReceiverProfileImageUrl(e){A.receiverProfileImageUrl=e},setReceiverProfileName(e){A.receiverProfileName=e},setNetworkBalanceInUsd(e){A.networkBalanceInUSD=e},setLoading(e){A.loading=e},getSdkEventProperties(e){var t,n,i;return{message:g.w.parseError(e),isSmartAccount:(0,p.lj)(y.W.state.activeChain)===h.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:(null===(t=A.token)||void 0===t?void 0:t.symbol)||"",amount:null!==(n=A.sendTokenAmount)&&void 0!==n?n:0,network:(null===(i=y.W.state.activeCaipNetwork)||void 0===i?void 0:i.caipNetworkId)||""}},async sendToken(){try{var e;switch(N.setLoading(!0),null===(e=y.W.state.activeCaipNetwork)||void 0===e?void 0:e.chainNamespace){case"eip155":return void await N.sendEvmToken();case"solana":return void await N.sendSolanaToken();default:throw new Error("Unsupported chain")}}catch(t){if(r.RQ.isUserRejectedRequestError(t))throw new r.vx(t);throw t}finally{N.setLoading(!1)}},async sendEvmToken(){var e;const t=y.W.state.activeChain;if(!t)throw new Error("SendController:sendEvmToken - activeChainNamespace is required");const n=(0,p.lj)(t);if(!N.state.sendTokenAmount||!N.state.receiverAddress)throw new Error("An amount and receiver address are required");if(!N.state.token)throw new Error("A token is required");if(null!==(e=N.state.token)&&void 0!==e&&e.address){var i;b.E.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:n===h.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:N.state.token.address,amount:N.state.sendTokenAmount,network:(null===(i=y.W.state.activeCaipNetwork)||void 0===i?void 0:i.caipNetworkId)||""}});const{hash:e}=await N.sendERC20Token({receiverAddress:N.state.receiverAddress,tokenAddress:N.state.token.address,sendTokenAmount:N.state.sendTokenAmount,decimals:N.state.token.quantity.decimals});e&&(A.hash=e)}else{var s;b.E.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:n===h.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:N.state.token.symbol||"",amount:N.state.sendTokenAmount,network:(null===(s=y.W.state.activeCaipNetwork)||void 0===s?void 0:s.caipNetworkId)||""}});const{hash:e}=await N.sendNativeToken({receiverAddress:N.state.receiverAddress,sendTokenAmount:N.state.sendTokenAmount,decimals:N.state.token.quantity.decimals});e&&(A.hash=e)}},async fetchTokenBalance(e){var t,n,i,s;A.loading=!0;const r=y.W.state.activeChain,o=null===(t=y.W.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId,a=null===(n=y.W.state.activeCaipNetwork)||void 0===n?void 0:n.chainNamespace,c=null!==(i=null===(s=y.W.getAccountData(r))||void 0===s?void 0:s.caipAddress)&&void 0!==i?i:y.W.state.activeCaipAddress,l=c?g.w.getPlainAddress(c):void 0;if(A.lastRetry&&!g.w.isAllowedRetry(A.lastRetry,30*f.oU.ONE_SEC_MS))return A.loading=!1,[];try{if(l&&o&&a){const e=await u.Z.getMyTokensWithBalance();return A.tokenBalances=e,A.lastRetry=void 0,e}}catch(d){A.lastRetry=Date.now(),null===e||void 0===e||e(d),C.P.showError("Token Balance Unavailable")}finally{A.loading=!1}return[]},fetchNetworkBalance(){if(0===A.tokenBalances.length)return;const e=v.s.mapBalancesToSwapTokens(A.tokenBalances);if(!e)return;const t=e.find(e=>e.address===(0,p.K1)());t&&(A.networkBalanceInUSD=t?o.S.multiply(t.quantity.numeric,t.price).toString():"0")},async sendNativeToken(e){var t,n,i,s;E.I.pushTransactionStack({});const r=e.receiverAddress,o=null===(t=y.W.getAccountData())||void 0===t?void 0:t.address,c=w.x.parseUnits(e.sendTokenAmount.toString(),Number(e.decimals)),l=await w.x.sendTransaction({chainNamespace:a.o.CHAIN.EVM,to:r,address:o,data:"0x",value:null!==c&&void 0!==c?c:BigInt(0)});return b.E.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:(0,p.lj)("eip155")===h.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:(null===(n=N.state.token)||void 0===n?void 0:n.symbol)||"",amount:e.sendTokenAmount,network:(null===(i=y.W.state.activeCaipNetwork)||void 0===i?void 0:i.caipNetworkId)||"",hash:l||""}}),null===(s=w.x._getClient())||void 0===s||s.updateBalance("eip155"),N.resetSend(),{hash:l}},async sendERC20Token(e){var t;E.I.pushTransactionStack({onSuccess(){E.I.replace("Account")}});const n=w.x.parseUnits(e.sendTokenAmount.toString(),Number(e.decimals)),i=null===(t=y.W.getAccountData())||void 0===t?void 0:t.address;if(i&&e.sendTokenAmount&&e.receiverAddress&&e.tokenAddress){var s,r;const t=g.w.getPlainAddress(e.tokenAddress);if(!t)throw new Error("SendController:sendERC20Token - tokenAddress is required");const o=await w.x.writeContract({fromAddress:i,tokenAddress:t,args:[e.receiverAddress,null!==n&&void 0!==n?n:BigInt(0)],method:"transfer",abi:d(t),chainNamespace:a.o.CHAIN.EVM});return b.E.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:(0,p.lj)("eip155")===h.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,token:(null===(s=N.state.token)||void 0===s?void 0:s.symbol)||"",amount:e.sendTokenAmount,network:(null===(r=y.W.state.activeCaipNetwork)||void 0===r?void 0:r.caipNetworkId)||"",hash:o||""}}),N.resetSend(),{hash:o}}return{hash:void 0}},async sendSolanaToken(){var e;if(!N.state.sendTokenAmount||!N.state.receiverAddress)throw new Error("An amount and receiver address are required");let t;E.I.pushTransactionStack({onSuccess(){E.I.replace("Account")}}),N.state.token&&N.state.token.address!==f.oU.SOLANA_NATIVE_TOKEN_ADDRESS&&(t=g.w.isCaipAddress(N.state.token.address)?g.w.getPlainAddress(N.state.token.address):N.state.token.address);const n=await w.x.sendTransaction({chainNamespace:"solana",tokenMint:t,to:N.state.receiverAddress,value:N.state.sendTokenAmount});n&&(A.hash=n),null===(e=w.x._getClient())||void 0===e||e.updateBalance("solana"),N.resetSend()},resetSend(){A.token=void 0,A.sendTokenAmount=void 0,A.receiverAddress=void 0,A.receiverProfileImageUrl=void 0,A.receiverProfileName=void 0,A.loading=!1,A.tokenBalances=[]}},N=(0,m.X)(I)},27142:(e,t,n)=>{"use strict";n.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",OKX_CONNECTOR_NAME:"OKX Wallet",EIP155:n(84873).o.CHAIN.EVM,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",getSDKVersionWarningMessage:(e,t)=>
2"\n @@@@@@@ @@@@@@@@@@@@@@@@@@ \n @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@ \n @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ \n @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@ \n @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@ @@@@@@@@@@@ \n @@@@@@@@@@@@@@@ @@@@@@@@@@@@@ @@@@@@@@@@@@ \n @@@@@@@@@@@@@@@ @@@@@@@@@@@@@ @@@@@@@@@@@@@\n @@@@@@@@@@@@@@@ @@@@@@@@@@@@ @@@@@@@@@@@@@ \n @@@@@@ @@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@ \n @@@@@@ @@@@@@ @@@@@@@@@@@ @@@@@@@@@@@@@@@ \n @@@@@@@@@@@@@@@ @@@@@@@@@@ @@@@@@@@@@@@@@@ \n @@@@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@@ \n @@@@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@@@ \n @@@@@@@@@@@ @@@@@@@@@@@@@@@@@@@@@@@@ \n @@@@@ @@@@@@@@@@@@@@@@@@ \n \nAppKit SDK version ".concat(e," is outdated. Latest version is ").concat(t,". Please update to the latest version for bug fixes and new features.\n \nChangelog: https://github.com/reown-com/appkit/releases\nNPM Registry: https://www.npmjs.com/package/@reown/appkit")}},28577:(e,t,n)=>{"use strict";n.d(t,{$:()=>c});var i=n(18539),s=n(13033),r=n(44777);const o={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00",cosmos:"",sui:"",stacks:""},a=(0,i.BX)({networkImagePromises:{}}),c={async fetchWalletImage(e){if(e)return await s.N._fetchWalletImage(e),this.getWalletImageById(e)},async fetchNetworkImage(e){if(!e)return;const t=this.getNetworkImageById(e);return t||(a.networkImagePromises[e]||(a.networkImagePromises[e]=s.N._fetchNetworkImage(e)),await a.networkImagePromises[e],this.getNetworkImageById(e))},getWalletImageById(e){if(e)return r.j.state.walletImages[e]},getWalletImage:e=>null!==e&&void 0!==e&&e.image_url?null===e||void 0===e?void 0:e.image_url:null!==e&&void 0!==e&&e.image_id?r.j.state.walletImages[e.image_id]:void 0,getNetworkImage(e){var t,n,i;return null!==e&&void 0!==e&&null!==(t=e.assets)&&void 0!==t&&t.imageUrl?null===e||void 0===e||null===(i=e.assets)||void 0===i?void 0:i.imageUrl:null!==e&&void 0!==e&&null!==(n=e.assets)&&void 0!==n&&n.imageId?r.j.state.networkImages[e.assets.imageId]:void 0},getNetworkImageById(e){if(e)return r.j.state.networkImages[e]},getConnectorImage(e){var t;return null!==e&&void 0!==e&&e.imageUrl?e.imageUrl:null!==e&&void 0!==e&&null!==(t=e.info)&&void 0!==t&&t.icon?e.info.icon:null!==e&&void 0!==e&&e.imageId?r.j.state.connectorImages[e.imageId]:void 0},getChainImage:e=>r.j.state.networkImages[o[e]],getTokenImage(e){if(e)return r.j.state.tokenImages[e]}}},28956:(e,t,n)=>{"use strict";n.d(t,{I:()=>u});var i=n(18539),s=n(35574),r=n(17555),o=n(10232),a=n(47482),c=n(23976),l=n(46443);const d=(0,i.BX)({view:"Connect",history:["Connect"],transactionStack:[]}),h={state:d,subscribeKey:(e,t)=>(0,s.u$)(d,e,t),pushTransactionStack(e){d.transactionStack.push(e)},popTransactionStack(e){const t=d.transactionStack.pop();if(!t)return;const{onSuccess:n,onError:i,onCancel:s}=t;switch(e){case"success":null===n||void 0===n||n();break;case"error":null===i||void 0===i||i(),u.goBack();break;case"cancel":null===s||void 0===s||s(),u.goBack()}},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(){var e,t;const n=o.W.state.activeCaipAddress,s="ConnectingFarcaster"===u.state.view,r=!n&&s;if(d.history.length>1){d.history.pop();const[e]=d.history.slice(-1);if(e){const t="Connect"===e;d.view=n&&t?"Account":e}}else c.W.close();null!==(e=d.data)&&void 0!==e&&e.wallet&&(d.data.wallet=void 0),null!==(t=d.data)&&void 0!==t&&t.redirectView&&(d.data.redirectView=void 0),setTimeout(()=>{if(r){var e,t,n;o.W.setAccountProp("farcasterUrl",void 0,o.W.state.activeChain);const s=a.a.getAuthConnector();null===s||void 0===s||null===(e=s.provider)||void 0===e||e.reload();const r=(0,i.P9)(l.H.state);null===s||void 0===s||null===(t=s.provider)||void 0===t||null===(n=t.syncDappData)||void 0===n||n.call(t,{metadata:r.metadata,sdkVersion:r.sdkVersion,projectId:r.projectId,sdkType:r.s
2dkType})}},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)}},goBackOrCloseModal(){u.state.history.length>1?u.goBack():c.W.close()}},u=(0,r.X)(h)},29025:(e,t,n)=>{"use strict";function i(e,t){return"light"===t?{"--w3m-accent":(null===e||void 0===e?void 0:e["--w3m-accent"])||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":(null===e||void 0===e?void 0:e["--w3m-accent"])||"hsla(230, 100%, 67%, 1)","--w3m-background":"#202020"}}n.d(t,{o:()=>i})},29259:(e,t,n)=>{"use strict";n.d(t,{D:()=>o});var i=n(46443),s=n(78256),r=n(78854);const o={getFeatureValue(e,t){const n=null===t||void 0===t?void 0:t[e];return void 0===n?s.oU.DEFAULT_FEATURES[e]:n},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},isSocialsEnabled(){var e,t,n,s;return Array.isArray(null===(e=i.H.state.features)||void 0===e?void 0:e.socials)&&(null===(t=i.H.state.features)||void 0===t?void 0:t.socials.length)>0||Array.isArray(null===(n=i.H.state.remoteFeatures)||void 0===n?void 0:n.socials)&&(null===(s=i.H.state.remoteFeatures)||void 0===s?void 0:s.socials.length)>0},isEmailEnabled(){var e,t;return Boolean((null===(e=i.H.state.features)||void 0===e?void 0:e.email)||(null===(t=i.H.state.remoteFeatures)||void 0===t?void 0:t.email))}}},30911:(e,t,n)=>{"use strict";n.d(t,{D5:()=>S,U5:()=>N,h6:()=>s.a,iP:()=>A,oI:()=>I});var i=n(23439),s=n.n(i),r=n(77101);const o={level:"info"},a="custom_context",c=1024e3;class l{constructor(e){this.nodeValue=e,this.sizeInBytes=(new TextEncoder).encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}class d{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const t=new l(e);if(t.size>this.maxSizeInBytes)throw new Error("[LinkedList] Value too big to insert into list: ".concat(e," with size ").concat(t.size));for(;this.size+t.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=t),this.tail=t):(this.head=t,this.tail=t),this.lengthInNodes++,this.sizeInBytes+=t.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let t=this.head;for(;null!==t;)e.push(t.value),t=t.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const t=e.value;return e=e.next,{done:!1,value:t}}}}}class h{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c;this.level=null!==e&&void 0!==e?e:"error",this.levelValue=i.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=t,this.logs=new d(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,t){t===i.levels.values.error?console.error(e):t===i.levels.values.warn?console.warn(e):t===i.levels.values.debug?console.debug(e):t===i.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append((0,r.h)({timestamp:(new Date).toISOString(),log:e}));const t="string"==typeof e?JSON.parse(e).level:e.level;t>=this.levelValue&&this.forwardToConsole(e,t)}getLogs(){return this.logs}clearLogs(){this.logs=new d(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const t=this.getLogArray();return t.push((0,r.h)({extraMetadata:e})),new Blob(t,{type:"application/json"})}}class u{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c;this.baseChunkLogger=new h(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const t=URL.createObjectURL(this.logsToBlob(e)),n=document.createElement("a");n.href=t,n.download="walletconnect-logs-".concat((new Date).toISOString(),".txt"),document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(t)}}class p{constructor(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:c;this.baseChunkLogger=new h(e,t)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}}var f=Object.defineProperty,g=Object.defineProperties,v=Object.getOwnPropertyDescriptors,m=Object.getOwnPropertySymbols,y=Object.prototype.hasOwnProperty,w=Object.prototype.propertyIsEnumerable,b=(e,t,n)=>t in e?f(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,E=(e,t)=>{for(var n in t||(t={}))y.call(t,n)&&b(e,n,t[n]);if(m)for(var n of m(t))w.call(t,n)&&b(e,n,t[n]);return e},C=(e,t)=>g(e,v(t));function A(e){return C(E({},e),{level:(null===e||void 0===e?void 0:e.level)||o.level})}function I(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a,n="";return n=typeof e.bindings>"u"?function(e){return e[arguments.length>1&&void 0!==arguments[1]?arguments[1]:a]||""}(e,t):e.bindings().context||"",n}function N(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a;const i=function(e,t){const n=I(e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:a);return n.trim()?"".concat(n,"/").concat(t):t}(e,t,n);return function(e,t){return e[arguments.length>2&&void 0!==arguments[2]?arguments[2]:a]=t,e}(e.child({context:i}),i,n)}function S(e){return typeof e.loggerOverride<"u"&&"string"!=typeof e.loggerOverride?{logger:e.loggerOverride,chunkLoggerController:null}:typeof window<"u"?function(e){var t,n;const i=new u(null==(t=e.opts)?void 0:t.level,e.maxSizeInBytes);return{logger:s()(C(E({},e.opts),{level:"trace",browser:C(E({},null==(n=e.opts)?void 0:n.browser),{write:e=>i.write(e)})})),chunkLoggerController:i}}(e):function(e){var t;const n=new p(null==(t=e.opts)?void 0:t.level,e.maxSizeInBytes);return{logger:s()(C(E({},e.opts),{level:"trace"}),n),chunkLoggerController:n}}(e)}},35258:(e,t,n)=>{"use strict";n.d(t,{mN:()=>O,AH:()=>l,W3:()=>S,Ec:()=>_,iz:()=>c});const i=globalThis,s=i.ShadowRoot&&(void 0===i.ShadyCSS||i.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,r=Symbol(),o=new WeakMap;class a{constructor(e,t,n){if(this._$cssResult$=!0,n!==r)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(s&&void 0===e){const n=void 0!==t&&1===t.length;n&&(e=o.get(t)),void 0===e&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&o.set(t,e))}return e}toString(){return this.cssText}}const c=e=>
2new a("string"==typeof e?e:e+"",void 0,r),l=function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];const s=1===e.length?e[0]:n.reduce((t,n,i)=>t+(e=>{if(!0===e._$cssResult$)return e.cssText;if("number"==typeof e)return e;throw Error("Value passed to 'css' function must be a 'css' function result: "+e+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(n)+e[i+1],e[0]);return new a(s,e,r)},d=(e,t)=>{if(s)e.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const n of t){const t=document.createElement("style"),s=i.litNonce;void 0!==s&&t.setAttribute("nonce",s),t.textContent=n.cssText,e.appendChild(t)}},h=s?e=>e:e=>e instanceof CSSStyleSheet?(e=>{let t="";for(const n of e.cssRules)t+=n.cssText;return c(t)})(e):e;var u,p,f;const{is:g,defineProperty:v,getOwnPropertyDescriptor:m,getOwnPropertyNames:y,getOwnPropertySymbols:w,getPrototypeOf:b}=Object,E=globalThis,C=E.trustedTypes,A=C?C.emptyScript:"",I=E.reactiveElementPolyfillSupport,N=(e,t)=>e,S={toAttribute(e,t){switch(t){case Boolean:e=e?A:null;break;case Object:case Array:e=null==e?e:JSON.stringify(e)}return e},fromAttribute(e,t){let n=e;switch(t){case Boolean:n=null!==e;break;case Number:n=null===e?null:Number(e);break;case Object:case Array:try{n=JSON.parse(e)}catch(e){n=null}}return n}},_=(e,t)=>!g(e,t),T={attribute:!0,type:String,converter:S,reflect:!1,useDefault:!1,hasChanged:_};null!==(u=Symbol.metadata)&&void 0!==u||(Symbol.metadata=Symbol("metadata")),null!==(p=E.litPropertyMetadata)&&void 0!==p||(E.litPropertyMetadata=new WeakMap);class O extends HTMLElement{static addInitializer(e){var t;this._$Ei(),(null!==(t=this.l)&&void 0!==t?t:this.l=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:T;if(t.state&&(t.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((t=Object.create(t)).wrapped=!0),this.elementProperties.set(e,t),!t.noAccessor){const n=Symbol(),i=this.getPropertyDescriptor(e,n,t);void 0!==i&&v(this.prototype,e,i)}}static getPropertyDescriptor(e,t,n){var i;const{get:s,set:r}=null!==(i=m(this.prototype,e))&&void 0!==i?i:{get(){return this[t]},set(e){this[t]=e}};return{get:s,set(t){const i=null===s||void 0===s?void 0:s.call(this);null!==r&&void 0!==r&&r.call(this,t),this.requestUpdate(e,i,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){var t;return null!==(t=this.elementProperties.get(e))&&void 0!==t?t:T}static _$Ei(){if(this.hasOwnProperty(N("elementProperties")))return;const e=b(this);e.finalize(),void 0!==e.l&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(N("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(N("properties"))){const e=this.properties,t=[...y(e),...w(e)];for(const n of t)this.createProperty(n,e[n])}const e=this[Symbol.metadata];if(null!==e){const t=litPropertyMetadata.get(e);if(void 0!==t)for(const[e,n]of t)this.elementProperties.set(e,n)}this._$Eh=new Map;for(const[t,n]of this.elementProperties){const e=this._$Eu(t,n);void 0!==e&&this._$Eh.set(e,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const n=new Set(e.flat(1/0).reverse());for(const e of n)t.unshift(h(e))}else void 0!==e&&t.push(h(e));return t}static _$Eu(e,t){const n=t.attribute;return!1===n?void 0:"string"==typeof n?n:"string"==typeof e?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var e;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),null===(e=this.constructor.l)||void 0===e||e.forEach(e=>e(this))}addController(e){var t,n;(null!==(t=this._$EO)&&void 0!==t?t:this._$EO=new Set).add(e),void 0!==this.renderRoot&&this.isConnected&&(null===(n=e.hostConnected)||void 0===n||n.call(e))}
2removeController(e){var t;null===(t=this._$EO)||void 0===t||t.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const n of t.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){var e;const t=null!==(e=this.shadowRoot)&&void 0!==e?e:this.attachShadow(this.constructor.shadowRootOptions);return d(t,this.constructor.elementStyles),t}connectedCallback(){var e,t;null!==(e=this.renderRoot)&&void 0!==e||(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),null===(t=this._$EO)||void 0===t||t.forEach(e=>{var t;return null===(t=e.hostConnected)||void 0===t?void 0:t.call(e)})}enableUpdating(e){}disconnectedCallback(){var e;null===(e=this._$EO)||void 0===e||e.forEach(e=>{var t;return null===(t=e.hostDisconnected)||void 0===t?void 0:t.call(e)})}attributeChangedCallback(e,t,n){this._$AK(e,n)}_$ET(e,t){const n=this.constructor.elementProperties.get(e),i=this.constructor._$Eu(e,n);if(void 0!==i&&!0===n.reflect){var s;const r=(void 0!==(null===(s=n.converter)||void 0===s?void 0:s.toAttribute)?n.converter:S).toAttribute(t,n.type);this._$Em=e,null==r?this.removeAttribute(i):this.setAttribute(i,r),this._$Em=null}}_$AK(e,t){const n=this.constructor,i=n._$Eh.get(e);if(void 0!==i&&this._$Em!==i){var s,r,o;const e=n.getPropertyOptions(i),a="function"==typeof e.converter?{fromAttribute:e.converter}:void 0!==(null===(s=e.converter)||void 0===s?void 0:s.fromAttribute)?e.converter:S;this._$Em=i;const c=a.fromAttribute(t,e.type);this[i]=null!==(r=null!==c&&void 0!==c?c:null===(o=this._$Ej)||void 0===o?void 0:o.get(i))&&void 0!==r?r:c,this._$Em=null}}requestUpdate(e,t,n){if(void 0!==e){var i,s;const r=this.constructor,o=this[e];if(null!==n&&void 0!==n||(n=r.getPropertyOptions(e)),!((null!==(i=n.hasChanged)&&void 0!==i?i:_)(o,t)||n.useDefault&&n.reflect&&o===(null===(s=this._$Ej)||void 0===s?void 0:s.get(e))&&!this.hasAttribute(r._$Eu(e,n))))return;this.C(e,t,n)}!1===this.isUpdatePending&&(this._$ES=this._$EP())}C(e,t,n,i){var s,r,o;let{useDefault:a,reflect:c,wrapped:l}=n;a&&!(null!==(s=this._$Ej)&&void 0!==s?s:this._$Ej=new Map).has(e)&&(this._$Ej.set(e,null!==(r=null!==i&&void 0!==i?i:t)&&void 0!==r?r:this[e]),!0!==l||void 0!==i)||(this._$AL.has(e)||(this.hasUpdated||a||(t=void 0),this._$AL.set(e,t)),!0===c&&this._$Em!==e&&(null!==(o=this._$Eq)&&void 0!==o?o:this._$Eq=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const e=this.scheduleUpdate();return null!=e&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){var e;if(null!==(e=this.renderRoot)&&void 0!==e||(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[e,t]of this._$Ep)this[e]=t;this._$Ep=void 0}const t=this.constructor.elementProperties;if(t.size>0)for(const[e,n]of t){const{wrapped:t}=n,i=this[e];!0!==t||this._$AL.has(e)||void 0===i||this.C(e,void 0,n,i)}}let t=!1;const n=this._$AL;try{var i;t=this.shouldUpdate(n),t?(this.willUpdate(n),null!==(i=this._$EO)&&void 0!==i&&i.forEach(e=>{var t;return null===(t=e.hostUpdate)||void 0===t?void 0:t.call(e)}),this.update(n)):this._$EM()}catch(n){throw t=!1,this._$EM(),n}t&&this._$AE(n)}willUpdate(e){}_$AE(e){var t;null!==(t=this._$EO)&&void 0!==t&&t.forEach(e=>{var t;return null===(t=e.hostUpdated)||void 0===t?void 0:t.call(e)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&(this._$Eq=this._$Eq.forEach(e=>this._$ET(e,this[e]))),this._$EM()}updated(e){}firstUpdated(e){}}O.elementStyles=[],O.shadowRootOptions={mode:"open"},O[N("elementProperties")]=new Map,O[N("finalized")]=new Map,null!==I&&void 0!==I&&I({ReactiveElement:O}),(null!==(f=E.reactiveElementVersions)&&void 0!==f?f:E.reactiveElementVersions=[]).push("2.1.1")},35574:(e,t,n)=>{"use strict";n.d(t,{u$:()=>s,zC:()=>c});var i=n(18539);function s(e,t,n,s){let r=e[t];return(0,i.B1)(e,()=>{const i=e[t];Object.is(r,i)||n(r=i)},s)}Symbol();const{proxyStateMap:r,snapCache:o}=(0,i.h2)(),a=e=>r.has(e);function c(e){const t=[];let n=0;const s=new Map,r=new WeakMap,c=e=>r.get(e)||s;if(e){if("function"!==typeof e[Symbol.iterator])throw new TypeError("proxyMap:\n\tinitial state must be iterable\n\t\ttip: structure should be [[key, value]]");for(const[i,r]of e)s.set(i,n),t[n++]=r}const l={data:t,index:n,epoch:0,get size(){a(this)||(()=>{const e=o.get(l),t=null==e?void 0:e[1];if(t&&!r.has(t)){const e=new Map(s);r.set(t,e)}})();return c(this).size},get(e){const t=c(this).get(e);if(void 0!==t)return this.data[t];this.epoch},has(e){const t=c(this);return this.epoch,t.has(e)},set(e,t){if(!a(this))throw new Error("Cannot perform mutations on a snapshot");const n=s.get(e);return void 0===n?(s.set(e,this.index),this.data[this.index++]=t):this.data[n]=t,this.epoch++,this},delete(e){if(!a(this))throw new Error("Cannot perform mutations on a snapshot");const t=s.get(e);return void 0!==t&&(delete this.data[t],s.delete(e),this.epoch++,!0)},clear(){if(!a(this))throw new Error("Cannot perform mutations on a snapshot");this.data.length=0,this.index=0,this.epoch++,s.clear()}
2,forEach(e){this.epoch;c(this).forEach((t,n)=>{e(this.data[t],n,this)})},*entries(){this.epoch;const e=c(this);for(const[t,n]of e)yield[t,this.data[n]]},*keys(){this.epoch;const e=c(this);for(const t of e.keys())yield t},*values(){this.epoch;const e=c(this);for(const t of e.values())yield this.data[t]},[Symbol.iterator](){return this.entries()},get[Symbol.toStringTag](){return"Map"},toJSON(){return new Map(this.entries())}},d=(0,i.BX)(l);return Object.defineProperties(d,{size:{enumerable:!1},index:{enumerable:!1},epoch:{enumerable:!1},data:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(d),d}const{proxyStateMap:l,snapCache:d}=(0,i.h2)()},37159:(e,t,n)=>{"use strict";n.d(t,{A:()=>u});var i=n(24107),s=n(47482),r=n(13033),o=n(46443),a=n(78854),c=n(81828),l=n(89386),d=n(92187),h=n(11217);const u={filterOutDuplicatesByRDNS(e){const t=o.H.state.enableEIP6963?s.a.state.connectors:[],n=c.i.getRecentWallets(),i=t.map(e=>{var t;return null===(t=e.info)||void 0===t?void 0:t.rdns}).filter(Boolean),r=n.map(e=>e.rdns).filter(Boolean),l=i.concat(r);if(l.includes("io.metamask.mobile")&&a.w.isMobile()){const e=l.indexOf("io.metamask.mobile");l[e]="io.metamask"}return e.filter(e=>{if(null!==e&&void 0!==e&&e.rdns&&l.includes(String(e.rdns)))return!1;if(null===e||void 0===e||!e.rdns){if(t.some(t=>t.name===e.name))return!1}return!0})},filterOutDuplicatesByIds(e){const t=s.a.state.connectors.filter(e=>"ANNOUNCED"===e.type||"INJECTED"===e.type),n=c.i.getRecentWallets(),i=t.map(e=>e.explorerId),r=n.map(e=>e.id),o=i.concat(r);return e.filter(e=>!o.includes(null===e||void 0===e?void 0:e.id))},filterOutDuplicateWallets(e){const t=this.filterOutDuplicatesByRDNS(e);return this.filterOutDuplicatesByIds(t)},markWalletsAsInstalled(e){const{connectors:t}=s.a.state,{featuredWalletIds:n}=o.H.state,r=t.filter(e=>"ANNOUNCED"===e.type).reduce((e,t)=>{var n;return null!==(n=t.info)&&void 0!==n&&n.rdns?(e[t.info.rdns]=!0,e):e},{});return e.map(e=>{var t;return(0,i.A)((0,i.A)({},e),{},{installed:Boolean(e.rdns)&&Boolean(r[null!==(t=e.rdns)&&void 0!==t?t:""])})}).sort((e,t)=>{const i=Number(t.installed)-Number(e.installed);if(0!==i)return i;if(null!==n&&void 0!==n&&n.length){const i=n.indexOf(e.id),s=n.indexOf(t.id);if(-1!==i&&-1!==s)return i-s;if(-1!==i)return-1;if(-1!==s)return 1}return 0})},getConnectOrderMethod(e,t){var n;const i=(null===e||void 0===e?void 0:e.connectMethodsOrder)||(null===(n=o.H.state.features)||void 0===n?void 0:n.connectMethodsOrder),a=t||s.a.state.connectors;if(i)return i;const{injected:c,announced:l}=d.g.getConnectorsByType(a,r.N.state.recommended,r.N.state.featured),u=c.filter(d.g.showConnector),p=l.filter(d.g.showConnector);return u.length||p.length?["wallet","email","social"]:h.o.DEFAULT_CONNECT_METHOD_ORDER},isExcluded(e){const t=Boolean(e.rdns)&&r.N.state.excludedWallets.some(t=>t.rdns===e.rdns),n=Boolean(e.name)&&r.N.state.excludedWallets.some(t=>l.y.isLowerCaseMatch(t.name,e.name));return t||n},markWalletsWithDisplayIndex:e=>e.map((e,t)=>(0,i.A)((0,i.A)({},e),{},{display_index:t}))}},38190:(e,t,n)=>{"use strict";n.d(t,{Vl:()=>i});const i={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",RP
2C_METHOD_NOT_ALLOWED_UI_MESSAGE:"Action not allowed",ACCOUNT_TYPES:{EOA:"eoa",SMART_ACCOUNT:"smartAccount"}}},39377:(e,t,n)=>{"use strict";n.d(t,{R:()=>w});var i=n(24107),s=n(46755),r=n(15882),o=n(14764),a=n(41661),c=n(14825),l=n(8447);const d=["chain","pollingInterval","timeout"];function h(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{key:n="fallback",name:s="Fallback",rank:o=!1,shouldThrow:a=u,retryCount:h,retryDelay:p}=t;return t=>{let{chain:u,pollingInterval:f=4e3,timeout:g}=t,v=(0,r.A)(t,d),m=e,y=()=>{};const w=(0,l.o)({key:n,name:s,async request(e){let t,{method:n,params:s}=e;const r=async function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;const o=m[e]((0,i.A)((0,i.A)({},v),{},{chain:u,retryCount:0,timeout:g}));try{const e=await o.request({method:n,params:s});return y({method:n,params:s,response:e,transport:o,status:"success"}),e}catch(c){if(y({error:c,method:n,params:s,transport:o,status:"error"}),a(c))throw c;if(e===m.length-1)throw c;if(null!==t&&void 0!==t||(t=m.slice(e+1).some(e=>{const{include:t,exclude:i}=e({chain:u}).config.methods||{};return t?t.includes(n):!i||!i.includes(n)})),!t)throw c;return r(e+1)}};return r()},retryCount:h,retryDelay:p,type:"fallback"},{onResponse:e=>y=e,transports:m.map(e=>e({chain:u,retryCount:0}))});if(o){var b;const e="object"===typeof o?o:{};!function(e){let{chain:t,interval:n=4e3,onTransports:i,ping:s,sampleCount:r=10,timeout:o=1e3,transports:a,weights:l={}}=e;const{stability:d=.7,latency:h=.3}=l,u=[],p=async()=>{const e=await Promise.all(a.map(async e=>{const n=e({chain:t,retryCount:0,timeout:o}),i=Date.now();let r,a;try{await(s?s({transport:n}):n.request({method:"net_listening"})),a=1}catch(c){a=0}finally{r=Date.now()}return{latency:r-i,success:a}}));u.push(e),u.length>r&&u.shift();const l=Math.max(...u.map(e=>Math.max(...e.map(e=>{let{latency:t}=e;return t})))),f=a.map((e,t)=>{const n=u.map(e=>e[t].latency),i=1-n.reduce((e,t)=>e+t,0)/n.length/l,s=u.map(e=>e[t].success),r=s.reduce((e,t)=>e+t,0)/s.length;return 0===r?[0,t]:[h*i+d*r,t]}).sort((e,t)=>t[0]-e[0]);i(f.map(e=>{let[,t]=e;return a[t]})),await(0,c.u)(n),p()};p()}({chain:u,interval:null!==(b=e.interval)&&void 0!==b?b:f,onTransports:e=>m=e,ping:e.ping,sampleCount:e.sampleCount,timeout:e.timeout,transports:m,weights:e.weights})}return w}}function u(e){return!(!("code"in e)||"number"!==typeof e.code||e.code!==a.YW.code&&e.code!==a.vx.code&&!o.A7.nodeMessage.test(e.message)&&5e3!==e.code)}var p=n(84873),f=n(81828),g=n(10232),v=n(23579);function m(e,t){const n=new URL("https://rpc.walletconnect.org/v1/");return n.searchParams.set("chainId",e),n.searchParams.set("projectId",t),n.toString()}const y=["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","eip155:80094","eip155:80069","eip155:560048","eip155:31","eip155:2818","eip155:57054","eip155:911867","eip155:534351","eip155:1112","eip155:534352","eip155:1111","eip155:146","eip155:130","eip155:1284","eip155:30","eip155:2810","bip122:000000000019d6689c085ae165831e93","bip122:000000000933ea01ad0ee984209779ba"],w={extendRpcUrlWithProjectId(e,t){let n=!1;try{n="rpc.walletconnect.org"===new URL(e).host}catch(i){n=!1}if(n){const n=new URL(e);return n.searchParams.has("projectId")||n.searchParams.set("projectId",t),n.toString()}return e},isCaipNetwork:e=>"chainNamespace"in e&&"caipNetworkId"in e,getChainNamespace(e){return this.isCaipNetwork(e)?e.chainNamespace:p.o.CHAIN.EVM},getCaipNetworkId(e){return this.isCaipNetwork(e)?e.caipNetworkId:"".concat(p.o.CHAIN.EVM,":").concat(e.id)},getDefaultRpcUrl(e,t,n){var i;const s=null===(i=e.rpcUrls)||void 0===i||null===(i=i.default)||void 0===i||null===(i=i.http)||void 0===i?void 0:i[0];return y.includes(t)?m(t,n):s||""},extendCaipNetwork(e,t){var n,s,r;let{customNetworkImageUrls:o,projectId:a,customRpcUrls:c}=t;const l=this.getChainNamespace(e),d=this.getCaipNetworkId(e),h=null===(n=e.rpcUrls)||void 0===n||null===(n=n.default)||void 0===n||null===(n=n.http)||void 0===n?void 0:n[0],u=this.getDefaultRpcUrl(e,d,a),p=(null===e||void 0===e||null===(s=e.rpcUrls)||void 0===s||null===(s=s.chainDefault)||void 0===s||null===(s=s.http)||void 0===s?void 0:s[0])||h,f=(null===c||void 0===c||null===(r=c[d])||void 0===r?void 0:r.map(e=>e.url))||[],g=[...f,...u?[u]:[]],m=[...f];return p&&!m.includes(p)&&m.push(p),(0,i.A)((0,i.A)({},e),{},{chainNamespace:l,caipNetworkId:d,assets:{imageId:v.L.NetworkImageIds[e.id],imageUrl:null===o||void 0===o?void 0:o[e.id]},rpcUrls:(0,i.A)((0,i.A)({},e.rpcUrls),{},{default:{http:g},chainDefault:{http:m}})})},extendCaipNetworks(e,t){let{customNetworkImageUrls:n,projectId:i,customRpcUrls:s}=t;return e.map(e=>w.extendCaipNetwork(e,{customNetworkImageUrls:n,customRpcUrls:s,projectId:i}))}
2,getViemTransport(e,t,n){var i;const r=[];return null===n||void 0===n||n.forEach(e=>{r.push((0,s.L)(e.url,e.config))}),y.includes(e.caipNetworkId)&&r.push((0,s.L)(m(e.caipNetworkId,t),{fetchOptions:{headers:{"Content-Type":"text/plain"}}})),null===e||void 0===e||null===(i=e.rpcUrls)||void 0===i||null===(i=i.default)||void 0===i||null===(i=i.http)||void 0===i||i.forEach(e=>{r.push((0,s.L)(e))}),h(r)},extendWagmiTransports(e,t,n){if(y.includes(e.caipNetworkId)){const i=this.getDefaultRpcUrl(e,e.caipNetworkId,t);return h([n,(0,s.L)(i)])}return n},getUnsupportedNetwork:e=>({id:e.split(":")[1],caipNetworkId:e,name:p.o.UNSUPPORTED_NETWORK_NAME,chainNamespace:e.split(":")[0],nativeCurrency:{name:"",decimals:0,symbol:""},rpcUrls:{default:{http:[]}}}),getCaipNetworkFromStorage(e){var t;const n=f.i.getActiveCaipNetworkId(),i=g.W.getAllRequestedCaipNetworks(),s=Array.from((null===(t=g.W.state.chains)||void 0===t?void 0:t.keys())||[]),r=null===n||void 0===n?void 0:n.split(":")[0],o=!!r&&s.includes(r),a=null===i||void 0===i?void 0:i.find(e=>e.caipNetworkId===n);return o&&!a&&n?this.getUnsupportedNetwork(n):a||(e||(null===i||void 0===i?void 0:i[0]))}}},44777:(e,t,n)=>{"use strict";n.d(t,{j:()=>l});var i=n(24107),s=n(18539),r=n(35574),o=n(17555);const a=(0,s.BX)({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),c={state:a,subscribeNetworkImages:e=>(0,s.B1)(a.networkImages,()=>e(a.networkImages)),subscribeKey:(e,t)=>(0,r.u$)(a,e,t),subscribe:e=>(0,s.B1)(a,()=>e(a)),setWalletImage(e,t){a.walletImages[e]=t},setNetworkImage(e,t){a.networkImages[e]=t},setChainImage(e,t){a.chainImages[e]=t},setConnectorImage(e,t){a.connectorImages=(0,i.A)((0,i.A)({},a.connectorImages),{},{[e]:t})},setTokenImage(e,t){a.tokenImages[e]=t},setCurrencyImage(e,t){a.currencyImages[e]=t}},l=(0,o.X)(c)},46443:(e,t,n)=>{"use strict";n.d(t,{H:()=>d});var i=n(24107),s=n(18539),r=n(35574),o=n(78256),a=n(78854),c=n(29259);const l=(0,s.BX)({features:o.oU.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:o.oU.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0,experimental_preferUniversalLinks:!1,remoteFeatures:{},enableMobileFullScreen:!1}),d={state:l,subscribeKey:(e,t)=>(0,r.u$)(l,e,t),setOptions(e){Object.assign(l,e)},setRemoteFeatures(e){var t,n;if(!e)return;const s=(0,i.A)((0,i.A)({},l.remoteFeatures),e);l.remoteFeatures=s,null!==(t=l.remoteFeatures)&&void 0!==t&&t.socials&&(l.remoteFeatures.socials=c.D.filterSocialsByPlatform(l.remoteFeatures.socials)),null!==(n=l.features)&&void 0!==n&&n.pay&&(l.remoteFeatures.email=!1,l.remoteFeatures.socials=!1)},setFeatures(e){var t;if(!e)return;l.features||(l.features=o.oU.DEFAULT_FEATURES);const n=(0,i.A)((0,i.A)({},l.features),e);l.features=n,null!==(t=l.features)&&void 0!==t&&t.pay&&l.remoteFeatures&&(l.remoteFeatures.email=!1,l.remoteFeatures.socials=!1)},setProjectId(e){l.projectId=e},setCustomRpcUrls(e){l.customRpcUrls=e},setAllWallets(e){l.allWallets=e},setIncludeWalletIds(e){l.includeWalletIds=e},setExcludeWalletIds(e){l.excludeWalletIds=e},setFeaturedWalletIds(e){l.featuredWalletIds=e},setTokens(e){l.tokens=e},setTermsConditionsUrl(e){l.termsConditionsUrl=e},setPrivacyPolicyUrl(e){l.privacyPolicyUrl=e},setCustomWallets(e){l.customWallets=e},setIsSiweEnabled(e){l.isSiweEnabled=e},setIsUniversalProvider(e){l.isUniversalProvider=e},setSdkVersion(e){l.sdkVersion=e},setMetadata(e){l.metadata=e},setDisableAppend(e){l.disableAppend=e},setEIP6963Enabled(e){l.enableEIP6963=e},setDebug(e){l.debug=e},setEnableWalletGuide(e){l.enableWalletGuide=e},setEnableAuthLogger(e){l.enableAuthLogger=e},setEnableWallets(e){l.enableWallets=e},setPreferUniversalLinks(e){l.experimental_preferUniversalLinks=e},setSIWX(e){if(e)for(const[n,i]of Object.entries(o.oU.SIWX_DEFAULTS)){var t;null!==(t=e[n])&&void 0!==t||(e[n]=i)}l.siwx=e},setConnectMethodsOrder(e){l.features=(0,i.A)((0,i.A)({},l.features),{},{connectMethodsOrder:e})},setWalletFeaturesOrder(e){l.features=(0,i.A)((0,i.A)({},l.features),{},{walletFeaturesOrder:e})},setSocialsOrder(e){l.remoteFeatures=(0,i.A)((0,i.A)({},l.remoteFeatures),{},{socials:e})},setCollapseWallets(e){l.features=(0,i.A)((0,i.A)({},l.features),{},{collapseWallets:e})},setEnableEmbedded(e){l.enableEmbedded=e},setAllowUnsupportedChain(e){l.allowUnsupportedChain=e},setManualWCControl(e){l.manualWCControl=e},setEnableNetworkSwitch(e){l.enableNetworkSwitch=e},setEnableMobileFullScreen(e){l.enableMobileFullScreen=a.w.isMobile()&&e},setEnableReconnect(e){l.enableReconnect=e},setDefaultAccountTypes(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};
2Object.entries(e).forEach(e=>{let[t,n]=e;n&&(l.defaultAccountTypes[t]=n)})},setUniversalProviderConfigOverride(e){l.universalProviderConfigOverride=e},getUniversalProviderConfigOverride:()=>l.universalProviderConfigOverride,getSnapshot:()=>(0,s.P9)(l)}},47482:(e,t,n)=>{"use strict";n.d(t,{a:()=>A});var i=n(24107),s=n(18539),r=n(35574),o=n(10394),a=n(84873),c=n(29025),l=n(38190),d=n(69968),h=n(84470),u=n(81828),p=n(17555),f=n(13033),g=n(10232),v=n(46443),m=n(28956),y=n(16788);const w=Object.fromEntries(o.P.map(e=>[e,void 0])),b=Object.fromEntries(o.P.map(e=>[e,!0])),E=(0,s.BX)({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:w,filterByNamespaceMap:b}),C={state:E,subscribe:e=>(0,s.B1)(E,()=>{e(E)}),subscribeKey:(e,t)=>(0,r.u$)(E,e,t),initialize(e){e.forEach(e=>{const t=u.i.getConnectedConnectorId(e);t&&A.setConnectorId(t,e)})},setActiveConnector(e){e&&(E.activeConnector=(0,s.KR)(e))},setConnectors(e){e.filter(e=>!E.allConnectors.some(t=>t.id===e.id&&A.getConnectorName(t.name)===A.getConnectorName(e.name)&&t.chain===e.chain)).forEach(e=>{"MULTI_CHAIN"!==e.type&&E.allConnectors.push((0,s.KR)(e))});const t=A.getEnabledNamespaces(),n=A.getEnabledConnectors(t);E.connectors=A.mergeMultiChainConnectors(n)},filterByNamespaces(e){Object.keys(E.filterByNamespaceMap).forEach(e=>{E.filterByNamespaceMap[e]=!1}),e.forEach(e=>{E.filterByNamespaceMap[e]=!0}),A.updateConnectorsForEnabledNamespaces()},filterByNamespace(e,t){E.filterByNamespaceMap[e]=t,A.updateConnectorsForEnabledNamespaces()},updateConnectorsForEnabledNamespaces(){const e=A.getEnabledNamespaces(),t=A.getEnabledConnectors(e),n=A.areAllNamespacesEnabled();E.connectors=A.mergeMultiChainConnectors(t),n?f.N.clearFilterByNamespaces():f.N.filterByNamespaces(e)},getEnabledNamespaces:()=>Object.entries(E.filterByNamespaceMap).filter(e=>{let[t,n]=e;return n}).map(e=>{let[t]=e;return t}),getEnabledConnectors:e=>E.allConnectors.filter(t=>e.includes(t.chain)),areAllNamespacesEnabled:()=>Object.values(E.filterByNamespaceMap).every(e=>e),mergeMultiChainConnectors(e){const t=A.generateConnectorMapByName(e),n=[];return t.forEach(e=>{const t=e[0],i=(null===t||void 0===t?void 0:t.id)===a.o.CONNECTOR_ID.AUTH;e.length>1&&t?n.push({name:t.name,imageUrl:t.imageUrl,imageId:t.imageId,connectors:[...e],type:i?"AUTH":"MULTI_CHAIN",chain:"eip155",id:(null===t||void 0===t?void 0:t.id)||""}):t&&n.push(t)}),n},generateConnectorMapByName(e){const t=new Map;return e.forEach(e=>{const{name:n}=e,i=A.getConnectorName(n);if(!i)return;const s=t.get(i)||[];s.find(t=>t.chain===e.chain)||s.push(e),t.set(i,s)}),t},getConnectorName(e){if(!e)return e;return{"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===a.o.CONNECTOR_ID.AUTH){var t,n,i;const r=e,o=(0,s.P9)(v.H.state),a=y.W.getSnapshot().themeMode,l=y.W.getSnapshot().themeVariables;null===r||void 0===r||null===(t=r.provider)||void 0===t||null===(n=t.syncDappData)||void 0===n||n.call(t,{metadata:o.metadata,sdkVersion:o.sdkVersion,projectId:o.projectId,sdkType:o.sdkType}),null===r||void 0===r||null===(i=r.provider)||void 0===i||i.syncTheme({themeMode:a,themeVariables:l,w3mThemeVariables:(0,c.o)(l,a)}),A.setConnectors([e])}else A.setConnectors([e])},getAuthConnector(e){var t;const n=e||g.W.state.activeChain,i=E.connectors.find(e=>e.id===a.o.CONNECTOR_ID.AUTH);if(i){if(null!==i&&void 0!==i&&null!==(t=i.connectors)&&void 0!==t&&t.length){return i.connectors.find(e=>e.chain===n)}return i}},getAnnouncedConnectorRdns:()=>E.connectors.filter(e=>"ANNOUNCED"===e.type).map(e=>{var t;return null===(t=e.info)||void 0===t?void 0:t.rdns}),getConnectorById:e=>E.allConnectors.find(t=>t.id===e),getConnector(e){let{id:t,rdns:n,namespace:i}=e;const s=i||g.W.state.activeChain;return E.allConnectors.filter(e=>e.chain===s).find(e=>{var i;return e.explorerId===t||(null===(i=e.info)||void 0===i?void 0:i.rdns)===n})},syncIfAuthConnector(e){var t,n;if("ID_AUTH"!==e.id)return;const i=e,r=(0,s.P9)(v.H.state),o=y.W.getSnapshot().themeMode,a=y.W.getSnapshot().themeVariables;null===i||void 0===i||null===(t=i.provider)||void 0===t||null===(n=t.syncDappData)||void 0===n||n.call(t,{metadata:r.metadata,sdkVersion:r.sdkVersion,sdkType:r.s
2dkType,projectId:r.projectId}),i.provider.syncTheme({themeMode:o,themeVariables:a,w3mThemeVariables:(0,c.o)(a,o)})},getConnectorsByNamespace(e){const t=E.allConnectors.filter(t=>t.chain===e);return A.mergeMultiChainConnectors(t)},canSwitchToSmartAccount:e=>g.W.checkIfSmartAccountEnabled()&&(0,d.lj)(e)===l.Vl.ACCOUNT_TYPES.EOA,selectWalletConnector(e){var t;const n=null===(t=m.I.state.data)||void 0===t?void 0:t.redirectView,i=A.getConnector({id:e.id,rdns:e.rdns});h.W.handleMobileDeeplinkRedirect((null===i||void 0===i?void 0:i.explorerId)||e.id,g.W.state.activeChain),i?m.I.push("ConnectingExternal",{connector:i,wallet:e,redirectView:n}):m.I.push("ConnectingWalletConnect",{wallet:e,redirectView:n})},getConnectors:e=>e?A.getConnectorsByNamespace(e):A.mergeMultiChainConnectors(E.allConnectors),setFilterByNamespace(e){E.filterByNamespace=e,E.connectors=A.getConnectors(e),f.N.setFilterByNamespace(e)},setConnectorId(e,t){e&&(E.activeConnectorIds=(0,i.A)((0,i.A)({},E.activeConnectorIds),{},{[t]:e}),u.i.setConnectedConnectorId(t,e))},removeConnectorId(e){E.activeConnectorIds=(0,i.A)((0,i.A)({},E.activeConnectorIds),{},{[e]:void 0}),u.i.deleteConnectedConnectorId(e)},getConnectorId(e){if(e)return E.activeConnectorIds[e]},isConnected:e=>e?Boolean(E.activeConnectorIds[e]):Object.values(E.activeConnectorIds).some(e=>Boolean(e)),resetConnectorIds(){E.activeConnectorIds=(0,i.A)({},w)}},A=(0,p.X)(C)},48181:function(e){e.exports=function(){"use strict";return function(e,t,n){e=e||{};var i=t.prototype,s={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"};function r(e,t,n,s){return i.fromToBase(e,t,n,s)}n.en.relativeTime=s,i.fromToBase=function(t,i,r,o,a){for(var c,l,d,h=r.$locale().relativeTime||s,u=e.thresholds||[{l:"s",r:44,d:"second"},{l:"m",r:89},{l:"mm",r:44,d:"minute"},{l:"h",r:89},{l:"hh",r:21,d:"hour"},{l:"d",r:35},{l:"dd",r:25,d:"day"},{l:"M",r:45},{l:"MM",r:10,d:"month"},{l:"y",r:17},{l:"yy",d:"year"}],p=u.length,f=0;f<p;f+=1){var g=u[f];g.d&&(c=o?n(t).diff(r,g.d,!0):r.diff(t,g.d,!0));var v=(e.rounding||Math.round)(Math.abs(c));if(d=c>0,v<=g.r||!g.r){v<=1&&f>0&&(g=u[f-1]);var m=h[g.l];a&&(v=a(""+v)),l="string"==typeof m?m.replace("%d",v):m(v,i,g.l,d);break}}if(i)return l;var y=d?h.future:h.past;return"function"==typeof y?y(l):y.replace("%s",l)},i.to=function(e,t){return r(e,t,this,!0)},i.from=function(e,t){return r(e,t,this)};var o=function(e){return e.$u?n.utc():n()};i.toNow=function(e){return this.to(o(this),e)},i.fromNow=function(e){return this.from(o(this),e)}}}()},48670:(e,t,n)=>{"use strict";n.d(t,{RQ:()=>i,vx:()=>r});const i={RPC_ERROR_CODE:{USER_REJECTED_REQUEST:4001},PROVIDER_RPC_ERROR_NAME:{PROVIDER_RPC:"ProviderRpcError",USER_REJECTED_REQUEST:"UserRejectedRequestError"},isRpcProviderError(e){try{if("object"===typeof e&&null!==e){const t=e,n="string"===typeof t.message,i="number"===typeof t.code;return n&&i}return!1}catch(t){return!1}},isUserRejectedMessage:e=>e.toLowerCase().includes("user rejected")||e.toLowerCase().includes("user cancelled")||e.toLowerCase().includes("user canceled"),isUserRejectedRequestError(e){if(i.isRpcProviderError(e)){return e.code===i.RPC_ERROR_CODE.USER_REJECTED_REQUEST||i.isUserRejectedMessage(e.message)}return e instanceof Error&&i.isUserRejectedMessage(e.message)}};class s extends Error{constructor(e,t){super(t.message,{cause:e}),this.name=i.PROVIDER_RPC_ERROR_NAME.PROVIDER_RPC,this.code=t.code}}class r extends s{constructor(e){super(e,{code:i.RPC_ERROR_CODE.USER_REJECTED_REQUEST,message:"User rejected the request"}),this.name=i.PROVIDER_RPC_ERROR_NAME.USER_REJECTED_REQUEST}}},50067:(e,t,n)=>{"use strict";n.d(t,{z:()=>a});var i=n(24107),s=n(18539),r=n(35574);const o=(0,s.BX)({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),a={state:o,subscribe:e=>(0,s.B1)(o,()=>e(o)),subscribeOpen:e=>(0,r.u$)(o,"open",e),set(e){Object.assign(o,(0,i.A)((0,i.A)({},o),e))}}},50390:(e,t,n)=>{"use strict";n.d(t,{x:()=>k});var i=n(18539),s=n(35574),r=n(84873),o=n(62951),a=n(69968),c=n(2641),l=n(38190),d=n(10232),h=n(47482),u=n(74520),p=n(23976),f=n(28956),g=n(78256),v=n(78854),m=n(81828);const y={checkNamespaceConnectorId:(e,t)=>h.a.getConnectorId(e)===t,isSocialProvider:e=>g.oU.DEFAULT_REMOTE_FEATURES.socials.includes(e),connectWalletConnect(e){let{walletConnect:t,connector:n,closeModalOnConnect:i=!0,redirectViewOnModalClose:s="Connect",onOpen:r,onConnect:a}=e;return new Promise((e,c)=>{if(t&&h.a.setActiveConnector(n),null===r||void 0===r||r(v.w.isMobile()&&t),s){const e=p.W.subscribeKey("open",t=>{t||(f.I.state.view!==s&&f.I.replace(s),e(),c(new Error("Modal closed")))})}const l=d.W.subscribeKey("activeCaipAddress",t=>{t&&(null===a||void 0===a||a(),i&&p.W.close(),l(),e(o.C.parseCaipAddress(t)))})})},connectExternal:e=>new Promise((t,n)=>{const i=d.W.subscribeKey("activeCaipAddress",e=>{e&&(p.W.close(),i(),t(o.C.parseCaipAddress(e)))});k.connectExternal(e,e.chain).catch(()=>{i(),n(new Error("Connection rejected"))})}),connectSocial(e){let{social:t,namespace:n,closeModalOnConnect:s=!0,onOpenFarcaster:a,onConnect:c}=e;const l=d.W.getAccountData(n);let f=null===l||void 0===l?void 0:l.socialWindow,g=null===l||void 0===l?void 0:l.socialProvider,y=!1,w=null;const b=n||d.W.state.activeChain,E=d.W.subscribeKey("activeCaipAddress",e=>{e&&(s&&p.W.close(),E())});
2return new Promise((e,n)=>{async function s(t){var i;if(null!==(i=t.data)&&void 0!==i&&i.resultUri)if(t.origin===r.o.SECURE_SITE_SDK_ORIGIN){window.removeEventListener("message",s,!1);try{const i=h.a.getAuthConnector(b);if(i&&!y){const s=d.W.getAccountData(b);f&&(f.close(),d.W.setAccountProp("socialWindow",void 0,b),f=null===s||void 0===s?void 0:s.socialWindow),y=!0;const r=t.data.resultUri;if(g&&u.E.sendEvent({type:"track",event:"SOCIAL_LOGIN_REQUEST_USER_DATA",properties:{provider:g}}),g){m.i.setConnectedSocialProvider(g),await k.connectExternal({id:i.id,type:i.type,socialUri:r},i.chain);const t=d.W.state.activeCaipAddress;if(!t)return void n(new Error("Failed to connect"));e(o.C.parseCaipAddress(t)),u.E.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",properties:{provider:g}})}}}catch(a){g&&u.E.sendEvent({type:"track",event:"SOCIAL_LOGIN_ERROR",properties:{provider:g,message:v.w.parseError(a)}}),n(new Error("Failed to connect"))}}else g&&u.E.sendEvent({type:"track",event:"SOCIAL_LOGIN_ERROR",properties:{provider:g,message:"Untrusted Origin"}})}!async function(){if(t){const e=d.W.getAccountData(b);d.W.setAccountProp("socialProvider",t,b),g=null===e||void 0===e?void 0:e.socialProvider,u.E.sendEvent({type:"track",event:"SOCIAL_LOGIN_STARTED",properties:{provider:g}})}if("farcaster"===g){null===a||void 0===a||a();const e=p.W.subscribeKey("open",i=>{i||"farcaster"!==t||(n(new Error("Popup closed")),null===c||void 0===c||c(),e())}),i=h.a.getAuthConnector();if(i){const e=d.W.getAccountData(b);if(null===e||void 0===e||!e.farcasterUrl)try{const{url:e}=await i.provider.getFarcasterUri();d.W.setAccountProp("farcasterUrl",e,b)}catch(m){n(new Error("Failed to connect to farcaster"))}}}else{const t=h.a.getAuthConnector();w=v.w.returnOpenHref("".concat(r.o.SECURE_SITE_SDK_ORIGIN,"/loading"),"popupWindow","width=600,height=800,scrollbars=yes");try{if(t&&g){const{uri:r}=await t.provider.getSocialRedirectUri({provider:g});if(w&&r){d.W.setAccountProp("socialWindow",(0,i.KR)(w),b),f=null===l||void 0===l?void 0:l.socialWindow,w.location.href=r;const e=setInterval(()=>{var t;null!==(t=f)&&void 0!==t&&t.closed&&!y&&(n(new Error("Popup closed")),clearInterval(e))},1e3);window.addEventListener("message",s,!1)}else{var e;null===(e=w)||void 0===e||e.close(),n(new Error("Failed to initiate social connection"))}}}catch(E){var o;n(new Error("Failed to initiate social connection")),null===(o=w)||void 0===o||o.close()}}}()})},connectEmail(e){let{closeModalOnConnect:t=!0,redirectViewOnModalClose:n="Connect",onOpen:i,onConnect:s}=e;return new Promise((e,r)=>{if(null===i||void 0===i||i(),n){const e=p.W.subscribeKey("open",t=>{t||(f.I.state.view!==n&&f.I.replace(n),e(),r(new Error("Modal closed")))})}const a=d.W.subscribeKey("activeCaipAddress",n=>{n&&(null===s||void 0===s||s(),t&&p.W.close(),a(),e(o.C.parseCaipAddress(n)))})})},async updateEmail(){var e;const t=m.i.getConnectedConnectorId(d.W.state.activeChain),n=h.a.getAuthConnector();if(!n)throw new Error("No auth connector found");if(t!==r.o.CONNECTOR_ID.AUTH)throw new Error("Not connected to email or social");const i=null!==(e=n.provider.getEmail())&&void 0!==e?e:"";return await p.W.open({view:"UpdateEmailWallet",data:{email:i,redirectView:void 0}}),new Promise((e,t)=>{const s=setInterval(()=>{var t;const o=null!==(t=n.provider.getEmail())&&void 0!==t?t:"";o!==i&&(p.W.close(),clearInterval(s),r(),e({email:o}))},1e3),r=p.W.subscribeKey("open",e=>{e||("Connect"!==f.I.state.view&&f.I.push("Connect"),clearInterval(s),r(),t(new Error("Modal closed")))})})},canSwitchToSmartAccount:e=>d.W.checkIfSmartAccountEnabled()&&(0,a.lj)(e)===l.Vl.ACCOUNT_TYPES.EOA};var w=n(17555),b=n(24107),E=n(87931),C=n(46443),A=n(62463);const I=(0,i.BX)({transactions:[],transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),N={state:I,subscribe:e=>(0,i.B1)(I,()=>e(I)),setLastNetworkInView(e){I.lastNetworkInView=e},async fetchTransactions(e){if(!e)throw new Error("Transactions can't be fetched without an accountAddress");I.loading=!0;try{var t;const n=await E.T.fetchTransactions({account:e,cursor:I.next,chainId:null===(t=d.W.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId}),i=S.filterSpamTransactions(n.data),s=S.filterByConnectedChain(i),r=[...I.transactions,...s];I.loading=!1,I.transactions=r,I.transactionsByYear=S.groupTransactionsByYearAndMonth(I.transactionsByYear,s),I.empty=0===r.length,I.next=n.next?n.next:void 0}catch(n){const t=d.W.state.activeChain;u.E.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:e,projectId:C.H.state.projectId,cursor:I.next,isSmartAccount:(0,a.lj)(t)===l.Vl.ACCOUNT_TYPES.SMART_ACCOUNT}}),A.P.showError("Failed to fetch transactions"),I.loading=!1,I.empty=!0,I.next=void 0}},groupTransactionsByYearAndMonth(){const e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return(arguments.length>
21&&void 0!==arguments[1]?arguments[1]:[]).forEach(t=>{var n,i;const s=new Date(t.metadata.minedAt).getFullYear(),r=new Date(t.metadata.minedAt).getMonth(),o=null!==(n=e[s])&&void 0!==n?n:{},a=(null!==(i=o[r])&&void 0!==i?i:[]).filter(e=>e.id!==t.id);e[s]=(0,b.A)((0,b.A)({},o),{},{[r]:[...a,t].sort((e,t)=>new Date(t.metadata.minedAt).getTime()-new Date(e.metadata.minedAt).getTime())})}),e},filterSpamTransactions:e=>e.filter(e=>!e.transfers.every(e=>{var t;return!0===(null===(t=e.nft_info)||void 0===t?void 0:t.flags.is_spam)})),filterByConnectedChain(e){var t;const n=null===(t=d.W.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId;return e.filter(e=>e.metadata.chain===n)},clearCursor(){I.next=void 0},resetTransactions(){I.transactions=[],I.transactionsByYear={},I.lastNetworkInView=void 0,I.loading=!1,I.empty=!1,I.next=void 0}},S=(0,w.X)(N,"API_ERROR"),_=(0,i.BX)({connections:new Map,recentConnections:new Map,isSwitchingConnection:!1,wcError:!1,buffering:!1,status:"disconnected"});let T;const O={state:_,subscribe:e=>(0,i.B1)(_,()=>e(_)),subscribeKey:(e,t)=>(0,s.u$)(_,e,t),_getClient:()=>_._client,setClient(e){_._client=(0,i.KR)(e)},initialize(e){const t=e.filter(e=>Boolean(e.namespace)).map(e=>e.namespace);k.syncStorageConnections(t)},syncStorageConnections(e){const t=m.i.getConnections(),n=null!==e&&void 0!==e?e:Array.from(d.W.state.chains.keys());for(const s of n){var i;const e=null!==(i=t[s])&&void 0!==i?i:[],n=new Map(_.recentConnections);n.set(s,e),_.recentConnections=n}},getConnections(e){var t;return e&&null!==(t=_.connections.get(e))&&void 0!==t?t:[]},hasAnyConnection(e){const t=k.state.connections;return Array.from(t.values()).flatMap(e=>e).some(t=>{let{connectorId:n}=t;return n===e})},async connectWalletConnect(){let{cache:e="auto"}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=v.w.isTelegram()||v.w.isSafari()&&v.w.isIos();if("always"===e||"auto"===e&&t){var n,i;if(T)return await T,void(T=void 0);if(!v.w.isPairingExpired(null===_||void 0===_?void 0:_.wcPairingExpiry)){const e=_.wcUri;return void(_.wcUri=e)}T=null===(n=k._getClient())||void 0===n||null===(i=n.connectWalletConnect)||void 0===i?void 0:i.call(n).catch(()=>{}),k.state.status="connecting",await T,T=void 0,_.wcPairingExpiry=void 0,k.state.status="connected"}else{var s,r;await(null===(s=k._getClient())||void 0===s||null===(r=s.connectWalletConnect)||void 0===r?void 0:r.call(s))}},async connectExternal(e,t){var n,i;let s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];const r=await(null===(n=k._getClient())||void 0===n||null===(i=n.connectExternal)||void 0===i?void 0:i.call(n,e));return s&&d.W.setActiveNamespace(t),r},async reconnectExternal(e){var t,n;await(null===(t=k._getClient())||void 0===t||null===(n=t.reconnectExternal)||void 0===n?void 0:n.call(t,e));const i=e.chain||d.W.state.activeChain;i&&h.a.setConnectorId(e.id,i)},async setPreferredAccountType(e,t){var n;if(!t)return;p.W.setLoading(!0,d.W.state.activeChain);const i=h.a.getAuthConnector();i&&(d.W.setAccountProp("preferredAccountType",e,t),await i.provider.setPreferredAccount(e),m.i.setPreferredAccountTypes(Object.entries(d.W.state.chains).reduce((e,t)=>{let[n,i]=t;const s=n,r=(0,a.lj)(s);return void 0!==r&&(e[s]=r),e},{})),await k.reconnectExternal(i),p.W.setLoading(!1,d.W.state.activeChain),u.E.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:e,network:(null===(n=d.W.state.activeCaipNetwork)||void 0===n?void 0:n.caipNetworkId)||""}}))},async signMessage(e){var t;return null===(t=k._getClient())||void 0===t?void 0:t.signMessage(e)},parseUnits(e,t){var n;return null===(n=k._getClient())||void 0===n?void 0:n.parseUnits(e,t)},formatUnits(e,t){var n;return null===(n=k._getClient())||void 0===n?void 0:n.formatUnits(e,t)},updateBalance(e){var t;return null===(t=k._getClient())||void 0===t?void 0:t.updateBalance(e)},async sendTransaction(e){var t;return null===(t=k._getClient())||void 0===t?void 0:t.sendTransaction(e)},async getCapabilities(e){var t;return null===(t=k._getClient())||void 0===t?void 0:t.getCapabilities(e)},async grantPermissions(e){var t;return null===(t=k._getClient())||void 0===t?void 0:t.grantPermissions(e)},async walletGetAssets(e){var t,n;return null!==(t=null===(n=k._getClient())||void 0===n?void 0:n.walletGetAssets(e))&&void 0!==t?t:{}},async estimateGas(e){var t;return null===(t=k._getClient())||void 0===t?void 0:t.estimateGas(e)},async writeContract(e){var t;return null===(t=k._getClient())||void 0===t?void 0:t.writeContract(e)},async getEnsAddress(e){var t;return null===(t=k._getClient())||void 0===t?void 0:t.getEnsAddress(e)},async getEnsAvatar(e){var t;return null===(t=k._getClient())||void 0===t?void 0:t.getEnsAvatar(e)},checkInstalled(e){var t,n;return(null===(t=k._getClient())||void 0===t||null===(n=t.checkInstalled)||void 0===n?void 0:n.call(t,e))||!1}
2,resetWcConnection(){_.wcUri=void 0,_.wcPairingExpiry=void 0,_.wcLinking=void 0,_.recentWallet=void 0,_.status="disconnected",S.resetTransactions(),m.i.deleteWalletConnectDeepLink(),m.i.deleteRecentWallet()},resetUri(){_.wcUri=void 0,_.wcPairingExpiry=void 0,T=void 0},finalizeWcConnection(e){const{wcLinking:t,recentWallet:n}=k.state;var i;(t&&m.i.setWalletConnectDeepLink(t),n&&m.i.setAppKitRecent(n),e)&&u.E.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:e,properties:{method:t?"mobile":"qrcode",name:(null===(i=f.I.state.data)||void 0===i||null===(i=i.wallet)||void 0===i?void 0:i.name)||"Unknown",view:f.I.state.view,walletRank:null===n||void 0===n?void 0:n.order}})},setWcBasic(e){_.wcBasic=e},setUri(e){_.wcUri=e,_.wcPairingExpiry=v.w.getPairingExpiry()},setWcLinking(e){_.wcLinking=e},setWcError(e){_.wcError=e,_.buffering=!1},setRecentWallet(e){_.recentWallet=e},setBuffering(e){_.buffering=e},setStatus(e){_.status=e},setIsSwitchingConnection(e){_.isSwitchingConnection=e},async disconnect(){let{id:e,namespace:t,initialDisconnect:n}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{var i;await(null===(i=k._getClient())||void 0===i?void 0:i.disconnect({id:e,chainNamespace:t,initialDisconnect:n}))}catch(s){throw new w.A("Failed to disconnect","INTERNAL_SDK_ERROR",s)}},async disconnectConnector(e){let{id:t,namespace:n}=e;try{var i;await(null===(i=k._getClient())||void 0===i?void 0:i.disconnectConnector({id:t,namespace:n}))}catch(s){throw new w.A("Failed to disconnect connector","INTERNAL_SDK_ERROR",s)}},setConnections(e,t){const n=new Map(_.connections);n.set(t,e),_.connections=n},async handleAuthAccountSwitch(e){var t;let{address:n,namespace:i}=e;const s=d.W.getAccountData(i),r=null===s||void 0===s||null===(t=s.user)||void 0===t||null===(t=t.accounts)||void 0===t?void 0:t.find(e=>"smartAccount"===e.type),o=r&&r.address.toLowerCase()===n.toLowerCase()&&y.canSwitchToSmartAccount(i)?"smartAccount":"eoa";await k.setPreferredAccountType(o,i)},async handleActiveConnection(e){let{connection:t,namespace:n,address:i}=e;const s=h.a.getConnectorById(t.connectorId),o=t.connectorId===r.o.CONNECTOR_ID.AUTH;if(!s)throw new Error("No connector found for connection: ".concat(t.connectorId));if(!o){const e=await k.connectExternal({id:s.id,type:s.type,provider:s.provider,address:i,chain:n},n);return null===e||void 0===e?void 0:e.address}return o&&i&&await k.handleAuthAccountSwitch({address:i,namespace:n}),i},async handleDisconnectedConnection(e){var t;let{connection:n,namespace:i,address:s,closeModalOnConnect:o}=e;const a=h.a.getConnectorById(n.connectorId),c=null===(t=n.auth)||void 0===t||null===(t=t.name)||void 0===t?void 0:t.toLowerCase(),l=n.connectorId===r.o.CONNECTOR_ID.AUTH,d=n.connectorId===r.o.CONNECTOR_ID.WALLET_CONNECT;if(!a)throw new Error("No connector found for connection: ".concat(n.connectorId));let u;if(l)if(c&&y.isSocialProvider(c)){const{address:e}=await y.connectSocial({social:c,closeModalOnConnect:o,onOpenFarcaster(){p.W.open({view:"ConnectingFarcaster"})},onConnect(){f.I.replace("ProfileWallets")}});u=e}else{const{address:e}=await y.connectEmail({closeModalOnConnect:o,onOpen(){p.W.open({view:"EmailLogin"})},onConnect(){f.I.replace("ProfileWallets")}});u=e}else if(d){const{address:e}=await y.connectWalletConnect({walletConnect:!0,connector:a,closeModalOnConnect:o,onOpen(e){const t=e?"AllWallets":"ConnectingWalletConnect";p.W.state.open?f.I.push(t):p.W.open({view:t})},onConnect(){f.I.replace("ProfileWallets")}});u=e}else{const e=await k.connectExternal({id:a.id,type:a.type,provider:a.provider,chain:i},i);e&&(u=e.address)}return l&&s&&await k.handleAuthAccountSwitch({address:s,namespace:i}),u},async switchConnection(e){var t;let n,{connection:i,address:s,namespace:r,closeModalOnConnect:a,onChange:l}=e;const h=null===(t=d.W.getAccountData(r))||void 0===t?void 0:t.caipAddress;if(h){const{address:e}=o.C.parseCaipAddress(h);n=e}const u=c.b.getConnectionStatus(i,r);switch(u){case"connected":case"active":{const e=await k.handleActiveConnection({connection:i,namespace:r,address:s});if(n&&e){const t=e.toLowerCase()!==n.toLowerCase();null===l||void 0===l||l({address:e,namespace:r,hasSwitchedAccount:t,hasSwitchedWallet:"active"===u})}break}case"disconnected":{const e=await k.handleDisconnectedConnection({connection:i,namespace:r,address:s,closeModalOnConnect:a});e&&(null===l||void 0===l||l({address:e,namespace:r,hasSwitchedAccount:!0,hasSwitchedWallet:!0}));break}default:throw new Error("Invalid connection status: ".concat(u))}}},k=(0,w.X)(O)},52415:(e,t,n)=>{"use strict";n.d(t,{createAppKit:()=>De});var i=n(24107),s=n(47482),r=n(10232),o=n(50390),a=n(78854),c=n(46443),l=n(92030),d=n(74500),h=n(84873),u=n(62951),p=n(10394),f=n(87931),g=n(18539),v=n(35574);const m={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0,cosmos:void 0,sui:void 0,stacks:void 0},y=(0,g.BX)({providers:(0,i.A)({},m),providerIds:(0,i.A)({},m)}),w={state:y,subscribeKey:(e,t)=>(0,v.u$)(y,e,t),subscribe:e=>(0,g.B1)(y,()=>{e(y)}),subscribeProviders:e=>(0,g.B1)(y.providers,()=>e(y.providers)),setProvider(e,t){e&&t&&(y.providers[e]=(0,g.KR)(t))},getProvider(e){if(e)return y.providers[e]},setProviderId(e,t){t&&(y.providerIds[e]=t)},getProviderId(e){if(e)return y.providerIds[e]},reset(){y.providers=(0,i.A)({},m),y.providerIds=(0,i.A)({},m)},resetChain(e){y.providers[e]=void 0,y.providerIds[e]=void 0}};var b=n(69968),E=n(81828);const C=2147483648,A={convertEVMChainIdToCoinType(e){if(e>=C)throw new Error("Invalid chainId");return(C|e)>>>0}};var I=n(17555),N=n(28956);const S=(0,g.BX)({suggestions:[],loading:!1}),_={state:S,subscribe:e=>(0,g.B1)(S,()=>e(S)),subscribeKey:(e,t)=>(0,v.u$)(S,e,t),async resolveName(e){try{return await f.T.lookupEnsName(e)}catch(n){var t;throw new Error((null===n||void 0===n||null===(t=n.reasons)||void 0===t||null===(t=t[0])||void 0===t?void 0:t.description)||"Error resolving name")}},async isNameRegistered(e){try{return await f.T.lookupEnsName(e),!0}catch(t){return!1}},async getSuggestions(e){try{S.loading=!0,S.suggestions=[];const t=await f.T.getEnsNameSuggestions(e);return S.suggestions=t.suggestions||[],S.suggestions}catch(t){const e=T.parseEnsApiError(t,"Error fetching name suggestions");throw new Error(e)}finally{S.loading=!1}},async getNamesForAddress(e){try{if(!r.W.state.activeCaipNetwork)return[];
2const t=E.i.getEnsFromCacheForAddress(e);if(t)return t;const n=await f.T.reverseLookupEnsName({address:e});return E.i.updateEnsCache({address:e,ens:n,timestamp:Date.now()}),n}catch(t){const e=T.parseEnsApiError(t,"Error fetching names for address");throw new Error(e)}},async registerName(e){var t;const n=r.W.state.activeCaipNetwork,i=null===(t=r.W.getAccountData(null===n||void 0===n?void 0:n.chainNamespace))||void 0===t?void 0:t.address,a=s.a.getAuthConnector();if(!n)throw new Error("Network not found");if(!i||!a)throw new Error("Address or auth connector not found");S.loading=!0;try{const t=JSON.stringify({name:e,attributes:{},timestamp:Math.floor(Date.now()/1e3)});N.I.pushTransactionStack({onCancel(){N.I.replace("RegisterAccountName")}});const s=await o.x.signMessage(t);S.loading=!1;const a=n.id;if(!a)throw new Error("Network not found");const c=A.convertEVMChainIdToCoinType(Number(a));await f.T.registerEnsName({coinType:c,address:i,signature:s,message:t}),r.W.setAccountProp("profileName",e,n.chainNamespace),E.i.updateEnsCache({address:i,ens:[{name:e,registered_at:(new Date).toISOString(),updated_at:void 0,addresses:{},attributes:[]}],timestamp:Date.now()}),N.I.replace("RegisterAccountNameSuccess")}catch(c){const t=T.parseEnsApiError(c,"Error registering name ".concat(e));throw N.I.replace("RegisterAccountName"),new Error(t)}finally{S.loading=!1}},validateName:e=>/^[\x2D0-9A-Za-z]{4,}$/.test(e),parseEnsApiError(e,t){var n;return(null===e||void 0===e||null===(n=e.reasons)||void 0===n||null===(n=n[0])||void 0===n?void 0:n.description)||t}},T=(0,I.X)(_);var O=n(28577),k=n(4791),P=n(2641),R=n(78256),x=n(13033);const U={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"}]},D={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},L={providers:R.tM,selectedProvider:null,error:null,purchaseCurrency:U,paymentCurrency:D,purchaseCurrencies:[U],paymentCurrencies:[],quotesLoading:!1},W=(0,g.BX)(L),M={state:W,subscribe:e=>(0,g.B1)(W,()=>e(W)),subscribeKey:(e,t)=>(0,v.u$)(W,e,t),setSelectedProvider(e){if(e&&"meld"===e.name){var t,n;const s=r.W.state.activeChain,o=s===h.o.CHAIN.SOLANA?"SOL":"USDC",a=s&&null!==(t=null===(n=r.W.state.chains.get(s))||void 0===n||null===(n=n.accountState)||void 0===n?void 0:n.address)&&void 0!==t?t:"",l=new URL(e.url);l.searchParams.append("publicKey",R.Db),l.searchParams.append("destinationCurrencyCode",o),l.searchParams.append("walletAddress",a),l.searchParams.append("externalCustomerId",c.H.state.projectId),W.selectedProvider=(0,i.A)((0,i.A)({},e),{},{url:l.toString()})}else W.selectedProvider=e},setOnrampProviders(e){if(Array.isArray(e)&&e.every(e=>"string"===typeof e)){const t=e,n=R.tM.filter(e=>t.includes(e.name));W.providers=n}else W.providers=[]},setPurchaseCurrency(e){W.purchaseCurrency=e},setPaymentCurrency(e){W.paymentCurrency=e},setPurchaseAmount(e){B.state.purchaseAmount=e},setPaymentAmount(e){B.state.paymentAmount=e},async getAvailableCurrencies(){const e=await f.T.getOnrampOptions();W.purchaseCurrencies=e.purchaseCurrencies,W.paymentCurrencies=e.paymentCurrencies,W.paymentCurrency=e.paymentCurrencies[0]||D,W.purchaseCurrency=e.purchaseCurrencies[0]||U,await x.N.fetchCurrencyImages(e.paymentCurrencies.map(e=>e.id)),await x.N.fetchTokenImages(e.purchaseCurrencies.map(e=>e.symbol))},async getQuote(){W.quotesLoading=!0;try{var e,t;const n=await f.T.getOnrampQuote({purchaseCurrency:W.purchaseCurrency,paymentCurrency:W.paymentCurrency,amount:(null===(e=W.paymentAmount)||void 0===e?void 0:e.toString())||"0",network:null===(t=W.purchaseCurrency)||void 0===t?void 0:t.symbol});return W.quotesLoading=!1,W.purchaseAmount=Number(null===n||void 0===n?void 0:n.purchaseAmount.amount),n}catch(n){return W.error=n.message,W.quotesLoading=!1,null}finally{W.quotesLoading=!1}},resetState(){W.selectedProvider=null,W.error=null,W.purchaseCurrency=U,W.paymentCurrency=D,W.purchaseCurrencies=[U],W.paymentCurrencies=[],W.paymentAmount=void 0,W.purchaseAmount=void 0,W.quotesLoading=!1}},B=(0,I.X)(M);var F=n(23976),j=n(26828),H=n(74520),q=n(16788),V=n(67666),K=n(50067),z=n(62463),$=n(92187),G=(n(11217),n(37159)),J=n(67531),Y=n(87999),X=n(27142);const Z={extractVersion(e){var t;if(!e||"string"!==typeof e)return null;const n=(0,Y.A)(/(?:[<->\^~]+[\t-\r \xA0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]*)?([0-9]+(?:\.[0-9]+){0,2})(?:-[A-Za-z]+\.[0-9]+)?/,{version:1}),i=e.match(n);return(null===i||void 0===i||null===(t=i.groups)||void 0===t?void 0:t.ver
2sion)||null},checkSDKVersion(e){const t=this.extractVersion(e),n=h.o.IS_DEVELOPMENT;if(!t||!n)return;const i=E.i.getLatestAppKitVersion();if(this.isValidVersion(i)&&this.isOlder(t,i))console.warn(X.o.getSDKVersionWarningMessage(t,i));else try{fetch("https://registry.npmjs.org/@reown/appkit/latest").then(e=>e.json()).then(e=>{const n=e.version;this.isOlder(t,n)&&(E.i.updateLatestAppKitVersion({timestamp:Date.now(),version:n}),console.warn(X.o.getSDKVersionWarningMessage(t,n)))})}catch(s){}},isValidVersion:e=>"string"===typeof e&&/^[0-9]+\.[0-9]+\.[0-9]+$/.test(e),isOlder(e,t){const n=this.extractVersion(e),i=this.extractVersion(t);if(!n||!i)return!1;function s(e){const t=e.split(".").map(Number);for(;t.length<3;)t.push(0);return t}const r=s(n),o=s(i);for(let a=0;a<Math.max(r.length,o.length);a+=1){const e=r[a]||0,t=o[a]||0;if(e<t)return!0;if(e>t)return!1}return!1}};const Q={network:"eip155:8453",asset:"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",metadata:{name:"USD Coin",symbol:"USDC",decimals:6}};const ee={TOKEN_ADDRESSES_BY_SYMBOL:{USDC:{8453:Q.asset,84532:"0x036CbD53842c5426634e7929541eC2318f3dCF7e"}},getTokenSymbolByAddress(e){var t;if(!e)return;const[n]=null!==(t=Object.entries(ee.TOKEN_ADDRESSES_BY_SYMBOL).find(t=>{let[n,i]=t;return Object.values(i).includes(e)}))&&void 0!==t?t:[];return n}};var te=n(76007);const ne={EmbeddedWalletAbortController:new AbortController,UniversalProviderErrors:{UNAUTHORIZED_DOMAIN_NOT_ALLOWED:{message:"Unauthorized: origin not allowed",alertErrorKey:"ORIGIN_NOT_ALLOWED"},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:{code:"APKT001",displayMessage:"Network Not Found",debugMessage:"The specified network is not recognized. Please ensure it is included in the `networks` array of your `createAppKit` configuration."},ORIGIN_NOT_ALLOWED:{code:"APKT002",displayMessage:"Invalid App Configuration",debugMessage:()=>"The origin ".concat((0,te.IP)()?window.origin:"unknown"," is not in your allow list. Please update your allowed domains at https://dashboard.reown.com.")},IFRAME_LOAD_FAILED:{code:"APKT003",displayMessage:"Network Error: Wallet Load Failed",debugMessage:()=>"Failed to load the embedded wallet. This may be due to network issues or server downtime. Please check your network connection and try again shortly. Contact support if the issue persists."},IFRAME_REQUEST_TIMEOUT:{code:"APKT004",displayMessage:"Wallet Request Timeout",debugMessage:()=>"The request to the embedded wallet timed out. Please check your network connection and try again shortly. Contact support if the issue persists."},UNVERIFIED_DOMAIN:{code:"APKT005",displayMessage:"Unverified Domain",debugMessage:()=>"Embedded wallet load failed. Ensure your domain is verified in https://dashboard.reown.com."},JWT_TOKEN_NOT_VALID:{code:"APKT006",displayMessage:"Session Expired",debugMessage:"Your session is invalid or expired. Please check your system\u2019s date and time settings, then reconnect."},INVALID_PROJECT_ID:{code:"APKT007",displayMessage:"Invalid Project ID",debugMessage:"The specified project ID is invali
2d. Please visit https://dashboard.reown.com to obtain a valid project ID."},PROJECT_ID_NOT_CONFIGURED:{code:"APKT008",displayMessage:"Project ID Missing",debugMessage:"No project ID is configured. You can create and configure a project ID at https://dashboard.reown.com."},SERVER_ERROR_APP_CONFIGURATION:{code:"APKT009",displayMessage:"Server Error",debugMessage:e=>"Unable to fetch App Configuration. ".concat(e,". Please check your network connection and try again shortly. Contact support if the issue persists.")},RATE_LIMITED_APP_CONFIGURATION:{code:"APKT010",displayMessage:"Rate Limited",debugMessage:"You have been rate limited while retrieving App Configuration. Please wait a few minutes and try again. Contact support if the issue persists."}},ALERT_WARNINGS:{LOCAL_CONFIGURATION_IGNORED:{debugMessage:e=>"[Reown Config Notice] ".concat(e)},INACTIVE_NAMESPACE_NOT_CONNECTED:{code:"APKTW001",displayMessage:"Inactive Namespace Not Connected",debugMessage:(e,t)=>"An error occurred while connecting an inactive namespace ".concat(e,': "').concat(t,'"')},INVALID_EMAIL:{code:"APKTW002",displayMessage:"Invalid Email Address",debugMessage:"Please enter a valid email address"}}};var ie=n(39377),se=n(89386),re=n(30911);const oe={createLogger(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"error";const n=(0,re.iP)({level:t}),{logger:i}=(0,re.D5)({opts:n});return i.error=function(){for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];for(const s of n)if(s instanceof Error)return void e(s,...n);e(void 0,...n)},i}};var ae=n(5890),ce=n(652),le=n(48670),de=n(23579);const he={hexStringToNumber(e){const t=e.startsWith("0x")?e.slice(2):e;return parseInt(t,16)},numberToHexString:e=>"0x".concat(e.toString(16)),async getUserInfo(e){const[t,n]=await Promise.all([he.getAddresses(e),he.getChainId(e)]);return{chainId:n,addresses:t}},async getChainId(e){const t=await e.request({method:"eth_chainId"});return Number(t)},async getAddress(e){const[t]=await e.request({method:"eth_accounts"});return t},getAddresses:async e=>await e.request({method:"eth_accounts"}),async addEthereumChain(e,t){var n,i;const s=(null===(n=t.rpcUrls.chainDefault)||void 0===n?void 0:n.http)||[];await e.request({method:"wallet_addEthereumChain",params:[{chainId:he.numberToHexString(t.id),rpcUrls:[...s],chainName:t.name,nativeCurrency:{name:t.nativeCurrency.name,decimals:t.nativeCurrency.decimals,symbol:t.nativeCurrency.symbol},blockExplorerUrls:[null===(i=t.blockExplorers)||void 0===i?void 0:i.default.url],iconUrls:[de.L.NetworkImageIds[t.id]]}]})}},ue={PAYMENT:0,ORDINAL:1};function pe(e){return(0,i.A)({formatters:void 0,fees:void 0,serializers:void 0},e)}const fe=pe({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"}),ge=pe({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"}),ve=(pe({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"}),pe({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}}),pe({id:"000000000933ea01ad0ee984209779ba",caipNetworkId:"bip122:000000000933ea01ad0ee984209779ba",chainNamespace:"bip122",name:"Bitcoin Testnet",n
2ativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},testnet:!0}),pe({id:"00000008819873e925422c1ff0f99f7c",caipNetworkId:"bip122:00000008819873e925422c1ff0f99f7c",chainNamespace:"bip122",name:"Bitcoin Signet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},testnet:!0}),{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"]}),me={RPC_ERROR_CODE:{USER_REJECTED:5e3,USER_REJECTED_METHODS:5002},getMethodsByChainNamespace:e=>ve[e]||[],createDefaultNamespace(e){return{methods:this.getMethodsByChainNamespace(e),events:["accountsChanged","chainChanged"],chains:[],rpcMap:{}}},applyNamespaceOverrides(e,t){if(!t)return(0,i.A)({},e);const n=(0,i.A)({},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=>{n[e]||(n[e]=this.createDefaultNamespace(e))}),t.methods&&Object.entries(t.methods).forEach(e=>{let[t,i]=e;n[t]&&(n[t].methods=i)}),t.chains&&Object.entries(t.chains).forEach(e=>{let[t,i]=e;n[t]&&(n[t].chains=i)}),t.events&&Object.entries(t.events).forEach(e=>{let[t,i]=e;n[t]&&(n[t].events=i)}),t.rpcMap){const e=new Set;Object.entries(t.rpcMap).forEach(t=>{let[i,s]=t;const[r,o]=i.split(":");r&&o&&n[r]&&(n[r].rpcMap||(n[r].rpcMap={}),e.has(r)||(n[r].rpcMap={},e.add(r)),n[r].rpcMap[o]=s)})}return n},createNamespaces(e,t){const n=e.reduce((e,t)=>{const{id:n,chainNamespace:i,rpcUrls:s}=t,r=s.default.http[0];e[i]||(e[i]=this.createDefaultNamespace(i));const o="".concat(i,":").concat(n),a=e[i];switch(a.chains.push(o),o){case fe.caipNetworkId:a.chains.push(fe.deprecatedCaipNetworkId);break;case ge.caipNetworkId:a.chains.push(ge.deprecatedCaipNetworkId)}return null!==a&&void 0!==a&&a.rpcMap&&r&&(a.rpcMap[n]=r),e},{});return this.applyNamespaceOverrides(n,t)},resolveReownName:async e=>{var t;const n=await T.resolveName(e);return(null===(t=(Object.values(null===n||void 0===n?void 0:n.addresses)||[])[0])||void 0===t?void 0:t.address)||!1},getChainsFromNamespaces(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.values(e).flatMap(e=>{const t=e.chains||[],n=e.accounts.map(e=>{const[t,n]=e.split(":");return"".concat(t,":").concat(n)});return Array.from(new Set([...t,...n]))})},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,isUserRejectedRequestError(e){try{if("object"===typeof e&&null!==e){const t=e,n="number"===typeof t.code,i=n&&t.code===me.RPC_ERROR_CODE.USER_REJECTED_METHODS,s=n&&t.code===me.RPC_ERROR_CODE.USER_REJECTED;return i||s}return!1}catch(t){return!1}},isOriginAllowed(e,t,n){for(const s of[...t,...n])if(s.includes("*")){const t=s.replace(/[\$\(-\+\.\?\[-\^\{-\}]/g,"\\$&"),n="^".concat(t.replace(/\\\*/g,".*"),"$");if(new RegExp(n,"u").test(e))return!0}else try{if(new URL(s).origin===e)return!0}catch(i){if(s===e)return!0}return!1},listenWcProvider(e){let{universalProvider:t,namespace:n,onConnect:i,onDisconnect:s,onAccountsChanged:r,onChainChanged:o,onDisplayUri:a}=e;i&&t.on("connect",()=>{const e=me.getWalletConnectAccounts(t,n);i(e)}),s&&t.on("disconnect",()=>{s()}),r&&t.on("accountsChanged",e=>{try{var i,s;const o=(null===(i=t.session)||void 0===i||null===(i=i.namespaces)||void 0===i||null===(i=i[n])||void 0===i?void 0:i.accounts)||[],a=null===(s=t.rpcProviders)||void 0===s||null===(s=s[n])||void 0===s?void 0:s.getDefaultChain(),c=e.map(e=>{const t=o.find(t=>t.includes("".concat(n,":").concat(a,":").concat(e)));if(!t)return;const{chainId:i,chainNamespace:s}=u.C.parseCaipAddress(t);return{address:e,chainId:i,chainNamespace:s}}).filter(e=>void 0!==e);c.length>0&&r(c)}catch(o){console.warn("Failed to parse accounts for namespace on accountsChanged event",n,e,o)}}),o&&t.on("chainChanged",e=>{o(e)}),a&&t.on("display_uri",e=>{a(e)})},getWalletConnectAccounts(e,t){var n;const i=new Set,s=null===e||void 0===e||null===(n=e.session)||void 0===n||null===(n=n.namespaces)||void 0===n||null===(n=n[t])||void 0===n||null===(n=n.accounts)||void 0===n?void 0:n.map(e=>u.C.parseCaipAddress(e)).filter(e=>{let{address:t}=e;return!i.has(t.toLowerCase())&&(i.add(t.toLowerCase()),!0)});return s&&s.length>0?s:[]}};class ye{constructor(e){this.namespace=e.namespace}async syncConnections(e){switch(this.namespace){case h.o.CHAIN.EVM:await this.syncEVMConnections(e);break;case h.o.CHAIN.SOLANA:await this.syncSolanaConnections(e);break;case h.o.CHAIN.BITCOIN:await this.syncBitcoinConnections(e);break;default:throw new Error("Unsupported chain namespace: ".concat(this.namespace))}}
2async syncEVMConnections(e){let{connectors:t,caipNetworks:n,universalProvider:i,onConnection:s,onListenProvider:r}=e;await Promise.all(t.filter(e=>{const{hasDisconnected:t,hasConnected:n}=se.y.getConnectorStorageInfo(e.id,this.namespace);return!t&&n}).map(async e=>{if(e.id===h.o.CONNECTOR_ID.WALLET_CONNECT){const t=me.getWalletConnectAccounts(i,this.namespace),r=n.find(e=>{var n;return e.chainNamespace===this.namespace&&e.id.toString()===(null===(n=t[0])||void 0===n||null===(n=n.chainId)||void 0===n?void 0:n.toString())});t.length>0&&s({connectorId:e.id,accounts:t.map(e=>({address:e.address})),caipNetwork:r})}else{const{accounts:t,chainId:i}=await $.g.fetchProviderData(e);if(t.length>0&&i){const o=n.find(e=>e.chainNamespace===this.namespace&&e.id.toString()===i.toString());s({connectorId:e.id,accounts:t.map(e=>({address:e})),caipNetwork:o}),e.provider&&e.id!==h.o.CONNECTOR_ID.AUTH&&e.id!==h.o.CONNECTOR_ID.WALLET_CONNECT&&r(e.id,e.provider)}}}))}async syncSolanaConnections(e){let{connectors:t,caipNetwork:n,universalProvider:i,onConnection:s,onListenProvider:r}=e;await Promise.all(t.filter(e=>{const{hasDisconnected:t,hasConnected:n}=se.y.getConnectorStorageInfo(e.id,this.namespace);return!t&&n}).map(async e=>{if(e.id===h.o.CONNECTOR_ID.WALLET_CONNECT){const t=me.getWalletConnectAccounts(i,this.namespace);t.length>0&&s({connectorId:e.id,accounts:t.map(e=>({address:e.address})),caipNetwork:n})}else{const t=await e.connect({chainId:null===n||void 0===n?void 0:n.id});t&&(s({connectorId:e.id,accounts:[{address:t}],caipNetwork:n}),r(e.id,e.provider))}}))}async syncBitcoinConnections(e){let{connectors:t,caipNetwork:n,universalProvider:i,onConnection:s,onListenProvider:r}=e;await Promise.all(t.filter(e=>{const{hasDisconnected:t,hasConnected:n}=se.y.getConnectorStorageInfo(e.id,this.namespace);return!t&&n}).map(async e=>{if(e.id===h.o.CONNECTOR_ID.WALLET_CONNECT){const t=me.getWalletConnectAccounts(i,this.namespace);return void(t.length>0&&s({connectorId:e.id,accounts:t.map(e=>({address:e.address})),caipNetwork:n}))}const t=await e.connect(),o=await e.getAccountAddresses();let c=null===o||void 0===o?void 0:o.map(e=>a.w.createAccount(h.o.CHAIN.BITCOIN,e.address,e.purpose||"payment",e.publicKey,e.path));var l,d,u,p,f,g,v,m,y,w,b,E;c&&c.length>1&&(c=[{namespace:h.o.CHAIN.BITCOIN,publicKey:null!==(l=null===(d=c[ue.PAYMENT])||void 0===d?void 0:d.publicKey)&&void 0!==l?l:"",path:null!==(u=null===(p=c[ue.PAYMENT])||void 0===p?void 0:p.path)&&void 0!==u?u:"",address:null!==(f=null===(g=c[ue.PAYMENT])||void 0===g?void 0:g.address)&&void 0!==f?f:"",type:"payment"},{namespace:h.o.CHAIN.BITCOIN,publicKey:null!==(v=null===(m=c[ue.ORDINAL])||void 0===m?void 0:m.publicKey)&&void 0!==v?v:"",path:null!==(y=null===(w=c[ue.ORDINAL])||void 0===w?void 0:w.path)&&void 0!==y?y:"",address:null!==(b=null===(E=c[ue.ORDINAL])||void 0===E?void 0:E.address)&&void 0!==b?b:"",type:"ordinal"}]);if(!(e.chains.find(e=>e.id===(null===n||void 0===n?void 0:n.id))||e.chains[0]))throw new Error("The connector does not support any of the requested chains");t&&(r(e.id,e.provider),s({connectorId:e.id,accounts:c.map(e=>({address:e.address,type:e.type,publicKey:e.publicKey,path:e.path})),caipNetwork:n}))}))}getConnection(e){let{address:t,connectorId:n,connections:s,connectors:r}=e;if(n){const e=s.find(e=>se.y.isLowerCaseMatch(e.connectorId,n));if(!e)return null;const o=r.find(t=>se.y.isLowerCaseMatch(t.id,e.connectorId)),a=t?e.accounts.find(e=>se.y.isLowerCaseMatch(e.address,t)):e.accounts[0];return(0,i.A)((0,i.A)({},e),{},{account:a,connector:o})}const o=s.find(e=>e.accounts.length>0&&r.some(t=>se.y.isLowerCaseMatch(t.id,e.connectorId)));if(o){const[e]=o.accounts,t=r.find(e=>se.y.isLowerCaseMatch(e.id,o.connectorId));return(0,i.A)((0,i.A)({},o),{},{account:e,connector:t})}return null}}const we=4902,be=5e3,Ee=32603,Ce=["http://localhost:*","https://localhost:*","http://127.0.0.1:*","https://127.0.0.1:*","https://*.pages.dev","https://*.vercel.app","https://*.ngrok-free.app","https://secure-mobile.walletconnect.com","https://secure-mobile.walletconnect.org"];class Ae{constructor(e){let{provider:t,namespace:n}=e;this.id=h.o.CONNECTOR_ID.WALLET_CONNECT,this.name=de.L.ConnectorNamesMap[h.o.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=de.L.ConnectorImageIds[h.o.CONNECTOR_ID.WALLET_CONNECT],this.getCaipNetworks=r.W.getCaipNetworks.bind(r.W),this.caipNetworks=this.getCaipNetworks(),this.provider=t,this.chain=n}get chains(){return this.getCaipNetworks()}async connectWalletConnect(){if(!await this.authenticate()){const e=this.getCaipNetworks(),t=c.H.state.universalProviderConfigOverride,n=me.createNamespaces(e,t);await this.provider.connect({optionalNamespaces:n})}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 V.U.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:Ie})}}const Ie=["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"],Ne=[h.o.CONNECTOR_ID.AUTH,h.o.CONNECTOR_ID.WALLET_CONNECT];class Se{constructor(e){this.availableConnectors=[],this.availableConnections=[],this.providerHandlers={},this.eventListeners=new Map,this.getCaipNetworks=e=>r.W.getCaipNetworks(e),this.getConnectorId=e=>s.a.getConnectorId(e),e&&this.construct(e),null!==e&&void 0!==e&&e.namespace&&(this.connectionManager=new ye({namespace:e.namespace}))}construct(e){this.projectId=e.projectId,this.namespace=e.namespace,this.adapterType=e.adapterType}get connectors(){return this.availableConnectors}get connections(){return this.availableConnections}get networks(){return this.getCaipNetworks(this.namespace)}onAuthConnected(e){let{accounts:t,chainId:n}=e;const i=this.getCaipNetworks().filter(e=>e.chainNamespace===this.namespace).find(e=>e.id.toString()===(null===n||void 0===n?void 0:n.toString()));t&&i&&this.addConnection({connectorId:h.o.CONNECTOR_ID.AUTH,accounts:t,caipNetwork:i})}setAuthProvider(e){e.onConnect(this.onAuthConnected.bind(this)),e.onSocialConnected(this.onAuthConnected.bind(this)),this.addConnector({id:h.o.CONNECTOR_ID.AUTH,type:"AUTH",
2name:h.o.CONNECTOR_NAMES.AUTH,provider:e,imageId:de.L.ConnectorImageIds[h.o.CONNECTOR_ID.AUTH],chain:this.namespace,chains:[]})}addConnector(){const e=new Set;for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];this.availableConnectors=[...n,...this.availableConnectors].filter(t=>!e.has(t.id)&&(e.add(t.id),!0)),this.emit("connectors",this.availableConnectors)}addConnection(){const e=new Set;for(var t=arguments.length,n=new Array(t),i=0;i<t;i++)n[i]=arguments[i];this.availableConnections=[...n,...this.availableConnections].filter(t=>!e.has(t.connectorId.toLowerCase())&&(e.add(t.connectorId.toLowerCase()),!0)),this.emit("connections",this.availableConnections)}deleteConnection(e){this.availableConnections=this.availableConnections.filter(t=>!se.y.isLowerCaseMatch(t.connectorId,e)),this.emit("connections",this.availableConnections)}clearConnections(){let e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];this.availableConnections=[],e&&this.emit("connections",this.availableConnections)}setStatus(e,t){r.W.setAccountProp("status",e,t)}on(e,t){var n;this.eventListeners.has(e)||this.eventListeners.set(e,new Set),null===(n=this.eventListeners.get(e))||void 0===n||n.add(t)}off(e,t){const n=this.eventListeners.get(e);n&&n.delete(t)}removeAllEventListeners(){this.eventListeners.forEach(e=>{e.clear()})}emit(e,t){const n=this.eventListeners.get(e);n&&n.forEach(e=>e(t))}async connectWalletConnect(e){try{const e=this.getWalletConnectConnector();return{clientId:(await e.connectWalletConnect()).clientId}}catch(t){if(me.isUserRejectedRequestError(t))throw new le.vx(t);throw t}}async switchNetwork(e){const{caipNetwork:t,providerType:n}=e;if(!e.provider)return;const i="provider"in e.provider?e.provider.provider:e.provider;if("WALLET_CONNECT"!==n){if(i&&"AUTH"===n){const e=i,n=(0,b.lj)(t.chainNamespace);await e.switchNetwork({chainId:t.caipNetworkId});const s=await e.getUser({chainId:t.caipNetworkId,preferredAccountType:n});this.emit("switchNetwork",s)}}else i.setDefaultChain(t.caipNetworkId)}getWalletConnectConnector(){const e=this.connectors.find(e=>e instanceof Ae);if(!e)throw new Error("WalletConnectConnector not found");return e}onConnect(e,t){if(e.length>0){const{address:n,chainId:i}=a.w.getAccount(e[0]),s=this.getCaipNetworks().filter(e=>e.chainNamespace===this.namespace).find(e=>e.id.toString()===(null===i||void 0===i?void 0:i.toString())),r=this.connectors.find(e=>e.id===t);n&&(this.emit("accountChanged",{address:n,chainId:i,connector:r}),this.addConnection({connectorId:t,accounts:e.map(e=>{const{address:t}=a.w.getAccount(e);return{address:t}}),caipNetwork:s}))}}onAccountsChanged(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(e.length>0){var i;const{address:n}=a.w.getAccount(e[0]),r=null===(i=this.connectionManager)||void 0===i?void 0:i.getConnection({connectorId:t,connections:this.connections,connectors:this.connectors});var s;if(n&&se.y.isLowerCaseMatch(this.getConnectorId(h.o.CHAIN.EVM),t))this.emit("accountChanged",{address:n,chainId:null===r||void 0===r||null===(s=r.caipNetwork)||void 0===s?void 0:s.id,connector:null===r||void 0===r?void 0:r.connector});this.addConnection({connectorId:t,accounts:e.map(e=>{const{address:t}=a.w.getAccount(e);return{address:t}}),caipNetwork:null===r||void 0===r?void 0:r.caipNetwork})}else n&&this.onDisconnect(t)}onDisconnect(e){this.removeProviderListeners(e),this.deleteConnection(e),se.y.isLowerCaseMatch(this.getConnectorId(h.o.CHAIN.EVM),e)&&this.emitFirstAvailableConnection(),0===this.connections.length&&this.emit("disconnect")}onChainChanged(e,t){var n;const i="string"===typeof e&&e.startsWith("0x")?he.hexStringToNumber(e).toString():e.toString(),s=null===(n=this.connectionManager)||void 0===n?void 0:n.getConnection({connectorId:t,connections:this.connections,connectors:this.connectors}),r=this.getCaipNetworks().filter(e=>e.chainNamespace===this.namespace).find(e=>e.id.toString()===i);s&&this.addConnection({connectorId:t,accounts:s.accounts,caipNetwork:r}),se.y.isLowerCaseMatch(this.getConnectorId(h.o.CHAIN.EVM),t)&&this.emit("switchNetwork",{chainId:i})}
2listenProviderEvents(e,t){if(Ne.includes(e))return;const n=t=>this.onAccountsChanged(t,e),i=t=>this.onChainChanged(t,e),s=()=>this.onDisconnect(e);this.providerHandlers[e]||(t.on("disconnect",s),t.on("accountsChanged",n),t.on("chainChanged",i),this.providerHandlers[e]={provider:t,disconnect:s,accountsChanged:n,chainChanged:i})}removeProviderListeners(e){if(this.providerHandlers[e]){const{provider:t,disconnect:n,accountsChanged:i,chainChanged:s}=this.providerHandlers[e];t.removeListener("disconnect",n),t.removeListener("accountsChanged",i),t.removeListener("chainChanged",s),this.providerHandlers[e]=null}}emitFirstAvailableConnection(){var e;const t=null===(e=this.connectionManager)||void 0===e?void 0:e.getConnection({connections:this.connections,connectors:this.connectors});if(t){var n;const[e]=t.accounts;this.emit("accountChanged",{address:null===e||void 0===e?void 0:e.address,chainId:null===(n=t.caipNetwork)||void 0===n?void 0:n.id,connector:t.connector})}}}class _e extends Se{async setUniversalProvider(e){if(!this.namespace)throw new Error("UniversalAdapter:setUniversalProvider - namespace is required");return this.addConnector(new Ae({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace})),Promise.resolve()}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(),this.emit("disconnect")}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}return{connections:[]}}syncConnections(){return Promise.resolve()}async getAccounts(e){var t;let{namespace:n}=e;const i=this.provider,s=(null===i||void 0===i||null===(t=i.session)||void 0===t||null===(t=t.namespaces)||void 0===t||null===(t=t[n])||void 0===t||null===(t=t.accounts)||void 0===t?void 0:t.map(e=>{const[,,t]=e.split(":");return t}).filter((e,t,n)=>n.indexOf(e)===t))||[];return Promise.resolve({accounts:s.map(e=>a.w.createAccount(n,e,"bip122"===n?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var t,n,i,s;var o;if(!(e.caipNetwork&&R.oU.BALANCE_SUPPORTED_CHAINS.includes(null===(t=e.caipNetwork)||void 0===t?void 0:t.chainNamespace))||null!==(n=e.caipNetwork)&&void 0!==n&&n.testnet)return{balance:"0.00",symbol:(null===(o=e.caipNetwork)||void 0===o?void 0:o.nativeCurrency.symbol)||""};const a=r.W.getAccountData();if(null!==a&&void 0!==a&&a.balanceLoading&&e.chainId===(null===(i=r.W.state.activeCaipNetwork)||void 0===i?void 0:i.id))return{balance:(null===a||void 0===a?void 0:a.balance)||"0.00",symbol:(null===a||void 0===a?void 0:a.balanceSymbol)||""};const c=(await r.W.fetchTokenBalance()).find(t=>{var n,i;return t.chainId==="".concat(null===(n=e.caipNetwork)||void 0===n?void 0:n.chainNamespace,":").concat(e.chainId)&&t.symbol===(null===(i=e.caipNetwork)||void 0===i?void 0:i.nativeCurrency.symbol)});return{balance:(null===c||void 0===c?void 0:c.quantity.numeric)||"0.00",symbol:(null===c||void 0===c?void 0:c.symbol)||(null===(s=e.caipNetwork)||void 0===s?void 0:s.nativeCurrency.symbol)||""}}async signMessage(e){var t;const{provider:n,message:i,address:s}=e;if(!n)throw new Error("UniversalAdapter:signMessage - provider is undefined");let o="";if((null===(t=r.W.state.activeCaipNetwork)||void 0===t?void 0:t.chainNamespace)===h.o.CHAIN.SOLANA){var a;o=(await n.request({method:"solana_signMessage",params:{message:ae.A.encode((new TextEncoder).encode(i)),pubkey:s}},null===(a=r.W.state.activeCaipNetwork)||void 0===a?void 0:a.caipNetworkId)).signature}else{var c;o=await n.request({method:"personal_sign",params:[i,s]},null===(c=r.W.state.activeCaipNetwork)||void 0===c?void 0:c.caipNetworkId)}return{signature:o}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}emitFirstAvailableConnection(){}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,n=this.getWalletConnectConnector();if(t.chainNamespace===h.o.CHAIN.EVM)try{var i;await(null===(i=n.provider)||void 0===i?void 0:i.request({method:"wallet_switchEthereumChain",params:[{chainId:(0,ce.nj)(t.id)}]}))}catch(c){var s;
2if(c.code===we||c.code===Ee||c.code===be||(null===c||void 0===c||null===(s=c.data)||void 0===s||null===(s=s.originalError)||void 0===s?void 0:s.code)===we)try{var r,o,a;await(null===(r=n.provider)||void 0===r?void 0:r.request({method:"wallet_addEthereumChain",params:[{chainId:(0,ce.nj)(t.id),rpcUrls:[null===t||void 0===t||null===(o=t.rpcUrls.chainDefault)||void 0===o?void 0:o.http],chainName:t.name,nativeCurrency:t.nativeCurrency,blockExplorerUrls:[null===(a=t.blockExplorers)||void 0===a?void 0:a.default.url]}]}))}catch(l){throw new Error("Chain is not supported")}}n.provider.setDefaultChain(t.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(e=>"WALLET_CONNECT"===e.type);return null===e||void 0===e?void 0:e.provider}}const Te=["email","socials","swaps","onramp","activity","reownBranding","multiWallet","emailCapture","payWithExchange","payments","reownAuthentication"],Oe={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:e=>{if(null===e||void 0===e||!e.config)return!1;const t=e.config;return Boolean(e.isEnabled)&&t.includes("email")},processFallback:e=>void 0===e?R.oU.DEFAULT_REMOTE_FEATURES.email:Boolean(e)},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:e=>{if(null===e||void 0===e||!e.config)return!1;const t=e.config;return!!(Boolean(e.isEnabled)&&t.length>0)&&t.filter(e=>"email"!==e)},processFallback:e=>void 0===e?R.oU.DEFAULT_REMOTE_FEATURES.socials:"boolean"===typeof e?!!e&&R.oU.DEFAULT_REMOTE_FEATURES.socials:e},swaps:{apiFeatureName:"swap",localFeatureName:"swaps",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:e=>{if(null===e||void 0===e||!e.config)return!1;const t=e.config;return!!(Boolean(e.isEnabled)&&t.length>0)&&t},processFallback:e=>void 0===e?R.oU.DEFAULT_REMOTE_FEATURES.swaps:"boolean"===typeof e?!!e&&R.oU.DEFAULT_REMOTE_FEATURES.swaps:e},onramp:{apiFeatureName:"onramp",localFeatureName:"onramp",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:e=>{if(null===e||void 0===e||!e.config)return!1;const t=e.config;return!!(Boolean(e.isEnabled)&&t.length>0)&&t},processFallback:e=>void 0===e?R.oU.DEFAULT_REMOTE_FEATURES.onramp:"boolean"===typeof e?!!e&&R.oU.DEFAULT_REMOTE_FEATURES.onramp:e},activity:{apiFeatureName:"activity",localFeatureName:"history",returnType:!1,isLegacy:!0,isAvailableOnBasic:!1,processApi:e=>Boolean(e.isEnabled),processFallback:e=>void 0===e?R.oU.DEFAULT_REMOTE_FEATURES.activity:Boolean(e)},reownBranding:{apiFeatureName:"reown_branding",localFeatureName:"reownBranding",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:e=>Boolean(e.isEnabled),processFallback:e=>void 0===e?R.oU.DEFAULT_REMOTE_FEATURES.reownBranding:Boolean(e)},emailCapture:{apiFeatureName:"email_capture",localFeatureName:"emailCapture",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:e=>{var t;return e.isEnabled&&(null!==(t=e.config)&&void 0!==t?t:[])},processFallback:e=>!1},multiWallet:{apiFeatureName:"multi_wallet",localFeatureName:"multiWallet",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:e=>Boolean(e.isEnabled),processFallback:()=>R.oU.DEFAULT_REMOTE_FEATURES.multiWallet},payWithExchange:{apiFeatureName:"fund_from_exchange",localFeatureName:"payWithExchange",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:e=>Boolean(e.isEnabled),processFallback:()=>R.oU.DEFAULT_REMOTE_FEATURES.payWithExchange},payments:{apiFeatureName:"payments",localFeatureName:"payments",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:e=>Boolean(e.isEnabled),processFallback:()=>R.oU.DEFAULT_REMOTE_FEATURES.payments},reownAuthentication:{apiFeatureName:"reown_authentication",localFeatureName:"reownAuthentication",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:e=>Boolean(e.isEnabled),processFallback:e=>"undefined"===typeof e?R.oU.DEFAULT_REMOTE_FEATURES.reownAuthentication:Boolean(e)}},ke={localSettingsOverridden:new Set,getApiConfig:(e,t)=>null===t||void 0===t?void 0:t.find(t=>t.id===e),addWarning(e,t){if(void 0!==e){const e=Oe[t],n=e.isLegacy?'"features.'.concat(e.localFeatureName,'"
2(now "').concat(t,'")'):'"features.'.concat(t,'"');this.localSettingsOverridden.add(n)}},processFeature(e,t,n,i,s){const r=Oe[e],o=t[r.localFeatureName];if(s&&!r.isAvailableOnBasic)return!1;if(i){const t=this.getApiConfig(r.apiFeatureName,n);return null===(null===t||void 0===t?void 0:t.config)?this.processFallbackFeature(e,o):!(null===t||void 0===t||!t.config)&&(void 0!==o&&this.addWarning(o,e),this.processApiFeature(e,t))}return this.processFallbackFeature(e,o)},processApiFeature:(e,t)=>Oe[e].processApi(t),processFallbackFeature:(e,t)=>Oe[e].processFallback(t),async fetchRemoteFeatures(e){var t;const n=null!==(t=e.basic)&&void 0!==t&&t,i=e.features||{};this.localSettingsOverridden.clear();let s=null,r=!1;try{s=await x.N.fetchProjectConfig(),r=null!==s&&void 0!==s}catch(a){console.warn("[Reown Config] Failed to fetch remote project configuration. Using local/default values.",a)}const o=r&&!n?R.oU.DEFAULT_REMOTE_FEATURES:R.oU.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const e of Te){const t=this.processFeature(e,i,s,r,n);Object.assign(o,{[e]:t})}}catch(a){return console.warn("[Reown Config] Failed to process the configuration from Cloud. Using default values.",a),R.oU.DEFAULT_REMOTE_FEATURES}if(r&&this.localSettingsOverridden.size>0){const e="Your local configuration for ".concat(Array.from(this.localSettingsOverridden).join(", ")," was ignored because a remote configuration was successfully fetched. Please manage these features via your project dashboard on dashboard.reown.com.");k.h.open({debugMessage:ne.ALERT_WARNINGS.LOCAL_CONFIGURATION_IGNORED.debugMessage(e)},"warning")}return o}};class Pe{constructor(e){this.chainNamespaces=[],this.features={},this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(e,t)=>{if(e){var n,i,s;const o=null===(n=r.W.getCaipNetworks(e))||void 0===n?void 0:n.find(e=>e.id===t);if(o)return o;const a=null===(i=r.W.getNetworkData(e))||void 0===i?void 0:i.caipNetwork;if(a)return a;return null===(s=r.W.getRequestedCaipNetworks(e).filter(t=>t.chainNamespace===e))||void 0===s?void 0:s[0]}return r.W.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const e=this.getCaipNetwork();if(e)return e.id},this.getCaipNetworks=e=>r.W.getCaipNetworks(e),this.getActiveChainNamespace=()=>r.W.state.activeChain,this.setRequestedCaipNetworks=(e,t)=>{r.W.setRequestedCaipNetworks(e,t)},this.getApprovedCaipNetworkIds=()=>r.W.getAllApprovedCaipNetworkIds(),this.getCaipAddress=e=>{var t;return r.W.state.activeChain!==e&&e?null===(t=r.W.state.chains.get(e))||void 0===t||null===(t=t.accountState)||void 0===t?void 0:t.caipAddress:r.W.state.activeCaipAddress},this.setClientId=e=>{f.T.setClientId(e)},this.getProvider=e=>w.getProvider(e),this.getProviderType=e=>w.getProviderId(e),this.getPreferredAccountType=e=>(0,b.lj)(e),this.setCaipAddress=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];r.W.setAccountProp("caipAddress",e,t,n),r.W.setAccountProp("address",a.w.getPlainAddress(e),t,n)},this.setBalance=(e,t,n)=>{r.W.setAccountProp("balance",e,n),r.W.setAccountProp("balanceSymbol",t,n)},this.setProfileName=(e,t)=>{r.W.setAccountProp("profileName",e,t)},this.setProfileImage=(e,t)=>{r.W.setAccountProp("profileImage",e,t)},this.setUser=(e,t)=>{r.W.setAccountProp("user",e,t)},this.resetAccount=e=>{r.W.resetAccount(e)},this.setCaipNetwork=e=>{r.W.setActiveCaipNetwork(e)},this.setCaipNetworkOfNamespace=(e,t)=>{r.W.setChainNetworkData(t,{caipNetwork:e})},this.setStatus=(e,t)=>{r.W.setAccountProp("status",e,t),s.a.isConnected()?E.i.setConnectionStatus("connected"):E.i.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=e=>{var t;return null===(t=r.W.getAccountData(e))||void 0===t?void 0:t.address},this.setConnectors=e=>{const t=[...s.a.state.allConnectors,...e];s.a.setConnectors(t)},this.setConnections=(e,t)=>{E.i.setConnections(e,t),o.x.setConnections(e,t)},this.fetchIdentity=e=>f.T.fetchIdentity(e),this.getReownName=e=>T.getNamesForAddress(e),this.getConnectors=()=>s.a.getConnectors(),this.getConnectorImage=e=>O.$.getConnectorImage(e),this.getConnections=e=>this.remoteFeatures.multiWallet?P.b.getConnectionsData(e).connections:(k.h.open(h.o.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.getRecentConnections=e=>this.remoteFeatures.multiWallet?P.b.getConnectionsData(e).recentConnections:(k.h.open(h.o.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.switchConnection=async e=>{this.remoteFeatures.multiWallet?await o.x.switchConnection(e):k.h.open(h.o.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info")},this.deleteConnection=e=>{this.remoteFeatures.multiWallet?(E.i.deleteAddressFromConnection(e),o.x.syncStorageConnections()):k.h.open(h.o.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info")},this.setConnectedWalletInfo=(e,t)=>{const n=w.getProviderId(t),s=e?(0,i.A)((0,i.A)({},e),{},{type:n}):void 0;r.W.setAccountProp("connectedWalletInfo",s,t)},this.getIsConnectedState=()=>Boolean(r.W.state.activeCaipAddress),this.addAddressLabel=(e,t,n
2)=>{var s;const o=(null===(s=r.W.getAccountData(n))||void 0===s?void 0:s.addressLabels)||{};r.W.setAccountProp("addressLabels",(0,i.A)((0,i.A)({},o),{},{[e]:t}),n)},this.removeAddressLabel=(e,t)=>{var n;const s=(null===(n=r.W.getAccountData(t))||void 0===n?void 0:n.addressLabels)||{};r.W.setAccountProp("addressLabels",(0,i.A)((0,i.A)({},s),{},{[e]:void 0}),t)},this.getAddress=e=>{var t;const n=e||r.W.state.activeChain;return null===(t=r.W.getAccountData(n))||void 0===t?void 0:t.address},this.setApprovedCaipNetworksData=e=>r.W.setApprovedCaipNetworksData(e),this.resetNetwork=e=>{r.W.resetNetwork(e)},this.addConnector=e=>{s.a.addConnector(e)},this.resetWcConnection=()=>{o.x.resetWcConnection()},this.setAddressExplorerUrl=(e,t)=>{r.W.setAccountProp("addressExplorerUrl",e,t)},this.setSmartAccountDeployed=(e,t)=>{r.W.setAccountProp("smartAccountDeployed",e,t)},this.setPreferredAccountType=(e,t)=>{r.W.setAccountProp("preferredAccountType",e,t)},this.setEIP6963Enabled=e=>{c.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=this.getChainNamespacesSet(e.adapters,this.caipNetworks),this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.readyPromise=this.initialize(e),Z.checkSDKVersion(e.sdkVersion)}getChainNamespacesSet(e,t){const n=null===e||void 0===e?void 0:e.map(e=>e.namespace).filter(e=>Boolean(e));if(null!==n&&void 0!==n&&n.length)return[...new Set(n)];const i=null===t||void 0===t?void 0:t.map(e=>e.chainNamespace);return[...new Set(i)]}async initialize(e){var t,i,s,r,o;if(this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),c.H.state.enableReconnect?(await this.syncExistingConnection(),await this.syncAdapterConnections()):await this.unSyncExistingConnection(),this.remoteFeatures=await ke.fetchRemoteFeatures(e),c.H.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&B.setOnrampProviders(this.remoteFeatures.onramp),(null!==(t=c.H.state.remoteFeatures)&&void 0!==t&&t.email||Array.isArray(null===(i=c.H.state.remoteFeatures)||void 0===i?void 0:i.socials)&&(null===(s=c.H.state.remoteFeatures)||void 0===s?void 0:s.socials.length)>0)&&await this.checkAllowedOrigins(),null!==(r=c.H.state.features)&&void 0!==r&&r.reownAuthentication||null!==(o=c.H.state.remoteFeatures)&&void 0!==o&&o.reownAuthentication){const{ReownAuthentication:e}=await n.e(8952).then(n.bind(n,18952)),t=c.H.state.siwx;t instanceof e||(t&&console.warn("ReownAuthentication option is enabled, SIWX configuration will be overridden."),c.H.setSIWX(new e))}}async openSend(e){var t;const n=e.namespace||r.W.state.activeChain,i=this.getCaipAddress(n),s=null===(t=this.getCaipNetwork(n))||void 0===t?void 0:t.id;if(!i)throw new Error("openSend: caipAddress not found");if((null===s||void 0===s?void 0:s.toString())!==e.chainId.toString()){const t=r.W.getCaipNetworkById(e.chainId,n);if(!t)throw new Error("openSend: caipNetwork with chainId ".concat(e.chainId," not found"));await this.switchNetwork(t,{throwOnFailure:!0})}try{const t=ee.getTokenSymbolByAddress(e.assetAddress);t&&await x.N.fetchTokenImages([t])}catch(o){}return await F.W.open({view:"WalletSend",data:{send:e}}),new Promise((e,t)=>{const n=j.R.subscribeKey("hash",t=>{t&&(s(),e({hash:t}))}),i=F.W.subscribe(e=>{e.open||(s(),t(new Error("Modal closed")))}),s=this.createCleanupHandler([n,i])})}toModalOptions(){return{isSwap:function(e){return"Swap"===(null===e||void 0===e?void 0:e.view)},isSend:function(e){return"WalletSend"===(null===e||void 0===e?void 0:e.view)}}}async checkAllowedOrigins(){try{const e=await x.N.fetchAllowedOrigins();if(!a.w.isClient())return;const t=window.location.origin;me.isOriginAllowed(t,e,Ce)||k.h.open(ne.ALERT_ERRORS.ORIGIN_NOT_ALLOWED,"error")}catch(e){if(!(e instanceof Error))return;switch(e.message){case"RATE_LIMITED":k.h.open(ne.ALERT_ERRORS.RATE_LIMITED_APP_CONFIGURATION,"error");break;case"SERVER_ERROR":{const t=e.cause instanceof Error?e.cause:e;k.h.open({displayMessage:ne.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.displayMessage,debugMessage:ne.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.debugMessage(t.message)},"error");break}}}}createCleanupHandler(e){return()=>
2{e.forEach(e=>{try{e()}catch(t){}})}}sendInitializeEvent(e){var t;const n=Object.assign({},((0,l.A)(e),e));delete n.adapters,delete n.universalProvider,H.E.sendEvent({type:"track",event:"INITIALIZE",properties:(0,i.A)((0,i.A)({},n),{},{networks:e.networks.map(e=>e.id),siweConfig:{options:(null===(t=e.siweConfig)||void 0===t?void 0:t.options)||{}}})})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&q.W.setThemeMode(e.themeMode),e.themeVariables&&q.W.setThemeVariables(e.themeVariables)}initializeChainController(e){var t;if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");r.W.initialize(null!==(t=e.adapters)&&void 0!==t?t:[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const n=this.getDefaultNetwork();n&&r.W.setActiveCaipNetwork(n)}initializeConnectionController(e){var t,n;o.x.initialize(null!==(t=e.adapters)&&void 0!==t?t:[]),o.x.setWcBasic(null!==(n=e.basic)&&void 0!==n&&n)}initializeConnectorController(){s.a.initialize(this.chainNamespaces)}initializeProjectSettings(e){c.H.setProjectId(e.projectId),c.H.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){var t,n;c.H.setDebug(!1!==e.debug),c.H.setEnableWalletGuide(!1!==e.enableWalletGuide),c.H.setEnableWallets(!1!==e.enableWallets),c.H.setEIP6963Enabled(!1!==e.enableEIP6963),c.H.setEnableNetworkSwitch(!1!==e.enableNetworkSwitch),c.H.setEnableReconnect(!1!==e.enableReconnect),c.H.setEnableMobileFullScreen(!0===e.enableMobileFullScreen),c.H.setEnableAuthLogger(!1!==e.enableAuthLogger),c.H.setCustomRpcUrls(e.customRpcUrls),c.H.setEnableEmbedded(e.enableEmbedded),c.H.setAllWallets(e.allWallets),c.H.setIncludeWalletIds(e.includeWalletIds),c.H.setExcludeWalletIds(e.excludeWalletIds),c.H.setFeaturedWalletIds(e.featuredWalletIds),c.H.setTokens(e.tokens),c.H.setTermsConditionsUrl(e.termsConditionsUrl),c.H.setPrivacyPolicyUrl(e.privacyPolicyUrl),c.H.setCustomWallets(e.customWallets),c.H.setFeatures(e.features),c.H.setAllowUnsupportedChain(e.allowUnsupportedChain),c.H.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),c.H.setPreferUniversalLinks(e.experimental_preferUniversalLinks),c.H.setDefaultAccountTypes(e.defaultAccountTypes);const i=this.getDefaultMetaData();if(!e.metadata&&i&&(e.metadata=i),c.H.setMetadata(e.metadata),c.H.setDisableAppend(e.disableAppend),c.H.setEnableEmbedded(e.enableEmbedded),c.H.setSIWX(e.siwx),this.features=null!==(t=c.H.state.features)&&void 0!==t?t:{},!e.projectId)return void k.h.open(ne.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");if((null===(n=e.adapters)||void 0===n?void 0:n.find(e=>e.namespace===h.o.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");c.H.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,t,n;return a.w.isClient()?{name:(null===(e=document.getElementsByTagName("title"))||void 0===e||null===(e=e[0])||void 0===e?void 0:e.textContent)||"",description:(null===(t=document.querySelector('meta[property="og:description"]'))||void 0===t?void 0:t.content)||"",url:window.location.origin,icons:[(null===(n=document.querySelector('link[rel~="icon"]'))||void 0===n?void 0:n.href)||""]}:null}setUnsupportedNetwork(e){const t=this.getActiveChainNamespace();if(t){const n=ie.R.getUnsupportedNetwork("".concat(t,":").concat(e));r.W.setActiveCaipNetwork(n)}}getDefaultNetwork(){return ie.R.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,t){return ie.R.extendCaipNetwork(e,{customNetworkImageUrls:t.chainImages,projectId:t.projectId})}extendCaipNetworks(e){return ie.R.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const t=e.networks.find(t=>{var n;return t.id===(null===(n=e.defaultNetwork)||void 0===n?void 0:n.id)});return t?ie.R.extendCaipNetwork(t,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectConnector(e,t){try{var n;this.setLoading(!0,e);let i={connections:[]};const s=this.getAdapter(e);return!(null===(n=r.W.state.chains.get(e))||void 0===n||null===(n=n.accountState)||void 0===n?void 0:n.caipAddress)&&c.H.state.enableReconnect||null===s||void 0===s||!s.disconnect||(i=await s.disconnect({id:t})),this.setLoading(!1,e),i}catch(i){throw this.setLoading(!1,e),new Error("Failed to disconnect chains: ".concat(i.message))}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var e;const t=r.W.state.activeChain,n=this.getAdapter(t),i=null===(e=this.getCaipNetwork(t))||void 0===e?void 0:e.id,s=o.x.getConnections(t),a=this.remoteFeatures.multiWallet,c=s.length>0;if(!n)throw new Error("Adapter not found");const l=await n.connectWalletConnect(i);(!c||!a)&&this.close(),this.setClientId((null===l||void 0===l?void 0:l.clientId)||null),E.i.setConnectedNamespaces([...r.W.state.chains.keys()]),await this.syncWalletConnectAccount(),await V.U.initializeIfEnabled()},connectExternal:async e=>{const t=await this.onConnectExternal(e);return await this.connectInactiveNamespaces(e,t),t?{address:t.address}:void 0},reconnectExternal:async e=>{let{id:t,info:n,type:i,provider:s}=e;const o=r.W.state.activeChain,a=this.getAdapter(o);if(!o)throw new Error("reconnectExternal: namespace not found");if(!a)throw new Error("reconnectExternal: adapter not found");var c;null!==a&&void 0!==a&&a.reconnect&&(await(null===a||void 0===a?void 0:a.reconnect({id:t,info:n,type:i,provider:s,chainId:null===(c=this.getCaipNetwork())||void 0===c?void 0:c.id})),E.i.addConnectedNamespace(o),this.syncConnectedWalletInfo(o))},disconnectConnector:async e=>{await this.disconnectConnector(e.namespace,e.id)},disconnect:async e=>{const{id:t,chainNamespace:n,initialDisconnect:i}=e||{},a=n||r.W.state.activeChain,c=s.a.getConnectorId(a),l=t===h.o.CONNECTOR_ID.AUTH||c===h.o.CONNECTOR_ID.AUTH,d=t===h.o.CONNECTOR_ID.WALLET_CONNECT||c===h.o.CONNECTOR_ID.WALLET_CONNECT;try{var u;const e=Array.from(r.W.state.chains.keys());let a=n?[n]:e;(d||l)&&(a=e);const c=a.map(async e=>{const n=s.a.getConnectorId(e),r=t||n,o=await this.disconnectConnector(e,r);o&&(l&&E.i.deleteConnectedSocialProvider(),o.connections.forEach(t=>{E.i.addDisconnectedConnectorId(t.connectorId,e)})),i&&this.onDisconnectNamespace({chainNamespace:e,closeModal:!1})}),h=await Promise.allSettled(c);j.R.resetSend(),o.x.resetWcConnection(),null!==(u=V.U.getSIWX())&&void 0!==u&&u.signOutOnDisconnect&&await V.U.clearSessions(),s.a.setFilterByNamespace(void 0),o.x.syncStorageConnections();const p=h.filter(e=>"rejected"===e.status);if(p.length>0)throw new Error(p.map(e=>e.reason.message).join(", "));H.E.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:n||"all"}})}catch(p){throw new Error("Failed to disconnect chains: ".concat(p.message))}},checkInstalled:e=>e?e.some(e=>{var t;return Boolean(null===(t=window.ethereum)||void 0===t?void 0:t[String(e)])}):Boolean(window.ethereum),signMessage:async e=>{const t=r.W.state.activeChain,n=this.getAdapter(r.W.state.activeChain);if(!t)throw new Error("signMessage: namespace not found");if(!n)throw new Error("signMessage: adapter not found");const i=this.getAddress(t);if(!i)throw new Error("signMessage: address not found");const s=await(null===n||void 0===n?void 0:n.signMessage({message:e,address:i,provider:w.getProvider(t)}));return(null===s||void 0===s?void 0:s.signature)||""},sendTransaction:async e=>{const t=e.chainNamespace;if(!t)throw new Error("sendTransaction: namespace not found");if(R.oU.SEND_SUPPORTED_NAMESPACES.includes(t)){const n=this.getAdapter(t);if(!n)throw new Error("sendTransaction: adapter not found");const s=w.getProvider(t),r=await(null===n||void 0===n?void 0:n.sendTransaction((0,i.A)((0,i.A)({},e),{},{caipNetwork:this.getCaipNetwork(),provider:s})));return(null===r||void 0===r?void 0:r.hash)||""}return""},estimateGas:async e=>{const t=e.chainNamespace;if(t===h.o.CHAIN.EVM){const n=this.getAdapter(t);if(!n)throw new Error("estimateGas: adapter is required but got undefined");const s=w.getProvider(t),r=this.getCaipNetwork();if(!r)throw new Error("estimateGas: caipNetwork is required but got undefined");const o=await(null===n||void 0===n?void 0:n.estimateGas((0,i.A)((0,i.A)({},e),{},{provider:s,caipNetwork:r})));return(null===o||void 0===o?void 0:o.gas)||0n}return 0n},getEnsAvatar:async()=>{var e;const t=r.W.state.activeChain;if(!t)throw new Error("getEnsAvatar: namespace is required but got undefined");const n=this.getAddress(t);if(!n)throw new Error("getEnsAvatar: address not found");await this.syncIdentity({address:n,chainId:Number(null===(e=this.getCaipNetwork())||void 0===e?void 0:e.id),chainNamespace:t});const i=r.W.getAccountData();return(null===i||void 0===i?void 0:i.profileImage)||!1},getEnsAddress:async e=>await me.resolveReownName(e),writeContract:async e=>{const t=r.W.state.activeChain,n=this.getAdapter(t);if(!t)throw new Error("writeContract: namespace is required but got undefined");if(!n)throw new Error("writeContract: adapter is required but got undefined");const s=this.getCaipNetwork(),o=this.getCaipAddress(),a=w.getProvider(t);if(!s||!o)throw new Error("writeContract: caipNetwork or caipAddress is required but got undefined");const c=await(null===n||void 0===n?void 0:n.writeContract((0,i.A)((0,i.A)({},e),{},{caipNetwork:s,provider:a,caipAddress:o})));return null===c||void 0===c?void 0:c.hash},parseUnits:(e,t)=>{var n;const i=this.getAdapter(r.W.state.activeChain);if(!i)throw new Error("parseUnits: adapter is required but got undefined");return null!==(n=null===i||void 0===i?void 0:i.parseUnits({value:e,decimals:t}))&&void 0!==n?n:0n},formatUnits:(e,t)=>{var n;const i=this.getAdapter(r.W.state.activeChain);if(!i)throw new Error("formatUnits: adapter is required but got undefined");return null!==(n=null===i||void 0===i?void 0:i.formatUnits({value:e,decimals:t}))&&void 0!==n?n:"0"},getCapabilities:async e=>{const t=this.getAdapter(r.W.state.activeChain);if(!t)throw new Error("getCapabilities: adapter is required but got undefined");return await(null===t||void 0===t?void 0:t.getCapabilities(e))},grantPermissions:async e=>{const t=this.getAdapter(r.W.state.activeChain);if(!t)throw new Error("grantPermissions: adapter is required but got undefined");return await(null===t||void 0===t?void 0:t.grantPermissions(e))},revokePermissions:async e=>{const t=this.getAdapter(r.W.state.activeChain);if(!t)throw new Error("revokePermissions: adapter is required but got undefined");return null!==t&&void 0!==t&&t.revokePermissions?await t.revokePermissions(e):"0x"},walletGetAssets:async e=>{var t;const n=this.getAdapter(r.W.state.activeChain);if(!n)throw new Error("walletGetAssets: adapter is required but got undefined");return null!==(t=await(null===n||void 0===n?void 0:n.walletGetAssets(e)))&&void 0!==t?t:{}},updateBalance:e=>{const t=this.getAddress(e),n=this.getCaipNetwork(e);n&&t&&this.updateNativeBalance(t,null===n||void 0===n?void 0:n.id,e)}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},o.x.setClient(this.connectionControllerClient)}async onConnectExternal(e){var t,n,o;const a=r.W.state.activeChain,c=e.chain||a,l=this.getAdapter(c);let d=!0;if(e.type===X.o.CONNECTOR_TYPE_AUTH){const t=h.o.AUTH_CONNECTOR_SUPPORTED_CHAINS.some(e=>s.a.getConnectorId(e)===h.o.CONNECTOR_ID.AUTH);t&&e.chain!==a&&(d=!1)}if(e.chain&&e.chain!==a&&!e.caipNetwork){const t=this.getCaipNetworks().find(t=>t.chainNamespace===e.chain);t&&d&&this.setCaipNetwork(t)}if(!c)throw new Error("connectExternal: namespace not found");if(!l)throw new Error("connectExternal: adapter not found");const u=this.getCaipNetwork(c),p=e.caipNetwork||u,f=await l.connect({id:e.id,address:e.address,info:e.info,type:e.type,provider:e.provider,socialUri:e.socialUri,chainId:(null===(t=e.caipNetwork)||void 0===t?void 0:t.id)||(null===u||void 0===u?void 0:u.id),rpcUrl:(null===(n=e.caipNetwork)||void 0===n||null===(n=n.rpcUrls)||void 0===n||null===(n=n.default)||void 0===n||null===(n=n.http)||void 0===n?void 0:n[0])||(null===u||void 0===u||null===(o=u.rpcUrls)||void 0===o||null===(o=o.default)||void 0===o||null===(o=o.http)||void 0===o?void 0:o[0])});if(f)return E.i.addConnectedNamespace(c),this.syncProvider((0,i.A)((0,i.A)({},f),{},{chainNamespace:c})),this.setStatus("connected",c),this.syncConnectedWalletInfo(c),E.i.removeDisconnectedConnectorId(e.id,c),{address:f.address,connectedCaipNetwork:p}}async connectInactiveNamespaces(e,t){var n;const s=e.type===X.o.CONNECTOR_TYPE_AUTH,o=se.y.getOtherAuthNamespaces(null===t||void 0===t||null===(n=t.connectedCaipNetwork)||void 0===n?void 0:n.chainNamespace),a=r.W.state.activeCaipNetwork,c=this.getAdapter(null===a||void 0===a?void 0:a.chainNamespace),l=w.getProvider(null===a||void 0===a?void 0:a.chainNamespace);s&&(await Promise.all(o.map(async t=>{try{var n;const s=w.getProvider(t),r=this.getCaipNetwork(t),o=this.getAdapter(t);await(null===o||void 0===o?void 0:o.connect((0,i.A)((0,i.A)({},e),{},{provider:s,socialUri:void 0,chainId:null===r||void 0===r?void 0:r.id,rpcUrl:null===r||void 0===r||null===(n=r.rpcUrls)||void 0===n||null===(n=n.default)||void 0===n||null===(n=n.http)||void 0===n?void 0:n[0]})))&&(E.i.addConnectedNamespace(t),E.i.removeDisconnectedConnectorId(e.id,t),this.setStatus("connected",t),this.syncConnectedWalletInfo(t))}catch(s){k.h.warn(ne.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.displayMessage,ne.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.debugMessage(t,s instanceof Error?s.message:void 0),ne.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.code)}})),a&&await(null===c||void 0===c?void 0:c.switchNetwork({caipNetwork:a,provider:l,providerType:e.type})))}getApprovedCaipNetworksData(){if(w.getProviderId(r.W.state.activeChain)===X.o.CONNECTOR_TYPE_WALLET_CONNECT){var e,t;const n=null===(e=this.universalProvider)||void 0===e||null===(e=e.session)||void 0===e?void 0:e.namespaces;return{supportsAllNetworks:"MetaMask Wallet"===(null===(t=this.universalProvider)||void 0===t||null===(t=t.session)||void 0===t||null===(t=t.peer)||void 0===t?void 0:t.metadata.name),approvedCaipNetworkIds:this.getChainsFromNamespaces(n)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){const t=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const n=w.getProvider(t),i=w.getProviderId(t);if(e.chainNamespace===r.W.state.activeChain){const s=this.getAdapter(t);await(null===s||void 0===s?void 0:s.switchNetwork({caipNetwork:e,provider:n,providerType:i}))}else if(this.setCaipNetwork(e),i===X.o.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const n=this.getAddressByChainNamespace(t);n&&this.syncAccount({address:n,chainId:e.id,chainNamespace:t})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.values(e).flatMap(e=>{const t=e.chains||[],n=e.accounts.map(e=>{const{chainId:t,chainNamespace:n}=u.C.parseCaipAddress(e);return"".concat(n,":").concat(t)});return Array.from(new Set([...t,...n]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((t,n)=>{const i=null===e||void 0===e?void 0:e.find(e=>e.namespace===n);var s,r;i?(i.construct({namespace:n,projectId:null===(s=this.options)||void 0===s?void 0:s.projectId,networks:null===(r=this.caipNetworks)||void 0===r?void 0:r.filter(e=>{let{chainNamespace:t}=e;return t===n})}
2),t[n]=i):t[n]=new _e({namespace:n,networks:this.getCaipNetworks()});return t},{})}async initChainAdapter(e){var t;this.onConnectors(e),this.listenAdapter(e),await(null===(t=this.chainAdapters)||void 0===t?void 0:t[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);null===t||void 0===t||t.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const t=this.getAdapter(e);if(!t)return;const n=E.i.getConnectionStatus();!1===c.H.state.enableReconnect?this.setStatus("disconnected",e):"connected"===n?this.setStatus("connecting",e):"disconnected"===n?(E.i.clearAddressCache(),this.setStatus(n,e)):this.setStatus(n,e),t.on("switchNetwork",t=>{var n;let{address:i,chainId:s}=t;const o=this.getCaipNetworks().find(e=>e.id.toString()===s.toString()||e.caipNetworkId.toString()===s.toString()),a=r.W.state.activeChain===e,c=null===(n=r.W.state.chains.get(e))||void 0===n||null===(n=n.accountState)||void 0===n?void 0:n.address;if(o){const t=a&&i?i:c;t&&this.syncAccount({address:t,chainId:o.id,chainNamespace:e})}else this.setUnsupportedNetwork(s)}),t.on("disconnect",()=>{const t=this.remoteFeatures.multiWallet,n=Array.from(o.x.state.connections.values()).flat();this.onDisconnectNamespace({chainNamespace:e,closeModal:!t||0===n.length})}),t.on("connections",t=>{this.setConnections(t,e)}),t.on("pendingTransactions",()=>{const t=this.getAddress(e),n=r.W.state.activeCaipNetwork;t&&null!==n&&void 0!==n&&n.id&&this.updateNativeBalance(t,n.id,n.chainNamespace)}),t.on("accountChanged",t=>{var n;let{address:i,chainId:s,connector:o}=t;this.handlePreviousConnectorConnection(o);const a=r.W.state.activeChain===e;null!==o&&void 0!==o&&o.provider&&(this.syncProvider({id:o.id,type:o.type,provider:null===o||void 0===o?void 0:o.provider,chainNamespace:e}),this.syncConnectedWalletInfo(e));const c=null===(n=r.W.getNetworkData(e))||void 0===n||null===(n=n.caipNetwork)||void 0===n?void 0:n.id,l=s||c;a&&l?this.syncAccount({address:i,chainId:l,chainNamespace:e}):!a&&l?(this.syncAccountInfo(i,l,e),this.syncBalance({address:i,chainId:l,chainNamespace:e})):this.syncAccountInfo(i,s,e),E.i.addConnectedNamespace(e)})}async handlePreviousConnectorConnection(e){var t;const n=null===e||void 0===e?void 0:e.chain,i=null===e||void 0===e?void 0:e.id,r=s.a.getConnectorId(n),a=null===(t=c.H.state.remoteFeatures)||void 0===t?void 0:t.multiWallet,l=n&&i&&r&&r!==i&&!a;try{l&&await o.x.disconnect({id:r,namespace:n})}catch(d){console.warn("Error disconnecting previous connector",d)}}async createUniversalProviderForAdapter(e){var t,n;(await this.getUniversalProvider(),this.universalProvider)&&await(null===(t=this.chainAdapters)||void 0===t||null===(t=t[e])||void 0===t||null===(n=t.setUniversalProvider)||void 0===n?void 0:n.call(t,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async unSyncExistingConnection(){try{await Promise.allSettled(this.chainNamespaces.map(e=>o.x.disconnect({namespace:e,initialDisconnect:!0})))}catch(e){console.error("Error disconnecting existing connections:",e)}}async reconnectWalletConnect(){await this.syncWalletConnectAccount();const e=this.getAddress();this.getCaipAddress()||E.i.deleteRecentWallet();const t=E.i.getRecentWallet();H.E.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:e,properties:{method:a.w.isMobile()?"mobile":"qrcode",name:(null===t||void 0===t?void 0:t.name)||"Unknown",reconnect:!0,view:N.I.state.view,walletRank:null===t||void 0===t?void 0:t.order}})}async syncNamespaceConnection(e){try{e===h.o.CHAIN.EVM&&a.w.isSafeApp()&&s.a.setConnectorId(h.o.CONNECTOR_ID.SAFE,e);const t=s.a.getConnectorId(e);switch(this.setStatus("connecting",e),t){case h.o.CONNECTOR_ID.WALLET_CONNECT:await this.reconnectWalletConnect();break;case h.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)}}onDisconnectNamespace(e){const{chainNamespace:t,closeModal:n}=e||{};r.W.resetAccount(t),r.W.resetNetwork(t),E.i.removeConnectedNamespace(t);const i=Array.from(r.W.state.chains.keys());
2(t?[t]:i).forEach(e=>E.i.addDisconnectedConnectorId(s.a.getConnectorId(e)||"",e)),s.a.removeConnectorId(t),w.resetChain(t),this.setUser(null,t),this.setStatus("disconnected",t),this.setConnectedWalletInfo(null,t),!1!==n&&F.W.close()}async syncAdapterConnections(){await Promise.allSettled(this.chainNamespaces.map(e=>{const t=this.getAdapter(e),n=this.getCaipAddress(e),i=this.getCaipNetwork(e);return null===t||void 0===t?void 0:t.syncConnections({connectToFirstConnector:!n,caipNetwork:i})}))}async syncAdapterConnection(e){const t=this.getAdapter(e),n=this.getCaipNetwork(e),r=s.a.getConnectorId(e),o=s.a.getConnectors(e).find(e=>e.id===r);try{var a;if(!t||!o)throw new Error("Adapter or connector not found for namespace ".concat(e));if(null===n||void 0===n||!n.id)throw new Error("CaipNetwork not found");const s=await(null===t||void 0===t?void 0:t.syncConnection({namespace:e,id:o.id,chainId:n.id,rpcUrl:null===n||void 0===n||null===(a=n.rpcUrls)||void 0===a||null===(a=a.default)||void 0===a||null===(a=a.http)||void 0===a?void 0:a[0]}));var c;if(s)this.syncProvider((0,i.A)((0,i.A)({},s),{},{chainNamespace:e})),await this.syncAccount((0,i.A)((0,i.A)({},s),{},{chainNamespace:e})),this.setStatus("connected",e),H.E.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:s.address,properties:{method:"browser",name:(null===(c=o.info)||void 0===c?void 0:c.name)||o.name||"Unknown",reconnect:!0,view:N.I.state.view,walletRank:void 0}});else this.setStatus("disconnected",e)}catch(l){this.onDisconnectNamespace({chainNamespace:e,closeModal:!1})}}async syncWalletConnectAccount(){var e;const t=Object.keys((null===(e=this.universalProvider)||void 0===e||null===(e=e.session)||void 0===e?void 0:e.namespaces)||{}),n=this.chainNamespaces.map(async e=>{var n,i;const o=this.getAdapter(e);if(!o)return;const a=(null===(n=this.universalProvider)||void 0===n||null===(n=n.session)||void 0===n||null===(n=n.namespaces)||void 0===n||null===(n=n[e])||void 0===n?void 0:n.accounts)||[],c=null===(i=r.W.state.activeCaipNetwork)||void 0===i?void 0:i.id,l=a.find(e=>{const{chainId:t}=u.C.parseCaipAddress(e);return t===(null===c||void 0===c?void 0:c.toString())})||a[0];if(l){const t=u.C.validateCaipAddress(l),{chainId:n,address:i}=u.C.parseCaipAddress(t);if(w.setProviderId(e,X.o.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&r.W.state.activeCaipNetwork&&o.namespace!==h.o.CHAIN.EVM){const t=o.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:r.W.state.activeCaipNetwork});w.setProvider(e,t)}else w.setProvider(e,this.universalProvider);s.a.setConnectorId(h.o.CONNECTOR_ID.WALLET_CONNECT,e),E.i.addConnectedNamespace(e),await this.syncAccount({address:i,chainId:n,chainNamespace:e})}else t.includes(e)&&this.setStatus("disconnected",e);this.syncConnectedWalletInfo(e),await r.W.setApprovedCaipNetworksData(e)});await Promise.all(n)}syncProvider(e){let{type:t,provider:n,id:i,chainNamespace:r}=e;w.setProviderId(r,t),w.setProvider(r,n),s.a.setConnectorId(i,r)}async syncAccount(e){var t;const n=e.chainNamespace===r.W.state.activeChain,i=r.W.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:s,chainId:o,chainNamespace:a}=e,{chainId:l}=E.i.getActiveNetworkProps(),d=o||l,p=(null===(t=r.W.state.activeCaipNetwork)||void 0===t?void 0:t.name)===h.o.UNSUPPORTED_NETWORK_NAME,f=r.W.getNetworkProp("supportsAllNetworks",a);if(this.setStatus("connected",a),(!p||f)&&d){let e=this.getCaipNetworks().find(e=>e.id.toString()===d.toString()),t=this.getCaipNetworks().find(e=>e.chainNamespace===a);if(!f&&!e&&!t){const n=this.getApprovedCaipNetworkIds()||[],i=n.find(e=>{var t;return(null===(t=u.C.parseCaipNetworkId(e))||void 0===t?void 0:t.chainId)===d.toString()}),s=n.find(e=>{var t;return(null===(t=u.C.parseCaipNetworkId(e))||void 0===t?void 0:t.chainNamespace)===a});e=this.getCaipNetworks().find(e=>e.caipNetworkId===i),t=this.getCaipNetworks().find(e=>e.caipNetworkId===s||"deprecatedCaipNetworkId"in e&&e.deprecatedCaipNetworkId===s)}const l=e||t;var g;if((null===l||void 0===l?void 0:l.chainNamespace)===r.W.state.activeChain)c.H.state.enableNetworkSwitch&&!c.H.state.allowUnsupportedChain&&(null===(g=r.W.state.activeCaipNetwork)||void 0===g?void 0:g.name)===h.o.UNSUPPORTED_NETWORK_NAME?r.W.showUnsupportedChainUI():this.setCaipNetwork(l);else n||i&&this.setCaipNetworkOfNamespace(i,a);this.syncConnectedWalletInfo(a);const p=this.getAddress(a);se.y.isLowerCaseMatch(s,p)||this.syncAccountInfo(s,null===l||void 0===l?void 0:l.id,a),n?await this.syncBalance({address:s,chainId:null===l||void 0===l?void 0:l.id,chainNamespace:a}):await this.syncBalance({address:s,chainId:null===i||void 0===i?void 0:i.id,chainNamespace:a}),this.syncIdentity({address:s,chainId:o,chainNamespace:a})}}async syncAccountInfo(e,t,n){const i=this.getCaipAddress(n),s=t||(null===i||void 0===i?void 0:i.split(":")[1]);if(!s)return;const r="".concat(n,":").concat(s,":").concat(e);this.setCaipAddress(r,n,!0),await this.syncIdentity({address:e,chainId:s,chainNamespace:n})}async syncReownName(e,t){try{const n=await this.getReownName(e);
2if(n[0]){const e=n[0];this.setProfileName(e.name,t)}else this.setProfileName(null,t)}catch(n){this.setProfileName(null,t)}}syncConnectedWalletInfo(e){const t=s.a.getConnectorId(e),n=w.getProviderId(e);if(n===X.o.CONNECTOR_TYPE_ANNOUNCED||n===X.o.CONNECTOR_TYPE_INJECTED){if(t){const n=this.getConnectors().find(e=>{var n,i;const s=e.id===t,r=(null===(n=e.info)||void 0===n?void 0:n.rdns)===t,o=null===(i=e.connectors)||void 0===i?void 0:i.some(e=>{var n;return e.id===t||(null===(n=e.info)||void 0===n?void 0:n.rdns)===t});return s||r||Boolean(o)});if(n){const{info:t,name:s,imageUrl:r}=n,o=r||this.getConnectorImage(n);this.setConnectedWalletInfo((0,i.A)({name:s,icon:o},t),e)}}}else if(n===X.o.CONNECTOR_TYPE_WALLET_CONNECT){const t=w.getProvider(e);var r;if(null!==t&&void 0!==t&&t.session)this.setConnectedWalletInfo((0,i.A)((0,i.A)({},t.session.peer.metadata),{},{name:t.session.peer.metadata.name,icon:null===(r=t.session.peer.metadata.icons)||void 0===r?void 0:r[0]}),e)}else if(t&&(t===h.o.CONNECTOR_ID.COINBASE_SDK||t===h.o.CONNECTOR_ID.COINBASE)){const n=this.getConnectors().find(e=>e.id===t),s=(null===n||void 0===n?void 0:n.name)||"Coinbase Wallet",r=(null===n||void 0===n?void 0:n.imageUrl)||this.getConnectorImage(n),o=null===n||void 0===n?void 0:n.info;this.setConnectedWalletInfo((0,i.A)((0,i.A)({},o),{},{name:s,icon:r}),e)}}async syncBalance(e){p.L.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(t=>{var n;return t.id.toString()===(null===(n=e.chainId)||void 0===n?void 0:n.toString())})&&e.chainId&&await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,t,n){const i=this.getAdapter(n),s=r.W.getCaipNetworkByNamespace(n,t);if(i){const r=await i.getBalance({address:e,chainId:t,caipNetwork:s,tokens:this.options.tokens});return this.setBalance(r.balance,r.symbol,n),r}}async initializeUniversalAdapter(){var e,t,n,i,s,r,o,a,l,h,u,p=this;const f=oe.createLogger(function(e){e&&p.handleAlertError(e);for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];console.error(...n)}),g={projectId:null===(e=this.options)||void 0===e?void 0:e.projectId,metadata:{name:null!==(t=this.options)&&void 0!==t&&t.metadata?null===(n=this.options)||void 0===n?void 0:n.metadata.name:"",description:null!==(i=this.options)&&void 0!==i&&i.metadata?null===(s=this.options)||void 0===s?void 0:s.metadata.description:"",url:null!==(r=this.options)&&void 0!==r&&r.metadata?null===(o=this.options)||void 0===o?void 0:o.metadata.url:"",icons:null!==(a=this.options)&&void 0!==a&&a.metadata?null===(l=this.options)||void 0===l?void 0:l.metadata.icons:[""]},logger:f};c.H.setManualWCControl(Boolean(null===(h=this.options)||void 0===h?void 0:h.manualWCControl)),this.universalProvider=null!==(u=this.options.universalProvider)&&void 0!==u?u:await d.A.init(g),!1===c.H.state.enableReconnect&&this.universalProvider.session&&await this.universalProvider.disconnect(),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&this.chainNamespaces.forEach(e=>{me.listenWcProvider({universalProvider:this.universalProvider,namespace:e,onDisplayUri:e=>{o.x.setUri(e)},onConnect:e=>{const{address:t}=a.w.getAccount(e[0]);o.x.finalizeWcConnection(t)},onDisconnect:()=>{r.W.state.noAdapters&&this.resetAccount(e),o.x.resetWcConnection()},onChainChanged:t=>{const n=r.W.state.activeChain,i=n&&s.a.state.activeConnectorIds[n]===h.o.CONNECTOR_ID.WALLET_CONNECT;if(n===e&&(r.W.state.noAdapters||i)){const e=this.getCaipNetworks().find(e=>e.id.toString()===t.toString()||e.caipNetworkId.toString()===t.toString()),n=this.getCaipNetwork();if(!e)return void this.setUnsupportedNetwork(t);(null===n||void 0===n?void 0:n.id.toString())!==(null===e||void 0===e?void 0:e.id.toString())&&(null===n||void 0===n?void 0:n.chainNamespace)===(null===e||void 0===e?void 0:e.chainNamespace)&&this.setCaipNetwork(e)}},onAccountsChanged:t=>{const n=r.W.state.activeChain,i=n&&s.a.state.activeConnectorIds[n]===h.o.CONNECTOR_ID.WALLET_CONNECT;if(n===e&&(r.W.state.noAdapters||i)){const e=null===t||void 0===t?void 0:t[0];e&&this.syncAccount({address:e.address,chainId:e.chainId,chainNamespace:e.chainNamespace})}}})})}createUniversalProvider(){var e;return!this.universalProviderInitPromise&&a.w.isClient()&&null!==(e=this.options)&&void 0!==e&&e.projectId&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}
2async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){H.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}getDisabledCaipNetworks(){const e=r.W.getAllApprovedCaipNetworkIds(),t=r.W.getAllRequestedCaipNetworks();return a.w.sortRequestedNetworks(e,t).filter(e=>r.W.isCaipNetworkDisabled(e))}handleAlertError(e){const t=Object.entries(ne.UniversalProviderErrors).find(t=>{let[,{message:n}]=t;return e.message.includes(n)}),[n,i]=null!==t&&void 0!==t?t:[],{message:s,alertErrorKey:r}=null!==i&&void 0!==i?i:{};if(n&&s&&!this.reportedAlertErrors[n]){const e=ne.ALERT_ERRORS[r];e&&(k.h.open(e,"error"),this.reportedAlertErrors[n]=!0)}}getAdapter(e){var t;if(e)return null===(t=this.chainAdapters)||void 0===t?void 0:t[e]}createAdapter(e){var t,n;if(!e)return;const i=e.namespace;if(!i)return;this.createClients();const s=e;s.namespace=i,s.construct({namespace:i,projectId:null===(t=this.options)||void 0===t?void 0:t.projectId,networks:null===(n=this.caipNetworks)||void 0===n?void 0:n.filter(e=>{let{chainNamespace:t}=e;return t===i})}),this.chainNamespaces.includes(i)||this.chainNamespaces.push(i),this.chainAdapters&&(this.chainAdapters[i]=s)}async open(e){await this.injectModalUi(),null!==e&&void 0!==e&&e.uri&&o.x.setUri(e.uri);const{isSwap:t,isSend:n}=this.toModalOptions();return t(e)?F.W.open((0,i.A)((0,i.A)({},e),{},{data:{swap:e.arguments}})):n(e)&&e.arguments?this.openSend(e.arguments):F.W.open(e)}async close(){await this.injectModalUi(),F.W.close()}setLoading(e,t){F.W.setLoading(e,t)}async disconnect(e){await o.x.disconnect({namespace:e})}getSIWX(){return c.H.state.siwx}getError(){return""}getChainId(){var e;return null===(e=r.W.state.activeCaipNetwork)||void 0===e?void 0:e.id}async switchNetwork(e){let{throwOnFailure:t=!1}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=this.getCaipNetworks().find(t=>t.id===e.id);n?await r.W.switchActiveNetwork(n,{throwOnFailure:t}):k.h.open(ne.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error")}getWalletProvider(){return r.W.state.activeChain?w.state.providers[r.W.state.activeChain]:null}getWalletProviderType(){return w.getProviderId(r.W.state.activeChain)}subscribeProviders(e){return w.subscribeProviders(e)}getThemeMode(){return q.W.state.themeMode}getThemeVariables(){return q.W.state.themeVariables}setThemeMode(e){q.W.setThemeMode(e),(0,J.JX)(q.W.state.themeMode)}setTermsConditionsUrl(e){c.H.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){c.H.setPrivacyPolicyUrl(e)}setThemeVariables(e){q.W.setThemeVariables(e),(0,J.ds)(q.W.state.themeVariables)}subscribeTheme(e){return q.W.subscribe(e)}subscribeConnections(e){return this.remoteFeatures.multiWallet?o.x.subscribe(e):(k.h.open(h.o.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),()=>{})}getWalletInfo(e){var t;if(e)return null===(t=r.W.state.chains.get(e))||void 0===t||null===(t=t.accountState)||void 0===t?void 0:t.connectedWalletInfo;const n=r.W.getAccountData();return null===n||void 0===n?void 0:n.connectedWalletInfo}getAccount(e){const t=e||r.W.state.activeChain,n=s.a.getAuthConnector(t),c=r.W.getAccountData(t),l=E.i.getConnectedConnectorId(r.W.state.activeChain),d=o.x.getConnections(t);if(!t)throw new Error("AppKit:getAccount - namespace is required");const u=d.flatMap(e=>e.accounts.map(e=>{let{address:n,type:i,publicKey:s}=e;return a.w.createAccount(t,n,i||"eoa",s)}));if(c)return{allAccounts:u,caipAddress:c.caipAddress,address:a.w.getPlainAddress(c.caipAddress),isConnected:Boolean(c.caipAddress),status:c.status,embeddedWalletInfo:n&&l===h.o.CONNECTOR_ID.AUTH?{user:c.user?(0,i.A)((0,i.A)({},c.user),{},{username:E.i.getConnectedSocialUsername()}):void 0,authProvider:c.socialProvider||"email",accountType:(0,b.lj)(t),isSmartAccountDeployed:Boolean(c.smartAccountDeployed)}:void 0}}subscribeAccount(e,t){const n=()=>{const n=this.getAccount(t);n&&e(n)};t?r.W.subscribeChainProp("accountState",n,t):r.W.subscribe(n),s.a.subscribe(n)}subscribeNetwork(e){return r.W.subscribe(t=>{let{activeCaipNetwork:n}=t;e({caipNetwork:n,chainId:null===n||void 0===n?void 0:n.id,caipNetworkId:null===n||void 0===n?void 0:n.caipNetworkId})})}subscribeWalletInfo(e,t){return t?r.W.subscribeChainProp("accountState",t=>e(null===t||void 0===t?void 0:t.connectedWalletInfo),t):r.W.subscribeChainProp("accountState",t=>e(null===t||void 0===t?void 0:t.connectedWalletInfo))}subscribeShouldUpdateToAddress(e){r.W.subscribeChainProp("accountState",t=>e(null===t||void 0===t?void 0:t.shouldUpdateToAddress))}subscribeCaipNetworkChange(e){r.W.subscribeKey("activeCaipNetwork",e)}getState(){return K.z.state}getRemoteFeatures(){return c.H.state.remoteFeatures}subscribeState(e){return K.z.subscribe(e)}subscribeRemoteFeatures(e){return c.H.subscribeKey("remoteFeatures",e)}showErrorMessage(e){z.P.showError(e)}showSuccessMessage(e){z.P.showSuccess(e)}getEvent(){return(0,i.A)({},H.E.state)}subscribeEvents(e){return H.E.subscribe(e)}replace(e){N.I.replace(e)}redirect(e){N.I.push(e)}popTransactionStack(e){N.I.popTransactionStack(e)}isOpen(){return F.W.state.open}isTransactionStackEmpty(){return 0===N.I.state.transactionStack.length}static getInstance(){return this.instance}updateFeatures(e){c.H.setFeatures(e)}updateRemoteFeatures(e){c.H.setRemoteFeatures(e)}updateOptions(e){const t=c.H.state||{},n=(0,i.A)((0,i.A)({},t),e);c.H.setOptions(n)}setConnectMethodsOrder(e){c.H.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){c.H.setWalletFeaturesOrder(e)}setCollapseWallets(e){c.H.setCollapseWallets(e)}setSocialsOrder(e){c.H.setSocialsOrder(e)}getConnectMethodsOrder(){return G.A.getConnectOrderMethod(c.H.state.features,s.a.getConnectors())}addNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error("Adapter for namespace ".concat(e," doesn't exist"));const n=this.extendCaipNetwork(t,this.options);this.getCaipNetworks().find(e=>e.id===n.id)||r.W.addNetwork(n)}removeNetwork(e,t){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error("Adapter for namespace ".concat(e," doesn't exist"));this.getCaipNetworks().find(e=>e.id===t)&&r.W.removeNetwork(e,t)}}let Re=!1;class xe extends Pe{async open(e){s.a.isConnected()||await super.open(e)}async close(){if(await super.close(),this.options.manualWCControl){var e;const t=null===(e=r.W.getAccountData(this.activeChainNamespace))||void 0===e?void 0:e.address;o.x.finalizeWcConnection(t)}}async syncIdentity(e){return Promise.resolve()}async syncBalance(e){return Promise.resolve()}
2async injectModalUi(){if(!Re&&a.w.isClient()){await Promise.all([n.e(4036),n.e(4680),n.e(2483)]).then(n.bind(n,22483)),await Promise.all([n.e(4680),n.e(7154)]).then(n.bind(n,27154));if(!document.querySelector("w3m-modal")){const e=document.createElement("w3m-modal");c.H.state.disableAppend||c.H.state.enableEmbedded||document.body.insertAdjacentElement("beforeend",e)}Re=!0}}}const Ue="1.8.7";function De(e){return new xe((0,i.A)((0,i.A)({},e),{},{basic:!0,sdkVersion:"html-core-".concat(Ue)}))}},57629:(e,t,n)=>{"use strict";n.d(t,{Z:()=>r});var i=n(24107);const s=".",r={getSpacingStyles:(e,t)=>Array.isArray(e)?e[t]?"var(--apkt-spacing-".concat(e[t],")"):void 0:"string"===typeof e?"var(--apkt-spacing-".concat(e,")"):void 0,getFormattedDate:e=>new Intl.DateTimeFormat("en-US",{month:"short",day:"numeric"}).format(e),formatCurrency(){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const t=Number(arguments.length>0&&void 0!==arguments[0]?arguments[0]:0);if(isNaN(t))return"$0.00";return new Intl.NumberFormat("en-US",(0,i.A)({style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2},e)).format(t)},getHostName(e){try{return new URL(e).hostname}catch(t){return""}},getTruncateString(e){let{string:t,charsStart:n,charsEnd:i,truncate:s}=e;return t.length<=n+i?t:"end"===s?"".concat(t.substring(0,n),"..."):"start"===s?"...".concat(t.substring(t.length-i)):"".concat(t.substring(0,Math.floor(n)),"...").concat(t.substring(t.length-Math.floor(i)))},generateAvatarColors(e){const t=e.toLowerCase().replace(/^0x/i,"").replace(/(?:[\0-\/:-`g-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g,"").substring(0,6).padEnd(6,"0"),n=this.hexToRgb(t),i=getComputedStyle(document.documentElement).getPropertyValue("--w3m-border-radius-master"),s=100-3*Number(null===i||void 0===i?void 0:i.replace("px","")),r="".concat(s,"% ").concat(s,"% at 65% 40%"),o=[];for(let a=0;a<5;a+=1){const e=this.tintColor(n,.15*a);o.push("rgb(".concat(e[0],", ").concat(e[1],", ").concat(e[2],")"))}return"\n --local-color-1: ".concat(o[0],";\n --local-color-2: ").concat(o[1],";\n --local-color-3: ").concat(o[2],";\n --local-color-4: ").concat(o[3],";\n --local-color-5: ").concat(o[4],";\n --local-radial-circle: ").concat(r,"\n ")},hexToRgb(e){const t=parseInt(e,16);return[t>>16&255,t>>8&255,255&t]},tintColor(e,t){const[n,i,s]=e;return[Math.round(n+(255-n)*t),Math.round(i+(255-i)*t),Math.round(s+(255-s)*t)]},isNumber:e=>/^[0-9]+$/.test(e),getColorTheme(e){return e||("undefined"!==typeof window&&window.matchMedia&&"function"===typeof window.matchMedia?null!==(t=window.matchMedia("(prefers-color-scheme: dark)"))&&void 0!==t&&t.matches?"dark":"light":"dark");var t},splitBalance(e){const t=e.split(".");return 2===t.length?[t[0],t[1]]:["0","00"]},roundNumber:(e,t,n)=>e.toString().length>=t?Number(e).toFixed(n):e,cssDurationToNumber:e=>e.endsWith("s")?1e3*Number(e.replace("s","")):e.endsWith("ms")?Number(e.replace("ms","")):0,maskInput(e){let{value:t,decimals:n,integers:i}=e;if(t=t.replace(",","."),t===s)return"0".concat(s);const[r="",o]=t.split(s).map(e=>e.replace(/(?:[\0-\/:-\uD7FF\uE000-\uFFFF]|[\uD800-\uDBFF][\uDC00-\uDFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF])/g,"")),a=i?r.substring(0,i):r,c=2===a.length?String(Number(a)):a,l="number"===typeof n?null===o||void 0===o?void 0:o.substring(0,n):o,d="string"===typeof l&&("number"!==typeof n||n>0)?[c,l].join(s):c;return null!==d&&void 0!==d?d:""},capitalize:e=>e?e.charAt(0).toUpperCase()+e.slice(1):""}},59931:(e,t,n)=>{"use strict";n.d(t,{S:()=>s});var i=n(77011);const s={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 n=new i.A(e),s=new i.A(t);return n.times(s)},toFixed(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return void 0===e||""===e?new i.A(0).toFixed(t):new i.A(e).toFixed(t)},formatNumberToLocalString(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:2;return void 0===e||""===e?"0.00":"number"===typeof e?e.toLocaleStr
2ing("en-US",{maximumFractionDigits:t,minimumFractionDigits:t,roundingMode:"floor"}):parseFloat(e).toLocaleString("en-US",{maximumFractionDigits:t,minimumFractionDigits:t,roundingMode:"floor"})},parseLocalStringToNumber(e){if(void 0===e||""===e)return 0;const t=e.replace(/,/g,"");return new i.A(t).toNumber()}}},62463:(e,t,n)=>{"use strict";n.d(t,{P:()=>l});var i=n(24107),s=n(18539),r=n(35574),o=n(78854);const a=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),c=(0,s.BX)((0,i.A)({},a)),l={state:c,subscribeKey:(e,t)=>(0,r.u$)(c,e,t),showLoading(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};this._showMessage((0,i.A)({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=o.w.parseError(e);this._showMessage({message:t,variant:"error"})},hide(){c.message=a.message,c.variant=a.variant,c.svg=a.svg,c.open=a.open,c.autoClose=a.autoClose},_showMessage(e){let{message:t,svg:n,variant:i="success",autoClose:s=a.autoClose}=e;c.open?(c.open=!1,setTimeout(()=>{c.message=t,c.variant=i,c.svg=n,c.open=!0,c.autoClose=s},150)):(c.message=t,c.variant=i,c.svg=n,c.open=!0,c.autoClose=s)}}},62951:(e,t,n)=>{"use strict";n.d(t,{C:()=>i});const i={validateCaipAddress(e){var t;if(3!==(null===(t=e.split(":"))||void 0===t?void 0:t.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: ".concat(e));const[n,i,s]=t;if(!n||!i||!s)throw new Error("Invalid CAIP-10 address: ".concat(e));return{chainNamespace:n,chainId:i,address:s}},parseCaipNetworkId(e){const t=e.split(":");if(2!==t.length)throw new Error("Invalid CAIP-2 network id: ".concat(e));const[n,i]=t;if(!n||!i)throw new Error("Invalid CAIP-2 network id: ".concat(e));return{chainNamespace:n,chainId:i}}}},64275:function(e){e.exports=function(){"use strict";var e=1e3,t=6e4,n=36e5,i="millisecond",s="second",r="minute",o="hour",a="day",c="week",l="month",d="quarter",h="year",u="date",p="Invalid Date",f=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,g=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,v={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}},m=function(e,t,n){var i=String(e);return!i||i.length>=t?e:""+Array(t+1-i.length).join(n)+e},y={s:m,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),i=Math.floor(n/60),s=n%60;return(t<=0?"+":"-")+m(i,2,"0")+":"+m(s,2,"0")},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var i=12*(n.year()-t.year())+(n.month()-t.month()),s=t.clone().add(i,l),r=n-s<0,o=t.clone().add(i+(r?-1:1),l);return+(-(i+(n-s)/(r?s-o:o-s))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:l,y:h,w:c,d:a,D:u,h:o,m:r,s:s,ms:i,Q:d}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},w="en",b={};b[w]=v;var E="$isDayjsObject",C=function(e){return e instanceof S||!(!e||!e[E])},A=function e(t,n,i){var s;if(!t)return w;if("string"==typeof t){var r=t.toLowerCase();b[r]&&(s=r),n&&(b[r]=n,s=r);var o=t.split("-");if(!s&&o.length>1)return e(o[0])}else{var a=t.name;b[a]=t,s=a}return!i&&s&&(w=s),s||!i&&w},I=function(e,t){if(C(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new S(n)},N=y;N.l=A,N.i=C,N.w=function(e,t){return I(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var S=function(){function v(e){this.$L=A(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[E]=!0}var m=v.prototype;return m.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(N.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var i=t.match(f);if(i){var s=i[2]-1||0,r=(i[7]||"0").substring(0,3);return n?new Date(Date.UTC(i[1],s,i[3]||1,i[4]||0,i[5]||0,i[6]||0,r)):new Date(i[1],s,i[3]||1,i[4]||0,i[5]||0,i[6]||0,r)}}return new Date(t)}(e),this.init()},m.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},m.$utils=function(){return N},m.isValid=function(){return!(this.$d.toString()===p)},m.isSame=function(e,t){var n=I(e);return this.startOf(t)<=n&&n<=this.endOf(t)},m.isAfter=function(e,t){return I(e)<this.startOf(t)},m.isBefore=function(e,t){return this.endOf(t)<I(e)},m.$g=function(e,t,n){return N.u(e)?this[t]:this.set(n,e)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(e,t){var n=this,i=!!N.u(t)||t,d=N.p(e),p=function(e,t){var s=N.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return i?s:s.endOf(a)},f=function(e,t){return N.w(n.toDate()[e].apply(n.toDate("s"),(i?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},g=this.$W,v=this.$M,m=this.$D,y="set"+(this.$u?"UTC":"");switch(d){case h:return i?p(1,0):p(31,11);case l:return i?p(1,v):p(0,v+1);case c:var w=this.$locale().weekStart||0,b=(g<w?g+7:g)-w;return p(i?m-b:m+(6-b),v);case a:case u:return f(y+"Hours",0);case o:return f(y+"Minutes",1);case r:return f(y+"Seconds",2);case s:return f(y+"Milliseconds",3);default:return this.clone()}},m.endOf=function(e){return this.startOf(e,!1)},m.$set=function(e,t){var n,c=N.p(e),d="set"+(this.$u?"UTC":""),p=(n={},n[a]=d+"Date",n[u]=d+"Date",n[l]=d+"Month",n[h]=d+"FullYear",n[o]=d+"Hours",n[r]=d+"Minutes",n[s]=d+"Seconds",n[i]=d+"Milliseconds",n)[c],f=c===a?this.$D+(t-this.$W):t;if(c===l||c===h){var g=this.clone().set(u,1);g.$d[p](f),g.init(),this.$d=g.set(u,Math.min(this.$D,g.daysInMonth())).$d}else p&&this.$d[p](f);return this.init(),this},m.set=function(e,t){return this.clone().$set(e,t)},m.get=function(e){return this[N.p(e)]()},m.add=function(i,d){var u,p=this;i=Number(i);var f=N.p(d),g=function(e){var t=I(p);return N.w(t.date(t.date()+Math.round(e*i)),p)};if(f===l)return this.set(l,this.$M+i);if(f===h)return this.set(h,this.$y+i);if(f===a)return g(1);if(f===c)return g(7);var v=(u={},u[r]=t,u[o]=n,u[s]=e,u)[f]||1,m=this.$d.getTime()+i*v;return N.w(m,this)},m.subtract=function(e,t){return this.add(-1*e,t)},m.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var i=e||"YYYY-MM-DDTHH:mm:ssZ",s=N.z(this),r=this.$H,o=this.$m,a=this.$M,c=n.weekdays,l=n.months,d=n.meridiem,h=function(e,n,s,r){return e&&(e[
2n]||e(t,i))||s[n].slice(0,r)},u=function(e){return N.s(r%12||12,e,"0")},f=d||function(e,t,n){var i=e<12?"AM":"PM";return n?i.toLowerCase():i};return i.replace(g,function(e,i){return i||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return N.s(t.$y,4,"0");case"M":return a+1;case"MM":return N.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,l,3);case"MMMM":return h(l,a);case"D":return t.$D;case"DD":return N.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return h(n.weekdaysMin,t.$W,c,2);case"ddd":return h(n.weekdaysShort,t.$W,c,3);case"dddd":return c[t.$W];case"H":return String(r);case"HH":return N.s(r,2,"0");case"h":return u(1);case"hh":return u(2);case"a":return f(r,o,!0);case"A":return f(r,o,!1);case"m":return String(o);case"mm":return N.s(o,2,"0");case"s":return String(t.$s);case"ss":return N.s(t.$s,2,"0");case"SSS":return N.s(t.$ms,3,"0");case"Z":return s}return null}(e)||s.replace(":","")})},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(i,u,p){var f,g=this,v=N.p(u),m=I(i),y=(m.utcOffset()-this.utcOffset())*t,w=this-m,b=function(){return N.m(g,m)};switch(v){case h:f=b()/12;break;case l:f=b();break;case d:f=b()/3;break;case c:f=(w-y)/6048e5;break;case a:f=(w-y)/864e5;break;case o:f=w/n;break;case r:f=w/t;break;case s:f=w/e;break;default:f=w}return p?f:N.a(f)},m.daysInMonth=function(){return this.endOf(l).$D},m.$locale=function(){return b[this.$L]},m.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),i=A(e,t,!0);return i&&(n.$L=i),n},m.clone=function(){return N.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},v}(),_=S.prototype;return I.prototype=_,[["$ms",i],["$s",s],["$m",r],["$H",o],["$W",a],["$M",l],["$y",h],["$D",u]].forEach(function(e){_[e[1]]=function(t){return this.$g(t,e[0],e[1])}}),I.extend=function(e,t){return e.$i||(e(t,S,I),e.$i=!0),I},I.locale=A,I.isDayjs=C,I.unix=function(e){return I(1e3*e)},I.en=b[w],I.Ls=b,I.p={},I}()},64751:(e,t,n)=>{"use strict";n.d(t,{Z:()=>y});var i=n(42483),s=n(97811),r=n(84873),o=n(62951),a=n(87931),c=n(10232),l=n(50390),d=n(47482);const h={createBalance(e,t){const n={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:n.name,symbol:n.symbol,chainId:t,address:"native"===e.address?void 0:this.convertAddressToCAIP10Address(e.address,t),value:n.value,price:n.price,quantity:{decimals:n.decimals.toString(),numeric:this.convertHexToBalance({hex:e.balance,decimals:n.decimals})},iconUrl:n.iconUrl}},convertHexToBalance(e){let{hex:t,decimals:n}=e;return(0,s.J)(BigInt(t),n)},convertAddressToCAIP10Address:(e,t)=>"".concat(t,":").concat(e),createCAIP2ChainId:(e,t)=>"".concat(t,":").concat(parseInt(e,16)),getChainIdHexFromCAIP2ChainId(e){const t=e.split(":");if(t.length<2||!t[1])return"0x0";const n=t[1],i=parseInt(n,10);return isNaN(i)?"0x0":"0x".concat(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};var u=n(81828),p=n(24107),f=n(46443);let g;async function v(){if(!g){const{createPublicClient:e,http:t,defineChain:i}=await n.e(7516).then(n.bind(n,27516));g={createPublicClient:e,http:t,defineChain:i}}return g}const m={getBlockchainApiRpcUrl(e,t){const n=new URL("https://rpc.walletconnect.org/v1/");return n.searchParams.set("chainId",e),n.searchParams.set("projectId",t),n.toString()},async getViemChain(e){const{defineChain:t}=await v(),{chainId:n}=o.C.parseCaipNetworkId(e.caipNetworkId);return t((0,p.A)((0,p.A)({},e),{},{id:Number(n)}))},async createViemPublicClient(e){const{createPublicClient:t,http:n}=await v(),i=f.H.state.projectId,s=await m.getViemChain(e);if(!s)throw new Error("Chain ".concat(e.caipNetworkId," not found in viem/chains"));return t({chain:s,transport:n(m.getBlockchainApiRpcUrl(e.caipNetworkId,i))})}},y={async getMyTokensWithBalance(e){var t;const n=null===(t=c.W.getAccountData())||void 0===t?void 0:t.address,i=c.W.state.activeCaipNetwork,s=d.a.getConnectorId("eip155")===r.o.CONNECTOR_ID.AUTH;if(!n||!i)return[];const o="".concat(i.caipNetworkId,":").concat(n),l=u.i.getBalanceCacheForCaipAddress(o);if(l)return l.balances;if(i.chainNamespace===r.o.CHAIN.EVM&&s){const e=await this.getEIP155Balances(n,i);if(e)return this.filterLowQualityTokens(e)}const h=await a.T.getBalance(n,i.caipNetworkId,e);return this.filterLowQualityTokens(h.balances)},async getEIP155Balances(e,t){try{var n;const i=h.getChainIdHexFromCAIP2ChainId(t.caipNetworkId),s=await l.x.getCapabilities(e);if(null===s||void 0===s||null===(n=s[i])||void 0===n||null===(n=n.assetDiscovery)||void 0===n||!n.supported)return null;const r=await l.x.walletGetAssets({account:e,chainFilter:[i]});if(!h.isWalletGetAssetsResponse(r))return null;const o=(r[i]||[]).map(e=>h.createBalance(e,t.caipNetworkId));return u.i.updateBalanceCache({caipAddress:"".concat(t.caipNetworkId,":").concat(e),balance:{balances:o},timestamp:Date.now()}),o}catch(i){return null}},filterLowQualityTokens:e=>e.filter(e=>"0"!==e.quantity.decimals),async fetchERC20Balance(e){let{caipAddress:t,assetAddress:n,caipNetwork:r}=e;const a=await m.createViemPublicClient(r),{address:c}=o.C.parseCaipAddress(t),[{result:l},{result:d},{result:h},{result:u}]=await a.multicall({contracts:[{address:n,functionName:"name",args:[],abi:i.xw},{address:n,functionName:"symbol",args:[],abi:i.xw},{address:n,functionName:"balanceOf",args:[c],abi:i.xw},{address:n,functionName:"decimals",args:[],abi:i.xw}]});
2return{name:l,symbol:d,decimals:u,balance:h&&u?(0,s.J)(h,u):"0"}}}},64985:(e,t,n)=>{"use strict";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:n,elements:i}=t;return{kind:n,elements:i,finisher(t){customElements.get(e)||customElements.define(e,t)}}}(e,t)}}n.d(t,{E:()=>i})},65073:(e,t,n)=>{"use strict";n.d(t,{LU:()=>i,R7:()=>s});const i={core:{backgroundAccentPrimary:"#0988F0",backgroundAccentCertified:"#C7B994",backgroundWalletKit:"#FFB800",backgroundAppKit:"#FF573B",backgroundCloud:"#0988F0",backgroundDocumentation:"#008847",backgroundSuccess:"rgba(48, 164, 107, 0.20)",backgroundError:"rgba(223, 74, 52, 0.20)",backgroundWarning:"rgba(243, 161, 63, 0.20)",textAccentPrimary:"#0988F0",textAccentCertified:"#C7B994",textWalletKit:"#FFB800",textAppKit:"#FF573B",textCloud:"#0988F0",textDocumentation:"#008847",textSuccess:"#30A46B",textError:"#DF4A34",textWarning:"#F3A13F",borderAccentPrimary:"#0988F0",borderSecondary:"#C7B994",borderSuccess:"#30A46B",borderError:"#DF4A34",borderWarning:"#F3A13F",foregroundAccent010:"rgba(9, 136, 240, 0.1)",foregroundAccent020:"rgba(9, 136, 240, 0.2)",foregroundAccent040:"rgba(9, 136, 240, 0.4)",foregroundAccent060:"rgba(9, 136, 240, 0.6)",foregroundSecondary020:"rgba(199, 185, 148, 0.2)",foregroundSecondary040:"rgba(199, 185, 148, 0.4)",foregroundSecondary060:"rgba(199, 185, 148, 0.6)",iconAccentPrimary:"#0988F0",iconAccentCertified:"#C7B994",iconSuccess:"#30A46B",iconError:"#DF4A34",iconWarning:"#F3A13F",glass010:"rgba(255, 255, 255, 0.1)",zIndex:"9999"},dark:{overlay:"rgba(0, 0, 0, 0.50)",backgroundPrimary:"#202020",backgroundInvert:"#FFFFFF",textPrimary:"#FFFFFF",textSecondary:"#9A9A9A",textTertiary:"#BBBBBB",textInvert:"#202020",borderPrimary:"#2A2A2A",borderPrimaryDark:"#363636",borderSecondary:"#4F4F4F",foregroundPrimary:"#252525",foregroundSecondary:"#2A2A2A",foregroundTertiary:"#363636",iconDefault:"#9A9A9A",iconInverse:"#FFFFFF"},light:{overlay:"rgba(230 , 230, 230, 0.5)",backgroundPrimary:"#FFFFFF",borderPrimaryDark:"#E9E9E9",backgroundInvert:"#202020",textPrimary:"#202020",textSecondary:"#9A9A9A",textTertiary:"#6C6C6C",textInvert:"#FFFFFF",borderPrimary:"#E9E9E9",borderSecondary:"#D0D0D0",foregroundPrimary:"#F3F3F3",foregroundSecondary:"#E9E9E9",foregroundTertiary:"#D0D0D0",iconDefault:"#9A9A9A",iconInverse:"#202020"}},s={colors:{black:"#202020",white:"#FFFFFF",white010:"rgba(255, 255, 255, 0.1)",accent010:"rgba(9, 136, 240, 0.1)",accent020:"rgba(9, 136, 240, 0.2)",accent030:"rgba(9, 136, 240, 0.3)",accent040:"rgba(9, 136, 240, 0.4)",accent050:"rgba(9, 136, 240, 0.5)",accent060:"rgba(9, 136, 240, 0.6)",accent070:"rgba(9, 136, 240, 0.7)",accent080:"rgba(9, 136, 240, 0.8)",accent090:"rgba(9, 136, 240, 0.9)",accent100:"rgba(9, 136, 240, 1.0)",accentSecondary010:"rgba(199, 185, 148, 0.1)",accentSecondary020:"rgba(199, 185, 148, 0.2)",accentSecondary030:"rgba(199, 185, 148, 0.3)",accentSecondary040:"rgba(199, 185, 148, 0.4)",accentSecondary050:"rgba(199, 185, 148, 0.5)",accentSecondary060:"rgba(199, 185, 148, 0.6)",accentSecondary070:"rgba(199, 185, 148, 0.7)",accentSecondary080:"rgba(199, 185, 148, 0.8)",accentSecondary090:"rgba(199, 185, 148, 0.9)",accentSecondary100:"rgba(199, 185, 148, 1.0)",productWalletKit:"#FFB800",productAppKit:"#FF573B",productCloud:"#0988F0",productDocumentation:"#008847",neutrals050:"#F6F6F6",neutrals100:"#F3F3F3",neutrals200:"#E9E9E9",neutrals300:"#D0D0D0",neutrals400:"#BBB",neutrals500:"#9A9A9A",neutrals600:"#6C6C6C",neutrals700:"#4F4F4F",neutrals800:"#363636",neutrals900:"#2A2A2A",neutrals1000:"#252525",semanticSuccess010:"rgba(48, 164, 107, 0.1)",semanticSuccess020:"rgba(48, 164, 107, 0.2)",semanticSuccess030:"rgba(48, 164, 107, 0.3)",semanticSuccess040:"rgba(48, 164, 107, 0.4)",semanticSuccess050:"rgba(48, 164, 107, 0.5)",semanticSuccess060:"rgba(48, 164, 107, 0.6)",semanticSuccess070:"rgba(48, 164, 107, 0.7)",semanticSuccess080:"rgba(48, 164, 107, 0.8)",semanticSuccess090:"rgba(48, 164, 107, 0.9)",semanticSuccess100:"rgba(48, 164, 107, 1.0)",semanticError010:"rgba(223, 74, 52, 0.1)",semanticError020:"rgba(223, 74, 52, 0.2)",semanticError030:"rgba(223, 74, 52, 0.3)",semanticError040:"rgba(223, 74, 52, 0.4)",semanticError050:"rgba(223, 74, 52, 0.5)",semanticError060:"rgba(223, 74, 52, 0.6)",semanticError070:"rgba(223, 74, 52, 0.7)",semanticError080:"rgba(223, 74, 52, 0.8)",semanticError090:"rgba(223, 74, 52, 0.9)",semanticError100:"rgba(223, 74, 52, 1.0)",semanticWarning010:"rgba(243, 161, 63, 0.1)",semanticWarning020:"rgba(243, 161, 63, 0.2)",semanticWarning030:"rgba(243, 161, 63, 0.3)",semanticWarning040:"rgba(243, 161, 63, 0.4)",semanticWarning050:"rgba(243, 161, 63, 0.5)",semanticWarning060:"rgba(243, 161, 63, 0.6)",semanticWarning070:"rgba(243, 161, 63, 0.7)",semanticWarning080:"rgba(243, 161, 63, 0.8)",semanticWarning090:"rgba(243, 161, 63, 0.9)",semanticWarning100:"rgba(243, 161, 63, 1.0)"},fontFamily:{regular:"KHTeka",mono:"KHTekaMono"},fontWeight:{regular:"400",medium:"500"},textSize:{h1:"50px",h2:"44px",h3:"38px",h4:"32px",h5:"26px",h6:"20px",large:"16px",medium:"14px",small:"12px"},typography:{"h1-regular-mono":{lineHeight:"50px",letterSpacing:"-3px"},"h1-regular":{lineHeight:"50px",letterSpacing:"-1px"},"h1-medium":{lineHeight:"50px",letterSpacing:"-0.84px"},"h2-regular-mono":{lineHeight:"44px",letterSpacing:"-2.64px"},"h2-regular":{lineHeight:"44px",letterSpacing:"-0.88px"},"h2-medium":{lineHeight:"44px",letterSpacing:"-0.88px"},"h3-regular-mono":{lineHeight:"38px",letterSpacing:"-2.28px"},"h3-regular":{lineHeight:"38px",letterSpacing:"-0.76px"},"h3-medium":{lineHeight:"38px",letterSpacing:"-0.76px"},"h4-regular-mono":{lineHeight:"32px",letterSpacing:"-1.92px"},"h4-regular":{lineHeight:"32px",letterSpacing:"-0.32px"},"h4-medium":{lineHeight:"32px",letterSpacing:"-0.32px"},"h5-regular-mono":{lineHeight:"26px",letterSpacing:"-1.56px"},"h5-regular":{lineHeight:"26px",letterSpacing:"-0.26px"},"h5-medium":{lineHeight:"26px",letterSpacing:"-0.26px"},"h6-regular-mono":{lineHeight:"20px",letterSpacing:"-1.2px"},"h6-regular":{lineHeight:"20px",letterSpacing:"-0.6px"},"h6-medium":{lineHeight:"20px",letterSpacing:"-0.6px"},"lg-regular-mono":{lineHeight:"16px",letterSpacing:"-0.96px"},"lg-regular":{lineHeight:"18px",letterSpacing:"-0.16px"},"lg-medium":{lineHeight:"18px",letterSpacing:"-0.16px"},"md-regular-mono":{lineHeight:"14px",letterSpacing:"-0.84px"},"md-regular":{lineHeight:"16px",letterSpacing:"-0.14px"},"md-medium":{lineHeight:"16px",letterSpacing:"-0.14px"},"sm-regular-mono":{lineHeight:"12px",letterSpacing:"-0.72px"},"sm-regular":{lineHeight:"14px",letterSpacing:"-0.12px"},"sm-medium":{lineHeight:"14px",letterSpacing:"-0.12px"}},tokens:{core:i.core,theme:i.dark},borderRadius:{1:"4px",2:"8px",10:"10px",3:"12px",4:"16px",6:"24px",5:"20px",8:"32px",16:"64px",20:"80px",32:"128px",64:"256px",128:"512px",round:"9999px"},spacing:{0:"0px","01":"2px",1:"4px",2:"8px",3:"12px",4:"16px",5:"20px",6:"24px",7:"28px",8:"32px",9:"36px",10:"40px",12:"48px",14:"56px",16:"64px",20:"80px",32:"128px",64:"256px"},durations:{xl:"400ms",lg:"200ms",md:"125ms",sm:"75ms"}
2,easings:{"ease-out-power-2":"cubic-bezier(0.23, 0.09, 0.08, 1.13)","ease-out-power-1":"cubic-bezier(0.12, 0.04, 0.2, 1.06)","ease-in-power-2":"cubic-bezier(0.92, -0.13, 0.77, 0.91)","ease-in-power-1":"cubic-bezier(0.88, -0.06, 0.8, 0.96)","ease-inout-power-2":"cubic-bezier(0.77, 0.09, 0.23, 1.13)","ease-inout-power-1":"cubic-bezier(0.88, 0.04, 0.12, 1.06)"}}},67531:(e,t,n)=>{"use strict";n.d(t,{Zv:()=>s.Z,AH:()=>u.AH,EM:()=>h.E,RF:()=>i.RF,JX:()=>i.JX,ds:()=>i.ds,f:()=>u.f});var i=n(86114),s=n(57629),r=n(24107),o=n(64275),a=n(20140),c=n(48181),l=n(12491);o.extend(c),o.extend(l);const d=(0,r.A)((0,r.A)({},a),{},{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"}});o.locale("en-web3-modal",d);var h=n(64985),u=(n(65073),n(88690))},67666:(e,t,n)=>{"use strict";n.d(t,{U:()=>m});var i=n(24107),s=(n(74500),n(84873)),r=n(38190),o=n(10232),a=n(50390),c=n(47482),l=n(74520),d=n(23976),h=n(46443),u=n(28956),p=n(62463),f=n(69968),g=n(78854);let v=null;const m={getSIWX:()=>h.H.state.siwx,async initializeIfEnabled(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:o.W.getActiveCaipAddress();const t=h.H.state.siwx;if(!t||!e)return;const[n,i,s]=e.split(":");if(o.W.checkIfSupportedNetwork(n,"".concat(n,":").concat(i)))try{var r;if(null!==(r=h.H.state.remoteFeatures)&&void 0!==r&&r.emailCapture){var c,f;const e=null===(c=o.W.getAccountData(n))||void 0===c?void 0:c.user;return void await d.W.open({view:"DataCapture",data:{email:null!==(f=null===e||void 0===e?void 0:e.email)&&void 0!==f?f:void 0}})}v&&await v;if((await t.getSessions("".concat(n,":").concat(i),s)).length)return;await d.W.open({view:"SIWXSignMessage"})}catch(m){var g;console.error("SIWXUtil:initializeIfEnabled",m),l.E.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties(m)}),await(null===(g=a.x._getClient())||void 0===g?void 0:g.disconnect().catch(console.error)),u.I.reset("Connect"),p.P.showError("A problem occurred while trying initialize authentication")}},async requestSignMessage(){const e=h.H.state.siwx,t=g.w.getPlainAddress(o.W.getActiveCaipAddress()),n=(0,f.kg)(),i=a.x._getClient();if(!e)throw new Error("SIWX is not enabled");if(!t)throw new Error("No ActiveCaipAddress found");if(!n)throw new Error("No ActiveCaipNetwork or client found");if(!i)throw new Error("No ConnectionController client found");try{const r=await e.createMessage({chainId:n.caipNetworkId,accountAddress:t}),a=r.toString();c.a.getConnectorId(n.chainNamespace)===s.o.CONNECTOR_ID.AUTH&&u.I.pushTransactionStack({});const h=await i.signMessage(a);await e.addSession({data:r,message:a,signature:h}),o.W.setLastConnectedSIWECaipNetwork(n),d.W.close(),l.E.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:this.getSIWXEventProperties()})}catch(r){d.W.state.open&&"ApproveTransaction"!==u.I.state.view||await d.W.open({view:"SIWXSignMessage"}),p.P.showError("Error signing message"),l.E.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties(r)}),console.error("SWIXUtil:requestSignMessage",r)}},async cancelSignMessage(){try{var e;const t=this.getSIWX();if(null===t||void 0===t||null===(e=t.getRequired)||void 0===e?void 0:e.call(t)){const e=o.W.getLastConnectedSIWECaipNetwork();if(e){const n=await(null===t||void 0===t?void 0:t.getSessions(null===e||void 0===e?void 0:e.caipNetworkId,g.w.getPlainAddress(o.W.getActiveCaipAddress())||""));n&&n.length>0?await o.W.switchActiveNetwork(e):await a.x.disconnect()}else await a.x.disconnect()}else d.W.close();d.W.close(),l.E.sendEvent({event:"CLICK_CANCEL_SIWX",type:"track",properties:this.getSIWXEventProperties()})}catch(t){console.error("SIWXUtil:cancelSignMessage",t)}},async getAllSessions(){const e=this.getSIWX(),t=o.W.getAllRequestedCaipNetworks(),n=[];return await Promise.all(t.map(async t=>{const i=await(null===e||void 0===e?void 0:e.getSessions(t.caipNetworkId,g.w.getPlainAddress(o.W.getActiveCaipAddress())||""));i&&n.push(...i)})),n},async getSessions(e){const t=h.H.state.siwx;let n=null===e||void 0===e?void 0:e.address;if(!n){const e=o.W.getActiveCaipAddress();n=g.w.getPlainAddress(e)}let i=null===e||void 0===e?void 0:e.caipNetworkId;if(!i){const e=o.W.getActiveCaipNetwork();i=null===e||void 0===e?void 0:e.caipNetworkId}return t&&n&&i?t.getSessions(i,n):[]},async isSIWXCloseDisabled(){const e=this.getSIWX();if(e){const n="ApproveTransaction"===u.I.state.view,i="SIWXSignMessage"===u.I.state.view;var t;if(n||i)return(null===(t=e.getRequired)||void 0===t?void 0:t.call(e))&&0===(await this.get
2Sessions()).length}return!1},async authConnectorAuthenticate(e){var t;let{authConnector:n,chainId:i,socialUri:r,preferredAccountType:a,chainNamespace:c}=e;const l=m.getSIWX(),d=(0,f.kg)();if(!l||!c.includes(s.o.CHAIN.EVM)||null!==(t=h.H.state.remoteFeatures)&&void 0!==t&&t.emailCapture){const e=await n.connect({chainId:i,socialUri:r,preferredAccountType:a});return{address:e.address,chainId:e.chainId,accounts:e.accounts}}const u="".concat(c,":").concat(i),p=await l.createMessage({chainId:u,accountAddress:"<<AccountAddress>>"}),g={accountAddress:p.accountAddress,chainId:p.chainId,domain:p.domain,uri:p.uri,version:p.version,nonce:p.nonce,notBefore:p.notBefore,statement:p.statement,resources:p.resources,requestId:p.requestId,issuedAt:p.issuedAt,expirationTime:p.expirationTime,serializedMessage:p.toString()},v=await n.connect({chainId:i,socialUri:r,siwxMessage:g,preferredAccountType:a});if(g.accountAddress=v.address,g.serializedMessage=v.message||"",v.signature&&v.message){const e=m.addEmbeddedWalletSession(g,v.message,v.signature);await e}return o.W.setLastConnectedSIWECaipNetwork(d),{address:v.address,chainId:v.chainId,accounts:v.accounts}},async addEmbeddedWalletSession(e,t,n){if(v)return v;const i=m.getSIWX();return i?(v=i.addSession({data:e,message:t,signature:n}).finally(()=>{v=null}),v):Promise.resolve()},async universalProviderAuthenticate(e){var t,n,s;let{universalProvider:r,chains:a,methods:c}=e;const d=m.getSIWX(),h=(0,f.kg)(),u=new Set(a.map(e=>e.split(":")[0]));if(!d||1!==u.size||!u.has("eip155"))return!1;const g=await d.createMessage({chainId:(null===(t=(0,f.kg)())||void 0===t?void 0:t.caipNetworkId)||"",accountAddress:""}),v=await r.authenticate({nonce:g.nonce,domain:g.domain,uri:g.uri,exp:g.expirationTime,iat:g.issuedAt,nbf:g.notBefore,requestId:g.requestId,version:g.version,resources:g.resources,statement:g.statement,chainId:g.chainId,methods:c,chains:[g.chainId,...a.filter(e=>e!==g.chainId)]});p.P.showLoading("Authenticating...",{autoClose:!1});const y=(0,i.A)((0,i.A)({},v.session.peer.metadata),{},{name:v.session.peer.metadata.name,icon:null===(n=v.session.peer.metadata.icons)||void 0===n?void 0:n[0],type:"WALLET_CONNECT"});if(o.W.setAccountProp("connectedWalletInfo",y,Array.from(u)[0]),null!==v&&void 0!==v&&null!==(s=v.auths)&&void 0!==s&&s.length){const e=v.auths.map(e=>{const t=r.client.formatAuthMessage({request:e.p,iss:e.p.iss});return{data:(0,i.A)((0,i.A)({},e.p),{},{accountAddress:e.p.iss.split(":").slice(-1).join(""),chainId:e.p.iss.split(":").slice(2,4).join(":"),uri:e.p.aud,version:e.p.version||g.version,expirationTime:e.p.exp,issuedAt:e.p.iat,notBefore:e.p.nbf}),message:t,signature:e.s.s,cacao:e}});try{await d.setSessions(e),h&&o.W.setLastConnectedSIWECaipNetwork(h),l.E.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:m.getSIWXEventProperties()})}catch(w){throw console.error("SIWX:universalProviderAuth - failed to set sessions",w),l.E.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:m.getSIWXEventProperties(w)}),await r.disconnect().catch(console.error),w}finally{p.P.hide()}}return!0},getSIWXEventProperties(e){var t;const n=o.W.state.activeChain;if(!n)throw new Error("SIWXUtil:getSIWXEventProperties - namespace is required");return{network:(null===(t=o.W.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId)||"",isSmartAccount:(0,f.lj)(n)===r.Vl.ACCOUNT_TYPES.SMART_ACCOUNT,message:e?g.w.parseError(e):void 0}},async clearSessions(){const e=this.getSIWX();e&&await e.setSessions([])}}},69968:(e,t,n)=>{"use strict";n.d(t,{K1:()=>r,kg:()=>a,lj:()=>o});var i=n(10232),s=n(78256);function r(){var e,t;const n=(null===(e=i.W.state.activeCaipNetwork)||void 0===e?void 0:e.chainNamespace)||"eip155",r=(null===(t=i.W.state.activeCaipNetwork)||void 0===t?void 0:t.id)||1,o=s.oU.NATIVE_TOKEN_ADDRESS[n];return"".concat(n,":").concat(r,":").concat(o)}function o(e){var t;return null===(t=i.W.getAccountData(e))||void 0===t?void 0:t.preferredAccountType}function a(e){var t;return e?null===(t=i.W.state.chains.get(e))||void 0===t||null===(t=t.networkState)||void 0===t?void 0:t.caipNetwork:i.W.state.activeCaipNetwork}}
2,70689:(e,t,n)=>{"use strict";n.d(t,{Z:()=>h});var i=n(15882);const s=["headers","signal","cache"],r=["headers","signal"],o=["body","headers","signal"],a=["body","headers","signal"],c=["body","headers","signal"],l=["body"];async function d(){const e=await fetch(...arguments);if(!e.ok){throw new Error("HTTP status code: ".concat(e.status),{cause:e})}return e}class h{constructor(e){let{baseUrl:t,clientId:n}=e;this.baseUrl=t,this.clientId=n}async get(e){let{headers:t,signal:n,cache:r}=e,o=(0,i.A)(e,s);const a=this.createUrl(o);return(await d(a,{method:"GET",headers:t,signal:n,cache:r})).json()}async getBlob(e){let{headers:t,signal:n}=e,s=(0,i.A)(e,r);const o=this.createUrl(s);return(await d(o,{method:"GET",headers:t,signal:n})).blob()}async post(e){let{body:t,headers:n,signal:s}=e,r=(0,i.A)(e,o);const a=this.createUrl(r);return(await d(a,{method:"POST",headers:n,body:t?JSON.stringify(t):void 0,signal:s})).json()}async put(e){let{body:t,headers:n,signal:s}=e,r=(0,i.A)(e,a);const o=this.createUrl(r);return(await d(o,{method:"PUT",headers:n,body:t?JSON.stringify(t):void 0,signal:s})).json()}async delete(e){let{body:t,headers:n,signal:s}=e,r=(0,i.A)(e,c);const o=this.createUrl(r);return(await d(o,{method:"DELETE",headers:n,body:t?JSON.stringify(t):void 0,signal:s})).json()}createUrl(e){let{path:t,params:n}=e;const i=new URL(t,this.baseUrl);return n&&Object.entries(n).forEach(e=>{let[t,n]=e;n&&i.searchParams.append(t,n)}),this.clientId&&i.searchParams.append("clientId",this.clientId),i}sendBeacon(e){let{body:t}=e,n=(0,i.A)(e,l);const s=this.createUrl(n);return navigator.sendBeacon(s.toString(),t?JSON.stringify(t):void 0)}}},74500:(e,t,n)=>{"use strict";n.d(t,{A:()=>wg});var i=n(24107),s=n(69692),r=n.n(s),o=n(89557),a=n(30349),c=n(30911),l=n(46455),d=Object.defineProperty,h=(e,t,n)=>((e,t,n)=>t in e?d(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class u extends l.H{constructor(e){super(),this.opts=e,h(this,"protocol","wc"),h(this,"version",2)}}var p=Object.defineProperty,f=(e,t,n)=>((e,t,n)=>t in e?p(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class g extends l.H{constructor(e,t){super(),this.core=e,this.logger=t,f(this,"records",new Map)}}class v{constructor(e,t){this.logger=e,this.core=t}}class m extends l.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class y extends l.H{constructor(e){super()}}class w{constructor(e,t,n,i){this.core=e,this.logger=t,this.name=n}}Object.defineProperty;class b extends l.H{constructor(e,t){super(),this.relayer=e,this.logger=t}}class E extends l.H{constructor(e,t){super(),this.core=e,this.logger=t}}class C{constructor(e,t,n){this.core=e,this.logger=t,this.store=n}}class A{constructor(e,t){this.projectId=e,this.logger=t}}class I{constructor(e,t,n){this.core=e,this.logger=t,this.telemetryEnabled=n}}var N=Object.defineProperty,S=(e,t,n)=>((e,t,n)=>t in e?N(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);r();class _{constructor(e){this.opts=e,S(this,"protocol","wc"),S(this,"version",2)}}s.EventEmitter;class T{constructor(e){this.client=e}}var O=n(77628),k=n(77101),P=n(4750),R=n(91376),x=n(70121),U=n(50543);const D="2.36.0";let L={getDocsUrl:e=>{let{docsBaseUrl:t,docsPath:n="",docsSlug:i}=e;return n?"".concat(null!==t&&void 0!==t?t:"https://viem.sh").concat(n).concat(i?"#".concat(i):""):void 0},version:"viem@".concat(D)};class W extends Error{constructor(e){var t,n,s;let r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const o=r.cause instanceof W?r.cause.details:null!==(a=r.cause)&&void 0!==a&&a.message?r.cause.message:r.details;var a;const c=r.cause instanceof W&&r.cause.docsPath||r.docsPath,l=null===(t=(n=L).getDocsUrl)||void 0===t?void 0:t.call(n,(0,i.A)((0,i.A)({},r),{},{docsPath:c}));super([e||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...l?["Docs: ".concat(l)]:[],...o?["Details: ".concat(o)]:[],...L.version?["Version: ".concat(L.version)]:[]].join("\n"),r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=o,this.docsPath=c,this.metaMessages=r.metaMessages,this.name=null!==(s=r.name)&&void 0!==s?s:this.name,this.shortMessage=e,this.version=D}walk(e){return M(this,e)}}function M(e,t){return null!==t&&void 0!==t&&t(e)?e:e&&"object"===typeof e&&"cause"in e&&void 0!==e.cause?M(e.cause,t):t?null:e}function B(e){let{strict:t=!0}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return!!e&&("string"===typeof e&&(t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")))}class F extends W{constructor(e){let{size:t,targetSize:n,type:i}=e;super("".concat(i.charAt(0).toUpperCase()).concat(i.slice(1).toLowerCase()," size (").concat(t,") exceeds padding size (").concat(n,")."),{name:"SizeExceedsPaddingSizeError"})}}function j(e){let{dir:t,size:n=32}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"string"===typeof e?function(e){let{dir:t,size:n=32}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null===n)return e;const i=e.replace("0x","");if(i.length>2*n)throw new F({size:Math.ceil(i.length/2),targetSize:n,type:"hex"});return"0x".concat(i["right"===t?"padEnd":"padStart"](2*n,"0"))}(e,{dir:t,size:n}):function(e){let{dir:t,size:n=32}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(null===n)return e;if(e.length>n)throw new F({size:e.length,targetSize:n,type:"bytes"});const i=new Uint8Array(n);for(let s=0;s<n;s++){const r="right"===t;i[r?s:n-s-1]=e[r?s:e.length-s-1]}return i}(e,{dir:t,size:n})}class H extends W{constructor(e){let{max:t,min:n,signed:i,size:s,value:r}=e;super('Number "'.concat(r,'" is not in safe ').concat(s?"".concat(8*s,"-bit ").concat(i?"signed":"unsigned"," "):"","integer range ").concat(t?"(".concat(n," to ").concat(t,")"):"(above ".concat(n,")")),{name:"IntegerOutOfRangeError"})}}class q extends W{constructor(e){let{givenSize:t,maxSize:n}=e;super("Size cannot exceed ".concat(n," bytes. Given size: ").concat(t," bytes."),{name:"SizeOverflowError"})}}function V(e){return B(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function K(e,t){let{size:n}=t;if(V(e)>
2n)throw new q({givenSize:V(e),maxSize:n})}function z(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{signed:n}=t;t.size&&K(e,{size:t.size});const i=BigInt(e);if(!n)return i;const s=(e.length-2)/2;return i<=(1n<<8n*BigInt(s)-1n)-1n?i:i-BigInt("0x".concat("f".padStart(2*s,"f")))-1n}function $(e){return Number(z(e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:{}))}const G=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function J(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"number"===typeof e||"bigint"===typeof e?X(e,t):"string"===typeof e?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=Z.encode(e);return Y(n,t)}(e,t):"boolean"===typeof e?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n="0x".concat(Number(e));if("number"===typeof t.size)return K(n,{size:t.size}),j(n,{size:t.size});return n}(e,t):Y(e,t)}function Y(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n="";for(let s=0;s<e.length;s++)n+=G[e[s]];const i="0x".concat(n);return"number"===typeof t.size?(K(i,{size:t.size}),j(i,{dir:"right",size:t.size})):i}function X(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{signed:n,size:i}=t,s=BigInt(e);let r;i?r=n?(1n<<8n*BigInt(i)-1n)-1n:2n**(8n*BigInt(i))-1n:"number"===typeof e&&(r=BigInt(Number.MAX_SAFE_INTEGER));const o="bigint"===typeof r&&n?-r-1n:0;if(r&&s>r||s<o){const t="bigint"===typeof e?"n":"";throw new H({max:r?"".concat(r).concat(t):void 0,min:"".concat(o).concat(t),signed:n,size:i,value:"".concat(e).concat(t)})}const a="0x".concat((n&&s<0?(1n<<BigInt(8*i))+BigInt(s):s).toString(16));return i?j(a,{size:i}):a}const Z=new TextEncoder;const Q=new TextEncoder;function ee(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return"number"===typeof e||"bigint"===typeof e?function(e,t){const n=X(e,t);return ie(n)}(e,t):"boolean"===typeof e?function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=new Uint8Array(1);if(n[0]=Number(e),"number"===typeof t.size)return K(n,{size:t.size}),j(n,{size:t.size});return n}(e,t):B(e)?ie(e,t):se(e,t)}const te={zero:48,nine:57,A:65,F:70,a:97,f:102};function ne(e){return e>=te.zero&&e<=te.nine?e-te.zero:e>=te.A&&e<=te.F?e-(te.A-10):e>=te.a&&e<=te.f?e-(te.a-10):void 0}function ie(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e;t.size&&(K(n,{size:t.size}),n=j(n,{dir:"right",size:t.size}));let i=n.slice(2);i.length%2&&(i="0".concat(i));const s=i.length/2,r=new Uint8Array(s);for(let o=0,a=0;o<s;o++){const e=ne(i.charCodeAt(a++)),t=ne(i.charCodeAt(a++));if(void 0===e||void 0===t)throw new W('Invalid byte sequence ("'.concat(i[a-2]).concat(i[a-1],'" in "').concat(i,'").'));r[o]=16*e+t}return r}function se(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=Q.encode(e);return"number"===typeof t.size?(K(n,{size:t.size}),j(n,{dir:"right",size:t.size})):n}var re=n(75008);function oe(e,t){const n=t||"hex",i=(0,re.lY)(B(e,{strict:!1})?ee(e):e);return"bytes"===n?i:J(i)}class ae extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&void 0!==t&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const e=this.keys().next().value;e&&this.delete(e)}return this}}const ce=new ae(8192);function le(e,t){if(ce.has("".concat(e,".").concat(t)))return ce.get("".concat(e,".").concat(t));const n=t?"".concat(t).concat(e.toLowerCase()):e.substring(2).toLowerCase(),i=oe(se(n),"bytes"),s=(t?n.substring("".concat(t,"0x").length):n).split("");for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&s[o]&&(s[o]=s[o].toUpperCase()),(15&i[o>>1])>=8&&s[o+1]&&(s[o+1]=s[o+1].toUpperCase());const r="0x".concat(s.join(""));return ce.set("".concat(e,".").concat(t),r),r}function de(e){if(0===e||1===e)return e;if(27===e)return 0;if(28===e)return 1;throw new Error("Invalid yParityOrV value")}async function he(e){let{hash:t,signature:i}=e;return function(e){const t=oe("0x".concat(e.substring(4))).substring(26);return le("0x".concat(t))}(await async function(e){let{hash:t,signature:i}=e;const s=B(t)?t:J(t),{secp256k1:r}=await n.e(9694).then(n.bind(n,39694)),o=(()=>
2{if("object"===typeof i&&"r"in i&&"s"in i){const{r:e,s:t,v:n,yParity:s}=i,o=de(Number(null!==s&&void 0!==s?s:n));return new r.Signature(z(e),z(t)).addRecoveryBit(o)}const e=B(i)?i:J(i);if(65!==V(e))throw new Error("invalid signature length");const t=de($("0x".concat(e.slice(130))));return r.Signature.fromCompact(e.substring(2,130)).addRecoveryBit(t)})(),a=o.recoverPublicKey(s.substring(2)).toHex(!1);return"0x".concat(a)}({hash:t,signature:i}))}var ue=n(5890),pe=n(16447),fe=n(90268),ge=n(15957),ve=n(89225),me=n(23691),ye=n(34903);const we=":";function be(e){const[t,n]=e.split(we);return{namespace:t,reference:n}}function Ee(e,t){return e.includes(":")?[e]:t.chains||[]}var Ce=Object.defineProperty,Ae=Object.defineProperties,Ie=Object.getOwnPropertyDescriptors,Ne=Object.getOwnPropertySymbols,Se=Object.prototype.hasOwnProperty,_e=Object.prototype.propertyIsEnumerable,Te=(e,t,n)=>t in e?Ce(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Oe=(e,t)=>{for(var n in t||(t={}))Se.call(t,n)&&Te(e,n,t[n]);if(Ne)for(var n of Ne(t))_e.call(t,n)&&Te(e,n,t[n]);return e},ke=(e,t,n)=>Te(e,"symbol"!=typeof t?t+"":t,n);const Pe="react-native",Re="node",xe="browser",Ue="unknown",De="js";function Le(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function We(){return!(0,x.getDocument)()&&!!(0,x.getNavigator)()&&"ReactNative"===navigator.product}function Me(){return!Le()&&!!(0,x.getNavigator)()&&!!(0,x.getDocument)()}function Be(){return We()?Pe:Le()?Re:Me()?xe:Ue}function Fe(){var e;try{return We()&&typeof n.g<"u"&&typeof(null==n.g?void 0:n.g.Application)<"u"?null==(e=n.g.Application)?void 0:e.applicationId:void 0}catch(t){return}}function je(e){var t,n;const i=He();try{return null!=e&&e.url&&i.url&&new URL(e.url).host!==new URL(i.url).host&&(console.warn("The configured WalletConnect 'metadata.url':".concat(e.url," differs from the actual page url:").concat(i.url,". This is probably unintended and can lead to issues.")),e.url=i.url),null!=(t=null===e||void 0===e?void 0:e.icons)&&t.length&&e.icons.length>0&&(e.icons=e.icons.filter(e=>""!==e)),((e,t)=>Ae(e,Ie(t)))(Oe(Oe({},i),e),{url:(null===e||void 0===e?void 0:e.url)||i.url,name:(null===e||void 0===e?void 0:e.name)||i.name,description:(null===e||void 0===e?void 0:e.description)||i.description,icons:null!=(n=null===e||void 0===e?void 0:e.icons)&&n.length&&e.icons.length>0?e.icons:i.icons})}catch(s){return console.warn("Error populating app metadata",s),e||i}}function He(){return(0,U.g)()||{name:"",description:"",url:"",icons:[""]}}function qe(e,t,i){const s=function(){if(Be()===Pe&&typeof n.g<"u"&&typeof(null==n.g?void 0:n.g.Platform)<"u"){const{OS:e,Version:t}=n.g.Platform;return[e,t].join("-")}const e=(0,R.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("-")}(),r=function(){var e;const t=Be();return t===xe?[t,(null==(e=(0,x.getLocation)())?void 0:e.host)||"unknown"].join(":"):t}();return[[e,t].join("-"),[De,i].join("-"),s,r].join("/")}function Ve(e){let{protocol:t,version:n,relayUrl:i,sdkVersion:s,auth:r,projectId:o,useOnCloseEvent:a,bundleId:c,packageName:l}=e;const d=i.split("?"),h={auth:r,ua:qe(t,n,s),projectId:o,useOnCloseEvent:a||void 0,packageName:l||void 0,bundleId:c||void 0},u=function(e,t){const n=new URLSearchParams(e);return Object.entries(t).sort((e,t)=>{let[n]=e,[i]=t;return n.localeCompare(i)}).forEach(e=>{let[t,i]=e;null!=i&&n.set(t,String(i))}),n.toString()}(d[1]||"",h);return d[0]+"?"+u}function Ke(e,t){return e.filter(e=>t.includes(e)).length===e.length}function ze(e){return Object.fromEntries(e.entries())}function $e(e){return new Map(Object.entries(e))}function Ge(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:O.FIVE_MINUTES,t=arguments.length>1?arguments[1]:void 0;const n=(0,O.toMiliseconds)(e||O.FIVE_MINUTES);let i,s,r,o;return{resolve:e=>{r&&i&&(clearTimeout(r),i(e),o=Promise.resolve(e))},reject:e=>{r&&s&&(clearTimeout(r),s(e))},done:()=>new Promise((e,a)=>{if(o)return e(o);r=setTimeout(()=>{const e=new Error(t);o=Promise.reject(e),a(e)},n),i=e,s=a})}}function Je(e,t,n){return new Promise(async(i,s)=>{const r=setTimeout(()=>s(new Error(n)),t);try{i(await e)}catch(S){s(S)}clearTimeout(r)})}function Ye(e,t){if("string"==typeof t&&t.startsWith("".concat(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:".concat(t)}if("id"===e.toLowerCase()){if("number"!=typeof t)throw new Error('Value must be "number" for expirer target type: id');return"id:".concat(t)}throw new Error("Unknown expirer target type: ".concat(e))}function Xe(e){const[t,n]=e.split(":"),i={id:void 0,topic:void 0};if("topic"===t&&"string"==typeof n)i.topic=n;else{if("id"!==t||!Number.isInteger(Number(n)))throw new Error("Invalid target, expected id:number or topic:string, got ".concat(t,":").concat(n));i.id=Number(n)}return i}function Ze(e,t){return(0,O.fromMiliseconds)((t||Date.now())+(0,O.toMiliseconds)(e))}function Qe(e){return Date.now()>=(0,O.toMiliseconds)(e)}function et(e,t){return"".concat(e).concat(t?":".concat(t):"")}function tt(){return[...new Set([...arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],...arguments.length>1&&void 0!==arguments[1]?arguments[1]:[]])]}async function nt(e){let{id:t,topic:i,wcDeepLink:s}=e;var r;try{if(!s)return;const e="string"==typeof s?JSON.parse(s):s,o=null===e||void 0===e?void 0:e.href;if("string"!=typeof o)return;const a=function(e,t,n){const i="requestId=".concat(t,"&sessionTopic=").concat(n);e.endsWith("/")&&(e=e.slice(0,-1));let s="".concat(e);
2if(e.startsWith("https://t.me")){const t=e.includes("?")?"&startapp=":"?startapp=";s="".concat(s).concat(t).concat(function(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=Buffer.from(e).toString("base64");return t?n.replace(/[=]/g,""):n}(i,!0))}else s="".concat(s,"/wc?").concat(i);return s}(o,t,i),c=Be();if(c===xe){if(null==(r=(0,x.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(e){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")}(a)}else c===Pe&&typeof(null==n.g?void 0:n.g.Linking)<"u"&&await n.g.Linking.openURL(a)}catch(o){console.error(o)}}function it(e,t){if(!e.includes(t))return null;const n=e.split(/([&,?,=])/),i=n.indexOf(t);return n[i+2]}function st(){return typeof crypto<"u"&&null!=crypto&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})}function rt(){return typeof process<"u"&&"true"==={NODE_ENV:"production",PUBLIC_URL:".",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.IS_VITEST}function ot(e){return Buffer.from(e,"base64").toString("utf-8")}class at{constructor(e){let{limit:t}=e;ke(this,"limit"),ke(this,"set"),this.limit=t,this.set=new Set}
2add(e){if(!this.set.has(e)){if(this.set.size>=this.limit){const e=this.set.values().next().value;e&&this.set.delete(e)}this.set.add(e)}}has(e){return this.set.has(e)}}const ct=BigInt(2**32-1),lt=BigInt(32);function dt(e){return arguments.length>1&&void 0!==arguments[1]&&arguments[1]?{h:Number(e&ct),l:Number(e>>lt&ct)}:{h:0|Number(e>>lt&ct),l:0|Number(e&ct)}}function ht(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];const n=e.length;let i=new Uint32Array(n),s=new Uint32Array(n);for(let r=0;r<n;r++){const{h:n,l:o}=dt(e[r],t);[i[r],s[r]]=[n,o]}return[i,s]}const ut=(e,t,n)=>e>>>n,pt=(e,t,n)=>e<<32-n|t>>>n,ft=(e,t,n)=>e>>>n|t<<32-n,gt=(e,t,n)=>e<<32-n|t>>>n,vt=(e,t,n)=>e<<64-n|t>>>n-32,mt=(e,t,n)=>e>>>n-32|t<<64-n,yt=(e,t)=>t,wt=(e,t)=>e;function bt(e,t,n,i){const s=(t>>>0)+(i>>>0);return{h:e+n+(s/2**32|0)|0,l:0|s}}const Et=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Ct=(e,t,n,i)=>t+n+i+(e/2**32|0)|0,At=(e,t,n,i)=>(e>>>0)+(t>>>0)+(n>>>0)+(i>>>0),It=(e,t,n,i,s)=>t+n+i+s+(e/2**32|0)|0,Nt=(e,t,n,i,s)=>(e>>>0)+(t>>>0)+(n>>>0)+(i>>>0)+(s>>>0),St=(e,t,n,i,s,r)=>t+n+i+s+r+(e/2**32|0)|0,_t="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0;function Tt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Ot(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function kt(e){if(!Tt(e))throw new Error("Uint8Array expected");for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];if(n.length>0&&!n.includes(e.length))throw new Error("Uint8Array expected of length "+n+", got length="+e.length)}function Pt(e){if("function"!=typeof e||"function"!=typeof e.create)throw new Error("Hash should be wrapped by utils.createHasher");Ot(e.outputLen),Ot(e.blockLen)}function Rt(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];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 xt(e,t){kt(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Ut(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function Dt(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(let i=0;i<t.length;i++)t[i].fill(0)}function Lt(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function Wt(e,t){return e<<32-t|e>>>t}const Mt=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function Bt(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}const Ft=Mt?e=>e:e=>Bt(e);const jt=Mt?e=>e:function(e){for(let t=0;t<e.length;t++)e[t]=Bt(e[t]);return e},Ht="function"==typeof Uint8Array.from([]).toHex&&"function"==typeof Uint8Array.fromHex,qt=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function Vt(e){if(kt(e),Ht)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=qt[e[n]];return t}const Kt=48,zt=57,$t=65,Gt=70,Jt=97,Yt=102;function Xt(e){return e>=Kt&&e<=zt?e-Kt:e>=$t&&e<=Gt?e-($t-10):e>=Jt&&e<=Yt?e-(Jt-10):void 0}function Zt(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);if(Ht)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const i=new Uint8Array(n);for(let s=0,r=0;s<n;s++,r+=2){const t=Xt(e.charCodeAt(r)),n=Xt(e.charCodeAt(r+1));if(void 0===t||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[s]=16*t+n}return i}function Qt(e){if("string"!=typeof e)throw new Error("string expected");return new Uint8Array((new TextEncoder).encode(e))}function en(e){return"string"==typeof e&&(e=Qt(e)),kt(e),e}function tn(){let e=0;for(let n=0;n<arguments.length;n++){const t=n<0||arguments.length<=n?void 0:arguments[n];kt(t),e+=t.length}const t=new Uint8Array(e);for(let n=0,i=0;n<arguments.length;n++){const e=n<0||arguments.length<=n?void 0:arguments[n];t.set(e,i),i+=e.length}return t}class nn{}function sn(e){const t=t=>e().update(en(t)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function rn(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:32;if(_t&&"function"==typeof _t.getRandomValues)return _t.getRandomValues(new Uint8Array(e));if(_t&&"function"==typeof _t.randomBytes)return Uint8Array.from(_t.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}const on=BigInt(0),an=BigInt(1),cn=BigInt(2),ln=BigInt(7),dn=BigInt(256),hn=BigInt(113),un=[],pn=[],fn=[];for(let bg=0,Eg=an,Cg=1,Ag=0;bg<24;bg++){[Cg,Ag]=[Ag,(2*Cg+3*Ag)%5],un.push(2*(5*Ag+Cg)),pn.push((bg+1)*(bg+2)/2%64);let e=on;for(let t=0;t<7;t++)Eg=(Eg<<an^(Eg>>ln)*hn)%dn,Eg&cn&&(e^=an<<(an<<BigInt(t))-an);fn.push(e)}const gn=ht(fn,!0),vn=gn[0],mn=gn[1],yn=(e,t,n)=>n>
vendor: 5,632 bytes, line 2
232?((e,t,n)=>t<<n-32|e>>>64-n)(e,t,n):((e,t,n)=>e<<n|t>>>32-n)(e,t,n),wn=(e,t,n)=>n>32?((e,t,n)=>e<<n-32|t>>>64-n)(e,t,n):((e,t,n)=>t<<n|e>>>32-n)(e,t,n);class bn extends nn{constructor(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]&&arguments[3],s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:24;if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=t,this.outputLen=n,this.enableXOF=i,this.rounds=s,Ot(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ut(this.state)}clone(){return this._cloneInto()}keccak(){jt(this.state32),function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:24;const n=new Uint32Array(10);for(let i=24-t;i<24;i++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const t=(i+8)%10,s=(i+2)%10,r=n[s],o=n[s+1],a=yn(r,o,1)^n[t],c=wn(r,o,1)^n[t+1];for(let n=0;n<50;n+=10)e[i+n]^=a,e[i+n+1]^=c}let t=e[2],s=e[3];for(let n=0;n<24;n++){const i=pn[n],r=yn(t,s,i),o=wn(t,s,i),a=un[n];t=e[a],s=e[a+1],e[a]=r,e[a+1]=o}for(let i=0;i<50;i+=10){for(let t=0;t<10;t++)n[t]=e[i+t];for(let t=0;t<10;t++)e[i+t]^=~n[(t+2)%10]&n[(t+4)%10]}e[0]^=vn[i],e[1]^=mn[i]}Dt(n)}(this.state32,this.rounds),jt(this.state32),this.posOut=0,this.pos=0}update(e){Rt(this),kt(e=en(e));const{blockLen:t,state:n}=this,i=e.length;for(let s=0;s<i;){const r=Math.min(t-this.pos,i-s);for(let t=0;t<r;t++)n[this.pos++]^=e[s++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:n,blockLen:i}=this;e[n]^=t,0!==(128&t)&&n===i-1&&this.keccak(),e[i-1]^=128,this.keccak()}writeInto(e){Rt(this,!1),kt(e),this.finish();const t=this.state,{blockLen:n}=this;for(let i=0,s=e.length;i<s;){this.posOut>=n&&this.keccak();const r=Math.min(n-this.posOut,s-i);e.set(t.subarray(this.posOut,this.posOut+r),i),this.posOut+=r,i+=r}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Ot(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(xt(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,Dt(this.state)}_cloneInto(e){const{blockLen:t,suffix:n,outputLen:i,rounds:s,enableXOF:r}=this;return e||(e=new bn(t,n,i,r,s)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=s,e.suffix=n,e.outputLen=i,e.enableXOF=r,e.destroyed=this.destroyed,e}}const En=(Cn=1,An=136,In=32,sn(()=>new bn(An,Cn,In)));var Cn,An,In;function Nn(e,t,n){return e&t^~e&n}function Sn(e,t,n){return e&t^e&n^t&n}class _n extends nn{constructor(e,t,n,i){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=t,this.padOffset=n,this.isLE=i,this.buffer=new Uint8Array(e),this.view=Lt(this.buffer)}update(e){Rt(this),kt(e=en(e));const{view:t,buffer:n,blockLen:i}=this,s=e.length;for(let r=0;r<s;){const o=Math.min(i-this.pos,s-r);if(o===i){const t=Lt(e);for(;i<=s-r;r+=i)this.process(t,r);continue}n.set(e.subarray(r,r+o),this.pos),this.pos+=o,r+=o,this.pos===i&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Rt(this),xt(e,this),this.finished=!0;const{buffer:t,view:n,blockLen:i,isLE:s}=this;let{pos:r}=this;t[r++]=128,Dt(this.buffer.subarray(r)),this.padOffset>i-r&&(this.process(n,0),r=0);for(let d=r;d<i;d++)t[d]=0;(function(e,t,n,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,i);const s=BigInt(32),r=BigInt(4294967295),o=Number(n>>s&r),a=Number(n&r),c=i?4:0,l=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+l,a,i)})(n,i-8,BigInt(8*this.length),s),this.process(n,0);const o=Lt(e),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=a/4,l=this.get();if(c>l.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<c;d++)o.setUint32(4*d,l[d],s)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:n,length:i,finished:s,destroyed:r,pos:o}=this;return e.destroyed=r,e.finished=s,e.length=i,e.pos=o,i%t&&e.buffer.set(n),e}clone(){return this._cloneInto()}}const Tn=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),On=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),kn=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),Pn=Uint32Array.from([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,2756
vendor: 2,059 bytes, line 2
2734187,3204031479,3329325298]),Rn=new Uint32Array(64);class xn extends _n{constructor(){super(64,arguments.length>0&&void 0!==arguments[0]?arguments[0]:32,8,!1),this.A=0|Tn[0],this.B=0|Tn[1],this.C=0|Tn[2],this.D=0|Tn[3],this.E=0|Tn[4],this.F=0|Tn[5],this.G=0|Tn[6],this.H=0|Tn[7]}get(){const{A:e,B:t,C:n,D:i,E:s,F:r,G:o,H:a}=this;return[e,t,n,i,s,r,o,a]}set(e,t,n,i,s,r,o,a){this.A=0|e,this.B=0|t,this.C=0|n,this.D=0|i,this.E=0|s,this.F=0|r,this.G=0|o,this.H=0|a}process(e,t){for(let d=0;d<16;d++,t+=4)Rn[d]=e.getUint32(t,!1);for(let d=16;d<64;d++){const e=Rn[d-15],t=Rn[d-2],n=Wt(e,7)^Wt(e,18)^e>>>3,i=Wt(t,17)^Wt(t,19)^t>>>10;Rn[d]=i+Rn[d-7]+n+Rn[d-16]|0}let{A:n,B:i,C:s,D:r,E:o,F:a,G:c,H:l}=this;for(let d=0;d<64;d++){const e=l+(Wt(o,6)^Wt(o,11)^Wt(o,25))+Nn(o,a,c)+Pn[d]+Rn[d]|0,t=(Wt(n,2)^Wt(n,13)^Wt(n,22))+Sn(n,i,s)|0;l=c,c=a,a=o,o=r+e|0,r=s,s=i,i=n,n=e+t|0}n=n+this.A|0,i=i+this.B|0,s=s+this.C|0,r=r+this.D|0,o=o+this.E|0,a=a+this.F|0,c=c+this.G|0,l=l+this.H|0,this.set(n,i,s,r,o,a,c,l)}roundClean(){Dt(Rn)}destroy(){this.set(0,0,0,0,0,0,0,0),Dt(this.buffer)}}const Un=ht(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e3585
25771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(e=>BigInt(e))),Dn=Un[0],Ln=Un[1],Wn=new Uint32Array(80),Mn=new Uint32Array(80);class Bn extends _n{constructor(){super(128,arguments.length>0&&void 0!==arguments[0]?arguments[0]:64,16,!1),this.Ah=0|kn[0],this.Al=0|kn[1],this.Bh=0|kn[2],this.Bl=0|kn[3],this.Ch=0|kn[4],this.Cl=0|kn[5],this.Dh=0|kn[6],this.Dl=0|kn[7],this.Eh=0|kn[8],this.El=0|kn[9],this.Fh=0|kn[10],this.Fl=0|kn[11],this.Gh=0|kn[12],this.Gl=0|kn[13],this.Hh=0|kn[14],this.Hl=0|kn[15]}get(){const{Ah:e,Al:t,Bh:n,Bl:i,Ch:s,Cl:r,Dh:o,Dl:a,Eh:c,El:l,Fh:d,Fl:h,Gh:u,Gl:p,Hh:f,Hl:g}=this;return[e,t,n,i,s,r,o,a,c,l,d,h,u,p,f,g]}set(e,t,n,i,s,r,o,a,c,l,d,h,u,p,f,g){this.Ah=0|e,this.Al=0|t,this.Bh=0|n,this.Bl=0|i,this.Ch=0|s,this.Cl=0|r,this.Dh=0|o,this.Dl=0|a,this.Eh=0|c,this.El=0|l,this.Fh=0|d,this.Fl=0|h,this.Gh=0|u,this.Gl=0|p,this.Hh=0|f,this.Hl=0|g}process(e,t){for(let y=0;y<16;y++,t+=4)Wn[y]=e.getUint32(t),Mn[y]=e.getUint32(t+=4);for(let y=16;y<80;y++){const e=0|Wn[y-15],t=0|Mn[y-15],n=ft(e,t,1)^ft(e,t,8)^ut(e,0,7),i=gt(e,t,1)^gt(e,t,8)^pt(e,t,7),s=0|Wn[y-2],r=0|Mn[y-2],o=ft(s,r,19)^vt(s,r,61)^ut(s,0,6),a=gt(s,r,19)^mt(s,r,61)^pt(s,r,6),c=At(i,a,Mn[y-7],Mn[y-16]),l=It(c,n,o,Wn[y-7],Wn[y-16]);Wn[y]=0|l,Mn[y]=0|c}let{Ah:n,Al:i,Bh:s,Bl:r,Ch:o,Cl:a,Dh:c,Dl:l,Eh:d,El:h,Fh:u,Fl:p,Gh:f,Gl:g,Hh:v,Hl:m}=this;for(let y=0;y<80;y++){const e=ft(d,h,14)^ft(d,h,18)^vt(d,h,41),t=gt(d,h,14)^gt(d,h,18)^mt(d,h,41),w=d&u^~d&f,b=Nt(m,t,h&p^~h&g,Ln[y],Mn[y]),E=St(b,v,e,w,Dn[y],Wn[y]),C=0|b,A=ft(n,i,28)^vt(n,i,34)^vt(n,i,39),I=gt(n,i,28)^mt(n,i,34)^mt(n,i,39),N=n&s^n&o^s&o,S=i&r^i&a^r&a;v=0|f,m=0|g,f=0|u,g=0|p,u=0|d,p=0|h,({h:d,l:h}=bt(0|c,0|l,0|E,0|C)),c=0|o,l=0|a,o=0|s,a=0|r,s=0|n,r=0|i;const _=Et(C,I,S);n=Ct(_,E,A,N),i=0|_}({h:n,l:i}=bt(0|this.Ah,0|this.Al,0|n,0|i)),({h:s,l:r}=bt(0|this.Bh,0|this.Bl,0|s,0|r)),({h:o,l:a}=bt(0|this.Ch,0|this.Cl,0|o,0|a)),({h:c,l:l}=bt(0|this.Dh,0|this.Dl,0|c,0|l)),({h:d,l:h}=bt(0|this.Eh,0|this.El,0|d,0|h)),({h:u,l:p}=bt(0|this.Fh,0|this.Fl,0|u,0|p)),({h:f,l:g}=bt(0|this.Gh,0|this.Gl,0|f,0|g)),({h:v,l:m}=bt(0|this.Hh,0|this.Hl,0|v,0|m)),this.set(n,i,s,r,o,a,c,l,d,h,u,p,f,g,v,m)}roundClean(){Dt(Wn,Mn)}destroy(){Dt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class Fn extends Bn{constructor(){super(48),this.Ah=0|On[0],this.Al=0|On[1],this.Bh=0|On[2],this.Bl=0|On[3],this.Ch=0|On[4],this.Cl=0|On[5],this.Dh=0|On[6],this.Dl=0|On[7],this.Eh=0|On[8],this.El=0|On[9],this.Fh=0|On[10],this.Fl=0|On[11],this.Gh=0|On[12],this.Gl=0|On[13],this.Hh=0|On[14],this.Hl=0|On[15]}}const jn=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class Hn extends Bn{constructor(){super(32),this.Ah=0|jn[0],this.Al=0|jn[1],this.Bh=0|jn[2],this.Bl=0|jn[3],this.Ch=0|jn[4],this.Cl=0|jn[5],this.Dh=0|jn[6],this.Dl=0|jn[7],this.Eh=0|jn[8],this.El=0|jn[9],this.Fh=0|jn[10],this.Fl=0|jn[11],this.Gh=0|jn[12],this.Gl=0|jn[13],this.Hh=0|jn[14],this.Hl=0|jn[15]}}const qn=sn(()=>new xn),Vn=sn(()=>new Bn),Kn=sn(()=>new Fn),zn=sn(()=>new Hn),$n=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]),Gn=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Jn=new Uint32Array(32);function Yn(e,t,n,i,s,r){const o=s[r],a=s[r+1];let c=Jn[2*e],l=Jn[2*e+1],d=Jn[2*t],h=Jn[2*t+1],u=Jn[2*n],p=Jn[2*n+1],f=Jn[2*i],g=Jn[2*i+1],v=Et(c,d,o);l=Ct(v,l,h,a),c=0|v,({Dh:g,Dl:f}={Dh:g^l,Dl:f^c}),({Dh:g,Dl:f}={Dh:yt(0,f),Dl:wt(g)}),({h:p,l:u}=bt(p,u,g,f)),({Bh:h,Bl:d}={Bh:h^p,Bl:d^u}),({Bh:h,Bl:d}={Bh:ft(h,d,24),Bl:gt(h,d,24)}),Jn[2*e]=c,Jn[2*e+1]=l,Jn[2*t]=d,Jn[2*t+1]=h,Jn[2*n]=u,Jn[2*n+1]=p,Jn[2*i]=f,Jn[2*i+1]=g}function Xn(e,t,n,i,s,r){const o=s[r],a=s[r+1];let c=Jn[2*e],l=Jn[2*e+1],d=Jn[2*t],h=Jn[2*t+1],u=Jn[2*n],p=Jn[2*n+1],f=Jn[2*i],g=Jn[2*i+1],v=Et(c,d,o);l=Ct(v,l,h,a),c=0|v,({Dh:g,Dl:f}={Dh:g^l,Dl:f^c}),({Dh:g,Dl:f}={Dh:ft(g,f,16),Dl:gt(g,f,16)}),({h:p,l:u}=bt(p,u,g,f)),({Bh:h,Bl:d}={Bh:h^p,Bl:d^u}),({Bh:h,Bl:d}={Bh:vt(h,d,63),Bl:mt(h,d,63)}),Jn[2*e]=c,Jn[2*e+1]=l,Jn[2*t]=d,Jn[2*t+1]=h,Jn[2*n]=u,Jn[2*n+1]=p,Jn[2*i]=f,Jn[2*i+1]=g}class Zn extends nn{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,Ot(e),Ot(t),this.blockLen=e,this.outputLen=t,this.buffer=new Uint8Array(e),this.buffer32=Ut(this.buffer)}update(e){Rt(this),kt(e=en(e));const{blockLen:t,buffer:n,buffer32:i}=this,s=e.length,r=e.byteOffset,o=e.buffer;for(let a=0;a<s;){this.pos===t&&(jt(i),this.compress(i,0,!1),jt(i),this.pos=0);const c=Math.min(t-this.pos,s-a),l=r+a;if(c===t&&!(l%4)&&a+c<s){const e=new Uint32Array(o,l,Math.floor((s-a)/4));jt(e);for(let n=0;a+t<s;n+=i.length,a+=t)this.length+=t,this.compress(e,n,!1);jt(e);continue}n.set(e.subarray(a,a+c),this.pos),this.pos+=c,this.length+=c,a+=c}return this}digestInto(e){Rt(this),xt(e,this);const{pos:t,buffer32:n}=this;this.finished=!0,Dt(this.buffer.subarray(t)),jt(n),this.compress(n,0,!0),jt(n);const i=Ut(e);
2this.get().forEach((e,t)=>i[t]=Ft(e))}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}_cloneInto(e){const{buffer:t,length:n,finished:i,destroyed:s,outputLen:r,pos:o}=this;return e||(e=new this.constructor({dkLen:r})),e.set(...this.get()),e.buffer.set(t),e.destroyed=s,e.finished=i,e.length=n,e.pos=o,e.outputLen=r,e}clone(){return this._cloneInto()}}class Qn extends Zn{constructor(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};const t=void 0===e.dkLen?64:e.dkLen;super(128,t),this.v0l=0|Gn[0],this.v0h=0|Gn[1],this.v1l=0|Gn[2],this.v1h=0|Gn[3],this.v2l=0|Gn[4],this.v2h=0|Gn[5],this.v3l=0|Gn[6],this.v3h=0|Gn[7],this.v4l=0|Gn[8],this.v4h=0|Gn[9],this.v5l=0|Gn[10],this.v5h=0|Gn[11],this.v6l=0|Gn[12],this.v6h=0|Gn[13],this.v7l=0|Gn[14],this.v7h=0|Gn[15],function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;if(Ot(n),e<0||e>n)throw new Error("outputLen bigger than keyLen");const{key:r,salt:o,personalization:a}=t;if(void 0!==r&&(r.length<1||r.length>n))throw new Error("key length must be undefined or 1.."+n);if(void 0!==o&&o.length!==i)throw new Error("salt must be undefined or "+i);if(void 0!==a&&a.length!==s)throw new Error("personalization must be undefined or "+s)}(t,e,64,16,16);let{key:n,personalization:i,salt:s}=e,r=0;if(void 0!==n&&(n=en(n),r=n.length),this.v0l^=this.outputLen|r<<8|65536|1<<24,void 0!==s){s=en(s);const e=Ut(s);this.v4l^=Ft(e[0]),this.v4h^=Ft(e[1]),this.v5l^=Ft(e[2]),this.v5h^=Ft(e[3])}if(void 0!==i){i=en(i);const e=Ut(i);this.v6l^=Ft(e[0]),this.v6h^=Ft(e[1]),this.v7l^=Ft(e[2]),this.v7h^=Ft(e[3])}if(void 0!==n){const e=new Uint8Array(this.blockLen);e.set(n),this.update(e)}}get(){let{v0l:e,v0h:t,v1l:n,v1h:i,v2l:s,v2h:r,v3l:o,v3h:a,v4l:c,v4h:l,v5l:d,v5h:h,v6l:u,v6h:p,v7l:f,v7h:g}=this;return[e,t,n,i,s,r,o,a,c,l,d,h,u,p,f,g]}set(e,t,n,i,s,r,o,a,c,l,d,h,u,p,f,g){this.v0l=0|e,this.v0h=0|t,this.v1l=0|n,this.v1h=0|i,this.v2l=0|s,this.v2h=0|r,this.v3l=0|o,this.v3h=0|a,this.v4l=0|c,this.v4h=0|l,this.v5l=0|d,this.v5h=0|h,this.v6l=0|u,this.v6h=0|p,this.v7l=0|f,this.v7h=0|g}compress(e,t,n){this.get().forEach((e,t)=>Jn[t]=e),Jn.set(Gn,16);let{h:i,l:s}=dt(BigInt(this.length));Jn[24]=Gn[8]^s,Jn[25]=Gn[9]^i,n&&(Jn[28]=~Jn[28],Jn[29]=~Jn[29]);let r=0;const o=$n;for(let a=0;a<12;a++)Yn(0,4,8,12,e,t+2*o[r++]),Xn(0,4,8,12,e,t+2*o[r++]),Yn(1,5,9,13,e,t+2*o[r++]),Xn(1,5,9,13,e,t+2*o[r++]),Yn(2,6,10,14,e,t+2*o[r++]),Xn(2,6,10,14,e,t+2*o[r++]),Yn(3,7,11,15,e,t+2*o[r++]),Xn(3,7,11,15,e,t+2*o[r++]),Yn(0,5,10,15,e,t+2*o[r++]),Xn(0,5,10,15,e,t+2*o[r++]),Yn(1,6,11,12,e,t+2*o[r++]),Xn(1,6,11,12,e,t+2*o[r++]),Yn(2,7,8,13,e,t+2*o[r++]),Xn(2,7,8,13,e,t+2*o[r++]),Yn(3,4,9,14,e,t+2*o[r++]),Xn(3,4,9,14,e,t+2*o[r++]);this.v0l^=Jn[0]^Jn[16],this.v0h^=Jn[1]^Jn[17],this.v1l^=Jn[2]^Jn[18],this.v1h^=Jn[3]^Jn[19],this.v2l^=Jn[4]^Jn[20],this.v2h^=Jn[5]^Jn[21],this.v3l^=Jn[6]^Jn[22],this.v3h^=Jn[7]^Jn[23],this.v4l^=Jn[8]^Jn[24],this.v4h^=Jn[9]^Jn[25],this.v5l^=Jn[10]^Jn[26],this.v5h^=Jn[11]^Jn[27],this.v6l^=Jn[12]^Jn[28],this.v6h^=Jn[13]^Jn[29],this.v7l^=Jn[14]^Jn[30],this.v7h^=Jn[15]^Jn[31],Dt(Jn)}destroy(){this.destroyed=!0,Dt(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const ei=function(e){const t=(t,n)=>e(n).update(en(t)).digest(),n=e({});return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}(e=>new Qn(e)),ti="https://rpc.walletconnect.org/v1";function ni(e){const t="\x19Ethereum Signed Message:\n".concat(e.length),n=(new TextEncoder).encode(t+e);return"0x"+Buffer.from(En(n)).toString("hex")}async function ii(e,t,n,i,s,r){switch(n.t){case"eip191":return await async function(e,t,n){return(await he({hash:ni(t),signature:n})).toLowerCase()===e.toLowerCase()}(e,t,n.s);case"eip1271":return await async function(e,t,n,i,s,r){const o=be(i);if(!o.namespace||!o.reference)throw new Error("isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ".concat(i));try{const o="0x1626ba7e",a="0000000000000000000000000000000000000000000000000000000000000040",c=n.substring(2),l=(c.length/2).toString(16).padStart(64,"0"),d=o+(t.startsWith("0x")?t:ni(t)).substring(2)+a+l+c,h=await fetch("".concat(r||ti,"/?chainId=").concat(i,"&projectId=").concat(s),{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify({id:si(),jsonrpc:"2.0",method:"eth_call",params:[{to:e,data:d},"latest"]})}),{result:u}=await h.json();return!!u&&u.slice(0,o.length).toLowerCase()===o.toLowerCase()}catch(h){return console.error("isValidEip1271Signature: ",h),!1}}(e,t,n.s,i,s,r);default:throw new Error("verifySignature failed: Attempted to verify CacaoSignature with unknown type: ".concat(n.t))}}function si(){return Date.now()+Math.floor(1e3*Math.random())}function ri(e){const t=new Uint8Array(Buffer.from(e,"base64")),n=Array.from("TransactionData::").map(e=>e.charCodeAt(0)),i=new Uint8Array(n.length+t.length);i.set(n),i.set(t,n.length);const s=ei(i,{dkLen:32});return ue.A.encode(s)}function oi(e){const t=new Uint8Array(qn(function(e){if(e instanceof Uint8Array)return e;if(Array.isArray(e))return new Uint8Array(e);if("object"==typeof e&&null!=e&&e.data)return new Uint8Array(Object.values(e.data));if("object"==typeof e&&e)return new Uint8Array(Object.values(e));throw new Error("getNearUint8ArrayFromBytes: Unexpected result type from bytes array")}(e)));return ue.A.encode(t)}function ai(e){const t=Buffer.from(e,"base64"),n=(0,pe.D)(t).txn;if(!n)throw new Error("Invalid signed transaction: missing 'txn' field");const i=(0,fe.l)(n),s=Buffer.from("TX"),r=Buffer.concat([s,Buffer.from(i)]),o=zn(r);return ge.RG.encode(o).replace(/=+$/,"")}function ci(e){const t=[];let n=BigInt(e);for(;n>=BigInt(128);)t.push(Number(n&BigInt(127)|BigInt(128))),n>>=BigInt(7);return t.push(Number(n)),Buffer.from(t)}function li(e){const t=Buffer.from(e.signed.bodyBytes,"base64"),n=Buffer.from(e.signed.authInfoBytes,"base64"),i=Buffer.from(e.signature.signature,"base64"),s=[];s.push(Buffer.from([10])),s.push(ci(t.length)),s.push(t),s.push(Buffer.from([18])),s.push(ci(n.length)),s.push(n),s.push(Buffer.from([26])),s.push(ci(i.length)),s.push(i);const r=Buffer.concat(s),o=qn(r);return Buffer.from(o).toString("hex").toUpperCase()}var di=Object.defineProperty,hi=Object.defineProperties,ui=Object.getOwnPropertyDescriptors,pi=Object.getOwnPropertySymbols,fi=Object.prototype.hasOwnProperty,gi=Object.prototype.propertyIsEnumerable,vi=(e,t,n)=>t in e?di(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,mi=(e,t)=>{for(var n in t||(t={}
2))fi.call(t,n)&&vi(e,n,t[n]);if(pi)for(var n of pi(t))gi.call(t,n)&&vi(e,n,t[n]);return e},yi=(e,t)=>hi(e,ui(t));const wi=e=>null===e||void 0===e?void 0:e.split(":"),bi=e=>{const t=e&&wi(e);if(t)return t[2]+":"+t[3]},Ei=e=>{const t=e&&wi(e);if(t)return t.pop()};async function Ci(e){const{cacao:t,projectId:n}=e,{s:i,p:s}=t,r=Ai(s,s.iss),o=Ei(s.iss);return await ii(o,r,i,bi(s.iss),n)}const Ai=(e,t)=>{const n="".concat(e.domain," wants you to sign in with your Ethereum account:"),i=Ei(t);if(!e.aud&&!e.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let s=e.statement||void 0;const r="URI: ".concat(e.aud||e.uri),o="Version: ".concat(e.version),a="Chain ID: ".concat((e=>{const t=e&&wi(e);if(t)return e.includes("did:pkh:")?t[3]:t[1]})(t)),c="Nonce: ".concat(e.nonce),l="Issued At: ".concat(e.iat),d=e.exp?"Expiration Time: ".concat(e.exp):void 0,h=e.nbf?"Not Before: ".concat(e.nbf):void 0,u=e.requestId?"Request ID: ".concat(e.requestId):void 0,p=e.resources?"Resources:".concat(e.resources.map(e=>"\n- ".concat(e)).join("")):void 0,f=Ui(e.resources);if(f){s=Pi(s,_i(f))}return[n,i,"",s,"",r,o,a,c,l,d,h,u,p].filter(e=>null!=e).join("\n")};function Ii(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 n=e.att[t];if(Array.isArray(n))throw new Error("Resource must be an object: ".concat(t));if("object"!=typeof n)throw new Error("Resource must be an object: ".concat(t));if(!Object.keys(n).length)throw new Error("Resource object is empty: ".concat(t));Object.keys(n).forEach(e=>{const t=n[e];if(!Array.isArray(t))throw new Error("Ability limits ".concat(e," must be an array of objects, found: ").concat(t));if(!t.length)throw new Error("Value of ".concat(e," is empty array, must be an array with objects"));t.forEach(t=>{if("object"!=typeof t)throw new Error("Ability limits (".concat(e,") must be an array of objects, found: ").concat(t))})})})}function Ni(e,t){var n;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const s=(t=null===(n=t)||void 0===n?void 0:n.sort((e,t)=>e.localeCompare(t))).map(t=>({["".concat(e,"/").concat(t)]:[i]}));return Object.assign({},...s)}function Si(e){return Ii(e),"urn:recap:".concat(function(e){return Buffer.from(JSON.stringify(e)).toString("base64")}(e).replace(/=/g,""))}function _i(e){const t=function(e){return JSON.parse(Buffer.from(e,"base64").toString("utf-8"))}(e.replace("urn:recap:",""));return Ii(t),t}function Ti(e,t,n){const i=function(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};return null!==n&&void 0!==n&&n.sort((e,t)=>e.localeCompare(t)),{att:{[e]:Ni(t,n,i)}}}(e,t,n);return Si(i)}function Oi(e){return e&&e.includes("urn:recap:")}function ki(e,t){const n=function(e,t){Ii(e),Ii(t);const n=Object.keys(e.att).concat(Object.keys(t.att)).sort((e,t)=>e.localeCompare(t)),i={att:{}};return n.forEach(n=>{var s,r;Object.keys((null==(s=e.att)?void 0:s[n])||{}).concat(Object.keys((null==(r=t.att)?void 0:r[n])||{})).sort((e,t)=>e.localeCompare(t)).forEach(s=>{var r,o;i.att[n]=yi(mi({},i.att[n]),{[s]:(null==(r=e.att[n])?void 0:r[s])||(null==(o=t.att[n])?void 0:o[s])})})}),i}(_i(e),_i(t));return Si(n)}function Pi(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=arguments.length>1?arguments[1]:void 0;Ii(t);const n="I further authorize the stated URI to perform the following actions on my behalf: ";if(e.includes(n))return e;const i=[];let s=0;Object.keys(t.att).forEach(e=>{const n=Object.keys(t.att[e]).map(e=>({ability:e.split("/")[0],action:e.split("/")[1]}));n.sort((e,t)=>e.action.localeCompare(t.action));const r={};n.forEach(e=>{r[e.ability]||(r[e.ability]=[]),r[e.ability].push(e.action)});const o=Object.keys(r).map(t=>(s++,"(".concat(s,") '").concat(t,"': '").concat(r[t].join("', '"),"' for '").concat(e,"'.")));i.push(o.join(", ").replace(".,","."))});const r=i.join(" "),o="".concat(n).concat(r);return"".concat(e?e+" ":"").concat(o)}function Ri(e){var t;const n=_i(e);Ii(n);const i=null==(t=n.att)?void 0:t.eip155;return i?Object.keys(i).map(e=>e.split("/")[1]):[]}function xi(e){const t=_i(e);Ii(t);const n=[];
2return Object.values(t.att).forEach(e=>{Object.values(e).forEach(e=>{var t;null!=(t=null===e||void 0===e?void 0:e[0])&&t.chains&&n.push(e[0].chains)})}),[...new Set(n.flat())]}function Ui(e){if(!e)return;const t=null===e||void 0===e?void 0:e[e.length-1];return Oi(t)?t:void 0}function Di(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&"Uint8Array"===e.constructor.name}function Li(e){if("boolean"!=typeof e)throw new Error("boolean expected, not ".concat(e))}function Wi(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Mi(e){if(!Di(e))throw new Error("Uint8Array expected");for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];if(n.length>0&&!n.includes(e.length))throw new Error("Uint8Array expected of length "+n+", got length="+e.length)}function Bi(e){let t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];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 Fi(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function ji(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];for(let i=0;i<t.length;i++)t[i].fill(0)}const Hi=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0];function qi(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(!Di(e))throw new Error("Uint8Array expected, got "+typeof e);e=$i(e)}return e}function Vi(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(void 0===t)return new Uint8Array(e);if(t.length!==e)throw new Error("invalid output length, expected "+e+", got: "+t.length);if(n&&!function(e){return e.byteOffset%4===0}(t))throw new Error("invalid output, must be aligned");return t}function Ki(e,t,n,i){if("function"==typeof e.setBigUint64)return e.setBigUint64(t,n,i);const s=BigInt(32),r=BigInt(4294967295),o=Number(n>>s&r),a=Number(n&r),c=i?4:0,l=i?0:4;e.setUint32(t+c,o,i),e.setUint32(t+l,a,i)}function zi(e,t,n){Li(n);const i=new Uint8Array(16),s=function(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}(i);return Ki(s,0,BigInt(t),n),Ki(s,8,BigInt(e),n),i}function $i(e){return Uint8Array.from(e)}const Gi=e=>Uint8Array.from(e.split("").map(e=>e.charCodeAt(0))),Ji=Gi("expand 16-byte k"),Yi=Gi("expand 32-byte k"),Xi=Fi(Ji),Zi=Fi(Yi);function Qi(e,t){return e<<t|e>>>32-t}function es(e){return e.byteOffset%4===0}const ts=2**32-1,ns=new Uint32Array;const is=(e,t)=>255&e[t++]|(255&e[t++])<<8;class ss{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,Mi(e=qi(e),32);const t=is(e,0),n=is(e,2),i=is(e,4),s=is(e,6),r=is(e,8),o=is(e,10),a=is(e,12),c=is(e,14);this.r[0]=8191&t,this.r[1]=8191&(t>>>13|n<<3),this.r[2]=7939&(n>>>10|i<<6),this.r[3]=8191&(i>>>7|s<<9),this.r[4]=255&(s>>>4|r<<12),this.r[5]=r>>>1&8190,this.r[6]=8191&(r>>>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 l=0;l<8;l++)this.pad[l]=is(e,16+2*l)}process(e,t){const n=arguments.length>2&&void 0!==arguments[2]&&arguments[2]?0:2048,{h:i,r:s}=this,r=s[0],o=s[1],a=s[2],c=s[3],l=s[4],d=s[5],h=s[6],u=s[7],p=s[8],f=s[9],g=is(e,t+0),v=is(e,t+2),m=is(e,t+4),y=is(e,t+6),w=is(e,t+8),b=is(e,t+10),E=is(e,t+12),C=is(e,t+14);let A=i[0]+(8191&g),I=i[1]+(8191&(g>>>13|v<<3)),N=i[2]+(8191&(v>>>10|m<<6)),S=i[3]+(8191&(m>>>7|y<<9)),_=i[4]+(8191&(y>>>4|w<<12)),T=i[5]+(w>>>1&8191),O=i[6]+(8191&(w>>>14|b<<2)),k=i[7]+(8191&(b>>>11|E<<5)),P=i[8]+(8191&(E>>>8|C<<8)),R=i[9]+(C>>>5|n),x=0,U=x+A*r+I*(5*f)+N*(5*p)+S*(5*u)+_*(5*h);x=U>>>13,U&=8191,U+=T*(5*d)+O*(5*l)+k*(5*c)+P*(5*a)+R*(5*o),x+=U>>>13,U&=8191;let D=x+A*o+I*r+N*(5*f)+S*(5*p)+_*(5*u);x=D>>>13,D&=8191,D+=T*(5*h)+O*(5*d)+k*(5*l)+P*(5*c)+R*(5*a),x+=D>>>13,D&=8191;let L=x+A*a+I*o+N*r+S*(5*f)+_*(5*p);x=L>>>13,L&=8191,L+=T*(5*u)+O*(5*h)+k*(5*d)+P*(5*l)+R*(5*c),x+=L>>>13,L&=8191;let W=x+A*c+I*a+N*o+S*r+_*(5*f);x=W>>>13,W&=8191,W+=T*(5*p)+O*(5*u)+k*(5*h)+P*(5*d)+R*(5*l),x+=W>>>13,W&=8191;let M=x+A*l+I*c+N*a+S*o+_*r;x=M>>>13,M&=8191,M+=T*(5*f)+O*(5*p)+k*(5*u)+P*(5*h)+R*(5*d),x+=M>>>13,M&=8191;let B=x+A*d+I*l+N*c+S*a+_*o;x=B>>>13,B&=8191,B+=T*r+O*(5*f)+k*(5*p)+P*(5*u)+R*(5*h),x+=B>>>13,B&=8191;let F=x+A*h+I*d+N*l+S*c+_*a;x=F>>>13,F&=8191,F+=T*o+O*r+k*(5*f)+P*(5*p)+R*(5*u),x+=F>>>13,F&=8191;let j=x+A*u+I*h+N*d+S*l+_*c;x=j>>>13,j&=8191,j+=T*a+O*o+k*r+P*(5*f)+R*(5*p),x+=j>>>13,j&=8191;
2let H=x+A*p+I*u+N*h+S*d+_*l;x=H>>>13,H&=8191,H+=T*c+O*a+k*o+P*r+R*(5*f),x+=H>>>13,H&=8191;let q=x+A*f+I*p+N*u+S*h+_*d;x=q>>>13,q&=8191,q+=T*l+O*c+k*a+P*o+R*r,x+=q>>>13,q&=8191,x=(x<<2)+x|0,x=x+U|0,U=8191&x,x>>>=13,D+=x,i[0]=U,i[1]=D,i[2]=L,i[3]=W,i[4]=M,i[5]=B,i[6]=F,i[7]=j,i[8]=H,i[9]=q}finalize(){const{h:e,pad:t}=this,n=new Uint16Array(10);let i=e[1]>>>13;e[1]&=8191;for(let o=2;o<10;o++)e[o]+=i,i=e[o]>>>13,e[o]&=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,n[0]=e[0]+5,i=n[0]>>>13,n[0]&=8191;for(let o=1;o<10;o++)n[o]=e[o]+i,i=n[o]>>>13,n[o]&=8191;n[9]-=8192;let s=(1^i)-1;for(let o=0;o<10;o++)n[o]&=s;s=~s;for(let o=0;o<10;o++)e[o]=e[o]&s|n[o];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 r=e[0]+t[0];e[0]=65535&r;for(let o=1;o<8;o++)r=(e[o]+t[o]|0)+(r>>>16)|0,e[o]=65535&r;ji(n)}update(e){Bi(this),Mi(e=qi(e));const{buffer:t,blockLen:n}=this,i=e.length;for(let s=0;s<i;){const r=Math.min(n-this.pos,i-s);if(r!==n)t.set(e.subarray(s,s+r),this.pos),this.pos+=r,s+=r,this.pos===n&&(this.process(t,0,!1),this.pos=0);else for(;n<=i-s;s+=n)this.process(e,s)}return this}destroy(){ji(this.h,this.r,this.buffer,this.pad)}digestInto(e){Bi(this),function(e,t){Mi(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}(e,this),this.finished=!0;const{buffer:t,h:n}=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 s=0;for(let r=0;r<8;r++)e[s++]=n[r]>>>0,e[s++]=n[r]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const n=e.slice(0,t);return this.destroy(),n}}const rs=function(e){const t=(t,n)=>e(n).update(qi(t)).digest(),n=e(new Uint8Array(32));return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=t=>e(t),t}(e=>new ss(e));const os=function(e,t){const{allowShortKeys:n,extendNonceFn:i,counterLength:s,counterRight:r,rounds:o}=function(e,t){if(null==t||"object"!=typeof t)throw new Error("options must be defined");return Object.assign(e,t)}({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},t);if("function"!=typeof e)throw new Error("core must be a function");return Wi(s),Wi(o),Li(r),Li(n),function(t,a,c,l){let d=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;Mi(t),Mi(a),Mi(c);const h=c.length;if(void 0===l&&(l=new Uint8Array(h)),Mi(l),Wi(d),d<0||d>=ts)throw new Error("arx: counter overflow");if(l.length<h)throw new Error("arx: output (".concat(l.length,") is shorter than data (").concat(h,")"));const u=[];let p,f,g=t.length;if(32===g)u.push(p=$i(t)),f=Zi;else{if(16!==g||!n)throw new Error("arx: invalid 32-byte key, got length=".concat(g));p=new Uint8Array(32),p.set(t),p.set(t,16),f=Xi,u.push(p)}es(a)||u.push(a=$i(a));const v=Fi(p);if(i){if(24!==a.length)throw new Error("arx: extended nonce must be 24 bytes");i(f,v,Fi(a.subarray(0,16)),v),a=a.subarray(16)}const m=16-s;if(m!==a.length)throw new Error("arx: nonce must be ".concat(m," or 16 bytes"));if(12!==m){const e=new Uint8Array(12);e.set(a,r?0:12-a.length),a=e,u.push(a)}const y=Fi(a);return function(e,t,n,i,s,r,o,a){const c=s.length,l=new Uint8Array(64),d=Fi(l),h=es(s)&&es(r),u=h?Fi(s):ns,p=h?Fi(r):ns;for(let f=0;f<c;o++){if(e(t,n,i,d,o,a),o>=ts)throw new Error("arx: counter overflow");const g=Math.min(64,c-f);if(h&&64===g){const e=f/4;if(f%4!==0)throw new Error("arx: invalid block position");for(let t,n=0;n<16;n++)t=e+n,p[t]=u[t]^d[n];f+=64;continue}for(let e,t=0;t<g;t++)e=f+t,r[e]=s[e]^l[t];f+=g}}(e,f,v,y,c,l,d,o),ji(...u),l}}(function(e,t,n,i,s){let r=arguments.length>5&&void 0!==arguments[5]?arguments[5]:20,o=e[0],a=e[1],c=e[2],l=e[3],d=t[0],h=t[1],u=t[2],p=t[3],f=t[4],g=t[5],v=t[6],m=t[7],y=s,w=n[0],b=n[1],E=n[2],C=o,A=a,I=c,N=l,S=d,_=h,T=u,O=p,k=f,P=g,R=v,x=m,U=y,D=w,L=b,W=E;for(let B=0;B<r;B+=2)C=C+S|0,U=Qi(U^C,16),k=k+U|0,S=Qi(S^k,12),C=C+S|0,U=Qi(U^C,8),k=k+U|0,S=Qi(S^k,7),A=A+_|0,D=Qi(D^A,16),P=P+D|0,_=Qi(_^P,12),A=A+_|0,D=Qi(D^A,8),P=P+D|0,_=Qi(_^P,7),I=I+T|0,L=Qi(L^I,16),R=R+L|0,T=Qi(T^R,12),I=I+T|0,L=Qi(L^I,8),R=R+L|0,T=Qi(T^R,7),N=N+O|0,W=Qi(W^N,16),x=x+W|0,O=Qi(O^x,12),N=N+O|0,W=Qi(W^N,8),x=x+W|0,O=Qi(O^x,7),C=C+_|0,W=Qi(W^C,16),R=R+W|0,_=Qi(_^R,12),C=C+_|0,W=Qi(W^C,8),R=R+W|0,_=Qi(_^R,7),A=A+T|0,U=Qi(U^A,16),x=x+U|0,T=Qi(T^x,12),A=A+T|0,U=Qi(U^A,8),x=x+U|0,T=Qi(T^x,7),I=I+O|0,D=Qi(D^I,16),
2k=k+D|0,O=Qi(O^k,12),I=I+O|0,D=Qi(D^I,8),k=k+D|0,O=Qi(O^k,7),N=N+S|0,L=Qi(L^N,16),P=P+L|0,S=Qi(S^P,12),N=N+S|0,L=Qi(L^N,8),P=P+L|0,S=Qi(S^P,7);let M=0;i[M++]=o+C|0,i[M++]=a+A|0,i[M++]=c+I|0,i[M++]=l+N|0,i[M++]=d+S|0,i[M++]=h+_|0,i[M++]=u+T|0,i[M++]=p+O|0,i[M++]=f+k|0,i[M++]=g+P|0,i[M++]=v+R|0,i[M++]=m+x|0,i[M++]=y+U|0,i[M++]=w+D|0,i[M++]=b+L|0,i[M++]=E+W|0},{counterRight:!1,counterLength:4,allowShortKeys:!1}),as=new Uint8Array(16),cs=(e,t)=>{e.update(t);const n=t.length%16;n&&e.update(as.subarray(n))},ls=new Uint8Array(32);function ds(e,t,n,i,s){const r=e(t,n,ls),o=rs.create(r);s&&cs(o,s),cs(o,i);const a=zi(i.length,s?s.length:0,!0);o.update(a);const c=o.digest();return ji(r,a),c}const hs=((e,t)=>{function n(n){if(Mi(n),!Hi)throw new Error("Non little-endian hardware is not yet supported");for(var i=arguments.length,s=new Array(i>1?i-1:0),r=1;r<i;r++)s[r-1]=arguments[r];if(void 0!==e.nonceLength){const t=s[0];if(!t)throw new Error("nonce / iv required");e.varSizeNonce?Mi(t):Mi(t,e.nonceLength)}const o=e.tagLength;o&&void 0!==s[1]&&Mi(s[1]);const a=t(n,...s),c=(e,t)=>{if(void 0!==t){if(2!==e)throw new Error("cipher output not supported");Mi(t)}};let l=!1;return{encrypt(e,t){if(l)throw new Error("cannot encrypt() twice with same key + nonce");return l=!0,Mi(e),c(a.encrypt.length,t),a.encrypt(e,t)},decrypt(e,t){if(Mi(e),o&&e.length<o)throw new Error("invalid ciphertext length: smaller than tagLength="+o);return c(a.decrypt.length,t),a.decrypt(e,t)}}}return Object.assign(n,e),n})({blockSize:64,nonceLength:12,tagLength:16},(e=>(t,n,i)=>({encrypt(s,r){const o=s.length;(r=Vi(o+16,r,!1)).set(s);const a=r.subarray(0,-16);e(t,n,a,a,1);const c=ds(e,t,n,a,i);return r.set(c,o),ji(c),r},decrypt(s,r){r=Vi(s.length-16,r,!1);const o=s.subarray(0,-16),a=s.subarray(-16),c=ds(e,t,n,o,i);if(!function(e,t){if(e.length!==t.length)return!1;let n=0;for(let i=0;i<e.length;i++)n|=e[i]^t[i];return 0===n}(a,c))throw new Error("invalid tag");return r.set(s.subarray(0,-16)),e(t,n,r,r,1),ji(c),r}}))(os));class us extends nn{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Pt(e);const n=en(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,s=new Uint8Array(i);s.set(n.length>i?e.create().update(n).digest():n);for(let r=0;r<s.length;r++)s[r]^=54;this.iHash.update(s),this.oHash=e.create();for(let r=0;r<s.length;r++)s[r]^=106;this.oHash.update(s),Dt(s)}update(e){return Rt(this),this.iHash.update(e),this}digestInto(e){Rt(this),kt(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:n,finished:i,destroyed:s,blockLen:r,outputLen:o}=this;return e.finished=i,e.destroyed=s,e.blockLen=r,e.outputLen=o,e.oHash=t._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const ps=(e,t,n)=>new us(e,t).update(n).digest();ps.create=(e,t)=>new us(e,t);const fs=Uint8Array.from([0]),gs=Uint8Array.of();const vs=(e,t,n,i,s)=>function(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:32;Pt(e),Ot(i);const s=e.outputLen;if(i>255*s)throw new Error("Length should be <= 255*HashLen");const r=Math.ceil(i/s);void 0===n&&(n=gs);const o=new Uint8Array(r*s),a=ps.create(e,t),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let d=0;d<r;d++)fs[0]=d+1,c.update(0===d?gs:l).update(n).update(fs).digestInto(l),o.set(l,s*d),a._cloneInto(c);return a.destroy(),c.destroy(),Dt(l,fs),o.slice(0,i)}(e,function(e,t,n){return Pt(e),void 0===n&&(n=new Uint8Array(e.outputLen)),ps(e,en(n),en(t))}(e,t,n),i,s),ms=qn,ys=BigInt(0),ws=BigInt(1);function bs(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if("boolean"!=typeof e){const n=t&&'"'.concat(t,'"');throw new Error(n+"expected boolean, got type="+typeof e)}return e}function Es(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";const i=Tt(e),s=null===e||void 0===e?void 0:e.length,r=void 0!==t;if(!i||r&&s!==t){const o=n&&'"'.concat(n,'" '),a=r?" of length ".concat(t):"",c=i?"length=".concat(s):"type=".concat(typeof e);throw new Error(o+"expected Uint8Array"+a+", got "+c)}return e}function Cs(e){const t=e.toString(16);return 1&t.length?"0"+t:t}function As(e){if("string"!=typeof e)throw new Error("hex string expected, got "+typeof e);return""===e?ys:BigInt("0x"+e)}function Is(e){return As(Vt(e))}function Ns(e){return kt(e),As(Vt(Uint8Array.from(e).reverse()))}function Ss(e,t){return Zt(e.toString(16).padStart(2*t,"0"))}function _s(e,t){return Ss(e,t).reverse()}
2function Ts(e,t,n){let i;if("string"==typeof t)try{i=Zt(t)}catch(r){throw new Error(e+" must be hex string or Uint8Array, cause: "+r)}else{if(!Tt(t))throw new Error(e+" must be hex string or Uint8Array");i=Uint8Array.from(t)}const s=i.length;if("number"==typeof n&&s!==n)throw new Error(e+" of length "+n+" expected, got "+s);return i}const Os=e=>"bigint"==typeof e&&ys<=e;function ks(e,t,n,i){if(!function(e,t,n){return Os(e)&&Os(t)&&Os(n)&&t<=e&&e<n}(t,n,i))throw new Error("expected valid "+e+": "+n+" <= n < "+i+", got "+t)}function Ps(e){let t;for(t=0;e>ys;e>>=ws,t+=1);return t}const Rs=e=>(ws<<BigInt(e))-ws;function xs(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!e||"object"!=typeof e)throw new Error("expected valid options object");function i(t,n,i){const s=e[t];if(i&&void 0===s)return;const r=typeof s;if(r!==n||null===s)throw new Error('param "'.concat(t,'" is invalid: expected ').concat(n,", got ").concat(r))}Object.entries(t).forEach(e=>{let[t,n]=e;return i(t,n,!1)}),Object.entries(n).forEach(e=>{let[t,n]=e;return i(t,n,!0)})}function Us(e){const t=new WeakMap;return function(n){const i=t.get(n);if(void 0!==i)return i;for(var s=arguments.length,r=new Array(s>1?s-1:0),o=1;o<s;o++)r[o-1]=arguments[o];const a=e(n,...r);return t.set(n,a),a}}const Ds=BigInt(0),Ls=BigInt(1),Ws=BigInt(2),Ms=BigInt(3),Bs=BigInt(4),Fs=BigInt(5),js=BigInt(7),Hs=BigInt(8),qs=BigInt(9),Vs=BigInt(16);function Ks(e,t){const n=e%t;return n>=Ds?n:t+n}function zs(e,t,n){let i=e;for(;t-- >Ds;)i*=i,i%=n;return i}function $s(e,t){if(e===Ds)throw new Error("invert: expected non-zero number");if(t<=Ds)throw new Error("invert: expected positive modulus, got "+t);let n=Ks(e,t),i=t,s=Ds,r=Ls;for(;n!==Ds;){const e=i%n,t=s-r*(i/n);i=n,n=e,s=r,r=t}if(i!==Ls)throw new Error("invert: does not exist");return Ks(s,t)}function Gs(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function Js(e,t){const n=(e.ORDER+Ls)/Bs,i=e.pow(t,n);return Gs(e,i,t),i}function Ys(e,t){const n=(e.ORDER-Fs)/Hs,i=e.mul(t,Ws),s=e.pow(i,n),r=e.mul(t,s),o=e.mul(e.mul(r,Ws),s),a=e.mul(r,e.sub(o,e.ONE));return Gs(e,a,t),a}function Xs(e){if(e<Ms)throw new Error("sqrt is not defined for small field");let t=e-Ls,n=0;for(;t%Ws===Ds;)t/=Ws,n++;let i=Ws;const s=ir(e);for(;1===tr(s,i);)if(i++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(1===n)return Js;let r=s.pow(i,t);const o=(t+Ls)/Ws;return function(e,i){if(e.is0(i))return i;if(1!==tr(e,i))throw new Error("Cannot find square root");let s=n,a=e.mul(e.ONE,r),c=e.pow(i,t),l=e.pow(i,o);for(;!e.eql(c,e.ONE);){if(e.is0(c))return e.ZERO;let t=1,n=e.sqr(c);for(;!e.eql(n,e.ONE);)if(t++,n=e.sqr(n),t===s)throw new Error("Cannot find square root");const i=Ls<<BigInt(s-t-1),r=e.pow(a,i);s=t,a=e.sqr(r),c=e.mul(c,a),l=e.mul(l,r)}return l}}function Zs(e){return e%Bs===Ms?Js:e%Hs===Fs?Ys:e%Vs===qs?function(e){const t=ir(e),n=Xs(e),i=n(t,t.neg(t.ONE)),s=n(t,i),r=n(t,t.neg(i)),o=(e+js)/Vs;return(e,t)=>{let n=e.pow(t,o),a=e.mul(n,i);const c=e.mul(n,s),l=e.mul(n,r),d=e.eql(e.sqr(a),t),h=e.eql(e.sqr(c),t);n=e.cmov(n,a,d),a=e.cmov(l,c,h);const u=e.eql(e.sqr(a),t),p=e.cmov(n,a,u);return Gs(e,p,t),p}}(e):Xs(e)}const Qs=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function er(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=new Array(t.length).fill(n?e.ZERO:void 0),s=t.reduce((t,n,s)=>e.is0(n)?t:(i[s]=t,e.mul(t,n)),e.ONE),r=e.inv(s);return t.reduceRight((t,n,s)=>e.is0(n)?t:(i[s]=e.mul(t,i[s]),e.mul(t,n)),r),i}function tr(e,t){const n=(e.ORDER-Ls)/Ws,i=e.pow(t,n),s=e.eql(i,e.ONE),r=e.eql(i,e.ZERO),o=e.eql(i,e.neg(e.ONE));if(!s&&!r&&!o)throw new Error("invalid Legendre symbol result");return s?1:r?0:-1}function nr(e,t){void 0!==t&&Ot(t);const n=void 0!==t?t:e.toString(2).length;return{nBitLength:n,nByteLength:Math.ceil(n/8)}}function ir(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};if(e<=Ds)throw new Error("invalid field: expected ORDER > 0, got "+e);let s,r,o,a=!1;if("object"==typeof t&&null!=t){if(i.sqrt||n)throw new Error("cannot specify opts in two arguments");const e=t;e.BITS&&(s=e.BITS),e.sqrt&&(r=e.sqrt),"boolean"==typeof e.isLE&&(n=e.isLE),"boolean"==typeof e.modFromBytes&&(a=e.modFromBytes),o=e.allowedLengths}else"number"==typeof t&&(s=t),i.sqrt&&(r=i.sqrt);const{nBitLength:c,nByteLength:l}=nr(e,s);if(l>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let d;const h=Object.freeze({ORDER:e,isLE:n,BITS:c,BYTES:l,MASK:Rs(c),ZERO:Ds,ONE:Ls,allowedLengths:o,create:t=>Ks(t,e),isValid:t=>{if("bigint"!=typeof t)throw new Error("invalid field element: expected bigint, got "+typeof t);return Ds<=t&&t<e},is0:e=>e===Ds,isValidNot0:e=>!h.is0(e)&&h.isValid(e),isOdd:e=>(e&Ls)===Ls,neg:t=>Ks(-t,e),eql:(e,t)=>
2e===t,sqr:t=>Ks(t*t,e),add:(t,n)=>Ks(t+n,e),sub:(t,n)=>Ks(t-n,e),mul:(t,n)=>Ks(t*n,e),pow:(e,t)=>function(e,t,n){if(n<Ds)throw new Error("invalid exponent, negatives unsupported");if(n===Ds)return e.ONE;if(n===Ls)return t;let i=e.ONE,s=t;for(;n>Ds;)n&Ls&&(i=e.mul(i,s)),s=e.sqr(s),n>>=Ls;return i}(h,e,t),div:(t,n)=>Ks(t*$s(n,e),e),sqrN:e=>e*e,addN:(e,t)=>e+t,subN:(e,t)=>e-t,mulN:(e,t)=>e*t,inv:t=>$s(t,e),sqrt:r||(t=>(d||(d=Zs(e)),d(h,t))),toBytes:e=>n?_s(e,l):Ss(e,l),fromBytes:function(t){let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(o){if(!o.includes(t.length)||t.length>l)throw new Error("Field.fromBytes: expected "+o+" bytes, got "+t.length);const e=new Uint8Array(l);e.set(t,n?0:e.length-t.length),t=e}if(t.length!==l)throw new Error("Field.fromBytes: expected "+l+" bytes, got "+t.length);let s=n?Ns(t):Is(t);if(a&&(s=Ks(s,e)),!i&&!h.isValid(s))throw new Error("invalid field element: outside of range 0..ORDER");return s},invertBatch:e=>er(h,e),cmov:(e,t,n)=>n?t:e});return Object.freeze(h)}function sr(e){if("bigint"!=typeof e)throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function rr(e){const t=sr(e);return t+Math.ceil(t/2)}const or=BigInt(0),ar=BigInt(1);function cr(e,t){const n=t.negate();return e?n:t}function lr(e,t){const n=er(e.Fp,t.map(e=>e.Z));return t.map((t,i)=>e.fromAffine(t.toAffine(n[i])))}function dr(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function hr(e,t){dr(e,t);const n=2**e;return{windows:Math.ceil(t/e)+1,windowSize:2**(e-1),mask:Rs(e),maxNumber:n,shiftBy:BigInt(e)}}function ur(e,t,n){const{windowSize:i,mask:s,maxNumber:r,shiftBy:o}=n;let a=Number(e&s),c=e>>o;a>i&&(a-=r,c+=ar);const l=t*i;return{nextN:c,offset:l+Math.abs(a)-1,isZero:0===a,isNeg:a<0,isNegF:t%2!==0,offsetF:l}}const pr=new WeakMap,fr=new WeakMap;function gr(e){return fr.get(e)||1}function vr(e){if(e!==or)throw new Error("invalid wNAF")}class mr{constructor(e,t){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=t}_unsafeLadder(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:this.ZERO,i=e;for(;t>or;)t&ar&&(n=n.add(i)),i=i.double(),t>>=ar;return n}precomputeWindow(e,t){const{windows:n,windowSize:i}=hr(t,this.bits),s=[];let r=e,o=r;for(let a=0;a<n;a++){o=r,s.push(o);for(let e=1;e<i;e++)o=o.add(r),s.push(o);r=o.double()}return s}wNAF(e,t,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let i=this.ZERO,s=this.BASE;const r=hr(e,this.bits);for(let o=0;o<r.windows;o++){const{nextN:e,offset:a,isZero:c,isNeg:l,isNegF:d,offsetF:h}=ur(n,o,r);n=e,c?s=s.add(cr(d,t[h])):i=i.add(cr(l,t[a]))}return vr(n),{p:i,f:s}}wNAFUnsafe(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:this.ZERO;const s=hr(e,this.bits);for(let r=0;r<s.windows&&n!==or;r++){const{nextN:e,offset:o,isZero:a,isNeg:c}=ur(n,r,s);if(n=e,!a){const e=t[o];i=i.add(c?e.negate():e)}}return vr(n),i}
2getPrecomputes(e,t,n){let i=pr.get(t);return i||(i=this.precomputeWindow(t,e),1!==e&&("function"==typeof n&&(i=n(i)),pr.set(t,i))),i}cached(e,t,n){const i=gr(e);return this.wNAF(i,this.getPrecomputes(i,e,n),t)}unsafe(e,t,n,i){const s=gr(e);return 1===s?this._unsafeLadder(e,t,i):this.wNAFUnsafe(s,this.getPrecomputes(s,e,n),t,i)}createCache(e,t){dr(t,this.bits),fr.set(e,t),pr.delete(e)}hasCache(e){return 1!==gr(e)}}function yr(e,t,n,i){(function(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((e,n)=>{if(!(e instanceof t))throw new Error("invalid point at index "+n)})})(n,e),function(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((e,n)=>{if(!t.isValid(e))throw new Error("invalid scalar at index "+n)})}(i,t);const s=n.length,r=i.length;if(s!==r)throw new Error("arrays of points and scalars must have equal length");const o=e.ZERO,a=Ps(BigInt(s));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const l=Rs(c),d=new Array(Number(l)+1).fill(o);let h=o;for(let u=Math.floor((t.BITS-1)/c)*c;u>=0;u-=c){d.fill(o);for(let t=0;t<r;t++){const e=i[t],s=Number(e>>BigInt(u)&l);d[s]=d[s].add(n[t])}let e=o;for(let t=d.length-1,n=o;t>0;t--)n=n.add(d[t]),e=e.add(n);if(h=h.add(e),0!==u)for(let t=0;t<c;t++)h=h.double()}return h}function wr(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return function(e){xs(e,Qs.reduce((e,t)=>(e[t]="function",e),{ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"}))}(t),t}return ir(e,{isLE:n})}BigInt(0),BigInt(1),BigInt(2),BigInt(8),Qt("HashToScalar-");const br=BigInt(0),Er=BigInt(1),Cr=BigInt(2);function Ar(e){const t=function(e){return xs(e,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze((0,i.A)({},e))}(e),{P:n,type:s,adjustScalarBytes:r,powPminus2:o,randomBytes:a}=t,c="x25519"===s;if(!c&&"x448"!==s)throw new Error("invalid type");const l=a||rn,d=c?255:448,h=c?32:56,u=BigInt(c?9:5),p=BigInt(c?121665:39081),f=c?Cr**BigInt(254):Cr**BigInt(447),g=c?BigInt(8)*Cr**BigInt(251)-Er:BigInt(4)*Cr**BigInt(445)-Er,v=f+g+Er,m=e=>Ks(e,n),y=w(u);function w(e){return _s(m(e),h)}function b(e,t){const i=function(e,t){ks("u",e,br,n),ks("scalar",t,f,v);const i=t,s=e;let r=Er,a=br,c=e,l=Er,h=br;for(let n=BigInt(d-1);n>=br;n--){const e=i>>n&Er;h^=e,({x_2:r,x_3:c}=C(h,r,c)),({x_2:a,x_3:l}=C(h,a,l)),h=e;const t=r+a,o=m(t*t),d=r-a,u=m(d*d),f=o-u,g=c+l,v=m((c-l)*t),y=m(g*d),w=v+y,b=v-y;c=m(w*w),l=m(s*m(b*b)),r=m(o*u),a=m(f*(o+m(p*f)))}({x_2:r,x_3:c}=C(h,r,c)),({x_2:a,x_3:l}=C(h,a,l));const u=o(a);return m(r*u)}(function(e){const t=Ts("u coordinate",e,h);return c&&(t[31]&=127),m(Ns(t))}(t),function(e){return Ns(r(Ts("scalar",e,h)))}(e));if(i===br)throw new Error("invalid private or public key received");return w(i)}function E(e){return b(e,y)}function C(e,t,n){const i=m(e*(t-n));return{x_2:t=m(t-i),x_3:n=m(n+i)}}const A={secretKey:h,publicKey:h,seed:h},I=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:l(h);return kt(e,A.seed),e};return{keygen:function(e){const t=I(e);return{secretKey:t,publicKey:E(t)}},getSharedSecret:(e,t)=>b(e,t),getPublicKey:e=>E(e),scalarMult:b,scalarMultBase:E,utils:{randomSecretKey:I,randomPrivateKey:I},GuBytes:y.slice(),lengths:A}}const Ir=BigInt(1),Nr=BigInt(2),Sr=BigInt(3),_r=BigInt(5),Tr=BigInt(8),Or=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");function kr(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}const Pr=ir({p:Or,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:Tr,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")}.p,{isLE:!0}),Rr=(()=>{const e=Pr.ORDER;return Ar({P:e,type:"x25519",powPminus2:t=>{const{pow_p_5_8:n,b2:i}=function(e){const t=BigInt(10),n=BigInt(20),i=BigInt(40),s=BigInt(80),r=Or,o=e*e%r*e%r,a=zs(o,Nr,r)*o%r,c=zs(a,Ir,r)*e%r,l=zs(c,_r,r)*c%r,d=zs(l,t,r)*l%r,h=zs(d,n,r)*d%r,u=zs(h,i,r)*h%r,p=zs(u,s,r)*u%r,f
2=zs(p,s,r)*u%r,g=zs(f,t,r)*l%r;return{pow_p_5_8:zs(g,Nr,r)*e%r,b2:o}}(t);return Ks(zs(n,Sr,e)*i,e)},adjustScalarBytes:kr})})(),xr=(e,t)=>(e+(e>=0?t:-t)/Fr)/t;function Ur(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Dr(e,t){const n={};for(let i of Object.keys(t))n[i]=void 0===e[i]?t[i]:e[i];return bs(n.lowS,"lowS"),bs(n.prehash,"prehash"),void 0!==n.format&&Ur(n.format),n}class Lr extends Error{constructor(){super(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"")}}const Wr={Err:Lr,_tlv:{encode:(e,t)=>{const{Err:n}=Wr;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(1&t.length)throw new n("tlv.encode: unpadded data");const i=t.length/2,s=Cs(i);if(s.length/2&128)throw new n("tlv.encode: long form length too big");const r=i>127?Cs(s.length/2|128):"";return Cs(e)+r+s+t},decode(e,t){const{Err:n}=Wr;let i=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[i++]!==e)throw new n("tlv.decode: wrong tlv");const s=t[i++];let r=0;if(!!(128&s)){const e=127&s;if(!e)throw new n("tlv.decode(long): indefinite length not supported");if(e>4)throw new n("tlv.decode(long): byte length is too big");const o=t.subarray(i,i+e);if(o.length!==e)throw new n("tlv.decode: length bytes not complete");if(0===o[0])throw new n("tlv.decode(long): zero leftmost byte");for(const t of o)r=r<<8|t;if(i+=e,r<128)throw new n("tlv.decode(long): not minimal encoding")}else r=s;const o=t.subarray(i,i+r);if(o.length!==r)throw new n("tlv.decode: wrong value length");return{v:o,l:t.subarray(i+r)}}},_int:{encode(e){const{Err:t}=Wr;if(e<Mr)throw new t("integer: negative integers are not allowed");let n=Cs(e);if(8&Number.parseInt(n[0],16)&&(n="00"+n),1&n.length)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=Wr;if(128&e[0])throw new t("invalid signature integer: negative");if(0===e[0]&&!(128&e[1]))throw new t("invalid signature integer: unnecessary leading zero");return Is(e)}},toSig(e){const{Err:t,_int:n,_tlv:i}=Wr,s=Ts("signature",e),{v:r,l:o}=i.decode(48,s);if(o.length)throw new t("invalid signature: left bytes after parsing");const{v:a,l:c}=i.decode(2,r),{v:l,l:d}=i.decode(2,c);if(d.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(a),s:n.decode(l)}},hexFromSig(e){const{_tlv:t,_int:n}=Wr,i=t.encode(2,n.encode(e.r))+t.encode(2,n.encode(e.s));return t.encode(48,i)}},Mr=BigInt(0),Br=BigInt(1),Fr=BigInt(2),jr=BigInt(3),Hr=BigInt(4);function qr(e,t){const{BYTES:n}=e;let i;if("bigint"==typeof t)i=t;else{let r=Ts("private key",t);try{i=e.fromBytes(r)}catch(s){throw new Error("invalid private key: expected ui8a of size ".concat(n,", got ").concat(typeof t))}}if(!e.isValidNot0(i))throw new Error("invalid private key: out of range [1..N-1]");return i}function Vr(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const n=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3?arguments[3]:void 0;if(void 0===i&&(i="edwards"===e),!t||"object"!=typeof t)throw new Error("expected valid ".concat(e," CURVE object"));for(const a of["p","n","h"]){const e=t[a];if(!("bigint"==typeof e&&e>or))throw new Error("CURVE.".concat(a," must be positive bigint"))}const s=wr(t.p,n.Fp,i),r=wr(t.n,n.Fn,i),o=["Gx","Gy","a","weierstrass"===e?"b":"d"];for(const a of o)if(!s.isValid(t[a]))throw new Error("CURVE.".concat(a," must be valid field element of CURVE.Fp"));return{CURVE:t=Object.freeze(Object.assign({},t)),Fp:s,Fn:r}}("weierstrass",e,t),{Fp:i,Fn:s}=n;let r=n.CURVE;const{h:o,n:a}=r;xs(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:c}=t;if(c&&(!i.is0(r.a)||"bigint"!=typeof c.beta||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const l=zr(i,s);function d(){if(!i.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}const h=t.toBytes||function(e,t,n){const{x:s,y:r}=t.toAffine(),o=i.toBytes(s);if(bs(n,"isCompressed"),n){d();return tn(Kr(!i.isOdd(r)),o)}return tn(Uint8Array.of(4),o,i.toBytes(r))},u=t.fromBytes||function(e){Es(e,void 0,"Point");const{publicKey:t,publicKeyUncompressed:n}=l,s=e.length,r=e[0],o=e.subarray(1);if(s!==t||2!==r&&3!==r){if(s===n&&4===r){const e=i.BYTES,t=i.fromBytes(o.subarray(0,e)),n=i.fromBytes(o.subarray(e,2*e));if(!f(t,n))throw new Error("bad point: is not on curve");return{x:t,y:n}}throw new Error("bad point: got length ".concat(s,", expected compressed=").concat(t," or uncompressed=").concat(n))}{const e=i.fromBytes(o);if(!i.isValid(e))throw new Error("bad point: is not on curve, wrong x");const t=p(e);let n;try{n=i.sqrt(t)}catch(a){const e=a instanceof Error?": "+a.message:"";throw new Error("bad point: is not on curve, sqrt error"+e)}d();return 1===(1&r)!==i.isOdd(n)&&(n=i.neg(n)),{x:e,y:n}}};function p(e){const t=i.sqr(e),n=i.mul(t,e);return i.add(i.add(n,i.mul(e,r.a)),r.b)}function f(e,t){const n=i.sqr(t),s=p(e);return i.eql(n,s)}if(!f(r.Gx,r.Gy))throw new Error("bad curve params: generator point");const g=i.mul(i.pow(r.a,jr),Hr),v=i.mul(i.sqr(r.b),BigInt(27));if(i.is0(i.add(g,v)))throw new Error("bad curve params: a or b");function m(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(!i.isValid(t)||n&&i.is0(t))throw new Error("bad point coordinate ".concat(e));return t}function y(e){if(!(e instanceof A))throw new Error("ProjectivePoint expected")}function w(e){if(!c||!c.basises)throw new Error("no endo");return function(e,t,n){const[[i,s],[r,o]]=t,a=xr(o*e,n),c=xr(-s*e,n);let l=e-a*i-c*r,d=-a*s-c*o;const h=l<Mr,u=d<Mr;h&&(l=-l),u&&(d=-d);const p=Rs(Math.ceil(Ps(n)/2))+Br;if(l<Mr||l>=p||d<Mr||d>
2=p)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:h,k1:l,k2neg:u,k2:d}}(e,c.basises,s.ORDER)}const b=Us((e,t)=>{const{X:n,Y:s,Z:r}=e;if(i.eql(r,i.ONE))return{x:n,y:s};const o=e.is0();null==t&&(t=o?i.ONE:i.inv(r));const a=i.mul(n,t),c=i.mul(s,t),l=i.mul(r,t);if(o)return{x:i.ZERO,y:i.ZERO};if(!i.eql(l,i.ONE))throw new Error("invZ was invalid");return{x:a,y:c}}),E=Us(e=>{if(e.is0()){if(t.allowInfinityPoint&&!i.is0(e.Y))return;throw new Error("bad point: ZERO")}const{x:n,y:s}=e.toAffine();if(!i.isValid(n)||!i.isValid(s))throw new Error("bad point: x or y not field elements");if(!f(n,s))throw new Error("bad point: equation left != right");if(!e.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function C(e,t,n,s,r){return n=new A(i.mul(n.X,e),n.Y,n.Z),t=cr(s,t),n=cr(r,n),t.add(n)}class A{constructor(e,t,n){this.X=m("x",e),this.Y=m("y",t,!0),this.Z=m("z",n),Object.freeze(this)}static CURVE(){return r}static fromAffine(e){const{x:t,y:n}=e||{};if(!e||!i.isValid(t)||!i.isValid(n))throw new Error("invalid affine point");if(e instanceof A)throw new Error("projective point not allowed");return i.is0(t)&&i.is0(n)?A.ZERO:new A(t,n,i.ONE)}static fromBytes(e){const t=A.fromAffine(u(Es(e,void 0,"point")));return t.assertValidity(),t}static fromHex(e){return A.fromBytes(Ts("pointHex",e))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return N.createCache(this,e),t||this.multiply(jr),this}assertValidity(){E(this)}hasEvenY(){const{y:e}=this.toAffine();if(!i.isOdd)throw new Error("Field doesn't support isOdd");return!i.isOdd(e)}equals(e){y(e);const{X:t,Y:n,Z:s}=this,{X:r,Y:o,Z:a}=e,c=i.eql(i.mul(t,a),i.mul(r,s)),l=i.eql(i.mul(n,a),i.mul(o,s));return c&&l}negate(){return new A(this.X,i.neg(this.Y),this.Z)}double(){const{a:e,b:t}=r,n=i.mul(t,jr),{X:s,Y:o,Z:a}=this;let c=i.ZERO,l=i.ZERO,d=i.ZERO,h=i.mul(s,s),u=i.mul(o,o),p=i.mul(a,a),f=i.mul(s,o);return f=i.add(f,f),d=i.mul(s,a),d=i.add(d,d),c=i.mul(e,d),l=i.mul(n,p),l=i.add(c,l),c=i.sub(u,l),l=i.add(u,l),l=i.mul(c,l),c=i.mul(f,c),d=i.mul(n,d),p=i.mul(e,p),f=i.sub(h,p),f=i.mul(e,f),f=i.add(f,d),d=i.add(h,h),h=i.add(d,h),h=i.add(h,p),h=i.mul(h,f),l=i.add(l,h),p=i.mul(o,a),p=i.add(p,p),h=i.mul(p,f),c=i.sub(c,h),d=i.mul(p,u),d=i.add(d,d),d=i.add(d,d),new A(c,l,d)}add(e){y(e);const{X:t,Y:n,Z:s}=this,{X:o,Y:a,Z:c}=e;let l=i.ZERO,d=i.ZERO,h=i.ZERO;const u=r.a,p=i.mul(r.b,jr);let f=i.mul(t,o),g=i.mul(n,a),v=i.mul(s,c),m=i.add(t,n),w=i.add(o,a);m=i.mul(m,w),w=i.add(f,g),m=i.sub(m,w),w=i.add(t,s);let b=i.add(o,c);return w=i.mul(w,b),b=i.add(f,v),w=i.sub(w,b),b=i.add(n,s),l=i.add(a,c),b=i.mul(b,l),l=i.add(g,v),b=i.sub(b,l),h=i.mul(u,w),l=i.mul(p,v),h=i.add(l,h),l=i.sub(g,h),h=i.add(g,h),d=i.mul(l,h),g=i.add(f,f),g=i.add(g,f),v=i.mul(u,v),w=i.mul(p,w),g=i.add(g,v),v=i.sub(f,v),v=i.mul(u,v),w=i.add(w,v),f=i.mul(g,w),d=i.add(d,f),f=i.mul(b,w),l=i.mul(m,l),l=i.sub(l,f),f=i.mul(m,g),h=i.mul(b,h),h=i.add(h,f),new A(l,d,h)}subtract(e){return this.add(e.negate())}is0(){return this.equals(A.ZERO)}multiply(e){const{endo:n}=t;if(!s.isValidNot0(e))throw new Error("invalid scalar: out of range");let i,r;const o=e=>N.cached(this,e,e=>lr(A,e));if(n){const{k1neg:t,k1:s,k2neg:a,k2:c}=w(e),{p:l,f:d}=o(s),{p:h,f:u}=o(c);r=d.add(u),i=C(n.beta,l,h,t,a)}else{const{p:t,f:n}=o(e);i=t,r=n}return lr(A,[i,r])[0]}multiplyUnsafe(e){const{endo:n}=t,i=this;if(!s.isValid(e))throw new Error("invalid scalar: out of range");if(e===Mr||i.is0())return A.ZERO;if(e===Br)return i;if(N.hasCache(this))return this.multiply(e);if(n){const{k1neg:t,k1:s,k2neg:r,k2:o}=w(e),{p1:a,p2:c}=function(e,t,n,i){let s=t,r=e.ZERO,o=e.ZERO;for(;n>or||i>or;)n&ar&&(r=r.add(s)),i&ar&&(o=o.add(s)),s=s.double(),n>>=ar,i>>=ar;return{p1:r,p2:o}}(A,i,s,o);return C(n.beta,a,c,t,r)}return N.unsafe(i,e)}multiplyAndAddUnsafe(e,t,n){const i=this.multiplyUnsafe(t).add(e.multiplyUnsafe(n));return i.is0()?void 0:i}toAffine(e){return b(this,e)}isTorsionFree(){const{isTorsionFree:e}=t;return o===Br||(e?e(A,this):N.unsafe(this,a).is0())}clearCofactor(){const{clearCofactor:e}=t;return o===Br?this:e?e(A,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return bs(e,"isCompressed"),this.assertValidity(),h(A,this,e)}toHex(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return Vt(this.toBytes(e))}toString(){return"<Point ".concat(this.is0()?"ZERO":this.toHex(),">")}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(){let e=!(arguments.length>0&&void 0!==arguments[0])||arguments[0];return this.toBytes(e)}
2_setWindowSize(e){this.precompute(e)}static normalizeZ(e){return lr(A,e)}static msm(e,t){return yr(A,s,e,t)}static fromPrivateKey(e){return A.BASE.multiply(qr(s,e))}}A.BASE=new A(r.Gx,r.Gy,i.ONE),A.ZERO=new A(i.ZERO,i.ONE,i.ZERO),A.Fp=i,A.Fn=s;const I=s.BITS,N=new mr(A,t.endo?Math.ceil(I/2):I);return A.BASE.precompute(8),A}function Kr(e){return Uint8Array.of(e?2:3)}function zr(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function $r(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};const{Fn:n}=e,i=t.randomBytes||rn,s=Object.assign(zr(e.Fp,n),{seed:rr(n.ORDER)});function r(e){try{return!!qr(n,e)}catch(t){return!1}}function o(){return function(e,t){let n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];const i=e.length,s=sr(t),r=rr(t);if(i<16||i<r||i>1024)throw new Error("expected "+r+"-1024 bytes of input, got "+i);const o=Ks(n?Ns(e):Is(e),t-Ls)+Ls;return n?_s(o,s):Ss(o,s)}(Es(arguments.length>0&&void 0!==arguments[0]?arguments[0]:i(s.seed),s.seed,"seed"),n.ORDER)}function a(t){let i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];return e.BASE.multiply(qr(n,t)).toBytes(i)}function c(t){if("bigint"==typeof t)return!1;if(t instanceof e)return!0;const{secretKey:i,publicKey:r,publicKeyUncompressed:o}=s;if(n.allowedLengths||i===r)return;const a=Ts("key",t).length;return a===r||a===o}return Object.freeze({getPublicKey:a,getSharedSecret:function(t,i){let s=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];if(!0===c(t))throw new Error("first arg must be private key");if(!1===c(i))throw new Error("second arg must be public key");const r=qr(n,t);return e.fromHex(i).multiply(r).toBytes(s)},keygen:function(e){const t=o(e);return{secretKey:t,publicKey:a(t)}},Point:e,utils:{isValidSecretKey:r,isValidPublicKey:function(t,n){const{publicKey:i,publicKeyUncompressed:r}=s;try{const s=t.length;return!(!0===n&&s!==i||!1===n&&s!==r)&&!!e.fromBytes(t)}catch(o){return!1}},randomSecretKey:o,isValidPrivateKey:r,randomPrivateKey:o,normPrivateKeyToScalar:e=>qr(n,e),precompute(){let t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:8;return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:e.BASE).precompute(t,!1)}},lengths:s})}function Gr(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};Pt(t),xs(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const i=n.randomBytes||rn,s=n.hmac||function(e){for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return ps(t,e,tn(...i))},{Fp:r,Fn:o}=e,{ORDER:a,BITS:c}=o,{keygen:l,getPublicKey:d,getSharedSecret:h,utils:u,lengths:p}=$r(e,n),f={prehash:!1,lowS:"boolean"==typeof n.lowS&&n.lowS,format:void 0,extraEntropy:!1},g="compact";function v(e){return e>a>>Br}function m(e,t){if(!o.isValidNot0(t))throw new Error("invalid signature ".concat(e,": out of range 1..Point.Fn.ORDER"));return t}class y{constructor(e,t,n){this.r=m("r",e),this.s=m("s",t),null!=n&&(this.recovery=n),Object.freeze(this)}static fromBytes(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:g;if(function(e,t){Ur(t);const n=p.signature;Es(e,"compact"===t?n:"recovered"===t?n+1:void 0,"".concat(t," signature"))}(e,n),"der"===n){const{r:t,s:n}=Wr.toSig(Es(e));return new y(t,n)}"recovered"===n&&(t=e[0],n="compact",e=e.subarray(1));const i=o.BYTES,s=e.subarray(0,i),r=e.subarray(i,2*i);return new y(o.fromBytes(s),o.fromBytes(r),t)}static fromHex(e,t){return this.fromBytes(Zt(e),t)}addRecoveryBit(e){return new y(this.r,this.s,e)}recoverPublicKey(t){const n=r.ORDER,{r:i,s:s,recovery:c}=this;if(null==c||![0,1,2,3].includes(c))throw new Error("recovery id invalid");if(a*Fr<n&&c>1)throw new Error("recovery id is ambiguous for h>1 curve");const l=2===c||3===c?i+a:i;if(!r.isValid(l))throw new Error("recovery id 2 or 3 invalid");const d=r.toBytes(l),h=e.fromBytes(tn(Kr(0===(1&c)),d)),u=o.inv(l),p=b(Ts("msgHash",t)),f=o.create(-p*u),g=o.create(s*u),v=e.BASE.multiplyUnsafe(f).add(h.multiplyUnsafe(g));if(v.is0())throw new Error("point at infinify");return v.assertValidity(),v}hasHighS(){return v(this.s)}toBytes(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:g;if(Ur(e),"der"===e)return Zt(Wr.hexFromSig(this));const t=o.toBytes(this.r),n=o.toBytes(this.s);if("recovered"===e){if(null==this.recovery)throw new Error("recovery bit must be present");return tn(Uint8Array.of(this.recovery),t,n)}return tn(t,n)}toHex(e){return Vt(this.toBytes(e))}assertValidity(){}static fromCompact(e){return y.fromBytes(Ts("sig",e),"compact")}static fromDER(e){return y.fromBytes(Ts("sig",e),"der")}normalizeS(){return this.hasHighS()?new y(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Vt(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Vt(this.toBytes("compact"))}}const w=n.bits2int||function(e){if(e.length>8192)throw new Error("input is too large");const t=Is(e),n=8*e.length-c;return n>0?t>>BigInt(n):t},b=n.bits2int_modN||function(e){return o.create(w(e))},E=Rs(c);function C(e){return ks("num < 2^"+c,e,Mr,E),o.toBytes(e)}function A(e,n){return Es(e,void 0,"message"),n?Es(t(e),void 0,"prehashed message"):e}return Object.freeze({keygen:l,getPublicKey:d,getSharedSecret:h,utils:u,lengths:p,Point:e,sign:function(n,r){let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};n=Ts("message",n);const{seed:c,k2sig:l}=function(t,n,s){if(["recovered","canonical"].some(e=>e in s))throw new Error("sign() legacy options not supported");const{lowS:r,prehash:a,extraEntropy:c}=Dr(s,f);t=A(t,a);const l=b(t),d=qr(o,n),h=[C(d),C(l)];if(null!=c&&!1!==c){const e=!0===c?i(p.secretKey):c;h.push(Ts("extraEntropy",e))}const u=tn(...h),g=l;return{seed:u,k2sig:function(t){const n=w(t);if(!o.isValidNot0(n))return;const i=o.inv(n),s=e.BASE.multiply(n).toAffine(),a=o.create(s.x);if(a===Mr)return;const c=o.create(i*o.create(g+a*d));if(c===Mr)return;let l=(s.x===a?0:2)|Number(s.y&Br),h=c;return r&&v(c)&&(h=o.neg(c),l^=1),new y(a,h,l)}}}(n,r,a);return function(e,t,n){if("number"!=typeof e||e<2)throw new Error("hashLen must be a number");if("number"!=typeof t||t<2)throw new Error("qByteLen must be a number");if("function"!=typeof n)throw new Error("hmacFn must be a function");const i=e=>new Uint8Array(e),s=e=>Uint8Array.of(e);let r=i(e),o=i(e),a=0;const c=()=>{r.fill(1),o.fill(0),a=0},l=function(){for(var e=arguments.length,t=new Array(e),i=0;i<e;i++)t[i]=arguments[i];return n(o,r,...t)},d=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:i(0);o=l(s(0),e),r=l(),0!==e.length&&(o=l(s(1),e),r=l())},h=()=>
2{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let e=0;const n=[];for(;e<t;){r=l();const t=r.slice();n.push(t),e+=r.length}return tn(...n)};return(e,t)=>{let n;for(c(),d(e);!(n=t(h()));)d();return c(),n}}(t.outputLen,o.BYTES,s)(c,l)},verify:function(t,n,i){let s=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};const{lowS:r,prehash:a,format:c}=Dr(s,f);if(i=Ts("publicKey",i),n=A(Ts("message",n),a),"strict"in s)throw new Error("options.strict was renamed to lowS");const l=void 0===c?function(e){let t;const n="string"==typeof e||Tt(e),i=!n&&null!==e&&"object"==typeof e&&"bigint"==typeof e.r&&"bigint"==typeof e.s;if(!n&&!i)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(i)t=new y(e.r,e.s);else if(n){try{t=y.fromBytes(Ts("sig",e),"der")}catch(r){if(!(r instanceof Wr.Err))throw r}if(!t)try{t=y.fromBytes(Ts("sig",e),"compact")}catch(s){return!1}}return t||!1}(t):y.fromBytes(Ts("sig",t),c);if(!1===l)return!1;try{const t=e.fromBytes(i);if(r&&l.hasHighS())return!1;const{r:s,s:a}=l,c=b(n),d=o.inv(a),h=o.create(c*d),u=o.create(s*d),p=e.BASE.multiplyUnsafe(h).add(t.multiplyUnsafe(u));return!p.is0()&&o.create(p.x)===s}catch(d){return!1}},recoverPublicKey:function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};const{prehash:i}=Dr(n,f);return t=A(t,i),y.fromBytes(e,"recovered").recoverPublicKey(t).toBytes()},Signature:y,hash:t})}function Jr(e){const{CURVE:t,curveOpts:n}=function(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let i=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(e=>Math.ceil(e/2)))):void 0;return{CURVE:t,curveOpts:{Fp:n,Fn:ir(t.n,{BITS:e.nBitLength,allowedLengths:i,modFromBytes:e.wrapPrivateKey}),allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes}}}(e),i={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:i}}function Yr(e){const{CURVE:t,curveOpts:n,hash:i,ecdsaOpts:s}=Jr(e);return function(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,nr(n.Fn.ORDER,n.Fn.BITS))})}(e,Gr(Vr(t,n),i,s))}function Xr(e,t){const n=t=>Yr((0,i.A)((0,i.A)({},e),{},{hash:t}));return(0,i.A)((0,i.A)({},n(t)),{},{create:n})}const Zr={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},Qr={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},eo={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},to=ir(Zr.p),no=ir(Qr.p),io=ir(eo.p),so=Xr((0,i.A)((0,i.A)({},Zr),{},{Fp:to,lowS:!1}),qn);Xr((0,i.A)((0,i.A)({},Qr),{},{Fp:no,lowS:!1}),Kn),Xr((0,i.A)((0,i.A)({},eo),{}
2,{Fp:io,lowS:!1,allowedPrivateKeyLengths:[130,131,132]}),Vn);const ro=so,oo="base10",ao="base16",co="base64pad",lo="base64url",ho="utf8";function uo(){const e=rn(32);return(0,ve.dI)(e,ao)}function po(e){const t=ms((0,ve.sH)(e,ao));return(0,ve.dI)(t,ao)}function fo(e){const t=ms((0,ve.sH)(e,ho));return(0,ve.dI)(t,ao)}function go(e){return(0,ve.sH)("".concat(e),oo)}function vo(e){return Number((0,ve.dI)(e,oo))}function mo(e){return e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function yo(e){const t=e.replace(/-/g,"+").replace(/_/g,"/"),n=(4-t.length%4)%4;return t+"=".repeat(n)}function wo(e){if(2===vo(e.type))return(0,ve.dI)((0,ve.xW)([e.type,e.sealed]),co);if(1===vo(e.type)){if(typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return(0,ve.dI)((0,ve.xW)([e.type,e.senderPublicKey,e.iv,e.sealed]),co)}return(0,ve.dI)((0,ve.xW)([e.type,e.iv,e.sealed]),co)}function bo(e){const t=(e.encoding||co)===lo?yo(e.encoded):e.encoded,n=(0,ve.sH)(t,co),i=n.slice(0,1);if(1===vo(i)){const e=33,t=e+12,s=n.slice(1,e),r=n.slice(e,t);return{type:i,sealed:n.slice(t),iv:r,senderPublicKey:s}}if(2===vo(i)){return{type:i,sealed:n.slice(1),iv:rn(12)}}const s=n.slice(1,13);return{type:i,sealed:n.slice(13),iv:s}}function Eo(e){const t=(null===e||void 0===e?void 0:e.type)||0;if(1===t){if(typeof(null===e||void 0===e?void 0:e.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(null===e||void 0===e?void 0:e.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:t,senderPublicKey:null===e||void 0===e?void 0:e.senderPublicKey,receiverPublicKey:null===e||void 0===e?void 0:e.receiverPublicKey}}function Co(e){return 1===e.type&&"string"==typeof e.senderPublicKey&&"string"==typeof e.receiverPublicKey}function Ao(e){return 2===e.type}function Io(e,t){const[n,i,s]=e.split("."),r=Buffer.from(yo(s),"base64");if(64!==r.length)throw new Error("Invalid signature length");const o=r.slice(0,32),a=r.slice(32,64),c="".concat(n,".").concat(i),l=ms(c),d=function(e){const t=Buffer.from(e.x,"base64"),n=Buffer.from(e.y,"base64");return(0,ve.xW)([new Uint8Array([4]),t,n])}(t);if(!ro.verify((0,ve.xW)([o,a]),l,d))throw new Error("Invalid signature");return(0,P.Cq)(e).payload}function No(e){return(null===e||void 0===e?void 0:e.relay)||{protocol:"irn"}}function So(e){const t=me.CG[e];if(typeof t>"u")throw new Error("Relay Protocol not supported: ".concat(e));return t}var _o=Object.defineProperty,To=Object.defineProperties,Oo=Object.getOwnPropertyDescriptors,ko=Object.getOwnPropertySymbols,Po=Object.prototype.hasOwnProperty,Ro=Object.prototype.propertyIsEnumerable,xo=(e,t,n)=>t in e?_o(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Uo=(e,t)=>{for(var n in t||(t={}))Po.call(t,n)&&xo(e,n,t[n]);if(ko)for(var n of ko(t))Ro.call(t,n)&&xo(e,n,t[n]);return e};function Do(e){const t={},n="relay"+(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-");return Object.keys(e).forEach(i=>{if(i.startsWith(n)){const s=i.replace(n,""),r=e[i];t[s]=r}}),t}function Lo(e){if(!e.includes("wc:")){const t=ot(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(":"),n=-1!==e.indexOf("?")?e.indexOf("?"):void 0,i=e.substring(0,t),s=e.substring(t+1,n).split("@"),r=typeof n<"u"?e.substring(n):"",o=new URLSearchParams(r),a=Object.fromEntries(o.entries()),c="string"==typeof a.methods?a.methods.split(","):void 0;return{protocol:i,topic:Wo(s[0]),version:parseInt(s[1],10),symKey:a.symKey,relay:Do(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function Wo(e){return e.startsWith("//")?e.substring(2):e}function Mo(e){const t=new URLSearchParams,n=Uo(Uo(((e,t)=>To(e,Oo(t)))(Uo({},function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"-";const n={};return Object.keys(e).forEach(i=>{const s=i,r="relay"+t+s;e[s]&&(n[r]=e[s])}),n}(e.relay)),{symKey:e.symKey}),e.expiryTimestamp&&{expiryTimestamp:e.expiryTimestamp.toString()}),e.methods&&{methods:e.methods.join(",")});return Object.entries(n).sort((e,t)=>
2{let[n]=e,[i]=t;return n.localeCompare(i)}).forEach(e=>{let[n,i]=e;void 0!==i&&t.append(n,String(i))}),"".concat(e.protocol,":").concat(e.topic,"@").concat(e.version,"?").concat(t)}function Bo(e,t,n){return"".concat(e,"?wc_ev=").concat(n,"&topic=").concat(t)}var Fo=Object.defineProperty,jo=Object.defineProperties,Ho=Object.getOwnPropertyDescriptors,qo=Object.getOwnPropertySymbols,Vo=Object.prototype.hasOwnProperty,Ko=Object.prototype.propertyIsEnumerable,zo=(e,t,n)=>t in e?Fo(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,$o=(e,t)=>{for(var n in t||(t={}))Vo.call(t,n)&&zo(e,n,t[n]);if(qo)for(var n of qo(t))Ko.call(t,n)&&zo(e,n,t[n]);return e},Go=(e,t)=>jo(e,Ho(t));function Jo(e){const t=[];return e.forEach(e=>{const[n,i]=e.split(":");t.push("".concat(n,":").concat(i))}),t}function Yo(e){return e.includes(":")}function Xo(e){return Yo(e)?e.split(":")[0]:e}function Zo(e){var t,n,i;const s={};if(!ra(e))return s;for(const[r,o]of Object.entries(e)){const e=Yo(r)?[r]:o.chains,a=o.methods||[],c=o.events||[],l=Xo(r);s[l]=Go($o({},s[l]),{chains:tt(e,null==(t=s[l])?void 0:t.chains),methods:tt(a,null==(n=s[l])?void 0:n.methods),events:tt(c,null==(i=s[l])?void 0:i.events)})}return s}function Qo(e,t){const n=function(e){const t={};return null!==e&&void 0!==e&&e.forEach(e=>{var n;const[i,s]=e.split(":");t[i]||(t[i]={accounts:[],chains:[],events:[],methods:[]}),t[i].accounts.push(e),null==(n=t[i].chains)||n.push("".concat(i,":").concat(s))}),t}(t=t.map(e=>e.replace("did:pkh:","")));for(const[i,s]of Object.entries(n))s.methods?s.methods=tt(s.methods,e):s.methods=e,s.events=["chainChanged","accountsChanged"];return n}const ea={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}},ta={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 na(e,t){const{message:n,code:i}=ta[e];return{message:t?"".concat(n," ").concat(t):n,code:i}}function ia(e,t){const{message:n,code:i}=ea[e];return{message:t?"".concat(n," ").concat(t):n,code:i}}function sa(e,t){return!!Array.isArray(e)&&(!(typeof t<"u"&&e.length)||e.every(t))}function ra(e){return Object.getPrototypeOf(e)===Object.prototype&&Object.keys(e).length}function oa(e){return typeof e>"u"}function aa(e,t){return!(!t||!oa(e))||"string"==typeof e&&!!e.trim().length}function ca(e,t){return!(!t||!oa(e))||"number"==typeof e&&!isNaN(e)}function la(e){return!(!aa(e,!1)||!e.includes(":"))&&2===e.split(":").length}function da(e){let t=!0;return sa(e)?e.length&&(t=e.every(e=>aa(e,!1))):t=!1,t}
2function ha(e,t,n){let i=null;return Object.entries(e).forEach(e=>{let[s,r]=e;if(i)return;const o=function(e,t,n){let i=null;return sa(t)&&t.length?t.forEach(e=>{i||la(e)||(i=ia("UNSUPPORTED_CHAINS","".concat(n,", chain ").concat(e,' should be a string and conform to "namespace:chainId" format')))}):la(e)||(i=ia("UNSUPPORTED_CHAINS","".concat(n,', 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}(s,Ee(s,r),"".concat(t," ").concat(n));o&&(i=o)}),i}function ua(e,t){let n=null;return sa(e)?e.forEach(e=>{n||function(e){if(aa(e,!1)&&e.includes(":")){const t=e.split(":");if(3===t.length){const e=t[0]+":"+t[1];return!!t[2]&&la(e)}}return!1}(e)||(n=ia("UNSUPPORTED_ACCOUNTS","".concat(t,", account ").concat(e,' should be a string and conform to "namespace:chainId:address" format')))}):n=ia("UNSUPPORTED_ACCOUNTS","".concat(t,', accounts should be an array of strings conforming to "namespace:chainId:address" format')),n}function pa(e,t){let n=null;return Object.values(e).forEach(e=>{if(n)return;const i=function(e,t){let n=null;return da(null===e||void 0===e?void 0:e.methods)?da(null===e||void 0===e?void 0:e.events)||(n=ia("UNSUPPORTED_EVENTS","".concat(t,", events should be an array of strings or empty array for no events"))):n=ia("UNSUPPORTED_METHODS","".concat(t,", methods should be an array of strings or empty array for no methods")),n}(e,"".concat(t,", namespace"));i&&(n=i)}),n}function fa(e,t){let n=null;if(e&&ra(e)){const i=pa(e,t);i&&(n=i);const s=function(e,t){let n=null;return Object.values(e).forEach(e=>{if(n)return;const i=ua(null===e||void 0===e?void 0:e.accounts,"".concat(t," namespace"));i&&(n=i)}),n}(e,t);s&&(n=s)}else n=na("MISSING_OR_INVALID","".concat(t,", namespaces should be an object with data"));return n}function ga(e){return aa(e.protocol,!0)}function va(e){return typeof e<"u"&&null!==typeof e}function ma(e,t){return!(!la(t)||!function(e){const t=[];return Object.values(e).forEach(e=>{t.push(...Jo(e.accounts))}),t}(e).includes(t))}function ya(e,t,n){return!!aa(n,!1)&&function(e,t){const n=[];return Object.values(e).forEach(e=>{Jo(e.accounts).includes(t)&&n.push(...e.methods)}),n}(e,t).includes(n)}function wa(e,t,n){return!!aa(n,!1)&&function(e,t){const n=[];return Object.values(e).forEach(e=>{Jo(e.accounts).includes(t)&&n.push(...e.events)}),n}(e,t).includes(n)}function ba(e,t,n){let i=null;const s=function(e){const t={};return Object.keys(e).forEach(n=>{var i;n.includes(":")?t[n]=e[n]:null==(i=e[n].chains)||i.forEach(i=>{t[i]={methods:e[n].methods,events:e[n].events}})}),t}(e),r=function(e){const t={};return Object.keys(e).forEach(n=>{if(n.includes(":"))t[n]=e[n];else{const i=Jo(e[n].accounts);null===i||void 0===i||i.forEach(i=>{t[i]={accounts:e[n].accounts.filter(e=>e.includes("".concat(i,":"))),methods:e[n].methods,events:e[n].events}})}}),t}(t),o=Object.keys(s),a=Object.keys(r),c=Ea(Object.keys(e)),l=Ea(Object.keys(t)),d=c.filter(e=>!l.includes(e));return d.length&&(i=na("NON_CONFORMING_NAMESPACES","".concat(n," namespaces keys don't satisfy requiredNamespaces.\n Required: ").concat(d.toString(),"\n Received: ").concat(Object.keys(t).toString()))),Ke(o,a)||(i=na("NON_CONFORMING_NAMESPACES","".concat(n," namespaces chains don't satisfy required namespaces.\n Required: ").concat(o.toString(),"\n Approved: ").concat(a.toString()))),Object.keys(t).forEach(e=>{if(!e.includes(":")||i)return;const s=Jo(t[e].accounts);s.includes(e)||(i=na("NON_CONFORMING_NAMESPACES","".concat(n," namespaces accounts don't satisfy namespace accounts for ").concat(e,"\n Required: ").concat(e,"\n Approved: ").concat(s.toString())))}),o.forEach(e=>{i||(Ke(s[e].methods,r[e].methods)?Ke(s[e].events,r[e].events)||(i=na("NON_CONFORMING_NAMESPACES","".concat(n," namespaces events don't satisfy namespace events for ").concat(e))):i=na("NON_CONFORMING_NAMESPACES","".concat(n," namespaces methods don't satisfy namespace methods for ").concat(e)))}),i}function Ea(e){return[...new Set(e.map(e=>e.includes(":")?e.split(":")[0]:e))]}function Ca(){const e=Be();return new Promise(t=>{switch(e){case xe:t(function(){var e;return Me()&&(null===(e=navigator)||void 0===e?void 0:e.onLine)}());break;case Pe:t(async function(){if(We()&&typeof n.g<"u"&&null!=n.g&&n.g.NetInfo){const e=await(null==n.g?void 0:n.g.NetInfo.fetch());return null===e||void 0===e?void 0:e.isConnected}return!0}());break;default:t(!0)}})}function Aa(e){switch(Be()){case xe:!function(e){!We()&&Me()&&(window.addEventListener("online",()=>e(!0)),window.addEventListener("offline",()=>e(!1)))}(e);break;case Pe:!function(e){var t;We()&&typeof n.g<"u"&&null!=n.g&&n.g.NetInfo&&(null===(t=n.g)||void 0===t||t.NetInfo.addEventListener(t=>e(null===t||void 0===t?void 0:t.isConnected)))}(e)}}const Ia={};class Na{static get(e){return Ia[e]}static set(e,t){Ia[e]=t}static delete(e){delete Ia[e]}}function Sa(e){let{publicKey:t,signature:n,payload:i}=e;var s;const r=_a(i.method),o=128|parseInt((null==(s=i.version)?void 0:s.toString())||"4"),a=function(e){const t=ue.A.decode(e)[0];return 42===t?0:60===t?2:1}(i.address),c="00"===i.era?new Uint8Array([0]):_a(i.era);if(1!==c.length&&2!==c.length)throw new Error("Invalid era length");const l=parseInt(i.nonce,16),d=new Uint8Array([255&l,l>>8&255]),h=BigInt("0x".concat(function(e){return e.startsWith("0x")?e.slice(2):e}(i.tip))),u=function(e){if(e<BigInt(1)<<BigInt(6))return new Uint8Array([Number(e<<BigInt(2))]);if(e<BigInt(1)<<BigInt(14)){const t=e<<BigInt(2)|BigInt(1);return new Uint8Array([Number(t&BigInt(255)),Number(t>>BigInt(8)&BigInt(255))])}if(e<BigInt(1)<<BigInt(30)){const t=e<<BigInt(2)|BigInt(2);return new Uint8Array([Number(t&BigInt(255)),Number(t>>BigInt(8)&BigInt(255)),Number(t>>BigInt(16)&BigInt(255)),Number(t>>BigInt(24)&BigInt(255))])}throw new Error("BigInt compact encoding not supported > 2^30")}(h),p=new Uint8Array([0,...t,a,...n,...c,...d,...u,...r]),f=function(e){if(e<64)return new Uint8Array([e<<2]);if(e<16384){const t=e<<2|1;return new Uint8Array([255&t,t>>8&255])}if(e<1<<30){const t=e<<2|2;return new Uint8Array([255&t,t>>8&255,t>>16&255,t>>24&255])}throw new Error("Compact encoding > 2^30 not supported")}(p.length+1);return new Uint8Array([...f,o,...p])}function _a(e){return new Uint8Array(e.replace(/^0x/,"").match(/.{1,2}/g).map(e=>parseInt(e,16)))}function Ta(e){const t=Uint8Array.from(Buffer.from(e.signature,"hex")),n=function(e){const t=ue.A.decode(e);if(t.length<33)throw new Error("Too short to contain a public key");return t.slice(1,33)}(e.transaction.address),i=Sa({publicKey:n,signature:t,payload:e.transaction});return function(e){const t=_a(e),n=(0,ye.blake2b)(t,void 0,32);return"0x"+Buffer.from(n).toString("hex")}(Buffer.from(i).toString("hex"))}var Oa=n(19168),ka=n(64655),Pa=n(8776);const Ra="core",xa="".concat("wc","@2:").concat(Ra,":"),Ua="error",Da={database:":memory:"},La="client_ed25519_seed",Wa=O.ONE_DAY,Ma=O.SIX_HOURS,Ba="wss://relay.walletconnect.org",Fa="relayer_message",ja="relayer_message_ack",Ha="relayer_connect",qa="relayer_disconnect",Va="relayer_error",Ka="relayer_connection_stalled",za="relayer_publish",$a="payload",Ga="connect",Ja="disconnect",Ya="error",Xa="2.21.9",Za={link_mode:"link_mode",relay:"relay"},Qa="inbound",ec="outbound",tc="WALLETCONNECT_LINK_MODE_APPS",nc="subscription_created",ic="subscription_deleted",sc="subscription_sync",rc="subscription_resubscribed",oc=(O.FIVE_SECONDS,{wc_pairingDelete:{req:{ttl:O.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:O.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:O.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:O.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:O.ONE_DAY,prompt:!1,tag:0},res:{ttl:O.ONE_DAY,prompt:!1,tag:0}}}),ac="pairing_create",cc="pairing_expire",lc="pairing_delete",dc="pairing_ping",hc="history_created",uc="history_updated",pc="history_deleted",fc="history_sync",gc="expirer_created",vc="expirer_deleted",mc="expirer_expired",yc="expirer_sync",wc="https://verify.walletconnect.org",bc=wc,Ec="".concat(bc,"/v3"),Cc=["https://verify.walletconnect.com",wc],Ac="pairing_started",Ic="pairing_uri_validation_success",Nc="pairing_uri_not_expired",Sc="store_new_pairing",_c="subscribing_pairing_topic",Tc="subscribe_pairing_topic_success",Oc="existing_pairing",kc="pairing_not_expired",Pc="emit_inactive_pairing",Rc="emit_session_proposal",xc="no_internet_connection",Uc="malformed_pairing_uri",Dc="active_pairing_already_exists",Lc="subscribe_pairing_topic_failure",Wc="pairing_expired",Mc="proposal_listener_not_found",Bc="session_approve_started",Fc="session_namespaces_validation_success",jc="subscribing_session_topic",Hc="subscribe_session_topic_success",qc="session_approve_publish_success",Vc="store_session",Kc="no_internet_connection",zc="proposal_expired",$c="subscribe_session_topic_failure",Gc="session_approve_namespace_validation_failure",Jc="proposal_not_found",Yc="authenticated_session_approve_started",Xc="create_authenticated_session_topic",Zc="cacaos_verified",Qc="store_authenticated_session",el="subscribing_authenticated_session_topic",tl="subscribe_authenticated_session_topic_success",nl="publishing_authenticated_session_approve",il="no_internet_connection",sl="invalid_cacao",rl="subscribe_authenticated_session_topic_failure",ol="authenticated_session_approve_publish_failure",al="authenticated_session_pending_request_not_found";var cl=function(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),i=0;i<n.length;i++)n[i]=255;for(var s=0;s<e.length;s++){var r=e.charAt(s),o=r.charCodeAt(0);if(255!==n[o])throw new TypeError(r+" is ambiguous");n[o]=s}var a=e.length,c=e.charAt(0),l=Math.log(a)/Math.log(256),d=Math.log(256)/Math.log(a);function h(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,s=0;e[t]===c;)i++,t++;for(var r=(e.length-t)*l+1>>>0,o=new Uint8Array(r);e[t];){var d=n[e.charCodeAt(t)];if(255===d)return;for(var h=0,u=r-1;(0!==d||h<s)&&-1!==u;u--,h++)d+=a*o[u]>>>0,o[u]=d%256>>>0,d=d/256>>>0;if(0!==d)throw new Error("Non-zero carry");s=h,t++}if(" "!==e[t]){for(var p=r-s;p!==r&&0===o[p];)p++;for(var f=new Uint8Array(i+(r-p)),g=i;p!==r;)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 n=0,i=0,s=0,r=t.length;s!==r&&0===t[s];)s++,n++;for(var o=(r-s)*d+1>>>0,l=new Uint8Array(o);s!==r;){for(var h=t[s],u=0,p=o-1;(0!==h||u<i)&&-1!==p;p--,u++)h+=256*l[p]>>>0,l[p]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");i=u,s++}for(var f=o-i;f!==o&&0===l[f];)f++;for(var g=c.repeat(n);f<o;++f)g+=e.charAt(l[f]);return g},decodeUnsafe:h,decode:function(e){var n=h(e);if(n)return n;throw new Error("Non-".concat(t," character"))}}},ll=cl;const dl=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 hl{constructor(e,t,n){this.name=e,this.prefix=t,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return"".concat(this.prefix).concat(this.baseEncode(e));throw Error("Unknown type, must be binary type")}}class ul{constructor(e,t,n){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=n}decode(e){if("string"==typeof e){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error("Unable to decode multibase string ".concat(JSON.stringify(e),", ").concat(this.name," decoder only supports input
2s prefixed with ").concat(this.prefix));return this.baseDecode(e.slice(this.prefix.length))}throw Error("Can only multibase decode strings")}or(e){return fl(this,e)}}class pl{constructor(e){this.decoders=e}or(e){return fl(this,e)}decode(e){const t=e[0],n=this.decoders[t];if(n)return n.decode(e);throw RangeError("Unable to decode multibase string ".concat(JSON.stringify(e),", only inputs prefixed with ").concat(Object.keys(this.decoders)," are supported"))}}const fl=(e,t)=>new pl((0,i.A)((0,i.A)({},e.decoders||{[e.prefix]:e}),t.decoders||{[t.prefix]:t}));class gl{constructor(e,t,n,i){this.name=e,this.prefix=t,this.baseEncode=n,this.baseDecode=i,this.encoder=new hl(e,t,n),this.decoder=new ul(e,t,i)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const vl=e=>{let{name:t,prefix:n,encode:i,decode:s}=e;return new gl(t,n,i,s)},ml=e=>{let{prefix:t,name:n,alphabet:i}=e;const{encode:s,decode:r}=ll(i,n);return vl({prefix:t,name:n,encode:s,decode:e=>dl(r(e))})},yl=e=>{let{name:t,prefix:n,bitsPerChar:i,alphabet:s}=e;return vl({prefix:n,name:t,encode:e=>((e,t,n)=>{const i="="===t[t.length-1],s=(1<<n)-1;let r="",o=0,a=0;for(let c=0;c<e.length;++c)for(a=a<<8|e[c],o+=8;o>n;)o-=n,r+=t[s&a>>o];if(o&&(r+=t[s&a<<n-o]),i)for(;r.length*n&7;)r+="=";return r})(e,s,i),decode:e=>((e,t,n,i)=>{const s={};for(let d=0;d<t.length;++d)s[t[d]]=d;let r=e.length;for(;"="===e[r-1];)--r;const o=new Uint8Array(r*n/8|0);let a=0,c=0,l=0;for(let d=0;d<r;++d){const t=s[e[d]];if(void 0===t)throw new SyntaxError("Non-".concat(i," character"));c=c<<n|t,a+=n,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=n||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o})(e,s,i,t)})},wl=vl({prefix:"\0",name:"identity",encode:e=>(e=>(new TextDecoder).decode(e))(e),decode:e=>(e=>(new TextEncoder).encode(e))(e)});var bl=Object.freeze({__proto__:null,identity:wl});const El=yl({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var Cl=Object.freeze({__proto__:null,base2:El});const Al=yl({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var Il=Object.freeze({__proto__:null,base8:Al});const Nl=ml({prefix:"9",name:"base10",alphabet:"0123456789"});var Sl=Object.freeze({__proto__:null,base10:Nl});const _l=yl({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Tl=yl({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var Ol=Object.freeze({__proto__:null,base16:_l,base16upper:Tl});const kl=yl({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),Pl=yl({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Rl=yl({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),xl=yl({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Ul=yl({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Dl=yl({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),Ll=yl({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Wl=yl({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ml=yl({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var Bl=Object.freeze({__proto__:null,base32:kl,base32upper:Pl,base32pad:Rl,base32padupper:xl,base32hex:Ul,base32hexupper:Dl,base32hexpad:Ll,base32hexpadupper:Wl,base32z:Ml});const Fl=ml({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),jl=ml({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var Hl=Object.freeze({__proto__:null,base36:Fl,base36upper:jl});const ql=ml({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Vl=ml({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var Kl=Object.freeze({__proto__:null,base58btc:ql,base58flickr:Vl});const zl=yl({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
2+/",bitsPerChar:6}),$l=yl({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Gl=yl({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Jl=yl({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var Yl=Object.freeze({__proto__:null,base64:zl,base64pad:$l,base64url:Gl,base64urlpad:Jl});const Xl=Array.from("\ud83d\ude80\ud83e\ude90\u2604\ud83d\udef0\ud83c\udf0c\ud83c\udf11\ud83c\udf12\ud83c\udf13\ud83c\udf14\ud83c\udf15\ud83c\udf16\ud83c\udf17\ud83c\udf18\ud83c\udf0d\ud83c\udf0f\ud83c\udf0e\ud83d\udc09\u2600\ud83d\udcbb\ud83d\udda5\ud83d\udcbe\ud83d\udcbf\ud83d\ude02\u2764\ud83d\ude0d\ud83e\udd23\ud83d\ude0a\ud83d\ude4f\ud83d\udc95\ud83d\ude2d\ud83d\ude18\ud83d\udc4d\ud83d\ude05\ud83d\udc4f\ud83d\ude01\ud83d\udd25\ud83e\udd70\ud83d\udc94\ud83d\udc96\ud83d\udc99\ud83d\ude22\ud83e\udd14\ud83d\ude06\ud83d\ude44\ud83d\udcaa\ud83d\ude09\u263a\ud83d\udc4c\ud83e\udd17\ud83d\udc9c\ud83d\ude14\ud83d\ude0e\ud83d\ude07\ud83c\udf39\ud83e\udd26\ud83c\udf89\ud83d\udc9e\u270c\u2728\ud83e\udd37\ud83d\ude31\ud83d\ude0c\ud83c\udf38\ud83d\ude4c\ud83d\ude0b\ud83d\udc97\ud83d\udc9a\ud83d\ude0f\ud83d\udc9b\ud83d\ude42\ud83d\udc93\ud83e\udd29\ud83d\ude04\ud83d\ude00\ud83d\udda4\ud83d\ude03\ud83d\udcaf\ud83d\ude48\ud83d\udc47\ud83c\udfb6\ud83d\ude12\ud83e\udd2d\u2763\ud83d\ude1c\ud83d\udc8b\ud83d\udc40\ud83d\ude2a\ud83d\ude11\ud83d\udca5\ud83d\ude4b\ud83d\ude1e\ud83d\ude29\ud83d\ude21\ud83e\udd2a\ud83d\udc4a\ud83e\udd73\ud83d\ude25\ud83e\udd24\ud83d\udc49\ud83d\udc83\ud83d\ude33\u270b\ud83d\ude1a\ud83d\ude1d\ud83d\ude34\ud83c\udf1f\ud83d\ude2c\ud83d\ude43\ud83c\udf40\ud83c\udf37\ud83d\ude3b\ud83d\ude13\u2b50\u2705\ud83e\udd7a\ud83c\udf08\ud83d\ude08\ud83e\udd18\ud83d\udca6\u2714\ud83d\ude23\ud83c\udfc3\ud83d\udc90\u2639\ud83c\udf8a\ud83d\udc98\ud83d\ude20\u261d\ud83d\ude15\ud83c\udf3a\ud83c\udf82\ud83c\udf3b\ud83d\ude10\ud83d\udd95\ud83d\udc9d\ud83d\ude4a\ud83d\ude39\ud83d\udde3\ud83d\udcab\ud83d\udc80\ud83d\udc51\ud83c\udfb5\ud83e\udd1e\ud83d\ude1b\ud83d\udd34\ud83d\ude24\ud83c\udf3c\ud83d\ude2b\u26bd\ud83e\udd19\u2615\ud83c\udfc6\ud83e\udd2b\ud83d\udc48\ud83d\ude2e\ud83d\ude46\ud83c\udf7b\ud83c\udf43\ud83d\udc36\ud83d\udc81\ud83d\ude32\ud83c\udf3f\ud83e\udde1\ud83c\udf81\u26a1\ud83c\udf1e\ud83c\udf88\u274c\u270a\ud83d\udc4b\ud83d\ude30\ud83e\udd28\ud83d\ude36\ud83e\udd1d\ud83d\udeb6\ud83d\udcb0\ud83c\udf53\ud83d\udca2\ud83e\udd1f\ud83d\ude41\ud83d\udea8\ud83d\udca8\ud83e\udd2c\u2708\ud83c\udf80\ud83c\udf7a\ud83e\udd13\ud83d\ude19\ud83d\udc9f\ud83c\udf31\ud83d\ude16\ud83d\udc76\ud83e\udd74\u25b6\u27a1\u2753\ud83d\udc8e\ud83d\udcb8\u2b07\ud83d\ude28\ud83c\udf1a\ud83e\udd8b\ud83d\ude37\ud83d\udd7a\u26a0\ud83d\ude45\ud83d\ude1f\ud83d\ude35\ud83d\udc4e\ud83e\udd32\ud83e\udd20\ud83e\udd27\ud83d\udccc\ud83d\udd35\ud83d\udc85\ud83e\uddd0\ud83d\udc3e\ud83c\udf52\ud83d\ude17\ud83e\udd11\ud83c\udf0a\ud83e\udd2f\ud83d\udc37\u260e\ud83d\udca7\ud83d\ude2f\ud83d\udc86\ud83d\udc46\ud83c\udfa4\ud83d\ude47\ud83c\udf51\u2744\ud83c\udf34\ud83d\udca3\ud83d\udc38\ud83d\udc8c\ud83d\udccd\ud83e\udd40\ud83e\udd22\ud83d\udc45\ud83d\udca1\ud83d\udca9\ud83d\udc50\ud83d\udcf8\ud83d\udc7b\ud83e\udd10\ud83e\udd2e\ud83c\udfbc\ud83e\udd75\ud83d\udea9\ud83c\udf4e\ud83c\udf4a\ud83d\udc7c\ud83d\udc8d\ud83d\udce3\ud83e\udd42"),Zl=Xl.reduce((e,t,n)=>(e[n]=t,e),[]),Ql=Xl.reduce((e,t,n)=>(e[t.codePointAt(0)]=n,e),[]);const ed=vl({prefix:"\ud83d\ude80",name:"base256emoji",encode:function(e){return e.reduce((e,t)=>e+=Zl[t],"")},decode:function(e){const t=[];for(const n of e){const e=Ql[n.codePointAt(0)];if(void 0===e)throw new Error("Non-base256emoji character: ".concat(n));t.push(e)}return new Uint8Array(t)}});var td=Object.freeze({__proto__:null,base256emoji:ed}),nd=function e(t,n,i){n=n||[];for(var s=i=i||0;t>=rd;)n[i++]=255&t|id,t/=128;for(;t&sd;)n[i++]=255&t|id,t>>>=7;return n[i]=0|t,e.bytes=i-s+1,n},id=128,sd=-128,rd=Math.pow(2,31);var od=function e(t,n){var i,s=0,r=(n=n||0,0),o=n,a=t.length;do{if(o>=a)throw e.bytes=0,new RangeError("Could not decode varint");i=t[o++],s+=r<28?(i&cd)<<r:(i&cd)*Math.pow(2,r),r+=7}while(i>=ad);return e.bytes=o-n,s},ad=128,cd=127;var ld=Math.pow(2,7),dd=Math.pow(2,14),hd=Math.pow(2,21),ud=Math.pow(2,28),pd=Math.pow(2,35),fd=Math.pow(2,42),gd=Math.pow(2,49),vd=Math.pow(2,56),md=Math.pow(2,63),yd={encode:nd,decode:od,encodingLength:function(e){return e<ld?1:e<dd?2:e<hd?3:e<ud?4:e<pd?5:e<fd?6:e<gd?7:e<vd?8:e<md?9:10}};const wd=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;return yd.encode(e,t,n),t},bd=e=>yd.encodingLength(e),Ed=(e,t)=>
2{const n=t.byteLength,i=bd(e),s=i+bd(n),r=new Uint8Array(s+n);return wd(e,r,0),wd(n,r,i),r.set(t,s),new Cd(e,n,t,r)};class Cd{constructor(e,t,n,i){this.code=e,this.size=t,this.digest=n,this.bytes=i}}const Ad=e=>{let{name:t,code:n,encode:i}=e;return new Id(t,n,i)};class Id{constructor(e,t,n){this.name=e,this.code=t,this.encode=n}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Ed(this.code,t):t.then(e=>Ed(this.code,e))}throw Error("Unknown type, must be binary type")}}const Nd=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),Sd=Ad({name:"sha2-256",code:18,encode:Nd("SHA-256")}),_d=Ad({name:"sha2-512",code:19,encode:Nd("SHA-512")});var Td=Object.freeze({__proto__:null,sha256:Sd,sha512:_d});const Od=dl,kd={code:0,name:"identity",encode:Od,digest:e=>Ed(0,Od(e))};var Pd=Object.freeze({__proto__:null,identity:kd});new TextEncoder,new TextDecoder;const Rd=(0,i.A)((0,i.A)((0,i.A)((0,i.A)((0,i.A)((0,i.A)((0,i.A)((0,i.A)((0,i.A)((0,i.A)({},bl),Cl),Il),Sl),Ol),Bl),Hl),Kl),Yl),td);function xd(e){return null!=globalThis.Buffer?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function Ud(e,t,n,i){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:n},decoder:{decode:i}}}(0,i.A)((0,i.A)({},Td),Pd);const Dd=Ud("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>(new TextEncoder).encode(e.substring(1))),Ld=Ud("ascii","a",e=>{let t="a";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t},e=>{const t=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return null!=globalThis.Buffer&&null!=globalThis.Buffer.allocUnsafe?xd(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}((e=e.substring(1)).length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}),Wd=(0,i.A)({utf8:Dd,"utf-8":Dd,hex:Rd.base16,latin1:Ld,ascii:Ld,binary:Ld},Rd);var Md=Object.defineProperty,Bd=(e,t,n)=>((e,t,n)=>t in e?Md(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class Fd{constructor(e,t){this.core=e,this.logger=t,Bd(this,"keychain",new Map),Bd(this,"name","keychain"),Bd(this,"version","0.3"),Bd(this,"initialized",!1),Bd(this,"storagePrefix",xa),Bd(this,"init",async()=>{if(!this.initialized){const e=await this.getKeyChain();typeof e<"u"&&(this.keychain=e),this.initialized=!0}}),Bd(this,"has",e=>(this.isInitialized(),this.keychain.has(e))),Bd(this,"set",async(e,t)=>{this.isInitialized(),this.keychain.set(e,t),await this.persist()}),Bd(this,"get",e=>{this.isInitialized();const t=this.keychain.get(e);if(typeof t>"u"){const{message:t}=na("NO_MATCHING_KEY","".concat(this.name,": ").concat(e));throw new Error(t)}return t}),Bd(this,"del",async e=>{this.isInitialized(),this.keychain.delete(e),await this.persist()}),this.core=e,this.logger=(0,c.U5)(t,this.name)}get context(){return(0,c.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,ze(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?$e(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=na("NOT_INITIALIZED",this.name);throw new Error(e)}}}var jd=Object.defineProperty,Hd=(e,t,n)=>((e,t,n)=>t in e?jd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class qd{constructor(e,t,n){this.core=e,this.logger=t,Hd(this,"name","crypto"),Hd(this,"keychain"),Hd(this,"randomSessionIdentifier",uo()),Hd(this,"initialized",!1),Hd(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Hd(this,"hasKeys",e=>(this.isInitialized(),this.keychain.has(e))),Hd(this,"getClientId",async()=>{this.isInitialized();const e=await this.getClientSeed(),t=P.TZ(e);return P.UF(t.publicKey)}),Hd(this,"generateKeyPair",()=>{this.isInitialized();const e=function(){const e=Rr.utils.randomPrivateKey(),t=Rr.getPublicKey(e);return{privateKey:(0,ve.dI)(e,ao),publicKey:(0,ve.dI)(t,ao)}}();return this.setPrivateKey(e.publicKey,e.privateKey)}),Hd(this,"signJWT",async e=>{this.isInitialized();const t=await this.getClientSeed(),n=P.TZ(t),i=this.randomSessionIdentifier,s=Wa;return await P.FA(i,e,s,n)}),Hd(this,"generateSharedKey",(e,t,n)=>{this.isInitialized();const i=function(e,t){const n=Rr.getSharedSecret((0,ve.sH)(e,ao),(0,ve.sH)(t,ao)),i=vs(ms,n,void 0,void 0,32);return(0,ve.dI)(i,ao)}(this.getPrivateKey(e),t);return this.setSymKey(i,n)}),Hd(this,"setSymKey",async(e,t)=>{this.isInitialized();const n=t||po(e);return await this.keychain.set(n,e),n}),Hd(this,"deleteKeyPair",async e=>{this.isInitialized(),await this.keychain.del(e)}),Hd(this,"deleteSymKey",async e=>{this.isInitialized(),await this.keychain.del(e)}),Hd(this,"encode",async(e,t,n)=>{this.isInitialized();const i=Eo(n),s=(0,k.h)(t);if(Ao(i))return function(e,t){const n=go(2),i=rn(12),s=wo({type:n,sealed:(0,ve.sH)(e,ho),iv:i});return t===lo?mo(s):s}(s,null===n||void 0===n?void 0:n.encoding);
2if(Co(i)){const t=i.senderPublicKey,n=i.receiverPublicKey;e=await this.generateSharedKey(t,n)}const r=this.getSymKey(e),{type:o,senderPublicKey:a}=i;return function(e){const t=go(typeof e.type<"u"?e.type:0);if(1===vo(t)&&typeof e.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const n=typeof e.senderPublicKey<"u"?(0,ve.sH)(e.senderPublicKey,ao):void 0,i=typeof e.iv<"u"?(0,ve.sH)(e.iv,ao):rn(12),s=(0,ve.sH)(e.symKey,ao),r=wo({type:t,sealed:hs(s,i).encrypt((0,ve.sH)(e.message,ho)),iv:i,senderPublicKey:n});return e.encoding===lo?mo(r):r}({type:o,symKey:r,message:s,senderPublicKey:a,encoding:null===n||void 0===n?void 0:n.encoding})}),Hd(this,"decode",async(e,t,n)=>{this.isInitialized();const i=function(e,t){const n=bo({encoded:e,encoding:null===t||void 0===t?void 0:t.encoding});return Eo({type:vo(n.type),senderPublicKey:typeof n.senderPublicKey<"u"?(0,ve.dI)(n.senderPublicKey,ao):void 0,receiverPublicKey:null===t||void 0===t?void 0:t.receiverPublicKey})}(t,n);if(Ao(i)){const e=function(e,t){const{sealed:n}=bo({encoded:e,encoding:t});return(0,ve.dI)(n,ho)}(t,null===n||void 0===n?void 0:n.encoding);return(0,k.j)(e)}if(Co(i)){const t=i.receiverPublicKey,n=i.senderPublicKey;e=await this.generateSharedKey(t,n)}try{const i=function(e){const t=(0,ve.sH)(e.symKey,ao),{sealed:n,iv:i}=bo({encoded:e.encoded,encoding:e.encoding}),s=hs(t,i).decrypt(n);if(null===s)throw new Error("Failed to decrypt");return(0,ve.dI)(s,ho)}({symKey:this.getSymKey(e),encoded:t,encoding:null===n||void 0===n?void 0:n.encoding});return(0,k.j)(i)}catch(h){this.logger.error("Failed to decode message from topic: '".concat(e,"', clientId: '").concat(await this.getClientId(),"'")),this.logger.error(h)}}),Hd(this,"getPayloadType",function(e){return vo(bo({encoded:e,encoding:arguments.length>1&&void 0!==arguments[1]?arguments[1]:co}).type)}),Hd(this,"getPayloadSenderPublicKey",function(e){const t=bo({encoded:e,encoding:arguments.length>1&&void 0!==arguments[1]?arguments[1]:co});return t.senderPublicKey?(0,ve.dI)(t.senderPublicKey,ao):void 0}),this.core=e,this.logger=(0,c.U5)(t,this.name),this.keychain=n||new Fd(this.core,this.logger)}get context(){return(0,c.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(La)}catch(t){e=uo(),await this.keychain.set(La,e)}return function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"utf8";const n=Wd[t];if(!n)throw new Error('Unsupported encoding "'.concat(t,'"'));return"utf8"!==t&&"utf-8"!==t||null==globalThis.Buffer||null==globalThis.Buffer.from?n.decoder.decode("".concat(n.prefix).concat(e)):xd(globalThis.Buffer.from(e,"utf-8"))}(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=na("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Vd=Object.defineProperty,Kd=Object.defineProperties,zd=Object.getOwnPropertyDescriptors,$d=Object.getOwnPropertySymbols,Gd=Object.prototype.hasOwnProperty,Jd=Object.prototype.propertyIsEnumerable,Yd=(e,t,n)=>t in e?Vd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Xd=(e,t,n)=>Yd(e,"symbol"!=typeof t?t+"":t,n);class Zd extends v{constructor(e,t){super(e,t),this.logger=e,this.core=t,Xd(this,"messages",new Map),Xd(this,"messagesWithoutClientAck",new Map),Xd(this,"name","messages"),Xd(this,"version","0.3"),Xd(this,"initialized",!1),Xd(this,"storagePrefix",xa),Xd(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 ".concat(this.name)),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(S){this.logger.debug("Failed to Restore records for ".concat(this.name)),this.logger.error(S)}finally{this.initialized=!0}}}),Xd(this,"set",async(e,t,n)=>{this.isInitialized();const i=fo(t);let s=this.messages.get(e);if(typeof s>"u"&&(s={}),typeof s[i]<"u")return i;if(s[i]=t,this.messages.set(e,s),n===Qa){const n=this.messagesWithoutClientAck.get(e)||{};this.messagesWithoutClientAck.set(e,((e,t)=>
2Kd(e,zd(t)))(((e,t)=>{for(var n in t||(t={}))Gd.call(t,n)&&Yd(e,n,t[n]);if($d)for(var n of $d(t))Jd.call(t,n)&&Yd(e,n,t[n]);return e})({},n),{[i]:t}))}return await this.persist(),i}),Xd(this,"get",e=>{this.isInitialized();let t=this.messages.get(e);return typeof t>"u"&&(t={}),t}),Xd(this,"getWithoutAck",e=>{this.isInitialized();const t={};for(const n of e){const e=this.messagesWithoutClientAck.get(n)||{};t[n]=Object.values(e)}return t}),Xd(this,"has",(e,t)=>{this.isInitialized();return typeof this.get(e)[fo(t)]<"u"}),Xd(this,"ack",async(e,t)=>{this.isInitialized();const n=this.messagesWithoutClientAck.get(e);if(typeof n>"u")return;delete n[fo(t)],0===Object.keys(n).length?this.messagesWithoutClientAck.delete(e):this.messagesWithoutClientAck.set(e,n),await this.persist()}),Xd(this,"del",async e=>{this.isInitialized(),this.messages.delete(e),this.messagesWithoutClientAck.delete(e),await this.persist()}),this.logger=(0,c.U5)(e,this.name),this.core=t}get context(){return(0,c.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,ze(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,ze(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?$e(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?$e(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=na("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Qd=Object.defineProperty,eh=Object.defineProperties,th=Object.getOwnPropertyDescriptors,nh=Object.getOwnPropertySymbols,ih=Object.prototype.hasOwnProperty,sh=Object.prototype.propertyIsEnumerable,rh=(e,t,n)=>t in e?Qd(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,oh=(e,t)=>{for(var n in t||(t={}))ih.call(t,n)&&rh(e,n,t[n]);if(nh)for(var n of nh(t))sh.call(t,n)&&rh(e,n,t[n]);return e},ah=(e,t)=>eh(e,th(t)),ch=(e,t,n)=>rh(e,"symbol"!=typeof t?t+"":t,n);class lh extends m{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,ch(this,"events",new s.EventEmitter),ch(this,"name","publisher"),ch(this,"queue",new Map),ch(this,"publishTimeout",(0,O.toMiliseconds)(O.ONE_MINUTE)),ch(this,"initialPublishTimeout",(0,O.toMiliseconds)(15*O.ONE_SECOND)),ch(this,"needsTransportRestart",!1),ch(this,"publish",async(e,t,n)=>{var i,s,r,o,a;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:e,message:t,opts:n}});const c=(null===n||void 0===n?void 0:n.ttl)||Ma,l=(null===n||void 0===n?void 0:n.prompt)||!1,d=(null===n||void 0===n?void 0:n.tag)||0,h=(null===n||void 0===n?void 0:n.id)||(0,ka.getBigIntRpcId)().toString(),u=So(No().protocol),p={id:h,method:(null===n||void 0===n?void 0:n.publishMethod)||u.publish,params:oh({topic:e,message:t,ttl:c,prompt:l,tag:d,attestation:null===n||void 0===n?void 0:n.attestation},null===n||void 0===n?void 0:n.tvf)},f="Failed to publish payload, please try again. id:".concat(h," tag:").concat(d);try{oa(null==(i=p.params)?void 0:i.prompt)&&(null==(s=p.params)||delete s.prompt),oa(null==(r=p.params)?void 0:r.tag)&&(null==(o=p.params)||delete o.tag);const a=new Promise(async e=>{const t=n=>{let{id:i}=n;var s;(null==(s=p.id)?void 0:s.toString())===i.toString()&&(this.removeRequestFromQueue(i),this.relayer.events.removeListener(za,t),e())};this.relayer.events.on(za,t);const i=Je(new Promise((e,t)=>{this.rpcPublish(p,n).then(e).catch(e=>{this.logger.warn(e,null===e||void 0===e?void 0:e.message),t(e)})}),this.initialPublishTimeout,"Failed initial publish, retrying.... id:".concat(h," tag:").concat(d));try{await i,this.events.removeListener(za,t)}catch(N){this.queue.set(h,{request:p,opts:n,attempt:1}),this.logger.warn(N,null===N||void 0===N?void 0:N.message)}});this.logger.trace({type:"method",method:"publish",params:{id:h,topic:e,message:t,opts:n}}),await Je(a,this.publishTimeout,f)}catch(g){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(g),null!=(a=null===n||void 0===n?void 0:n.internal)&&a.throwOnFailedPublish)throw g}finally{this.queue.delete(h)}}),ch(this,"publishCustom",async e=>{var t,n,i,s,r;this.logger.debug("Publishing custom payload"),this.logger.trace({type:"method",method:"publishCustom",params:e});const{payload:o,opts:a={}}=e,{attestation:c,tvf:l,publishMethod:d,prompt:h,tag:u,ttl:p=O.FIVE_MINUTES}=a,f=a.id||(0,ka.getBigIntRpcId)().toString(),g=So(No().protocol),v=d||g.publish,m={id:f,method:v,params:oh(ah(oh({},o),{ttl:p,prompt:h,tag:u,attestation:c}),l)},y="Failed to publish custom payload, please try again. id:".concat(f," tag:").concat(u);try{oa(null==(t=m.params)?void 0:t.prompt)&&(null==(n=m.params)||delete n.prompt),oa(null==(i=m.params)?void 0:i.tag)&&(null==(s=m.params)||delete s.tag);const e=new Promise(async e=>{const t=n=>{let{id:i}=n;var s;(null==(s=m.id)?void 0:s.toString())===i.toString()&&(this.removeRequestFromQueue(i),this.relayer.events.removeListener(za,t),e())};this.relayer.events.on(za,t);const n=Je(new Promise((e,t)=>
2{this.rpcPublish(m,a).then(e).catch(e=>{this.logger.warn(e,null===e||void 0===e?void 0:e.message),t(e)})}),this.initialPublishTimeout,"Failed initial custom payload publish, retrying.... method:".concat(v," id:").concat(f," tag:").concat(u));try{await n,this.events.removeListener(za,t)}catch(up){this.queue.set(f,{request:m,opts:a,attempt:1}),this.logger.warn(up,null===up||void 0===up?void 0:up.message)}});this.logger.trace({type:"method",method:"publish",params:{id:f,payload:o,opts:a}}),await Je(e,this.publishTimeout,y)}catch(N){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(N),null!=(r=null===a||void 0===a?void 0:a.internal)&&r.throwOnFailedPublish)throw N}finally{this.queue.delete(f)}}),ch(this,"on",(e,t)=>{this.events.on(e,t)}),ch(this,"once",(e,t)=>{this.events.once(e,t)}),ch(this,"off",(e,t)=>{this.events.off(e,t)}),ch(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.relayer=e,this.logger=(0,c.U5)(t,this.name),this.registerEventListeners()}get context(){return(0,c.oI)(this.logger)}async rpcPublish(e,t){this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:e});const n=await this.relayer.request(e);return this.relayer.events.emit(za,oh(oh({},e),t)),this.logger.debug("Successfully Published Payload"),n}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{var n;const i=e.attempt+1;this.queue.set(t,ah(oh({},e),{attempt:i})),this.logger.warn({},"Publisher: queue->publishing: ".concat(e.request.id,", tag: ").concat(null==(n=e.request.params)?void 0:n.tag,", attempt: ").concat(i)),await this.rpcPublish(e.request,e.opts),this.logger.warn({},"Publisher: queue->published: ".concat(e.request.id))})}registerEventListeners(){this.relayer.core.heartbeat.on(o.li.pulse,()=>{if(this.needsTransportRestart)return this.needsTransportRestart=!1,void this.relayer.events.emit(Ka);this.checkQueue()}),this.relayer.on(ja,e=>{this.removeRequestFromQueue(e.id.toString())})}}var dh=Object.defineProperty,hh=(e,t,n)=>((e,t,n)=>t in e?dh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class uh{constructor(){hh(this,"map",new Map),hh(this,"set",(e,t)=>{const n=this.get(e);this.exists(e,t)||this.map.set(e,[...n,t])}),hh(this,"get",e=>this.map.get(e)||[]),hh(this,"exists",(e,t)=>this.get(e).includes(t)),hh(this,"delete",(e,t)=>{if(typeof t>"u")return void this.map.delete(e);if(!this.map.has(e))return;const n=this.get(e);if(!this.exists(e,t))return;const i=n.filter(e=>e!==t);i.length?this.map.set(e,i):this.map.delete(e)}),hh(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var ph=Object.defineProperty,fh=Object.defineProperties,gh=Object.getOwnPropertyDescriptors,vh=Object.getOwnPropertySymbols,mh=Object.prototype.hasOwnProperty,yh=Object.prototype.propertyIsEnumerable,wh=(e,t,n)=>t in e?ph(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,bh=(e,t)=>{for(var n in t||(t={}))mh.call(t,n)&&wh(e,n,t[n]);if(vh)for(var n of vh(t))yh.call(t,n)&&wh(e,n,t[n]);return e},Eh=(e,t)=>fh(e,gh(t)),Ch=(e,t,n)=>wh(e,"symbol"!=typeof t?t+"":t,n);class Ah extends b{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,Ch(this,"subscriptions",new Map),Ch(this,"topicMap",new uh),Ch(this,"events",new s.EventEmitter),Ch(this,"name","subscription"),Ch(this,"version","0.3"),Ch(this,"pending",new Map),Ch(this,"cached",[]),Ch(this,"initialized",!1),Ch(this,"storagePrefix",xa),Ch(this,"subscribeTimeout",(0,O.toMiliseconds)(O.ONE_MINUTE)),Ch(this,"initialSubscribeTimeout",(0,O.toMiliseconds)(15*O.ONE_SECOND)),Ch(this,"clientId"),Ch(this,"batchSubscribeTopicsLimit",500),Ch(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),Ch(this,"subscribe",async(e,t)=>{var n;this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:e,opts:t}});try{const i=No(t),s={topic:e,relay:i,transportType:null===t||void 0===t?void 0:t.transportType};null!=(n=null===t||void 0===t?void 0:t.internal)&&n.skipSubscribe||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(i){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(i),i}}),Ch(this,"unsubscribe",async(e,t)=>{this.isInitialized(),typeof(null===t||void 0===t?void 0:t.id)<"u"?await this.unsubscribeById(e,t.id,t):await this.unsubscribeByTopic(e,t)}),Ch(this,"isSubscribed",e=>new Promise(t=>{t(this.topicMap.topics.includes(e))})),Ch(this,"isKnownTopic",e=>new Promise(t=>{t(this.topicMap.topics.includes(e)||this.pending.has(e)||this.cached.some(t=>t.topic===e))})),Ch(this,"on",(e,t)=>{this.events.on(e,t)}),Ch(this,"once",(e,t)=>{this.events.once(e,t)}),Ch(this,"off",(e,t)=>{this.events.off(e,t)}),Ch(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),Ch(this,"start",async()=>{await this.onConnect()}),Ch(this,"stop",async()=>{await this.onDisconnect()}),Ch(this,"restart",async()=>
2{await this.restore(),await this.onRestart()}),Ch(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)}),Ch(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(o.li.pulse,async()=>{await this.checkPending()}),this.events.on(nc,async e=>{const t=nc;this.logger.info("Emitting ".concat(t)),this.logger.debug({type:"event",event:t,data:e}),await this.persist()}),this.events.on(ic,async e=>{const t=ic;this.logger.info("Emitting ".concat(t)),this.logger.debug({type:"event",event:t,data:e}),await this.persist()})}),this.relayer=e,this.logger=(0,c.U5)(t,this.name),this.clientId=""}get context(){return(0,c.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 n=!1;try{n=this.getSubscription(e).topic===t}catch(i){}return n}reset(){this.cached=[],this.initialized=!0}onDisable(){this.values.length>0&&(this.cached=this.values),this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const n=this.topicMap.get(e);await Promise.all(n.map(async n=>await this.unsubscribeById(e,n,t)))}async unsubscribeById(e,t,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:n}});try{const i=No(n);await this.restartToComplete({topic:e,id:t,relay:i}),await this.rpcUnsubscribe(e,t,i);const s=ia("USER_DISCONNECTED","".concat(this.name,", ").concat(e));await this.onUnsubscribe(e,t,s),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:n}})}catch(i){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(i),i}}async rpcSubscribe(e,t,n){var i,s;
2const r=await this.getSubscriptionId(e);if(null!=(i=null===n||void 0===n?void 0:n.internal)&&i.skipSubscribe)return r;(!n||(null===n||void 0===n?void 0:n.transportType)===Za.relay)&&await this.restartToComplete({topic:e,id:e,relay:t});const o={method:So(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:o});const a=null==(s=null===n||void 0===n?void 0:n.internal)?void 0:s.throwOnFailedPublish;try{if((null===n||void 0===n?void 0:n.transportType)===Za.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(o).catch(e=>this.logger.warn(e))},(0,O.toMiliseconds)(O.ONE_SECOND)),r;const t=new Promise(async t=>{const n=i=>{i.topic===e&&(this.events.removeListener(nc,n),t(i.id))};this.events.on(nc,n);try{const i=await Je(new Promise((e,t)=>{this.relayer.request(o).catch(e=>{this.logger.warn(e,null===e||void 0===e?void 0:e.message),t(e)}).then(e)}),this.initialSubscribeTimeout,"Subscribing to ".concat(e," failed, please try again"));this.events.removeListener(nc,n),t(i)}catch(i){}}),i=await Je(t,this.subscribeTimeout,"Subscribing to ".concat(e," failed, please try again"));if(!i&&a)throw new Error("Subscribing to ".concat(e," failed, please try again"));return i?r:null}catch(u){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ka),a)throw u}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t={method:So(e[0].relay.protocol).batchSubscribe,params:{topics:e.map(e=>e.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});try{await await Je(new Promise(e=>{this.relayer.request(t).catch(e=>this.logger.warn(e)).then(e)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch(n){this.relayer.events.emit(Ka)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t={method:So(e[0].relay.protocol).batchFetchMessages,params:{topics:e.map(e=>e.topic)}};let n;this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:t});try{n=await await Je(new Promise((e,n)=>{this.relayer.request(t).catch(e=>{this.logger.warn(e),n(e)}).then(e)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch(i){this.relayer.events.emit(Ka)}return n}rpcUnsubscribe(e,t,n){const i={method:So(n.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,Eh(bh({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(e=>{this.setSubscription(e.id,bh({},e)),this.pending.delete(e.topic)})}async onUnsubscribe(e,t,n){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,n),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,bh({},t)),this.topicMap.set(t.topic,e),this.events.emit(nc,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}=na("NO_MATCHING_KEY","".concat(this.name,": ").concat(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 n=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(n.topic,e),this.events.emit(ic,Eh(bh({},n),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(sc)}
2async onRestart(){if(this.cached.length){const e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let n=0;n<t;n++){const t=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(t)}}this.events.emit(rc)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size&&!e.every(e=>{var t;return e.topic===(null==(t=this.subscriptions.get(e.id))?void 0:t.topic)})){const{message:e}=na("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),this.logger.error("".concat(this.name,": ").concat(JSON.stringify(this.values))),new Error(e)}this.cached=e,this.logger.debug("Successfully Restored subscriptions for ".concat(this.name)),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(An){this.logger.debug("Failed to Restore subscriptions for ".concat(this.name)),this.logger.error(An)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async e=>Eh(bh({}
2,e),{id:await this.getSubscriptionId(e.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace("Fetching batch messages for ".concat(e.length," subscriptions"));const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await function(e){return new Promise(t=>setTimeout(t,e))}((0,O.toMiliseconds)(O.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}=na("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 fo(e+await this.getClientId())}}var Ih=Object.defineProperty,Nh=Object.getOwnPropertySymbols,Sh=Object.prototype.hasOwnProperty,_h=Object.prototype.propertyIsEnumerable,Th=(e,t,n)=>t in e?Ih(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Oh=(e,t)=>{for(var n in t||(t={}))Sh.call(t,n)&&Th(e,n,t[n]);if(Nh)for(var n of Nh(t))_h.call(t,n)&&Th(e,n,t[n]);return e},kh=(e,t,n)=>Th(e,"symbol"!=typeof t?t+"":t,n);class Ph extends y{constructor(e){super(e),kh(this,"protocol","wc"),kh(this,"version",2),kh(this,"core"),kh(this,"logger"),kh(this,"events",new s.EventEmitter),kh(this,"provider"),kh(this,"messages"),kh(this,"subscriber"),kh(this,"publisher"),kh(this,"name","relayer"),kh(this,"transportExplicitlyClosed",!1),kh(this,"initialized",!1),kh(this,"connectionAttemptInProgress",!1),kh(this,"relayUrl"),kh(this,"projectId"),kh(this,"packageName"),kh(this,"bundleId"),kh(this,"hasExperiencedNetworkDisruption",!1),kh(this,"pingTimeout"),kh(this,"heartBeatTimeout",(0,O.toMiliseconds)(O.THIRTY_SECONDS+O.FIVE_SECONDS)),kh(this,"reconnectTimeout"),kh(this,"connectPromise"),kh(this,"reconnectInProgress",!1),kh(this,"requestsInFlight",[]),kh(this,"connectTimeout",(0,O.toMiliseconds)(15*O.ONE_SECOND)),kh(this,"request",async e=>{var t,n;this.logger.debug("Publishing Request Payload");const i=e.id||(0,ka.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 s="".concat(i,":").concat((null==(n=e.params)?void 0:n.tag)||"");this.requestsInFlight.push(s);const r=await this.provider.request(e);return this.requestsInFlight=this.requestsInFlight.filter(e=>e!==s),r}catch(s){throw this.logger.debug("Failed to Publish Request: ".concat(i)),s}}),kh(this,"resetPingTimeout",()=>{Le()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var e,t,n,i;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),null==(i=null==(n=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:n.terminate)||i.call(n)}catch(s){this.logger.warn(s,null===s||void 0===s?void 0:s.message)}},this.heartBeatTimeout))}),kh(this,"onPayloadHandler",e=>{this.onProviderPayload(e),this.resetPingTimeout()}),kh(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected \ud83d\udedc"),this.startPingTimeout(),this.events.emit(Ha)}),kh(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected \ud83d\uded1"),this.requestsInFlight=[],this.onProviderDisconnect()}),kh(this,"onProviderErrorHandler",e=>{this.logger.fatal("Fatal socket error: ".concat(e.message)),this.events.emit(Va,e),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),kh(this,"registerProviderListeners",()=>{this.provider.on($a,this.onPayloadHandler),this.provider.on(Ga,this.onConnectHandler),this.provider.on(Ja,this.onDisconnectHandler),this.provider.on(Ya,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&"string"!=typeof e.logger?(0,c.U5)(e.logger,this.name):(0,c.h6)((0,c.iP)({level:e.logger||"error"})),this.messages=new Zd(this.logger,e.core),this.subscriber=new Ah(this,this.logger),this.publisher=new lh(this,this.logger),this.projectId=null===e||void 0===e?void 0:e.projectId,this.relayUrl=(null===e||void 0===e?void 0:e.relayUrl)||Ba,We()&&typeof n.g<"u"&&typeof(null==n.g?void 0:n.g.Platform)<"u"&&"android"===(null==n.g?void 0:n.g.Platform.OS)?this.packageName=Fe():We()&&typeof n.g<"u"&&typeof(null==n.g?void 0:n.g.Platform)<"u"&&"ios"===(null==n.g?void 0:n.g.Platform.OS)&&(this.bundleId=Fe()),this.provider={}}
2async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.transportOpen().catch(e=>this.logger.warn(e,null===e||void 0===e?void 0:e.message))}get context(){return(0,c.oI)(this.logger)}get connected(){var e,t,n;return 1===(null==(n=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:n.readyState)||!1}get connecting(){var e,t,n;return 0===(null==(n=null==(t=null==(e=this.provider)?void 0:e.connection)?void 0:t.socket)?void 0:n.readyState)||void 0!==this.connectPromise||!1}async publish(e,t,n){this.isInitialized(),await this.publisher.publish(e,t,n),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:Za.relay},ec)}async publishCustom(e){this.isInitialized(),await this.publisher.publishCustom(e)}async subscribe(e,t){var n,i,s;this.isInitialized(),(null==t||!t.transportType||"relay"===(null===t||void 0===t?void 0:t.transportType))&&await this.toEstablishConnection();const r=typeof(null==(n=null===t||void 0===t?void 0:t.internal)?void 0:n.throwOnFailedPublish)>"u"||(null==(i=null===t||void 0===t?void 0:t.internal)?void 0:i.throwOnFailedPublish);let o,a=(null==(s=this.subscriber.topicMap.get(e))?void 0:s[0])||"";const c=t=>{t.topic===e&&(this.subscriber.off(nc,c),o())};return await Promise.all([new Promise(e=>{o=e,this.subscriber.on(nc,c)}),new Promise(async(n,i)=>{a=await this.subscriber.subscribe(e,Oh({internal:{throwOnFailedPublish:r}},t)).catch(e=>{r&&i(e)})||a,n()})]),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 Je(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,n)=>{await this.connect(e).then(t).catch(n).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error("Couldn't establish socket connection to the relay server: ".concat(this.relayUrl))}else this.logger.info("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 Ca())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(0===(null===e||void 0===e?void 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 ".concat(t.length," message events sorted"));for(const i of t)try{await this.onMessageEvent(i)}catch(n){this.logger.warn(n,"Error while processing batch message event: "+(null===n||void 0===n?void 0:n.message))}this.logger.trace("Batch of ".concat(t.length," message events processed"))}async onLinkMessageEvent(e,t){const{topic:n}=e;if(!t.sessionExists){const e={topic:n,expiry:Ze(O.FIVE_MINUTES),relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(n,e)}this.events.emit(Fa,e),await this.recordMessageEvent(e,Qa)}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 ".concat(this.relayUrl,", attempt: ").concat(t,"...")),await this.createProvider(),await new Promise(async(e,t)=>{const n=()=>
2{t(new Error("Connection interrupted while trying to connect"))};this.provider.once(Ja,n),await Je(new Promise((e,t)=>{this.provider.connect().then(e).catch(t)}),this.connectTimeout,"Socket stalled when trying to connect to ".concat(this.relayUrl)).catch(e=>{t(e)}).finally(()=>{this.provider.off(Ja,n),clearTimeout(this.reconnectTimeout)}),await new Promise(async(e,n)=>{const i=()=>{t(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Ja,i),await this.subscriber.start().then(e).catch(n).finally(()=>{this.provider.off(Ja,i)})}),this.hasExperiencedNetworkDisruption=!1,e()})}catch(S){await this.subscriber.stop();const t=S;this.logger.warn({},t.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},"Connected to ".concat(this.relayUrl," successfully on attempt: ").concat(t));break}await new Promise(e=>setTimeout(e,(0,O.toMiliseconds)(1*t))),t++}}startPingTimeout(){var e,t,n,i,s;if(Le())try{null!=(t=null==(e=this.provider)?void 0:e.connection)&&t.socket&&(null==(s=null==(i=null==(n=this.provider)?void 0:n.connection)?void 0:i.socket)||s.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(r){this.logger.warn(r,null===r||void 0===r?void 0:r.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Oa.F(new Pa.A(Ve({sdkVersion:Xa,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:n,message:i}=e;await this.messages.set(n,i,t)}async shouldIgnoreMessageEvent(e){const{topic:t,message:n}=e;if(!n||0===n.length)return this.logger.warn("Ignoring invalid/empty message: ".concat(n)),!0;if(!await this.subscriber.isKnownTopic(t))return this.logger.warn("Ignoring message for unknown topic ".concat(t)),!0;const i=this.messages.has(t,n);return i&&this.logger.warn("Ignoring duplicate message: ".concat(n)),i}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),(0,ka.isJsonRpcRequest)(e)){if(!e.method.endsWith("_subscription"))return;const t=e.params,{topic:n,message:i,publishedAt:s,attestation:r}=t.data,o={topic:n,message:i,publishedAt:s,transportType:Za.relay,attestation:r};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Oh({type:"event",event:t.id},o)),this.events.emit(t.id,o),await this.acknowledgePayload(e),await this.onMessageEvent(o)}else(0,ka.isJsonRpcResponse)(e)&&this.events.emit(ja,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,Qa),this.events.emit(Fa,e))}async acknowledgePayload(e){const t=(0,ka.formatJsonRpcResult)(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off($a,this.onPayloadHandler),this.provider.off(Ga,this.onConnectHandler),this.provider.off(Ja,this.onDisconnectHandler),this.provider.off(Ya,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Ca();Aa(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(e=>this.logger.error(e,null===e||void 0===e?void 0:e.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))}),this.core.heartbeat.on(o.li.pulse,async()=>{if(!this.transportExplicitlyClosed&&!this.connected&&function(){var e;return!Me()||!(0,x.getDocument)()||"visible"===(null==(e=(0,x.getDocument)())?void 0:e.visibilityState)}())try{await this.confirmOnlineStateOrThrow(),await this.transportOpen()}catch(Cn){this.logger.warn(Cn,null===Cn||void 0===Cn?void 0:Cn.message)}})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(qa),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,null===e||void 0===e?void 0:e.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},(0,O.toMiliseconds)(.1)))))}isInitialized(){if(!this.initialized){const{message:e}=na("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectPromise)return void await this.connectPromise;await this.connect()}}}function Rh(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}
2function xh(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Uh="[object Arguments]",Dh="[object Object]";function Lh(){}function Wh(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 Mh(e,t,n,i,s,r,o){const a=o(e,t,n,i,s,r);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 Bh(e,t,r,o)}return Bh(e,t,r,o)}function Bh(e,t,n,i){if(Object.is(e,t))return!0;let s=xh(e),r=xh(t);if(s===Uh&&(s=Dh),r===Uh&&(r=Dh),s!==r)return!1;switch(s){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=(n=null!==n&&void 0!==n?n:new Map).get(e),a=n.get(t);if(null!=o&&null!=a)return o===t;n.set(e,t),n.set(t,e);try{switch(s){case"[object Map]":if(e.size!==t.size)return!1;for(const[s,r]of e.entries())if(!t.has(s)||!Mh(r,t.get(s),s,e,t,n,i))return!1;return!0;case"[object Set]":{if(e.size!==t.size)return!1;const s=Array.from(e.values()),r=Array.from(t.values());for(let o=0;o<s.length;o++){const a=s[o],c=r.findIndex(s=>Mh(a,s,void 0,e,t,n,i));if(-1===c)return!1;r.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 Buffer<"u"&&Buffer.isBuffer(e)!==Buffer.isBuffer(t)||e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(!Mh(e[s],t[s],s,e,t,n,i))return!1;return!0;case"[object ArrayBuffer]":return e.byteLength===t.byteLength&&Bh(new Uint8Array(e),new Uint8Array(t),n,i);case"[object DataView]":return e.byteLength===t.byteLength&&e.byteOffset===t.byteOffset&&Bh(new Uint8Array(e),new Uint8Array(t),n,i);case"[object Error]":return e.name===t.name&&e.message===t.message;case Dh:{if(!(Bh(e.constructor,t.constructor,n,i)||Wh(e)&&Wh(t)))return!1;const s=[...Object.keys(e),...Rh(e)],r=[...Object.keys(t),...Rh(t)];if(s.length!==r.length)return!1;for(let o=0;o<s.length;o++){const r=s[o],a=e[r];if(!Object.hasOwn(t,r))return!1;if(!Mh(a,t[r],r,e,t,n,i))return!1}return!0}default:return!1}}finally{n.delete(e),n.delete(t)}}function Fh(e,t){return function(e,t,n){return Mh(e,t,void 0,void 0,void 0,void 0,n)}(e,t,Lh)}var jh=Object.defineProperty,Hh=Object.getOwnPropertySymbols,qh=Object.prototype.hasOwnProperty,Vh=Object.prototype.propertyIsEnumerable,Kh=(e,t,n)=>t in e?jh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,zh=(e,t)=>{for(var n in t||(t={}))qh.call(t,n)&&Kh(e,n,t[n]);if(Hh)for(var n of Hh(t))Vh.call(t,n)&&Kh(e,n,t[n]);return e},$h=(e,t,n)=>Kh(e,"symbol"!=typeof t?t+"":t,n);class Gh extends w{constructor(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:xa,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0;super(e,t,n,i),this.core=e,this.logger=t,this.name=n,$h(this,"map",new Map),$h(this,"version","0.3"),$h(this,"cached",[]),$h(this,"initialized",!1),$h(this,"getKey"),$h(this,"storagePrefix",xa),$h(this,"recentlyDeleted",[]),$h(this,"recentlyDeletedLimit",200),$h(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(e=>{this.getKey&&null!==e&&!oa(e)?this.map.set(this.getKey(e),e):function(e){var t;return null==(t=null===e||void 0===e?void 0:e.proposer)?void 0:t.publicKey}(e)?this.map.set(e.id,e):function(e){return null===e||void 0===e?void 0:e.topic}(e)&&this.map.set(e.topic,e)}),this.cached=[],this.initialized=!0)}),$h(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())}),$h(this,"get",e=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:e}),this.getData(e))),$h(this,"getAll",e=>(this.isInitialized(),e?this.values.filter(t=>Object.keys(e).every(n=>Fh(t[n],e[n]))):this.values)),$h(this,"update",async(e,t)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:e,update:t});const n=zh(zh({},this.getData(e)),t);this.map.set(e,n),await this.persist()}),$h(this,"delete",async(e,t)=>{this.isInitialized(),this.map.has(e)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",ke
2y:e,reason:t}),this.map.delete(e),this.addToRecentlyDeleted(e),await this.persist())}),this.logger=(0,c.U5)(t,this.name),this.storagePrefix=i,this.getKey=s}get context(){return(0,c.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}=na("MISSING_OR_INVALID","Record was recently deleted - ".concat(this.name,": ").concat(e));throw this.logger.error(t),new Error(t)}const{message:t}=na("NO_MATCHING_KEY","".concat(this.name,": ").concat(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}=na("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug("Successfully Restored value for ".concat(this.name)),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(An){this.logger.debug("Failed to Restore value for ".concat(this.name)),this.logger.error(An)}}isInitialized(){if(!this.initialized){const{message:e}=na("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Jh=Object.defineProperty,Yh=(e,t,n)=>((e,t,n)=>t in e?Jh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class Xh{constructor(e,t){this.core=e,this.logger=t,Yh(this,"name","pairing"),Yh(this,"version","0.3"),Yh(this,"events",new(r())),Yh(this,"pairings"),Yh(this,"initialized",!1),Yh(this,"storagePrefix",xa),Yh(this,"ignoredPayloadTypes",[1]),Yh(this,"registeredMethods",[]),Yh(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),Yh(this,"register",e=>{let{methods:t}=e;this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...t])]}),Yh(this,"create",async e=>{this.isInitialized();const t=uo(),n=await this.core.crypto.setSymKey(t),i=Ze(O.FIVE_MINUTES),s={protocol:"irn"},r={topic:n,expiry:i,relay:s,active:!1,methods:null===e||void 0===e?void 0:e.methods},o=Mo({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:t,relay:s,expiryTimestamp:i,methods:null===e||void 0===e?void 0:e.methods});return this.events.emit(ac,r),this.core.expirer.set(n,i),await this.pairings.set(n,r),await this.core.relayer.subscribe(n,{transportType:null===e||void 0===e?void 0:e.transportType,internal:null===e||void 0===e?void 0:e.internal}),{topic:n,uri:o}}),Yh(this,"pair",async e=>{this.isInitialized();const t=this.core.eventClient.createEvent({properties:{topic:null===e||void 0===e?void 0:e.uri,trace:[Ac]}});this.isValidPair(e,t);const{topic:n,symKey:i,relay:s,expiryTimestamp:r,methods:o}=Lo(e.uri);let a;if(t.props.properties.topic=n,t.addTrace(Ic),t.addTrace(Nc),this.pairings.keys.includes(n)){if(a=this.pairings.get(n),t.addTrace(Oc),a.active)throw t.setError(Dc),new Error("Pairing already exists: ".concat(n,". Please try again with a new connection URI."));t.addTrace(kc)}const c=r||Ze(O.FIVE_MINUTES),l={topic:n,relay:s,expiry:c,active:!1,methods:o};this.core.expirer.set(n,c),await this.pairings.set(n,l),t.addTrace(Sc),e.activatePairing&&await this.activate({topic:n}),this.events.emit(ac,l),t.addTrace(Pc),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(i,n),t.addTrace(_c);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch(d){t.setError(xc)}try{await this.core.relayer.subscribe(n,{relay:s})}catch(h){throw t.setError(Lc),h}return t.addTrace(Tc),l}),Yh(this,"activate",async e=>{let{topic:t}=e;this.isInitialized();const n=Ze(O.FIVE_MINUTES);this.core.expirer.set(t,n),await this.pairings.update(t,{active:!0,expiry:n})}),Yh(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:n,resolve:i,reject:s}=Ge();this.events.once(et("pairing_ping",e),e=>{let{error:t}=e;t?s(t):i()}),await n()}}),Yh(this,"updateExpiry",async e=>{let{topic:t,expiry:n}=e;this.isInitialized(),await this.pairings.update(t,{expiry:n})}),Yh(this,"updateMetadata",async e=>{let{topic:t,metadata:n}=e;this.isInitialized(),await this.pairings.update(t,{peerMetadata:n})}),Yh(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),Yh(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",ia("USER_DISCONNECTED")),await this.deletePairing(t))}),Yh(this,"formatUriFromPairing",e=>{this.isInitialized();const{topic:t,relay:n,expiry:i,methods:s}=e,r=this.core.crypto.keychain.get(t);return Mo({protocol:this.core.protocol,version:this.core.version,topic:t,symKey:r,relay:n,expiryTimestamp:i,methods:s})}),Yh(this,"sendRequest",async(e,t,n)=>{const i=(0,ka.formatJsonRpcRequest)(t,n),s=await this.core.crypto.encode(e,i),r=oc[t].req;return this.core.history.set(e,i),this.core.relayer.publish(e,s,r),i.id}),Yh(this,"sendResult",async(e,t,n)=>{const i=(0,ka.formatJsonRpcResult)(e,n),s=await this.core.crypto.encode(t,i),r=(await this.core.history.get(t,e)).request.method,o=oc[r].res;await this.core.relayer.publish(t,s,o),await this.core.history.resolve(i)}),Yh(this,"sendError",async(e,t,n)=>{const i=(0,ka.formatJsonRpcError)(e,n),s=await this.core.crypto.encode(t,i),r=(await this.core.history.get(t,e)).request.method,o=oc[r]?oc[r].res:oc.unregistered_method.res;await this.core.relayer.publish(t,s,o),await this.core.history.resolve(i)}),Yh(this,"deletePairing",async(e,t)=>{await this.core.relayer.unsubscribe(e),await Promise.all([this.pairings.delete(e,ia("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(e),t?Promise.resolve():this.core.expirer.del(e)])}),Yh(this,"cleanup",async()=>{const e=this.pairings.getAll().filter(e=>Qe(e.expiry));await Promise.all(e.map(e=>this.deletePairing(e.topic)))}),Yh(this,"onRelayEventRequest",async e=>{const{topic:t,payload:n}=e;switch(n.method){case"wc_pairingPing":return await this.onPairingPingRequest(t,n);case"wc_pairingDelete":return await this.onPairingDeleteRequest(t,n);default:return await this.onUnknownRpcMethodRequest(t,n)}}),Yh(this,"onRelayEventResponse",async e=>{const{topic:t,payload:n}=e,i=(await this.core.history.get(t,n.id)).request.method;return"wc_pairingPing"===i?this.onPairingPingResponse(t,n):this.onUnknownRpcMethodResponse(i)}),Yh(this,"onPairingPingRequest",async(e,t)=>{const{id:n}=t;try{this.isValidPing({topic:e}),await this.sendResult(n,e,!0),this.events.emit(dc,{id:n,topic:e})}catch(i){await this.sendError(n,e,i),this.logger.error(i)}}),Yh(this,"onPairingPingResponse",(e,t)=>{const{id:n}=t;setTimeout(()=>{(0,ka.isJsonRpcResult)(t)?this.events.emit(et("pairing_ping",n),{}):(0,ka.isJsonRpcError)(t)&&this.events.emit(et("pairing_ping",n),{error:t.error})},500)}),Yh(this,"onPairingDeleteRequest",async(e,t)=>{const{id:n}=t;try{this.isValidDisconnect({topic:e}),await this.deletePairing(e),this.events.emit(lc,{id:n,topic:e})}catch(i){await this.sendError(n,e,i),this.logger.error(i)}}),Yh(this,"onUnknownRpcMethodRequest",async(e,t)=>{const{id:n,method:i}=t;try{if(this.registeredMethods.includes(i))return;const t=ia("WC_METHOD_UNSUPPORTED",i);await this.sendError(n,e,t),this.logger.error(t)}catch(d){await this.sendError(n,e,d),this.logger.error(d)}}),Yh(this,"onUnknownRpcMethodResponse",e=>{this.registeredMethods.includes(e)||this.logger.error(ia("WC_METHOD_UNSUPPORTED",e))}),Yh(this,"isValidPair",(e,t)=>{var n;if(!va(e)){const{message:n}=na("MISSING_OR_INVALID","pair() params: ".concat(e));throw t.setError(Uc),new Error(n)}if(!function(e){function t(e){try{return typeof new URL(e)<"u"}catch(t){return!1}}try{if(aa(e,!1))return!!t(e)||t(ot(e))}catch(n){}return!1}(e.uri)){const{message:n}=na("MISSING_OR_INVALID","pair() uri: ".concat(e.uri));throw t.setError(Uc),new Error(n)}const i=Lo(null===e||void 0===e?void 0:e.uri);if(null==(n=null===i||void 0===i?void 0:i.relay)||!n.protocol){const{message:e}=na("MISSING_OR_INVALID","pair() uri#relay-protocol");throw t.setError(Uc),new Error(e)}if(null==i||!i.symKey){const{message:e}=na("MISSING_OR_INVALID","pair() uri#symKey");throw t.setError(Uc),new Error(e)}if(null!=i&&i.expiryTimestamp&&(0,O.toMiliseconds)(null===i||void 0===i?void 0:i.expiryTimestamp)<Date.now()){t.setError(Wc);const{message:e}=na("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(e)}}),Yh(this,"isValidPing",async e=>{if(!va(e)){const{message:t}=na("MISSING_OR_INVALID","ping() params: ".concat(e));throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)}),Yh(this,"isValidDisconnect",async e=>{if(!va(e)){const{message:t}=na("MISSING_OR_INVALID","disconnect() params: ".concat(e));throw new Error(t)}const{topic:t}=e;await this.isValidPairingTopic(t)}),Yh(this,"isValidPairingTopic",async e=>{if(!aa(e,!1)){const{message:t}=na("MISSING_OR_INVALID","pairing topic should be a string: ".concat(e));throw new Error(t)}if(!this.pairings.keys.includes(e)){const{message:t}=na("NO_MATCHING_KEY","pairing topic doesn't exist: ".concat(e));throw new Error(t)}if(Qe(this.pairings.get(e).expiry)){await this.deletePairing(e);const{message:t}=na("EXPIRED","pairing topic: ".concat(e));throw new Error(t)}}),this.core=e,this.logger=(0,c.U5)(t,this.name),this.pairings=new Gh(this.core,this.logger,this.name,this.storagePrefix)}get context(){return(0,c.oI)(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=na("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Fa,async e=>{const{topic:t,message:n,transportType:i}=e;if(this.pairings.keys.includes(t)&&i!==Za.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))try{const e=await this.core.crypto.decode(t,n);(0,ka.isJsonRpcRequest)(e)?(this.core.history.set(t,e),await this.onRelayEventRequest({topic:t,payload:e})):(0,ka.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,n)}catch(In){this.logger.error(In)}})}registerExpirerEvents(){this.core.expirer.on(mc,async e=>{const{topic:t}=Xe(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(cc,{topic:t}))})}}var Zh=Object.defineProperty,Qh=(e,t,n)=>((e,t,n)=>t in e?Zh(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class eu extends g{constructor(e,t){super(e,t),this.core=e,this.logger=t,Qh(this,"records",new Map),Qh(this,"events",new s.EventEmitter),Qh(this,"name","history"),Qh(this,"version","0.3"),Q
2h(this,"cached",[]),Qh(this,"initialized",!1),Qh(this,"storagePrefix",xa),Qh(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)}),Qh(this,"set",(e,t,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:e,request:t,chainId:n}),this.records.has(t.id))return;const i={id:t.id,topic:e,request:{method:t.method,params:t.params||null},chainId:n,expiry:Ze(O.THIRTY_DAYS)};this.records.set(i.id,i),this.persist(),this.events.emit(hc,i)}),Qh(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,ka.isJsonRpcError)(e)?{error:e.error}:{result:e.result},this.records.set(t.id,t),this.persist(),this.events.emit(uc,t))}),Qh(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))),Qh(this,"delete",(e,t)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:t}),this.values.forEach(n=>{if(n.topic===e){if(typeof t<"u"&&n.id!==t)return;this.records.delete(n.id),this.events.emit(pc,n)}}),this.persist()}),Qh(this,"exists",async(e,t)=>(this.isInitialized(),!!this.records.has(t)&&(await this.getRecord(t)).topic===e)),Qh(this,"on",(e,t)=>{this.events.on(e,t)}),Qh(this,"once",(e,t)=>{this.events.once(e,t)}),Qh(this,"off",(e,t)=>{this.events.off(e,t)}),Qh(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,c.U5)(t,this.name)}get context(){return(0,c.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 n={topic:t.topic,request:(0,ka.formatJsonRpcRequest)(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(n)}),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}=na("NO_MATCHING_KEY","".concat(this.name,": ").concat(e));throw new Error(t)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(fc)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:e}=na("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug("Successfully Restored records for ".concat(this.name)),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(An){this.logger.debug("Failed to Restore records for ".concat(this.name)),this.logger.error(An)}}registerEventListeners(){this.events.on(hc,e=>{const t=hc;this.logger.info("Emitting ".concat(t)),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(uc,e=>{const t=uc;this.logger.info("Emitting ".concat(t)),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(pc,e=>{const t=pc;this.logger.info("Emitting ".concat(t)),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(o.li.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{(0,O.toMiliseconds)(t.expiry||0)-Date.now()<=0&&(this.logger.info("Deleting expired history log: ".concat(t.id)),this.records.delete(t.id),this.events.emit(pc,t,!1),e=!0)}),e&&this.persist()}catch(An){this.logger.warn(An)}}isInitialized(){if(!this.initialized){const{message:e}=na("NOT_INITIALIZED",this.name);throw new Error(e)}}}var tu=Object.defineProperty,nu=(e,t,n)=>((e,t,n)=>t in e?tu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);
2class iu extends E{constructor(e,t){super(e,t),this.core=e,this.logger=t,nu(this,"expirations",new Map),nu(this,"events",new s.EventEmitter),nu(this,"name","expirer"),nu(this,"version","0.3"),nu(this,"cached",[]),nu(this,"initialized",!1),nu(this,"storagePrefix",xa),nu(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)}),nu(this,"has",e=>{try{const t=this.formatTarget(e);return typeof this.getExpiration(t)<"u"}catch(t){return!1}}),nu(this,"set",(e,t)=>{this.isInitialized();const n=this.formatTarget(e),i={target:n,expiry:t};this.expirations.set(n,i),this.checkExpiry(n,i),this.events.emit(gc,{target:n,expiration:i})}),nu(this,"get",e=>{this.isInitialized();const t=this.formatTarget(e);return this.getExpiration(t)}),nu(this,"del",e=>{if(this.isInitialized(),this.has(e)){const t=this.formatTarget(e),n=this.getExpiration(t);this.expirations.delete(t),this.events.emit(vc,{target:t,expiration:n})}}),nu(this,"on",(e,t)=>{this.events.on(e,t)}),nu(this,"once",(e,t)=>{this.events.once(e,t)}),nu(this,"off",(e,t)=>{this.events.off(e,t)}),nu(this,"removeListener",(e,t)=>{this.events.removeListener(e,t)}),this.logger=(0,c.U5)(t,this.name)}get context(){return(0,c.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 function(e){return Ye("topic",e)}(e);if("number"==typeof e)return function(e){return Ye("id",e)}(e);const{message:t}=na("UNKNOWN_TYPE","Target type: ".concat(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(yc)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:e}=na("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(e),new Error(e)}this.cached=e,this.logger.debug("Successfully Restored expirations for ".concat(this.name)),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(An){this.logger.debug("Failed to Restore expirations for ".concat(this.name)),this.logger.error(An)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:t}=na("NO_MATCHING_KEY","".concat(this.name,": ").concat(e));throw this.logger.warn(t),new Error(t)}return t}checkExpiry(e,t){const{expiry:n}=t;(0,O.toMiliseconds)(n)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(mc,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(o.li.pulse,()=>this.checkExpirations()),this.events.on(gc,e=>{const t=gc;this.logger.info("Emitting ".concat(t)),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(mc,e=>{const t=mc;this.logger.info("Emitting ".concat(t)),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(vc,e=>{const t=vc;this.logger.info("Emitting ".concat(t)),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=na("NOT_INITIALIZED",this.name);throw new Error(e)}}}var su=Object.defineProperty,ru=(e,t,n)=>((e,t,n)=>t in e?su(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class ou extends C{constructor(e,t,n){super(e,t,n),this.core=e,this.logger=t,this.store=n,ru(this,"name","verify-api"),ru(this,"abortController"),ru(this,"isDevEnv"),ru(this,"verifyUrlV3",Ec),ru(this,"storagePrefix",xa),ru(this,"version",2),ru(this,"publicKey"),ru(this,"fetchPromise"),ru(this,"init",async()=>{var e;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&(0,O.toMiliseconds)(null==(e=this.publicKey)?void 0:e.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),ru(this,"register",async e=>{if(!Me()||this.isDevEnv)return;const t=window.location.origin,{id:n,decryptedId:i}=e,s="".concat(this.verifyUrlV3,"/attestation?projectId=").concat(this.core.projectId,"&origin=").concat(t,"&id=").concat(n,"&decryptedId=").concat(i);try{const e=(0,x.getDocument)(),t=this.startAbortTimer(5*O.ONE_SECOND),i=await new Promise((i,r)=>{const o=()=>{window.removeEventListener("message",c),e.body.removeChild(a),r("attestation aborted")};this.abortController.signal.addEventListener("abort",o);const a=e.createElement("iframe");a.src=s,a.style.display="none",a.addEventListener("error",o,{signal:this.abortController.signal});const c=s=>{if(s.data&&"string"==typeof s.data)try{const r=JSON.parse(s.data);if("verify_attestation"===r.type){if((0,P.Cq)(r.attestation).payload.id!==n)return;clearInterval(t),e.body.removeChild(a),this.abortController.signal.removeEventListener("abort",o),window.removeEventListener("message",c),i(null===r.attestation?"":r.attestation)}}catch(r){this.logger.warn(r)}};e.body.appendChild(a),window.addEventListener("message",c,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",i),i}catch(u){this.logger.warn(u)}return""}),ru(this,"resolve",async e=>{if(this.isDevEnv)return"";const{attestationId:t,hash:n,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);
2if(e)return e.isVerified?e:void this.logger.warn("resolve: jwt attestation: origin url not verified")}if(!n)return;const s=this.getVerifyUrl(null===e||void 0===e?void 0:e.verifyUrl);return this.fetchAttestation(n,s)}),ru(this,"fetchAttestation",async(e,t)=>{this.logger.debug("resolving attestation: ".concat(e," from url: ").concat(t));const n=this.startAbortTimer(5*O.ONE_SECOND),i=await fetch("".concat(t,"/attestation/").concat(e,"?v2Supported=true"),{signal:this.abortController.signal});return clearTimeout(n),200===i.status?await i.json():void 0}),ru(this,"getVerifyUrl",e=>{let t=e||bc;return Cc.includes(t)||(this.logger.info("verify url: ".concat(t,", not included in trusted list, assigning default: ").concat(bc)),t=bc),t}),ru(this,"fetchPublicKey",async()=>{try{this.logger.debug("fetching public key from: ".concat(this.verifyUrlV3));const e=this.startAbortTimer(O.FIVE_SECONDS),t=await fetch("".concat(this.verifyUrlV3,"/public-key"),{signal:this.abortController.signal});return clearTimeout(e),await t.json()}catch(e){this.logger.warn(e)}}),ru(this,"persistPublicKey",async e=>{this.logger.debug("persisting public key to local storage",e),await this.store.setItem(this.storeKey,e),this.publicKey=e}),ru(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),ru(this,"isValidJwtAttestation",async e=>{const t=await this.getPublicKey();try{if(t)return this.validateAttestation(e,t)}catch(d){this.logger.error(d),this.logger.warn("error validating attestation")}const n=await this.fetchAndPersistPublicKey();try{if(n)return this.validateAttestation(e,n)}catch(d){this.logger.error(d),this.logger.warn("error validating attestation")}}),ru(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),ru(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}),ru(this,"validateAttestation",(e,t)=>{const n=Io(e,t.publicKey),i={hasExpired:(0,O.toMiliseconds)(n.exp)<Date.now(),payload:n};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,c.U5)(t,this.name),this.abortController=new AbortController,this.isDevEnv=rt(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return(0,c.oI)(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),(0,O.toMiliseconds)(e))}}var au=Object.defineProperty,cu=(e,t,n)=>((e,t,n)=>t in e?au(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class lu extends A{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,cu(this,"context","echo"),cu(this,"registerDeviceToken",async e=>{const{clientId:t,token:n,notificationType:i,enableEncrypted:s=!1}=e,r="".concat("https://echo.walletconnect.com","/").concat(this.projectId,"/clients");await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:t,type:i,token:n,always_raw:s})})}),this.logger=(0,c.U5)(t,this.context)}}var du=Object.defineProperty,hu=Object.getOwnPropertySymbols,uu=Object.prototype.hasOwnProperty,pu=Object.prototype.propertyIsEnumerable,fu=(e,t,n)=>t in e?du(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,gu=(e,t)=>{for(var n in t||(t={}))uu.call(t,n)&&fu(e,n,t[n]);if(hu)for(var n of hu(t))pu.call(t,n)&&fu(e,n,t[n]);return e},vu=(e,t,n)=>fu(e,"symbol"!=typeof t?t+"":t,n);class mu extends I{constructor(e,t){let n=!(arguments.length>2&&void 0!==arguments[2])||arguments[2];super(e,t,n),this.core=e,this.logger=t,vu(this,"context","event-client"),vu(this,"storagePrefix",xa),vu(this,"storageVersion",.1),vu(this,"events",new Map),vu(this,"shouldPersist",!1),vu(this,"init",async()=>
2{if(!rt())try{const e={eventId:st(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:qe(this.core.relayer.protocol,this.core.relayer.version,Xa)}}};await this.sendEvent([e])}catch(e){this.logger.warn(e)}}),vu(this,"createEvent",e=>{const{event:t="ERROR",type:n="",properties:{topic:i,trace:s}}=e,r=st(),o=this.core.projectId||"",a=Date.now(),c=gu({eventId:r,timestamp:a,props:{event:t,type:n,properties:{topic:i,trace:s}},bundleId:o,domain:this.getAppDomain()},this.setMethods(r));return this.telemetryEnabled&&(this.events.set(r,c),this.shouldPersist=!0),c}),vu(this,"getEvent",e=>{const{eventId:t,topic:n}=e;if(t)return this.events.get(t);const i=Array.from(this.events.values()).find(e=>e.props.properties.topic===n);return i?gu(gu({},i),this.setMethods(i.eventId)):void 0}),vu(this,"deleteEvent",e=>{const{eventId:t}=e;this.events.delete(t),this.shouldPersist=!0}),vu(this,"setEventListeners",()=>{this.core.heartbeat.on(o.li.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(e=>{(0,O.fromMiliseconds)(Date.now())-(0,O.fromMiliseconds)(e.timestamp)>86400&&(this.events.delete(e.eventId),this.shouldPersist=!0)})})}),vu(this,"setMethods",e=>({addTrace:t=>this.addTrace(e,t),setError:t=>this.setError(e,t)})),vu(this,"addTrace",(e,t)=>{const n=this.events.get(e);n&&(n.props.properties.trace.push(t),this.events.set(e,n),this.shouldPersist=!0)}),vu(this,"setError",(e,t)=>{const n=this.events.get(e);n&&(n.props.type=t,n.timestamp=Date.now(),this.events.set(e,n),this.shouldPersist=!0)}),vu(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),vu(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,gu(gu({},e),this.setMethods(e.eventId)))})}catch(e){this.logger.warn(e)}}),vu(this,"submit",async()=>{if(!this.telemetryEnabled||0===this.events.size)return;const e=[];for(const[t,n]of this.events)n.props.type&&e.push(n);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(In){this.logger.warn(In)}}),vu(this,"sendEvent",async e=>{const t=this.getAppDomain()?"":"&sp=desktop";return await fetch("".concat("https://pulse.walletconnect.org/batch","?projectId=").concat(this.core.projectId,"&st=events_sdk&sv=js-").concat(Xa).concat(t),{method:"POST",body:JSON.stringify(e)})}),vu(this,"getAppDomain",()=>He().url),this.logger=(0,c.U5)(t,this.context),this.telemetryEnabled=n,n?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var yu=Object.defineProperty,wu=Object.getOwnPropertySymbols,bu=Object.prototype.hasOwnProperty,Eu=Object.prototype.propertyIsEnumerable,Cu=(e,t,n)=>t in e?yu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Au=(e,t)=>{for(var n in t||(t={}))bu.call(t,n)&&Cu(e,n,t[n]);if(wu)for(var n of wu(t))Eu.call(t,n)&&Cu(e,n,t[n]);return e},Iu=(e,t,n)=>Cu(e,"symbol"!=typeof t?t+"":t,n);class Nu extends u{constructor(e){var t;super(e),Iu(this,"protocol","wc"),Iu(this,"version",2),Iu(this,"name",Ra),Iu(this,"relayUrl"),Iu(this,"projectId"),Iu(this,"customStoragePrefix"),Iu(this,"events",new s.EventEmitter),Iu(this,"logger"),Iu(this,"heartbeat"),Iu(this,"relayer"),Iu(this,"crypto"),Iu(this,"storage"),Iu(this,"history"),Iu(this,"expirer"),Iu(this,"pairing"),Iu(this,"verify"),Iu(this,"echoClient"),Iu(this,"linkModeSupportedApps"),Iu(this,"eventClient"),Iu(this,"initialized",!1),Iu(this,"logChunkController"),Iu(this,"on",(e,t)=>this.events.on(e,t)),Iu(this,"once",(e,t)=>this.events.once(e,t)),Iu(this,"off",(e,t)=>this.events.off(e,t)),Iu(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),Iu(this,"dispatchEnvelope",e=>{let{topic:t,message:n,sessionExists:i}=e;if(!t||!n)return;const s={topic:t,message:n,publishedAt:Date.now(),transportType:Za.link_mode};this.relayer.onLinkMessageEvent(s,{sessionExists:i})});const n=this.getGlobalCore(null===e||void 0===e?void 0:e.customStoragePrefix);if(n)try{return this.customStoragePrefix=n.customStoragePrefix,this.logger=n.logger,this.heartbeat=n.heartbeat,this.crypto=n.crypto,this.history=n.history,this.expirer=n.expirer,this.storage=n.storage,this.relayer=n.relayer,this.pairing=n.pairing,this.verify=n.verify,this.echoClient=n.echoClient,this.linkModeSupportedApps=n.linkModeSupportedApps,this.eventClient=n.eventClient,this.initialized=n.initialized,this.logChunkController=n.logChunkController,n}catch(d){console.warn("Failed to copy global core",d)}this.projectId=null===e||void 0===e?void 0:e.projectId,this.relayUrl=(null===e||void 0===e?void 0:e.relayUrl)||Ba,this.customStoragePrefix=null!=e&&e.customStoragePrefix?":".concat(e.customStoragePrefix):"";const i=(0,c.iP)({level:"string"==typeof(null===e||void 0===e?void 0:e.logger)&&e.logger?e.logger:Ua,name:Ra}),{logger:r,chunkLoggerController:l}=(0,c.D5)({opts:i,maxSizeInBytes:null===e||void 0===e?void 0:e.maxLogBlobSizeInBytes,loggerOverride:null===e||void 0===e?void 0:e.logger});this.logChunkController=l,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,c.U5)(r,this.name),this.heartbeat=new o.VH,this.crypto=new qd(this,this.logger,null===e||void 0===e?void 0:e.keychain),this.history=new eu(this,this.logger),this.expirer=new iu(this,this.logger),this.storage=null!=e&&e.storage?e.storage:new a.A(Au(Au({},Da),null===e||void 0===e?void 0:e.storageOptions)),this.relayer=new Ph({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Xh(this,this.logger),this.verify=new ou(this,this.logger,this.storage),this.echoClient=new lu(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new mu(this,this.logger,null===e||void 0===e?void 0:e.telemetryEnabled),this.setGlobalCore(this)}static async init(e){const t=new Nu(e);await t.initialize();const n=await t.crypto.getClientId();return await t.storage.setItem("WALLETCONNECT_CLIENT_ID",n),t}get context(){return(0,c.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(tc,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(
2),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(tc)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(An){throw this.logger.warn("Core Initialization Failure at epoch ".concat(Date.now()),An),this.logger.error(An.message),An}}getGlobalCore(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"";try{if(this.isGlobalCoreDisabled())return;const t="_walletConnectCore_".concat(e),n="".concat(t,"_count");return globalThis[n]=(globalThis[n]||0)+1,globalThis[n]>1&&console.warn("WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ".concat(globalThis[n]," times.")),globalThis[t]}catch(Cn){return void console.warn("Failed to get global WalletConnect core",Cn)}}setGlobalCore(e){var t;try{if(this.isGlobalCoreDisabled())return;const n="_walletConnectCore_".concat((null==(t=e.opts)?void 0:t.customStoragePrefix)||"");globalThis[n]=e}catch(S){console.warn("Failed to set global WalletConnect core",S)}}isGlobalCoreDisabled(){try{return typeof process<"u"&&"true"==={NODE_ENV:"production",PUBLIC_URL:".",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.DISABLE_GLOBAL_CORE}catch(e){return!0}}}const Su=Nu,_u="client",Tu="".concat("wc","@").concat(2,":").concat(_u,":"),Ou=_u,ku="error",Pu="WALLETCONNECT_DEEPLINK_CHOICE",Ru="Proposal expired",xu=O.SEVEN_DAYS,Uu={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}}},Du={min:O.FIVE_MINUTES,max:O.SEVEN_DAYS},Lu="IDLE",Wu="ACTIVE",Mu={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"},sui_signAndExecuteTransaction:{key:"digest"},sui_signTransaction:{key:""},hedera_signAndExecuteTransaction:{key:"transactionId"},hedera_executeTransaction:{key:"transactionId"},near_signTransaction:{key:""},near_signTransactions:{key:""},tron_signTransaction:{key:"txID"},xrpl_signTransaction:{key:""},xrpl_signTransactionFor:{key:""},algo_signTxn:{key:""},sendTransfer:{key:"txid"},stacks_stxTransfer:{key:"txId"},polkadot_signTransaction:{key:""},cosmos_signDirect:{key:""}},Bu=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],Fu="".concat("wc","@",1.5,":").concat("auth",":"),ju="".concat(Fu,":PUB_KEY");var Hu=Object.defineProperty,qu=Object.defineProperties,Vu=Object.getOwnPropertyDescriptors,Ku=Object.getOwnPropertySymbols,zu=Object.prototype.hasOwnProperty,$u=Object.prototype.propertyIsEnumerable,Gu=(e,t,n)=>t in e?Hu(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Ju=(e,t)=>{for(var n in t||(t={}))zu.call(t,n)&&Gu(e,n,t[n]);if(Ku)for(var n of Ku(t))$u.call(t,n)&&Gu(e,n,t[n]);return e},Yu=(e,t)=>qu(e,Vu(t)),Xu=(e,t,n)=>Gu(e,"symbol"!=typeof t?t+"":t,n);class Zu extends T{constructor(e){var t;super(e),t=this,Xu(this,"name","engine"),Xu(this,"events",new(r())),Xu(this,"initialized",!1),Xu(this,"requestQueue",{state:Lu,queue:[]}),Xu(this,"sessionRequestQueue",{state:Lu,queue:[]}),Xu(this,"emittedSessionRequests",new at({limit:500})),Xu(this,"requestQueueDelay",O.ONE_SECOND),Xu(this,"expectedPairingMethodMap",new Map),Xu(this,"recentlyDeletedMap",new Map),Xu(this,"recentlyDeletedLimit",200),Xu(this,"relayMessageCache",[]),Xu(this,"pendingSessions",new Map),Xu(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(Uu)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},(0,O.toMiliseconds)(this.requestQueueDelay)))}),Xu(this,"connect",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const t=Yu(Ju({},e),{requiredNamespaces:e.requiredNamespaces||{},optionalNamespaces:e.optionalNamespaces||{}});await this.isValidConnect(t),t.optionalNamespaces=function(e,t){var n,i,s,r,o,a;const c=Zo(e),l=Zo(t),d={},h=Object.keys(c).concat(Object.keys(l));for(const u of h)d[u]={chains:tt(null==(n=c[u])?void 0:n.chains,null==(i=l[u])?void 0:i.chains),methods:tt(null==(s=c[u])?void 0:s.methods,null==(r=l[u])?void 0:r.methods),events:tt(null==(o=c[u])?void 0:o.events,null==(a=l[u])?void 0:a.events)};return d}(t.requiredNamespaces,t.optionalNamespaces),t.requiredNamespaces={};const{pairingTopic:n,requiredNamespaces:i,optionalNamespaces:s,sessionProperties:r,scopedProperties:o,relays:a}=t;let c,l=n,d=!1;try{if(l){const e=this.client.core.pairing.pairings.get(l);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),d=e.active}}catch(N){throw this.client.logger.error("connect() -> pairing.get(".concat(l,") failed")),N}if(!l||!d){const{topic:e,uri:t}=await this.client.core.pairing.create({internal:{skipSubscribe:!0}});l=e,c=t}if(!l){const{message:e}=na("NO_MATCHING_KEY","connect() pairing topic: ".concat(l));throw new Error(e)}const h=await this.client.core.crypto.generateKeyPair(),u=Uu.wc_sessionPropose.req.ttl||O.FIVE_MINUTES,p=Ze(u),f=Yu(Ju(Ju({requiredNamespaces:i,optionalNamespaces:s,relays:null!==a&&void 0!==a?a:[{protocol:"irn"}],proposer:{publicKey:h,metadata:this.client.metadata},expiryTimestamp:p,pairingTopic:l},r&&{sessionProperties:r}),o&&{scopedProperties:o}),{id:(0,ka.payloadId)()}),g=et("session_connect",f.id),{reject:v,resolve:m,done:y}=Ge(u,Ru),w=e=>{let{id:t}=e;t===f.id&&(this.client.events.off("proposal_expire",w),this.pendingSessions.delete(f.id),this.events.emit(g,{error:{message:Ru,code:0}}))};return this.client.events.on("proposal_expire",w),this.events.once(g,e=>{let{error:t,session:n}=e;this.client.events.off("proposal_expire",w),t?v(t):n&&m(n)}),await this.sendProposeSession({proposal:f,publishOpts:{internal:{throwOnFailedPublish:!0},tvf:{correlationId:f.id}}}),await this.setProposal(f.id,f),{uri:c,approval:y}}),Xu(this,"pair",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(e)}catch(An){throw this.client.logger.error("pair() failed"),An}}),Xu(this,"approve",async e=>{var t,n,i;const s=this.client.core.eventClient.createEvent({properties:{topic:null==(t=null===e||void 0===e?void 0:e.id)?void 0:t.toString(),trace:[Bc]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(Qh){throw s.setError(Kc),Qh}try{await this.isValidProposalId(null===e||void 0===e?void 0:e.id)}catch(Qh){throw this.client.logger.error("approve() -> proposal.get(".concat(null===e||void 0===e?void 0:e.id,") failed")),s.setError(Jc),Qh}try{await this.isValidApprove(e)}catch(Qh){throw this.client.logger.error("approve() -> isValidApprove() failed"),s.setError(Gc),Qh}const{id:r,relayProtocol:o,namespaces:a,sessionProperties:c,scopedProperties:l,sessionConfig:d}=e,h=this.client.proposal.get(r);this.client.core.eventClient.deleteEvent({eventId:s.eventId});const{pairingTopic:u,proposer:p,requiredNamespaces:f,optionalNamespaces:g}=h;let v=null==(n=this.client.core.eventClient)?void 0:n.getEvent({topic:u});v||(v=null==(i=this.client.core.eventClient)?void 0:i.createEvent({type:Bc,properties:{topic:u,trace:[Bc,Fc]}}));const m=await this.client.core.crypto.generateKeyPair(),y=p.publicKey,w=await this.client.core.crypto.generateSharedKey(m,y),b=Ju(Ju(Ju({relay:{protocol:null!==o&&void 0!==o?o:"irn"},namespaces:a,controller:{publicKey:m,metadata:this.client.metadata},expiry:Ze(xu)},c&&{sessionProperties:c}),l&&{scopedProperties:l}),d&&{sessionConfig:d}),E=Za.relay;v.addTrace(jc);try{await this.client.core.relayer.subscribe(w,{transportType:E,internal:{skipSubscribe:!0}})}catch(Qh){throw v.setError($c),Qh}v.addTrace(Hc);const C=Yu(Ju({},b),{topic:w,requiredNamespaces:f,optionalNamespaces:g,pairingTopic:u,acknowledged:!1,self:b.controller,peer:{publicKey:p.publicKey,metadata:p.metadata},controller:m,transportType:Za.relay});await this.client.session.set(w,C),v.addTrace(Vc);try{await this.sendApproveSession({sessionTopic:w,proposal:h,pairingProposalResponse:{relay:{protocol:null!==o&&void 0!==o?o:"irn"},responderPublicKey:m},sessionSettleRequest:b,publishOpts:{internal:{throwOnFailedPublish:!0},tvf:{correlationId:r}}}),v.addTrace(qc)}catch(Qh){throw this.client.logger.error(Qh),this.client.session.delete(w,ia("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(w),Qh}return this.client.core.eventClient.deleteEvent({eventId:v.eventId}),await this.client.core.pairing.updateMetadata({topic:u,metadata:p.metadata}),await this.deleteProposal(r),await this.client.core.pairing.activate({topic:u}),await this.setExpiry(w,Ze(xu)),{topic:w,acknowledged:()=>Promise.resolve(this.client.session.get(w))}}),Xu(this,"reject",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(e)}catch(s){throw this.client.logger.error("reject() -> isValidReject() failed"),s}const{id:t,reason:n}=e;let i;try{i=this.client.proposal.get(t).pairingTopic}catch(s){throw this.client.logger.error("reject() -> proposal.get(".concat(t,") failed")),s}
2i&&await this.sendError({id:t,topic:i,error:n,rpcOpts:Uu.wc_sessionPropose.reject}),await this.deleteProposal(t)}),Xu(this,"update",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(e)}catch(u){throw this.client.logger.error("update() -> isValidUpdate() failed"),u}const{topic:t,namespaces:n}=e,{done:i,resolve:s,reject:r}=Ge(),o=(0,ka.payloadId)(),a=(0,ka.getBigIntRpcId)().toString(),c=this.client.session.get(t).namespaces;return this.events.once(et("session_update",o),e=>{let{error:t}=e;t?r(t):s()}),await this.client.session.update(t,{namespaces:n}),await this.sendRequest({topic:t,method:"wc_sessionUpdate",params:{namespaces:n},throwOnFailedPublish:!0,clientRpcId:o,relayRpcId:a}).catch(e=>{this.client.logger.error(e),this.client.session.update(t,{namespaces:c}),r(e)}),{acknowledged:i}}),Xu(this,"extend",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(e)}catch(d){throw this.client.logger.error("extend() -> isValidExtend() failed"),d}const{topic:t}=e,n=(0,ka.payloadId)(),{done:i,resolve:s,reject:r}=Ge();return this.events.once(et("session_extend",n),e=>{let{error:t}=e;t?r(t):s()}),await this.setExpiry(t,Ze(xu)),this.sendRequest({topic:t,method:"wc_sessionExtend",params:{},clientRpcId:n,throwOnFailedPublish:!0}).catch(e=>{r(e)}),{acknowledged:i}}),Xu(this,"request",async e=>{this.isInitialized();try{await this.isValidRequest(e)}catch(m){throw this.client.logger.error("request() -> isValidRequest() failed"),m}const{chainId:t,request:n,topic:i,expiry:s=Uu.wc_sessionRequest.req.ttl}=e,r=this.client.session.get(i);(null===r||void 0===r?void 0:r.transportType)===Za.relay&&await this.confirmOnlineStateOrThrow();const o=(0,ka.payloadId)(),a=(0,ka.getBigIntRpcId)().toString(),{done:c,resolve:l,reject:d}=Ge(s,"Request expired. Please try again.");this.events.once(et("session_request",o),e=>{let{error:t,result:n}=e;t?d(t):l(n)});const h="wc_sessionRequest",u=this.getAppLinkIfEnabled(r.peer.metadata,r.transportType);if(u)return await this.sendRequest({clientRpcId:o,relayRpcId:a,topic:i,method:h,params:{request:Yu(Ju({},n),{expiryTimestamp:Ze(s)}),chainId:t},expiry:s,throwOnFailedPublish:!0,appLink:u}).catch(e=>d(e)),this.client.events.emit("session_request_sent",{topic:i,request:n,chainId:t,id:o}),await c();const p={request:Yu(Ju({},n),{expiryTimestamp:Ze(s)}),chainId:t};return await Promise.all([new Promise(async e=>{await this.sendRequest({clientRpcId:o,relayRpcId:a,topic:i,method:h,params:p,expiry:s,throwOnFailedPublish:!0,tvf:this.getTVFParams(o,p)}).catch(e=>d(e)),this.client.events.emit("session_request_sent",{topic:i,request:n,chainId:t,id:o}),e()}),new Promise(async e=>{var t;if(null==(t=r.sessionConfig)||!t.disableDeepLink){const e=await async function(e,t){let n="";try{if(Me()&&(n=localStorage.getItem(t),n))return n;n=await e.getItem(t)}catch(s){console.error(s)}return n}(this.client.core.storage,Pu);await nt({id:o,topic:i,wcDeepLink:e})}e()}),c()]).then(e=>e[2])}),Xu(this,"respond",async e=>{this.isInitialized(),await this.isValidRespond(e);const{topic:t,response:n}=e,{id:i}=n,s=this.client.session.get(t);s.transportType===Za.relay&&await this.confirmOnlineStateOrThrow();const r=this.getAppLinkIfEnabled(s.peer.metadata,s.transportType);(0,ka.isJsonRpcResult)(n)?await this.sendResult({id:i,topic:t,result:n.result,throwOnFailedPublish:!0,appLink:r}):(0,ka.isJsonRpcError)(n)&&await this.sendError({id:i,topic:t,error:n.error,appLink:r}),this.cleanupAfterResponse(e)}),Xu(this,"ping",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(e)}catch(n){throw this.client.logger.error("ping() -> isValidPing() failed"),n}const{topic:t}=e;if(this.client.session.keys.includes(t)){const e=(0,ka.payloadId)(),n=(0,ka.getBigIntRpcId)().toString(),{done:i,resolve:s,reject:r}=Ge();this.events.once(et("session_ping",e),e=>{let{error:t}=e;t?r(t):s()}),await Promise.all([this.sendRequest({topic:t,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:e,relayRpcId:n}),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}))}),Xu(this,"emit",async e=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(e);const{topic:t,event:n,chainId:i}=e,s=(0,ka.getBigIntRpcId)().toString(),r=(0,ka.payloadId)();await this.sendRequest({topic:t,method:"wc_sessionEvent",params:{event:n,chainId:i},throwOnFailedPublish:!0,relayRpcId:s,clientRpcId:r})}),Xu(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:ia("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:t,emitEvent:!1});else{if(!this.client.core.pairing.pairings.keys.includes(t)){const{message:e}=na("MISMATCHED_TOPIC","Session or pairing topic not found: ".concat(t));throw new Error(e)}
2await this.client.core.pairing.disconnect({topic:t})}}),Xu(this,"find",e=>(this.isInitialized(),this.client.session.getAll().filter(t=>function(e,t){const{requiredNamespaces:n}=t,i=Object.keys(e.namespaces),s=Object.keys(n);let r=!0;return!!Ke(s,i)&&(i.forEach(t=>{const{accounts:i,methods:s,events:o}=e.namespaces[t],a=Jo(i),c=n[t];(!Ke(Ee(t,c),a)||!Ke(c.methods,s)||!Ke(c.events,o))&&(r=!1)}),r)}(t,e)))),Xu(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),Xu(this,"authenticate",async(e,t)=>{var n;this.isInitialized(),this.isValidAuthenticate(e);const i=t&&this.client.core.linkModeSupportedApps.includes(t)&&(null==(n=this.client.metadata.redirect)?void 0:n.linkMode),s=i?Za.link_mode:Za.relay;s===Za.relay&&await this.confirmOnlineStateOrThrow();const{chains:r,statement:o="",uri:a,domain:c,nonce:l,type:d,exp:h,nbf:u,methods:p=[],expiry:f}=e,g=[...e.resources||[]],{topic:v,uri:m}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:s});this.client.logger.info({message:"Generated new pairing",pairing:{topic:v,uri:m}});const y=await this.client.core.crypto.generateKeyPair(),w=po(y);if(await Promise.all([this.client.auth.authKeys.set(ju,{responseTopic:w,publicKey:y}),this.client.auth.pairingTopics.set(w,{topic:w,pairingTopic:v})]),await this.client.core.relayer.subscribe(w,{transportType:s}),this.client.logger.info("sending request to new pairing topic: ".concat(v)),p.length>0){const{namespace:e}=be(r[0]);let t=Ti(e,"request",p);Ui(g)&&(t=ki(t,g.pop())),g.push(t)}const b=f&&f>Uu.wc_sessionAuthenticate.req.ttl?f:Uu.wc_sessionAuthenticate.req.ttl,E={authPayload:{type:null!==d&&void 0!==d?d:"caip122",chains:r,statement:o,aud:a,domain:c,version:"1",nonce:l,iat:(new Date).toISOString(),exp:h,nbf:u,resources:g},requester:{publicKey:y,metadata:this.client.metadata},expiryTimestamp:Ze(b)},C={requiredNamespaces:{},optionalNamespaces:{eip155:{chains:r,methods:[...new Set(["personal_sign",...p])],events:["chainChanged","accountsChanged"]}},relays:[{protocol:"irn"}],pairingTopic:v,proposer:{publicKey:y,metadata:this.client.metadata},expiryTimestamp:Ze(Uu.wc_sessionPropose.req.ttl),id:(0,ka.payloadId)()},{done:A,resolve:I,reject:N}=Ge(b,"Request expired"),S=(0,ka.payloadId)(),_=et("session_connect",C.id),T=et("session_request",S),O=async e=>{let{error:t,session:n}=e;this.events.off(T,k),t?N(t):n&&I({session:n})},k=async e=>{var n,i,r;if(await this.deletePendingAuthRequest(S,{message:"fulfilled",code:0}),e.error){const t=ia("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return e.error.code===t.code?void 0:(this.events.off(_,O),N(e.error.message))}
2await this.deleteProposal(C.id),this.events.off(_,O);const{cacaos:o,responder:a}=e.result,c=[],l=[];for(const t of o){await Ci({cacao:t,projectId:this.client.core.projectId})||(this.client.logger.error(t,"Signature verification failed"),N(ia("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:e}=t,n=Ui(e.resources),i=[bi(e.iss)],s=Ei(e.iss);if(n){const e=Ri(n),t=xi(n);c.push(...e),i.push(...t)}for(const t of i)l.push("".concat(t,":").concat(s))}const d=await this.client.core.crypto.generateSharedKey(y,a.publicKey);let h;c.length>0&&(h={topic:d,acknowledged:!0,self:{publicKey:y,metadata:this.client.metadata},peer:a,controller:a.publicKey,expiry:Ze(xu),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:v,namespaces:Qo([...new Set(c)],[...new Set(l)]),transportType:s},await this.client.core.relayer.subscribe(d,{transportType:s}),await this.client.session.set(d,h),v&&await this.client.core.pairing.updateMetadata({topic:v,metadata:a.metadata}),h=this.client.session.get(d)),null!=(n=this.client.metadata.redirect)&&n.linkMode&&null!=(i=a.metadata.redirect)&&i.linkMode&&null!=(r=a.metadata.redirect)&&r.universal&&t&&(this.client.core.addLinkModeSupportedApp(a.metadata.redirect.universal),this.client.session.update(d,{transportType:Za.link_mode})),I({auths:o,session:h})};let P;this.events.once(_,O),this.events.once(T,k);try{if(i){const e=(0,ka.formatJsonRpcRequest)("wc_sessionAuthenticate",E,S);this.client.core.history.set(v,e);const n=await this.client.core.crypto.encode("",e,{type:2,encoding:lo});P=Bo(t,v,n)}else await Promise.all([this.sendRequest({topic:v,method:"wc_sessionAuthenticate",params:E,expiry:e.expiry,throwOnFailedPublish:!0,clientRpcId:S}),this.sendRequest({topic:v,method:"wc_sessionPropose",params:C,expiry:Uu.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:C.id})])}catch(yl){throw this.events.off(_,O),this.events.off(T,k),yl}return await this.setProposal(C.id,C),await this.setAuthRequest(S,{request:Yu(Ju({},E),{verifyContext:{}}),pairingTopic:v,transportType:s}),{uri:null!==P&&void 0!==P?P:m,response:A}}),Xu(this,"approveSessionAuthenticate",async e=>{const{id:t,auths:n}=e,i=this.client.core.eventClient.createEvent({properties:{topic:t.toString(),trace:[Yc]}});try{this.isInitialized()}catch(m){throw i.setError(il),m}const s=this.getPendingAuthRequest(t);if(!s)throw i.setError(al),new Error("Could not find pending auth request with id ".concat(t));const r=s.transportType||Za.relay;r===Za.relay&&await this.confirmOnlineStateOrThrow();const o=s.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=po(o),l={type:1,receiverPublicKey:o,senderPublicKey:a},d=[],h=[];for(const f of n){if(!await Ci({cacao:f,projectId:this.client.core.projectId})){i.setError(sl);const e=ia("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:t,topic:c,error:e,encodeOpts:l}),new Error(e.message)}i.addTrace(Zc);const{p:e}=f,n=Ui(e.resources),s=[bi(e.iss)],r=Ei(e.iss);if(n){const e=Ri(n),t=xi(n);d.push(...e),s.push(...t)}for(const t of s)h.push("".concat(t,":").concat(r))}const u=await this.client.core.crypto.generateSharedKey(a,o);let p;if(i.addTrace(Xc),(null===d||void 0===d?void 0:d.length)>0){p={topic:u,acknowledged:!0,self:{publicKey:a,metadata:this.client.metadata},peer:{publicKey:o,metadata:s.requester.metadata},controller:o,expiry:Ze(xu),authentication:n,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:s.pairingTopic,namespaces:Qo([...new Set(d)],[...new Set(h)]),transportType:r},i.addTrace(el);try{await this.client.core.relayer.subscribe(u,{transportType:r})}catch(m){throw i.setError(rl),m}i.addTrace(tl),await this.client.session.set(u,p),i.addTrace(Qc),await this.client.core.pairing.updateMetadata({topic:s.pairingTopic,metadata:s.requester.metadata})}i.addTrace(nl);try{await this.sendResult({topic:c,id:t,result:{cacaos:n,responder:{publicKey:a,metadata:this.client.metadata}},encodeOpts:l,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(s.requester.metadata,r)})}catch(m){throw i.setError(ol),m}return await this.client.auth.requests.delete(t,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:s.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:i.eventId}),{session:p}}),Xu(this,"rejectSessionAuthenticate",async e=>{this.isInitialized();const{id:t,reason:n}=e,i=this.getPendingAuthRequest(t);if(!i)throw new Error("Could not find pending auth request with id ".concat(t));i.transportType===Za.relay&&await this.confirmOnlineStateOrThrow();const s=i.requester.publicKey,r=await this.client.core.crypto.generateKeyPair(),o=po(s),a={type:1,receiverPublicKey:s,senderPublicKey:r};
2await this.sendError({id:t,topic:o,error:n,encodeOpts:a,rpcOpts:Uu.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(i.requester.metadata,i.transportType)}),await this.client.auth.requests.delete(t,{message:"rejected",code:0}),await this.deleteProposal(t)}),Xu(this,"formatAuthMessage",e=>{this.isInitialized();const{request:t,iss:n}=e;return Ai(t,n)}),Xu(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(Cn){this.client.logger.error(Cn)}},50)}),Xu(this,"cleanupDuplicatePairings",async e=>{if(e.pairingTopic)try{const t=this.client.core.pairing.pairings.get(e.pairingTopic),n=this.client.core.pairing.pairings.getAll().filter(n=>{var i,s;return(null==(i=n.peerMetadata)?void 0:i.url)&&(null==(s=n.peerMetadata)?void 0:s.url)===e.peer.metadata.url&&n.topic&&n.topic!==t.topic});if(0===n.length)return;this.client.logger.info("Cleaning up ".concat(n.length," duplicate pairing(s)")),await Promise.all(n.map(e=>this.client.core.pairing.disconnect({topic:e.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(An){this.client.logger.error(An)}}),Xu(this,"deleteSession",async e=>{var t;const{topic:n,expirerHasDeleted:i=!1,emitEvent:s=!0,id:r=0}=e,{self:o}=this.client.session.get(n);await this.client.core.relayer.unsubscribe(n),await this.client.session.delete(n,ia("USER_DISCONNECTED")),this.addToRecentlyDeleted(n,"session"),this.client.core.crypto.keychain.has(o.publicKey)&&await this.client.core.crypto.deleteKeyPair(o.publicKey),this.client.core.crypto.keychain.has(n)&&await this.client.core.crypto.deleteSymKey(n),i||this.client.core.expirer.del(n),this.client.core.storage.removeItem(Pu).catch(e=>this.client.logger.warn(e)),this.getPendingSessionRequests().forEach(e=>{e.topic===n&&this.deletePendingSessionRequest(e.id,ia("USER_DISCONNECTED"))}),n===(null==(t=this.sessionRequestQueue.queue[0])?void 0:t.topic)&&(this.sessionRequestQueue.state=Lu),s&&this.client.events.emit("session_delete",{id:r,topic:n})}),Xu(this,"deleteProposal",async(e,t)=>{if(t)try{const t=this.client.proposal.get(e),n=this.client.core.eventClient.getEvent({topic:t.pairingTopic});null===n||void 0===n||n.setError(zc)}catch(n){}await Promise.all([this.client.proposal.delete(e,ia("USER_DISCONNECTED")),t?Promise.resolve():this.client.core.expirer.del(e)]),this.addToRecentlyDeleted(e,"proposal")}),Xu(this,"deletePendingSessionRequest",async function(e,n){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];await Promise.all([t.client.pendingRequest.delete(e,n),i?Promise.resolve():t.client.core.expirer.del(e)]),t.addToRecentlyDeleted(e,"request"),t.sessionRequestQueue.queue=t.sessionRequestQueue.queue.filter(t=>t.id!==e),i&&(t.sessionRequestQueue.state=Lu,t.client.events.emit("session_request_expire",{id:e}))}),Xu(this,"deletePendingAuthRequest",async function(e,n){let i=arguments.length>2&&void 0!==arguments[2]&&arguments[2];await Promise.all([t.client.auth.requests.delete(e,n),i?Promise.resolve():t.client.core.expirer.del(e)])}),Xu(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}))}),Xu(this,"setProposal",async(e,t)=>{this.client.core.expirer.set(e,Ze(Uu.wc_sessionPropose.req.ttl)),await this.client.proposal.set(e,t)}),Xu(this,"setAuthRequest",async(e,t)=>{const{request:n,pairingTopic:i,transportType:s=Za.relay}=t;this.client.core.expirer.set(e,n.expiryTimestamp),await this.client.auth.requests.set(e,{authPayload:n.authPayload,requester:n.requester,expiryTimestamp:n.expiryTimestamp,id:e,pairingTopic:i,verifyContext:n.verifyContext,transportType:s})}),Xu(this,"setPendingSessionRequest",async e=>{const{id:t,topic:n,params:i,verifyContext:s}=e,r=i.request.expiryTimestamp||Ze(Uu.wc_sessionRequest.req.ttl);this.client.core.expirer.set(t,r),await this.client.pendingRequest.set(t,{id:t,topic:n,params:i,verifyContext:s})}),Xu(this,"sendRequest",async e=>{const{topic:t,method:i,params:s,expiry:r,relayRpcId:o,clientRpcId:a,throwOnFailedPublish:c,appLink:l,tvf:d,publishOpts:h={}}=e,u=(0,ka.formatJsonRpcRequest)(i,s,a);let p;const f=!!l;try{const e=f?lo:co;p=await this.client.core.crypto.encode(t,u,{encoding:e})}catch(m){throw await this.cleanup(),this.client.logger.error("send
2Request() -> core.crypto.encode() for topic ".concat(t," failed")),m}let g;if(Bu.includes(i)){const e=fo(JSON.stringify(u)),t=fo(p);g=await this.client.core.verify.register({id:t,decryptedId:e})}const v=Ju(Ju({},Uu[i].req),h);if(v.attestation=g,r&&(v.ttl=r),o&&(v.id=o),this.client.core.history.set(t,u),f){const e=Bo(l,t,p);await n.g.Linking.openURL(e,this.client.name)}else v.tvf=Yu(Ju({},d),{correlationId:u.id}),c?(v.internal=Yu(Ju({},v.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(t,p,v)):this.client.core.relayer.publish(t,p,v).catch(e=>this.client.logger.error(e));return u.id}),Xu(this,"sendProposeSession",async e=>{const{proposal:t,publishOpts:n}=e,i=(0,ka.formatJsonRpcRequest)("wc_sessionPropose",t,t.id);this.client.core.history.set(t.pairingTopic,i);const s=await this.client.core.crypto.encode(t.pairingTopic,i,{encoding:co}),r=fo(JSON.stringify(i)),o=fo(s),a=await this.client.core.verify.register({id:o,decryptedId:r});await this.client.core.relayer.publishCustom({payload:{pairingTopic:t.pairingTopic,sessionProposal:s},opts:Yu(Ju({},n),{publishMethod:"wc_proposeSession",attestation:a})})}),Xu(this,"sendApproveSession",async e=>{const{sessionTopic:t,pairingProposalResponse:n,proposal:i,sessionSettleRequest:s,publishOpts:r}=e,o=(0,ka.formatJsonRpcResult)(i.id,n),a=await this.client.core.crypto.encode(i.pairingTopic,o,{encoding:co}),c=(0,ka.formatJsonRpcRequest)("wc_sessionSettle",s,null===r||void 0===r?void 0:r.id),l=await this.client.core.crypto.encode(t,c,{encoding:co});this.client.core.history.set(t,c),await this.client.core.relayer.publishCustom({payload:{sessionTopic:t,pairingTopic:i.pairingTopic,sessionProposalResponse:a,sessionSettlementRequest:l},opts:Yu(Ju({},r),{publishMethod:"wc_approveSession"})})}),Xu(this,"sendResult",async e=>{const{id:t,topic:i,result:s,throwOnFailedPublish:r,encodeOpts:o,appLink:a}=e,c=(0,ka.formatJsonRpcResult)(t,s);let l;const d=a&&typeof(null==n.g?void 0:n.g.Linking)<"u";try{const e=d?lo:co;l=await this.client.core.crypto.encode(i,c,Yu(Ju({},o||{}),{encoding:e}))}catch(v){throw await this.cleanup(),this.client.logger.error("sendResult() -> core.crypto.encode() for topic ".concat(i," failed")),v}let h,u;try{h=await this.client.core.history.get(i,t);const e=h.request;try{u=this.getTVFParams(t,e.params,s)}catch(p){this.client.logger.warn("sendResult() -> getTVFParams() failed: ".concat(null===p||void 0===p?void 0:p.message))}}catch(v){throw this.client.logger.error("sendResult() -> history.get(".concat(i,", ").concat(t,") failed")),v}if(d){const e=Bo(a,i,l);await n.g.Linking.openURL(e,this.client.name)}else{const e=h.request.method,n=Uu[e].res;n.tvf=Yu(Ju({},u),{correlationId:t}),r?(n.internal=Yu(Ju({},n.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,l,n)):this.client.core.relayer.publish(i,l,n).catch(e=>this.client.logger.error(e))}await this.client.core.history.resolve(c)}),Xu(this,"sendError",async e=>{const{id:t,topic:i,error:s,encodeOpts:r,rpcOpts:o,appLink:a}=e,c=(0,ka.formatJsonRpcError)(t,s);let l;const d=a&&typeof(null==n.g?void 0:n.g.Linking)<"u";try{const e=d?lo:co;l=await this.client.core.crypto.encode(i,c,Yu(Ju({},r||{}),{encoding:e}))}catch(y){throw await this.cleanup(),this.client.logger.error("sendError() -> core.crypto.encode() for topic ".concat(i," failed")),y}let h;try{h=await this.client.core.history.get(i,t)}catch(y){throw this.client.logger.error("sendError() -> history.get(".concat(i,", ").concat(t,") failed")),y}if(d){const e=Bo(a,i,l);await n.g.Linking.openURL(e,this.client.name)}else{const e=h.request.method,t=o||Uu[e].res;this.client.core.relayer.publish(i,l,t)}await this.client.core.history.resolve(c)}),Xu(this,"cleanup",async()=>{const e=[],t=[];this.client.session.getAll().forEach(t=>{let n=!1;Qe(t.expiry)&&(n=!0),this.client.core.crypto.keychain.has(t.topic)||(n=!0),n&&e.push(t.topic)}),this.client.proposal.getAll().forEach(e=>{Qe(e.expiryTimestamp)&&t.push(e.id)}),await Promise.all([...e.map(e=>this.deleteSession({topic:e})),...t.map(e=>this.deleteProposal(e))])}),Xu(this,"onProviderMessageEvent",async e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):await this.onRelayMessage(e)}),Xu(this,"onRelayEventRequest",async e=>{this.requestQueue.queue.push(e),await this.processRequestsQueue()}),Xu(this,"processRequestsQueue",async()=>
2{if(this.requestQueue.state!==Wu){for(this.client.logger.info("Request queue starting with ".concat(this.requestQueue.queue.length," requests"));this.requestQueue.queue.length>0;){this.requestQueue.state=Wu;const e=this.requestQueue.queue.shift();if(e)try{await this.processRequest(e)}catch(An){this.client.logger.warn(An)}}this.requestQueue.state=Lu}else this.client.logger.info("Request queue already active, skipping...")}),Xu(this,"processRequest",async e=>{const{topic:t,payload:n,attestation:i,transportType:s,encryptedId:r}=e,o=n.method;if(!this.shouldIgnorePairingRequest({topic:t,requestMethod:o}))switch(o){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:t,payload:n,attestation:i,encryptedId:r});case"wc_sessionSettle":return await this.onSessionSettleRequest(t,n);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(t,n);case"wc_sessionExtend":return await this.onSessionExtendRequest(t,n);case"wc_sessionPing":return await this.onSessionPingRequest(t,n);case"wc_sessionDelete":return await this.onSessionDeleteRequest(t,n);case"wc_sessionRequest":return await this.onSessionRequest({topic:t,payload:n,attestation:i,encryptedId:r,transportType:s});case"wc_sessionEvent":return await this.onSessionEventRequest(t,n);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:t,payload:n,attestation:i,encryptedId:r,transportType:s});default:return this.client.logger.info("Unsupported request method ".concat(o))}}),Xu(this,"onRelayEventResponse",async e=>{const{topic:t,payload:n,transportType:i}=e,s=(await this.client.core.history.get(t,n.id)).request.method;switch(s){case"wc_sessionPropose":return this.onSessionProposeResponse(t,n,i);case"wc_sessionSettle":return this.onSessionSettleResponse(t,n);case"wc_sessionUpdate":return this.onSessionUpdateResponse(t,n);case"wc_sessionExtend":return this.onSessionExtendResponse(t,n);case"wc_sessionPing":return this.onSessionPingResponse(t,n);case"wc_sessionRequest":return this.onSessionRequestResponse(t,n);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(t,n);default:return this.client.logger.info("Unsupported response method ".concat(s))}}),Xu(this,"onRelayEventUnknownPayload",e=>{const{topic:t}=e,{message:n}=na("MISSING_OR_INVALID","Decoded payload on topic ".concat(t," is not identifiable as a JSON-RPC request or a response."));throw new Error(n)}),Xu(this,"shouldIgnorePairingRequest",e=>{const{topic:t,requestMethod:n}=e,i=this.expectedPairingMethodMap.get(t);return!(!i||i.includes(n))&&!!(i.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),Xu(this,"onSessionProposeRequest",async e=>{const{topic:t,payload:n,attestation:i,encryptedId:s}=e,{params:r,id:o}=n;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"),null!==e&&void 0!==e&&e.setError(Mc)),this.isValidConnect(Ju({},n.params));const a=r.expiryTimestamp||Ze(Uu.wc_sessionPropose.req.ttl),c=Ju({id:o,pairingTopic:t,expiryTimestamp:a,attestation:i,encryptedId:s},r);await this.setProposal(o,c);const l=await this.getVerifyContext({attestationId:i,hash:fo(JSON.stringify(n)),encryptedId:s,metadata:c.proposer.metadata});null!==e&&void 0!==e&&e.addTrace(Rc),this.client.events.emit("session_proposal",{id:o,params:c,verifyContext:l})}catch(a){await this.sendError({id:o,topic:t,error:a,rpcOpts:Uu.wc_sessionPropose.autoReject}),this.client.logger.error(a)}}),Xu(this,"onSessionProposeResponse",async(e,t,n)=>{const{id:i}=t;if((0,ka.isJsonRpcResult)(t)){const{result:s}=t;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:s});const r=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:r});const o=r.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:o});const a=s.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 l=await this.client.core.relayer.subscribe(c,{transportType:n});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:l}),await this.client.core.pairing.activate({topic:e})}else if((0,ka.isJsonRpcError)(t)){await this.deleteProposal(i);const e=et("session_connect",i);if(0===this.events.listenerCount(e))throw new Error("emitting ".concat(e," without any listeners, 954"));this.events.emit(e,{error:t.error})}}),Xu(this,"onSessionSettleRequest",async(e,t)=>{const{id:n,params:i}=t;try{this.isValidSessionSettleRequest(i);const{relay:n,controller:s,expiry:r,namespaces:o,sessionProperties:a,scopedProperties:c,sessionConfig:l}=t.params,d=[...this.pendingSessions.values()].find(t=>t.sessionTopic===e);if(!d)return this.client.logger.error("Pending session not found for topic ".concat(e));const h=this.client.proposal.get(d.proposalId),u=Yu(Ju(Ju(Ju({topic:e,relay:n,expiry:r,namespaces:o,acknowledged:!0,pairingTopic:d.pairingTopic,requiredNamespaces:h.requiredNamespaces,optionalNamespaces:h.optionalNamespaces,controller:s.publicKey,self:{publicKey:d.publicKey,metadata:this.client.metadata},peer:{publicKey:s.publicKey,metadata:s.metadata}},a&&{sessionProperties:a}),c&&{scopedProperties:c}),l&&{sessionConfig:l}),{transportType:Za.relay});await this.client.session.set(u.topic,u),await this.setExpiry(u.topic,u.expiry),await this.client.core.pairing.updateMetadata({topic:d.pairingTopic,metadata:u.peer.metadata}),this.client.events.emit("session_connect",{session:u}),this.events.emit(et("session_connect",d.proposalId),{session:u}
2),this.pendingSessions.delete(d.proposalId),this.deleteProposal(d.proposalId,!1),this.cleanupDuplicatePairings(u),await this.sendResult({id:t.id,topic:e,result:!0})}catch(s){await this.sendError({id:n,topic:e,error:s}),this.client.logger.error(s)}}),Xu(this,"onSessionSettleResponse",async(e,t)=>{const{id:n}=t;(0,ka.isJsonRpcResult)(t)?(await this.client.session.update(e,{acknowledged:!0}),this.events.emit(et("session_approve",n),{})):(0,ka.isJsonRpcError)(t)&&(await this.client.session.delete(e,ia("USER_DISCONNECTED")),this.events.emit(et("session_approve",n),{error:t.error}))}),Xu(this,"onSessionUpdateRequest",async(e,t)=>{const{params:n,id:i}=t;try{const t="".concat(e,"_session_update"),s=Na.get(t);if(s&&this.isRequestOutOfSync(s,i))return this.client.logger.warn("Discarding out of sync request - ".concat(i)),void this.sendError({id:i,topic:e,error:ia("INVALID_UPDATE_REQUEST")});this.isValidUpdate(Ju({topic:e},n));try{Na.set(t,i),await this.client.session.update(e,{namespaces:n.namespaces}),await this.sendResult({id:i,topic:e,result:!0})}catch(d){throw Na.delete(t),d}this.client.events.emit("session_update",{id:i,topic:e,params:n})}catch(s){await this.sendError({id:i,topic:e,error:s}),this.client.logger.error(s)}}),Xu(this,"isRequestOutOfSync",(e,t)=>t.toString().slice(0,-3)<e.toString().slice(0,-3)),Xu(this,"onSessionUpdateResponse",(e,t)=>{const{id:n}=t,i=et("session_update",n);if(0===this.events.listenerCount(i))throw new Error("emitting ".concat(i," without any listeners"));(0,ka.isJsonRpcResult)(t)?this.events.emit(et("session_update",n),{}):(0,ka.isJsonRpcError)(t)&&this.events.emit(et("session_update",n),{error:t.error})}),Xu(this,"onSessionExtendRequest",async(e,t)=>{const{id:n}=t;try{this.isValidExtend({topic:e}),await this.setExpiry(e,Ze(xu)),await this.sendResult({id:n,topic:e,result:!0}),this.client.events.emit("session_extend",{id:n,topic:e})}catch(S){await this.sendError({id:n,topic:e,error:S}),this.client.logger.error(S)}}),Xu(this,"onSessionExtendResponse",(e,t)=>{const{id:n}=t,i=et("session_extend",n);if(0===this.events.listenerCount(i))throw new Error("emitting ".concat(i," without any listeners"));(0,ka.isJsonRpcResult)(t)?this.events.emit(et("session_extend",n),{}):(0,ka.isJsonRpcError)(t)&&this.events.emit(et("session_extend",n),{error:t.error})}),Xu(this,"onSessionPingRequest",async(e,t)=>{const{id:n}=t;try{this.isValidPing({topic:e}),await this.sendResult({id:n,topic:e,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:n,topic:e})}catch(S){await this.sendError({id:n,topic:e,error:S}),this.client.logger.error(S)}}),Xu(this,"onSessionPingResponse",(e,t)=>{const{id:n}=t,i=et("session_ping",n);setTimeout(()=>{if(0===this.events.listenerCount(i))throw new Error("emitting ".concat(i," without any listeners 2176"));(0,ka.isJsonRpcResult)(t)?this.events.emit(et("session_ping",n),{}):(0,ka.isJsonRpcError)(t)&&this.events.emit(et("session_ping",n),{error:t.error})},500)}),Xu(this,"onSessionDeleteRequest",async(e,t)=>{const{id:n}=t;try{this.isValidDisconnect({topic:e,reason:t.params}),await Promise.all([new Promise(t=>{this.client.core.relayer.once(za,async()=>{t(await this.deleteSession({topic:e,id:n}))})}),this.sendResult({id:n,topic:e,result:!0}),this.cleanupPendingSentRequestsForTopic({topic:e,error:ia("USER_DISCONNECTED")})]).catch(e=>this.client.logger.error(e))}catch(S){this.client.logger.error(S)}}),Xu(this,"onSessionRequest",async e=>{var t,n,i;const{topic:s,payload:r,attestation:o,encryptedId:a,transportType:c}=e,{id:l,params:d}=r;try{await this.isValidRequest(Ju({topic:s},d));const e=this.client.session.get(s),r={id:l,topic:s,params:d,verifyContext:await this.getVerifyContext({attestationId:o,hash:fo(JSON.stringify((0,ka.formatJsonRpcRequest)("wc_sessionRequest",d,l))),encryptedId:a,metadata:e.peer.metadata,transportType:c})};await this.setPendingSessionRequest(r),c===Za.link_mode&&null!=(t=e.peer.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(null==(n=e.peer.metadata.redirect)?void 0:n.universal),null!=(i=this.client.signConfig)&&i.disableRequestQueue?this.emitSessionRequest(r):(this.addSessionRequestToSessionRequestQueue(r),this.processSessionRequestQueue())}
2catch(y){await this.sendError({id:l,topic:s,error:y}),this.client.logger.error(y)}}),Xu(this,"onSessionRequestResponse",(e,t)=>{const{id:n}=t,i=et("session_request",n);if(0===this.events.listenerCount(i))throw new Error("emitting ".concat(i," without any listeners"));(0,ka.isJsonRpcResult)(t)?this.events.emit(et("session_request",n),{result:t.result}):(0,ka.isJsonRpcError)(t)&&this.events.emit(et("session_request",n),{error:t.error})}),Xu(this,"onSessionEventRequest",async(e,t)=>{const{id:n,params:i}=t;try{const t="".concat(e,"_session_event_").concat(i.event.name),s=Na.get(t);if(s&&this.isRequestOutOfSync(s,n))return void this.client.logger.info("Discarding out of sync request - ".concat(n));this.isValidEmit(Ju({topic:e},i)),this.client.events.emit("session_event",{id:n,topic:e,params:i}),Na.set(t,n)}catch(s){await this.sendError({id:n,topic:e,error:s}),this.client.logger.error(s)}}),Xu(this,"onSessionAuthenticateResponse",(e,t)=>{const{id:n}=t;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:e,payload:t}),(0,ka.isJsonRpcResult)(t)?this.events.emit(et("session_request",n),{result:t.result}):(0,ka.isJsonRpcError)(t)&&this.events.emit(et("session_request",n),{error:t.error})}),Xu(this,"onSessionAuthenticateRequest",async e=>{var t;const{topic:n,payload:i,attestation:s,encryptedId:r,transportType:o}=e;try{const{requester:e,authPayload:a,expiryTimestamp:c}=i.params,l=await this.getVerifyContext({attestationId:s,hash:fo(JSON.stringify(i)),encryptedId:r,metadata:e.metadata,transportType:o}),d={requester:e,pairingTopic:n,id:i.id,authPayload:a,verifyContext:l,expiryTimestamp:c};await this.setAuthRequest(i.id,{request:d,pairingTopic:n,transportType:o}),o===Za.link_mode&&null!=(t=e.metadata.redirect)&&t.universal&&this.client.core.addLinkModeSupportedApp(e.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:n,params:i.params,id:i.id,verifyContext:l})}catch(a){this.client.logger.error(a);const e=i.params.requester.publicKey,t=await this.client.core.crypto.generateKeyPair(),s=this.getAppLinkIfEnabled(i.params.requester.metadata,o),r={type:1,receiverPublicKey:e,senderPublicKey:t};await this.sendError({id:i.id,topic:n,error:a,encodeOpts:r,rpcOpts:Uu.wc_sessionAuthenticate.autoReject,appLink:s})}}),Xu(this,"addSessionRequestToSessionRequestQueue",e=>{this.sessionRequestQueue.queue.push(e)}),Xu(this,"cleanupAfterResponse",e=>{this.deletePendingSessionRequest(e.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Lu,this.processSessionRequestQueue()},(0,O.toMiliseconds)(this.requestQueueDelay))}),Xu(this,"cleanupPendingSentRequestsForTopic",e=>{let{topic:t,error:n}=e;const i=this.client.core.history.pending;i.length>0&&i.filter(e=>e.topic===t&&"wc_sessionRequest"===e.request.method).forEach(e=>{const t=et("session_request",e.request.id);if(0===this.events.listenerCount(t))throw new Error("emitting ".concat(t," without any listeners"));this.events.emit(et("session_request",e.request.id),{error:n})})}),Xu(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===Wu)return void this.client.logger.info("session request queue is already active.");const e=this.sessionRequestQueue.queue[0];if(e)try{this.emitSessionRequest(e)}catch(An){this.client.logger.error(An)}else this.client.logger.info("session request queue is empty.")}),Xu(this,"emitSessionRequest",e=>{this.emittedSessionRequests.has(e.id)?this.client.logger.warn({id:e.id},"Skipping emitting `session_request` event for duplicate request. id: ".concat(e.id)):(this.sessionRequestQueue.state=Wu,this.emittedSessionRequests.add(e.id),this.client.events.emit("session_request",e))}),Xu(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);
2t&&this.onSessionProposeRequest({topic:e.topic,payload:(0,ka.formatJsonRpcRequest)("wc_sessionPropose",Yu(Ju({},t),{requiredNamespaces:t.requiredNamespaces,optionalNamespaces:t.optionalNamespaces,relays:t.relays,proposer:t.proposer,sessionProperties:t.sessionProperties,scopedProperties:t.scopedProperties}),t.id),attestation:t.attestation,encryptedId:t.encryptedId})}),Xu(this,"isValidConnect",async e=>{if(!va(e)){const{message:t}=na("MISSING_OR_INVALID","connect() params: ".concat(JSON.stringify(e)));throw new Error(t)}const{pairingTopic:t,requiredNamespaces:n,optionalNamespaces:i,sessionProperties:s,scopedProperties:r,relays:o}=e;if(oa(t)||await this.isValidPairingTopic(t),!function(e,t){let n=!1;return t&&!e?n=!0:e&&sa(e)&&e.length&&e.forEach(e=>{n=ga(e)}),n}(o,!0)){const{message:e}=na("MISSING_OR_INVALID","connect() relays: ".concat(o));throw new Error(e)}if(!oa(n)&&0!==ra(n)){const e="requiredNamespaces are deprecated and are automatically assigned to optionalNamespaces";["fatal","error","silent"].includes(this.client.logger.level)?console.warn(e):this.client.logger.warn(e),this.validateNamespaces(n,"requiredNamespaces")}if(!oa(i)&&0!==ra(i)&&this.validateNamespaces(i,"optionalNamespaces"),oa(s)||this.validateSessionProps(s,"sessionProperties"),!oa(r)){this.validateSessionProps(r,"scopedProperties");const e=Object.keys(n||{}).concat(Object.keys(i||{}));if(!Object.keys(r).every(t=>e.includes(t.split(":")[0])))throw new Error("Scoped properties must be a subset of required/optional namespaces, received: ".concat(JSON.stringify(r),", required/optional namespaces: ").concat(JSON.stringify(e)))}}),Xu(this,"validateNamespaces",(e,t)=>{const n=function(e,t,n){let i=null;if(e&&ra(e)){const s=pa(e,t);s&&(i=s);const r=ha(e,t,n);r&&(i=r)}else i=na("MISSING_OR_INVALID","".concat(t,", ").concat(n," should be an object with data"));return i}(e,"connect()",t);if(n)throw new Error(n.message)}),Xu(this,"isValidApprove",async e=>{if(!va(e))throw new Error(na("MISSING_OR_INVALID","approve() params: ".concat(e)).message);const{id:t,namespaces:n,relayProtocol:i,sessionProperties:s,scopedProperties:r}=e;this.checkRecentlyDeleted(t),await this.isValidProposalId(t);const o=this.client.proposal.get(t),a=fa(n,"approve()");if(a)throw new Error(a.message);const c=ba(o.requiredNamespaces,n,"approve()");if(c)throw new Error(c.message);if(!aa(i,!0)){const{message:e}=na("MISSING_OR_INVALID","approve() relayProtocol: ".concat(i));throw new Error(e)}if(oa(s)||this.validateSessionProps(s,"sessionProperties"),!oa(r)){this.validateSessionProps(r,"scopedProperties");const e=new Set(Object.keys(n));if(!Object.keys(r).every(t=>e.has(t.split(":")[0])))throw new Error("Scoped properties must be a subset of approved namespaces, received: ".concat(JSON.stringify(r),", approved namespaces: ").concat(Array.from(e).join(", ")))}}),Xu(this,"isValidReject",async e=>{if(!va(e)){const{message:t}=na("MISSING_OR_INVALID","reject() params: ".concat(e));throw new Error(t)}const{id:t,reason:n}=e;if(this.checkRecentlyDeleted(t),await this.isValidProposalId(t),!function(e){return!(!e||"object"!=typeof e||!e.code||!ca(e.code,!1)||!e.message||!aa(e.message,!1))}(n)){const{message:e}=na("MISSING_OR_INVALID","reject() reason: ".concat(JSON.stringify(n)));throw new Error(e)}}),Xu(this,"isValidSessionSettleRequest",e=>{if(!va(e)){const{message:t}=na("MISSING_OR_INVALID","onSessionSettleRequest() params: ".concat(e));throw new Error(t)}const{relay:t,controller:n,namespaces:i,expiry:s}=e;if(!ga(t)){const{message:e}=na("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(e)}const r=function(e,t){let n=null;return aa(null===e||void 0===e?void 0:e.publicKey,!1)||(n=na("MISSING_OR_INVALID","".concat(t," controller public key should be a string"))),n}(n,"onSessionSettleRequest()");if(r)throw new Error(r.message);const o=fa(i,"onSessionSettleRequest()");if(o)throw new Error(o.message);if(Qe(s)){const{message:e}=na("EXPIRED","onSessionSettleRequest()");throw new Error(e)}}),Xu(this,"isValidUpdate",async e=>{if(!va(e)){const{message:t}
2=na("MISSING_OR_INVALID","update() params: ".concat(e));throw new Error(t)}const{topic:t,namespaces:n}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const i=this.client.session.get(t),s=fa(n,"update()");if(s)throw new Error(s.message);const r=ba(i.requiredNamespaces,n,"update()");if(r)throw new Error(r.message)}),Xu(this,"isValidExtend",async e=>{if(!va(e)){const{message:t}=na("MISSING_OR_INVALID","extend() params: ".concat(e));throw new Error(t)}const{topic:t}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t)}),Xu(this,"isValidRequest",async e=>{if(!va(e)){const{message:t}=na("MISSING_OR_INVALID","request() params: ".concat(e));throw new Error(t)}const{topic:t,request:n,chainId:i,expiry:s}=e;this.checkRecentlyDeleted(t),await this.isValidSessionTopic(t);const{namespaces:r}=this.client.session.get(t);if(!ma(r,i)){const{message:e}=na("MISSING_OR_INVALID","request() chainId: ".concat(i));throw new Error(e)}if(!function(e){return!(oa(e)||!aa(e.method,!1))}(n)){const{message:e}=na("MISSING_OR_INVALID","request() ".concat(JSON.stringify(n)));throw new Error(e)}if(!ya(r,i,n.method)){const{message:e}=na("MISSING_OR_INVALID","request() method: ".concat(n.method));throw new Error(e)}if(s&&!function(e,t){return ca(e,!1)&&e<=t.max&&e>=t.min}(s,Du)){const{message:e}=na("MISSING_OR_INVALID","request() expiry: ".concat(s,". Expiry must be a number (in seconds) between ").concat(Du.min," and ").concat(Du.max));throw new Error(e)}}),Xu(this,"isValidRespond",async e=>{var t;if(!va(e)){const{message:t}=na("MISSING_OR_INVALID","respond() params: ".concat(e));throw new Error(t)}const{topic:n,response:i}=e;try{await this.isValidSessionTopic(n)}catch(s){throw null!=(t=null===e||void 0===e?void 0:e.response)&&t.id&&this.cleanupAfterResponse(e),s}if(!function(e){return!(oa(e)||oa(e.result)&&oa(e.error)||!ca(e.id,!1)||!aa(e.jsonrpc,!1))}(i)){const{message:e}=na("MISSING_OR_INVALID","respond() response: ".concat(JSON.stringify(i)));throw new Error(e)}}),Xu(this,"isValidPing",async e=>{if(!va(e)){const{message:t}=na("MISSING_OR_INVALID","ping() params: ".concat(e));throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),Xu(this,"isValidEmit",async e=>{if(!va(e)){const{message:t}=na("MISSING_OR_INVALID","emit() params: ".concat(e));throw new Error(t)}const{topic:t,event:n,chainId:i}=e;await this.isValidSessionTopic(t);const{namespaces:s}=this.client.session.get(t);if(!ma(s,i)){const{message:e}=na("MISSING_OR_INVALID","emit() chainId: ".concat(i));throw new Error(e)}if(!function(e){return!(oa(e)||!aa(e.name,!1))}(n)){const{message:e}=na("MISSING_OR_INVALID","emit() event: ".concat(JSON.stringify(n)));throw new Error(e)}if(!wa(s,i,n.name)){const{message:e}=na("MISSING_OR_INVALID","emit() event: ".concat(JSON.stringify(n)));throw new Error(e)}}),Xu(this,"isValidDisconnect",async e=>{if(!va(e)){const{message:t}=na("MISSING_OR_INVALID","disconnect() params: ".concat(e));throw new Error(t)}const{topic:t}=e;await this.isValidSessionOrPairingTopic(t)}),Xu(this,"isValidAuthenticate",e=>{const{chains:t,uri:n,domain:i,nonce:s}=e;if(!Array.isArray(t)||0===t.length)throw new Error("chains is required and must be a non-empty array");if(!aa(n,!1))throw new Error("uri is required parameter");if(!aa(i,!1))throw new Error("domain is required parameter");if(!aa(s,!1))throw new Error("nonce is required parameter");if([...new Set(t.map(e=>be(e).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:r}=be(t[0]);if("eip155"!==r)throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),Xu(this,"getVerifyContext",async e=>{const{attestationId:t,hash:n,encryptedId:i,metadata:s,transportType:r}=e,o={verified:{verifyUrl:s.verifyUrl||bc,validation:"UNKNOWN",origin:s.url||""}};try{if(r===Za.link_mode){const e=this.getAppLinkIfEnabled(s,r);return o.verified.validation=e&&new URL(e).origin===new URL(s.url).origin?"VALID":"INVALID",o}const e=await this.client.core.verify.resolve({attestationId:t,hash:n,encryptedId:i,verifyUrl:s.verifyUrl});e&&(o.verified.origin=e.origin,o.verified.isScam=e.isScam,o.verified.validation=e.origin===new URL(s.url).origin?"VALID":"INVALID")}catch(a){this.client.logger.warn(a)}return this.client.logger.debug("Verify context: ".concat(JSON.stringify(o))),o}),Xu(this,"validateSessionProps",(e,t)=>{Object.values(e).forEach((n,i)=>{if(null==n){const{message:s}=na("MISSING_OR_INVALID","".concat(t," must contain an existing value for each key. Received: ").concat(n," for key ").concat(Object.keys(e)[i]));throw new Error(s)}})}),Xu(this,"getPendingAuthRequest",e=>{const t=this.client.auth.requests.get(e);return"object"==typeof t?t:void 0}),Xu(this,"addToRecentlyDeleted",(e,t)=>{if(this.recentlyDeletedMap.set(e,t),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let e=0;const t=this.recentlyDeletedLimit/2;
2for(const n of this.recentlyDeletedMap.keys()){if(e++>=t)break;this.recentlyDeletedMap.delete(n)}}}),Xu(this,"checkRecentlyDeleted",e=>{const t=this.recentlyDeletedMap.get(e);if(t){const{message:n}=na("MISSING_OR_INVALID","Record was recently deleted - ".concat(t,": ").concat(e));throw new Error(n)}}),Xu(this,"isLinkModeEnabled",(e,t)=>{var i,s,r,o,a,c,l,d,h;return!(!e||t!==Za.link_mode)&&(!0===(null==(s=null==(i=this.client.metadata)?void 0:i.redirect)?void 0:s.linkMode)&&void 0!==(null==(o=null==(r=this.client.metadata)?void 0:r.redirect)?void 0:o.universal)&&""!==(null==(c=null==(a=this.client.metadata)?void 0:a.redirect)?void 0:c.universal)&&void 0!==(null==(l=null===e||void 0===e?void 0:e.redirect)?void 0:l.universal)&&""!==(null==(d=null===e||void 0===e?void 0:e.redirect)?void 0:d.universal)&&!0===(null==(h=null===e||void 0===e?void 0:e.redirect)?void 0:h.linkMode)&&this.client.core.linkModeSupportedApps.includes(e.redirect.universal)&&typeof(null==n.g?void 0:n.g.Linking)<"u")}),Xu(this,"getAppLinkIfEnabled",(e,t)=>{var n;return this.isLinkModeEnabled(e,t)?null==(n=null===e||void 0===e?void 0:e.redirect)?void 0:n.universal:void 0}),Xu(this,"handleLinkModeMessage",e=>{let{url:t}=e;if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;const n=it(t,"topic")||"",i=decodeURIComponent(it(t,"wc_ev")||""),s=this.client.session.keys.includes(n);s&&this.client.session.update(n,{transportType:Za.link_mode}),this.client.core.dispatchEnvelope({topic:n,message:i,sessionExists:s})}),Xu(this,"registerLinkModeListeners",async()=>{var e;if(rt()||We()&&null!=(e=this.client.metadata.redirect)&&e.linkMode){const e=null==n.g?void 0:n.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)}}}),Xu(this,"getTVFParams",(e,t,n)=>{var i,s,r;if(null==(i=t.request)||!i.method)return{};const o={correlationId:e,rpcMethods:[t.request.method],chainId:t.chainId};try{const e=this.extractTxHashesFromResult(t.request,n);o.txHashes=e,o.contractAddresses=this.isValidContractData(t.request.params)?[null==(r=null==(s=t.request.params)?void 0:s[0])?void 0:r.to]:[]}catch(a){this.client.logger.warn("Error getting TVF params",a)}return o}),Xu(this,"isValidContractData",e=>{var t;if(!e)return!1;try{const n=(null===e||void 0===e?void 0:e.data)||(null==(t=null===e||void 0===e?void 0:e[0])?void 0:t.data);if(!n.startsWith("0x"))return!1;const i=n.slice(2);return!!/^[0-9a-fA-F]*$/.test(i)&&i.length%2===0}catch(n){}return!1}),Xu(this,"extractTxHashesFromResult",(t,n)=>{var i;try{if(!n)return[];const s=t.method,r=Mu[s];if("sui_signTransaction"===s)return[ri(n.transactionBytes)];if("near_signTransaction"===s)return[oi(n)];if("near_signTransactions"===s)return n.map(e=>oi(e));if("xrpl_signTransactionFor"===s||"xrpl_signTransaction"===s)return[null==(i=n.tx_json)?void 0:i.hash];if("polkadot_signTransaction"===s)return[Ta({transaction:t.params.transactionPayload,signature:n.signature})];if("algo_signTxn"===s)return sa(n)?n.map(e=>ai(e)):[ai(n)];if("cosmos_signDirect"===s)return[li(n)];if("wallet_sendCalls"===s)return function(t){var n,i;const s=[];try{if("string"==typeof t)return s.push(t),s;if("object"!=typeof t)return s;null!=t&&t.id&&s.push(t.id);const e=null==(i=null==(n=null===t||void 0===t?void 0:t.capabilities)?void 0:n.caip345)?void 0:i.transactionHashes;e&&s.push(...e)}catch(e){console.warn("getWalletSendCallsHashes failed: ",e)}return s}(n);if("string"==typeof n)return[n];const o=n[r.key];if(sa(o))return"solana_signAllTransactions"===s?o.map(e=>function(e){const t=atob(e),n=new Uint8Array(t.length);for(let o=0;o<t.length;o++)n[o]=t.charCodeAt(o);const i=n[0];if(0===i)throw new Error("No signatures found");const s=1+64*i;if(n.length<s)throw new Error("Transaction data too short for claimed signature count");if(n.length<100)throw new Error("Transaction too short");const r=Buffer.from(e,"base64").slice(1,65);return ue.A.encode(r)}(e)):o;if("string"==typeof o)return[o]}catch(S){this.client.logger.warn("Error extracting tx hashes from result",S)}return[]})}async processPendingMessageEvents(){try{const t=this.client.session.keys,n=this.client.core.relayer.messages.getWithoutAck(t);for(const[i,s]of Object.entries(n))for(const t of s)try{await this.onProviderMessageEvent({topic:i,message:t,publishedAt:Date.now()})}catch(e){this.client.logger.warn("Error processing pending message event for topic: ".concat(i,", message: ").concat(t))}}catch(t){this.client.logger.warn("processPendingMessageEvents failed",t)}}isInitialized(){if(!this.initialized){const{message:e}=na("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Fa,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){const{topic:t,message:n,attestation:i,transportType:s}=e,{publicKey:r}=this.client.auth.authKeys.keys.includes(ju)?this.client.auth.authKeys.get(ju):{responseTopic:void 0,publicKey:void 0};try{const e=await this.client.core.crypto.decode(t,n,{receiverPublicKey:r,encoding:s===Za.link_mode?lo:co});(0,ka.isJsonRpcRequest)(e)?(this.client.core.history.set(t,e),await this.onRelayEventRequest({topic:t,payload:e,attestation:i,transportType:s,encryptedId:fo(n)})):(0,ka.isJsonRpcResponse)(e)?(await this.client.core.history.resolve(e),await this.onRelayEventResponse({topic:t,payload:e,transportType:s}),this.client.core.history.delete(t,e.id)):await this.onRelayEventUnknownPayload({topic:t,payload:e,transportType:s}),await this.client.core.relayer.messages.ack(t,n)}catch(In){this.client.logger.error(In)}}registerExpirerEvents(){this.client.core.expirer.on(mc,async e=>
2{const{topic:t,id:n}=Xe(e.target);return n&&this.client.pendingRequest.keys.includes(n)?await this.deletePendingSessionRequest(n,na("EXPIRED"),!0):n&&this.client.auth.requests.keys.includes(n)?await this.deletePendingAuthRequest(n,na("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})):n&&(await this.deleteProposal(n,!0),this.client.events.emit("proposal_expire",{id:n})))})}registerPairingEvents(){this.client.core.pairing.events.on(ac,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(lc,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!aa(e,!1)){const{message:t}=na("MISSING_OR_INVALID","pairing topic should be a string: ".concat(e));throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=na("NO_MATCHING_KEY","pairing topic doesn't exist: ".concat(e));throw new Error(t)}if(Qe(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=na("EXPIRED","pairing topic: ".concat(e));throw new Error(t)}}async isValidSessionTopic(e){if(!aa(e,!1)){const{message:t}=na("MISSING_OR_INVALID","session topic should be a string: ".concat(e));throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=na("NO_MATCHING_KEY","session topic doesn't exist: ".concat(e));throw new Error(t)}if(Qe(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=na("EXPIRED","session topic: ".concat(e));throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=na("MISSING_OR_INVALID","session topic does not exist in keychain: ".concat(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(aa(e,!1)){const{message:t}=na("NO_MATCHING_KEY","session or pairing topic doesn't exist: ".concat(e));throw new Error(t)}{const{message:t}=na("MISSING_OR_INVALID","session or pairing topic should be a string: ".concat(e));throw new Error(t)}}this.isValidPairingTopic(e)}}async isValidProposalId(e){if(!function(e){return"number"==typeof e}(e)){const{message:t}=na("MISSING_OR_INVALID","proposal id should be a number: ".concat(e));throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=na("NO_MATCHING_KEY","proposal id doesn't exist: ".concat(e));throw new Error(t)}if(Qe(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=na("EXPIRED","proposal id: ".concat(e));throw new Error(t)}}}class Qu extends Gh{constructor(e,t){super(e,t,"proposal",Tu),this.core=e,this.logger=t}}class ep extends Gh{constructor(e,t){super(e,t,"session",Tu),this.core=e,this.logger=t}}class tp extends Gh{constructor(e,t){super(e,t,"request",Tu,e=>e.id),this.core=e,this.logger=t}}class np extends Gh{constructor(e,t){super(e,t,"authKeys",Fu,()=>ju),this.core=e,this.logger=t}}class ip extends Gh{constructor(e,t){super(e,t,"pairingTopics",Fu),this.core=e,this.logger=t}}class sp extends Gh{constructor(e,t){super(e,t,"requests",Fu,e=>e.id),this.core=e,this.logger=t}}var rp=Object.defineProperty,op=(e,t,n)=>((e,t,n)=>t in e?rp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class ap{constructor(e,t){this.core=e,this.logger=t,op(this,"authKeys"),op(this,"pairingTopics"),op(this,"requests"),this.authKeys=new np(this.core,this.logger),this.pairingTopics=new ip(this.core,this.logger),this.requests=new sp(this.core,this.logger)}
2async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var cp=Object.defineProperty,lp=(e,t,n)=>((e,t,n)=>t in e?cp(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class dp extends _{constructor(e){super(e),lp(this,"protocol","wc"),lp(this,"version",2),lp(this,"name",Ou),lp(this,"metadata"),lp(this,"core"),lp(this,"logger"),lp(this,"events",new s.EventEmitter),lp(this,"engine"),lp(this,"session"),lp(this,"proposal"),lp(this,"pendingRequest"),lp(this,"auth"),lp(this,"signConfig"),lp(this,"on",(e,t)=>this.events.on(e,t)),lp(this,"once",(e,t)=>this.events.once(e,t)),lp(this,"off",(e,t)=>this.events.off(e,t)),lp(this,"removeListener",(e,t)=>this.events.removeListener(e,t)),lp(this,"removeAllListeners",e=>this.events.removeAllListeners(e)),lp(this,"connect",async e=>{try{return await this.engine.connect(e)}catch(t){throw this.logger.error(t.message),t}}),lp(this,"pair",async e=>{try{return await this.engine.pair(e)}catch(t){throw this.logger.error(t.message),t}}),lp(this,"approve",async e=>{try{return await this.engine.approve(e)}catch(t){throw this.logger.error(t.message),t}}),lp(this,"reject",async e=>{try{return await this.engine.reject(e)}catch(t){throw this.logger.error(t.message),t}}),lp(this,"update",async e=>{try{return await this.engine.update(e)}catch(t){throw this.logger.error(t.message),t}}),lp(this,"extend",async e=>{try{return await this.engine.extend(e)}catch(t){throw this.logger.error(t.message),t}}),lp(this,"request",async e=>{try{return await this.engine.request(e)}catch(t){throw this.logger.error(t.message),t}}),lp(this,"respond",async e=>{try{return await this.engine.respond(e)}catch(t){throw this.logger.error(t.message),t}}),lp(this,"ping",async e=>{try{return await this.engine.ping(e)}catch(t){throw this.logger.error(t.message),t}}),lp(this,"emit",async e=>{try{return await this.engine.emit(e)}catch(t){throw this.logger.error(t.message),t}}),lp(this,"disconnect",async e=>{try{return await this.engine.disconnect(e)}catch(t){throw this.logger.error(t.message),t}}),lp(this,"find",e=>{try{return this.engine.find(e)}catch(t){throw this.logger.error(t.message),t}}),lp(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(An){throw this.logger.error(An.message),An}}),lp(this,"authenticate",async(e,t)=>{try{return await this.engine.authenticate(e,t)}catch(S){throw this.logger.error(S.message),S}}),lp(this,"formatAuthMessage",e=>{try{return this.engine.formatAuthMessage(e)}catch(t){throw this.logger.error(t.message),t}}),lp(this,"approveSessionAuthenticate",async e=>{try{return await this.engine.approveSessionAuthenticate(e)}catch(t){throw this.logger.error(t.message),t}}),lp(this,"rejectSessionAuthenticate",async e=>{try{return await this.engine.rejectSessionAuthenticate(e)}catch(t){throw this.logger.error(t.message),t}}),this.name=(null===e||void 0===e?void 0:e.name)||Ou,this.metadata=je(null===e||void 0===e?void 0:e.metadata),this.signConfig=null===e||void 0===e?void 0:e.signConfig;const t=typeof(null===e||void 0===e?void 0:e.logger)<"u"&&"string"!=typeof(null===e||void 0===e?void 0:e.logger)?e.logger:(0,c.h6)((0,c.iP)({level:(null===e||void 0===e?void 0:e.logger)||ku}));this.core=(null===e||void 0===e?void 0:e.core)||new Su(e),this.logger=(0,c.U5)(t,this.name),this.session=new ep(this.core,this.logger),this.proposal=new Qu(this.core,this.logger),this.pendingRequest=new tp(this.core,this.logger),this.engine=new Zu(this),this.auth=new ap(this.core,this.logger)}static async init(e){const t=new dp(e);return await t.initialize(),t}get context(){return(0,c.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")}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}}var hp=n(77417);const up="error",pp="".concat("wc","@2:").concat("universal_provider",":"),fp="https://rpc.walletconnect.org/v1/",gp="generic",vp="".concat(fp,"bundler"),mp="call_status",yp="default_chain_changed";function wp(e){return null==e||"object"!=typeof e&&"function"!=typeof e}function bp(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.prototype.propertyIsEnumerable.call(e,t))}
2function Ep(e){return null==e?void 0===e?"[object Undefined]":"[object Null]":Object.prototype.toString.call(e)}const Cp="[object RegExp]",Ap="[object String]",Ip="[object Number]",Np="[object Boolean]",Sp="[object Arguments]",_p="[object Symbol]",Tp="[object Date]",Op="[object Map]",kp="[object Set]",Pp="[object Array]",Rp="[object ArrayBuffer]",xp="[object Object]",Up="[object DataView]",Dp="[object Uint8Array]",Lp="[object Uint8ClampedArray]",Wp="[object Uint16Array]",Mp="[object Uint32Array]",Bp="[object Int8Array]",Fp="[object Int16Array]",jp="[object Int32Array]",Hp="[object Float32Array]",qp="[object Float64Array]";function Vp(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function Kp(e,t,n){let i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:new Map,s=arguments.length>4&&void 0!==arguments[4]?arguments[4]:void 0;const r=null===s||void 0===s?void 0:s(e,t,n,i);if(null!=r)return r;if(wp(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 r=0;r<e.length;r++)t[r]=Kp(e[r],r,n,i,s);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[r,o]of e)t.set(r,Kp(o,r,n,i,s));return t}if(e instanceof Set){const t=new Set;i.set(e,t);for(const r of e)t.add(Kp(r,void 0,n,i,s));return t}if(typeof Buffer<"u"&&Buffer.isBuffer(e))return e.subarray();if(Vp(e)){const t=new(Object.getPrototypeOf(e).constructor)(e.length);i.set(e,t);for(let r=0;r<e.length;r++)t[r]=Kp(e[r],r,n,i,s);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),zp(t,e,n,i,s),t}if(typeof File<"u"&&e instanceof File){const t=new File([e],e.name,{type:e.type});return i.set(e,t),zp(t,e,n,i,s),t}if(e instanceof Blob){const t=new Blob([e],{type:e.type});return i.set(e,t),zp(t,e,n,i,s),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,zp(t,e,n,i,s),t}if("object"==typeof e&&function(e){switch(Ep(e)){case Sp:case Pp:case Rp:case Up:case Np:case Tp:case Hp:case qp:case Bp:case Fp:case jp:case Op:case Ip:case xp:case Cp:case kp:case Ap:case _p:case Dp:case Lp:case Wp:case Mp:return!0;default:return!1}}(e)){const t=Object.create(Object.getPrototypeOf(e));return i.set(e,t),zp(t,e,n,i,s),t}return e}function zp(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e,i=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;const r=[...Object.keys(t),...bp(t)];for(let o=0;o<r.length;o++){const a=r[o],c=Object.getOwnPropertyDescriptor(e,a);(null==c||c.writable)&&(e[a]=Kp(t[a],a,n,i,s))}}function $p(e,t){return function(e,t){return Kp(e,void 0,e,new Map,t)}(e,(n,i,s,r)=>{const o=null===t||void 0===t?void 0:t(n,i,s,r);if(null!=o)return o;if("object"==typeof e)switch(Object.prototype.toString.call(e)){case Ip:case Ap:case Np:{const t=new e.constructor(null===e||void 0===e?void 0:e.valueOf());return zp(t,e),t}case Sp:{const t={};return zp(t,e),t.length=e.length,t[Symbol.iterator]=e[Symbol.iterator],t}default:return}})}function Gp(e){return $p(e)}function Jp(e){return null!==e&&"object"==typeof e&&"[object Arguments]"===Ep(e)}function Yp(e){return"object"==typeof e&&null!==e}function Xp(){}function Zp(e){return Vp(e)}function Qp(e){if("object"!=typeof e||null==e)return!1;if(null===Object.getPrototypeOf(e))return!0;if("[object Object]"!==Object.prototype.toString.call(e)){var t;const n=e[Symbol.toStringTag];return!(null==n||null===(t=Object.getOwnPropertyDescriptor(e,Symbol.toStringTag))||void 0===t||!t.writable)&&e.toString()==="[object ".concat(n,"]")}let n=e;for(;null!==Object.getPrototypeOf(n);)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(e)===n}function ef(e,t,n,s){if(wp(e)&&(e=Object(e)),null==t||"object"!=typeof t)return e;if(s.has(t))return function(e){if(wp(e))return e;if(Array.isArray(e)||Vp(e)||e instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&e instanceof SharedArrayBuffer)return e.slice(0);const t=Object.getPrototypeOf(e),n=t.constructor;if(e instanceof Date||e instanceof Map||e instanceof Set)return new n(e);if(e instanceof RegExp){const t=new n(e);return t.lastIndex=e.lastIndex,t}if(e instanceof DataView)return new n(e.buffer.slice(0));if(e instanceof Error){const t=new n(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 n([e],e.name,{type:e.type,lastModified:e.lastModified});if("object"==typeof e){const n=Object.create(t);return Object.assign(n,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++){var r;t[e]=null!==(r=t[e])&&void 0!==r?r:void 0}}const o=[...Object.keys(t),...bp(t)];for(let a=0;a<o.length;a++){const r=o[a];let c=t[r],l=e[r];if(Jp(c)&&(c=(0,i.A)({},c)),Jp(l)&&(l=(0,i.A)({},l)),typeof Buffer<"u"&&Buffer.isBuffer(c)&&(c=Gp(c)),Array.isArray(c))if("object"==typeof l&&null!=l){const e=[],t=Reflect.ownKeys(l);for(let n=0;n<t.length;n++){const i=t[n];e[i]=l[i]}l=e}else l=[];const d=n(l,c,r,e,t,s);null!=d?e[r]=d:Array.isArray(c)||Yp(l)&&Yp(c)?e[r]=ef(l,c,n,s):null==l&&Qp(c)?e[r]=ef({},c,n,s):null==l&&Zp(c)?e[r]=Gp(c):(void 0===l||void 0!==c)&&(e[r]=c)}return e}function tf(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return function(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];const s=n.slice(0,-1),r=n[n.length-1];let o=e;for(let a=0;a<s.length;a++)o=ef(o,s[a],r,new Map);return o}(e,...n,Xp)}var nf=Object.defineProperty,sf=Object.defineProperties,rf=Object.getOwnPropertyDescriptors,of=Object.getOwnPropertySymbols,af=Object.prototype.hasOwnProperty,cf=Object.prototype.propertyIsEnumerable,lf=(e,t,n)=>t in e?nf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,df=(e,t)=>
2{for(var n in t||(t={}))af.call(t,n)&&lf(e,n,t[n]);if(of)for(var n of of(t))cf.call(t,n)&&lf(e,n,t[n]);return e},hf=(e,t)=>sf(e,rf(t));function uf(e,t,n){var i;const s=be(e);return(null==(i=t.rpcMap)?void 0:i[s.reference])||"".concat(fp,"?chainId=").concat(s.namespace,":").concat(s.reference,"&projectId=").concat(n)}function pf(e){return e.map(e=>"".concat(e.split(":")[0],":").concat(e.split(":")[1]))}function ff(e){return Object.fromEntries(Object.entries(e).filter(e=>{let[t,n]=e;var i,s;return(null==(i=null===n||void 0===n?void 0:n.chains)?void 0:i.length)&&(null==(s=null===n||void 0===n?void 0:n.chains)?void 0:s.length)>0}))}function gf(){let e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return tf(ff(vf(arguments.length>0&&void 0!==arguments[0]?arguments[0]:{})),ff(vf(e)))}function vf(e){var t,n,i,s,r;const o={};if(!ra(e))return o;for(const[a,c]of Object.entries(e)){const e=Yo(a)?[a]:c.chains,l=c.methods||[],d=c.events||[],h=c.rpcMap||{},u=Xo(a);o[u]=hf(df(df({},o[u]),c),{chains:tt(e,null==(t=o[u])?void 0:t.chains),methods:tt(l,null==(n=o[u])?void 0:n.methods),events:tt(d,null==(i=o[u])?void 0:i.events)}),(ra(h)||ra((null==(s=o[u])?void 0:s.rpcMap)||{}))&&(o[u].rpcMap=df(df({},h),null==(r=o[u])?void 0:r.rpcMap))}return o}function mf(e){return e.includes(":")?e.split(":")[2]:e}function yf(e){const t={};for(const[n,i]of Object.entries(e)){const e=i.methods||[],s=i.events||[],r=i.accounts||[],o=Yo(n)?[n]:i.chains?i.chains:pf(i.accounts);t[n]={chains:o,methods:e,events:s,accounts:r}}return t}function wf(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 bf={},Ef=e=>bf[e],Cf=(e,t)=>{bf[e]=t};var Af=Object.defineProperty,If=Object.getOwnPropertySymbols,Nf=Object.prototype.hasOwnProperty,Sf=Object.prototype.propertyIsEnumerable,_f=(e,t,n)=>t in e?Af(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,Tf=(e,t)=>{for(var n in t||(t={}))Nf.call(t,n)&&_f(e,n,t[n]);if(If)for(var n of If(t))Sf.call(t,n)&&_f(e,n,t[n]);return e};const Of="eip155",kf=["atomic","flow-control","paymasterService","sessionKeys","auxiliaryFunds"],Pf=e=>e&&e.startsWith("0x")?BigInt(e).toString(10):e,Rf=e=>e&&e.startsWith("0x")?e:"0x".concat(BigInt(e).toString(16)),xf=e=>Object.keys(e).filter(e=>kf.includes(e)).reduce((t,n)=>(t[n]=Uf(e[n]),t),{}),Uf=e=>"string"==typeof e&&function(e){try{const t=JSON.parse(e);return"object"==typeof t&&null!==t&&!Array.isArray(t)}catch(t){return!1}}(e)?JSON.parse(e):e;var Df=Object.defineProperty,Lf=(e,t,n)=>((e,t,n)=>t in e?Df(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);let Wf;class Mf{constructor(e){Lf(this,"storage"),this.storage=e}async getItem(e){return await this.storage.getItem(e)}async setItem(e,t){return await this.storage.setItem(e,t)}async removeItem(e){return await this.storage.removeItem(e)}static getStorage(e){return Wf||(Wf=new Mf(e)),Wf}}var Bf=Object.defineProperty,Ff=Object.defineProperties,jf=Object.getOwnPropertyDescriptors,Hf=Object.getOwnPropertySymbols,qf=Object.prototype.hasOwnProperty,Vf=Object.prototype.propertyIsEnumerable,Kf=(e,t,n
2)=>t in e?Bf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;async function zf(e,t){const n=be(e.result.capabilities.caip345.caip2),i=e.result.capabilities.caip345.transactionHashes,s=await Promise.allSettled(i.map(e=>async function(e,t,n){return await n(parseInt(e)).request((0,ka.formatJsonRpcRequest)("eth_getTransactionReceipt",[t]))}(n.reference,e,t))),r=s.filter(e=>"fulfilled"===e.status).map(e=>e.value).filter(e=>e);s.filter(e=>"rejected"===e.status).forEach(e=>console.warn("Failed to fetch transaction receipt:",e.reason));const o=!r.length||r.some(e=>!e),a=r.every(e=>"0x1"===(null===e||void 0===e?void 0:e.status)),c=r.every(e=>"0x0"===(null===e||void 0===e?void 0:e.status)),l=r.some(e=>"0x0"===(null===e||void 0===e?void 0:e.status));let d;return o?d=100:a?d=200:c?d=500:l&&(d=600),{id:e.result.id,version:e.request.version,atomic:e.request.atomicRequired,chainId:e.request.chainId,capabilities:e.result.capabilities,receipts:r,status:d}}async function $f(e){let{sendCalls:t,storage:n}=e;const i=await n.getItem(mp);await n.setItem(mp,((e,t)=>Ff(e,jf(t)))(((e,t)=>{for(var n in t||(t={}))qf.call(t,n)&&Kf(e,n,t[n]);if(Hf)for(var n of Hf(t))Vf.call(t,n)&&Kf(e,n,t[n]);return e})({},i),{[t.result.id]:{request:t.request,result:t.result,expiry:Ze(86400)}}))}async function Gf(e){let{resultId:t,storage:n}=e;const i=await n.getItem(mp),s=null===i||void 0===i?void 0:i[t];if(s&&!Qe(s.expiry))return s;await async function(e){let{resultId:t,storage:n}=e;const i=await n.getItem(mp);if(i){delete i[t],await n.setItem(mp,i);for(const e in i)Qe(i[e].expiry)&&delete i[e];await n.setItem(mp,i)}}({resultId:t,storage:n})}var Jf=Object.defineProperty,Yf=Object.defineProperties,Xf=Object.getOwnPropertyDescriptors,Zf=Object.getOwnPropertySymbols,Qf=Object.prototype.hasOwnProperty,eg=Object.prototype.propertyIsEnumerable,tg=(e,t,n)=>t in e?Jf(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,ng=(e,t)=>{for(var n in t||(t={}))Qf.call(t,n)&&tg(e,n,t[n]);if(Zf)for(var n of Zf(t))eg.call(t,n)&&tg(e,n,t[n]);return e},ig=(e,t)=>Yf(e,Xf(t)),sg=(e,t,n)=>tg(e,"symbol"!=typeof t?t+"":t,n);class rg{constructor(e){sg(this,"name","eip155"),sg(this,"client"),sg(this,"chainId"),sg(this,"namespace"),sg(this,"httpProviders"),sg(this,"events"),sg(this,"storage"),this.namespace=e.namespace,this.events=Ef("events"),this.client=Ef("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain()),this.storage=Mf.getStorage(this.client.core.storage)}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);case"wallet_sendCalls":return await this.sendCalls(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);const n=this.chainId;this.chainId=parseInt(e),this.events.emit(yp,{currentCaipChainId:"".concat(this.name,":").concat(e),previousCaipChainId:"".concat(this.name,":").concat(n)})}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 n=t||uf("".concat(this.name,":").concat(e),this.namespace,this.client.core.projectId);if(!n)throw new Error("No RPC url provided for chainId: ".concat(e));return new Oa.F(new hp.V(n,Ef("disableProviderPing")))}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var n;const i=parseInt(function(e){return e.includes(":")?e.split(":")[1]:e}(t));e[i]=this.createHttpProvider(i,null==(n=this.namespace.rpcMap)?void 0:n[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(e){const t=e||this.chainId;return this.httpProviders[t]||(this.httpProviders=ig(ng({},this.httpProviders),{[t]:this.createHttpProvider(t)}),this.httpProviders[t])}async handleSwitchChain(e){var t,n;let i=e.request.params?null==(t=e.request.params[0])?void 0:t.chainId:"0x0";i=i.startsWith("0x")?i:"0x".concat(i);const s=parseInt(i,16);if(this.isChainApproved(s))this.setDefaultChain("".concat(s));else{if(!this.namespace.methods.includes("wallet_switchEthereumChain"))throw new Error("Failed to switch to chain 'eip155:".concat(s,"'. 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==(n=this.namespace.chains)?void 0:n[0]}),this.setDefaultChain("".concat(s))}return null}isChainApproved(e){return this.namespace.chains.includes("".concat(this.name,":").concat(e))}async getCapabilities(e){var t,n,i,s,r;const o=null==(n=null==(t=e.request)?void 0:t.params)?void 0:n[0],a=(null==(s=null==(i=e.request)?void 0:i.params)?void 0:s[1])||[];if(!o)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const c=this.client.session.get(e.topic),l=(null==(r=null===c||void 0===c?void 0:c.sessionProperties)?void 0:r.capabilities)||{},d="".concat(o).concat(a.join(",")),h=null===l||void 0===l?void 0:l[d];if(h)return h;let u;
2try{u=((e,t,n)=>{const{sessionProperties:i={},scopedProperties:s={}}=e,r={};if(!ra(s)&&!ra(i))return;const o=xf(i);for(const a of n){const e=Pf(a);if(!e)continue;r[Rf(e)]=o;const n=null===s||void 0===s?void 0:s["".concat(Of,":").concat(e)];if(n){const i=null===n||void 0===n?void 0:n["".concat(Of,":").concat(e,":").concat(t)];r[Rf(e)]=Tf(Tf({},r[Rf(e)]),xf(i||n))}}for(const[a,c]of Object.entries(r))0===Object.keys(c).length&&delete r[a];return Object.keys(r).length>0?r:void 0})(c,o,a)}catch(f){console.warn("Failed to extract capabilities from session",f)}if(u)return u;const p=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:ig(ng({},c.sessionProperties||{}),{capabilities:ig(ng({},l||{}),{[d]:p})})})}catch(f){console.warn("Failed to update session with capabilities",f)}return p}async getCallStatus(e){var t,n,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(c){console.warn("Failed to fetch call status from bundler",c,t)}}const o=null==(n=s.sessionProperties)?void 0:n.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(u){console.warn("Failed to fetch call status from custom bundler",u,o)}const a=await Gf({resultId:null==(i=e.request.params)?void 0:i[0],storage:this.storage});if(a)try{return await zf(a,this.getHttpProvider.bind(this))}catch(u){console.warn("Failed to fetch call status from stored send calls",u,a)}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 n;const i=new URL(e),s=await fetch(i,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify((0,ka.formatJsonRpcRequest)("eth_getUserOperationReceipt",[null==(n=t.request.params)?void 0:n[0]]))});if(!s.ok)throw new Error("Failed to fetch user operation receipt - ".concat(s.status));return await s.json()}getBundlerUrl(e,t){return"".concat(vp,"?projectId=").concat(this.client.core.projectId,"&chainId=").concat(e,"&bundler=").concat(t)}async sendCalls(e){var t,n,i;const s=await this.client.request(e),r=null==(t=e.request.params)?void 0:t[0],o=null===s||void 0===s?void 0:s.id,a=(null===s||void 0===s?void 0:s.capabilities)||{},c=null==(n=null===a||void 0===a?void 0:a.caip345)?void 0:n.caip2,l=null==(i=null===a||void 0===a?void 0:a.caip345)?void 0:i.transactionHashes;return!o||!c||!(null!=l&&l.length)||await $f({sendCalls:{request:r,result:s},storage:this.storage}),s}}var og=Object.defineProperty,ag=(e,t,n)=>((e,t,n)=>t in e?og(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n)(e,"symbol"!=typeof t?t+"":t,n);class cg{constructor(e){ag(this,"name",gp),ag(this,"client"),ag(this,"httpProviders"),ag(this,"events"),ag(this,"namespace"),ag(this,"chainId"),this.namespace=e.namespace,this.events=Ef("events"),this.client=Ef("client"),this.chainId=this.getDefaultChain(),this.name=this.getNamespaceName(),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);const n=this.chainId;this.chainId=e,this.events.emit(yp,{currentCaipChainId:"".concat(this.name,":").concat(e),previousCaipChainId:"".concat(this.name,":").concat(n)})}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]}getNamespaceName(){const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return be(e).namespace}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 n={};return null==(t=null==(e=this.namespace)?void 0:e.accounts)||t.forEach(e
2=>{var t,i;const s=be(e),r=null==(i=null==(t=this.namespace)?void 0:t.rpcMap)?void 0:i["".concat(s.namespace,":").concat(s.reference)];n[s.reference]=this.createHttpProvider(e,r)}),n}getHttpProvider(e){const t=be(e).reference,n=this.httpProviders[t];if(typeof n>"u")throw new Error("JSON-RPC provider for ".concat(e," not found"));return n}setHttpProvider(e,t){const n=this.createHttpProvider(e,t);n&&(this.httpProviders[e]=n)}createHttpProvider(e,t){const n=t||uf(e,this.namespace,this.client.core.projectId);if(!n)throw new Error("No RPC url provided for chainId: ".concat(e));return new Oa.F(new hp.A(n,Ef("disableProviderPing")))}}var lg=Object.defineProperty,dg=Object.defineProperties,hg=Object.getOwnPropertyDescriptors,ug=Object.getOwnPropertySymbols,pg=Object.prototype.hasOwnProperty,fg=Object.prototype.propertyIsEnumerable,gg=(e,t,n)=>t in e?lg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,vg=(e,t)=>{for(var n in t||(t={}))pg.call(t,n)&&gg(e,n,t[n]);if(ug)for(var n of ug(t))fg.call(t,n)&&gg(e,n,t[n]);return e},mg=(e,t)=>dg(e,hg(t)),yg=(e,t,n)=>gg(e,"symbol"!=typeof t?t+"":t,n);class wg{constructor(e){yg(this,"client"),yg(this,"namespaces"),yg(this,"optionalNamespaces"),yg(this,"sessionProperties"),yg(this,"scopedProperties"),yg(this,"events",new(r())),yg(this,"rpcProviders",{}),yg(this,"session"),yg(this,"providerOpts"),yg(this,"logger"),yg(this,"uri"),yg(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof(null===e||void 0===e?void 0:e.logger)<"u"&&"string"!=typeof(null===e||void 0===e?void 0:e.logger)?e.logger:(0,c.h6)((0,c.iP)({level:(null===e||void 0===e?void 0:e.logger)||up})),this.disableProviderPing=(null===e||void 0===e?void 0:e.disableProviderPing)||!1}static async init(e){const t=new wg(e);return await t.initialize(),t}async request(e,t,n){const[i,s]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(i).request({request:vg({},e),chainId:"".concat(i,":").concat(s),topic:this.session.topic,expiry:n})}sendAsync(e,t,n,i){const s=(new Date).getTime();this.request(e,n,i).then(e=>t(null,(0,ka.formatJsonRpcResult)(s,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:ia("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),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:n,response:i}=await this.client.authenticate(e,t);n&&(this.uri=n,this.events.emit("display_uri",n));const s=await i();if(this.session=s.session,this.session){const e=yf(this.session.namespaces);this.namespaces=gf(this.namespaces,e),await this.persist("namespaces",this.namespaces),this.onConnect()}return s}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:n}=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 n();this.session=i;const s=yf(i.namespaces);return this.namespaces=gf(this.namespaces,s),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[n,i]=this.validateChain(e);this.getProvider(n).setDefaultChain(i,t)}catch(S){if(!/Please call connect/.test(S.message))throw S}}async cleanupPendingPairings(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};try{this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if(!sa(t))return;for(const n of t)e.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info("Inactive pairings cleared: ".concat(t.length))}catch(t){this.logger.warn("Failed to cleanup pending pairings",t)}}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 dp.init({core:this.providerOpts.core,logger:this.providerOpts.logger||up,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: ".concat(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=>Xo(e)))];Cf("client",this.client),Cf("events",this.events),Cf("disableProviderPing",this.disableProviderPing),e.forEach(e
2=>{if(!this.session)return;const t=function(e,t){const n=Object.keys(t.namespaces).filter(t=>t.includes(e));if(!n.length)return[];const i=[];return n.forEach(e=>{const n=t.namespaces[e].accounts;i.push(...n)}),i}(e,this.session);if(0===(null===t||void 0===t?void 0:t.length))return;const n=pf(t),i=gf(this.namespaces,this.optionalNamespaces),s=mg(vg({},i[e]),{accounts:t,chains:n});if("eip155"===e)this.rpcProviders[e]=new rg({namespace:s});else this.rpcProviders[e]=new cg({namespace:s})})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var t;const{topic:n}=e;n===(null==(t=this.session)?void 0:t.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var t;const{params:n,topic:i}=e;if(i!==(null==(t=this.session)?void 0:t.topic))return;const{event:s}=n;if("accountsChanged"===s.name){const e=s.data;e&&sa(e)&&this.events.emit("accountsChanged",e.map(mf))}else if("chainChanged"===s.name){const e=n.chainId,t=n.event.data,i=Xo(e),s=wf(e)!==wf(t)?"".concat(i,":").concat(wf(t)):e;this.onChainChanged({currentCaipChainId:s})}else this.events.emit(s.name,s.data);this.events.emit("session_event",e)}),this.client.on("session_update",e=>{let{topic:t,params:n}=e;var i,s;if(t!==(null==(i=this.session)?void 0:i.topic))return;const{namespaces:r}=n,o=null==(s=this.client)?void 0:s.session.get(t);this.session=mg(vg({},o),{namespaces:r}),this.onSessionUpdate(),this.events.emit("session_update",{topic:t,params:n})}),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",mg(vg({},ia("USER_DISCONNECTED")),{data:e.topic})))}),this.on(yp,e=>{this.onChainChanged(mg(vg({},e),{internal:!0}))})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[gp]}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:n={},sessionProperties:i,scopedProperties:s}=e;this.optionalNamespaces=gf(t,n),this.sessionProperties=i,this.scopedProperties=s}validateChain(e){const[t,n]=(null===e||void 0===e?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,n];if(t&&!Object.keys(this.namespaces||{}).map(e=>Xo(e)).includes(t))throw new Error("Namespace '".concat(t,"' is not configured. Please call connect() first with namespace config."));if(t&&n)return[t,n];const i=Xo(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){let{currentCaipChainId:t,previousCaipChainId:n,internal:i=!1}=e;if(!this.namespaces)return;const[s,r]=this.validateChain(t);r&&(this.updateNamespaceChain(s,r),i?(this.events.emit("chainChanged",r),this.emitAccountsChangedOnChainChange({namespace:s,currentCaipChainId:t,previousCaipChainId:n})):this.getProvider(s).setDefaultChain(r),await this.persist("namespaces",this.namespaces))}emitAccountsChangedOnChainChange(e){let{namespace:t,currentCaipChainId:n,previousCaipChainId:i}=e;var s,r;try{if(i===n)return;const e=null==(r=null==(s=this.session)?void 0:s.namespaces[t])?void 0:r.accounts;if(!e)return;const o=e.filter(e=>e.includes("".concat(n,":"))).map(mf);if(!sa(o))return;this.events.emit("accountsChanged",o)}catch(In){this.logger.warn("Failed to emit accountsChanged on chain change",In)}}updateNamespaceChain(e,t){if(!this.namespaces)return;const n=this.namespaces[e]?e:"".concat(e,":").concat(t),i={chains:[],methods:[],events:[],defaultChain:t};this.namespaces[n]?this.namespaces[n]&&(this.namespaces[n].defaultChain=t):this.namespaces[n]=i}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,this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,t){var n;const i=(null==(n=this.session)?void 0:n.topic)||"";await this.client.core.storage.setItem("".concat(pp,"/").concat(e).concat(i),t)}
2async getFromStore(e){var t;const n=(null==(t=this.session)?void 0:t.topic)||"";return await this.client.core.storage.getItem("".concat(pp,"/").concat(e).concat(n))}async deleteFromStore(e){var t;const n=(null==(t=this.session)?void 0:t.topic)||"";await this.client.core.storage.removeItem("".concat(pp,"/").concat(e).concat(n))}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(pp)&&await this.client.core.storage.removeItem(e)}catch(t){this.logger.warn("Failed to cleanup storage",t)}}}},74520:(e,t,n)=>{"use strict";n.d(t,{E:()=>p});var i=n(24107),s=n(18539),r=n(78854),o=n(70689),a=n(10232),c=n(46443);const l=r.w.getAnalyticsUrl(),d=new o.Z({baseUrl:l,clientId:null}),h=["MODAL_CREATED"],u=(0,s.BX)({timestamp:Date.now(),lastFlush:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"},pendingEvents:[],subscribedToVisibilityChange:!1,walletImpressions:[]}),p={state:u,subscribe:e=>(0,s.B1)(u,()=>e(u)),getSdkProperties(){const{projectId:e,sdkType:t,sdkVersion:n}=c.H.state;return{projectId:e,st:t,sv:n||"html-wagmi-4.2.2"}},shouldFlushEvents(){const e=JSON.stringify(u.pendingEvents).length/1024>45,t=u.lastFlush+1e4<Date.now();return e||t},_setPendingEvent(e){try{var t,n;let s=null===(t=a.W.getAccountData())||void 0===t?void 0:t.address;if("address"in e.data&&e.data.address&&(s=e.data.address),h.includes(e.data.event)||"undefined"===typeof window)return;const o=null===(n=a.W.getActiveCaipNetwork())||void 0===n?void 0:n.caipNetworkId;this.state.pendingEvents.push({eventId:r.w.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:e.timestamp,props:(0,i.A)((0,i.A)({},e.data),{},{address:s,properties:(0,i.A)((0,i.A)({},"properties"in e.data?e.data.properties:{}),{},{caipNetworkId:o})})}),u.reportedErrors.FORBIDDEN=!1;p.shouldFlushEvents()&&p._submitPendingEvents()}catch(s){console.warn("_setPendingEvent",s)}},sendEvent(e){var t;u.timestamp=Date.now(),u.data=e;(null!==(t=c.H.state.features)&&void 0!==t&&t.analytics||["INITIALIZE","CONNECT_SUCCESS","SOCIAL_LOGIN_SUCCESS"].includes(e.event))&&p._setPendingEvent(u),this.subscribeToFlushTriggers()},sendWalletImpressionEvent(e){u.walletImpressions.push(e)},_transformPendingEventsForBatch(e){try{return e.filter(e=>"WALLET_IMPRESSION"!==e.props.event)}catch(t){return e}},_submitPendingEvents(){if(u.lastFlush=Date.now(),0!==u.pendingEvents.length||0!==u.walletImpressions.length)try{const e=p._transformPendingEventsForBatch(u.pendingEvents);u.walletImpressions.length&&e.push({eventId:r.w.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:Date.now(),props:{type:"track",event:"WALLET_IMPRESSION",items:[...u.walletImpressions]}}),d.sendBeacon({path:"/batch",params:p.getSdkProperties(),body:e}),u.reportedErrors.FORBIDDEN=!1,u.pendingEvents=[],u.walletImpressions=[]}catch(e){u.reportedErrors.FORBIDDEN=!0}},subscribeToFlushTriggers(){var e,t,n,i,s,r;u.subscribedToVisibilityChange||"undefined"!==typeof document&&(u.subscribedToVisibilityChange=!0,null===(e=document)||void 0===e||null===(t=e.addEventListener)||void 0===t||t.call(e,"visibilitychange",()=>{"hidden"===document.visibilityState&&p._submitPendingEvents()}),null===(n=document)||void 0===n||null===(i=n.addEventListener)||void 0===i||i.call(n,"freeze",()=>{p._submitPendingEvents()}),null===(s=window)||void 0===s||null===(r=s.addEventListener)||void 0===r||r.call(s,"pagehide",()=>{p._submitPendingEvents()}),setInterval(()=>{p._submitPendingEvents()},1e4))}}},76007:(e,t,n)=>{"use strict";n.d(t,{IP:()=>o,T8:()=>s,Ud:()=>r,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",RECENT_WALLET:"@appkit/recent_wallet",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_cac
2he",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache",PREFERRED_ACCOUNT_TYPES:"@appkit/preferred_account_types",CONNECTIONS:"@appkit/connections",DISCONNECTED_CONNECTOR_IDS:"@appkit/disconnected_connector_ids",HISTORY_TRANSACTIONS_CACHE:"@appkit/history_transactions_cache",TOKEN_PRICE_CACHE:"@appkit/token_price_cache",RECENT_EMAILS:"@appkit/recent_emails",LATEST_APPKIT_VERSION:"@appkit/latest_version"};function s(e){if(!e)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return"@appkit/".concat(e,":connected_connector_id")}const r={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}},78256:(e,t,n)=>{"use strict";n.d(t,{Db:()=>o,oU:()=>a,tM:()=>r});var i=n(84873);const s=("undefined"!==typeof process?{NODE_ENV:"production",PUBLIC_URL:".",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",r=[{label:"Meld.io",name:"meld",feeRange:"1-2%",url:"https://meldcrypto.com",supportedChains:["eip155","solana"]}],o="WXETMuFUQmqqybHuRkSgxv:25B8LJHSfpG6LVjR2ytU5Cwh7Z4Sch2ocoU",a={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,FIVE_SEC_MS:5e3,THREE_SEC_MS:3e3,ONE_SEC_MS:1e3,SECURE_SITE:s,SECURE_SITE_DASHBOARD:"".concat(s,"/dashboard"),SECURE_SITE_FAVICON:"".concat(s,"/images/favicon.png"),SOLANA_NATIVE_TOKEN_ADDRESS:"So11111111111111111111111111111111111111111",RESTRICTED_TIMEZONES:["ASIA/SHANGHAI","ASIA/URUMQI","ASIA/CHONGQING","ASIA/HARBIN","ASIA/KASHGAR","ASIA/MACAU","ASIA/HONG_KONG","ASIA/MACAO","ASIA/BEIJING","ASIA/HARBIN"],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:[i.o.CHAIN.EVM,i.o.CHAIN.SOLANA],SEND_PARAMS_SUPPORTED_CHAINS:[i.o.CHAIN.EVM],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:[i.o.CHAIN.EVM],ONRAMP_SUPPORTED_CHAIN_NAMESPACES:[i.o.CHAIN.EVM,i.o.CHAIN.SOLANA],PAY_WITH_EXCHANGE_SUPPORTED_CHAIN_NAMESPACES:[i.o.CHAIN.EVM,i.o.CHAIN.SOLANA],ACTIVITY_ENABLED_CHAIN_NAMESPACES:[i.o.CHAIN.EVM],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x",cosmos:"0x",sui:"0x",stacks:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in the wallet app",WEB:"Open and continue in the wallet app"},SEND_SUPPORTED_NAMESPACES:[i.o.CHAIN.EVM,i.o.CHAIN.SOLANA],DEFAULT_REMOTE_FEATURES:{swaps:["1inch"],onramp:["meld"],email:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],activity:!0,reownBranding:!0,multiWallet:!1,emailCapture:!1,payWithExchange:!1,payments:!1,reownAuthentication:!1},DEFAULT_REMOTE_FEATURES_DISABLED:{email:!1,socials:!1,swaps:!1,onramp:!1,activity:!1,reownBranding:!1,emailCapture:!1,reownAuthentication:!1},DEFAULT_FEATURES:{receive:!0,send:!0,emailShowWallets:!0,connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0,pay:!1,reownAuthentication:!1},DEFAULT_SOCIALS:["google","x","farcaster","discord","apple","github","facebook"],DEFAULT_ACCOUNT_TYPES:{b
2ip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",BITCOIN:"bitcoin"},SIWX_DEFAULTS:{signOutOnDisconnect:!0}}},78854:(e,t,n)=>{"use strict";n.d(t,{w:()=>o});var i=n(84873),s=n(78256),r=n(81828);const o={isMobile(){var e,t;return!!this.isClient()&&Boolean((null===(e=window)||void 0===e?void 0:e.matchMedia)&&"function"===typeof window.matchMedia&&(null===(t=window.matchMedia("(pointer:coarse)"))||void 0===t?void 0:t.matches)||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/.test(navigator.userAgent))},checkCaipNetwork(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";return null===e||void 0===e?void 0:e.caipNetworkId.toLocaleLowerCase().includes(t.toLowerCase())},isAndroid(){var e;if(!this.isMobile())return!1;const t=null===(e=window)||void 0===e?void 0:e.navigator.userAgent.toLowerCase();return o.isMobile()&&t.includes("android")},isIos(){var e;if(!this.isMobile())return!1;const t=null===(e=window)||void 0===e?void 0:e.navigator.userAgent.toLowerCase();return t.includes("iphone")||t.includes("ipad")},isSafari(){var e;if(!this.isClient())return!1;return(null===(e=window)||void 0===e?void 0:e.navigator.userAgent.toLowerCase()).includes("safari")},isClient:()=>"undefined"!==typeof window,isPairingExpired:e=>!e||e-Date.now()<=s.oU.TEN_SEC_MS,isAllowedRetry(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:s.oU.ONE_SEC_MS;return Date.now()-e>=t},copyToClopboard(e){navigator.clipboard.writeText(e)},isIframe(){try{var e,t;return(null===(e=window)||void 0===e?void 0:e.self)!==(null===(t=window)||void 0===t?void 0:t.top)}catch(n){return!1}},isSafeApp(){if(o.isClient()&&window.self!==window.top)try{var e;const t=null===(e=window)||void 0===e||null===(e=e.location)||void 0===e||null===(e=e.ancestorOrigins)||void 0===e?void 0:e[0],n="https://app.safe.global";if(t){const e=new URL(t),i=new URL(n);return e.hostname===i.hostname}}catch(t){return!1}return!1},getPairingExpiry:()=>Date.now()+s.oU.FOUR_MINUTES_MS,getNetworkId:e=>null===e||void 0===e?void 0:e.split(":")[1],getPlainAddress:e=>null===e||void 0===e?void 0:e.split(":")[2],wait:async e=>new Promise(t=>{setTimeout(t,e)}),debounce(e){let t,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:500;return function(){for(var i=arguments.length,s=new Array(i),r=0;r<i;r++)s[r]=arguments[r];t&&clearTimeout(t),t=setTimeout(function(){e(...s)},n)}},isHttpUrl:e=>e.startsWith("http://")||e.startsWith("https://"),formatNativeUrl(e,t){var n;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;if(o.isHttpUrl(e))return this.formatUniversalUrl(e,t);let s=e,r=i;s&&(s.includes("://")||(s=e.replaceAll("/","").replaceAll(":",""),s="".concat(s,"://")),s.endsWith("/")||(s="".concat(s,"/"))),!r||null!==(n=r)&&void 0!==n&&n.endsWith("/")||(r="".concat(r,"/")),this.isTelegram()&&this.isAndroid()&&(t=encodeURIComponent(t));const a=encodeURIComponent(t);return{redirect:"".concat(s,"wc?uri=").concat(a),redirectUniversalLink:r?"".concat(r,"wc?uri=").concat(a):void 0,href:s}},formatUniversalUrl(e,t){if(!o.isHttpUrl(e))return this.formatNativeUrl(e,t);let n=e;n.endsWith("/")||(n="".concat(n,"/"));const i=encodeURIComponent(t);return{redirect:"".concat(n,"wc?uri=").concat(i),href:n}},getOpenTargetForPlatform(e){return"popupWindow"===e?e:this.isTelegram()?r.i.getTelegramSocialProvider()?"_top":"_blank":e},openHref(e,t,n){var i;null===(i=window)||void 0===i||i.open(e,this.getOpenTargetForPlatform(t),n||"noreferrer noopener")},returnOpenHref(e,t,n){var i;return null===(i=window)||void 0===i?void 0:i.open(e,this.getOpenTargetForPlatform(t),n||"noreferrer noopener")},isTelegram:()=>"undefined"!==typeof window&&(Boolean(window.TelegramWebviewProxy)||Boolean(window.Telegram)||Boolean(window.TelegramWebviewProxyProto)),isPWA(){var e,t,n;if("undefined"===typeof window)return!1;const i=!(null===(e=window)||void 0===e||!e.matchMedia||"function"!==typeof window.matchMedia)&&(null===(t=window.matchMedia("(display-mode: standalone)"))||void 0===t?void 0:t.matches),s=null===(n=window)||void 0===n||null===(n=n.navigator)||void 0===n?void 0:n.standalone;return Boolean(i||s)},async preloadImage(e){const t=new Promise((t,n)=>{const i=new Image;i.onload=t,i.onerror=n,i.crossOrigin="anonymous",i.src=e});return Promise.race([t,o.wait(2e3)])},parseBalance(e,t){let n="0.000";if("string"===typeof e){const t=Number(e);if(!isNaN(t)){const e=(Math.floor(1e3*t)/1e3).toFixed(3);e&&(n=e)}}const[i,s]=n.split("."),r=i||"0",o=s||"000";return{formattedText:"".concat(r,".").concat(o).concat(t?" ".concat(t):""),value:r,decimals:o,symbol:t}},getApiUrl:()=>i.o.W3M_API_URL,getBlockchainApiUrl:()=>i.o.BLOCKCHAIN_API_RPC_URL,getAnalyticsUrl:()=>i.o.PULSE_API_URL,getUUID(){var e;return null!==(e=crypto)&&void 0!==e&&e.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,e=>{const t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)})},parseError(e){var t;return"string"===typeof e?e:"string"===typeof(null===e||void 0===e||null===(t=e.issues)||void 0===t||null===(t=t[0])||void 0===t?void 0:t.message)?e.issues[0].message:e instanceof Error?e.message:"Unknown error"},sortRequestedNetworks(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];const n={};return t&&e&&(e.forEach((e,t)=>{n[e]=t}),t.sort((e,t)=>
2{const i=n[e.id],s=n[t.id];return void 0!==i&&void 0!==s?i-s:void 0!==i?-1:void 0!==s?1:0})),t},calculateBalance(e){let t=0;for(const i of e){var n;t+=null!==(n=i.value)&&void 0!==n?n:0}return t},formatTokenBalance(e){const t=e.toFixed(2),[n,i]=t.split(".");return{dollars:n,pennies:i}},isAddress(e){switch(arguments.length>1&&void 0!==arguments[1]?arguments[1]:"eip155"){case"eip155":return!!/^(?:0x)?[0-9a-f]{40}$/i.test(e)&&!(!/^(?:0x)?[0-9a-f]{40}$/i.test(e)&&!/^(?:0x)?[0-9A-F]{40}$/i.test(e));case"solana":return/[1-9A-HJ-NP-Za-km-z\u017F\u212A]{32,44}$/i.test(e);default:return!1}},uniqueBy(e,t){const n=new Set;return e.filter(e=>{const i=e[t];return!n.has(i)&&(n.add(i),!0)})},generateSdkVersion(e,t,n){const i=0===e.length?s.oU.ADAPTER_TYPES.UNIVERSAL:e.map(e=>e.adapterType).join(",");return"".concat(t,"-").concat(i,"-").concat(n)},createAccount:(e,t,n,i,s)=>({namespace:e,address:t,type:n,publicKey:i,path:s}),isCaipAddress(e){if("string"!==typeof e)return!1;const t=e.split(":"),n=t[0];return 3===t.filter(Boolean).length&&n in i.o.CHAIN_NAME_MAP},getAccount:e=>e?"string"===typeof e?{address:e,chainId:void 0}:{address:e.address,chainId:e.chainId}:{address:void 0,chainId:void 0},isMac(){var e;const t=null===(e=window)||void 0===e?void 0:e.navigator.userAgent.toLowerCase();return t.includes("macintosh")&&!t.includes("safari")},formatTelegramSocialLoginUrl(e){var t;const n="--".concat(encodeURIComponent(null===(t=window)||void 0===t?void 0:t.location.href)),i="state=";if("auth.magic.link"===new URL(e).host){const t="provider_authorization_url=",s=e.substring(e.indexOf(t)+t.length),r=this.injectIntoUrl(decodeURIComponent(s),i,n);return e.replace(s,encodeURIComponent(r))}return this.injectIntoUrl(e,i,n)},injectIntoUrl(e,t,n){const i=e.indexOf(t);if(-1===i)throw new Error("".concat(t," parameter not found in the URL: ").concat(e));const s=e.indexOf("&",i),r=t.length,o=-1!==s?s:e.length;return e.substring(0,i+r)+(e.substring(i+r,o)+n)+e.substring(s)}}},80846:(e,t,n)=>{"use strict";var i;n.d(t,{JW:()=>S,XX:()=>K,c0:()=>T,ej:()=>_,ge:()=>q,qy:()=>N,s6:()=>O});const s=globalThis,r=s.trustedTypes,o=r?r.createPolicy("lit-html",{createHTML:e=>e}):void 0,a="$lit$",c="lit$".concat(Math.random().toFixed(9).slice(2),"$"),l="?"+c,d="<".concat(l,">"),h=document,u=()=>h.createComment(""),p=e=>null===e||"object"!=typeof e&&"function"!=typeof e,f=Array.isArray,g=e=>f(e)||"function"==typeof(null===e||void 0===e?void 0:e[Symbol.iterator]),v="[ \t\n\f\r]",m=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,y=/-->/g,w=/>/g,b=RegExp(">|".concat(v,"(?:([^\\s\"'>=/]+)(").concat(v,"*=").concat(v,"*(?:[^ \t\n\f\r\"'`<>=]|(\"|')|))|$)"),"g"),E=/'/g,C=/"/g,A=/^(?:script|style|textarea|title)$/i,I=e=>function(t){for(var n=arguments.length,i=new Array(n>1?n-1:0),s=1;s<n;s++)i[s-1]=arguments[s];return{_$litType$:e,strings:t,values:i}},N=I(1),S=I(2),_=I(3),T=Symbol.for("lit-noChange"),O=Symbol.for("lit-nothing"),k=new WeakMap,P=h.createTreeWalker(h,129);function R(e,t){if(!f(e)||!e.hasOwnProperty("raw"))throw Error("invalid template strings array");return void 0!==o?o.createHTML(t):t}const x=(e,t)=>{const n=e.length-1,i=[];let s,r=2===t?"<svg>":3===t?"<math>":"",o=m;for(let l=0;l<n;l++){const t=e[l];let n,h,u=-1,p=0;for(;p<t.length&&(o.lastIndex=p,h=o.exec(t),null!==h);)p=o.lastIndex,o===m?"!--"===h[1]?o=y:void 0!==h[1]?o=w:void 0!==h[2]?(A.test(h[2])&&(s=RegExp("</"+h[2],"g")),o=b):void 0!==h[3]&&(o=b):o===b?">"===h[0]?(o=null!==s&&void 0!==s?s:m,u=-1):void 0===h[1]?u=-2:(u=o.lastIndex-h[2].length,n=h[1],o=void 0===h[3]?b:'"'===h[3]?C:E):o===C||o===E?o=b:o===y||o===w?o=m:(o=b,s=void 0);const f=o===b&&e[l+1].startsWith("/>")?" ":"";r+=o===m?t+d:u>=0?(i.push(n),t.slice(0,u)+a+t.slice(u)+c+f):t+c+(-2===u?l:f)}return[R(e,r+(e[n]||"<?>")+(2===t?"</svg>":3===t?"</math>":"")),i]};class U{constructor(e,t){let n,{strings:i,_$litType$:s}=e;this.parts=[];let o=0,d=0;const h=i.length-1,p=this.parts,[f,g]=x(i,s);if(this.el=U.createElement(f,t),P.currentNode=this.el.content,2===s||3===s){const e=this.el.content.firstChild;e.replaceWith(...e.childNodes)}for(;null!==(n=P.nextNode())&&p.length<h;){if(1===n.nodeType){if(n.hasAttributes())for(const e of n.getAttributeNames())if(e.endsWith(a)){const t=g[d++],i=n.getAttribute(e).split(c),s=/([.?@])?(.*)/.exec(t);p.push({type:1,index:o,name:s[2],strings:i,ctor:"."===s[1]?B:"?"===s[1]?F:"@"===s[1]?j:M}),n.removeAttribute(e)}else e.startsWith(c)&&(p.push({type:6,index:o}),n.removeAttribute(e));if(A.test(n.tagName)){const e=n.textContent.split(c),t=e.length-1;if(t>0){n.textContent=r?r.emptyScript:"";for(let i=0;i<t;i++)n.append(e[i],u()),P.nextNode(),p.push({type:2,index:++o});n.append(e[t],u())}}}else if(8===n.nodeType)if(n.data===l)p.push({type:2,index:o});else{let e=-1;for(;-1!==(e=n.data.indexOf(c,e+1));)p.push({type:7,index:o}),e+=c.length-1}o++}}static createElement(e,t){const n=h.createElement("template");return n.innerHTML=e,n}}function D(e,t){var n,i,s,r,o;let a=arguments.length>2&&void 0!==arguments[2]?arguments[2]:e,c=arguments.length>3?arguments[3]:void 0;if(t===T)return t;let l=void 0!==c?null===(n=a._$Co)||void 0===n?void 0:n[c]:a._$Cl;const d=p(t)?void 0:t._$litDirective$;return(null===(i=l)||void 0===i?void 0:i.constructor)!==d&&(null!==(s=l)&&void 0!==s&&null!==(r=s._$AO)&&void 0!==r&&r.call(s,!1),void 0===d?l=void 0:(l=new d(e),l._$AT(e,a,c)),void 0!==c?(null!==(o=a._$Co)&&void 0!==o?o:a._$Co=[])[c]=l:a._$Cl=l),void 0!==l&&(t=D(e,l._$AS(e,t.values),l,c)),t}class L{constructor(e,t){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=t}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){var t;const{el:{content:n},parts:i}=this._$AD,s=(null!==(t=null===e||void 0===e?void 0:e.creationScope)&&void 0!==t?t:h).importNode(n,!0);P.currentNode=s;let r=P.nextNode(),o=0,a=0,c=i[0];for(;void 0!==c;){var l;if(o===c.index){let t;2===c.type?t=new W(r,r.nextSibling,this,e):1===c.type?t=new c.ctor(r,c.name,c.strings,this,e):6===c.type&&(t=new H(r,this,e)),this._$AV.push(t),c=i[++a]}o!==(null===(l=c)||void 0===l?void 0:l.index)&&(r=P.nextNode(),o++)}return P.currentNode=h,s}p(e){let t=0;for(const n of this._$AV)void 0!==n&&(void 0!==n.strings?(n._$AI(e,n,t),t+=n.strings.length-2):n._$AI(e[t])),t++}}class W{get _$AU(){var e,t;return null!==(e=null===(t=this._$AM)||void 0===t?void 0:t._$AU)&&void 0!==e?e:this._$Cv}constructor(e,t,n,i){var s;this.type=2,this._$AH=O,this._$AN=void 0,this._$AA=e,this._$AB=t,this._$AM=n,this.options=i,this._$Cv=null===(s=null===i||void 0===i?void 0:i.isConnected)||void 0===s||s}get parentNode(){var e;let t=this._$AA.parentNode;const n=this._$AM;return void 0!==n&&11===(null===(e=t)||void 0===e?void 0:e.nodeType)&&(t=n.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e){e=D(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this),p(e)?e===O||null==e||""===e?(this._$AH!==O&&this._$AR(),this._$AH=O):e!==this._$AH&&e!==T&&this._(e):void 0!==e._$litType$?this.$(e):void 0!==e.nodeType?this.T(e):g(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==O&&p(this._$AH)?this._$AA.nextSibling.data=e:this.T(h.createTextNode(e)),this._$AH=e}$(e){var t;const{values:n,_$litType$:i}=e,s="number"==typeof i?this._$AC(e):(void 0===i.el&&(i.el=U.createElement(R(i.h,i.h[0]),this.options)),i);if((null===(t=this._$AH)||void 0===t?void 0:t._$AD)===s)this._$AH.p(n);else{const e=new L(s,this),t=e.u(this.options);e.p(n),this.T(t),this._$AH=e}}_$AC(e){let t=k.get(e.strings);return void 0===t&&k.set(e.strings,t=new U(e)),t}k(e){f(this._$AH)||(this._$AH=[],this._$AR());const t=this._$AH;let n,i=0;for(const s of e)i===t.length?t.push(n=new W(this.O(u()),this.O(u()),this,this.options)):n=t[i],n._$AI(s),i++;i<t.length&&(this._$AR(n&&n._$AB.nextSibling,i),t.length=i)}_$AR(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:this._$AA.nextSibling,t=arguments.length>1?arguments[1]:void 0;
2for(null===(n=this._$AP)||void 0===n||n.call(this,!1,!0,t);e!==this._$AB;){var n;const t=e.nextSibling;e.remove(),e=t}}setConnected(e){var t;void 0===this._$AM&&(this._$Cv=e,null===(t=this._$AP)||void 0===t||t.call(this,e))}}class M{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,t,n,i,s){this.type=1,this._$AH=O,this._$AN=void 0,this.element=e,this.name=t,this._$AM=i,this.options=s,n.length>2||""!==n[0]||""!==n[1]?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=O}_$AI(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,n=arguments.length>2?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0;const s=this.strings;let r=!1;if(void 0===s)e=D(this,e,t,0),r=!p(e)||e!==this._$AH&&e!==T,r&&(this._$AH=e);else{const i=e;let o,a;for(e=s[0],o=0;o<s.length-1;o++)a=D(this,i[n+o],t,o),a===T&&(a=this._$AH[o]),r||(r=!p(a)||a!==this._$AH[o]),a===O?e=O:e!==O&&(e+=(null!==a&&void 0!==a?a:"")+s[o+1]),this._$AH[o]=a}r&&!i&&this.j(e)}j(e){e===O?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,null!==e&&void 0!==e?e:"")}}class B extends M{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===O?void 0:e}}class F extends M{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==O)}}class j extends M{constructor(e,t,n,i,s){super(e,t,n,i,s),this.type=5}_$AI(e){var t;if((e=null!==(t=D(this,e,arguments.length>1&&void 0!==arguments[1]?arguments[1]:this,0))&&void 0!==t?t:O)===T)return;const n=this._$AH,i=e===O&&n!==O||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,s=e!==O&&(n===O||i);i&&this.element.removeEventListener(this.name,this,n),s&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){var t,n;"function"==typeof this._$AH?this._$AH.call(null!==(t=null===(n=this.options)||void 0===n?void 0:n.host)&&void 0!==t?t:this.element,e):this._$AH.handleEvent(e)}}class H{constructor(e,t,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=t,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){D(this,e)}}const q={M:a,P:c,A:l,C:1,L:x,R:L,D:g,V:D,I:W,H:M,N:F,U:j,B:B,F:H},V=s.litHtmlPolyfillSupport;null!==V&&void 0!==V&&V(U,W),(null!==(i=s.litHtmlVersions)&&void 0!==i?i:s.litHtmlVersions=[]).push("3.3.1");const K=(e,t,n)=>{var i;const s=null!==(i=null===n||void 0===n?void 0:n.renderBefore)&&void 0!==i?i:t;let r=s._$litPart$;if(void 0===r){var o;const e=null!==(o=null===n||void 0===n?void 0:n.renderBefore)&&void 0!==o?o:null;s._$litPart$=r=new W(t.insertBefore(u(),e),e,void 0,null!==n&&void 0!==n?n:{})}return r._$AI(e),r}},81828:(e,t,n)=>{"use strict";n.d(t,{i:()=>c});var i=n(15882),s=n(31576),r=n(24107),o=n(84873),a=n(76007);const c={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5,transactionsHistory:15e3,tokenPrice:15e3,latestAppKitVersion:6048e5},isCacheExpired:(e,t)=>Date.now()-e>t,getActiveNetworkProps(){const e=c.getActiveNamespace(),t=c.getActiveCaipNetworkId(),n=t?t.split(":")[1]:void 0;return{namespace:e,caipNetworkId:t,chainId:n?isNaN(Number(n))?n:Number(n):void 0}},setWalletConnectDeepLink(e){let{name:t,href:n}=e;try{a.Ud.setItem(a.Ws.DEEPLINK_CHOICE,JSON.stringify({href:n,name:t}))}catch(i){console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const e=a.Ud.getItem(a.Ws.DEEPLINK_CHOICE);if(e)return JSON.parse(e)}catch(e){console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{a.Ud.removeItem(a.Ws.DEEPLINK_CHOICE)}catch(e){console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(e){try{a.Ud.setItem(a.Ws.ACTIVE_NAMESPACE,e)}catch(t){console.info("Unable to set active namespace")}},setActiveCaipNetworkId(e){try{a.Ud.setItem(a.Ws.ACTIVE_CAIP_NETWORK_ID,e),c.setActiveNamespace(e.split(":")[0])}catch(t){console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return a.Ud.getItem(a.Ws.ACTIVE_CAIP_NETWORK_ID)}catch(e){return void console.info("Unable to get active caip network id")}},deleteActiveCaipNetworkId(){try{a.Ud.removeItem(a.Ws.ACTIVE_CAIP_NETWORK_ID)}catch(e){console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(e){try{const t=(0,a.T8)(e);a.Ud.removeItem(t)}catch(t){console.info("Unable to delete connected connector id")}},setAppKitRecent(e){try{const t=c.getRecentWallets();t.find(t=>
2t.id===e.id)||(t.unshift(e),t.length>2&&t.pop(),a.Ud.setItem(a.Ws.RECENT_WALLETS,JSON.stringify(t)),a.Ud.setItem(a.Ws.RECENT_WALLET,JSON.stringify(e)))}catch(t){console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const e=a.Ud.getItem(a.Ws.RECENT_WALLETS);return e?JSON.parse(e):[]}catch(e){console.info("Unable to get AppKit recent")}return[]},getRecentWallet(){try{const e=a.Ud.getItem(a.Ws.RECENT_WALLET);return e?JSON.parse(e):null}catch(e){console.info("Unable to get AppKit recent")}return null},deleteRecentWallet(){try{a.Ud.removeItem(a.Ws.RECENT_WALLET)}catch(e){console.info("Unable to delete AppKit recent")}},setConnectedConnectorId(e,t){try{const n=(0,a.T8)(e);a.Ud.setItem(n,t)}catch(n){console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return a.Ud.getItem(a.Ws.ACTIVE_NAMESPACE)}catch(e){console.info("Unable to get active namespace")}},getConnectedConnectorId(e){if(e)try{const t=(0,a.T8)(e);return a.Ud.getItem(t)}catch(t){console.info("Unable to get connected connector id in namespace",e)}},setConnectedSocialProvider(e){try{a.Ud.setItem(a.Ws.CONNECTED_SOCIAL,e)}catch(t){console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return a.Ud.getItem(a.Ws.CONNECTED_SOCIAL)}catch(e){console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{a.Ud.removeItem(a.Ws.CONNECTED_SOCIAL)}catch(e){console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return a.Ud.getItem(a.Ws.CONNECTED_SOCIAL_USERNAME)}catch(e){console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){var e;const t=a.Ud.getItem(a.Ws.ACTIVE_CAIP_NETWORK_ID);return null===t||void 0===t||null===(e=t.split(":"))||void 0===e?void 0:e[1]},setConnectionStatus(e){try{a.Ud.setItem(a.Ws.CONNECTION_STATUS,e)}catch(t){console.info("Unable to set connection status")}},getConnectionStatus(){try{return a.Ud.getItem(a.Ws.CONNECTION_STATUS)}catch(e){return}},getConnectedNamespaces(){try{const e=a.Ud.getItem(a.Ws.CONNECTED_NAMESPACES);return null!==e&&void 0!==e&&e.length?e.split(","):[]}catch(e){return[]}},setConnectedNamespaces(e){try{const t=Array.from(new Set(e));a.Ud.setItem(a.Ws.CONNECTED_NAMESPACES,t.join(","))}catch(t){console.info("Unable to set namespaces in storage")}},addConnectedNamespace(e){try{const t=c.getConnectedNamespaces();t.includes(e)||(t.push(e),c.setConnectedNamespaces(t))}catch(t){console.info("Unable to add connected namespace")}},removeConnectedNamespace(e){try{const t=c.getConnectedNamespaces(),n=t.indexOf(e);n>-1&&(t.splice(n,1),c.setConnectedNamespaces(t))}catch(t){console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return a.Ud.getItem(a.Ws.TELEGRAM_SOCIAL_PROVIDER)}catch(e){return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(e){try{a.Ud.setItem(a.Ws.TELEGRAM_SOCIAL_PROVIDER,e)}catch(t){console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{a.Ud.removeItem(a.Ws.TELEGRAM_SOCIAL_PROVIDER)}catch(e){console.info("Unable to remove telegram social provider")}},getBalanceCache(){let e={};try{const t=a.Ud.getItem(a.Ws.PORTFOLIO_CACHE);e=t?JSON.parse(t):{}}catch(t){console.info("Unable to get balance cache")}return e},removeAddressFromBalanceCache(e){try{const t=c.getBalanceCache();a.Ud.setItem(a.Ws.PORTFOLIO_CACHE,JSON.stringify((0,r.A)((0,r.A)({},t),{},{[e]:void 0})))}catch(t){console.info("Unable to remove address from balance cache",e)}},getBalanceCacheForCaipAddress(e){try{const t=c.getBalanceCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.portfolio))return t.balance;c.removeAddressFromBalanceCache(e)}catch(t){console.info("Unable to get balance cache for address",e)}},updateBalanceCache(e){try{const t=c.getBalanceCache();t[e.caipAddress]=e,a.Ud.setItem(a.Ws.PORTFOLIO_CACHE,JSON.stringify(t))}catch(t){console.info("Unable to update balance cache",e)}},getNativeBalanceCache(){let e={};try{const t=a.Ud.getItem(a.Ws.NATIVE_BALANCE_CACHE);e=t?JSON.parse(t):{}}catch(t){console.info("Unable to get balance cache")}return e},removeAddressFromNativeBalanceCache(e){try{const t=c.getBalanceCache();a.Ud.setItem(a.Ws.NATIVE_BALANCE_CACHE,JSON.stringify((0,r.A)((0,r.A)({},t),{},{[e]:void 0})))}catch(t){console.info("Unable to remove address from balance cache",e)}},getNativeBalanceCacheForCaipAddress(e){try{const t=c.getNativeBalanceCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.nativeBalance))return t;console.info("Discarding cache for address",e),c.removeAddressFromBalanceCache(e)}catch(t){console.info("Unable to get balance cache for address",e)}},updateNativeBalanceCache(e){try{const t=c.getNativeBalanceCache();t[e.caipAddress]=e,a.Ud.setItem(a.Ws.NATIVE_BALANCE_CACHE,JSON.stringify(t))}catch(t){console.info("Unable to update balance cache",e)}},getEnsCache(){let e={};try{const t=a.Ud.getItem(a.Ws.ENS_CACHE);e=t?JSON.parse(t):{}}catch(t){console.info("Unable to get ens name cache")}return e}
2,getEnsFromCacheForAddress(e){try{const t=c.getEnsCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.ens))return t.ens;c.removeEnsFromCache(e)}catch(t){console.info("Unable to get ens name from cache",e)}},updateEnsCache(e){try{const t=c.getEnsCache();t[e.address]=e,a.Ud.setItem(a.Ws.ENS_CACHE,JSON.stringify(t))}catch(t){console.info("Unable to update ens name cache",e)}},removeEnsFromCache(e){try{const t=c.getEnsCache();a.Ud.setItem(a.Ws.ENS_CACHE,JSON.stringify((0,r.A)((0,r.A)({},t),{},{[e]:void 0})))}catch(t){console.info("Unable to remove ens name from cache",e)}},getIdentityCache(){let e={};try{const t=a.Ud.getItem(a.Ws.IDENTITY_CACHE);e=t?JSON.parse(t):{}}catch(t){console.info("Unable to get identity cache")}return e},getIdentityFromCacheForAddress(e){try{const t=c.getIdentityCache()[e];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.identity))return t.identity;c.removeIdentityFromCache(e)}catch(t){console.info("Unable to get identity from cache",e)}},updateIdentityCache(e){try{const t=c.getIdentityCache();t[e.address]={identity:e.identity,timestamp:e.timestamp},a.Ud.setItem(a.Ws.IDENTITY_CACHE,JSON.stringify(t))}catch(t){console.info("Unable to update identity cache",e)}},removeIdentityFromCache(e){try{const t=c.getIdentityCache();a.Ud.setItem(a.Ws.IDENTITY_CACHE,JSON.stringify((0,r.A)((0,r.A)({},t),{},{[e]:void 0})))}catch(t){console.info("Unable to remove identity from cache",e)}},clearAddressCache(){try{a.Ud.removeItem(a.Ws.PORTFOLIO_CACHE),a.Ud.removeItem(a.Ws.NATIVE_BALANCE_CACHE),a.Ud.removeItem(a.Ws.ENS_CACHE),a.Ud.removeItem(a.Ws.IDENTITY_CACHE),a.Ud.removeItem(a.Ws.HISTORY_TRANSACTIONS_CACHE)}catch(e){console.info("Unable to clear address cache")}},setPreferredAccountTypes(e){try{a.Ud.setItem(a.Ws.PREFERRED_ACCOUNT_TYPES,JSON.stringify(e))}catch(t){console.info("Unable to set preferred account types",e)}},getPreferredAccountTypes(){try{const e=a.Ud.getItem(a.Ws.PREFERRED_ACCOUNT_TYPES);return e?JSON.parse(e):{}}catch(e){console.info("Unable to get preferred account types")}return{}},setConnections(e,t){try{var n;const i=c.getConnections(),s=null!==(n=i[t])&&void 0!==n?n:[],l=new Map;for(const e of s)l.set(e.connectorId,(0,r.A)({},e));for(const t of e){const e=l.get(t.connectorId),n=t.connectorId===o.o.CONNECTOR_ID.AUTH;if(e&&!n){const n=new Set(e.accounts.map(e=>e.address.toLowerCase())),i=t.accounts.filter(e=>!n.has(e.address.toLowerCase()));e.accounts.push(...i)}else l.set(t.connectorId,(0,r.A)({},t))}const d=(0,r.A)((0,r.A)({},i),{},{[t]:Array.from(l.values())});a.Ud.setItem(a.Ws.CONNECTIONS,JSON.stringify(d))}catch(i){console.error("Unable to sync connections to storage",i)}},getConnections(){try{const e=a.Ud.getItem(a.Ws.CONNECTIONS);return e?JSON.parse(e):{}}catch(e){return console.error("Unable to get connections from storage",e),{}}},deleteAddressFromConnection(e){let{connectorId:t,address:n,namespace:i}=e;try{var s;const e=c.getConnections(),o=null!==(s=e[i])&&void 0!==s?s:[],l=new Map(o.map(e=>[e.connectorId,e])),d=l.get(t);if(d){0===d.accounts.filter(e=>e.address.toLowerCase()!==n.toLowerCase()).length?l.delete(t):l.set(t,(0,r.A)((0,r.A)({},d),{},{accounts:d.accounts.filter(e=>e.address.toLowerCase()!==n.toLowerCase())}))}a.Ud.setItem(a.Ws.CONNECTIONS,JSON.stringify((0,r.A)((0,r.A)({},e),{},{[i]:Array.from(l.values())})))}catch(o){console.error('Unable to remove address "'.concat(n,'" from connector "').concat(t,'" in namespace "').concat(i,'"'))}},getDisconnectedConnectorIds(){try{const e=a.Ud.getItem(a.Ws.DISCONNECTED_CONNECTOR_IDS);return e?JSON.parse(e):{}}catch(e){console.info("Unable to get disconnected connector ids")}return{}},addDisconnectedConnectorId(e,t){try{var n;const i=c.getDisconnectedConnectorIds(),s=null!==(n=i[t])&&void 0!==n?n:[];s.push(e),a.Ud.setItem(a.Ws.DISCONNECTED_CONNECTOR_IDS,JSON.stringify((0,r.A)((0,r.A)({},i),{},{[t]:Array.from(new Set(s))})))}catch(i){console.error('Unable to set disconnected connector id "'.concat(e,'" for namespace "').concat(t,'"'))}},removeDisconnectedConnectorId(e,t){try{var n;const i=c.getDisconnectedConnectorIds();let s=null!==(n=i[t])&&void 0!==n?n:[];s=s.filter(t=>t.toLowerCase()!==e.toLowerCase()),a.Ud.setItem(a.Ws.DISCONNECTED_CONNECTOR_IDS,JSON.stringify((0,r.A)((0,r.A)({},i),{},{[t]:Array.from(new Set(s))})))}catch(i){console.error('Unable to remove disconnected connector id "'.concat(e,'" for namespace "').concat(t,'"'))}},isConnectorDisconnected(e,t){try{var n;const i=c.getDisconnectedConnectorIds();return(null!==(n=i[t])&&void 0!==n?n:[]).some(t=>t.toLowerCase()===e.toLowerCase())}catch(i){console.info('Unable to get disconnected connector id "'.concat(e,'" for namespace "').concat(t,'"'))}return!1},getTransactionsCache(){try{const e=a.Ud.getItem(a.Ws.HISTORY_TRANSACTIONS_CACHE);return e?JSON.parse(e):{}}catch(e){console.info("Unable to get transactions cache")}return{}},getTransactionsCacheForAddress(e){let{address:t,chainId:n=""}=e;try{var i;const e=null===(i=c.getTransactionsCache()[t])||void 0===i?void 0:i[n];if(e&&!this.isCacheExpired(e.timestamp,this.cacheExpiry.transactionsHistory)
2)return e.transactions;c.removeTransactionsCache({address:t,chainId:n})}catch(s){console.info("Unable to get transactions cache")}},updateTransactionsCache(e){let{address:t,chainId:n="",timestamp:i,transactions:s}=e;try{const e=c.getTransactionsCache();e[t]=(0,r.A)((0,r.A)({},e[t]),{},{[n]:{timestamp:i,transactions:s}}),a.Ud.setItem(a.Ws.HISTORY_TRANSACTIONS_CACHE,JSON.stringify(e))}catch(o){console.info("Unable to update transactions cache",{address:t,chainId:n,timestamp:i,transactions:s})}},removeTransactionsCache(e){let{address:t,chainId:n}=e;try{const e=c.getTransactionsCache(),o=(null===e||void 0===e?void 0:e[t])||{},{[n]:l}=o,d=(0,i.A)(o,[n].map(s.A));a.Ud.setItem(a.Ws.HISTORY_TRANSACTIONS_CACHE,JSON.stringify((0,r.A)((0,r.A)({},e),{},{[t]:d})))}catch(o){console.info("Unable to remove transactions cache",{address:t,chainId:n})}},getTokenPriceCache(){try{const e=a.Ud.getItem(a.Ws.TOKEN_PRICE_CACHE);return e?JSON.parse(e):{}}catch(e){console.info("Unable to get token price cache")}return{}},getTokenPriceCacheForAddresses(e){try{const t=c.getTokenPriceCache()[e.join(",")];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.tokenPrice))return t.tokenPrice;c.removeTokenPriceCache(e)}catch(t){console.info("Unable to get token price cache for addresses",e)}},updateTokenPriceCache(e){try{const t=c.getTokenPriceCache();t[e.addresses.join(",")]={timestamp:e.timestamp,tokenPrice:e.tokenPrice},a.Ud.setItem(a.Ws.TOKEN_PRICE_CACHE,JSON.stringify(t))}catch(t){console.info("Unable to update token price cache",e)}},removeTokenPriceCache(e){try{const t=c.getTokenPriceCache();a.Ud.setItem(a.Ws.TOKEN_PRICE_CACHE,JSON.stringify((0,r.A)((0,r.A)({},t),{},{[e.join(",")]:void 0})))}catch(t){console.info("Unable to remove token price cache",e)}},getLatestAppKitVersion(){try{const e=this.getLatestAppKitVersionCache(),t=null===e||void 0===e?void 0:e.version;return t&&!this.isCacheExpired(e.timestamp,this.cacheExpiry.latestAppKitVersion)?t:void 0}catch(e){console.info("Unable to get latest AppKit version")}},getLatestAppKitVersionCache(){try{const e=a.Ud.getItem(a.Ws.LATEST_APPKIT_VERSION);return e?JSON.parse(e):{}}catch(e){console.info("Unable to get latest AppKit version cache")}return{}},updateLatestAppKitVersion(e){try{const t=c.getLatestAppKitVersionCache();t.timestamp=e.timestamp,t.version=e.version,a.Ud.setItem(a.Ws.LATEST_APPKIT_VERSION,JSON.stringify(t))}catch(t){console.info("Unable to update latest AppKit version on local storage",e)}}}},84470:(e,t,n)=>{"use strict";n.d(t,{O:()=>r,W:()=>o});var i=n(84873),s=n(10232);const r={PHANTOM:{id:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",url:"https://phantom.app"},SOLFLARE:{id:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",url:"https://solflare.com"},COINBASE:{id:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",url:"https://go.cb-w.com"},BINANCE:{id:"2fafea35bb471d22889ccb49c08d99dd0a18a37982602c33f696a5723934ba25",appId:"yFK5FCqYprrXDiVFbhyRx7",deeplink:"bnc://app.binance.com/mp/app",url:"https://app.binance.com/en/download"}},o={handleMobileDeeplinkRedirect(e,t){const n=window.location.href,o=encodeURIComponent(n);if(e===r.PHANTOM.id&&!("phantom"in window)){const e=n.startsWith("https")?"https":"http",t=n.split("/")[2],i=encodeURIComponent("".concat(e,"://").concat(t));window.location.href="".concat(r.PHANTOM.url,"/ul/browse/").concat(o,"?ref=").concat(i)}if(e!==r.SOLFLARE.id||"solflare"in window||(window.location.href="".concat(r.SOLFLARE.url,"/ul/v1/browse/").concat(o,"?ref=").concat(o)),t===i.o.CHAIN.SOLANA&&(e!==r.COINBASE.id||"coinbaseSolana"in window||(window.location.href="".concat(r.COINBASE.url,"/dapp?cb_url=").concat(o))),t===i.o.CHAIN.BITCOIN&&e===r.BINANCE.id&&!("binancew3w"in window)){var a;const e=s.W.state.activeCaipNetwork,t=window.btoa("/pages/browser/index"),n=window.btoa("url=".concat(o,"&defaultChainId=").concat(null!==(a=null===e||void 0===e?void 0:e.id)&&void 0!==a?a:1)),i=new URL(r.BINANCE.deeplink);i.searchParams.set("appId",r.BINANCE.appId),i.searchParams.set("startPagePath",t),i.searchParams.set("startPageQuery",n);const c=new URL(r.BINANCE.url);c.searchParams.set("_dp",window.btoa(i.toString())),window.location.href=c.toString()}}}},84873:(e,t,n)=>{"use strict";n.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"}
2,CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin",cosmos:"Cosmos",sui:"Sui",stacks:"Stacks"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],SOLANA_SPL_TOKEN_ADDRESSES:{SOL:"So11111111111111111111111111111111111111112"},HTTP_STATUS_CODES:{SERVER_ERROR:500,TOO_MANY_REQUESTS:429,SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network",SECURE_SITE_SDK_ORIGIN:("undefined"!==typeof process?{NODE_ENV:"production",PUBLIC_URL:".",WDS_SOCKET_HOST:void 0,WDS_SOCKET_PATH:void 0,WDS_SOCKET_PORT:void 0,FAST_REFRESH:!0}.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",REMOTE_FEATURES_ALERTS:{MULTI_WALLET_NOT_ENABLED:{DEFAULT:{displayMessage:"Multi-Wallet Not Enabled",debugMessage:"Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com."},CONNECTIONS_HOOK:{displayMessage:"Multi-Wallet Not Enabled",debugMessage:"Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com to use the useAppKitConnections hook."},CONNECTION_HOOK:{displayMessage:"Multi-Wallet Not Enabled",debugMessage:"Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com to use the useAppKitConnection hook."}}},IS_DEVELOPMENT:"undefined"!==typeof process&&!1}},86114:(e,t,n)=>{"use strict";n.d(t,{JX:()=>E,RF:()=>b,W5:()=>I,ds:()=>C,fD:()=>N});var i,s,r,o,a,c,l,d=n(14640),h=n(89217),u=n(88690);let p,f,g,v,m;const y={"KHTeka-500-woff2":"https://fonts.reown.com/KHTeka-Medium.woff2","KHTeka-400-woff2":"https://fonts.reown.com/KHTeka-Regular.woff2","KHTeka-300-woff2":"https://fonts.reown.com/KHTeka-Light.woff2","KHTekaMono-400-woff2":"https://fonts.reown.com/KHTekaMono-Regular.woff2","KHTeka-500-woff":"https://fonts.reown.com/KHTeka-Light.woff","KHTeka-400-woff":"https://fonts.reown.com/KHTeka-Regular.woff","KHTeka-300-woff":"https://fonts.reown.com/KHTeka-Light.woff","KHTekaMono-400-woff":"https://fonts.reown.com/KHTekaMono-Regular.woff"};function w(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"dark";p&&document.head.removeChild(p),p=document.createElement("style"),p.textContent=u.CV.createRootStyles(t,e),document.head.appendChild(p)}function b(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"dark";if(m=e,f=document.createElement("style"),g=document.createElement("style"),v=document.createElement("style"),f.textContent=A(e).core.cssText,g.textContent=A(e).dark.cssText,v.textContent=A(e).light.cssText,document.head.appendChild(f),document.head.appendChild(g),document.head.appendChild(v),w(e,t),E(t),null===e||void 0===e||!e["--w3m-font-family"])for(const[n,i]of Object.entries(y)){const e=document.createElement("link");e.rel="preload",e.href=i,e.as="font",e.type=n.includes("woff2")?"font/woff2":"font/woff",e.crossOrigin="anonymous",document.head.appendChild(e)}E(t)}function E(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"dark";g&&v&&p&&("light"===e?(w(m,e),g.removeAttribute("media"),v.media="enabled"):(w(m,e),v.removeAttribute("media"),g.media="enabled"))}function C(e){if(m=e,f&&g&&v&&(f.textContent=A(e).core.cssText,g.textContent=A(e).dark.cssText,v.textContent=A(e).light.cssText,null!==e&&void 0!==e&&e["--w3m-font-family"])){var t,n,i;const s=e["--w3m-font-family"];f.textContent=null===(t=f.textContent)||void 0===t?void 0:t.replace("font-family: KHTeka","font-family: ".concat(s)),g.textContent=null===(n=g.textContent)||void 0===n?void 0:n.replace("font-family: KHTeka","font-family: ".concat(s)),v.textContent=null===(i=v.textContent)||void 0===i?void 0:i.replace("font-family: KHTeka","font-family: ".concat(s))}if(p){var s;w(e,"enabled"===(null===(s=v)||void 0===s?void 0:s.media)?"light":"dark")}}function A(e){const t=Boolean(null===e||void 0===e?void 0:e["--w3m-font-family"]);return{core:(0,h.AH)(i||(i=(0,d.A)(["\n ","\n\n @keyframes w3m-shake {\n 0% {\n transform: scale(1) rotate(0deg);\n }\n 20% {\n transform: scale(1) rotate(-1deg);\n }\n 40% {\n transform: scale(1) rotate(1.5deg);\n }\n 60% {\n transform: scale(1) rotate(-1.5deg);\n }\n 80% {\n transform: scale(1) rotate(1deg);\n }\n 100% {\n transform: scale(1) rotate(0deg);\n }\n }\n @keyframes w3m-iframe-fade-out {\n 0% {\n opacity: 1;\n }\n 100% {\n opacity: 0;\n }\n }\n @keyframes w3m-iframe-zoom-in {\n 0% {\n transform: translateY(50px);\n opacity: 0;\n }\n 100% {\n transform: translateY(0px);\n opacity: 1;\n }\n }\n @keyframes w3m-iframe-zoom-in-mobile {\n 0% {\n transform: scale(0.95);\n opacity: 0;\n }\n 100% {\n transform: scale(1);\n opacity: 1;\n }\n }\n :root {\n --apkt-modal-width: 370px;\n\n --apkt-visual-size-inherit: inherit;\n --apkt-visual-size-sm: 40px;\n --apkt-visual-size-md: 55px;\n --apkt-visual-size-lg: 80px;\n\n --apkt-path-network-sm: path(\n 'M15.4 2.1a5.21 5.21 0 0 1 5.2 0l11.61 6.7a5.21 5.21 0 0 1 2.61 4.52v13.4c0 1.87-1 3.59-2.6 4.52l-11.
261 6.7c-1.62.93-3.6.93-5.22 0l-11.6-6.7a5.21 5.21 0 0 1-2.61-4.51v-13.4c0-1.87 1-3.6 2.6-4.52L15.4 2.1Z'\n );\n\n --apkt-path-network-md: path(\n 'M43.4605 10.7248L28.0485 1.61089C25.5438 0.129705 22.4562 0.129705 19.9515 1.61088L4.53951 10.7248C2.03626 12.2051 0.5 14.9365 0.5 17.886V36.1139C0.5 39.0635 2.03626 41.7949 4.53951 43.2752L19.9515 52.3891C22.4562 53.8703 25.5438 53.8703 28.0485 52.3891L43.4605 43.2752C45.9637 41.7949 47.5 39.0635 47.5 36.114V17.8861C47.5 14.9365 45.9637 12.2051 43.4605 10.7248Z'\n );\n\n --apkt-path-network-lg: path(\n 'M78.3244 18.926L50.1808 2.45078C45.7376 -0.150261 40.2624 -0.150262 35.8192 2.45078L7.6756 18.926C3.23322 21.5266 0.5 26.3301 0.5 31.5248V64.4752C0.5 69.6699 3.23322 74.4734 7.6756 77.074L35.8192 93.5492C40.2624 96.1503 45.7376 96.1503 50.1808 93.5492L78.3244 77.074C82.7668 74.4734 85.5 69.6699 85.5 64.4752V31.5248C85.5 26.3301 82.7668 21.5266 78.3244 18.926Z'\n );\n\n --apkt-width-network-sm: 36px;\n --apkt-width-network-md: 48px;\n --apkt-width-network-lg: 86px;\n\n --apkt-duration-dynamic: 0ms;\n --apkt-height-network-sm: 40px;\n --apkt-height-network-md: 54px;\n --apkt-height-network-lg: 96px;\n }\n "])),t?(0,h.AH)(s||(s=(0,d.A)([""]))):(0,h.AH)(r||(r=(0,d.A)(["\n @font-face {\n font-family: 'KHTeka';\n src:\n url(",") format('woff2'),\n url(",") format('woff');\n font-weight: 400;\n font-style: normal;\n font-display: swap;\n }\n\n @font-face {\n font-family: 'KHTeka';\n src:\n url(",") format('woff2'),\n url(",") format('woff');\n font-weight: 300;\n font-style: normal;\n }\n\n @font-face {\n font-family: 'KHTekaMono';\n src:\n url(",") format('woff2'),\n url(",") format('woff');\n font-weight: 400;\n font-style: normal;\n }\n\n @font-face {\n font-family: 'KHTeka';\n src:\n url(",") format('woff2'),\n url(",") format('woff');\n font-weight: 400;\n font-style: normal;\n }\n "])),(0,h.iz)(y["KHTeka-400-woff2"]),(0,h.iz)(y["KHTeka-400-woff"]),(0,h.iz)(y["KHTeka-300-woff2"]),(0,h.iz)(y["KHTeka-300-woff"]),(0,h.iz)(y["KHTekaMono-400-woff2"]),(0,h.iz)(y["KHTekaMono-400-woff"]),(0,h.iz)(y["KHTeka-400-woff2"]),(0,h.iz)(y["KHTeka-400-woff"]))),dark:(0,h.AH)(o||(o=(0,d.A)(["\n :root {\n }\n "]))),light:(0,h.AH)(a||(a=(0,d.A)(["\n :root {\n }\n "])))}}const I=(0,h.AH)(c||(c=(0,d.A)(["\n div,\n span,\n iframe,\n a,\n img,\n form,\n button,\n label,\n *::after,\n *::before {\n margin: 0;\n padding: 0;\n box-sizing: border-box;\n font-style: normal;\n text-rendering: optimizeSpeed;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n -webkit-tap-highlight-color: transparent;\n backface-visibility: hidden;\n }\n\n :host {\n font-family: var(--apkt-fontFamily-regular);\n }\n"]))),N=(0,h.AH)(l||(l=(0,d.A)(["\n button,\n a {\n cursor: pointer;\n display: flex;\n justify-content: center;
2\n align-items: center;\n position: relative;\n\n will-change: background-color, color, border, box-shadow, width, height, transform, opacity;\n outline: none;\n border: none;\n text-decoration: none;\n transition:\n background-color var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),\n color var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),\n border var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),\n box-shadow var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),\n width var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),\n height var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),\n transform var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),\n opacity var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),\n scale var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),\n border-radius var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2);\n will-change:\n background-color, color, border, box-shadow, width, height, transform, opacity, scale,\n border-radius;\n }\n\n a:active:not([disabled]),\n button:active:not([disabled]) {\n scale: 0.975;\n transform-origin: center;\n }\n\n button:disabled {\n cursor: default;\n }\n\n input {\n border: none;\n outline: none;\n appearance: none;\n }\n"])))},87931:(e,t,n)=>{"use strict";n.d(t,{T:()=>g});var i=n(24107),s=n(18539),r=n(78256),o=n(78854),a=n(70689),c=n(81828),l=n(10232),d=n(46443),h=n(62463);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=o.w.getBlockchainApiUrl(),f=(0,s.BX)({clientId:null,api:new a.Z({baseUrl:p,clientId:null}),supportedChains:{http:[],ws:[]}}),g={state:f,async get(e){const{st:t,sv:n}=g.getSdkProperties(),s=d.H.state.projectId,r=(0,i.A)((0,i.A)({},e.params||{}),{},{st:t,sv:n,projectId:s});return f.api.get((0,i.A)((0,i.A)({},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(t){return!1}return f.supportedChains.http.includes(e)},async getSupportedNetworks(){try{const e=await g.get({path:"v1/supported-chains"});return f.supportedChains=e,e}catch(e){return f.supportedChains}},async fetchIdentity(e){let{address:t}=e;const n=c.i.getIdentityFromCacheForAddress(t);if(n)return n;const i=await g.get({path:"/v1/identity/".concat(t),params:{sender:l.W.state.activeCaipAddress?o.w.getPlainAddress(l.W.state.activeCaipAddress):void 0}});return c.i.updateIdentityCache({address:t,identity:i,timestamp:Date.now()}),i},async fetchTransactions(e){var t;let{account:n,cursor:i,signal:s,cache:r,chainId:o}=e;if(!await g.isNetworkSupported(null===(t=l.W.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId))return{data:[],next:void 0};const a=c.i.getTransactionsCacheForAddress({address:n,chainId:o});if(a)return a;const d=await g.get({path:"/v1/account/".concat(n,"/history"),params:{cursor:i,chainId:o},signal:s,cache:r});return c.i.updateTransactionsCache({address:n,chainId:o,timestamp:Date.now(),transactions:d}),d},async fetchSwapQuote(e){var t;let{amount:n,userAddress:i,from:s,to:r,gasPrice:o}=e;return await g.isNetworkSupported(null===(t=l.W.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId)?g.get({path:"/v1/convert/quotes",headers:{"Content-Type":"application/json"},params:{amount:n,userAddress:i,from:s,to:r,gasPrice:o}}):{quotes:[]}},async fetchSwapTokens(e){var t;let{chainId:n}=e;return await g.isNetworkSupported(null===(t=l.W.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId)?g.get({path:"/v1/convert/tokens",params:{chainId:n}}):{tokens:[]}},async fetchTokenPrice(e){var t;let{addresses:n}=e;if(!await g.isNetworkSupported(null===(t=l.W.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId))return{fungibles:[]};const i=c.i.getTokenPriceCacheForAddresses(n);if(i)return i;const s=await f.api.post({path:"/v1/fungible/price",body:{currency:"usd",addresses:n,projectId:d.H.state.projectId},headers:{"Content-Type":"application/json"}});return c.i.updateTokenPriceCache({addresses:n,timestamp:Date.now(),tokenPrice:s}),s},async fetchSwapAllowance(e){var t;let{tokenAddress:n,userAddress:i}=e;return await g.isNetworkSupported(null===(t=l.W.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId)?g.get({path:"/v1/convert/allowance",params:{tokenAddress:n,userAddress:i},headers:{"Content-Type":"application/json"}}):{allowance:"0"}},async fetchGasPrice(e){var t;let{chainId:n}=e;const{st:i,sv:s}=g.getSdkProperties();if(!await g.isNetworkSupported(null===(t=l.W.state.activeCaipNetwork)||void 0===t?void 0:t.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:n,st:i,sv:s}})},async generateSwapCalldata(e){var t;let{amount:n,from:i,to:s,userAddress:o,disableEstimate:a}=e;if(!await g.isNetworkSupported(null===(t=l.W.state.activeCaipNetwork)||void 0===t?void 0:t.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:n,eip155:{slippage:r.oU.CONVERT_SLIPPAGE_TOLERANCE},projectId:d.H.state.projectId,from:i,to:s,userAddress:o,disableEstimate:a}})},async generateApproveCalldata(e){var t;let{from:n,to:i,userAddress:s}=e;const{st:r,sv:o}=g.getSdkProperties();if(!await g.isNetworkSupported(null===(t=l.W.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId))throw new Error("Network not supported for Swaps");return g.get({path:"/v1/convert/build-approve",headers:{"Content-Type":"application/json"},params:{userAddress:s,from:n,to:i,st:r,sv:o}})},async getBalance(e,t,n){var i;const{st:s,sv:r}=g.getSdkProperties();if(!await g.isNetworkSupported(null===(i=l.W.state.activeCaipNetwork)||void 0===i?void 0:i.caipNetworkId))return h.P.showError("Token Balance Unavailable"),{balances:[]};const o="".concat(t,":").concat(e),a=c.i.getBalanceCacheForCaipAddress(o);if(a)return a;const d=await g.get({path:"/v1/account/".concat(e,"/balance"),params:{currency:"usd",chainId:t,forceUpdate:n,st:s,sv:r}});return c.i.updateBalanceCache({caipAddress:o,balance:d,timestamp:Date.now()}),d},async lookupEnsName(e){var t;return await g.isNetworkSupported(null===(t=l.W.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId)?g.get({path:"/v1/profile/account/".concat(e),params:{apiVersion:"2"}}):{addresses:{},attributes:[]}},async reverseLookupEnsName(e){var t,n;let{address:i}=e;if(!await g.isNetworkSupported(null===(t=l.W.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId))return[];const s=null===(n=l.W.getAccountData())||void 0===n?void 0:n.address;return g.get({path:"/v1/profile/reverse/".concat(i),params:{sender:s,apiVersion:"2"}})},async getEnsNameSuggestions(e){var t;return await g.isNetworkSupported(null===(t=l.W.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId)?g.get({path:"/v1/profile/suggestions/".concat(e),params:{zone:"reown.id"}}):{suggestions:[]}},async registerEnsName(e){var t;let{coinType:n,address:i,message:s,signature:r}=e;return await g.isNetworkSupported(null===(t=l.W.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId)?f.api.post({path:"/v1/profile/account",body:{coin_type:n,address:i,message:s,signature:r},headers:{"Content-Type":"application/json"}}):{success:!1}},async generateOnRampURL(e){var t;let{destinationWallets:n,partnerUserId:i,defaultNetwork:s,purchaseAmount:r,paymentAmount:o}=e;if(!await g.isNetworkSupported(null===(t=l.W.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId))return"";return(await f.api.post({path:"/v1/generators/onrampurl",params:{projectId:d.H.state.projectId},body:{destinationWallets:n,defaultNetwork:s,partnerUserId:i,defaultExperience:"buy",presetCryptoAmount:r,presetFiatAmount:o}})).url},async getOnrampOptions(){var e;if(!await g.isNetworkSupported(null===(e=l.W.state.activeCaipNetwork)||void 0===e?void 0:e.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await g.get({path:"/v1/onramp/options"})}catch(t){return u}},async getOnrampQuote(e){let{purchaseCurrency:t,paymentCurrency:n,amount:i,network:s}=e;try{var r;if(!await g.isNetworkSupported(null===(r=l.W.state.activeCaipNetwork)||void 0===r?void 0:r.caipNetworkId))return null;return await f.api.post({path:"/v1/onramp/quote",params:{projectId:d.H.state.projectId},body:{purchaseCurrency:t,paymentCurrency:n,amount:i,network:s}})}catch(o){return{networkFee:{amount:i,currency:n.id},paymentSubtotal:{amount:i,currency:n.id},paymentTotal:{amount:i,currency:n.id},purchaseAmount:{amount:i,currency:n.id},quoteId:"mocked-quote-id"}}},async getSmartSessions(e){var t;return await g.isNetworkSupported(null===(t=l.W.state.activeCaipNetwork)||void 0===t?void 0:t.caipNetworkId)?g.get({path:"/v1/sessions/".concat(e)}):[]},async revokeSmartSession(e,t,n){var i;return await g.isNetworkSupported(null===(i=l.W.state.activeCaipNetwork)||void 0===i?void 0:i.caipNetworkId)?f.api.post({path:"/v1/sessions/".concat(e,"/revoke"),params:{projectId:d.H.state.projectId},body:{pci:t,signature:n}}):{success:!1}},setClientId(e){f.clientId=e,f.api=new a.Z({baseUrl:p,clientId:e})}}},88690:(e,t,n)=>{"use strict";n.d(t,{AH:()=>l,CV:()=>a,f:()=>c});var i=n(24107),s=n(89217),r=n(65073);const o="--apkt",a={createCSSVariables(e){const t={},n={};return function e(t,n){let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";for(const[s,r]of Object.entries(t)){const t=i?"".concat(i,"-").concat(s):s;r&&"object"===typeof r&&Object.keys(r).length?(n[s]={},e(r,n[s],t)):"string"===typeof r&&(n[s]="".concat(o,"-").concat(t))}}(e,t),function e(t,n){for(const[i,s]of Object.entries(t))s&&"object"===typeof s?(n[i]={},e(s,n[i])):"string"===typeof s&&(n[i]="var(".concat(s,")"))}(t,n),{cssVariables:t,cssVariablesVarPrefix:n}},assignCSSVariables(e,t){const n={};return function e(t,i,s){for(const[r,a]of Object.entries(t)){const t=s?"".concat(s,"-").concat(r):r,c=i[r];
2a&&"object"===typeof a?e(a,c,t):"string"===typeof c&&(n["".concat(o,"-").concat(t)]=c)}}(e,t),n},createRootStyles(e,t){const n=(0,i.A)((0,i.A)({},r.R7),{},{tokens:(0,i.A)((0,i.A)({},r.R7.tokens),{},{theme:"light"===e?r.LU.light:r.LU.dark})}),{cssVariables:s}=a.createCSSVariables(n),o=a.assignCSSVariables(s,n),c=a.generateW3MVariables(t),l=a.generateW3MOverrides(t),d=a.generateScaledVariables(t),h=a.generateBaseVariables(o),u=(0,i.A)((0,i.A)((0,i.A)((0,i.A)((0,i.A)({},o),h),c),l),d),p=a.applyColorMixToVariables(t,u),f=(0,i.A)((0,i.A)({},u),p),g=Object.entries(f).map(e=>{let[t,n]=e;return"".concat(t,":").concat(n.replace("/[:;{}</>]/g",""),";")}).join("");return":root {".concat(g,"}")},generateW3MVariables(e){if(!e)return{};const t={};return t["--w3m-font-family"]=e["--w3m-font-family"]||"KHTeka",t["--w3m-accent"]=e["--w3m-accent"]||"#0988F0",t["--w3m-color-mix"]=e["--w3m-color-mix"]||"#000",t["--w3m-color-mix-strength"]="".concat(e["--w3m-color-mix-strength"]||0,"%"),t["--w3m-font-size-master"]=e["--w3m-font-size-master"]||"10px",t["--w3m-border-radius-master"]=e["--w3m-border-radius-master"]||"4px",t},generateW3MOverrides(e){if(!e)return{};const t={};if(e["--w3m-accent"]){const n=e["--w3m-accent"];t["--apkt-tokens-core-iconAccentPrimary"]=n,t["--apkt-tokens-core-borderAccentPrimary"]=n,t["--apkt-tokens-core-textAccentPrimary"]=n,t["--apkt-tokens-core-backgroundAccentPrimary"]=n}return e["--w3m-font-family"]&&(t["--apkt-fontFamily-regular"]=e["--w3m-font-family"]),e["--w3m-z-index"]&&(t["--apkt-tokens-core-zIndex"]="".concat(e["--w3m-z-index"])),t},generateScaledVariables(e){if(!e)return{};const t={};if(e["--w3m-font-size-master"]){const n=parseFloat(e["--w3m-font-size-master"].replace("px",""));t["--apkt-textSize-h1"]="".concat(5*Number(n),"px"),t["--apkt-textSize-h2"]="".concat(4.4*Number(n),"px"),t["--apkt-textSize-h3"]="".concat(3.8*Number(n),"px"),t["--apkt-textSize-h4"]="".concat(3.2*Number(n),"px"),t["--apkt-textSize-h5"]="".concat(2.6*Number(n),"px"),t["--apkt-textSize-h6"]="".concat(2*Number(n),"px"),t["--apkt-textSize-large"]="".concat(1.6*Number(n),"px"),t["--apkt-textSize-medium"]="".concat(1.4*Number(n),"px"),t["--apkt-textSize-small"]="".concat(1.2*Number(n),"px")}if(e["--w3m-border-radius-master"]){const n=parseFloat(e["--w3m-border-radius-master"].replace("px",""));t["--apkt-borderRadius-1"]="".concat(Number(n),"px"),t["--apkt-borderRadius-2"]="".concat(2*Number(n),"px"),t["--apkt-borderRadius-3"]="".concat(3*Number(n),"px"),t["--apkt-borderRadius-4"]="".concat(4*Number(n),"px"),t["--apkt-borderRadius-5"]="".concat(5*Number(n),"px"),t["--apkt-borderRadius-6"]="".concat(6*Number(n),"px"),t["--apkt-borderRadius-8"]="".concat(8*Number(n),"px"),t["--apkt-borderRadius-16"]="".concat(16*Number(n),"px"),t["--apkt-borderRadius-20"]="".concat(20*Number(n),"px"),t["--apkt-borderRadius-32"]="".concat(32*Number(n),"px"),t["--apkt-borderRadius-64"]="".concat(64*Number(n),"px"),t["--apkt-borderRadius-128"]="".concat(128*Number(n),"px")}return t},generateColorMixCSS(e,t){if(null===e||void 0===e||!e["--w3m-color-mix"]||!e["--w3m-color-mix-strength"])return"";const n=e["--w3m-color-mix"],i=e["--w3m-color-mix-strength"];if(!i||0===i)return"";const s=Object.keys(t||{}).filter(e=>{const t=e.includes("-tokens-core-background")||e.includes("-tokens-core-text")||e.includes("-tokens-core-border")||e.includes("-tokens-core-foreground")||e.includes("-tokens-core-icon")||e.includes("-tokens-theme-background")||e.includes("-tokens-theme-text")||e.includes("-tokens-theme-border")||e.includes("-tokens-theme-foreground")||e.includes("-tokens-theme-icon"),n=e.includes("-borderRadius-")||e.includes("-spacing-")||e.includes("-textSize-")||e.includes("-fontFamily-")||e.includes("-fontWeight-")||e.includes("-typography-")||e.includes("-duration-")||e.includes("-ease-")||e.includes("-path-")||e.includes("-width-")||e.includes("-height-")||e.includes("-visual-size-")||e.includes("-modal-width")||e.includes("-cover");return t&&!n});if(0===s.length)return"";const r=s.map(e=>{const s=(null===t||void 0===t?void 0:t[e])||"";return s.includes("color-mix")||s.startsWith("#")||s.startsWith("rgb")?"".concat(e,": color-mix(in srgb, ").concat(n," ").concat(i,"%, ").concat(s,");"):"".concat(e,": color-mix(in srgb, ").concat(n," ").concat(i,"%, var(").concat(e,"-base, ").concat(s,"));")}).join("");return" @supports (background: color-mix(in srgb, white 50%, black)) {\n :root {\n ".concat(r,"\n }\n }")},generateBaseVariables(e){const t={},n=e["--apkt-tokens-theme-backgroundPrimary"];n&&(t["--apkt-tokens-theme-backgroundPrimary-base"]=n);const i=e["--apkt-tokens-core-backgroundAccentPrimary"];return i&&(t["--apkt-tokens-core-backgroundAccentPrimary-base"]=i),t},applyColorMixToVariables(e,t){const n={};if(null!==t&&void 0!==t&&t["--apkt-tokens-theme-backgroundPrimary"]&&(n["--apkt-tokens-theme-backgroundPrimary"]="var(--apkt-tokens-theme-backgroundPrimary-base)"),null!==t&&void 0!==t&&t["--apkt-tokens-core-backgroundAccentPrimary"]&&(n["--apkt-tokens-core-backgroundAccentPrimary"]="var(--apkt-tokens-core-backgroundAccentPrimary-base)"),null===e||void 0===e||!e["--w3m-color-mix"]||!e["--w3m-color-mix-strength"])return n;const i=e["--w3m-color-mix"],s=e["--w3m-color-mix-strength"];if(!s||0===s)return n;const r=Object.keys(t||{}).filter(e=>{const t=e.includes("-tokens-core-background")||e.includes("-tokens-core-text")||e.includes("-tokens-core-border")||e.includes("-tokens-core-foreground")||e.includes("-tokens-core-icon")||e.includes("-tokens-theme-background")||e.includes("-tokens-theme-text")||e.includes("-tokens-theme-border")||e.includes("-tokens-theme-foreground")||e.includes("-tokens-theme-icon")||e.includes("-tokens-theme-overlay"),n=e.includes("-borderRadius-")||e.includes("-spacing-")||e.includes("-textSize-")||e.includes("-fontFamily-")||e.includes("-fontWeight-")||e.includes("-typography-")||e.includes("-duration-")||e.includes("-ease-")||e.includes("-path-")||e.includes("-width-")||e.includes("-height-")||e.includes("-visual-size-")||e.includes("-modal-width")||e.includes("-cover");return t&&!n});
2return 0===r.length||r.forEach(e=>{const r=(null===t||void 0===t?void 0:t[e])||"";e.endsWith("-base")||("--apkt-tokens-theme-backgroundPrimary"===e||"--apkt-tokens-core-backgroundAccentPrimary"===e?n[e]="color-mix(in srgb, ".concat(i," ").concat(s,"%, var(").concat(e,"-base))"):r.includes("color-mix")||r.startsWith("#")||r.startsWith("rgb")?n[e]="color-mix(in srgb, ".concat(i," ").concat(s,"%, ").concat(r,")"):n[e]="color-mix(in srgb, ".concat(i," ").concat(s,"%, var(").concat(e,"-base, ").concat(r,"))"))}),n}},{cssVariablesVarPrefix:c}=a.createCSSVariables(r.R7);function l(e){for(var t=arguments.length,n=new Array(t>1?t-1:0),i=1;i<t;i++)n[i-1]=arguments[i];return(0,s.AH)(e,...n.map(e=>"function"===typeof e?(0,s.iz)(e(c)):(0,s.iz)(e)))}},89217:(e,t,n)=>{"use strict";n.d(t,{WF:()=>c,AH:()=>r.AH,qy:()=>o.qy,JW:()=>o.JW,iz:()=>r.iz});var i,s,r=n(35258),o=n(80846);const a=globalThis;class c extends r.mN{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e,t;const n=super.createRenderRoot();return null!==(t=(e=this.renderOptions).renderBefore)&&void 0!==t||(e.renderBefore=n.firstChild),n}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=(0,o.XX)(t,this.renderRoot,this.renderOptions)}connectedCallback(){var e;super.connectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!0)}disconnectedCallback(){var e;super.disconnectedCallback(),null===(e=this._$Do)||void 0===e||e.setConnected(!1)}render(){return o.c0}}c._$litElement$=!0,c.finalized=!0,null===(i=a.litElementHydrateSupport)||void 0===i||i.call(a,{LitElement:c});const l=a.litElementPolyfillSupport;null===l||void 0===l||l({LitElement:c});(null!==(s=a.litElementVersions)&&void 0!==s?s:a.litElementVersions=[]).push("4.2.1")},89386:(e,t,n)=>{"use strict";n.d(t,{y:()=>c});var i=n(84873),s=n(10232),r=n(47482),o=n(81828),a=n(27142);const c={getCaipTokens(e){if(!e)return;const t={};return Object.entries(e).forEach(e=>{let[n,i]=e;t["".concat(a.o.EIP155,":").concat(n)]=i}),t},isLowerCaseMatch:(e,t)=>(null===e||void 0===e?void 0:e.toLowerCase())===(null===t||void 0===t?void 0:t.toLowerCase()),getActiveNamespaceConnectedToAuth(){const e=s.W.state.activeChain;return i.o.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(t=>r.a.getConnectorId(t)===i.o.CONNECTOR_ID.AUTH&&t===e)},withRetry(e){let{conditionFn:t,intervalMs:n,maxRetries:i}=e,s=0;return new Promise(e=>{!async function r(){return s+=1,await t()?e(!0):s>=i?e(!1):(setTimeout(r,n),null)}()})},userChainIdToChainNamespace(e){if("number"===typeof e)return i.o.CHAIN.EVM;const[t]=e.split(":");return t},getOtherAuthNamespaces(e){if(!e)return[];return i.o.AUTH_CONNECTOR_SUPPORTED_CHAINS.filter(t=>t!==e)},getConnectorStorageInfo(e,t){var n;const i=null!==(n=o.i.getConnections()[t])&&void 0!==n?n:[];return{hasDisconnected:o.i.isConnectorDisconnected(e,t),hasConnected:i.some(t=>c.isLowerCaseMatch(t.connectorId,e))}}}},92187:(e,t,n)=>{"use strict";n.d(t,{g:()=>f});var i=n(84873),s=n(10232),r=n(50390),o=n(47482),a=n(13033),c=n(46443),l=n(78854),d=n(81828),h=n(29259),u=n(89386),p=n(37159);const f={getConnectorsByType(e,t,n){const{customWallets:i}=c.H.state,s=d.i.getRecentWallets(),r=p.A.filterOutDuplicateWallets(t),o=p.A.filterOutDuplicateWallets(n),a=e.filter(e=>"MULTI_CHAIN"===e.type),l=e.filter(e=>"ANNOUNCED"===e.type),h=e.filter(e=>"INJECTED"===e.type);return{custom:i,recent:s,external:e.filter(e=>"EXTERNAL"===e.type),multiChain:a,announced:l,injected:h,recommended:r,featured:o}},showConnector(e){var t;const n=null===(t=e.info)||void 0===t?void 0:t.rdns,i=Boolean(n)&&a.N.state.excludedWallets.some(e=>Boolean(e.rdns)&&e.rdns===n),s=Boolean(e.name)&&a.N.state.excludedWallets.some(t=>u.y.isLowerCaseMatch(t.name,e.name));if("INJECTED"===e.type){if("Browser Wallet"===e.name){if(!l.w.isMobile())return!1;if(l.w.isMobile()&&!n&&!r.x.checkInstalled())return!1}if(i||s)return!1}return"ANNOUNCED"!==e.type&&"EXTERNAL"!==e.type||!i&&!s},getIsConnectedWithWC:()=>Array.from(s.W.state.chains.values()).some(e=>o.a.getConnectorId(e.namespace)===i.o.CONNECTOR_ID.WALLET_CONNECT),getConnectorTypeOrder(e){var t,n;let{recommended:i,featured:s,custom:r,recent:o,announced:a,injected:l,multiChain:d,external:h,overriddenConnectors:u=(null!==(t=null===(n=c.H.state.features)||void 0===n?void 0:n.connectorTypeOrder)&&void 0!==t?t:[])}=e;const p=[{type:"walletConnect",isEnabled:!0},{type:"recent",isEnabled:o.length>0},{type:"injected",isEnabled:[...l,...a,...d].length>0},{type:"featured",isEnabled:s.length>0},{type:"custom",isEnabled:r&&r.length>0},{type:"external",isEnabled:h.length>0},{type:"recommended",isEnabled:i.length>0}].filter(e=>e.isEnabled),f=new Set(p.map(e=>e.type)),g=u.filter(e=>f.has(e)).map(e=>({type:e,isEnabled:!0})),v=p.filter(e=>{let{type:t}=e;return!g.some(e=>{let{type:n}=e;return n===t})});return Array.from(new Set([...g,...v].map(e=>{let{type:t}=e;return t})))},sortConnectorsByExplorerWallet:e=>[...e].sort((e,t)=>
2{var n,i;return e.explorerWallet&&t.explorerWallet?(null!==(n=e.explorerWallet.order)&&void 0!==n?n:0)-(null!==(i=t.explorerWallet.order)&&void 0!==i?i:0):e.explorerWallet?-1:t.explorerWallet?1:0}),getAuthName(e){let{email:t,socialUsername:n,socialProvider:i}=e;return n?i&&"discord"===i&&n.endsWith("0")?n.slice(0,-1):n:t.length>30?"".concat(t.slice(0,-3),"..."):t},async fetchProviderData(e){try{var t,n;if("Browser Wallet"===e.name&&!l.w.isMobile())return{accounts:[],chainId:void 0};if(e.id===i.o.CONNECTOR_ID.AUTH)return{accounts:[],chainId:void 0};const[s,r]=await Promise.all([null===(t=e.provider)||void 0===t?void 0:t.request({method:"eth_accounts"}),null===(n=e.provider)||void 0===n?void 0:n.request({method:"eth_chainId"}).then(e=>Number(e))]);return{accounts:s,chainId:r}}catch(s){return console.warn("Failed to fetch provider data for ".concat(e.name),s),{accounts:[],chainId:void 0}}},getFilteredCustomWallets(e){const t=d.i.getRecentWallets(),n=o.a.state.connectors.map(e=>{var t;return null===(t=e.info)||void 0===t?void 0:t.rdns}).filter(Boolean),i=t.map(e=>e.rdns).filter(Boolean),s=n.concat(i);if(s.includes("io.metamask.mobile")&&l.w.isMobile()){const e=s.indexOf("io.metamask.mobile");s[e]="io.metamask"}return e.filter(e=>!s.includes(String(null===e||void 0===e?void 0:e.rdns)))},hasWalletConnector:e=>o.a.state.connectors.some(t=>t.id===e.id||t.name===e.name),isWalletCompatibleWithCurrentChain(e){const t=s.W.state.activeChain;return!t||!e.chains||e.chains.some(e=>{const n=e.split(":")[0];return t===n})},getFilteredRecentWallets(){return d.i.getRecentWallets().filter(e=>!p.A.isExcluded(e)).filter(e=>!this.hasWalletConnector(e)).filter(e=>this.isWalletCompatibleWithCurrentChain(e))},getCappedRecommendedWallets(e){const{connectors:t}=o.a.state,{customWallets:n,featuredWalletIds:i}=c.H.state,s=t.find(e=>"walletConnect"===e.id),r=t.filter(e=>"INJECTED"===e.type||"ANNOUNCED"===e.type||"MULTI_CHAIN"===e.type);if(!s&&!r.length&&(null===n||void 0===n||!n.length))return[];const a=h.D.isEmailEnabled(),l=h.D.isSocialsEnabled(),d=r.filter(e=>"Browser Wallet"!==e.name),u=((null===i||void 0===i?void 0:i.length)||0)+((null===n||void 0===n?void 0:n.length)||0)+(d.length||0)+(a?1:0)+(l?1:0),f=Math.max(0,4-u);if(f<=0)return[];return p.A.filterOutDuplicateWallets(e).slice(0,f)}}}}]); 3//# sourceMappingURL=2415.dcdabf21.chunk.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.